瀏覽代碼

Minor tweaking of code using typing information

Yentl Van Tendeloo 8 年之前
父節點
當前提交
a54438ffa8

+ 0 - 4
bootstrap/modelling.alc

@@ -75,9 +75,6 @@ String function model_add_edge(model : Element, name : String, source : String,
 
 Void function retype_model(model : Element, metamodel : Element):
 	// Remove the type mapping and add a new one for the specified metamodel
-	if (dict_in(model, "type_mapping")):
-		dict_delete(model, "type_mapping")
-
 	new_type_mapping(model)
 	dict_add_fast(model, "metamodel", metamodel)
 	return!
@@ -403,7 +400,6 @@ Element function read_attribute(model : Element, element : String, attribute : S
 
 	else:
 		log("Element does not exist: " + element)
-		set_pop(set_create())
 
 	// Not found: either element doesn't exist, or we couldn't find it
 	return read_root()!

+ 4 - 1
bootstrap/object_operations.alc

@@ -17,9 +17,12 @@ Element function allInstances(model : Element, type_name : String):
 		result = set_create()
 		accepted = get_subclasses(model["metamodel"], type_name)
 
+		Element dict_mapping
+		dict_mapping = get_type_mapping_as_dict(model)
+
 		while (set_len(accepted) > 0):
 			class = set_pop(accepted)
-			set_merge(result, get_elements_typed_by(model, class))
+			set_merge(result, reverseKeyLookupMulti(dict_mapping, class))
 		return result!
 	else:
 		log("No such type in the metamodel: " + type_name)

+ 1 - 1
bootstrap/semi_primitives.alc

@@ -384,7 +384,7 @@ String function reverseKeyLookup(dict : Element, element : Element):
 
 		counter = counter + 1
 	
-	return string_join(string_join("(unknown: ", cast_e2s(element)), " )")!
+	return ""!
 
 Element function reverseKeyLookupMulti(dict : Element, element : Element):
 	// TODO don't know if this AL will actually work...

+ 0 - 1
interface/HUTN/includes/typing.alh

@@ -1,5 +1,4 @@
 Element function get_type_mapping_as_dict(model : Element)
-Element function get_elements_typed_by(model : Element, type : String)
 String function read_type(model : Element, name : String)
 Void function retype(model : Element, element : String, type : String)
 Void function new_type_mapping(model : Element)

+ 1 - 1
kernel/modelverse_kernel/compiled.py

@@ -35,7 +35,7 @@ def reverseKeyLookup(a, b, **remainder):
         e, = yield [("RE", [out_edge])]
         result = e[1]
     else:
-        result, = yield [("CNV", ["(unknown: %s)" % b])]
+        result, = yield [("CNV", [""])]
     #PROFILE print("[COMPILED]reverseKeyLookup : %s : %s" % (time.time() - start, time.time() - start))
     raise PrimitiveFinished(result)