Browse Source

Minor fixes to code, which don't account to much: a major rewrite is required!

Yentl Van Tendeloo 7 years ago
parent
commit
14dab5342e
3 changed files with 47 additions and 4 deletions
  1. 44 3
      bootstrap/modelling.alc
  2. 2 0
      kernel/modelverse_jit/jit.py
  3. 1 1
      wrappers/modelverse_SCCD.py

+ 44 - 3
bootstrap/modelling.alc

@@ -477,7 +477,40 @@ Void function add_AL_links(model : Element, list : Element, element : Element, t
 	// The link
 	// The link
 	if (linkname == "next"):
 	if (linkname == "next"):
 		type = "Statement"
 		type = "Statement"
-	reuse_element(model, (type + "_") + linkname, "", link)
+	if (expected_type == "param_dict"):
+		// Add the link to param_dict
+		log("In param_dict adder")
+
+		reuse_element(model, "funcdef_params", "", link)
+		link = read_out(link, 0)
+		reuse_element(model, "dict_link_name", "", link)
+		link = read_edge_dst(link)
+		if (bool_not(dict_in(model["model"], "__" + cast_id(link)))):
+			reuse_element(model, "StringAttr", "__" + cast_id(link), link)
+
+		element = element[linkname]
+		reuse_element(model, "param_dict", "", element)
+
+		Element keys
+		String key
+		keys = dict_keys(element)
+		while (set_len(keys) > 0):
+			key = set_pop(keys)
+			log("Adding key " + cast_value(key))
+			link = dict_read_edge(element, key)
+
+			reuse_element(model, "param_dict_link", "", link)
+			reuse_element(model, "Element", "", read_edge_dst(link))
+			link = read_out(link, 0)
+			reuse_element(model, "dict_link_name", "", link)
+			link = read_edge_dst(link)
+			if (bool_not(dict_in(model["model"], "__" + cast_id(link)))):
+				reuse_element(model, "StringAttr", "__" + cast_id(link), link)
+
+		log("Done!")
+		return!
+	else:
+		reuse_element(model, (type + "_") + linkname, "", link)
 
 
 	// The name link
 	// The name link
 	link = read_out(link, 0)
 	link = read_out(link, 0)
@@ -561,15 +594,23 @@ String function add_AL(model : Element, element : Element):
 				add_AL_links(model, todo, elem, type, "value", "")
 				add_AL_links(model, todo, elem, type, "value", "")
 				add_AL_links(model, todo, elem, type, "next_param", "param")
 				add_AL_links(model, todo, elem, type, "next_param", "param")
 			elif (type == "funcdef"):
 			elif (type == "funcdef"):
+				log("Adding param_dict!")
 				add_AL_links(model, todo, elem, type, "body", "")
 				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, "params", "param_dict")
 				add_AL_links(model, todo, elem, type, "next", "")
 				add_AL_links(model, todo, elem, type, "next", "")
 			elif (type == "call"):
 			elif (type == "call"):
 				add_AL_links(model, todo, elem, type, "func", "")
 				add_AL_links(model, todo, elem, type, "func", "")
 				add_AL_links(model, todo, elem, type, "params", "param")
 				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, "last_param", "param")
 				add_AL_links(model, todo, elem, type, "next", "")
 				add_AL_links(model, todo, elem, type, "next", "")
+			elif (type == "Element"):
+				log("Potential funcdef found!")
+				log("   keys: " + set_to_string(dict_keys(elem)))
+				if (dict_in(elem, "body")):
+					log("Potential next function found!")
+					add_AL_links(model, todo, elem, "funcdef", "body", "")
+					add_AL_links(model, todo, elem, "funcdef", "params", "param_dict")
+					add_AL_links(model, todo, elem, "funcdef", "next", "")
 
 
 			// TODO why isn't declare added here? --> this causes the JIT to crash with a "localXXXXX is undefined" error
 			// TODO why isn't declare added here? --> this causes the JIT to crash with a "localXXXXX is undefined" error
 
 

+ 2 - 0
kernel/modelverse_jit/jit.py

@@ -754,6 +754,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,)])]

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Wed Mar 28 14:32:59 2018
+Date:   Tue Apr  3 13:31:36 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server