Get called functions from the environment
authorDavid Kerkeslager <kerkeslager@gmail.com>
Wed, 9 Aug 2017 12:50:43 +0000 (08:50 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Wed, 9 Aug 2017 12:52:42 +0000 (08:52 -0400)
generation.py
templates/program.c
transformation.py

index 86abe96..6bc2384 100644 (file)
@@ -65,7 +65,7 @@ def generate_negation_expression(c_negation_expression):
     )
 
 def generate_function_call(function_call):
-    return '{}({}, {})'.format(
+    return 'Environment_get(environment, "{}").instance.closure({}, {})'.format(
         function_call.name,
         function_call.argument_count,
         # TODO This is just a single item containing a reference to the items list--make that clearer
index f23640a..0d6d947 100644 (file)
@@ -330,6 +330,11 @@ int main(int argc, char** argv)
 {
   Environment* environment = Environment_construct();
 
+  // TODO Use the symbol from SYMBOL_LIST
+  {% for builtin in builtins %}
+  Environment_set(environment, "{{ builtin }}", builtin${{ builtin }});
+  {% endfor %}
+
   {% for statement in statements %}
   {{ statement }}
   {% endfor %}
index 9784c15..b636286 100644 (file)
@@ -270,8 +270,9 @@ def transform_function_call_expression(accumulators, function_call):
         # TODO Check that the builtin is actually callable
         accumulators.builtin_set.add(function_call.function.value)
 
+        # TODO Use the symbol from SYMBOL LIST
         return CFunctionCallExpression(
-            name='builtin${}.instance.closure'.format(function_call.function.value),
+            name=function_call.function.value,
             argument_count=function_call.argument_count,
             argument_items=transform_expression(accumulators, function_call.argument_items),
         )