def test_factorial(self): code = tlc.compile(FACTORIAL_SOURCE) bytecode = ','.join([str(ord(c)) for c in code]) n = 5 expected = 120 res = self.timeshift_from_portal(tlc_interp_without_call, tlc_interp_eval_without_call, [bytecode, 0, n], policy=P_OOPSPEC)#, backendoptimize=True) assert res == expected self.check_insns(malloc=1)
def test_factorial(self): code = tlc.compile(FACTORIAL_SOURCE) bytecode = ','.join([str(ord(c)) for c in code]) n = 5 expected = 120 res = self.timeshift_from_portal( tlc_interp_without_call, tlc_interp_eval_without_call, [bytecode, 0, n], policy=P_OOPSPEC) #, backendoptimize=True) assert res == expected self.check_insns(malloc=1)
def test_nth_item(self): # get the nth item of a chained list code = tlc.compile(""" NIL PUSH 40 CONS PUSH 20 CONS PUSH 10 CONS PUSHARG DIV """) bytecode = ','.join([str(ord(c)) for c in code]) res = self.timeshift_from_portal(tlc_interp_without_call, tlc_interp_eval_without_call, [bytecode, 0, 1], policy=P_OOPSPEC)#, backendoptimize=True) assert res == 20
def test_nth_item(self): # get the nth item of a chained list code = tlc.compile(""" NIL PUSH 40 CONS PUSH 20 CONS PUSH 10 CONS PUSHARG DIV """) bytecode = ','.join([str(ord(c)) for c in code]) res = self.timeshift_from_portal( tlc_interp_without_call, tlc_interp_eval_without_call, [bytecode, 0, 1], policy=P_OOPSPEC) #, backendoptimize=True) assert res == 20
def exec_code(self, src, inputarg): pool = tlc.ConstantPool() bytecode = tlc.compile(src, pool) interp = self._get_interp(bytecode, pool) return self.meta_interp(interp, [0, inputarg], view=False)
def exec_code(self, src, inputarg): pool = tlc.ConstantPool() bytecode = tlc.compile(src, pool) interp = self._get_interp(bytecode, pool) return self.meta_interp(interp, [0, inputarg])