Browse Source

Make sure that AL_text keeps working

Yentl Van Tendeloo 7 years ago
parent
commit
9c30f5a8a9
4 changed files with 25 additions and 17 deletions
  1. 4 1
      bootstrap/core_algorithm.alc
  2. 5 4
      bootstrap/mini_modify.alc
  3. 15 11
      bootstrap/utils.alc
  4. 1 1
      wrappers/modelverse_SCCD.py

+ 4 - 1
bootstrap/core_algorithm.alc

@@ -1044,7 +1044,10 @@ Void function enact_PM(pm : Element, mapping : Element):
 	return !
 	return !
 
 
 String function cmd_AL_text(location : String):
 String function cmd_AL_text(location : String):
-	return "Success: " + cast_string(import_node(location + "/__text"))!
+	if location == "":
+		return "Success: \n"!
+	else:
+		return "Success: " + cast_string(import_node(location + "/__text"))!
 
 
 String function cmd_help():
 String function cmd_help():
 	String result
 	String result

+ 5 - 4
bootstrap/mini_modify.alc

@@ -365,7 +365,6 @@ String function cmd_read_attrs(model : Element, element_name : String):
 	Element attr_keys
 	Element attr_keys
 	String attr_key
 	String attr_key
 	String attr
 	String attr
-	String type_attr
 
 
 	result = "Success: "
 	result = "Success: "
 	if (dict_in(model["model"], element_name)):
 	if (dict_in(model["model"], element_name)):
@@ -374,9 +373,11 @@ String function cmd_read_attrs(model : Element, element_name : String):
 		while (0 < set_len(attr_keys)):
 		while (0 < set_len(attr_keys)):
 			attr_key = set_pop(attr_keys)
 			attr_key = set_pop(attr_keys)
 			attr = read_attribute(model, element_name, attr_key)
 			attr = read_attribute(model, element_name, attr_key)
-			type_attr = read_type(model, reverseKeyLookup(model["model"], attr))
-			if (read_type(model["metamodel"], type_attr) == "ActionLanguage"):
-				result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = {\"AL\": " + cast_value(attr) + "}\n"
+			if (read_type(model["metamodel"], attr_list[attr_key]) == "ActionLanguage"):
+				if (element_eq(attr, read_root())):
+					result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = {\"AL\": \"\"}\n"
+				else:
+					result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = {\"AL\": " + cast_value(attr) + "}\n"
 			else:
 			else:
 				result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = " + cast_value(attr) + "\n"
 				result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = " + cast_value(attr) + "\n"
 		return result!
 		return result!

+ 15 - 11
bootstrap/utils.alc

@@ -13,6 +13,7 @@ String function JSON_print(model : Element):
 	Boolean first
 	Boolean first
 	Element attr_value
 	Element attr_value
 	String type_attr
 	String type_attr
+	Element attrs
 
 
 	result = "["
 	result = "["
 	keys_m = dict_keys(model["model"])
 	keys_m = dict_keys(model["model"])
@@ -36,22 +37,25 @@ String function JSON_print(model : Element):
 				result = result + ", \"__target\": \"" + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])) + "\""
 				result = result + ", \"__target\": \"" + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])) + "\""
 
 
 			// Has attributes
 			// Has attributes
-			attr_keys = dict_keys(getAttributeList(model, v_m))
+			attrs = getAttributeList(model, v_m)
+			attr_keys = dict_keys(attrs)
 			while (0 < set_len(attr_keys)):
 			while (0 < set_len(attr_keys)):
 				attr_key = set_pop(attr_keys)
 				attr_key = set_pop(attr_keys)
 				attr_value = read_attribute(model, v_m, attr_key)
 				attr_value = read_attribute(model, v_m, attr_key)
-				if (element_eq(attr_value, read_root())):
-					result = result + ", \"" + attr_key + "\": null"
+				if (read_type(model["metamodel"], attrs[attr_key]) == "ActionLanguage"):
+					if (element_eq(attr_value, read_root())):
+						result = result + ", \"" + attr_key + "\": {\"AL\": \"\"}"
+					else:
+						result = result + ", \"" + attr_key + "\": {\"AL\": " + cast_value(attr_value) + "}"
 				else:
 				else:
-					if (is_physical_boolean(attr_value)):
-						if (attr_value):
-							result = result + ", \"" + attr_key + "\": true"
-						else:
-							result = result + ", \"" + attr_key + "\": false"
+					if (element_eq(attr_value, read_root())):
+						result = result + ", \"" + attr_key + "\": null"
 					else:
 					else:
-						type_attr = read_type(model, reverseKeyLookup(model["model"], attr_value))
-						if (read_type(model["metamodel"], type_attr) == "ActionLanguage"):
-							result = result + ", \"" + attr_key + "\": {\"AL\": " + cast_value(attr_value) + "}"
+						if (is_physical_boolean(attr_value)):
+							if (attr_value):
+								result = result + ", \"" + attr_key + "\": true"
+							else:
+								result = result + ", \"" + attr_key + "\": false"
 						else:
 						else:
 							result = result + ", \"" + attr_key + "\": " + cast_value(attr_value)
 							result = result + ", \"" + attr_key + "\": " + cast_value(attr_value)
 
 

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Tue May 29 16:19:29 2018
+Date:   Wed May 30 08:07:46 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server