示例#1
0
 def testTimesTwo_execution(self):
     mod = create_two_module()
     ee = ExecutionEngine.create_execution_engine(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('two')
     y = ee.run_function(f, [])
     self.assertEqual(2, y.to_int(True))
示例#2
0
 def testTimesTwo_execution(self):
     mod = create_two_module()
     ee = ExecutionEngine.create_execution_engine(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('two')
     y = ee.run_function(f, [])
     self.assertEqual(2, y.to_int(True))
示例#3
0
 def testTimesTwoWithFunction(self):
     mod = create_timestwo_module_with_function()
     ee = ExecutionEngine.create_interpreter(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('caller')
     x = GenericValue.of_int(ty, 3, True)
     y = ee.run_function(f, [x])
     self.assertEqual(6, y.to_int(True))
示例#4
0
 def testCumsum(self):
     mod, _ = create_cumsum_module()
     ee = ExecutionEngine.create_interpreter(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('cumsum')
     x = GenericValue.of_int(ty, 10, True)
     y = ee.run_function(f, [x])
     self.assertEqual(55, y.to_int(True))
示例#5
0
 def testTimesTwoWithFunction(self):
     mod = create_timestwo_module_with_function()
     ee = ExecutionEngine.create_interpreter(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('caller')
     x = GenericValue.of_int(ty, 3, True)
     y = ee.run_function(f, [x])
     self.assertEqual(6, y.to_int(True))
示例#6
0
 def testCumsum(self):
     mod, _ = create_cumsum_module()
     ee = ExecutionEngine.create_interpreter(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('cumsum')
     x = GenericValue.of_int(ty, 10, True)
     y = ee.run_function(f, [x])
     self.assertEqual(55, y.to_int(True))
示例#7
0
 def testTimesTwoC(self):
     mod = parse_bitcode('timestwo.c')
     ee = ExecutionEngine.create_interpreter(mod)
     ty = Type.int32(context=mod.context)
     f = mod.get_function('timestwo')
     x = GenericValue.of_int(ty, 3, True)
     y = ee.run_function(f, [x])
     
     self.assertEqual(6, y.to_int(True))
示例#8
0
    def testTimesTwoC(self):
        mod = parse_bitcode('timestwo.c')
        ee = ExecutionEngine.create_interpreter(mod)
        ty = Type.int32(context=mod.context)
        f = mod.get_function('timestwo')
        x = GenericValue.of_int(ty, 3, True)
        y = ee.run_function(f, [x])

        self.assertEqual(6, y.to_int(True))
示例#9
0
 def testLessThanZero(self):
     mod, _ = create_lessthanzero_module()
     ee = ExecutionEngine.create_interpreter(mod)
     ty = Type.int8(context=mod.context)
     f = mod.get_function('lessthanzero')
     x = GenericValue.of_int(ty, 3, True)
     y = ee.run_function(f, [x])
     self.assertEqual(0, y.to_int(True) & 1)
     
     x = GenericValue.of_int(ty, -3, True)
     y = ee.run_function(f, [x])
     self.assertEqual(1, y.to_int(True) & 1)
示例#10
0
    def testLessThanZero(self):
        mod, _ = create_lessthanzero_module()
        ee = ExecutionEngine.create_interpreter(mod)
        ty = Type.int8(context=mod.context)
        f = mod.get_function('lessthanzero')
        x = GenericValue.of_int(ty, 3, True)
        y = ee.run_function(f, [x])
        self.assertEqual(0, y.to_int(True) & 1)

        x = GenericValue.of_int(ty, -3, True)
        y = ee.run_function(f, [x])
        self.assertEqual(1, y.to_int(True) & 1)
示例#11
0
    def testAbs(self):
        mod, _ = create_abs_module()
        ee = ExecutionEngine.create_interpreter(mod)
        ty = Type.int8(context=mod.context)
        f = mod.get_function('abs')

        x = GenericValue.of_int(ty, 3, True)
        y = ee.run_function(f, [x])
        self.assertEqual(3, y.to_int(True))

        x = GenericValue.of_int(ty, -3, True)
        y = ee.run_function(f, [x])
        self.assertEqual(3, y.to_int(True) & 255)
示例#12
0
    def testGlobalLoadStore(self):
        mod = create_global_load_save_module()
        ee = ExecutionEngine.create_interpreter(mod)
        load = mod.get_function('load')
        x0 = ee.run_function(load, [])
        self.assertEqual(0, x0.to_int(True))

        ty = Type.int8(context=mod.context)
        y = GenericValue.of_int(ty, 4, True)
        store = mod.get_function('store')
        ee.run_function(store, [y])
        x = ee.run_function(load, [])
        self.assertEqual(4, x.to_int(True))
示例#13
0
    def testAbs(self):
        mod, _ = create_abs_module()
        ee = ExecutionEngine.create_interpreter(mod)
        ty = Type.int8(context=mod.context)
        f = mod.get_function('abs')

        x = GenericValue.of_int(ty, 3, True)
        y = ee.run_function(f, [x])
        self.assertEqual(3, y.to_int(True))

        x = GenericValue.of_int(ty, -3, True)
        y = ee.run_function(f, [x])
        self.assertEqual(3, y.to_int(True) & 255)
示例#14
0
    def testGlobalLoadStore(self):
        mod = create_global_load_save_module()
        ee = ExecutionEngine.create_interpreter(mod)
        load = mod.get_function('load')
        x0 = ee.run_function(load, [])
        self.assertEqual(0, x0.to_int(True))

        ty = Type.int8(context=mod.context)
        y = GenericValue.of_int(ty, 4, True)
        store = mod.get_function('store')
        ee.run_function(store, [y])
        x = ee.run_function(load, [])
        self.assertEqual(4, x.to_int(True))