Package org.cx4a.rsense.typing.vertex

Examples of org.cx4a.rsense.typing.vertex.Vertex


                }

                List<TemplateAttribute> attrs = generateTemplateAttributes(receivers, args, block);
                boolean applied = false;
                for (TemplateAttribute attr : attrs) {
                    Vertex returnVertex = applyTemplateAttribute(graph, vertex, name, attr, callSuper);
                    if (returnVertex != null) {
                        applied = true;
                        if (!noReturn)
                            accumulator.addAll(returnVertex.getTypeSet());
                    }
                }
                if (!applied)
                    graph.notifyMethodMissingEvent(vertex);
                if (result.isNextMethodChange()) {
View Full Code Here


        context.pushScope(scope);

        Template template = new Template(method, context.getCurrentFrame(), scope, attr);
        method.addTemplate(attr, template);

        Vertex returnVertex = template.getReturnVertex();
        setFrameTemplate(context.getCurrentFrame(), template);

        AnnotationResolver.Result result = AnnotationHelper.resolveMethodAnnotation(graph, template);
        if (result == AnnotationResolver.Result.UNRESOLVED) {
            Logger.warn(SourceLocation.of(vertex), "annotation unmatched: %s", method);
        }

        Vertex ret = method.call(graph, template, receiver, args, argVertices, block);
        if (ret != null && result != AnnotationResolver.Result.RESOLVED) {
            graph.addEdgeAndUpdate(ret, returnVertex);
        }

        context.popScope();
View Full Code Here

        MultipleAsgnNode masgn = null;
        int preCount = 0;
        boolean isRest = false;
        Node rest = null;
        ListNode pre = null;
        Vertex vertex = graph.createFreeVertex();

        if (varNode == null || varNode instanceof ZeroArgNode) {
            noargblock = true;
        } else if (varNode instanceof MultipleAsgnNode) {
            masgn = (MultipleAsgnNode) varNode;
            preCount = masgn.getPreCount();
            isRest = masgn.getRest() != null;
            rest = masgn.getRest();
            pre = masgn.getPre();
        }
       
        if (args != null && !args.isEmpty()) {
            for (IRubyObject value : args) {
                pushLoopFrame(context, block.getFrame(), returnVertex, vertex);
                context.pushScope(block.getScope());

                if (noargblock) {}
                else if (masgn != null) {
                    Array array;
                    if (!expanded) {
                        // FIXME to_ary
                        if (value instanceof Array) {
                            array = (Array) value;
                        } else {
                            array = createArray(graph, new Vertex[] { graph.createFreeSingleTypeVertex(value) });
                        }
                    } else {
                        if (value instanceof Array) {
                            array = (Array) value;
                        } else {
                            array = createArray(graph, new Vertex[] { graph.createFreeSingleTypeVertex(value) });
                        }
                    }
                    multipleAssign(graph, masgn, array);
                } else {
                    assign(graph, varNode, graph.createFreeSingleTypeVertex(value));
                }

                if (block.getBodyNode() != null) {
                    Vertex v = graph.createVertex(block.getBodyNode());
                    graph.addEdgeAndPropagate(v, vertex);
                }

                context.popScope();
                popLoopFrame(context);
            }
        } else {
            pushLoopFrame(context, block.getFrame(), returnVertex, vertex);
            context.pushScope(block.getScope());

            if (block.getBodyNode() != null) {
                Vertex v = graph.createVertex(block.getBodyNode());
                graph.addEdgeAndPropagate(v, vertex);
            }
           
            context.popScope();
            popLoopFrame(context);
View Full Code Here

        return vertex;
    }

    public static Vertex yield(Graph graph, YieldVertex vertex) {
        Vertex returnVertex = null;
        if (vertex.getTemplate() != null)
            returnVertex = vertex.getTemplate().getReturnVertex();

        // return immediately if no need to apply
        Proc block = (Proc) vertex.getBlock();
        Vertex argsVertex = vertex.getArgsVertex();
        if (block != null
            && block.isApplied(vertex)
            && (argsVertex == null
                || !argsVertex.isChanged())) {
            return vertex;
        }
        if (argsVertex != null)
            argsVertex.markUnchanged();

        if (block != null)
            block.recordYield(vertex);
        returnVertex = yield(graph, block, (argsVertex != null ? argsVertex.getTypeSet() : TypeSet.EMPTY), vertex.getExpandArguments(), returnVertex);
        if (returnVertex != null)
            graph.addEdgeAndUpdate(returnVertex, vertex);
       
        return vertex;
    }
View Full Code Here

    public static RubyModule getNamespace(Graph graph, Colon3Node node) {
        if (node instanceof Colon2ImplicitNode) {
            return graph.getRuntime().getContext().getFrameModule();
        } else if (node instanceof Colon2Node) {
            Vertex left = graph.createVertex(((Colon2Node) node).getLeftNode());
            IRubyObject object = left.singleType();
            if (object instanceof RubyModule) {
                return (RubyModule) object;
            } else {
                return null;
            }
View Full Code Here

        return array;
    }

    public static Vertex createArrayVertex(Graph graph, Node node, Vertex[] elements) {
        Array array = createArray(graph, elements);
        Vertex vertex = new PassThroughVertex(node);
        vertex.addType(array);
        array.getTypeVarVertex().addEdge(vertex);
        return vertex;
    }
View Full Code Here

    }


    public static Vertex createHashVertex(Graph graph, Node node, Vertex[] elements) {
        Hash hash = createHash(graph, elements);
        Vertex vertex = new PassThroughVertex(node);
        vertex.addType(hash);
        hash.getKeyTypeVarVertex().addEdge(vertex);
        hash.getValueTypeVarVertex().addEdge(vertex);
        return vertex;
    }
View Full Code Here

        for (Map.Entry<TypeVariable, Vertex> entry : tvmap.entrySet()) {
            entry.getValue().addEdge(etvmap.get(entry.getKey()));
           
            IRubyObject value = entry.getValue().singleType();
            if (value != null) {
                Vertex v = new Vertex();
                v.addType(value);
                fixedTypeVarMap.put(entry.getKey(), v);
            }
        }
    }
View Full Code Here

            Iterator<IRubyObject> ite = typeSet.iterator();
            int k = 0, n = typeSet.size();
            int newUnit = unit / n;
            IRubyObject v = ite.next();
            for (int j = 0; j < size; j++) {
                Vertex vertex = new Vertex(1);
                vertex.addType(v);
                result[j].put(entry.getKey(), vertex);
                if (++k == newUnit) {
                    k = 0;
                    if (!ite.hasNext()) {
                        ite = typeSet.iterator();
View Full Code Here

    }

    public TypeVarMap clone() {
        TypeVarMap clone = new TypeVarMap();
        for (Map.Entry<TypeVariable, Vertex> entry : entrySet()) {
            clone.put(entry.getKey(), new Vertex(null, new TypeSet(entry.getValue().getTypeSet())));
        }
        return clone;
    }
View Full Code Here

TOP

Related Classes of org.cx4a.rsense.typing.vertex.Vertex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.