Browse Source

Merge branch 'testing' into new_JIT

Yentl Van Tendeloo 7 years ago
parent
commit
6bc0a5a2e9

+ 8 - 2
bootstrap/conformance_scd.alc

@@ -167,12 +167,12 @@ String function conformance_scd(model : Element):
 				if (bool_not(is_nominal_instance(model, src_model, src_metamodel))):
 				if (bool_not(is_nominal_instance(model, src_model, src_metamodel))):
 					log("got: " + src_model)
 					log("got: " + src_model)
 					log("expected: " + src_metamodel)
 					log("expected: " + src_metamodel)
-					return "Source of model edge not typed by source of type: " + model_info(model, model_name)!
+					return "Source of model edge not typed by source of type: " + model_info(model, model_name) + " Expected: " + src_metamodel + " Got: " + src_model!
 
 
 				if (bool_not(is_nominal_instance(model, dst_model, dst_metamodel))):
 				if (bool_not(is_nominal_instance(model, dst_model, dst_metamodel))):
 					log("got: " + dst_model)
 					log("got: " + dst_model)
 					log("expected: " + dst_metamodel)
 					log("expected: " + dst_metamodel)
-					return "Destination of model edge not typed by destination of type: " + model_info(model, model_name)!
+					return "Destination of model edge not typed by source of type: " + model_info(model, model_name) + " Expected: " + dst_metamodel + " Got: " + dst_model!
 
 
 			// Check cardinality for all of our edges
 			// Check cardinality for all of our edges
 			//
 			//
@@ -232,6 +232,7 @@ String function conformance_scd(model : Element):
 				String result
 				String result
 				Element func
 				Element func
 
 
+				log("Fetching local constraint at location " + cast_string(constraint_function))
 				func = get_func_AL_model(import_node(constraint_function))
 				func = get_func_AL_model(import_node(constraint_function))
 				result = func(model, model_name)
 				result = func(model, model_name)
 
 
@@ -291,6 +292,7 @@ String function conformance_scd(model : Element):
 	global_constraints = allInstances(model, "GlobalConstraint")
 	global_constraints = allInstances(model, "GlobalConstraint")
 	while (set_len(global_constraints) > 0):
 	while (set_len(global_constraints) > 0):
 		constraint = set_pop(global_constraints)
 		constraint = set_pop(global_constraints)
+		log("Fetching global constraint at location " + cast_string(read_attribute(model, constraint, "global_constraint")))
 		func = get_func_AL_model(import_node(read_attribute(model, constraint, "global_constraint")))
 		func = get_func_AL_model(import_node(read_attribute(model, constraint, "global_constraint")))
 		result = func(model)
 		result = func(model)
 		if (result != "OK"):
 		if (result != "OK"):
@@ -318,4 +320,8 @@ Element function set_model_constraints(model : Element, func : Element):
 	return model!
 	return model!
 
 
 String function model_info(model : Element, name : String):
 String function model_info(model : Element, name : String):
+	if (is_edge(model["model"][name])):
+		return "EDGE " + name + " (ID: " + cast_id(model["model"][name]) + ")" + "  src: " + readAssociationSource(model, name) + "  dst: " + readAssociationDestination(model, name)!
+	else:
+		return "NODE " + name + " (ID: " + cast_id(model["model"][name]) + ")"!
 	return name!
 	return name!

+ 185 - 178
bootstrap/constructors.alc

@@ -4,6 +4,7 @@ include "library.alh"
 include "io.alh"
 include "io.alh"
 include "modelling.alh"
 include "modelling.alh"
 include "utils.alh"
 include "utils.alh"
+include "object_operations.alh"
 
 
 Element while_stack = ?
 Element while_stack = ?
 Element variable_map = ?
 Element variable_map = ?
@@ -11,10 +12,13 @@ Element variable_map = ?
 Element function construct_function_list(list : Element):
 Element function construct_function_list(list : Element):
 	String command
 	String command
 	Element result
 	Element result
-	Element main_function
+	String main_function
 	Boolean continue
 	Boolean continue
-	Element prev_element
-	Element first_element
+	String prev_element
+	String first_element
+
+	Element model
+	model = instantiate_model(import_node("models/ActionLanguage"))
 
 
 	list = list_reverse(list)
 	list = list_reverse(list)
 
 
@@ -30,19 +34,19 @@ Element function construct_function_list(list : Element):
 	while (continue):
 	while (continue):
 		command = list_pop_final(list)
 		command = list_pop_final(list)
 		if (command == "global"):
 		if (command == "global"):
-			result = construct_global(list)
+			result = construct_global(model, list)
 		elif (command == "funcdef"):
 		elif (command == "funcdef"):
-			result = construct_funcdef(False, list)
+			result = construct_funcdef(model, list, False)
 		elif (command == "mutable_funcdef"):
 		elif (command == "mutable_funcdef"):
-			result = construct_funcdef(True, list)
+			result = construct_funcdef(model, list, True)
 		else:
 		else:
 			log("ERROR (1): did not understand command " + cast_value(command))
 			log("ERROR (1): did not understand command " + cast_value(command))
 			output("ERROR: compiled code not understood: " + cast_value(command))
 			output("ERROR: compiled code not understood: " + cast_value(command))
 			return read_root()!
 			return read_root()!
 
 
 		continue = list_pop_final(list)
 		continue = list_pop_final(list)
-		if (prev_element != read_root()):
-			dict_add_fast(prev_element, "next", result["start"])
+		if (element_neq(prev_element, read_root())):
+			create_al_link(model, "Statement_next", prev_element, result["start"], "next")
 		else:
 		else:
 			first_element = result["start"]
 			first_element = result["start"]
 
 
@@ -63,49 +67,53 @@ Element function construct_function_list(list : Element):
 		return read_root()!
 		return read_root()!
 
 
 	// Overwrite the main function with our declaration function
 	// Overwrite the main function with our declaration function
-	prev_element = main_function["body"]
-	dict_delete(main_function, "body")
-	dict_add_fast(main_function, "body", first_element)
-	dict_add_fast(result["end"], "next", prev_element)
-	
-	return main_function!
-
-Action function construct_global(list : Element):
-	Action this_element
+	prev_element = set_pop(allAssociationDestinations(model, main_function, "funcdef_body"))
+	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)
+	return model!
+
+Void function create_al_link(model : Element, linktype : String, source : String, target : String, dictname : String):
+	instantiate_attribute(model, instantiate_link(model, linktype, "", source, target), "name", dictname)
+	return!
+
+String function construct_global(model : Element, list : Element):
+	String this_element
 	String declared_element
 	String declared_element
 	String op
 	String op
 
 
-	this_element = create_value(!global)
-	declared_element = list_pop_final(list)
-	dict_add_fast(this_element, "var", declared_element)
+	this_element = instantiate_value(model, "global", "", create_value(!global))
+	declared_element = instantiate_value(model, "String", "", create_value(list_pop_final(list)))
+	create_al_link(model, "global_var", this_element, declared_element, "var")
 
 
 	op = list_pop_final(list)
 	op = list_pop_final(list)
 	if (op != "none"):
 	if (op != "none"):
 		// Defines
 		// Defines
-		Action assign
-		Action resolve
-		Action value
-		assign = create_value(!assign)
-		dict_add_fast(this_element, "next", assign)
-		resolve = create_value(!resolve)
-		dict_add_fast(assign, "var", resolve)
-		dict_add_fast(resolve, "var", declared_element)
+		String assign
+		String resolve
+		String value
+		assign = instantiate_value(model, "assign", "", create_value(!assign))
+		create_al_link(model, "Statement_next", this_element, assign, "next")
+		resolve = instantiate_value(model, "resolve", "", create_value(!resolve))
+		create_al_link(model, "assign_var", assign, resolve, "var")
+		create_al_link(model, "resolve_var", resolve, declared_element, "var")
 		if (op == "deref"):
 		if (op == "deref"):
-			value = create_value(!constant)
-			dict_add_fast(value, "node", import_node(list_pop_final(list)))
+			value = instantiate_value(model, "constant", "", create_value(!constant))
+			create_al_link(model, "constant_node", this_element, value, "node")
 		elif (op == "empty"):
 		elif (op == "empty"):
