All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.python.indexer.ast.NBlock Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

The newest version!
/**
 * Copyright 2009, Google Inc.  All rights reserved.
 * Licensed to PSF under a Contributor Agreement.
 */
package org.python.indexer.ast;

import org.python.indexer.Indexer;
import org.python.indexer.Scope;
import org.python.indexer.types.NType;

import java.util.ArrayList;
import java.util.List;

public class NBlock extends NNode {

    static final long serialVersionUID = -9096405259154069107L;

    public List seq;

    public NBlock(List seq) {
        this(seq, 0, 1);
    }

    public NBlock(List seq, int start, int end) {
        super(start, end);
        if (seq == null) {
            seq = new ArrayList();
        }
        this.seq = seq;
        addChildren(seq);
    }

    @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();
    }

    @Override
    public String toString() {
        return "";
    }

    @Override
    public void visit(NNodeVisitor v) {
        if (v.visit(this)) {
            visitNodeList(seq, v);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy