Browse Source

Skip "difficult" or mutable functions (consider exec to be mutable for now)

Yentl Van Tendeloo 7 years ago
parent
commit
928fed8dd2
3 changed files with 18 additions and 2 deletions
  1. 1 1
      bootstrap/semi_primitives.alc
  2. 16 0
      kernel/modelverse_kernel/main.py
  3. 1 1
      wrappers/modelverse_SCCD.py

+ 1 - 1
bootstrap/semi_primitives.alc

@@ -89,7 +89,7 @@ Void function interruptable_sleep(a : Float):
 	__sleep(a, True)
 	__sleep(a, True)
 	return!
 	return!
 
 
-Element function exec(first_instr : Element):
+Element mutable function exec(first_instr : Element):
 	// This does very ugly things, so beware!
 	// This does very ugly things, so beware!
 	// Basically, we dynamically construct an if True condition with as body the provided instructions
 	// Basically, we dynamically construct an if True condition with as body the provided instructions
 	// after the if conditional, we append a return of an empty element, as we need a return at the end
 	// after the if conditional, we append a return of an empty element, as we need a return at the end

+ 16 - 0
kernel/modelverse_kernel/main.py

@@ -180,6 +180,19 @@ class ModelverseKernel(object):
                 getattr(source, function_names[i]),
                 getattr(source, function_names[i]),
                 function_names[i])
                 function_names[i])
 
 
+    def read_function(self, inst):
+        initial_instruction = inst
+        suggested_name = self.jit.get_global_name(inst)
+
+        (_, _, is_mutable), = yield [("CALL_ARGS", [self.jit.jit_signature, (inst,)])]
+        if suggested_name is None or is_mutable:
+            print("Ignoring mutable or unreadable: %s" % suggested_name)
+            raise jit.JitCompilationFailedException("FAIL")
+
+        print("Reading function: %s" % suggested_name)
+        inst_type, = yield [("RV", [inst])]
+        print("  %s (%s)" % (inst, inst_type["value"]))
+
     def jit_compile(self, task_root, inst):
     def jit_compile(self, task_root, inst):
         # Try to retrieve the suggested name.
         # Try to retrieve the suggested name.
         suggested_name = self.jit.get_global_name(inst)
         suggested_name = self.jit.get_global_name(inst)
@@ -201,6 +214,9 @@ class ModelverseKernel(object):
             print("KWARGS: " + str(kwargs))
             print("KWARGS: " + str(kwargs))
             #raise primitive_functions.PrimitiveFinished(None)
             #raise primitive_functions.PrimitiveFinished(None)
         """
         """
+
+        yield [("CALL_ARGS", [self.read_function, (inst,)])]
+
         raise jit.JitCompilationFailedException("FAIL")
         raise jit.JitCompilationFailedException("FAIL")
 
 
         raise primitive_functions.PrimitiveFinished(func)
         raise primitive_functions.PrimitiveFinished(func)

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Fri Mar 23 07:16:57 2018
+Date:   Fri Mar 23 07:36:08 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server