|
@@ -8,6 +8,45 @@ include "metamodels.alh"
|
|
|
include "modelling.alh"
|
|
|
include "compilation_manager.alh"
|
|
|
|
|
|
+String function pretty_print(model : Element):
|
|
|
+ Element keys_m
|
|
|
+ String type
|
|
|
+ String v_m
|
|
|
+ Element attr_list
|
|
|
+ Element attr_keys
|
|
|
+ String attr_key
|
|
|
+ String result
|
|
|
+
|
|
|
+ result = ""
|
|
|
+ keys_m = dict_keys(model["model"])
|
|
|
+
|
|
|
+ while (read_nr_out(keys_m) > 0):
|
|
|
+ v_m = set_pop(keys_m)
|
|
|
+ type = read_type(model["metamodel"], read_type(model, v_m))
|
|
|
+
|
|
|
+ if (bool_or(type == "Class", type == "Association")):
|
|
|
+ result = result + (((" " + v_m) + " : ") + read_type(model, v_m))
|
|
|
+ if (type == "Association"):
|
|
|
+ result = result + (((" " + reverseKeyLookup(model["model"], read_edge_src(model["model"][v_m]))) + " --> ") + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])))
|
|
|
+
|
|
|
+ // Defines attributes
|
|
|
+ attr_list = getInstantiatableAttributes(model, v_m)
|
|
|
+ attr_keys = dict_keys(attr_list)
|
|
|
+ while (0 < read_nr_out(attr_keys)):
|
|
|
+ attr_key = set_pop(attr_keys)
|
|
|
+ result = result + ((((" " + attr_key) + " : ") + cast_v2s(attr_list[attr_key])))
|
|
|
+
|
|
|
+ // Has attributes
|
|
|
+ attr_list = getAttributeList(model, v_m)
|
|
|
+ attr_keys = dict_keys(attr_list)
|
|
|
+ while (0 < read_nr_out(attr_keys)):
|
|
|
+ attr_key = set_pop(attr_keys)
|
|
|
+ if (element_eq(read_attribute(model, v_m, attr_key), read_root())):
|
|
|
+ result = result + ((((" " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = (undefined)")
|
|
|
+ else:
|
|
|
+ result = result + (((((" " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, v_m, attr_key)))
|
|
|
+ return result!
|
|
|
+
|
|
|
Element function modify(model : Element, write : Boolean):
|
|
|
String cmd
|
|
|
|
|
@@ -191,41 +230,7 @@ Element function modify(model : Element, write : Boolean):
|
|
|
output("Permission denied")
|
|
|
|
|
|
elif (cmd == "nice_list"):
|
|
|
- Element keys_m
|
|
|
- String type
|
|
|
- String v_m
|
|
|
- Element attr_list
|
|
|
- Element attr_keys
|
|
|
- String attr_key
|
|
|
-
|
|
|
- // TODO change log to output
|
|
|
- keys_m = dict_keys(model["model"])
|
|
|
-
|
|
|
- while (read_nr_out(keys_m) > 0):
|
|
|
- v_m = set_pop(keys_m)
|
|
|
- type = read_type(model["metamodel"], read_type(model, v_m))
|
|
|
-
|
|
|
- if (bool_or(type == "Class", type == "Association")):
|
|
|
- log(((" " + v_m) + " : ") + read_type(model, v_m))
|
|
|
- if (type == "Association"):
|
|
|
- log(((" " + reverseKeyLookup(model["model"], read_edge_src(model["model"][v_m]))) + " --> ") + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])))
|
|
|
-
|
|
|
- // Defines attributes
|
|
|
- attr_list = getInstantiatableAttributes(model, v_m)
|
|
|
- attr_keys = dict_keys(attr_list)
|
|
|
- while (0 < read_nr_out(attr_keys)):
|
|
|
- attr_key = set_pop(attr_keys)
|
|
|
- log((((" " + attr_key) + " : ") + cast_v2s(attr_list[attr_key])))
|
|
|
-
|
|
|
- // Has attributes
|
|
|
- attr_list = getAttributeList(model, v_m)
|
|
|
- attr_keys = dict_keys(attr_list)
|
|
|
- while (0 < read_nr_out(attr_keys)):
|
|
|
- attr_key = set_pop(attr_keys)
|
|
|
- if (element_eq(read_attribute(model, v_m, attr_key), read_root())):
|
|
|
- log((((" " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = (undefined)")
|
|
|
- else:
|
|
|
- log(((((" " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, v_m, attr_key)))
|
|
|
+ pretty_print(model)
|
|
|
|
|
|
elif (cmd == "list"):
|
|
|
Element keys_m
|