Ver código fonte

Fixed get_full_model function and model_overwrite

Yentl Van Tendeloo 8 anos atrás
pai
commit
572a22563a

+ 0 - 1
bootstrap/modelling.alc

@@ -24,7 +24,6 @@ Element function instantiate_bottom():
 	// Add an empty model and empty type mapping
 	// Add an empty model and empty type mapping
 	dict_add(new_model, "model", create_node())
 	dict_add(new_model, "model", create_node())
 	dict_add(new_model, "type_mapping", create_node())
 	dict_add(new_model, "type_mapping", create_node())
-	dict_add(new_model, "__kind", "formalism")
 
 
 	// Return the created model
 	// Return the created model
 	return new_model!
 	return new_model!

+ 4 - 0
bootstrap/object_operations.alc

@@ -254,8 +254,12 @@ String function read_type(model : Element, name : String):
 			if (dict_in(model["metamodel"]["model"], result)):
 			if (dict_in(model["metamodel"]["model"], result)):
 				return result!
 				return result!
 			else:
 			else:
+				log("Could not find " + result)
 				return ""!
 				return ""!
 		else:
 		else:
+			log("Untyped " + name)
+			log("Type mapping: " + dict_to_string(model["type_mapping"]))
 			return ""!
 			return ""!
 	else:
 	else:
+		log("Couldn't find " + name)
 		return ""!
 		return ""!

+ 28 - 9
core/core_algorithm.alc

@@ -12,7 +12,6 @@ include "metamodels.alh"
 
 
 Element core = ?
 Element core = ?
 
 
-String scd_location = "models/SimpleClassDiagrams"
 String core_location = "models/CoreFormalism"
 String core_location = "models/CoreFormalism"
 String core_model_location = "models/core"
 String core_model_location = "models/core"
 
 
@@ -28,12 +27,14 @@ Void function main():
 	String core_formalism
 	String core_formalism
 	Element scd
 	Element scd
 
 
-	scd = initialize_SCD(scd_location)
+	String scd_location
+	scd_location = "models/SimpleClassDiagrams"
+	scd = import_node(scd_location)
 
 
 	// Create the Model itself and make public
 	// Create the Model itself and make public
 	core_formalism = import_node(core_location)
 	core_formalism = import_node(core_location)
 	core = instantiate_model(core_formalism)
 	core = instantiate_model(core_formalism)
-	export_node(core_model_location, core)
+	export_node(core_model_location, core["model"])
 
 
 	// Switch all new users to the user_function
 	// Switch all new users to the user_function
 	// This accesses the bootstrap level, so do not change this unless you know what you are doing
 	// This accesses the bootstrap level, so do not change this unless you know what you are doing
@@ -82,7 +83,7 @@ Void function main():
 	// Add the SimpleClassDiagrams formalism already
 	// Add the SimpleClassDiagrams formalism already
 	scd_model = instantiate_node(core, "Model", "")
 	scd_model = instantiate_node(core, "Model", "")
 	instantiate_attribute(core, scd_model, "name", "SimpleClassDiagrams")
 	instantiate_attribute(core, scd_model, "name", "SimpleClassDiagrams")
-	instantiate_attribute(core, scd_model, "location", scd_location)
+	instantiate_attribute(core, scd_model, "location", scd_location + "/model")
 	instantiate_attribute(core, scd_model, "permissions", "221")
 	instantiate_attribute(core, scd_model, "permissions", "221")
 	instance_of = instantiate_link(core, "instanceOf", "", scd_model, scd_model)
 	instance_of = instantiate_link(core, "instanceOf", "", scd_model, scd_model)
 	instantiate_attribute(core, instance_of, "type_mapping", scd["type_mapping"])
 	instantiate_attribute(core, instance_of, "type_mapping", scd["type_mapping"])
@@ -94,7 +95,7 @@ Void function main():
 	// Add the core formalism already
 	// Add the core formalism already
 	core_formalism_model = instantiate_node(core, "Model", "")
 	core_formalism_model = instantiate_node(core, "Model", "")
 	instantiate_attribute(core, core_formalism_model, "name", "CoreFormalism")
 	instantiate_attribute(core, core_formalism_model, "name", "CoreFormalism")
-	instantiate_attribute(core, core_formalism_model, "location", core_location)
+	instantiate_attribute(core, core_formalism_model, "location", core_location + "/model")
 	instantiate_attribute(core, core_formalism_model, "permissions", "221")
 	instantiate_attribute(core, core_formalism_model, "permissions", "221")
 	instance_of = instantiate_link(core, "instanceOf", "", core_formalism_model, scd_model)
 	instance_of = instantiate_link(core, "instanceOf", "", core_formalism_model, scd_model)
 	instantiate_attribute(core, instance_of, "type_mapping", core_formalism["type_mapping"])
 	instantiate_attribute(core, instance_of, "type_mapping", core_formalism["type_mapping"])
