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

src.org.python.indexer.ast.BindingFinder 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.

There is a newer version: 2.7.4
Show 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;

/**
 * A visitor that looks for name-binding constructs in a given scope.
 */
class BindingFinder extends GenericNodeVisitor {

    private Scope scope;  // starting scope

    public BindingFinder(Scope scope) {
        this.scope = scope;
    }

    @Override
    public boolean dispatch(NNode n) {
        if (n.bindsName()) {
            try {
                n.bindNames(scope);
            } catch (Exception x) {
                Indexer.idx.handleException("error binding names for " + n, x);
            }
        }
        // Do not descend into new scopes.
        if (n.isFunctionDef() || n.isClassDef()) {
            return false;
        }
        return super.dispatch(n);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy