]> code.kerkeslager.com Git - fur/commitdiff
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 86abe96e79409ad5650cf0345fc4b107a3c2e038..6bc238456429942f4a0288b63f440f7ff5722fa4 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 f23640a79d12bd228cf08f5d29fe68f9c159c64e..0d6d947f06f3b7d5689f34537a3697971c9b1e17 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 9784c155eb72c92fc15a792c14535af2f2439d79..b636286efa8ad2ae0ee052a69b2a3cfa0e1ebc81 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),
         )