Handle anonymous lambdas
authorDavid Kerkeslager <kerkeslager@gmail.com>
Sat, 28 Sep 2019 00:51:51 +0000 (20:51 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Sat, 28 Sep 2019 00:51:51 +0000 (20:51 -0400)
crossplatform_ir_generation.py

index fad6222..7f8a6ec 100644 (file)
@@ -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 = []