From: David Kerkeslager Date: Sat, 28 Sep 2019 00:51:51 +0000 (-0400) Subject: Handle anonymous lambdas X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=909476f4bdcdaea7d5724019d2fb46ec304cc755;p=fur Handle anonymous lambdas --- diff --git a/crossplatform_ir_generation.py b/crossplatform_ir_generation.py index fad6222..7f8a6ec 100644 --- a/crossplatform_ir_generation.py +++ b/crossplatform_ir_generation.py @@ -60,13 +60,18 @@ def generate_integer_literal_expression(counters, expression): return referenced_entry_list, instruction_list +def escape_name(name): + return name.replace('$','$$').replace('_','$') + def generate_lambda_expression(counters, expression): - if expression.name is None or 'lambda' in expression.name.lower(): - import ipdb; ipdb.set_trace() + if expression.name is None: + name = '__lambda__' + else: + name = escape_name(expression.name) - name_counter = counters.get(expression.name, 0) + name_counter = counters.get(name, 0) counters[expression.name] = name_counter + 1 - label = '{}${}'.format(expression.name, name_counter) + label = '{}${}'.format(name, name_counter) referenced_entry_list_list = [] instruction_list_list = []