Browse Source

Fixed several problems with loading...

Yentl Van Tendeloo 7 years ago
parent
commit
47928e248a

+ 1 - 1
bootstrap/bootstrap.py

@@ -223,7 +223,7 @@ def bootstrap():
                     # Now link the code with the compilation manager structure
 
                 print("[MERGE]")
-                all_code += "Void function main():\n\tlog(\"INIT\")\n\treturn!"
+                all_code += "Boolean function main(model : Element):\n\tlog(\"INIT\")\n\treturn True!"
                 with open("bootstrap/merged.alm", 'w') as merged:
                     merged.write(all_code)
 

+ 18 - 8
bootstrap/conformance_finding.alc

@@ -19,15 +19,25 @@ Boolean function find_type_mapping(model : Element):
 
 	// 1) remove elements from type mapping that are not in the model or metamodel
 	elems = dict_keys(tm)
-	while (set_len(elems) > 0):
-		elem = set_pop(elems)
-		if (bool_not(dict_in(model["model"], elem))):
-			// Remove the key, as the model does not contain the element anymore
-			dict_delete(tm, elem)
-		else:
-			if (bool_not(dict_in(model["metamodel"]["model"], tm[elem]))):
-				// Remove the key, as the metamodel does not contain the type anymore
+
+	if (set_len(elems) > 1000):
+		// For now, we give up as this takes too much time...
+		return True!
+
+	if (bool_not(set_equality(elems, dict_keys(model["model"])))):
+		// First do a simplified check to see which ones are known to be there
+		while (set_len(elems) > 0):
+			log("Remaining " + cast_string(set_len(elems)))
+			elem = set_pop(elems)
+			if (bool_not(dict_in(model["model"], elem))):
+				// Remove the key, as the model does not contain the element anymore
 				dict_delete(tm, elem)
+			else:
+				if (bool_not(dict_in(model["metamodel"]["model"], tm[elem]))):
+					// Remove the key, as the metamodel does not contain the type anymore
+					dict_delete(tm, elem)
+	else:
+		log("Skipped " + cast_string(set_len(elems)))
 		
 	// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
 	// TODO this must be expanded for other things than trivial metamodels!

+ 1 - 1
bootstrap/core_algorithm.alc

@@ -2589,7 +2589,7 @@ Void function new_task():
 			// Execute it directly
 			Element func
 			func = get_func_AL_model(get_full_model(core_model, get_entry_id("formalisms/ActionLanguage")))
-			func()
+			func(read_root())
 
 		output("Welcome to the Model Management Interface v2.0!")
 		output("Use the 'help' command for a list of possible commands")

+ 1 - 1
bootstrap/semi_primitives.alc

@@ -89,7 +89,7 @@ Void function interruptable_sleep(a : Float):
 	__sleep(a, True)
 	return!
 
-Element mutable function exec(first_instr : Element):
+Element mutable function execute(first_instr : Element):
 	// This does very ugly things, so beware!
 	// 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

+ 1 - 1
interface/HUTN/includes/primitives.alh

@@ -90,7 +90,7 @@ Float function time()
 String function hash(a : String)
 Void function sleep(a : Float)
 Void function interruptable_sleep(a : Float)
-Element function exec(a : Element)
+Element function execute(a : Element)
 Element function resolve(var_name : String)
 Boolean function has_input()
 Element function list_pop(lst : Element, index : Integer)

+ 15 - 0
kernel/modelverse_kernel/compiled.py

@@ -447,3 +447,18 @@ def retype(a, b, c, **remainder):
             ("CD", [tm, str(instance_link), instance_link])]
 
     yield [("RETURN", [None])]
+
+def set_equality(a, b, **remainder):
+    if "id" not in a:
+        yield [("RETURN", [{'value': False}])]
+    if "id" not in b:
+        yield [("RETURN", [{'value': False}])]
+
+    keys_a, keys_b = yield [("RDK", [a["id"]]), ("RDK", [b["id"]])]
+    if (len(keys_a) != len(keys_b)):
+        yield [("RETURN", [{'value': False}])]
+
+    keys_a = yield [("RV", [i]) for i in keys_a]
+    keys_b = yield [("RV", [i]) for i in keys_b]
+    print("Check equality for # " + str(len(keys_a) + len(keys_b)))
+    yield [("RETURN", [{'value': keys_a == keys_b}])]

+ 1 - 1
kernel/modelverse_kernel/main.py

@@ -462,6 +462,7 @@ class ModelverseKernel(object):
             result, = yield [("RD", [params['a']['id'], params['b']['value']])]
             result = {'id': result}
         else:
+            #print("CALL " + str(self.jit.get_global_name(inst)) + " --> " + params)
             results = yield [("CALL_KWARGS", [compiled_func, params])]
             if results is None:
                 raise Exception("%s: primitive finished without returning a value!" % (self.debug_info[taskname]))
@@ -1473,7 +1474,6 @@ class ModelverseKernel(object):
                               ]
 
         value, =        yield [("RV", [new_var])]
-        print("GLOB " + str(value))
         exists, =       yield [("RDE", [global_symbols, value])]
 
         if exists is not None: