Browse Source

Add JIT support for 'access' instructions

jonathanvdc 8 years ago
parent
commit
d981a25a25
1 changed files with 24 additions and 0 deletions
  1. 24 0
      kernel/modelverse_jit/jit.py

+ 24 - 0
kernel/modelverse_jit/jit.py

@@ -491,6 +491,29 @@ class AnalysisState(object):
                 tree_ir.DeleteEdgeInstruction(
                     value_link.create_load())))
 
+    def analyze_access(self, instruction_id):
+        """Tries to analyze the given 'access' instruction."""
+        var_id, = yield [("RD", [instruction_id, "var"])]
+
+        try:
+            gen = self.analyze(var_id)
+            inp = None
+            while True:
+                inp = yield gen.send(inp)
+        except primitive_functions.PrimitiveFinished as ex:
+            var_r = ex.result
+
+        # Accessing a variable is pretty easy. It really just boils
+        # down to reading the value corresponding to the 'value' key
+        # of the variable.
+        #
+        #     value, =  yield [("RD", [returnvalue, "value"])]
+
+        raise primitive_functions.PrimitiveFinished(
+            tree_ir.ReadDictionaryValueInstruction(
+                var_r,
+                tree_ir.LiteralInstruction('value')))
+
     instruction_analyzers = {
         'if' : analyze_if,
         'while' : analyze_while,
@@ -500,6 +523,7 @@ class AnalysisState(object):
         'declare' : analyze_declare,
         'global' : analyze_global,
         'assign' : analyze_assign,
+        'access' : analyze_access,
         'output' : analyze_output
     }