|
@@ -62,22 +62,22 @@ def create_get_length(expression):
|
|
|
# get them right.
|
|
|
# pylint: disable=I0011,C0103
|
|
|
def __set_add(a, b):
|
|
|
- tmp = tree_ir.StoreLocalInstruction(None, a)
|
|
|
+ store_a, load_a = tree_ir.evaluate_and_load(a)
|
|
|
return tree_ir.create_block(
|
|
|
- tmp,
|
|
|
- tree_ir.CreateEdgeInstruction(tmp.create_load(), b),
|
|
|
- tmp.create_load())
|
|
|
+ store_a,
|
|
|
+ tree_ir.CreateEdgeInstruction(load_a, b),
|
|
|
+ load_a)
|
|
|
|
|
|
def __dict_add(a, b, c):
|
|
|
- a_tmp = tree_ir.StoreLocalInstruction(None, a)
|
|
|
- b_tmp = tree_ir.StoreLocalInstruction(None, b)
|
|
|
+ store_a, load_a = tree_ir.evaluate_and_load(a)
|
|
|
+ store_b, load_b = tree_ir.evaluate_and_load(b)
|
|
|
return tree_ir.create_block(
|
|
|
- a_tmp,
|
|
|
- b_tmp,
|
|
|
+ store_a,
|
|
|
+ store_b,
|
|
|
tree_ir.CreateEdgeInstruction(
|
|
|
- tree_ir.CreateEdgeInstruction(a_tmp.create_load(), c),
|
|
|
- b_tmp.create_load()),
|
|
|
- a_tmp.create_load())
|
|
|
+ tree_ir.CreateEdgeInstruction(load_a, c),
|
|
|
+ load_b),
|
|
|
+ load_a)
|
|
|
|
|
|
def __list_read(a, b):
|
|
|
# The statements in this function generate the following code:
|
|
@@ -89,17 +89,17 @@ def __list_read(a, b):
|
|
|
# raise Exception("List read out of bounds: %s" % b_value)
|
|
|
# result
|
|
|
|
|
|
- a_tmp = tree_ir.StoreLocalInstruction(None, a)
|
|
|
+ store_a, load_a = tree_ir.evaluate_and_load(a)
|
|
|
b_val = tree_ir.StoreLocalInstruction(
|
|
|
None,
|
|
|
tree_ir.ReadValueInstruction(b))
|
|
|
result = tree_ir.StoreLocalInstruction(
|
|
|
None,
|
|
|
tree_ir.ReadDictionaryValueInstruction(
|
|
|
- a_tmp.create_load(), b_val.create_load()))
|
|
|
+ load_a.create_load(), b_val.create_load()))
|
|
|
|
|
|
return tree_ir.create_block(
|
|
|
- a_tmp,
|
|
|
+ store_a,
|
|
|
b_val,
|
|
|
result,
|
|
|
tree_ir.SelectInstruction(
|
|
@@ -126,17 +126,18 @@ def __list_append(a, b):
|
|
|
# _ = yield [("CD", [a_tmp, len(a_outgoing), b_tmp])]
|
|
|
# a
|
|
|
|
|
|
- a_tmp = tree_ir.StoreLocalInstruction(None, a)
|
|
|
- b_tmp = tree_ir.StoreLocalInstruction(None, b)
|
|
|
+ store_a, load_a = tree_ir.evaluate_and_load(a)
|
|
|
+ store_b, load_b = tree_ir.evaluate_and_load(b)
|
|
|
return tree_ir.create_block(
|
|
|
- a_tmp,
|
|
|
+ store_a,
|
|
|
+ store_b,
|
|
|
tree_ir.CreateDictionaryEdgeInstruction(
|
|
|
- a_tmp.create_load(),
|
|
|
+ load_a,
|
|
|
create_get_length(
|
|
|
tree_ir.ReadOutgoingEdgesInstruction(
|
|
|
- a_tmp.create_load())),
|
|
|
- b_tmp),
|
|
|
- a_tmp.create_load())
|
|
|
+ load_a)),
|
|
|
+ load_b),
|
|
|
+ load_a)
|
|
|
|
|
|
def __log(a):
|
|
|
# Original definition:
|
|
@@ -146,18 +147,18 @@ def __log(a):
|
|
|
# print("== LOG == " + str(a_value))
|
|
|
# raise PrimitiveFinished(a)
|
|
|
|
|
|
- a_tmp = tree_ir.StoreLocalInstruction(None, a)
|
|
|
+ store_a, load_a = tree_ir.evaluate_and_load(a)
|
|
|
return tree_ir.CompoundInstruction(
|
|
|
tree_ir.create_block(
|
|
|
- a_tmp,
|
|
|
+ store_a,
|
|
|
tree_ir.PrintInstruction(
|
|
|
tree_ir.BinaryInstruction(
|
|
|
tree_ir.LiteralInstruction("== LOG == "),
|
|
|
'+',
|
|
|
tree_ir.CallInstruction(
|
|
|
tree_ir.LoadGlobalInstruction('str'),
|
|
|
- [tree_ir.ReadValueInstruction(a_tmp.create_load())])))),
|
|
|
- a_tmp.create_load())
|
|
|
+ [tree_ir.ReadValueInstruction(load_a)])))),
|
|
|
+ load_a)
|
|
|
|
|
|
MISC_INTRINSICS = {
|
|
|
# Reference equality
|