|
@@ -46,120 +46,99 @@ def integer_subtraction(a, b, **remainder):
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] - b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] - b['value']})
|
|
|
|
|
|
def integer_addition(a, b, **remainder):
|
|
def integer_addition(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] + b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] + b['value']})
|
|
|
|
|
|
def integer_multiplication(a, b, **remainder):
|
|
def integer_multiplication(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] * b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] * b['value']})
|
|
|
|
|
|
def integer_division(a, b, **remainder):
|
|
def integer_division(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': int(a['value']) // b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': int(a['value']) // b['value']})
|
|
|
|
|
|
def integer_lt(a, b, **remainder):
|
|
def integer_lt(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] < b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] < b['value']})
|
|
|
|
|
|
def bool_and(a, b, **remainder):
|
|
def bool_and(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] and b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] and b['value']})
|
|
|
|
|
|
def bool_or(a, b, **remainder):
|
|
def bool_or(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] or b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] or b['value']})
|
|
|
|
|
|
def bool_not(a, **remainder):
|
|
def bool_not(a, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
- result = {'value': not a['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': not a['value']})
|
|
|
|
|
|
def float_subtraction(a, b, **remainder):
|
|
def float_subtraction(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] - b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] - b['value']})
|
|
|
|
|
|
def float_addition(a, b, **remainder):
|
|
def float_addition(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] + b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] + b['value']})
|
|
|
|
|
|
def float_multiplication(a, b, **remainder):
|
|
def float_multiplication(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] * b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] * b['value']})
|
|
|
|
|
|
def float_division(a, b, **remainder):
|
|
def float_division(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': float(a['value']) / float(b['value'])}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': float(a['value']) / float(b['value'])})
|
|
|
|
|
|
def float_lt(a, b, **remainder):
|
|
def float_lt(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': a['value'] < b['value']}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] < b['value']})
|
|
|
|
|
|
def string_join(a, b, **remainder):
|
|
def string_join(a, b, **remainder):
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
b['value'], = yield [("RV", [b['id']])]
|
|
- result = {'value': str(a['value']) + str(b['value'])}
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': str(a['value']) + str(b['value'])})
|
|
|
|
|
|
def string_split(a, b, **remainder):
|
|
def string_split(a, b, **remainder):
|
|
# TODO make non-primitive, though compiled
|
|
# TODO make non-primitive, though compiled
|
|
- a_value, b_value = yield [("RV", [a]), ("RV", [b])]
|
|
|
|
- result = a_value.split(b_value)
|
|
|
|
- elems = yield [("CN", [])] + [("CNV", [v]) for v in result]
|
|
|
|
- new_val = elems[0]
|
|
|
|
- yield [("CD", [new_val, i, v]) for i, v in enumerate(elems[1:])]
|
|
|
|
- raise PrimitiveFinished(new_val)
|
|
|
|
-
|
|
|
|
if 'value' not in a:
|
|
if 'value' not in a:
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
a['value'], = yield [("RV", [a['id']])]
|
|
if 'value' not in b:
|
|
if 'value' not in b:
|
|
@@ -171,100 +150,84 @@ def string_split(a, b, **remainder):
|
|
raise PrimitiveFinished({'id': new_val})
|
|
raise PrimitiveFinished({'id': new_val})
|
|
|
|
|
|
def string_get(a, b, **remainder):
|
|
def string_get(a, b, **remainder):
|
|
- a_value, b_value = yield [("RV", [a]), ("RV", [b])]
|
|
|
|
- result, = yield [("CNV", [a_value[b_value]])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
|
|
+ if 'value' not in b:
|
|
|
|
+ b['value'], = yield [("RV", [b['id']])]
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'][b['value']]})
|
|
|
|
|
|
def string_len(a, **remainder):
|
|
def string_len(a, **remainder):
|
|
- a_value, = yield [("RV", [a])]
|
|
|
|
- result, = yield [("CNV", [len(a_value)])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
|
|
+ raise PrimitiveFinished({'value': len(a['value'])})
|
|
|
|
|
|
def value_eq(a, b, **remainder):
|
|
def value_eq(a, b, **remainder):
|
|
- a_value, b_value = yield [("RV", [a]), ("RV", [b])]
|
|
|
|
- result, = yield [("CNV", [a_value == b_value])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
|
|
+ if 'value' not in b:
|
|
|
|
+ b['value'], = yield [("RV", [b['id']])]
|
|
|
|
+ raise PrimitiveFinished({'value': a['value'] == b['value']})
|
|
|
|
|
|
def element_eq(a, b, **remainder):
|
|
def element_eq(a, b, **remainder):
|
|
- result, = yield [("CNV", [a == b])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if "id" not in a:
|
|
|
|
+ print("MATERIALIZING A element_eq")
|
|
|
|
+ if "value" in a:
|
|
|
|
+ a['id'], = yield [("CNV", [a['value']])]
|
|
|
|
+ if "id" not in b:
|
|
|
|
+ print("MATERIALIZING B element_eq")
|
|
|
|
+ if "value" in b:
|
|
|
|
+ b['id'], = yield [("CNV", [b['value']])]
|
|
|
|
+ raise PrimitiveFinished({'value': a['id'] == b['id']})
|
|
|
|
|
|
def cast_string(a, **remainder):
|
|
def cast_string(a, **remainder):
|
|
- a_value, = yield [("RV", [a])]
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
if isinstance(a_value, dict):
|
|
if isinstance(a_value, dict):
|
|
- result, = yield [("CNV", [str(a_value["value"])])]
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': str(a['value']['value'])})
|
|
else:
|
|
else:
|
|
- result, = yield [("CNV", [str(a_value)])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': str(a['value'])})
|
|
|
|
|
|
def cast_float(a, **remainder):
|
|
def cast_float(a, **remainder):
|
|
- a_value, = yield [("RV", [a])]
|
|
|
|
- result, = yield [("CNV", [float(a_value)])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
|
|
+ raise PrimitiveFinished({'value': float(a['value'])})
|
|
|
|
|
|
def cast_boolean(a, **remainder):
|
|
def cast_boolean(a, **remainder):
|
|
- a_value, = yield [("RV", [a])]
|
|
|
|
- result, = yield [("CNV", [bool(a_value)])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
|
|
+ raise PrimitiveFinished({'value': bool(a['value'])})
|
|
|
|
|
|
def cast_integer(a, **remainder):
|
|
def cast_integer(a, **remainder):
|
|
- a_value, = yield [("RV", [a])]
|
|
|
|
- result, = yield [("CNV", [int(a_value)])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
|
|
+ raise PrimitiveFinished({'value': int(a['value'])})
|
|
|
|
|
|
def cast_value(a, **remainder):
|
|
def cast_value(a, **remainder):
|
|
- a_value, = yield [("RV", [a])]
|
|
|
|
|
|
+ if 'value' not in a:
|
|
|
|
+ a['value'], = yield [("RV", [a['id']])]
|
|
if isinstance(a_value, dict):
|
|
if isinstance(a_value, dict):
|
|
- # Action or type
|
|
|
|
- value = a_value["value"]
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': str(a['value']['value'])})
|
|
else:
|
|
else:
|
|
- value = json.dumps(a_value)
|
|
|
|
- result, = yield [("CNV", [value])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
|
|
+ raise PrimitiveFinished({'value': json.dumps(a['value'])})
|
|
|
|
|
|
def cast_id(a, **remainder):
|
|
def cast_id(a, **remainder):
|
|
- result, = yield [("CNV", ["%s" % (a)])]
|
|
|
|
- raise PrimitiveFinished(result)
|
|
|
|
-
|
|
|
|
-def list_insert(a, b, c, **remainder):
|
|
|
|
- # TODO make non-primitive, though compiled
|
|
|
|
- a_outgoing, c_value = yield [("RO", [a]), ("RV", [c])]
|
|
|
|
- links = yield [("RD", [a, i]) for i in range(c_value, len(a_outgoing))] + \
|
|
|
|
- [("RDE", [a, i]) for i in range(c_value, len(a_outgoing))]
|
|
|
|
-
|
|
|
|
- if sys.version_info[0] < 3:
|
|
|
|
- values = links[:len(links)/2]
|
|
|
|
- edges = links[len(links)/2:]
|
|
|
|
- else:
|
|
|
|
- values = links[:len(links) // 2]
|
|
|
|
- edges = links[len(links) // 2:]
|
|
|
|
-
|
|
|
|
- yield [("CD", [a, c_value, b])] + \
|
|
|
|
- [("CD", [a, c_value + 1 + index, value]) for index, value in enumerate(values)] + \
|
|
|
|
- [("DE", [i]) for i in edges]
|
|
|
|
- raise PrimitiveFinished(a)
|
|
|
|
-
|
|
|
|
-def list_delete(a, b, **remainder):
|
|
|
|
- # TODO make non-primitive, though compiled
|
|
|
|
- a_outgoing, b_value = yield [("RO", [a]), ("RV", [b])]
|
|
|
|
- links = yield [("RD", [a, i]) for i in range(b_value, len(a_outgoing))] + \
|
|
|
|
- [("RDE", [a, i]) for i in range(b_value, len(a_outgoing))]
|
|
|
|
-
|
|
|
|
- if sys.version_info[0] < 3:
|
|
|
|
- values = links[:len(links) / 2]
|
|
|
|
- edges = links[len(links) / 2:]
|
|
|
|
- else:
|
|
|
|
- values = links[:len(links) // 2]
|
|
|
|
- edges = links[len(links) // 2:]
|
|
|
|
-
|
|
|
|
- yield [("CD", [a, b_value + index, value]) for index, value in enumerate(values[1:])] + \
|
|
|
|
- [("DE", [i]) for i in edges]
|
|
|
|
- raise PrimitiveFinished(a)
|
|
|
|
|
|
+ if "id" not in a:
|
|
|
|
+ print("MATERIALIZING A cast_id")
|
|
|
|
+ if "value" in a:
|
|
|
|
+ a['id'], = yield [("CNV", [a['value']])]
|
|
|
|
+ else:
|
|
|
|
+ a['id'], = yield [("CN", [])]
|
|
|
|
+ raise PrimitiveFinished({'value': str(a['id'])})
|
|
|
|
|
|
def dict_add_fast(a, b, c, **remainder):
|
|
def dict_add_fast(a, b, c, **remainder):
|
|
# TODO deprecate, as dict_add is now also efficient
|
|
# TODO deprecate, as dict_add is now also efficient
|
|
- v, = yield [("RV", [b])]
|
|
|
|
- yield [("CD", [a, v, c])]
|
|
|
|
|
|
+ if "value" not in b:
|
|
|
|
+ b['value'], = yield [("RV", [b['id']])]
|
|
|
|
+ if "id" not in c:
|
|
|
|
+ print("MATERIALIZING C dict_add_fast")
|
|
|
|
+ c['id'], = yield [("CNV", [c['value']])]
|
|
|
|
+
|
|
|
|
+ yield [("CD", [a['id'], b['value'], c['id']])]
|
|
raise PrimitiveFinished(a)
|
|
raise PrimitiveFinished(a)
|
|
|
|
|
|
def dict_delete(a, b, **remainder):
|
|
def dict_delete(a, b, **remainder):
|