瀏覽代碼

Merge branch 'master' into testing

Yentl Van Tendeloo 8 年之前
父節點
當前提交
feb5827fc0

+ 3 - 3
addis/PM_to_SCCD.mvc

@@ -211,7 +211,7 @@ Composite schedule {
                     String function value(model : Element, name : String, mapping : Element):
                         return "cd"!
                     $
-                value_parameter = $
+                value_parameters = $
                     Element function raise(model : Element, name : String, mapping : Element):
                         String code
                         Element result
@@ -305,7 +305,7 @@ Composite schedule {
                         else:
                             return result!
                     $
-                value_parameter = $
+                value_parameters = $
                     Element function raise(model : Element, name : String, mapping : Element):
                         String code
                         Element result
@@ -787,7 +787,7 @@ Composite schedule {
                     String function value(model : Element, name : String, mapping : Element):
                         return "local"!
                     $
-                value_parameter = $
+                value_parameters = $
                     Element function raise(model : Element, name : String, mapping : Element):
                         String code
                         Element result

+ 1 - 1
addis/SCCD_MetaModel.mvc

@@ -170,7 +170,7 @@ Class Raise{
     scope ?: EventScope
     port ?: String
     target ?: String
-    parameter ?: Action
+    parameters ?: Action
 }
 Association raise_parameters(Raise, ActualParameter){
     order : Natural

+ 1 - 9
bootstrap/compiler.alc

@@ -9,14 +9,9 @@ Element function generic_compile(code : String, port : String):
 	String response
 	response = comm_get(port)
 	if (response == "OK"):
-		Integer count
 		Element lst
 
-		lst = list_create()
-		count = comm_get(port)
-		while (count > 0):
-			list_append(lst, comm_get(port))
-			count = count - 1
+		lst = comm_get_list(port)
 
 		comm_close(port)
 		return lst!
@@ -26,9 +21,6 @@ Element function generic_compile(code : String, port : String):
 		return read_root()!
 
 Element function compile_code(code : String):
-	// TODO to test performance impact
-	return code!
-
 	String port
 	port = comm_connect("compiler")
 	comm_set(port, "code")

+ 12 - 0
bootstrap/services.alc

@@ -79,3 +79,15 @@ Void function comm_close(comm : String):
 	if (string_startswith(comm, "__")):
 		dict_delete(read_root(), comm)
 	return!
+
+Element function comm_get_list(comm : String):
+	Integer length
+	Element result
+
+	length = comm_get(comm)
+	result = list_create()
+	while (length > 0):
+		list_append(result, comm_get(comm))
+		length = length - 1
+
+	return result!

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

@@ -4,3 +4,4 @@ Void function comm_set(comm : String, value : Element)
 Element function comm_get(comm : String)
 String function comm_connect(service : String)
 Void function comm_close(comm : String)
+Element function comm_get_list(comm : String)

+ 6 - 2
scripts/HUTN_service.py

@@ -11,6 +11,7 @@ init()
 login("HUTN", "HUTN")
 
 def compile_service(port):
+    start = time.time()
     temp_file = ".tmp_%s" % port
     def compile_AL(code):
         code_fragments = code.split("\n")
@@ -25,7 +26,9 @@ def compile_service(port):
             f.write(code)
             f.flush()
 
+        ss = time.time()
         compiled = do_compile(temp_file, COMPILER_PATH + "/grammars/actionlanguage.g", "CS")
+        print("    Compile: %ss" % (time.time() - ss))
         os.remove(temp_file)
         return compiled
 
@@ -53,16 +56,17 @@ def compile_service(port):
         if mode == "code":
             compiled = compile_AL(code)
             service_set(port, "OK")
-            [service_set(port, i) for i in compiled]
+            service_set(port, compiled)
         elif mode == "model":
             compiled = compile_model(code)
             service_set(port, "OK")
-            [service_set(port, i) for i in compiled]
+            service_set(port, compiled)
         else:
             raise Exception("No such mode: " + mode)
     except Exception as e:
         service_set(port, str(e))
         raise
+    print("Compile took %ss" % (time.time() - start))
 
 service_register("compiler", compile_service)
 try:

+ 7 - 1
wrappers/modelverse.py

@@ -78,6 +78,12 @@ def _check_type(value):
     if not isinstance(value, (int, long, float, str, unicode, bool)):
         raise UnsupportedValue("%s : %s" % (value, str(type(value))))
 
+def _check_type_list(value):
+    if isinstance(value, list):
+        [_check_type(i) for i in value]
+    else:
+        _check_type(value)
+
 def _dict_to_list(python_dict):
     lst = []
     for k, v in python_dict.items():
@@ -913,7 +919,7 @@ def service_get(port):
 
 def service_set(port, value):
     """Set a value on a specified port."""
-    _check_type(value)
+    _check_type_list(value)
     _goto_mode(MODE_SERVICE)
 
     _input(value, port=port)