Browse Source

Make instantiate_node compiled

Yentl Van Tendeloo 3 years ago
parent
commit
2dbffc7b92
3 changed files with 18 additions and 11 deletions
  1. 0 1
      bootstrap/transform.alc
  2. 0 3
      bootstrap/typing.alc
  3. 18 7
      kernel/modelverse_kernel/compiled.py

+ 0 - 1
bootstrap/transform.alc

@@ -420,7 +420,6 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 			typename = read_type(schedule_model, RHS_map[label])
 			original_typename = string_substr(typename, 5, string_len(typename))
 			new_name = instantiate_node(host_model, original_typename, new_identifier)
-			log("Added element " + new_name + " typed by " + original_typename)
 			dict_add_fast(new_mapping, label, new_name)
 
 	Element attributes

+ 0 - 3
bootstrap/typing.alc

@@ -72,10 +72,7 @@ Void function new_type_mapping(model : Element):
 
 Void function remove_type(model : Element, name : String):
 	Element value
-	//value = dict_read(model["type_mapping"]["root"], name)
 	value = dict_read_edge(model["type_mapping"]["root"], name)
 	if (element_neq(value, read_root())):
-		// TODO why is this a reverseKeyLookup? This means that it will not be removed, as it resolves to a constant...
-		//delete_element(reverseKeyLookup(model["type_mapping"], value))
 		delete_element(value)
 	return !

+ 18 - 7
kernel/modelverse_kernel/compiled.py

@@ -311,17 +311,17 @@ def list_pop_final(a, **remainder):
     _, = yield [("DE", [result_edge])]
     yield [("RETURN", [{'id': result}])]
 
-"""
 def instantiate_node(a, b, c, **remainder):
+    if "value" not in b:
+        b['value'], = yield [("RV", [b['id']])]
+
     if "value" not in c:
         c['value'], = yield [("RV", [c['id']])]
         
-    if "id" not in b:
-        b['id'], = yield [("CNV", [b['value']])]
-
-    node, dict_entry = \
+    node, dict_entry, tm = \
         yield [("CN", []),
                ("RD", [a['id'], "model"]),
+               ("RD", [a['id'], "type_mapping"]),
               ]
 
     if c['value'] == "":
@@ -331,10 +331,21 @@ def instantiate_node(a, b, c, **remainder):
         name = c['value']
         name_node = c
 
-    yield [("CD", [dict_entry, name, node])]
+    _, root = yield [("CD", [dict_entry, name, node]),
+                     ("RD", [tm, "root"])]
+
+    # Create new type links
+    type_elem, instance_elem = yield [("CNV", [b['value']]), ("CNV", [name])]
+    type_link, = yield [("CE", [root, type_elem])]
+    instance_link, = yield [("CE", [type_link, instance_elem])]
+
+    # Add them to the model
+    yield  [("CD", [tm, str(type_elem), type_elem]),
+            ("CD", [tm, str(instance_elem), instance_elem]),
+            ("CD", [tm, str(type_link), type_link]),
+            ("CD", [tm, str(instance_link), instance_link])]
 
     yield [("RETURN", [name_node])]
-"""
 
 def list_insert(a, b, c, **remainder):
     if "id" not in b: