コード例 #1
0
    def vcall(self,
              module: 'values.Field',
              graph: 'graphs.Graph',
              inst: 'values.Object',
              args: 'FunctionArgInput',
              context: 'VEvalContext' = None,
              line=-1):
        ret = values.Object(
            values.UserDefinedInstance(module, None, self.classinfo))
        inst = ret

        func_field = values.Field()
        func_field.set_module(module)

        # add args
        funcArgs = self.args.merge_inputs(inst, args)

        for k, v in funcArgs.keywords.items():
            func_field.get_field().get_attribute(k,
                                                 from_module=False).revise(v)

        astc = vevaluator.AstContext(self.ast.body,
                                     self.lineno - 1,
                                     filename=self.filename)
        vevaluator.veval_ast(astc, func_field, graph)

        # dispose because of exit from function
        func_field.dispose()

        return ret
コード例 #2
0
    def vcall(self, module: 'values.Field', graph: 'graphs.Graph', inst: 'values.Object', args: 'FunctionArgInput',
              context: 'VEvalContext' = None, line=-1):

        if context is None:
            context = VEvalContext()

        context.stacktrace.append(line)
        with context.stacktrace:

            func_field = values.Field()
            func_field.set_module(module)

            # add args
            funcArgs = self.args.merge_inputs(inst, args)

            for k, v in funcArgs.keywords.items():
                func_field.get_field().get_attribute(k, from_module=False).revise(utils.try_get_obj(v, self.name, utils.LineProperty()))

            astc = vevaluator.AstContext(self.ast.body, self.lineno - 1, filename=self.filename)
            ret = vevaluator.veval_ast(astc, func_field, graph, context)

            # dispose because of exit from function
            func_field.dispose()

            return ret
コード例 #3
0
ファイル: functions.py プロジェクト: mrsekut/chainer-compiler
    def vcall(self,
              module: 'values.Field',
              graph: 'core.Graph',
              inst: 'values.ValueRef',
              args: 'FunctionArgInput',
              line=-1):
        func_field = values.Field()
        func_field.set_module(module)

        # add args
        funcArgs = self.args.merge_inputs(inst, args)

        for k, v in funcArgs.keywords.items():
            func_field.get_field().get_attribute(k,
                                                 from_module=False).revise(v)

        astc = vevaluator.AstContext(self.ast.body,
                                     self.lineno - 1,
                                     filename=self.filename)
        return vevaluator.veval_ast(astc, func_field, graph)