本文整理汇总了Python中optimizer.Optimizer.getvalue方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.getvalue方法的具体用法?Python Optimizer.getvalue怎么用?Python Optimizer.getvalue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optimizer.Optimizer
的用法示例。
在下文中一共展示了Optimizer.getvalue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subtraction
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import getvalue [as 别名]
def test_subtraction(self):
opt = Optimizer([ConstantFold])
res = opt.add_operation(Types.INT, Operations.INT_SUB,
[opt.new_constant_int(1), opt.new_constant_int(0)]
)
ops = opt.build_operations()
assert len(ops) == 0
assert opt.getvalue(res).getint() == 1
示例2: test_known_guard_true
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import getvalue [as 别名]
def test_known_guard_true(self):
opt = Optimizer([GuardPropagation])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i0])
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i0])
ops = opt.build_operations()
assert len(ops) == 1
assert opt.getvalue(i0).getint() == 1
示例3: test_guard_false
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import getvalue [as 别名]
def test_guard_false(self):
opt = Optimizer([ConstantFold, GuardPropagation])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i0])
opt.add_operation(Types.INT, Operations.INT_EQ, [i0, opt.new_constant_int(1)])
ops = opt.build_operations()
assert len(ops) == 1
assert opt.getvalue(i0).getint() == 0
示例4: test_read_unsetfield
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import getvalue [as 别名]
def test_read_unsetfield(self, cpu):
opt = Optimizer([Virtualize])
struct_descr = cpu.new_struct()
field_descr = cpu.new_field(struct_descr)
p0 = opt.add_operation(Types.REF, Operations.NEW, [], descr=struct_descr)
i0 = opt.add_operation(Types.INT, Operations.GETFIELD, [p0], descr=field_descr)
ops = opt.build_operations()
assert len(ops) == 0
assert opt.getvalue(i0).getint() == 0
示例5: test_get_setfield
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import getvalue [as 别名]
def test_get_setfield(self, cpu):
opt = Optimizer([Virtualize])
i0 = opt.add_input(Types.INT)
struct_descr = cpu.new_struct()
field_descr = cpu.new_field(struct_descr)
p0 = opt.add_operation(Types.REF, Operations.NEW, [], descr=struct_descr)
opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i0], descr=field_descr)
i1 = opt.add_operation(Types.INT, Operations.GETFIELD, [p0], descr=field_descr)
ops = opt.build_operations()
assert len(ops) == 0
assert opt.getvalue(i1) is i0
示例6: test_lt_reverse
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import getvalue [as 别名]
def test_lt_reverse(self):
opt = Optimizer([IntBounds, GuardPropagation])
i0 = opt.add_input(Types.INT)
i1 = opt.add_operation(Types.INT, Operations.INT_GT,
[i0, opt.new_constant_int(5)]
)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
i2 = opt.add_operation(Types.INT, Operations.INT_LT,
[i0, opt.new_constant_int(3)]
)
opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i2])
ops = opt.build_operations()
assert len(ops) == 2
assert opt.getvalue(i2).getint() == 0