Package org.python.indexer.types

Examples of org.python.indexer.types.NType


        resolveList(defaults, s);

        Scope funcTable = getTable();
        int argnum = 0;
        for (NNode a : args) {
            NType argtype = NFunctionDef.getArgType(args, defaults, argnum++);
            param.bind(funcTable, a, argtype);
            fromType.add(argtype);
        }

        if (varargs != null) {
            NType u = new NUnknownType();
            param.bind(funcTable, varargs, u);
            fromType.add(u);
        }

        if (kwargs != null) {
            NType u = new NUnknownType();
            param.bind(funcTable, kwargs, u);
            fromType.add(u);
        }

        // A lambda body is not an NBody, so it doesn't undergo the two
        // pre-resolve passes for finding global statements and name-binding
        // constructs.  However, the lambda expression may itself contain
        // name-binding constructs (generally, other lambdas), so we need to
        // perform the name-binding pass on it before resolving.
        try {
            funcTable.setNameBindingPhase(true);
            body.visit(new BindingFinder(funcTable));
        } finally {
            funcTable.setNameBindingPhase(false);
        }

        NType toType = resolveExpr(body, funcTable);
        if (getType().isFuncType()) {  // else warning logged at method entry above
            getType().asFuncType().setReturnType(toType);
        }
        return getType();
    }
View Full Code Here


        addChildren(target, value);
    }

    @Override
    public NType resolve(Scope s) throws Exception {
        NType ltype = null, rtype = null;
        if (left != null) {
            ltype = resolveExpr(left, s).follow();
        }
        if (right != null) {
            rtype = resolveExpr(right, s).follow();
View Full Code Here

    @Override
    public NType resolve(Scope s) throws Exception {
        Scope scope = s.getScopeSymtab();
        resolveExpr(qname, s);

        NType bottomType = qname.getBottom().getType();
        if (!bottomType.isModuleType()) {
            return setType(new NUnknownType());
        }
        NModuleType mt = (NModuleType)bottomType;
        setType(mt);
View Full Code Here

    @Override
    public NType resolve(Scope scope) throws Exception {
        for (NNode n : seq) {
            // XXX:  This works for inferring lambda return types, but needs
            // to be fixed for functions (should be union of return stmt types).
            NType returnType = resolveExpr(n, scope);
            if (returnType != Indexer.idx.builtins.None) {
                setType(returnType);
            }
        }
        return getType();
View Full Code Here

        addChildren(keywords);
    }

    @Override
    public NType resolve(Scope s) throws Exception {
        NType ft = resolveExpr(func, s);
        List<NType> argTypes = new ArrayList<NType>();
        for (NNode a : args) {
            argTypes.add(resolveExpr(a, s));
        }
        resolveList(keywords, s);
        resolveExpr(starargs, s);
        resolveExpr(kwargs, s);

        if (ft.isClassType()) {
            return setType(ft)// XXX:  was new NInstanceType(ft)
        }

        if (ft.isFuncType()) {
            return setType(ft.asFuncType().getReturnType().follow());
        }

        if (ft.isUnknownType()) {
            NUnknownType to = new NUnknownType();
            NFuncType at = new NFuncType(to);
            NUnionType.union(ft, at);
            return setType(to);
        }
View Full Code Here

        if (name.indexOf(".") == -1) {  // unqualified
            return getModule(name);
        }

        String[] mods = name.split("\\.");
        NType type = getModule(mods[0]);
        if (type == null) {
            return null;
        }
        for (int i = 1; i < mods.length; i++) {
            type = type.getTable().lookupType(mods[i]);
            if (!(type instanceof NModuleType)) {
                return null;
            }
        }
        return (NModuleType)type;
View Full Code Here

TOP

Related Classes of org.python.indexer.types.NType

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.