예제 #1
0
 def setup_method(self, method):
     tree = ast.parse(method.__doc__)
     tree = annotators.TypeAnnotator(
         hpcs_builtins.create_builtin_scope()).visit(tree)
     self.tree = tree
     self.builder_spy = BuilderSpy()
     self.compiler = compiler.CompilerVisitor(self.builder_spy)
예제 #2
0
    def testIllegalAssignmentToArrayElement(self):
        annotator = TypeAnnotator(hpcs_builtins.create_builtin_scope())
        an_ast = ast.parse("""
a = PlacedInt8Array(100, 0x0)
a[3] = "SomeString"
        """)

        with pytest.raises(TypeError):
            an_ast = annotator.visit(an_ast)
예제 #3
0
파일: hpcs.py 프로젝트: Jokymon/hpcs
def compile_source(source_file_name):
    checker = compiler.ConstraintChecker()

    with open(source_file_name) as source_file:
        source = ast.parse(source_file.read())
    checker.visit(source)
    type_annotator = annotators.TypeAnnotator(
        hpcs_builtins.create_builtin_scope())
    source = type_annotator.visit(source)
    vst = compiler.CompilerVisitor(llvm_builder.LLVMBuilder())
    root = vst.visit(source)
    return root.module.module
예제 #4
0
 def setup_method(self, method):
     self.annotator = TypeAnnotator(hpcs_builtins.create_builtin_scope())
     self.ast = ast.parse(method.__doc__)
     self.ast = self.annotator.visit(self.ast)