Example #1
0
    def testAdd(self):
        def func(a, b):
            return 2 * a + b

        # Prevent leakage?
        func = replaceGlobals(func, {})

        # TODO mock console?
        compiler = CompilerContext(Console())

        interface = application.makefile.InterfaceDeclaration()

        interface.func.append(
            (func, (application.makefile.ExistingWrapper(3),
                    application.makefile.ExistingWrapper(5))))

        compiler.interface = interface

        extractProgram(compiler)
        result = analysis.cpa.evaluate(compiler)

        # Check argument and return types
        funcobj, funcast = compiler.extractor.getObjectCall(func)
        types = set([compiler.extractor.getObject(int)])

        for param in funcast.codeparameters.params:
            self.assertLocalRefTypes(param, types)

        for param in funcast.codeparameters.returnparams:
            self.assertLocalRefTypes(param, types)
Example #2
0
	def testAdd(self):
		def func(a, b):
			return 2*a+b

		# Prevent leakage?
		func = replaceGlobals(func, {})

		# TODO mock console?
		compiler = CompilerContext(Console())

		interface = application.makefile.InterfaceDeclaration()

		interface.func.append((func,
			(application.makefile.ExistingWrapper(3), application.makefile.ExistingWrapper(5))
			))

		compiler.interface = interface

		extractProgram(compiler)
		result = analysis.cpa.evaluate(compiler)

		# Check argument and return types
		funcobj, funcast = compiler.extractor.getObjectCall(func)
		types = set([compiler.extractor.getObject(int)])

		for param in funcast.codeparameters.params:
			self.assertLocalRefTypes(param, types)

		for param in funcast.codeparameters.returnparams:
			self.assertLocalRefTypes(param, types)
Example #3
0
	def pystreamCompile(self):
		compiler = context.CompilerContext(Console())
		prgm = Program()

		self.interface = prgm.interface


		with compiler.console.scope("makefile"):
			compiler.console.output("Processing %s" % self.filename)
			self.executeFile()

			if not self.interface:
				compiler.console.output("No entry points, nothing to do.")
				return

			assert self.outdir, "No output directory declared."

		extractProgram(compiler, prgm)

		application.pipeline.evaluate(compiler, prgm, self.moduleName)