Remove unecessary pushing/popping for function calls
authorDavid Kerkeslager <kerkeslager@gmail.com>
Wed, 24 Jul 2019 17:12:30 +0000 (13:12 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Wed, 24 Jul 2019 17:12:30 +0000 (13:12 -0400)
generation.py
normalization.py

index e167f25..d855d07 100644 (file)
@@ -56,10 +56,10 @@ def generate_expression(expression):
 
 def generate_function_call(function_call):
     # This gets called twice, so we want to be sure it is efficient and without side effects
 
 def generate_function_call(function_call):
     # This gets called twice, so we want to be sure it is efficient and without side effects
-    assert isinstance(function_call.function_expression, transformation.CVariableExpression)
+    assert isinstance(function_call.function_expression, transformation.CSymbolExpression)
 
     # TODO Check the type of the things being called
 
     # TODO Check the type of the things being called
-    function_expression = generate_variable_expression(function_call.function_expression)
+    function_expression = generate_expression(function_call.function_expression)
     return '{}.instance.closure.call(environmentPool, {}.instance.closure.closed, {}, stack, {}, jump)'.format(
         function_expression,
         function_expression,
     return '{}.instance.closure.call(environmentPool, {}.instance.closure.closed, {}, stack, {}, jump)'.format(
         function_expression,
         function_expression,
index b55d42c..5eef1db 100644 (file)
@@ -280,16 +280,10 @@ def normalize_structure_literal_expression(counter, expression):
 
 
 def normalize_symbol_expression(counter, expression):
 
 
 def normalize_symbol_expression(counter, expression):
-    variable = '${}'.format(counter)
     return (
     return (
-        counter + 1,
-        (
-            NormalVariableInitializationStatement(
-                variable=variable,
-                expression=NormalSymbolExpression(symbol=expression.symbol),
-            ),
-        ),
-        NormalVariableExpression(variable=variable),
+        counter,
+        (),
+        NormalSymbolExpression(symbol=expression.symbol),
     )
 
 def normalize_function_call_expression(counter, expression):
     )
 
 def normalize_function_call_expression(counter, expression):
@@ -315,19 +309,6 @@ def normalize_function_call_expression(counter, expression):
     for ps in function_prestatements:
         prestatements.append(ps)
 
     for ps in function_prestatements:
         prestatements.append(ps)
 
-    if not isinstance(function_expression, NormalVariableExpression):
-        function_variable = '${}'.format(counter)
-
-        prestatements.append(
-            NormalVariableInitializationStatement(
-                variable=function_variable,
-                expression=function_expression,
-            )
-        )
-
-        function_expression = NormalVariableExpression(variable=function_variable)
-        counter += 1
-
     result_variable = '${}'.format(counter)
 
     prestatements.append(
     result_variable = '${}'.format(counter)
 
     prestatements.append(