Jelajahi Sumber

Check for compilation errors...

Yentl Van Tendeloo 8 tahun lalu
induk
melakukan
fc8587dfd1
4 mengubah file dengan 25 tambahan dan 16 penghapusan
  1. 0 3
      bootstrap/compiler.alc
  2. 16 1
      bootstrap/core_algorithm.alc
  3. 9 1
      bootstrap/mini_modify.alc
  4. 0 11
      models/SCCD_execute.alc

+ 0 - 3
bootstrap/compiler.alc

@@ -32,7 +32,6 @@ Element function compile_code(code : String):
 	list = generic_compile(code, port)
 
 	if (element_eq(list, read_root())):
-		log("ERROR IN CODE COMPILATION")
 		return read_root()!
 
 	else:
@@ -50,9 +49,7 @@ Element function compile_model(code : String, metamodel : Element):
 	list = generic_compile(code, port)
 
 	if (element_eq(list, read_root())):
-		log("ERROR in model compile")
 		return read_root()!
 
 	else:
-		log("Creating model...")
 		return construct_model_list(instantiate_model(metamodel), list)!

+ 16 - 1
bootstrap/core_algorithm.alc

@@ -1000,6 +1000,10 @@ String function cmd_model_add(type : String, name : String):
 
 						output("Waiting for model constructors...")
 						new_model = compile_model(input(), mm)
+
+						if (element_eq(new_model, read_root())):
+							return "Compilation error"!
+
 						model_create(new_model, name, type_id, "Model")
 						return "Success"!
 					else:
@@ -1298,6 +1302,10 @@ String function cmd_model_overwrite(model_name : String, metamodel_name : String
 
 				output("Waiting for model constructors...")
 				new_model = compile_model(input(), mm)
+
+				if (element_eq(new_model, read_root())):
+					return "Compilation error"!
+
 				model_overwrite(new_model, model_id, get_entry_id(metamodel_name))
 				return "Success"!
 			else:
@@ -1519,7 +1527,12 @@ String function transformation_add(source_models : Element, target_models : Elem
 		elif (operation_type == "actionlanguage"):
 			// Finished with all information, now create the model itself!
 			output("Waiting for code constructors...")
-			add_code_model(get_full_model(get_entry_id("formalisms/ActionLanguage"), get_entry_id("formalisms/SimpleClassDiagrams")), "AL/" + operation_name, compile_code(input()))
+			Element compiled
+			compiled = compile_code(input())
+			if (element_eq(compiled, read_root())):
+				return "Compilation error"!
+
+			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")
 			model_id = get_entry_id(operation_name)
 
@@ -1652,6 +1665,8 @@ String function cmd_transformation_add_MT(source_models : Element, target_models
 		// Finished with all information, now create the model itself!
 		output("Waiting for model constructors...")
 		new_model = compile_model(input(), get_full_model(ramified_metamodel_id, get_entry_id("formalisms/SimpleClassDiagrams")))
+		if (element_eq(new_model, read_root())):
+			return "Compilation error"!
 		model_create(new_model, operation_name, ramified_metamodel_id, "ModelTransformation")
 		model_id = get_entry_id(operation_name)
 

+ 9 - 1
bootstrap/mini_modify.alc

@@ -89,6 +89,9 @@ String function cmd_upload(write : Boolean, model : Element):
 	if (write):
 		output("Waiting for model constructors...")
 		new_model = compile_model(input(), model["metamodel"])
+		if (element_eq(new_model, read_root())):
+			return "Compilation error"!
+
 		dict_overwrite(model, "model", new_model["model"])
 		set_type_mapping(model, get_type_mapping(new_model))
 		return "Success"!
@@ -173,7 +176,12 @@ String function cmd_attr_add_code(write : Boolean, model : Element, element_name
 			attrs = getAttributeList(model, element_name)
 			if (set_in(dict_keys(attrs), attr_name)):
 				output("Waiting for code constructors...")
-				instantiate_attribute_code(model, element_name, attr_name, compile_code(input()))
+				Element compiled
+				compiled = compile_code(input())
+				if (element_eq(compiled, read_root())):
+					return "Compilation error"!
+
+				instantiate_attribute_code(model, element_name, attr_name, compiled)
 				return "Success"!
 			else:
 				return "Attribute not found: " + attr_name!

+ 0 - 11
models/SCCD_execute.alc

@@ -633,9 +633,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
 		if (element_neq(action, read_root())):
 			// Got a script, so execute!
 			action = resolve_function(action, data)
-			log("Executing script 'action'!")
 			action(data["current_class_handle"]["attributes"])
-			log("DONE")
 
 		// Raise events
 		events = allAssociationDestinations(model, state, "SCCD/onExitRaise")
@@ -647,9 +645,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
 			if (element_neq(parameter_action, read_root())):
 				// Got a parameter to evaluate
 				parameter_action = resolve_function(parameter_action, data)
-				log("Execution script 'parameter_action'!")
 				parameter_action = parameter_action(data["current_class_handle"]["attributes"])
-				log("DONE")
 
 			process_raised_event(model, event, parameter_action, data)
 
@@ -668,9 +664,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
 		if (element_neq(action, read_root())):
 			// Got a script, so execute!
 			action = resolve_function(action, data)
-			log("Executing script 'act2'!")
 			action(data["current_class_handle"]["attributes"])
-			log("DONE")
 
 		// Raise events
 		events = allAssociationDestinations(model, state, "SCCD/onEntryRaise")
@@ -682,9 +676,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
 			if (element_neq(parameter_action, read_root())):
 				// Got a parameter to evaluate
 				parameter_action = resolve_function(parameter_action, data)
-				log("Executing script 'param2'!")
 				parameter_action = parameter_action(data["current_class_handle"]["attributes"])
-				log("DONE")
 
 			process_raised_event(model, event, parameter_action, data)
 
@@ -696,10 +688,7 @@ Void function execute_actions(model : Element, source_states : Element, target_s
 		while (set_len(timed_transitions) > 0):
 			transition = set_pop(timed_transitions)
 			after = resolve_function(read_attribute(model, transition, "after"), data)
-			log("Executing script 'after'!")
-			log("Function: " + cast_e2s(after))
 			dict_add(data["current_class_handle"]["timers"], transition, float_addition(data["time_sim"], after(data["current_class_handle"]["attributes"])))
-			log("DONE")
 
 	return !