def vcall(self, module: 'values.Field', graph: 'graphs.Graph', inst: 'values.Object', args: 'functions.FunctionArgInput',
              option: 'vevaluator.VEvalContext' = None, line=-1):
        funcArgs = self.args.merge_inputs(inst, args)

        if inst.in_container:
            raise Exception('Invalid operation')

        key_hashes = inst.get_value().internal_keys.keys()
        attributes = inst.get_value().internal_values
        vargs = []
        vargs_ref = []
        for hash in key_hashes:
            varg = attributes.get_attribute(hash)
            if varg.has_obj():
                vargs.append(utils.try_get_obj(varg, 'dict_values', utils.LineProperty()).get_value())
                vargs_ref.append(utils.try_get_obj(varg, 'dict_values', utils.LineProperty()))
            else:
                assert(False)

        node = nodes.NodeGenerate('List', vargs , line)
        graph.add_node(node)

        value = values.ListValue(vargs_ref)
        value.name = '@F.{}.{}'.format(line, self.name)
        node.set_outputs([value])
        return value
Esempio n. 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
Esempio n. 3
0
    def vcall(self,
              module: 'values.Field',
              graph: 'graphs.Graph',
              inst: 'values.Object',
              args: 'functions.FunctionArgInput',
              context: 'functions.VEvalContext' = None,
              line=-1):
        assert (inst is None)

        funcArgs = self.args.merge_inputs(inst, args)
        vargs = funcArgs.get_value().inputs
        value = values.ListValue()

        if isinstance(vargs[0], values.NoneValue):
            node = nodes.NodeGenerate('List', [], line)
            graph.add_node(node)
        else:
            node = nodes.NodeConvert('List', vargs[0], line)
            graph.add_node(node)

            if vargs[0].has_constant_value():
                refs = []
                for attr_or_ref in vargs[0].internal_value:
                    refs.append(
                        utils.try_get_obj(attr_or_ref, 'list',
                                          utils.LineProperty()))

                value.internal_value = refs

        value.name = '@F.{}.{}'.format(line, self.name)
        node.set_outputs([value])
        return values.Object(value)