-			value = create_value(!call)
-			Element res
-			Element acc
-			res = create_value(!resolve)
-			acc = create_value(!access)
-			dict_add_fast(value, "func", acc)
-			dict_add_fast(acc, "var", res)
-			dict_add_fast(res, "var", "create_node")
+			value = instantiate_value(model, "call", "", create_value(!call))
+			String res
+			String acc
+			res = instantiate_value(model, "resolve", "", create_value(!resolve))
+			acc = instantiate_value(model, "access", "", create_value(!access))
+			create_al_link(model, "call_func", value, acc, "func")
+			create_al_link(model, "access_var", acc, res, "var")
+			create_al_link(model, "resolve_var", res, instantiate_value(model, "String", "", "create_node"), "var")
 		elif (op == "const"):
 		elif (op == "const"):
-			value = create_value(!constant)
-			dict_add_fast(value, "node", list_pop_final(list))
-		dict_add_fast(assign, "value", value)
+			value = instantiate_value(model, "constant", "", create_value(!constant))
+			create_al_link(model, "constant_node", value, list_pop_final(list), "node")
+		create_al_link(model, "assign_value", assign, value, "value")
 
 
 		Element result
 		Element result
 		result = dict_create()
 		result = dict_create()
@@ -123,37 +131,37 @@ Action function construct_global(list : Element):
 		dict_add_fast(result, "end", this_element)
 		dict_add_fast(result, "end", this_element)
 		return result!
 		return result!
 
 
-Action function construct_funcdef(mutable : Boolean, list : Element):
-	Action assign
-	Action resolve
-	Action constant
-	Element formal
-	Element func
-	Element params
-	Action declare
+String function construct_funcdef(model : Element, list : Element, mutable : Boolean):
+	String assign
+	String resolve
+	String constant
+	String formal
+	String func
+	String params
+	String declare
 	String name
 	String name
 
 
-	declare = create_value(!global)
-	assign = create_value(!assign)
-	resolve = create_value(!resolve)
-	constant = create_value(!constant)
+	declare = instantiate_value(model, "global", "", create_value(!global))
+	assign = instantiate_value(model, "assign", "", create_value(!assign))
+	resolve = instantiate_value(model, "resolve", "", create_value(!resolve))
+	constant = instantiate_value(model, "constant", "", create_value(!constant))
 	name = list_pop_final(list)
 	name = list_pop_final(list)
 	if (dict_in(variable_map, name)):
 	if (dict_in(variable_map, name)):
 		formal = dict_read(variable_map, name)
 		formal = dict_read(variable_map, name)
 	else:
 	else:
-		formal = name
-	func = create_node()
-	params = create_node()
-	dict_add_fast(declare, "var", formal)
-	dict_add_fast(declare, "next", assign)
-	dict_add_fast(assign, "var", resolve)
-	dict_add_fast(assign, "value", constant)
-	dict_add_fast(resolve, "var", formal)
-	dict_add_fast(constant, "node", func)
-	dict_add_fast(func, "params", params)
+		formal = instantiate_value(model, "String", "", name)
+	func = instantiate_node(model, "funcdef", "")
+	params = instantiate_node(model, "param_dict", "")
+	create_al_link(model, "global_var", declare, formal, "var")
+	create_al_link(model, "Statement_next", declare, assign, "next")
+	create_al_link(model, "assign_var", assign, resolve, "var")
+	create_al_link(model, "assign_value", assign, constant, "value")
+	create_al_link(model, "resolve_var", resolve, formal, "var")
+	create_al_link(model, "constant_node", constant, func, "node")
+	create_al_link(model, "funcdef_params", func, params, "params")
 
 
 	if (mutable):
 	if (mutable):
-		dict_add_fast(func, "mutable", create_node())
+		create_al_link(model, "funcdef_mutable", func, instantiate_node(model, "Element", ""), "mutable")
 
 
 	Integer nrParams
 	Integer nrParams
 	nrParams = list_pop_final(list)
 	nrParams = list_pop_final(list)
@@ -165,15 +173,14 @@ Action function construct_funcdef(mutable : Boolean, list : Element):
 	arg_names_decl = "abcdefghijklmnopqrstuvwxyz"
 	arg_names_decl = "abcdefghijklmnopqrstuvwxyz"
 
 
 	while (counter < nrParams):
 	while (counter < nrParams):
-		param = create_node()
-		dict_add_fast(params, string_get(arg_names_decl, counter), param)
-		dict_add_fast(param, "name", string_get(arg_names_decl, counter))
+		param = instantiate_node(model, "Element", "")
+		create_al_link(model, "param_dict_link", params, param, string_get(arg_names_decl, counter))
 		dict_add_fast(variable_map, list_pop_final(list), param)
 		dict_add_fast(variable_map, list_pop_final(list), param)
 		// Output each parameter in turn
 		// Output each parameter in turn
 		counter = counter + 1
 		counter = counter + 1
 
 
 	// Now add the body
 	// Now add the body
-	dict_add_fast(func, "body", construct_unknown(list))
+	create_al_link(model, "funcdef_body", func, construct_unknown(model, list), "body")
 
 
 	Element result
 	Element result
 	result = dict_create()
 	result = dict_create()
@@ -183,102 +190,103 @@ Action function construct_funcdef(mutable : Boolean, list : Element):
 	dict_add_fast(result, "end", assign)
 	dict_add_fast(result, "end", assign)
 	return result!
 	return result!
 
 
-Element function construct_unknown(list : Element):
+Element function construct_unknown(model : Element, list : Element):
 	String elem
 	String elem
 	Element new_model
 	Element new_model
 	Element new_model_model
 	Element new_model_model
 	elem = list_pop_final(list)
 	elem = list_pop_final(list)
 
 
 	if (elem == "if"):
 	if (elem == "if"):
-		return construct_if(list)!
+		return construct_if(model, list)!
 	elif (elem == "while"):
 	elif (elem == "while"):
-		return construct_while(list)!
+		return construct_while(model, list)!
 	elif (elem == "access"):
 	elif (elem == "access"):
-		return construct_access(list)!
+		return construct_access(model, list)!
 	elif (elem == "resolve"):
 	elif (elem == "resolve"):
-		return construct_resolve(list)!
+		return construct_resolve(model, list)!
 	elif (elem == "assign"):
 	elif (elem == "assign"):
-		return construct_assign(list)!
+		return construct_assign(model, list)!
 	elif (elem == "call"):
 	elif (elem == "call"):
-		return construct_call(list)!
+		return construct_call(model, list)!
 	elif (elem == "return"):
 	elif (elem == "return"):
-		return construct_return(list)!
+		return construct_return(model, list)!
 	elif (elem == "const"):
 	elif (elem == "const"):
-		return construct_const(list)!
+		return construct_const(model, list)!
 	elif (elem == "declare"):
 	elif (elem == "declare"):
-		return construct_declare(list)!
+		return construct_declare(model, list)!
 	elif (elem == "output"):
 	elif (elem == "output"):
-		return construct_output(list)!
+		return construct_output(model, list)!
 	elif (elem == "input"):
 	elif (elem == "input"):
-		return construct_input(list)!
+		return construct_input(model, list)!
 	elif (elem == "deref"):
 	elif (elem == "deref"):
-		return construct_deref(list)!
+		return construct_deref(model, list)!
 	elif (elem == "break"):
 	elif (elem == "break"):
-		return construct_break(list)!
+		return construct_break(model, list)!
 	elif (elem == "continue"):
 	elif (elem == "continue"):
-		return construct_continue(list)!
+		return construct_continue(model, list)!
 	else:
 	else:
 		log("ERROR (2): did not understand command " + cast_value(elem))
 		log("ERROR (2): did not understand command " + cast_value(elem))
 		output("ERROR: compiled code not understood: " + cast_value(elem))
 		output("ERROR: compiled code not understood: " + cast_value(elem))
 		return read_root()!
 		return read_root()!
 
 
-Action function construct_if(list : Element):
-	Action this_element
-	this_element = create_value(!if)
-	dict_add_fast(this_element, "cond", construct_unknown(list))
-	dict_add_fast(this_element, "then", construct_unknown(list))
+String function construct_if(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "if", "", create_value(!if))
+	create_al_link(model, "if_cond", this_element, construct_unknown(model, list), "cond")
+	create_al_link(model, "if_then", this_element, construct_unknown(model, list), "then")
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		dict_add_fast(this_element, "else", construct_unknown(list))
+		create_al_link(model, "if_else", this_element, construct_unknown(model, list), "else")
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		dict_add_fast(this_element, "next", construct_unknown(list))
+		create_al_link(model, "Statement_next", this_element, construct_unknown(model, list), "next")
 	return this_element!
 	return this_element!
 
 
-Action function construct_while(list : Element):
-	Action this_element
-	this_element = create_value(!while)
-	dict_add_fast(this_element, "cond", construct_unknown(list))
+String function construct_while(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "while", "", create_value(!while))
+	create_al_link(model, "while_cond", this_element, construct_unknown(model, list), "cond")
 
 
 	list_append(while_stack, this_element)
 	list_append(while_stack, this_element)
