Browse Source

Declare also doesn't redeclare when in the same scope

Yentl Van Tendeloo 9 years ago
parent
commit
fbb392f96d

+ 16 - 2
bootstrap/object_operations.alc

@@ -174,22 +174,36 @@ String function getName(m : Element, e : Element):
 	s = dict_read(m, "model")
 	element_keys = dict_keys(s)
 
+	log("getName")
+	Element key
 	while (0 < read_nr_out(element_keys)):
-		Element key
 		key = set_pop(element_keys)
 		if (element_eq(dict_read_node(s, key), e)):
+			log("Gone")
 			return key
 
+	log("Finish")
 	return string_join(string_join("(unknown: ", cast_e2s(e)), " )")
 
 String function reverseNameLookup(s : Element, e : Element):
+	log("Lookup name")
+	log("Node: " + cast_e2s(s))
+	log("Node2: " + cast_e2s(e))
 	Element element_keys
 	element_keys = dict_keys(s)
 
+	Element key
 	while (0 < read_nr_out(element_keys)):
-		Element key
+		log("POP")
 		key = set_pop(element_keys)
+		log("Check")
+		log("Key " + cast_e2s(key))
 		if (element_eq(dict_read_node(s, key), e)):
+			log("EQ")
 			return key
+		else:
+			log("NEQ")
+		log("Read nr out")
 
+	log("Finished")
 	return string_join(string_join("(unknown: ", cast_e2s(e)), " )")

+ 1 - 1
integration/code/pn_interface.alc

@@ -518,9 +518,9 @@ Element function initial_prompt():
 				output("Model not found; aborting")
 		elif (command == "list"):
 			Element keys
+			String m_menu_list
 			keys = dict_keys(root)
 			output("Found models:")
-			String m_menu_list
 			while (read_nr_out(keys) > 0):
 				m_menu_list = set_pop(keys)
 				output((("  " + m_menu_list) + " : ") + reverseNameLookup(root, dict_read(dict_read(root, m_menu_list), "metamodel")))

+ 7 - 3
kernel/modelverse_kernel/main.py

@@ -922,9 +922,13 @@ class ModelverseKernel(object):
                                ("CN", []),
                                ("CNV", ["finish"]),
                               ]
-        new_edge =      yield [("CE", [symbols, empty_node])]
-        _, _, _ =       yield [("CE", [new_edge, new_var]),
-                               ("CD", [user_frame, "phase", new_phase]),
+
+        exists = yield [("RDN", [symbols, new_var])]
+        if exists is None:
+            new_edge =      yield [("CE", [symbols, empty_node])]
+            _ =             yield [("CE", [new_edge, new_var])]
+
+        _, _ =       yield [   ("CD", [user_frame, "phase", new_phase]),
                                ("DE", [phase_link]),
                               ]
 

+ 2 - 2
state/modelverse_state/main.py

@@ -233,7 +233,7 @@ class ModelverseState(object):
                         return (None, status.FAIL_RDICTE_UNCERTAIN)
                     else:
                         if found is not None:
-                            print("Duplicate key: %s (%s <-> %s)!" % (v, found, e1))
+                            print("Duplicate key on value: %s (%s <-> %s)!" % (v, found, e1))
                             return (None, status.FAIL_RDICTE_AMBIGUOUS)
                         found = e1
         if found is not None:
@@ -271,7 +271,7 @@ class ModelverseState(object):
                         return (None, status.FAIL_RDICTNE_UNCERTAIN)
                     else:
                         if found is not None:
-                            print("Duplicate key: %s (%s <-> %s)!" % (value_node, found, e1))
+                            print("Duplicate key on node: %s (%s <-> %s)!" % (value_node, found, e1))
                             return (None, status.FAIL_RDICTNE_AMBIGUOUS)
                         found = e1
         if found is not None: