Explorar o código

Fixed AL_text bug

Yentl Van Tendeloo %!s(int64=7) %!d(string=hai) anos
pai
achega
7ee5e33c2c

+ 0 - 1
bootstrap/core_algorithm.alc

@@ -51,7 +51,6 @@ String function full_name(model_id : String):
 
 Void function initialize_core():
 	// 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)
 	return !
 
 Boolean function is_typed_by(model_id : String, metamodel_id : String):

+ 5 - 3
bootstrap/modelling.alc

@@ -494,6 +494,10 @@ Element function trim_AL_constructors(list : Element):
 
 	return lst!
 
+Element function add_text(elem : Element, code : String):
+	dict_add(elem, "__text", code)
+	return elem!
+
 Element function construct_model_list(model : Element, list : Element):
 	String command
 
@@ -516,11 +520,9 @@ Element function construct_model_list(model : Element, list : Element):
 		elif (command == "instantiate_attribute_ref"):
 			instantiate_attribute_ref(model, list_pop_final(list), list_pop_final(list), list_pop_final(list))
 		elif (command == "instantiate_attribute_code"):
-			instantiate_attribute_code(model, list_pop_final(list), list_pop_final(list), construct_function_list(trim_AL_constructors(list)))
+			instantiate_attribute_code(model, list_pop_final(list), list_pop_final(list), add_text(construct_function_list(trim_AL_constructors(list)), list_pop_final(list)))
 		elif (command == "instantiate_link"):
 			instantiate_link(model, list_pop_final(list), list_pop_final(list), list_pop_final(list), list_pop_final(list))
-		elif (command == "add_code_model"):
-			export_node(list_pop_final(list), construct_function_list(trim_AL_constructors(list)))
 		else:
 			log("Modelling error: did not understand command " + command)
 

+ 1 - 1
interface/HUTN/hutn_compiler/model_visitor.py

@@ -127,7 +127,7 @@ class ModelVisitor(Visitor):
                 f.flush()
             directory = os.path.realpath(__file__).rsplit(os.sep, 1)[0]
             compiled = do_compile(".code.alc", directory + "/../grammars/actionlanguage.g", "CS")
-            return compiled
+            return compiled + [code]
 
         children = tree.get_children("MODEL_ID")
         attr_name = children[0].get_text()

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

@@ -26,6 +26,5 @@ String function model_define_attribute(model : Element, elem : String, name : St
 String function model_define_attribute_ID(model : Element, elem : String, name : String, optional : Boolean, type : String, ID : String)
 Element function construct_model_raw(metamodel : Element)
 Element function get_func_AL_model(model : Element)
-Void function add_code_model(model : Element, export_name : String, code : Element)
 String function read_type(model : Element, name : String)
 Element function construct_model_list(metamodel : Element, list : Element)

+ 1 - 4
unit/test_all.py

@@ -1554,10 +1554,7 @@ class TestModelverse(unittest.TestCase):
                     $
             }
             """)
-        assert AL_text(read_attrs("users/user/test/a", "A")["constraint"]["AL"]).strip() == """
-            String function main(value : Element):
-                return "OK"!
-            """.strip()
+        assert AL_text(read_attrs("users/user/test/a", "A")["constraint"]["AL"]).strip() == 'String function main(value : Element):\n\treturn "OK"!'
 
     """
     def test_op_model_render(self):

+ 0 - 1
wrappers/classes/modelverse.xml

@@ -1821,7 +1821,6 @@
                                 <transition cond="self.actions and self.actions[0] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model" target=".">
                                     <script>
                                         self.load_action()
-                                        print("INTERFACE")
                                     </script>
                                     <raise event="exception">
                                         <parameter expr="'InterfaceMismatch'"/>

+ 0 - 1
wrappers/modelverse_SCCD.py

@@ -3350,7 +3350,6 @@ class Modelverse(RuntimeClassBase):
     
     def _initialized_behaviour_wait_for_action_modelling_recognized_scripted_1_exec(self, parameters):
         self.load_action()
-        print("INTERFACE")
         self.raiseInternalEvent(Event("exception", None, ['InterfaceMismatch', 'Operation cannot be executed in this context']))
     
     def _initialized_behaviour_wait_for_action_modelling_recognized_scripted_1_guard(self, parameters):