-	dict_add_fast(this_element, "body", construct_unknown(list))
+	create_al_link(model, "while_body", this_element, construct_unknown(model, list), "body")
 	list_delete(while_stack, list_len(while_stack) - 1)
 	list_delete(while_stack, list_len(while_stack) - 1)
 
 
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		dict_add_fast(this_element, "next", construct_unknown(list))
+		create_al_link(model, "Statement_next", this_element, construct_unknown(model, list), "next")
 	return this_element!
 	return this_element!
 
 
-Action function construct_access(list : Element):
-	Action this_element
-	this_element = create_value(!access)
-	dict_add_fast(this_element, "var", construct_unknown(list))
+String function construct_access(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "access", "", create_value(!access))
+	create_al_link(model, "access_var", this_element, construct_unknown(model, list), "var")
 	return this_element!
 	return this_element!
 
 
-Action function construct_resolve(list : Element):
-	Action this_element
+String function construct_resolve(model : Element, list : Element):
+	String this_element
 	Element linked_element
 	Element linked_element
 	String name
 	String name
 
 
-	this_element = create_value(!resolve)
+	this_element = instantiate_value(model, "resolve", "", create_value(!resolve))
 	name = list_pop_final(list)
 	name = list_pop_final(list)
+	// TODO might have to check if this is to be added
 	if dict_in(variable_map, name):
 	if dict_in(variable_map, name):
 		linked_element = variable_map[name]
 		linked_element = variable_map[name]
 	else:
 	else:
-		linked_element = name
-	dict_add_fast(this_element, "var", linked_element)
+		linked_element = instantiate_value(model, "String", "", name)
+	create_al_link(model, "resolve_var", this_element, linked_element, "var")
 	return this_element!
 	return this_element!
 
 
-Action function construct_assign(list : Element):
-	Action this_element
-	this_element = create_value(!assign)
-	dict_add_fast(this_element, "var", construct_unknown(list))
-	dict_add_fast(this_element, "value", construct_unknown(list))
+String function construct_assign(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "assign", "", create_value(!assign))
+	create_al_link(model, "assign_var", this_element, construct_unknown(model, list), "var")
+	create_al_link(model, "assign_value", this_element, construct_unknown(model, list), "value")
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		dict_add_fast(this_element, "next", construct_unknown(list))
+		create_al_link(model, "Statement_next", this_element, construct_unknown(model, list), "next")
 	return this_element!
 	return this_element!
 
 
-Action function construct_call(list : Element):
-	Action this_element
-	this_element = create_value(!call)
-	dict_add_fast(this_element, "func", construct_unknown(list))
+String function construct_call(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "call", "", create_value(!call))
+	create_al_link(model, "call_func", this_element, construct_unknown(model, list), "func")
 
 
 	Integer nrParams
 	Integer nrParams
 	nrParams = list_pop_final(list)
 	nrParams = list_pop_final(list)
@@ -291,49 +299,49 @@ Action function construct_call(list : Element):
 	arg_names_call = "abcdefghijklmnopqrstuvwxyz"
 	arg_names_call = "abcdefghijklmnopqrstuvwxyz"
 
 
 	while (counter < nrParams):
 	while (counter < nrParams):
-		param = create_node()
+		param = instantiate_node(model, "param", "")
 
 
-		dict_add_fast(param, "name", string_get(arg_names_call, counter))
-		dict_add_fast(param, "value", construct_unknown(list))
+		create_al_link(model, "param_name", param, instantiate_value(model, "String", "", string_get(arg_names_call, counter)), "name")
+		create_al_link(model, "param_value", param, construct_unknown(model, list), "value")
 
 
 		if (counter == 0):
 		if (counter == 0):
-			dict_add_fast(this_element, "params", param)
+			create_al_link(model, "call_params", this_element, param, "params")
 		else:
 		else:
-			dict_add_fast(prev_param, "next_param", param)
+			create_al_link(model, "param_next_param", prev_param, param, "next_param")
 		prev_param = param
 		prev_param = param
 
 
 		counter = counter + 1
 		counter = counter + 1
 
 
 	if (nrParams > 0):
 	if (nrParams > 0):
-		dict_add_fast(this_element, "last_param", prev_param)
+		create_al_link(model, "call_last_param", this_element, prev_param, "last_param")
 
 
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		dict_add_fast(this_element, "next", construct_unknown(list))
+		create_al_link(model, "Statement_next", this_element, construct_unknown(model, list), "next")
 	return this_element!
 	return this_element!
 
 
-Action function construct_return(list : Element):
+String function construct_return(model : Element, list : Element):
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		Action this_element
-		this_element = create_value(!return)
-		dict_add_fast(this_element, "value", construct_unknown(list))
+		String this_element
+		this_element = instantiate_value(model, "return", "", create_value(!return))
+		create_al_link(model, "return_value", this_element, construct_unknown(model, list), "value")
 		return this_element!
 		return this_element!
 	else:
 	else:
-		return create_value(!return)!
+		return instantiate_value(model, "return", "", create_value(!return))!
 
 
-Action function construct_const(list : Element):
-	Action this_element
-	this_element = create_value(!constant)
-	dict_add_fast(this_element, "node", list_pop_final(list))
+String function construct_const(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "constant", "", create_value(!constant))
+	create_al_link(model, "constant_node", this_element, instantiate_value(model, "Element", "", list_pop_final(list)), "node")
 	return this_element!
 	return this_element!
 
 
-Action function construct_declare(list : Element):
-	Action this_element
+String function construct_declare(model : Element, list : Element):
+	String this_element
 	Element declared_element
 	Element declared_element
 	String name
 	String name
 
 
-	this_element = create_value(!declare)
-	declared_element = create_node()
-	dict_add_fast(this_element, "var", declared_element)
+	this_element = instantiate_value(model, "declare", "", create_value(!declare))
+	declared_element = instantiate_node(model, "Element", "")
+	create_al_link(model, "declare_var", this_element, declared_element, "var")
 	name = list_pop_final(list)
 	name = list_pop_final(list)
 	dict_add_fast(variable_map, name, declared_element)
 	dict_add_fast(variable_map, name, declared_element)
 
 
@@ -341,65 +349,64 @@ Action function construct_declare(list : Element):
 	String op
 	String op
 	op = list_pop_final(list)
 	op = list_pop_final(list)
 	if (op != "none"):
 	if (op != "none"):
-		Action assign
-		Action resolve
-		Action value
-		assign = create_value(!assign)
-		dict_add_fast(this_element, "next", assign)
-		resolve = create_value(!resolve)
-		dict_add_fast(assign, "var", resolve)
-		dict_add_fast(resolve, "var", declared_element)
+		String assign
+		String resolve
+		String value
+		assign = instantiate_value(model, "assign", "", create_value(!assign))
+		create_al_link(model, "Statement_next", this_element, assign, "next")
+		resolve = instantiate_value(model, "resolve", "", create_value(!resolve))
+		create_al_link(model, "assign_var", assign, resolve, "var")
+		create_al_link(model, "resolve_var", resolve, declared_element, "var")
 		if (op == "deref"):
 		if (op == "deref"):
-			value = create_value(!constant)
-			dict_add_fast(value, "node", import_node(list_pop_final(list)))
+			value = instantiate_value(model, "constant", "", create_value(!constant))
+			create_al_link(model, "constant_node", value, reuse_element(model, "Element", "", import_node(list_pop_final(list))), "node")
 		elif (op == "empty"):
 		elif (op == "empty"):
-			value = create_value(!call)
+			value = instantiate_value(model, "call", "", create_value(!call))
 			Element res
 			Element res
 			Element acc
 			Element acc
-			res = create_value(!resolve)
-			acc = create_value(!access)
-			dict_add_fast(value, "func", acc)
-			dict_add_fast(acc, "var", res)
-			dict_add_fast(res, "var", "create_node")
+			res = instantiate_value(model, "resolve", "", create_value(!resolve))
+			acc = instantiate_value(model, "access", "", create_value(!access))
+			create_al_link(model, "call_func", value, acc, "func")
+			create_al_link(model, "access_var", acc, res, "var")
+			create_al_link(model, "resolve_var", res, instantiate_value(model, "String", "", "create_node"), "var")
 		elif (op == "const"):
 		elif (op == "const"):
