Przeglądaj źródła

Fixed some bugs related to AL models

Yentl Van Tendeloo 7 lat temu
rodzic
commit
f746937885

+ 19 - 12
bootstrap/constructors.alc

@@ -12,13 +12,13 @@ Element variable_map = ?
 Element function construct_function_list(list : Element):
 	String command
 	Element result
-	Element main_function
+	String main_function
 	Boolean continue
-	Element prev_element
-	Element first_element
+	String prev_element
+	String first_element
 
 	Element model
-	model = instantiate_model("formalisms/ActionLanguage")
+	model = instantiate_model(import_node("models/ActionLanguage"))
 
 	list = list_reverse(list)
 
@@ -45,7 +45,7 @@ Element function construct_function_list(list : Element):
 			return read_root()!
 
 		continue = list_pop_final(list)
-		if (prev_element != read_root()):
+		if (element_neq(prev_element, read_root())):
 			dict_add_fast(prev_element, "next", result["start"])
 		else:
 			first_element = result["start"]
@@ -68,13 +68,16 @@ Element function construct_function_list(list : Element):
 
 	// Overwrite the main function with our declaration function
 	prev_element = set_pop(allAssociationDestinations(model, main_function, "funcdef_body"))
-	log("Got parameters for main function: " + set_to_string(dict_keys(model["model"][main_function])))
+	log("Got main function: " + main_function)
+	log("Got main function: " + set_to_string(dict_keys(model["model"][main_function])))
+	log("Parameters stored in " + cast_string(reverseKeyLookup(model["model"], model["model"][main_function]["params"])))
+	log("Got parameters for main function: " + set_to_string(dict_keys(model["model"][main_function]["params"])))
 	model_delete_element(model, set_pop(allOutgoingAssociationInstances(model, main_function, "funcdef_body")))
 	create_al_link(model, "funcdef_body", main_function, first_element, "body")
 	create_al_link(model, "Statement_next", result["end"], prev_element, "next")
-
 	instantiate_link(model, "initial_funcdef", "", instantiate_node(model, "Initial", ""), main_function)
 	
+	log("Created model!")
 	return model!
 
 Void function create_al_link(model : Element, linktype : String, source : String, target : String, dictname : String):
@@ -87,7 +90,7 @@ String function construct_global(model : Element, list : Element):
 	String op
 
 	this_element = instantiate_value(model, "global", "", create_value(!global))
-	declared_element = list_pop_final(list)
+	declared_element = instantiate_value(model, "String", "", create_value(list_pop_final(list)))
 	create_al_link(model, "global_var", this_element, instantiate_value(model, "String", "", declared_element), "var")
 
 	op = list_pop_final(list)
@@ -138,9 +141,9 @@ String function construct_funcdef(model : Element, list : Element, mutable : Boo
 	String assign
 	String resolve
 	String constant
-	Element formal
-	Element func
-	Element params
+	String formal
+	String func
+	String params
 	String declare
 	String name
 
@@ -178,8 +181,12 @@ String function construct_funcdef(model : Element, list : Element, mutable : Boo
 
 	while (counter < nrParams):
 		param = instantiate_node(model, "Element", "")
+		log("Adding parameter: " + string_get(arg_names_decl, counter))
+		log(" func " + func)
+		log(" params " + params)
 		create_al_link(model, "param_dict_link", params, param, string_get(arg_names_decl, counter))
-		dict_add_fast(variable_map, list_pop_final(list), model["model"][param])
+		log("After append: " + set_to_string(dict_keys(model["model"][params])))
+		dict_add_fast(variable_map, list_pop_final(list), param)
 		// Output each parameter in turn
 		counter = counter + 1
 

+ 9 - 3
bootstrap/core_algorithm.alc

@@ -51,7 +51,7 @@ String function full_name(model_id : String):
 
 Void function initialize_core():
 	// TODO make this more flexible by putting it in the bootstrap in a similar way as other models
-	add_code_model(import_node("models/ActionLanguage"), "models/Conformance_MV", wrap_conformance)
+	//add_code_model(import_node("models/ActionLanguage"), "models/Conformance_MV", wrap_conformance)
 	return !
 
 Boolean function is_typed_by(model_id : String, metamodel_id : String):
@@ -1808,12 +1808,18 @@ String function transformation_add(source_models : Element, target_models : Elem
 			output("Waiting for code constructors...")
 			Element compiled
 			compiled = compile_code(input())
+			log("Compiled code!")
 			if (is_physical_string(compiled)):
 				return "Compilation error: " + cast_string(compiled)!
 
-			add_code_model(get_full_model(get_entry_id("formalisms/ActionLanguage"), get_entry_id("formalisms/SimpleClassDiagrams")), "AL/" + operation_name, compiled)
-			model_create(import_node("AL/" + operation_name), operation_name, get_entry_id("formalisms/ActionLanguage"), "ActionLanguage")
+			log("Adding code model")
+			//add_code_model(get_full_model(get_entry_id("formalisms/ActionLanguage"), get_entry_id("formalisms/SimpleClassDiagrams")), "AL/" + operation_name, compiled)
+			log("Added code model")
+			//model_create(import_node("AL/" + operation_name), operation_name, get_entry_id("formalisms/ActionLanguage"), "ActionLanguage")
+			model_create(compiled, operation_name, get_entry_id("formalisms/ActionLanguage"), "ActionLanguage")
+			log("Create model")
 			model_id = get_entry_id(operation_name)
+			log("Get model ID")
 
 		if (dict_len(source_models) + dict_len(target_models) > 0):
 			merged_formalism_id = get_entry_id("merged/" + operation_name)

+ 1 - 0
bootstrap/metamodels.alt

@@ -277,6 +277,7 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_link(model, "Inheritance", "", "call_func", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_params", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_last_param", "dict_link")
+	instantiate_link(model, "Inheritance", "", "param_dict_link", "dict_link")
 
 	instantiate_attribute(model, "if_cond", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "if_then", "target_lower_cardinality", 1)

+ 0 - 1
services/HUTN/main.py

@@ -39,7 +39,6 @@ def compile_service(port):
             f.flush()
 
         compiled = do_compile(temp_file, COMPILER_PATH + "/grammars/actionlanguage.g", "CS")
-        print("Compiled: " + str(compiled))
         os.remove(temp_file)
         return compiled
 

+ 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)
 
-Date:   Tue Apr  3 16:07:17 2018
+Date:   Tue Apr  3 17:25:38 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server