@@ -124,12 +125,10 @@ Void function main():
 	// Note that if there are no admin users left, it will be very difficult to manage, as nobody will have admin permissions!
 	// Note that if there are no admin users left, it will be very difficult to manage, as nobody will have admin permissions!
 	return !
 	return !
 
 
-Element function get_full_model(model_id : String):
-	Element m
+String function get_instanceOf_link(model_id : String):
 	Element all_links
 	Element all_links
 	String choice
 	String choice
 
 
-	m = create_node()
 	all_links = allOutgoingAssociationInstances(core, model_id, "instanceOf")
 	all_links = allOutgoingAssociationInstances(core, model_id, "instanceOf")
 
 
 	if (read_nr_out(all_links) > 1):
 	if (read_nr_out(all_links) > 1):
@@ -139,9 +138,24 @@ Element function get_full_model(model_id : String):
 	
 	
 	choice = set_pop(allOutgoingAssociationInstances(core, model_id, "instanceOf"))
 	choice = set_pop(allOutgoingAssociationInstances(core, model_id, "instanceOf"))
 
 
+	return choice!
+
+Element function get_full_model(model_id : String):
+	Element m
+	Element all_links
+	String choice
+
+	choice = get_instanceOf_link(model_id)
+
+	m = create_node()
 	dict_add(m, "model", import_node(read_attribute(core, model_id, "location")))
 	dict_add(m, "model", import_node(read_attribute(core, model_id, "location")))
 	dict_add(m, "type_mapping", read_attribute(core, choice, "type_mapping"))
 	dict_add(m, "type_mapping", read_attribute(core, choice, "type_mapping"))
-	dict_add(m, "metamodel", import_node(read_attribute(core, readAssociationDestination(core, choice), "location")))
+
+	if (readAssociationDestination(core, choice) == model_id):
+		// Found the meta-circular level, so we can stop!
+		dict_add(m, "metamodel", m)
+	else:
+		dict_add(m, "metamodel", get_full_model(readAssociationDestination(core, choice)))
 
 
 	return m!
 	return m!
 
 
@@ -349,6 +363,7 @@ Void function model_create(model : Element, name : String, user_id : String, typ
 
 
 Void function model_overwrite(model : Element, model_id : String):
 Void function model_overwrite(model : Element, model_id : String):
 	String location
 	String location
+	String instanceOf_link
 
 
 	location = "/models/" + cast_id2s(model)
 	location = "/models/" + cast_id2s(model)
 	export_node(location, model["model"])
 	export_node(location, model["model"])
@@ -357,6 +372,10 @@ Void function model_overwrite(model : Element, model_id : String):
 	unset_attribute(core, model_id, "location")
 	unset_attribute(core, model_id, "location")
 	instantiate_attribute(core, model_id, "location", location)
 	instantiate_attribute(core, model_id, "location", location)
 
 
+	instanceOf_link = get_instanceOf_link(model_id)
+	unset_attribute(core, instanceOf_link, "type_mapping")
+	instantiate_attribute(core, instanceOf_link, "type_mapping", model["type_mapping"])
+
 	return!
 	return!
 
 
 Boolean function check_is_typed_by(model_id : String, metamodel_id : String):
 Boolean function check_is_typed_by(model_id : String, metamodel_id : String):

+ 1 - 0
core/mini_modify.alc

@@ -77,6 +77,7 @@ Element function modify(model : Element, write : Boolean):
 							instantiate_node(model, mm_type_name, element_name)
 							instantiate_node(model, mm_type_name, element_name)
 							output("Instantiation successful!")
 							output("Instantiation successful!")
 				else:
 				else:
+					log("Culd not find element in " + set_to_string(dict_keys(model["metamodel"]["model"])))
 					output("Unknown type specified; aborting")
 					output("Unknown type specified; aborting")
 			else:
 			else:
 				output("Permission denied")
 				output("Permission denied")

+ 2 - 2
scripts/run_local_modelverse.py

@@ -7,5 +7,5 @@ if len(sys.argv) < 2:
     sys.stderr.write("    %s port\n" % sys.argv[0])
     sys.stderr.write("    %s port\n" % sys.argv[0])
 else:
 else:
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"], cwd="hybrid_server")
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"], cwd="hybrid_server")
-    #subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=baseline-jit"], cwd="hybrid_server")
-    subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=legacy-interpreter"], cwd="hybrid_server")
+    subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=baseline-jit"], cwd="hybrid_server")
+    #subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=legacy-interpreter"], cwd="hybrid_server")