Yentl Van Tendeloo 8 лет назад
Родитель
Сommit
9c93634f3b

+ 1 - 0
bootstrap/bootstrap.py

@@ -75,6 +75,7 @@ def bootstrap():
                     "create_edge": ["Element", "Element", "Element"],
                     "create_value": ["Element", "Element"],
                     "is_edge": ["Boolean", "Element"],
+                    "is_error": ["Boolean", "Element"],
                     "read_nr_out": ["Integer", "Element"],
                     "read_out": ["Element", "Element", "Integer"],
                     "read_nr_in": ["Integer", "Element"],

+ 1 - 0
bootstrap/primitives.alc

@@ -67,3 +67,4 @@ Boolean function is_physical_action(a: Element) = ?primitives/is_physical_action
 Float function time() = ?primitives/time
 String function hash(a : String) = ?primitives/hash
 Float function __sleep(a : Float, b : Boolean) = ?primitives/__sleep
+Boolean function is_error() = ?primitives/is_error

+ 3 - 0
bootstrap/transform.alc

@@ -437,6 +437,9 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 				elif (has_value(result)):
 					// New value defined, so assign!
 					instantiate_attribute(host_model, new_mapping[label], string_substr(attribute, string_len("value_"), string_len(attribute) + 1), result)
+				elif (is_error(result)):
+					log("Error in evaluation of attribute " + attribute)
+					log("On element with label " + label)
 				else:
 					// Try to interpret as code
 					instantiate_attribute_code(host_model, new_mapping[label], string_substr(attribute, string_len("value_"), string_len(attribute) + 1), result)

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

@@ -123,3 +123,4 @@ Element function dict_create()
 String function reverseKeyLookup(a: Element, b: Element)
 Element function reverseKeyLookupMulti(a: Element, b: Element)
 Element function dict_values(dict : Element)
+Boolean function is_error(a : Element)

+ 7 - 0
kernel/modelverse_kernel/primitives.py

@@ -409,3 +409,10 @@ def __sleep(a, b, **remainder):
     timeout, interruptable = yield [("RV", [a]), ("RV", [b])]
     yield [("SLEEP", [timeout, interruptable])]
     raise PrimitiveFinished(a)
+
+def is_error(a, **remainder):
+    if a is None:
+        result, = yield [("CNV", [True])]
+    else:
+        result, = yield [("CNV", [False])]
+    raise PrimitiveFinished(result)