|
@@ -160,6 +160,17 @@ def __log(a):
|
|
|
[tree_ir.ReadValueInstruction(load_a)])))),
|
|
|
load_a)
|
|
|
|
|
|
+def __read_nr_out(a):
|
|
|
+ # Original definition:
|
|
|
+ #
|
|
|
+ # def read_nr_out(a, **remainder):
|
|
|
+ # outgoing, = yield [("RO", [a])]
|
|
|
+ # result, = yield [("CNV", [len(outgoing)])]
|
|
|
+ # raise PrimitiveFinished(result)
|
|
|
+
|
|
|
+ return tree_ir.CreateNodeWithValueInstruction(
|
|
|
+ create_get_length(tree_ir.ReadOutgoingEdgesInstruction(a)))
|
|
|
+
|
|
|
MISC_INTRINSICS = {
|
|
|
# Reference equality
|
|
|
'element_eq' :
|
|
@@ -238,6 +249,8 @@ MISC_INTRINSICS = {
|
|
|
'is not',
|
|
|
tree_ir.LiteralInstruction(None))),
|
|
|
|
|
|
+ 'read_nr_out' : __read_nr_out,
|
|
|
+
|
|
|
# read_root
|
|
|
'read_root' :
|
|
|
lambda:
|
|
@@ -269,10 +282,7 @@ MISC_INTRINSICS = {
|
|
|
'set_add' : __set_add,
|
|
|
|
|
|
# List operations
|
|
|
- 'list_len' :
|
|
|
- lambda a:
|
|
|
- tree_ir.CreateNodeWithValueInstruction(
|
|
|
- create_get_length(tree_ir.ReadOutgoingEdgesInstruction(a))),
|
|
|
+ 'list_len' : __read_nr_out,
|
|
|
|
|
|
'list_read' : __list_read,
|
|
|
'list_append' : __list_append,
|
|
@@ -281,6 +291,22 @@ MISC_INTRINSICS = {
|
|
|
'log' : __log
|
|
|
}
|
|
|
|
|
|
+def __read_nr_out_cfg(original_def, a):
|
|
|
+ # Original definition:
|
|
|
+ #
|
|
|
+ # def read_nr_out(a, **remainder):
|
|
|
+ # outgoing, = yield [("RO", [a])]
|
|
|
+ # result, = yield [("CNV", [len(outgoing)])]
|
|
|
+ # raise PrimitiveFinished(result)
|
|
|
+
|
|
|
+ original_def.redefine(
|
|
|
+ cfg_ir.CreateNode(
|
|
|
+ original_def.insert_before(
|
|
|
+ cfg_ir.create_pure_simple_call(
|
|
|
+ 'len',
|
|
|
+ original_def.insert_before(
|
|
|
+ cfg_ir.create_read_outgoing_edges(a))))))
|
|
|
+
|
|
|
MISC_CFG_INTRINSICS = {
|
|
|
# Reference equality
|
|
|
'element_eq' :
|
|
@@ -351,16 +377,11 @@ MISC_CFG_INTRINSICS = {
|
|
|
original_def.redefine(
|
|
|
cfg_ir.CreateNode(original_def.insert_before(cfg_ir.Read(a)))),
|
|
|
|
|
|
+ # State reads
|
|
|
+ 'read_nr_out' : __read_nr_out_cfg,
|
|
|
+
|
|
|
# List operations
|
|
|
- 'list_len' :
|
|
|
- lambda original_def, a:
|
|
|
- original_def.redefine(
|
|
|
- cfg_ir.CreateNode(
|
|
|
- original_def.insert_before(
|
|
|
- cfg_ir.create_pure_simple_call(
|
|
|
- 'len',
|
|
|
- original_def.insert_before(
|
|
|
- cfg_ir.create_read_outgoing_edges(a))))))
|
|
|
+ 'list_len' : __read_nr_out_cfg
|
|
|
}
|
|
|
|
|
|
def register_time_intrinsic(target_jit):
|