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

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

        # add self
        if inst is not None:
            self_func_arg = FunctionArg()
            self_func_arg.obj = inst
            args = [self_func_arg] + args

        # add args
        funcArgs = self.parse_args(args)

        for fa in funcArgs:
            func_field.get_field().get_attribute(fa.name).revise(fa.obj)

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

        return ret
コード例 #2
0
ファイル: functions.py プロジェクト: disktnk/chainer-compiler
    def vcall(self,
              module: 'values.Field',
              graph: 'graphs.Graph',
              inst: 'values.ValueRef',
              args: 'FunctionArgInput',
              line=-1):
        ret = values.ValueRef(
            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).revise(v)

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

        return ret