Selaa lähdekoodia

compiler waits for the MvK to acknowledge that it has processed requests (new interface: 2)

Yentl Van Tendeloo 9 vuotta sitten
vanhempi
commit
4e054564eb

+ 3 - 0
bootstrap/bootstrap.py

@@ -175,6 +175,9 @@ Void function __main():
 \t\telif (interface == 1):
 \t\t\tlog("User entered constructors")
 \t\t\texec(construct_unknown())
+\t\telif (interface == 2):
+\t\t\tlog("Done signalled")
+\t\t\toutput("DONE")
 \t\telif (interface == 3):
 \t\t\tcompilation_manager()
 \t\telse:

+ 2 - 0
integration/utils.py

@@ -46,6 +46,8 @@ def compile_file(mod_filename, filename, mode, proc):
     # Load in the file required
     try:
         timeout_val = 120
+        import random
+        username = str(random.random())
         while 1:
             proc2 = execute("compile", [mod_filename, username, filename, mode], wait=False)
 

+ 9 - 1
interface/HUTN/hutn_compiler/constructors_object_visitor.py

@@ -93,7 +93,15 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
 
         # Finish the symbol table
         urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read()
-        return True
+
+        # Wait for kernel to signal that it finished
+        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '2', "username": self.username}))).read()
+        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username}))).read()
+        v = v.split("=", 2)[2]
+        if v == "DONE":
+            return True
+        else:
+            return False
 
     def visit_definition(self, tree):
         for a in tree.get_children("ID"):

+ 9 - 1
interface/HUTN/hutn_compiler/primitives_object_visitor.py

@@ -69,7 +69,15 @@ class PrimitivesObjectVisitor(PrimitivesVisitor):
 
         # Finish the symbol table
         urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read()
-        return True
+
+        # Wait for kernel to signal that it finished
+        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '2', "username": self.username}))).read()
+        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username}))).read()
+        v = v.split("=", 2)[2]
+        if v == "DONE":
+            return True
+        else:
+            return False
 
     def visit_definition(self, tree):
         for a in tree.get_children("ID"):