Ejemplo n.º 1
0
 def _complie_with_label(self, code):
     xx = "void function main() %s endfunction" % code
     
     ast = CParser().parse(xx, "#0")
     interp = Interpreter()
     bytedata = interp.assemble_ast(ast)
     
     func = bytedata.func_reference("main")
     
     return (func.bytedata.code, func.bytedata.labels) 
Ejemplo n.º 2
0
class TestPyTel_interpreter(unittest.TestCase):
    
    def setUp(self):
        pass
    
    def _complie_source(self, path):
        ast = parse_file(path)
        self.interp = Interpreter()
        bytedata = self.interp.assemble_ast(ast)
        
        return bytedata
    
    
    def test_simple_helloword(self):
        
        bytedata = self._complie_source(os.path.join(os.path.dirname(__file__), "helloword.t"))
        interp = self.interp
        from pytel.builtin import BUILTIN_LIST
        interp.init_builtin_function(BUILTIN_LIST)
        interp.link_global_code(bytedata)
        #bytedata.show()
        
        main = interp.function_reference("main", None)
        main.call(["xxx", "bb"])
Ejemplo n.º 3
0
 def cc(code):
     ast = CParser().parse(code, "#0")
     interp = Interpreter()
     bytedata = interp.assemble_ast(ast)
     func = bytedata.functions.values()[0]            
     return func.bytedata.code
Ejemplo n.º 4
0
 def _complie_source(self, path):
     ast = parse_file(path)
     self.interp = Interpreter()
     bytedata = self.interp.assemble_ast(ast)
     
     return bytedata