Package org.yinwang.pysonar.types

Examples of org.yinwang.pysonar.types.Type


    }


    @NotNull
    public String getFirstFile() {
        Type bt = type;
        if (bt instanceof ModuleType) {
            String file = bt.asModuleType().file;
            return file != null ? file : "<built-in module>";
        }

        String file = getFile();
        if (file != null) {
View Full Code Here


            {
                json.writeObjectFieldStart("funcData");

                // get args expression
                String argExpr = null;
                Type t = binding.type;

                if (t instanceof UnionType) {
                    t = ((UnionType) t).firstUseful();
                }
View Full Code Here

        }
    }


    public static Type makeUnion(Set<Binding> bs) {
        Type t = Type.UNKNOWN;
        for (Binding b : bs) {
            t = UnionType.union(t, b.type);
        }
        return t;
    }
View Full Code Here

     */
    @NotNull
    @Override
    public Type transform(State s) {
        resolveList(generators, s);
        Type keyType = transformExpr(key, s);
        Type valueType = transformExpr(value, s);
        return new DictType(keyType, valueType);
    }
View Full Code Here


    @NotNull
    @Override
    public Type transform(State s) {
        Type type1, type2;
        transformExpr(test, s);

        if (body != null) {
            type1 = transformExpr(body, s);
        } else {
View Full Code Here

    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        for (Withitem item : items) {
            Type val = transformExpr(item.context_expr, s);
            if (item.optional_vars != null) {
                Binder.bind(s, item.optional_vars, val);
            }
        }
        return transformExpr(body, s);
View Full Code Here


    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        Type typeval = Type.UNKNOWN;
        if (exceptions != null) {
            typeval = resolveUnion(exceptions, s);
        }
        if (binder != null) {
            Binder.bind(s, binder, typeval);
View Full Code Here

    public Type transform(@NotNull State s) {
        if (module == null) {
            return Type.CONT;
        }

        Type mod = Analyzer.self.loadModule(module, s);

        if (mod == null) {
            Analyzer.self.putProblem(this, "Cannot load module");
        } else if (isImportStar()) {
            importStar(s, mod);
        } else {
            for (Alias a : names) {
                Name first = a.name.get(0);
                Set<Binding> bs = mod.table.lookup(first.id);
                if (bs != null) {
                    if (a.asname != null) {
                        s.update(a.asname.id, bs);
                        Analyzer.self.putRef(a.asname, bs);
                    } else {
                        s.update(first.id, bs);
                        Analyzer.self.putRef(first, bs);
                    }
                } else {
                    List<Name> ext = new ArrayList<>(module);
                    ext.add(first);
                    Type mod2 = Analyzer.self.loadModule(ext, s);
                    if (mod2 != null) {
                        if (a.asname != null) {
                            s.insert(a.asname.id, a.asname, mod2, Binding.Kind.VARIABLE);
                        } else {
                            s.insert(first.id, first, mod2, Binding.Kind.VARIABLE);
View Full Code Here

        if (node == null) {
            return;
        }

        List<String> names = new ArrayList<>();
        Type allType = mt.table.lookupType("__all__");

        if (allType != null && allType instanceof ListType) {
            ListType lt = (ListType) allType;

            for (Object o : lt.values) {
                if (o instanceof String) {
                    names.add((String) o);
                }
            }
        }

        if (!names.isEmpty()) {
            int start = this.start;

            for (String name : names) {
                Set<Binding> b = mt.table.lookupLocal(name);
                if (b != null) {
                    s.update(name, b);
                } else {
                    List<Name> m2 = new ArrayList<>(module);
                    Name fakeName = new Name(name, this.file, start, start + name.length());
                    m2.add(fakeName);
                    Type type = Analyzer.self.loadModule(m2, s);
                    if (type != null) {
                        start += name.length();
                        s.insert(name, fakeName, type, Binding.Kind.VARIABLE);
                    }
                }
View Full Code Here

    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        for (Alias a : names) {
            Type mod = Analyzer.self.loadModule(a.name, s);
            if (mod == null) {
                Analyzer.self.putProblem(this, "Cannot load module");
            } else if (a.asname != null) {
                s.insert(a.asname.id, a.asname, mod, Binding.Kind.VARIABLE);
            }
View Full Code Here

TOP

Related Classes of org.yinwang.pysonar.types.Type

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.