Examples of NBinding


Examples of org.python.indexer.NBinding

            return;
        }
        NModuleType mt = qname.getType().asModuleType();

        String modQname = mt.getTable().getPath();
        NBinding mb = Indexer.idx.lookupQname(modQname);
        if (mb == null) {
            mb = Indexer.idx.moduleTable.lookup(modQname);
        }

        if (mb == null) {
View Full Code Here

Examples of org.python.indexer.NBinding

        this.id = id;
    }

    @Override
    public NType resolve(Scope s) throws Exception {
        NBinding b = s.lookup(id);
        if (b == null) {
            b = makeTempBinding(s);
        }
        Indexer.idx.putLocation(this, b);
        return setType(b.followType());
    }
View Full Code Here

Examples of org.python.indexer.NBinding

        addReadOnlyAttr("im_self", cls, ATTRIBUTE);
        addReadOnlyAttr("__self__", cls, ATTRIBUTE);
    }

    protected NBinding addSpecialAttr(String name, NType atype, NBinding.Kind kind) {
        NBinding b = getTable().update(name,
                                       Builtins.newDataModelUrl("the-standard-type-hierarchy"),
                                       atype, kind);
        b.markSynthetic();
        b.markStatic();
        return b;
    }
View Full Code Here

Examples of org.python.indexer.NBinding

        b.markStatic();
        return b;
    }

    protected NBinding addReadOnlyAttr(String name, NType type, NBinding.Kind kind) {
        NBinding b = addSpecialAttr(name, type, kind);
        b.markReadOnly();
        return b;
    }
View Full Code Here

Examples of org.python.indexer.NBinding

    public NType resolve(Scope outer) throws Exception {
        resolveList(defaults, outer);
        resolveList(decoratorList, outer);

        Scope funcTable = getTable();
        NBinding selfBinding = funcTable.lookup("__self__");
        if (selfBinding != null && !selfBinding.getType().isClassType()) {
            selfBinding = null;
        }

        if (selfBinding != null) {
            if (args.size() < 1) {
                addWarning(name, "method should have at least one argument (self)");
            } else if (!(args.get(0) instanceof NName)) {
                addError(name, "self parameter must be an identifier");
            }
        }

        NTupleType fromType = new NTupleType();
        bindParamsToDefaults(selfBinding, fromType);

        if (varargs != null) {
            NBinding b = funcTable.lookupLocal(varargs.id);
            if (b != null) {
                fromType.add(b.getType());
            }
        }

        if (kwargs != null) {
            NBinding b = funcTable.lookupLocal(kwargs.id);
            if (b != null) {
                fromType.add(b.getType());
            }
        }

        NType toType = resolveExpr(body, funcTable);
        getType().asFuncType().setReturnType(toType);
View Full Code Here

Examples of org.python.indexer.NBinding

        return md5;
    }

    @Override
    public NType resolve(Scope s) throws Exception {
        NBinding mb = Indexer.idx.moduleTable.lookupLocal(file);
        if (mb == null ) {
            Indexer.idx.reportFailedAssertion("No module for " + name + ": " + file);
            setType(new NModuleType(name, file, s));
        } else {
            setType(mb.getType());
        }

        resolveExpr(body, getTable());

        resolveExportedNames();
View Full Code Here

Examples of org.python.indexer.NBinding

        }

        Scope table = mtype.getTable();
        for (NStr nstr : getExportedNameNodes()) {
            String name = nstr.n.toString();
            NBinding b = table.lookupLocal(name);
            if (b != null) {
                Indexer.idx.putLocation(nstr, b);
            }
        }
    }
View Full Code Here

Examples of org.python.indexer.NBinding

    public List<NStr> getExportedNameNodes() throws Exception {
        List<NStr> exports = new ArrayList<NStr>();
        if (!getType().isModuleType()) {
            return exports;
        }
        NBinding all = getTable().lookupLocal("__all__");
        if (all== null) {
            return exports;
        }
        Def def = all.getSignatureNode();
        if (def == null) {
            return exports;
        }
        NNode __all__ = getDeepestNodeAtOffset(def.start());
        if (!(__all__ instanceof NName)) {
View Full Code Here

Examples of org.python.indexer.NBinding

        resolveExpr(body, getTable());
        return getType();
    }

    private void addSpecialAttribute(String name, NType proptype) {
        NBinding b = getTable().update(name, Builtins.newTutUrl("classes.html"),
                                       proptype, NBinding.Kind.ATTRIBUTE);
        b.markSynthetic();
        b.markStatic();
        b.markReadOnly();
    }
View Full Code Here

Examples of org.python.indexer.NBinding

            bind(s, xs.get(i), new NUnknownType());
        }
    }

    public NBinding bindName(Scope s, NName name, NType rvalue) throws Exception {
        NBinding b;

        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
        // and document what use cases require it.
        NType nameType = name.getType();
        if (!(nameType.isModuleType() || nameType.isClassType())) {
            nameType.getTable().setPath(b.getQname());
        }

        return b;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.