|
@@ -3,20 +3,20 @@ include "conformance_scd.alh"
|
|
|
include "constructors.alh"
|
|
|
include "modelling.alh"
|
|
|
|
|
|
-Element function allInstances(model : Element, type_name : String):
|
|
|
+Element function allInstancesSlow(model : Element, type_name : String):
|
|
|
Element result
|
|
|
- Element type
|
|
|
|
|
|
String key
|
|
|
Element keys
|
|
|
|
|
|
+ // TODO more efficient implementation!
|
|
|
keys = dict_keys(model["model"])
|
|
|
if (dict_in(model["metamodel"]["model"], type_name)):
|
|
|
- type = model["metamodel"]["model"][type_name]
|
|
|
result = create_node()
|
|
|
|
|
|
// TODO more efficient to work backwards: find all instances of an element through the type mapping directly
|
|
|
// must then take into account all inheritance links ourselves...
|
|
|
+ log(cast_v2s(list_len(keys)))
|
|
|
while (0 < list_len(keys)):
|
|
|
key = set_pop(keys)
|
|
|
if (is_nominal_instance(model, key, type_name)):
|
|
@@ -27,19 +27,39 @@ Element function allInstances(model : Element, type_name : String):
|
|
|
log("No such type in the metamodel!")
|
|
|
return create_node()!
|
|
|
|
|
|
+Element function allInstances(model : Element, type_name : String):
|
|
|
+ if (dict_in(model["metamodel"]["model"], type_name)):
|
|
|
+ Element result
|
|
|
+ Element accepted
|
|
|
+ Element keys
|
|
|
+ Element tm
|
|
|
+ String key
|
|
|
+
|
|
|
+ result = create_node()
|
|
|
+ accepted = get_subclasses(model["metamodel"], type_name)
|
|
|
+
|
|
|
+ tm = model["type_mapping"]
|
|
|
+ keys = dict_keys(tm)
|
|
|
+ while (0 < list_len(keys)):
|
|
|
+ key = set_pop(keys)
|
|
|
+ if (set_in(accepted, tm[key])):
|
|
|
+ set_add(result, key)
|
|
|
+
|
|
|
+ return result!
|
|
|
+ else:
|
|
|
+ log("No such type in the metamodel!")
|
|
|
+ return create_node()!
|
|
|
+
|
|
|
Element function selectPossibleIncoming(model : Element, target : String, limit_set : Element):
|
|
|
// Find all possible incoming link types for the target model
|
|
|
// Should also include those specified on the superclass(es)
|
|
|
-
|
|
|
String type
|
|
|
Element model_dict
|
|
|
Element elem
|
|
|
Element result
|
|
|
Element target_element
|
|
|
-
|
|
|
result = create_node()
|
|
|
model_dict = model["model"]
|
|
|
-
|
|
|
while (0 < list_len(limit_set)):
|
|
|
type = set_pop(limit_set)
|
|
|
elem = model_dict[type]
|