Explorar o código

Fixed with test for create_instance

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
69c8a65264
Modificáronse 2 ficheiros con 9 adicións e 8 borrados
  1. 8 4
      integration/code/minimal_SCCD.mvc
  2. 1 4
      models/SCCD_execute.alc

+ 8 - 4
integration/code/minimal_SCCD.mvc

@@ -11,7 +11,10 @@ Class main {
     constructor_body = $
             Void function const(attributes : Element, parameters : Element):
                 dict_overwrite(attributes, "a", 0)
-                dict_overwrite(attributes, "id", 0)
+                if (element_eq(parameters, read_root())):
+                    dict_overwrite(attributes, "id", 0)
+                else:
+                    dict_overwrite(attributes, "id", parameters)
                 return !
         $
 }
@@ -113,7 +116,7 @@ transition (x_a, x_b) {
             Void function script(attributes : Element, evt_param : Element):
                 log("In script")
                 dict_overwrite(attributes, "a", 1)
-                dict_overwrite(attributes, "b", 2)
+                dict_overwrite(attributes, "id", 2)
                 return!
         $
 }
@@ -132,7 +135,7 @@ transition (x_b, x_c) {
     cond = $
             Boolean function cond(attributes : Element, evt_param : Element):
                 log("In condition")
-                return integer_lt(attributes["a"], attributes["b"])!
+                return integer_lt(attributes["a"], attributes["id"])!
         $
 }
 
@@ -151,8 +154,9 @@ Raise create_new_class {
                 result = create_node()
                 list_append(result, "Main")
                 list_append(result, attributes["id"])
-                list_append(result, read_root())
                 dict_overwrite(attributes, "id", integer_addition(attributes["id"], 1))
+                list_append(result, attributes["id"])
+                return result!
         $
 }
 

+ 1 - 4
models/SCCD_execute.alc

@@ -190,8 +190,6 @@ Element function get_enabled_transitions(model : Element, state : String, data :
 		// Add event parameters
 		set_add(event_parameters[evt_name], list_read(evt, 1))
 
-		log("Got enabled events: " + set_to_string(event_names))
-
 	while (read_nr_out(to_filter) > 0):
 		transition = set_pop(to_filter)
 
@@ -289,7 +287,6 @@ Element function execute_transition(model : Element, data : Element, class : Str
 			String operation
 			operation = read_attribute(model, event, "event")
 			if (operation == "create_instance"):
-				log("Creating new instance")
 				// Start up a new class of the desired type
 
 				// Parameters of this call:
@@ -615,7 +612,7 @@ Boolean function main(model : Element):
 	default_class = set_pop(filter(model, allInstances(model, "SCCD/Class"), "default", True))
 
 	// Start up the default class
-	start_class(model, data, default_class, "main", create_node())
+	start_class(model, data, default_class, "main", read_root())
 
 	Float timeout
 	Element interrupt