Package org.python.indexer

Examples of org.python.indexer.Scope


        this.table = table;
    }

    public Scope getTable() {
        if (table == null) {
            table = new Scope(null, Scope.Type.SCOPE);
        }
        return table;
    }
View Full Code Here


        if (s.isGlobalName(name.id)) {
            b = s.getGlobalTable().put(name.id, name, rvalue, kindOr(SCOPE));
            Indexer.idx.putLocation(name, b);
        } else {
            Scope bindingScope = s.getScopeSymtab();
            b = bindingScope.put(name.id, name, rvalue,
                                 kindOr(bindingScope.isFunctionScope() ? VARIABLE : SCOPE));
        }

        name.setType(b.followType());

        // XXX: this seems like a bit of a hack; should at least figure out
View Full Code Here

        this("<unknown>", null);
    }

    public NClassType(String name, Scope parent) {
        this.name = name;
        this.setTable(new Scope(parent, Scope.Type.CLASS));
        if (parent != null) {
            this.getTable().setPath(parent.extendPath(name));
        } else {
            this.getTable().setPath(name);
        }
View Full Code Here

     * Create a temporary binding and definition for this name.
     * If we later encounter a true definition we'll remove this
     * node from the defs and add it to the refs.
     */
    private NBinding makeTempBinding(Scope s) {
        Scope scope = s.getScopeSymtab();

        NBinding b = scope.put(id, this, new NUnknownType(), NBinding.Kind.SCOPE);
        setType(b.getType().follow());

        // Update the qname to this point in case we add attributes later.
        // If we don't add attributes, this path extension is harmless/unused.
        getTable().setPath(scope.extendPath(id));

        return b;
    }
View Full Code Here

            return getType();
        }
        setType(name.setType(mod));

        if (!isTop() && mod.getFile() != null) {
            Scope parentPkg = getPrevious().getTable();
            NBinding mb = Indexer.idx.moduleTable.lookup(mod.getFile());
            parentPkg.put(name.id, mb);
        }

        resolveExpr(next, s);
        return getType();
    }
View Full Code Here

        }

        // Start with module for current file (i.e. containing directory).

        NModuleType start = null;
        Scope mtable = s.getSymtabOfType(Scope.Type.MODULE);
        if (mtable != null) {
            start = Indexer.idx.loadModule(mtable.getPath());
            if (start != null) {
                return start;
            }
        }
View Full Code Here

        addChildren(names);
    }

    @Override
    public NType resolve(Scope s) throws Exception {
        Scope moduleTable = s.getGlobalTable();
        for (NName name : names) {
            if (s.isGlobalName(name.id)) {
                continue// already bound by this (or another) global stmt
            }
            s.addGlobalName(name.id);
            NBinding b = moduleTable.lookup(name);
            if (b == null) {
                b = moduleTable.put(name.id, null, new NUnknownType(), NBinding.Kind.SCOPE);
            }
            Indexer.idx.putLocation(name, b);
        }
        return getType();
    }
View Full Code Here

        NTupleType fromType = new NTupleType();
        NameBinder param = NameBinder.make(NBinding.Kind.PARAMETER);

        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);
View Full Code Here

        NImport.bindAliases(s, aliases);
    }

    @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());
View Full Code Here

TOP

Related Classes of org.python.indexer.Scope

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.