-			value = create_value(!constant)
-			dict_add_fast(value, "node", list_pop_final(list))
-		dict_add_fast(assign, "value", value)
+			value = instantiate_value(model, "constant", "", create_value(!constant))
+			create_al_link(model, "constant_node", value, instantiate_value(model, "Element", "", list_pop_final(list)), "node")
+		create_al_link(model, "assign_value", assign, value, "value")
 
 
 		if (list_pop_final(list)):
 		if (list_pop_final(list)):
-			dict_add_fast(assign, "next", construct_unknown(list))
+			create_al_link(model, "Statement_next", assign, construct_unknown(model, list), "next")
 	else:
 	else:
 		if (list_pop_final(list)):
 		if (list_pop_final(list)):
-			dict_add_fast(this_element, "next", construct_unknown(list))
+			create_al_link(model, "Statement_next", this_element, construct_unknown(model, list), "next")
 	return this_element!
 	return this_element!
 
 
-Action function construct_input(list : Element):
-	Action this_element
-	this_element = create_value(!input)
-	return this_element!
+String function construct_input(model : Element, list : Element):
+	return instantiate_value(model, "input", "", create_value(!input))!
+
+String function construct_output(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "output", "", create_value(!output))
+	create_al_link(model, "output_value", this_element, construct_unknown(model, list), "value")
 
 
-Action function construct_output(list : Element):
-	Action this_element
-	this_element = create_value(!output)
-	dict_add_fast(this_element, "value", construct_unknown(list))
 	if (list_pop_final(list)):
 	if (list_pop_final(list)):
-		dict_add_fast(this_element, "next", construct_unknown(list))
+		create_al_link(model, "Statement_next", this_element, construct_unknown(model, list), "next")
 	return this_element!
 	return this_element!
 
 
-Action function construct_deref(list : Element):
-	Action this_element
-	this_element = create_value(!constant)
-	dict_add_fast(this_element, "node", import_node(list_pop_final(list)))
+String function construct_deref(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "constant", "", create_value(!constant))
+	create_al_link(model, "constant_node", this_element, reuse_element(model, "Element", "", import_node(list_pop_final(list))), "node")
 	return this_element!
 	return this_element!
 
 
-Action function construct_break(list : Element):
-	Action this_element
-	this_element = create_value(!break)
-	dict_add_fast(this_element, "while", while_stack[list_len(while_stack) - 1])
+String function construct_break(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "break", "", create_value(!break))
+	create_al_link(model, "break_while", this_element, while_stack[list_len(while_stack) - 1], "while")
 	return this_element!
 	return this_element!
 
 
-Action function construct_continue(list : Element):
-	Action this_element
-	this_element = create_value(!continue)
-	dict_add_fast(this_element, "while", while_stack[list_len(while_stack) - 1])
+String function construct_continue(model : Element, list : Element):
+	String this_element
+	this_element = instantiate_value(model, "continue", "", create_value(!continue))
+	create_al_link(model, "continue_while", this_element, while_stack[list_len(while_stack) - 1], "while")
 	return this_element!
 	return this_element!

+ 6 - 4
bootstrap/core_algorithm.alc

@@ -44,11 +44,14 @@ String function get_filename(name : String):
 	return list_pop_final(string_split(name, "/"))!
 	return list_pop_final(string_split(name, "/"))!
 
 
 String function full_name(model_id : String):
 String function full_name(model_id : String):
-	return read_attribute(core, model_id, "name")!
+	if (dict_in(core["model"], model_id)):
+		return read_attribute(core, model_id, "name")!
+	else:
+		return read_root()!
 
 
 Void function initialize_core():
 Void function initialize_core():
 	// TODO make this more flexible by putting it in the bootstrap in a similar way as other models
 	// 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 !
 	return !
 
 
 Boolean function is_typed_by(model_id : String, metamodel_id : String):
 Boolean function is_typed_by(model_id : String, metamodel_id : String):
