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)
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)
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
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)