Package org.cx4a.rsense.typing.annotation

Examples of org.cx4a.rsense.typing.annotation.TypeVariable


            if (array.isModified()) {
                return;
            }
        } else {
            TypeVarMap tvmap = getTypeVarMap(object);
            TypeVariable var = TypeVariable.valueOf("t");
            if (tvmap != null && tvmap.containsKey(var)) {
                element = tvmap.get(var);
            }
        }
       
View Full Code Here


                            vertex.addType(object);
                        }
                        continue;
                    }
                }
                TypeVariable var = TypeVariable.valueOf("t");
                TypeVarMap tvmap = getTypeVarMap(object);
                if (tvmap != null && tvmap.containsKey(var)) {
                    vertex.update(tvmap.get(var));
                }
            }
View Full Code Here

    public boolean resolveMethodArg(Template template, ClassType classType, TypeExpression argType, IRubyObject receiver, IRubyObject arg) {
        if (argType == null) { return true; }

        switch (argType.getType()) {
        case VARIABLE: {
            TypeVariable var = (TypeVariable) argType;
            TypeVarMap typeVarMap = RuntimeHelper.getTypeVarMap(receiver);
            if (classType != null
                && typeVarMap != null
                && classType.containsType(var)) {
                Vertex vertex = typeVarMap.get(var);
                if (vertex == null) {
                    vertex = graph.createFreeVertex();
                    typeVarMap.put(var, vertex);
                }
                vertex.addType(arg);
                graph.propagateEdges(vertex);
            } else {
                Vertex vertex = env.get(var);
                if (vertex == null) {
                    vertex = graph.createFreeVertex();
                    env.put(var, vertex);
                }
                vertex.addType(arg);
                graph.propagateEdges(vertex);
            }
            return true;
        }
        case APPLICATION: {
            TypeApplication app = (TypeApplication) argType;
            List<TypeExpression> types = app.getTypes();
            IRubyObject ret = resolveIdentity(template, app.getIdentity());
            if (!(ret instanceof RubyModule) || !arg.isKindOf((RubyModule) ret)) {
                return false;
            } else {
                RubyModule klass = (RubyModule) ret;
                ClassType klassType = RuntimeHelper.getClassAnnotation(klass);
                TypeVarMap typeVarMap = RuntimeHelper.getTypeVarMap(arg);
                if (klassType != null && typeVarMap != null) {
                    List<TypeVariable> vars = klassType.getTypes();
                    for (int i = 0; i < vars.size(); i++) {
                        TypeVariable var = vars.get(i);
                        Vertex vertex = typeVarMap.get(var);
                        if (i < types.size() && vertex != null) {
                            TypeExpression expr = types.get(i);
                            for (IRubyObject a : vertex.getTypeSet()) {
                                if (!resolveMethodArg(template, klassType, expr, receiver, a)) {
View Full Code Here

        if (returnType == null) { return TypeSet.EMPTY; }

        TypeSet result = new TypeSet();
        switch (returnType.getType()) {
        case VARIABLE: {
            TypeVariable var = (TypeVariable) returnType;
            if (var.getName().equals("self")) {
                result.add(receiver);
            } else if (var.getName().equals("nil")) {
                result.add(runtime.getNil());
            } else {
                Vertex vertex = env.get(var);
                TypeVarMap typeVarMap = RuntimeHelper.getTypeVarMap(receiver);
                if (vertex != null) {
                    result.addAll(vertex.getTypeSet());
                } else if (classType != null
                           && typeVarMap != null
                           && classType.containsType(var)) {
                    vertex = typeVarMap.get(var);
                    if (vertex != null) {
                        result.addAll(vertex.getTypeSet());
                    } else {
                        result.add(runtime.getNil());
                    }
                }
            }
            return result;
        }
        case APPLICATION: {
            TypeApplication app = (TypeApplication) returnType;
            List<TypeExpression> types = app.getTypes();
            IRubyObject ret = resolveIdentity(template, app.getIdentity());
            if (ret != null && ret instanceof RubyClass) {
                RubyClass klass = (RubyClass) ret;
                ret = graph.newInstanceOf(klass);
                ClassType klassType = RuntimeHelper.getClassAnnotation(klass);
                TypeVarMap typeVarMap = RuntimeHelper.getTypeVarMap(ret);
                if (klassType != null && typeVarMap != null) {
                    List<TypeVariable> vars = klassType.getTypes();
                    for (int i = 0; i < vars.size(); i++) {
                        TypeVariable var = vars.get(i);
                        if (i < types.size()) {
                            TypeExpression expr = types.get(i);
                            TypeSet ts = processMethodReturn(template, classType, expr, receiver);
                            Vertex vertex = graph.createFreeVertex();
                            vertex.addTypes(ts);
View Full Code Here

TOP

Related Classes of org.cx4a.rsense.typing.annotation.TypeVariable

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.