@@ -1808,8 +1811,7 @@ String function transformation_add(source_models : Element, target_models : Elem
 			if (is_physical_string(compiled)):
 			if (is_physical_string(compiled)):
 				return "Compilation error: " + cast_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")
+			model_create(compiled, operation_name, get_entry_id("formalisms/ActionLanguage"), "ActionLanguage")
 			model_id = get_entry_id(operation_name)
 			model_id = get_entry_id(operation_name)
 
 
 		if (dict_len(source_models) + dict_len(target_models) > 0):
 		if (dict_len(source_models) + dict_len(target_models) > 0):

+ 20 - 5
bootstrap/metamodels.alt

@@ -143,11 +143,11 @@ Element function initialize_SCD(location : String):
 	model_define_attribute(scd, "Element", "constraint", True, "ActionLanguage")
 	model_define_attribute(scd, "Element", "constraint", True, "ActionLanguage")
 
 
 	// Define some constraints
 	// Define some constraints
-	instantiate_attribute_code(scd, "Natural", "constraint", constraint_Natural)
-	instantiate_attribute_code(scd, "String", "constraint", constraint_String)
-	instantiate_attribute_code(scd, "Boolean", "constraint", constraint_Boolean)
-	instantiate_attribute_code(scd, "Location", "constraint", constraint_Location)
-	instantiate_attribute_code(scd, "ActionLanguage", "constraint", constraint_ActionLanguage)
+	//instantiate_attribute_code(scd, "Natural", "constraint", constraint_Natural)
+	//instantiate_attribute_code(scd, "String", "constraint", constraint_String)
+	//instantiate_attribute_code(scd, "Boolean", "constraint", constraint_Boolean)
+	//instantiate_attribute_code(scd, "Location", "constraint", constraint_Location)
+	//instantiate_attribute_code(scd, "ActionLanguage", "constraint", constraint_ActionLanguage)
 
 
 	instantiate_node(scd, "Class", "GlobalConstraint")
 	instantiate_node(scd, "Class", "GlobalConstraint")
 	model_define_attribute(scd, "GlobalConstraint", "global_constraint", False, "ActionLanguage")
 	model_define_attribute(scd, "GlobalConstraint", "global_constraint", False, "ActionLanguage")
@@ -174,6 +174,7 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_node(model, "Class", "Expression")
 	instantiate_node(model, "Class", "Expression")
 	instantiate_node(model, "Class", "funcdef")
 	instantiate_node(model, "Class", "funcdef")
 	instantiate_node(model, "Class", "param")
 	instantiate_node(model, "Class", "param")
+	instantiate_node(model, "Class", "param_dict")
 	instantiate_node(model, "Class", "if")
 	instantiate_node(model, "Class", "if")
 	instantiate_node(model, "Class", "break")
 	instantiate_node(model, "Class", "break")
 	instantiate_node(model, "Class", "while")
 	instantiate_node(model, "Class", "while")
@@ -201,6 +202,7 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_link(model, "Inheritance", "", "Action", "Element")
 	instantiate_link(model, "Inheritance", "", "Action", "Element")
 	instantiate_link(model, "Inheritance", "", "funcdef", "Action")
 	instantiate_link(model, "Inheritance", "", "funcdef", "Action")
 	instantiate_link(model, "Inheritance", "", "param", "Action")
 	instantiate_link(model, "Inheritance", "", "param", "Action")
+	instantiate_link(model, "Inheritance", "", "param_dict", "Element")
 	instantiate_link(model, "Inheritance", "", "Statement", "Action")
 	instantiate_link(model, "Inheritance", "", "Statement", "Action")
 	instantiate_link(model, "Inheritance", "", "Expression", "Action")
 	instantiate_link(model, "Inheritance", "", "Expression", "Action")
 	instantiate_link(model, "Inheritance", "", "resolve", "Statement")
 	instantiate_link(model, "Inheritance", "", "resolve", "Statement")
@@ -238,13 +240,17 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_link(model, "Association", "constant_node", "constant", "Element")
 	instantiate_link(model, "Association", "constant_node", "constant", "Element")
 	instantiate_link(model, "Association", "output_node", "output", "Expression")
 	instantiate_link(model, "Association", "output_node", "output", "Expression")
 	instantiate_link(model, "Association", "global_var", "global", "String")
 	instantiate_link(model, "Association", "global_var", "global", "String")
+	instantiate_link(model, "Association", "declare_var", "declare", "Element")
 	instantiate_link(model, "Association", "param_name", "param", "String")
 	instantiate_link(model, "Association", "param_name", "param", "String")
 	instantiate_link(model, "Association", "param_value", "param", "Expression")
 	instantiate_link(model, "Association", "param_value", "param", "Expression")
 	instantiate_link(model, "Association", "param_next_param", "param", "param")
 	instantiate_link(model, "Association", "param_next_param", "param", "param")
 	instantiate_link(model, "Association", "funcdef_body", "funcdef", "Statement")
 	instantiate_link(model, "Association", "funcdef_body", "funcdef", "Statement")
+	instantiate_link(model, "Association", "funcdef_params", "funcdef", "param_dict")
+	instantiate_link(model, "Association", "funcdef_mutable", "funcdef", "Element")
 	instantiate_link(model, "Association", "call_func", "call", "Expression")
 	instantiate_link(model, "Association", "call_func", "call", "Expression")
 	instantiate_link(model, "Association", "call_params", "call", "param")
 	instantiate_link(model, "Association", "call_params", "call", "param")
 	instantiate_link(model, "Association", "call_last_param", "call", "param")
 	instantiate_link(model, "Association", "call_last_param", "call", "param")
+	instantiate_link(model, "Association", "param_dict_link", "param_dict", "Element")
 	instantiate_link(model, "Inheritance", "", "Statement_next", "dict_link")
 	instantiate_link(model, "Inheritance", "", "Statement_next", "dict_link")
 	instantiate_link(model, "Inheritance", "", "if_cond", "dict_link")
 	instantiate_link(model, "Inheritance", "", "if_cond", "dict_link")
 	instantiate_link(model, "Inheritance", "", "if_then", "dict_link")
 	instantiate_link(model, "Inheritance", "", "if_then", "dict_link")
@@ -261,13 +267,17 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_link(model, "Inheritance", "", "constant_node", "dict_link")
 	instantiate_link(model, "Inheritance", "", "constant_node", "dict_link")
 	instantiate_link(model, "Inheritance", "", "output_node", "dict_link")
 	instantiate_link(model, "Inheritance", "", "output_node", "dict_link")
 	instantiate_link(model, "Inheritance", "", "global_var", "dict_link")
 	instantiate_link(model, "Inheritance", "", "global_var", "dict_link")
+	instantiate_link(model, "Inheritance", "", "declare_var", "dict_link")
 	instantiate_link(model, "Inheritance", "", "param_name", "dict_link")
 	instantiate_link(model, "Inheritance", "", "param_name", "dict_link")
 	instantiate_link(model, "Inheritance", "", "param_value", "dict_link")
 	instantiate_link(model, "Inheritance", "", "param_value", "dict_link")
 	instantiate_link(model, "Inheritance", "", "param_next_param", "dict_link")
 	instantiate_link(model, "Inheritance", "", "param_next_param", "dict_link")
 	instantiate_link(model, "Inheritance", "", "funcdef_body", "dict_link")
 	instantiate_link(model, "Inheritance", "", "funcdef_body", "dict_link")
+	instantiate_link(model, "Inheritance", "", "funcdef_params", "dict_link")
+	instantiate_link(model, "Inheritance", "", "funcdef_mutable", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_func", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_func", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_params", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_params", "dict_link")
 	instantiate_link(model, "Inheritance", "", "call_last_param", "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_cond", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "if_then", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "if_then", "target_lower_cardinality", 1)
@@ -282,9 +292,11 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_attribute(model, "constant_node", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "constant_node", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "output_node", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "output_node", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "global_var", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "global_var", "target_lower_cardinality", 1)
+	instantiate_attribute(model, "declare_var", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "param_name", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "param_name", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "param_value", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "param_value", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "funcdef_body", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "funcdef_body", "target_lower_cardinality", 1)
+	instantiate_attribute(model, "funcdef_params", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "call_func", "target_lower_cardinality", 1)
 	instantiate_attribute(model, "call_func", "target_lower_cardinality", 1)
 
 
 	instantiate_attribute(model, "Statement_next", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "Statement_next", "target_upper_cardinality", 1)
@@ -303,10 +315,13 @@ Void function initialize_AL(scd_location : String, export_location : String):
 	instantiate_attribute(model, "constant_node", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "constant_node", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "output_node", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "output_node", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "global_var", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "global_var", "target_upper_cardinality", 1)
+	instantiate_attribute(model, "declare_var", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "param_name", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "param_name", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "param_value", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "param_value", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "param_next_param", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "param_next_param", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "funcdef_body", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "funcdef_body", "target_upper_cardinality", 1)
+	instantiate_attribute(model, "funcdef_params", "target_upper_cardinality", 1)
+	instantiate_attribute(model, "funcdef_mutable", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "call_func", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "call_func", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "call_params", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "call_params", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "call_last_param", "target_upper_cardinality", 1)
 	instantiate_attribute(model, "call_last_param", "target_upper_cardinality", 1)

+ 2 - 121
bootstrap/modelling.alc

@@ -275,20 +275,12 @@ Void function instantiate_attribute_ref(model : Element, element : String, attri
 
 
 	return!
 	return!
 
 
-Void function add_code_model(model : Element, export_name : String, code : Element):
-	Element code_model
-	code_model = instantiate_model(model)
-	add_AL(code_model, code)
-	export_node(export_name, code_model)
-
-	return !
-
 Void function instantiate_attribute_code(model : Element, element : String, attribute_name : String, code : Element):
 Void function instantiate_attribute_code(model : Element, element : String, attribute_name : String, code : Element):
 	// First create a new model for the AL part
 	// First create a new model for the AL part
 	String location
 	String location
 	location = "code/" + cast_id(code)
 	location = "code/" + cast_id(code)
 
 
-	add_code_model(import_node("models/ActionLanguage"), location, code)
+	export_node(location, code)
 
 
 	// Now link it with a complex attribute
 	// Now link it with a complex attribute
 	instantiate_attribute(model, element, attribute_name, location)
 	instantiate_attribute(model, element, attribute_name, location)
@@ -467,117 +459,6 @@ Void function unset_attribute(model : Element, element : String, attribute : Str
 
 
 	return!
 	return!
 
 
-Void function add_AL_links(model : Element, list : Element, element : Element, type: String, linkname : String, expected_type : String):
-	if (bool_not(dict_in(element, linkname))):
-		return!
-
-	Element link
-	link = dict_read_edge(element, linkname)
-
-	// The link
-	if (linkname == "next"):
-		type = "Statement"
-	reuse_element(model, (type + "_") + linkname, "", link)
-
-	// The name link
-	link = read_out(link, 0)
-	reuse_element(model, "dict_link_name", "", link)
-	
-	// The name node
-	String link_name
-	link = read_edge_dst(link)
-	link_name = "__" + cast_id(link)
-
-	if (bool_not(dict_in(model["model"], link_name))):
-		reuse_element(model, "StringAttr", link_name, link)
-
-	// Now add the destination to the worker list
-	set_add_node(list, create_tuple(element[linkname], expected_type))
-
-	return!
-
-String function add_AL(model : Element, element : Element):
-	Element todo
-	Element node
-	Element work_node
-	Element elem
-	String type
-	String elem_name
-
-	todo = set_create()
-	set_add_node(todo, create_tuple(element, "funcdef"))
-
-	while (0 < dict_len(todo)):
-		work_node = set_pop(todo)
-		elem = list_read(work_node, 0)
-		type = list_read(work_node, 1)
-
-		elem_name = "__" + cast_id(elem)
-		if (bool_not(set_in(model["model"], elem_name))):
-			// Determine the type if we don't know it
-			if (type == ""):
-				if (is_physical_action(elem)):
-					type = cast_value(elem)
-				else:
-					type = "Element"
-
-			// Add the node itself
-			reuse_element(model, type, elem_name, elem)
-
-			// Now add its edges
-			if (type == "if"):
-				add_AL_links(model, todo, elem, type, "cond", "")
-				add_AL_links(model, todo, elem, type, "then", "")
-				add_AL_links(model, todo, elem, type, "else", "")
-				add_AL_links(model, todo, elem, type, "next", "")
-			elif (type == "while"):
-				add_AL_links(model, todo, elem, type, "cond", "")
-				add_AL_links(model, todo, elem, type, "body", "")
-				add_AL_links(model, todo, elem, type, "next", "")
-			elif (type == "assign"):
-				add_AL_links(model, todo, elem, type, "var", "resolve")
-				add_AL_links(model, todo, elem, type, "value", "")
-				add_AL_links(model, todo, elem, type, "next", "")
-			elif (type == "break"):
-				add_AL_links(model, todo, elem, type, "while", "while")
-			elif (type == "continue"):
-				add_AL_links(model, todo, elem, type, "while", "while")
-			elif (type == "return"):
-				add_AL_links(model, todo, elem, type, "value", "")
-			elif (type == "resolve"):
-				add_AL_links(model, todo, elem, type, "var", "")
-			elif (type == "access"):
-				add_AL_links(model, todo, elem, type, "var", "resolve")
-			elif (type == "constant"):
-				add_AL_links(model, todo, elem, type, "node", "")
-			elif (type == "output"):
-				add_AL_links(model, todo, elem, type, "node", "")
-				add_AL_links(model, todo, elem, type, "next", "")
-			elif (type == "global"):
-				add_AL_links(model, todo, elem, type, "var", "String")
-				add_AL_links(model, todo, elem, type, "next", "")
-			elif (type == "param"):
-				add_AL_links(model, todo, elem, type, "name", "String")
-				add_AL_links(model, todo, elem, type, "value", "")
-				add_AL_links(model, todo, elem, type, "next_param", "param")
-			elif (type == "funcdef"):
-				add_AL_links(model, todo, elem, type, "body", "")
-				// TODO this should be added, but is not the same as "param"
-				//add_AL_links(model, todo, elem, type, "params", "")
-				add_AL_links(model, todo, elem, type, "next", "")
-			elif (type == "call"):
-				add_AL_links(model, todo, elem, type, "func", "")
-				add_AL_links(model, todo, elem, type, "params", "param")
-				add_AL_links(model, todo, elem, type, "last_param", "param")
-				add_AL_links(model, todo, elem, type, "next", "")
-
-	// Mark the node as first
-	String initial
-	initial = instantiate_node(model, "Initial", "")
-	instantiate_link(model, "initial_funcdef", "", initial, reverseKeyLookup(model["model"], element))
-
-	return reverseKeyLookup(model["model"], element)!
-
 Element function get_func_AL_model(al_model : Element):
 Element function get_func_AL_model(al_model : Element):
 	Element initial_function
 	Element initial_function
 
 
@@ -633,7 +514,7 @@ Element function construct_model_list(model : Element, list : Element):
 		elif (command == "instantiate_link"):
 		elif (command == "instantiate_link"):
 			instantiate_link(model, list_pop_final(list), list_pop_final(list), list_pop_final(list), list_pop_final(list))
 			instantiate_link(model, list_pop_final(list), list_pop_final(list), list_pop_final(list), list_pop_final(list))
 		elif (command == "add_code_model"):
 		elif (command == "add_code_model"):
-			add_code_model(model, list_pop_final(list), construct_function_list(trim_AL_constructors(list)))
+			export_node(list_pop_final(list), construct_function_list(trim_AL_constructors(list)))
 		else:
 		else:
 			log("Modelling error: did not understand command " + command)
 			log("Modelling error: did not understand command " + command)
 
 

+ 9 - 9
doc/process_enactment.rst

@@ -15,16 +15,16 @@ Enacting process models
 
 
 To enact the process model, such as *query_state_space*, you must execute the following operation::
 To enact the process model, such as *query_state_space*, you must execute the following operation::
 
 
-    >>> process_execute("models/query_state_space", "my_", {})
+    >>> process_execute("models/query_state_space", {"pn": "models/my_pn"}, {})
 
 
 There are three parameters to this function, the first obviously being the name of the process model.
 There are three parameters to this function, the first obviously being the name of the process model.
-The second parameter is a prefix for the models used in the process model.
-When executing a process model, data is processed and produced.
-By providing a prefix, the names of these models are first prefixed with the prefix, before they are resolved.
-As such, it becomes possible to execute a process in different contexts.
-
-.. note::
-   This behaviour is likely to change in the future, with the process taking a mapping from the terms in the process model, to actual names.
+The second parameter is a mapping between elements in the process and the actual location in the Modelverse.
+When executing a process model, models are processed and produced, and when a binding is made to an actual model in the Modelverse, this model is actually stored and made available outside of the process.
+For example, in this case we bind the model called *pn* to the model at location *models/my_pn*.
+In the process, every occurence of *pn* is therefore processed at that location, both for input models (e.g., when chosing the Petri net to operate on) and output models (e.g., when this is the result).
+It is not necessary to define such a mapping, as it is perfectly possible that all models are created inside the process and are intended to stay in there.
+For example, in the power window case study, all DSMs are created during the process and we are only interested in the verification result, meaning that no models ``escape`` the process.
+If we were to retain the DSMs, for example to push them into another process later on, we could bind all these models to an actual location in the Modelverse.
 
 
 The third parameter is a dictionary of callbacks.
 The third parameter is a dictionary of callbacks.
 For each activity, it is possible for users to define a callback function.
 For each activity, it is possible for users to define a callback function.
@@ -40,7 +40,7 @@ The call then becomes::
     ...     instantiate(None, "P2T", (p, t))
     ...     instantiate(None, "P2T", (p, t))
     ...     # Alternatively, we could have used raw_input() or so to prompt the user
     ...     # Alternatively, we could have used raw_input() or so to prompt the user
     ...
     ...
-    >>> process_execute("models/query_state_space", "my_", {"models/refine_petrinet": callback})
+    >>> process_execute("models/query_state_space", {}, {"models/refine_petrinet": callback})
 
 
 When the process executes *refine_petrinet*, the callback function is executed, and the manual operation is terminated when the function terminates.
 When the process executes *refine_petrinet*, the callback function is executed, and the manual operation is terminated when the function terminates.
 Other types of operation, such as *model transformations* and *action language* can also have a callback function, but this is usually less important to end users and is therefore not elaborated on here.
 Other types of operation, such as *model transformations* and *action language* can also have a callback function, but this is usually less important to end users and is therefore not elaborated on here.

+ 1 - 1
integration/code/pn_simulate.alc

@@ -5,7 +5,7 @@ include "model_management.alh"
 include "object_operations.alh"
 include "object_operations.alh"
 include "modelling.alh"
 include "modelling.alh"
 
 
-Boolean function simulate(model : Element):
+Boolean function main(model : Element):
 	// Do a single simulation step
 	// Do a single simulation step
 
 
 	// Find enabled transitions
 	// Find enabled transitions

+ 0 - 1
interface/HUTN/includes/constructors.alh

@@ -1,2 +1 @@
-Action function construct_function()
 Action function construct_function_list(list : Element)
 Action function construct_function_list(list : Element)

+ 3 - 0
kernel/modelverse_jit/bytecode_ir.py

@@ -35,6 +35,9 @@ class VariableNode(object):
     """Represents a variable node, which has an identifier and an optional name."""
     """Represents a variable node, which has an identifier and an optional name."""
     def __init__(self, node_id, name):
     def __init__(self, node_id, name):
         self.node_id = node_id
         self.node_id = node_id
+        if node_id is None:
+            print(locals())
+            raise Exception("NONE")
         self.name = name
         self.name = name
 
 
     def __str__(self):
     def __str__(self):

+ 2 - 0
kernel/modelverse_jit/cfg_optimization.py

@@ -254,6 +254,8 @@ def try_redefine_as_direct_call(definition, jit, called_globals):
                 called_globals.add(loaded_ptr)
                 called_globals.add(loaded_ptr)
     elif isinstance(target, cfg_ir.Literal):
     elif isinstance(target, cfg_ir.Literal):
         node_id = target.literal
         node_id = target.literal
+        if target.literal is None:
+            raise Exception("NONE")
         thunk_name = jit.jit_thunk_constant_function(node_id)
         thunk_name = jit.jit_thunk_constant_function(node_id)
         definition.redefine(
         definition.redefine(
             cfg_ir.DirectFunctionCall(
             cfg_ir.DirectFunctionCall(

+ 8 - 0
kernel/modelverse_jit/jit.py

@@ -445,6 +445,8 @@ class ModelverseJit(object):
             else:
             else:
                 param_name_ids, = yield [("RDK", [param_set_id])]
                 param_name_ids, = yield [("RDK", [param_set_id])]
                 param_names = yield [("RV", [n]) for n in param_name_ids]
                 param_names = yield [("RV", [n]) for n in param_name_ids]
+                #NOTE Patch up strange links...
+                param_names = [i for i in param_names if i is not None]
                 param_vars = yield [("RD", [param_set_id, k]) for k in param_names]
                 param_vars = yield [("RD", [param_set_id, k]) for k in param_names]
                 self.jitted_parameters[body_id] = (param_vars, param_names, is_mutable)
                 self.jitted_parameters[body_id] = (param_vars, param_names, is_mutable)
 
 
@@ -763,6 +765,8 @@ def compile_function_body_baseline(
     """Have the baseline JIT compile the function with the given name and body id."""
     """Have the baseline JIT compile the function with the given name and body id."""
     (parameter_ids, parameter_list, _), = yield [
     (parameter_ids, parameter_list, _), = yield [
         ("CALL_ARGS", [jit.jit_signature, (body_id,)])]
         ("CALL_ARGS", [jit.jit_signature, (body_id,)])]
+    if None in parameter_list:
+        raise JitCompilationFailedException('JIT exception...')
     param_dict = dict(list(zip(parameter_ids, parameter_list)))
     param_dict = dict(list(zip(parameter_ids, parameter_list)))
     body_param_dict = dict(list(zip(parameter_ids, [p + "_ptr" for p in parameter_list])))
     body_param_dict = dict(list(zip(parameter_ids, [p + "_ptr" for p in parameter_list])))
     body_bytecode, = yield [("CALL_ARGS", [jit.jit_parse_bytecode, (body_id,)])]
     body_bytecode, = yield [("CALL_ARGS", [jit.jit_parse_bytecode, (body_id,)])]
@@ -811,6 +815,10 @@ def compile_function_body_fast_original(jit, function_name, body_id, _):
     (parameter_ids, parameter_list, _), = yield [
     (parameter_ids, parameter_list, _), = yield [
         ("CALL_ARGS", [jit.jit_signature, (body_id,)])]
         ("CALL_ARGS", [jit.jit_signature, (body_id,)])]
     param_dict = dict(list(zip(parameter_ids, parameter_list)))
     param_dict = dict(list(zip(parameter_ids, parameter_list)))
+    if None in param_dict:
+        del param_dict[None]
+        print("REMOVING NONE IN PARAMETERS for ")
+        print(locals())
     body_bytecode, = yield [("CALL_ARGS", [jit.jit_parse_bytecode, (body_id,)])]
     body_bytecode, = yield [("CALL_ARGS", [jit.jit_parse_bytecode, (body_id,)])]
     bytecode_analyzer = bytecode_to_cfg.AnalysisState(jit, function_name, param_dict)
     bytecode_analyzer = bytecode_to_cfg.AnalysisState(jit, function_name, param_dict)
     bytecode_analyzer.analyze(body_bytecode)
     bytecode_analyzer.analyze(body_bytecode)

+ 4 - 0
kernel/modelverse_kernel/main.py

@@ -124,6 +124,10 @@ class ModelverseKernel(object):
             if self.phase_v == "finish":
             if self.phase_v == "finish":
                 gen = self.helper_init(task_root)
                 gen = self.helper_init(task_root)
             elif self.inst is None:
             elif self.inst is None:
+                print("No instruction pointer found...")
+                print(locals())
+                print("Phase: " + str(self.phase_v))
+                print("Debug: " + str(self.debug_info[taskname]))
                 raise Exception("Instruction pointer could not be found!")
                 raise Exception("Instruction pointer could not be found!")
             elif isinstance(self.phase_v, string_types):
             elif isinstance(self.phase_v, string_types):
                 if self.phase_v == "init" and self.jit.is_jittable_entry_point(self.inst):
                 if self.phase_v == "init" and self.jit.is_jittable_entry_point(self.inst):

+ 135 - 8
models/AL_to_py.alc

@@ -103,17 +103,144 @@ include "object_operations.alh"
 //
 //
 //        raise primitive_functions.PrimitiveFinished(instruction + next_inst)
 //        raise primitive_functions.PrimitiveFinished(instruction + next_inst)
 
 
+String function get_indent(indentation : Integer):
+	String code
+	code = ""
+	while (indentation > 0):
+		code = code + "    "
+		indentation = indentation - 1
+	return code!
+
+String function code_print(node : Element, indentation : Integer):
+	String code
+	String inst_type
+
+	inst_type = cast_value(node)
+	code = "(no_printer_for_" + inst_type + ")"
+
+	if (inst_type == "if"):
+		String cond_code
+		String true_code
+		String false_code
+
+		cond_code = code_print(node["cond"], 0)
+		true_code = code_print(node["then"], indentation + 1)
+		if (dict_in(node, "else")):
+			false_code = get_indent(indentation) + "else:\n"
+			false_code = code_print(node["else"], indentation + 1)
+		else:
+			false_code = ""
+
+		code = get_indent(indentation) + "if(" + cond_code + "):\n" + true_code + false_code
+	elif (inst_type == "constant"):
+		String value
+		value = cast_value(node["node"])
+		if (value == "true"):
+			value = "True"
+		elif (value == "false"):
+			value = "False"
+		code = get_indent(indentation) + value
+	elif (inst_type == "return"):
+		if (dict_in(node, "value")):
+			code = get_indent(indentation) + "return " + code_print(node["value"], 0) + "\n"
+		else:
+			code = get_indent(indentation) + "return\n"
+	elif (inst_type == "declare"):
+		code = ""
+	elif (inst_type == "resolve"):
+		if (is_physical_string(node["var"])):
+			code = cast_string(node["var"])
+		else:
+			code = "var_" + cast_id(node["var"])
+	elif (inst_type == "assign"):
+		code = get_indent(indentation) + code_print(node["var"], 0) + " = " + code_print(node["value"], 0) + "\n"
+	elif (inst_type == "access"):
+		code = code_print(node["var"], indentation)
+	elif (inst_type == "while"):
+		code = get_indent(indentation) + "while (" + code_print(node["cond"], 0) + "):\n" + code_print(node["body"], indentation + 1)
+	elif (inst_type == "call"):
+		String func_name
+		String params
+
+		params = ""
+		func_name = code_print(node["func"], 0)
+
+		Element param
+		param = node["params"]
+		Boolean continue
+		continue = True
+		while (continue):
+			if (params == ""):
+				params = code_print(param["value"], 0)
+			else:
+				params = params + ", " + code_print(param["value"], 0)
+			if (bool_not(dict_in(param, "next_param"))):
+				continue = False
+			param = param["next_param"]
+
+		code = func_name + "(" + params + ")"
+		if (indentation > 0):
+			code = get_indent(indentation) + code + "\n"
+
+	if (dict_in(node, "next")):
+		code = code + code_print(node["next"], indentation)
+
+	return code!
+
 Boolean function main(model : Element):
 Boolean function main(model : Element):
 	// Read out the main function
 	// Read out the main function
-	String initial_function
+	log("Start up MAIN function")
 	String al_node
 	String al_node
+	Element function_element
+	String code
+
+	Element funcdefs
+	String function
+	funcdefs = allInstances(model, "AL/funcdef")
+	code = ""
+	while (set_len(funcdefs) > 0):
+		// Iterate over all functions
+		function = set_pop(funcdefs)
+
+		log("Starting at function " + function)
+		log("Got keys: " + set_to_string(dict_keys(model["model"][function])))
+		log("Parameters:")
+		Element params
+		String param
+		params = dict_keys(model["model"][function]["params"])
+		code = code + "def func_" + cast_id(model["model"][function]) + "("
+		while (set_len(params) > 0):
+			param = set_pop(params)
+			log("  " + param + " --> " + cast_id(model["model"][function]["params"][param]))
+			code = code + "var_" + cast_id(model["model"][function]["params"][param])
+			if (set_len(params) > 0):
+				code = code + ", "
+		code = code + "):\n"
+			
+		function_element = model["model"][function]["body"]
+		al_node = cast_value(function_element)
+		while (cast_value(function_element) == "global"):
+			log("Assigning to " + cast_value(function_element["next"]["var"]["var"]))
+			log("  the element: " + cast_id(function_element["next"]["value"]["node"]))
+			log("  keys: " + set_to_string(dict_keys(function_element["next"]["value"]["node"])))
+			log("Function is element: " + cast_id(function_element["next"]["value"]["node"]))
+			function_element = function_element["next"]["next"]
+		log("Started execution at " + cast_value(function_element))
+		log("Started REAL execution at " + cast_value(function_element))
+		
+		code = code + code_print(function_element, 1)
+
+	log("Finding initial function...")
+	function = set_pop(allInstances(model, "AL/Initial"))
+	function = set_pop(allAssociationDestinations(model, function, "AL/initial_funcdef"))
+	log("Initial function: " + cast_id(model["model"][function]))
+	code = code + "main = func_" + cast_id(model["model"][function]) + "\n"
+
+	// Found the main function, though we only have the name of the function to assign...
+	// What we can do is reassign main to that function!
 
 
-	initial_function = set_pop(allInstances(model, "AL/Initial"))
-	initial_function = set_pop(allAssociationDestinations(model, initial_function))
-	al_node = cast_value(initial_function)
-	log("Read out initial node: " + initial_function)
-	log("Value: " + al_node)
+	log("Generated code:")
+	log(code)
 
 
-	// Ready, now branch out
-	// TODO
+	log("Function block can now be invoked by calling the 'main' function!")
 	return True!
 	return True!

+ 2 - 2
models/cbd_design.mvc

@@ -1,7 +1,7 @@
 include "primitives.alh"
 include "primitives.alh"
 
 
-Class Float {}
-Class String {}
+SimpleAttribute Float {}
+SimpleAttribute String {}
 
 
 Class Block{}
 Class Block{}
 Class ICBlock{}
 Class ICBlock{}

+ 6 - 2
models/reachability.alc

@@ -108,7 +108,9 @@ Boolean function reachability_graph(model : Element):
 				if (integer_lt(dict_repr[key], transition_vectors_consume[transition][key])):
 				if (integer_lt(dict_repr[key], transition_vectors_consume[transition][key])):
 					// Impossible transition, so discard this one
 					// Impossible transition, so discard this one
 					possible = False
 					possible = False
-					break!
+					// Alternative implementation of break, which seems to crash JIT sometimes
+					//break!
+					keys = set_create()
 
 
 			if (possible):
 			if (possible):
 				new_dict_repr = dict_copy(dict_repr)
 				new_dict_repr = dict_copy(dict_repr)
@@ -135,7 +137,9 @@ Boolean function reachability_graph(model : Element):
 
 
 					if (dict_eq(reachable_states[other_state_id], new_dict_repr)):
 					if (dict_eq(reachable_states[other_state_id], new_dict_repr)):
 						target_id = other_state_id
 						target_id = other_state_id
-						break!
+						// Alternative implementation of break, which seems to crash JIT sometimes
+						//break!
+						keys = set_create()
 
 
 				if (target_id == -1):
 				if (target_id == -1):
 					// New state
 					// New state

+ 15 - 0
models/test.alc

@@ -0,0 +1,15 @@
+include "primitives.alh"
+
+Boolean function other(a : Boolean, b : Boolean, c : Integer, d : String, e : Integer):
+	a = 6
+	return False!
+
+Boolean function main(model : Element, c : Element):
+	log("Test")
+	Integer a
+	a = 1
+	a = 2
+	a = 3
+	log("Model: " + cast_id(model))
+	log("Model2: " + cast_id(c))
+	return True!

+ 2 - 2
state/modelverse_state/main.py

@@ -162,7 +162,7 @@ class ModelverseState(object):
                 return False
                 return False
         elif not isinstance(value, primitive_types):
         elif not isinstance(value, primitive_types):
             return False
             return False
-        elif isinstance(value, integer_types) and not (-2**63 <= value <= 2**64 - 1):
+        elif isinstance(value, integer_types) and not (-2**63 <= value <= 2**63 - 1):
             return False
             return False
         return True
         return True
 
 
@@ -228,9 +228,9 @@ class ModelverseState(object):
             del self.cache[node][value]
             del self.cache[node][value]
         except KeyError:
         except KeyError:
             # Didn't exist
             # Didn't exist
+            #print("No such entry: " + str(locals()))
             pass
             pass
         except:
         except:
-            print(locals())
             raise
             raise
         return None
         return None
 
 

+ 1 - 1
state/test/test_read_value.py

@@ -36,7 +36,7 @@ class TestReadValue(unittest.TestCase):
 
 
     def test_read_value_integer_ib_positive(self):
     def test_read_value_integer_ib_positive(self):
         # Just within range
         # Just within range
-        for i in range(2**64-10, 2**64):
+        for i in range(2**63-10, 2**63):
             id1 = self.mvs.create_nodevalue(i)
             id1 = self.mvs.create_nodevalue(i)
             assert id1 != None
             assert id1 != None
 
 

+ 2 - 1
test_printer.py

@@ -6,5 +6,6 @@ init()
 login("admin", "admin")
 login("admin", "admin")
 
 
 model_add("formalisms/String", "formalisms/SimpleClassDiagrams", open("models/String.mvc", 'r').read())
 model_add("formalisms/String", "formalisms/SimpleClassDiagrams", open("models/String.mvc", 'r').read())
+transformation_add_AL({}, {}, "models/test", open("models/test.alc", 'r').read())
 transformation_add_AL({"AL": "formalisms/ActionLanguage"}, {"String": "formalisms/String"}, "models/AL_to_Py", open("models/AL_to_py.alc", 'r').read())
 transformation_add_AL({"AL": "formalisms/ActionLanguage"}, {"String": "formalisms/String"}, "models/AL_to_Py", open("models/AL_to_py.alc", 'r').read())
-transformation_execute_AL("models/AL_to_PY", {"AL": "models/AL_to_Py"}, {"String": "models/printed_string"})
+transformation_execute_AL("models/AL_to_Py", {"AL": "models/test"}, {"String": "models/printed_string"})

+ 4 - 1
unit/test_all.py

@@ -238,6 +238,7 @@ class TestModelverse(unittest.TestCase):
         assert transformation_execute_MANUAL("test/pn_design_to_runtime", {"PetriNet": "test/my_pn"}, {"PetriNet_Runtime": "test/my_pn_RT"}, manual_callback) == True
         assert transformation_execute_MANUAL("test/pn_design_to_runtime", {"PetriNet": "test/my_pn"}, {"PetriNet_Runtime": "test/my_pn_RT"}, manual_callback) == True
         print("OK")
         print("OK")
         assert transformation_execute_AL("test/pn_simulate", {"PetriNet_Runtime": "test/my_pn_RT"}, {"PetriNet_Runtime": "test/my_pn_RT"}) == True
         assert transformation_execute_AL("test/pn_simulate", {"PetriNet_Runtime": "test/my_pn_RT"}, {"PetriNet_Runtime": "test/my_pn_RT"}) == True
+        print("Exec AL OK")
         assert transformation_execute_MT("test/pn_runtime_to_design", {"PetriNet_Runtime": "test/my_pn_RT"}, {"PetriNet": "test/my_pn"}) == True
         assert transformation_execute_MT("test/pn_runtime_to_design", {"PetriNet_Runtime": "test/my_pn_RT"}, {"PetriNet": "test/my_pn"}) == True
         print("MT OK")
         print("MT OK")
 
 
@@ -322,6 +323,7 @@ class TestModelverse(unittest.TestCase):
         model_delete("tracability")
         model_delete("tracability")
         model_delete("type mappings/tracability")
         model_delete("type mappings/tracability")
 
 
+    """
     def test_SCCD_basic(self):
     def test_SCCD_basic(self):
         model_add("test/SCCD", "formalisms/SimpleClassDiagrams", open("models/SCCD.mvc", 'r').read())
         model_add("test/SCCD", "formalisms/SimpleClassDiagrams", open("models/SCCD.mvc", 'r').read())
         model_add("test/SCCD_Trace", "formalisms/SimpleClassDiagrams", open("models/SCCD_Trace.mvc", 'r').read())
         model_add("test/SCCD_Trace", "formalisms/SimpleClassDiagrams", open("models/SCCD_Trace.mvc", 'r').read())
@@ -388,6 +390,7 @@ class TestModelverse(unittest.TestCase):
                           (147.9, "displayNone"),
                           (147.9, "displayNone"),
                           (148.4, "displayYellow"),
                           (148.4, "displayYellow"),
                          ]
                          ]
+    """
 
 
     def test_switch_MM(self):
     def test_switch_MM(self):
         model_add("test/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
         model_add("test/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
@@ -475,4 +478,4 @@ if __name__== "__main__":
     print("Setting up")
     print("Setting up")
     tmv.setUp()
     tmv.setUp()
     print("Start test")
     print("Start test")
-    tmv.test_operations()
+    tmv.test_operations()

+ 1 - 1
wrappers/modelverse.py

@@ -131,7 +131,7 @@ def __run_new_modelverse_activity(address, username, password, taskname, pipe, c
                 response = pipe.recv()
                 response = pipe.recv()
 
 
                 if response.name == "output":
                 if response.name == "output":
-                    controller.addInput(Event("data_input", "action_in", [response.parameters, context]))
+                    controller.addInput(Event("data_input", "action_in", [response.parameters, None]))
                 else:
                 else:
                     raise Exception("Unknown data from SC to MV: " + str(response))
                     raise Exception("Unknown data from SC to MV: " + str(response))
                 empty = False
                 empty = False

+ 4 - 0
wrappers/modelverse_SCCD.py

@@ -1,7 +1,11 @@
 """
 """
 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)
 
 
+<<<<<<< HEAD
 Date:   Wed Mar 28 08:08:55 2018
 Date:   Wed Mar 28 08:08:55 2018
+=======
+Date:   Thu Apr  5 09:43:06 2018
+>>>>>>> testing
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server