org.python.antlr.ast.comprehension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython-slim Show documentation
Show all versions of jython-slim Show documentation
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.
// Autogenerated AST node
package org.python.antlr.ast;
import org.antlr.runtime.Token;
import org.python.antlr.AST;
import org.python.antlr.PythonTree;
import org.python.antlr.adapter.AstAdapters;
import org.python.antlr.base.expr;
import org.python.core.ArgParser;
import org.python.core.AstList;
import org.python.core.Py;
import org.python.core.PyObject;
import org.python.core.PyString;
import org.python.core.PyStringMap;
import org.python.core.PyType;
import org.python.core.Visitproc;
import org.python.expose.ExposedGet;
import org.python.expose.ExposedMethod;
import org.python.expose.ExposedNew;
import org.python.expose.ExposedSet;
import org.python.expose.ExposedType;
import java.util.ArrayList;
@ExposedType(name = "_ast.comprehension", base = AST.class)
public class comprehension extends PythonTree {
public static final PyType TYPE = PyType.fromClass(comprehension.class);
private expr target;
public expr getInternalTarget() {
return target;
}
@ExposedGet(name = "target")
public PyObject getTarget() {
return target;
}
@ExposedSet(name = "target")
public void setTarget(PyObject target) {
this.target = AstAdapters.py2expr(target);
}
private expr iter;
public expr getInternalIter() {
return iter;
}
@ExposedGet(name = "iter")
public PyObject getIter() {
return iter;
}
@ExposedSet(name = "iter")
public void setIter(PyObject iter) {
this.iter = AstAdapters.py2expr(iter);
}
private java.util.List ifs;
public java.util.List getInternalIfs() {
return ifs;
}
@ExposedGet(name = "ifs")
public PyObject getIfs() {
return new AstList(ifs, AstAdapters.exprAdapter);
}
@ExposedSet(name = "ifs")
public void setIfs(PyObject ifs) {
this.ifs = AstAdapters.py2exprList(ifs);
}
private final static PyString[] fields =
new PyString[] {new PyString("target"), new PyString("iter"), new PyString("ifs")};
@ExposedGet(name = "_fields")
public PyString[] get_fields() { return fields; }
private final static PyString[] attributes = new PyString[0];
@ExposedGet(name = "_attributes")
public PyString[] get_attributes() { return attributes; }
public comprehension(PyType subType) {
super(subType);
}
public comprehension() {
this(TYPE);
}
@ExposedNew
@ExposedMethod
public void comprehension___init__(PyObject[] args, String[] keywords) {
ArgParser ap = new ArgParser("comprehension", args, keywords, new String[]
{"target", "iter", "ifs"}, 3, true);
setTarget(ap.getPyObject(0, Py.None));
setIter(ap.getPyObject(1, Py.None));
setIfs(ap.getPyObject(2, Py.None));
}
public comprehension(PyObject target, PyObject iter, PyObject ifs) {
setTarget(target);
setIter(iter);
setIfs(ifs);
}
public comprehension(Token token, expr target, expr iter, java.util.List ifs) {
super(token);
this.target = target;
addChild(target);
this.iter = iter;
addChild(iter);
this.ifs = ifs;
if (ifs == null) {
this.ifs = new ArrayList();
}
for(PythonTree t : this.ifs) {
addChild(t);
}
}
public comprehension(Integer ttype, Token token, expr target, expr iter, java.util.List
ifs) {
super(ttype, token);
this.target = target;
addChild(target);
this.iter = iter;
addChild(iter);
this.ifs = ifs;
if (ifs == null) {
this.ifs = new ArrayList();
}
for(PythonTree t : this.ifs) {
addChild(t);
}
}
public comprehension(PythonTree tree, expr target, expr iter, java.util.List ifs) {
super(tree);
this.target = target;
addChild(target);
this.iter = iter;
addChild(iter);
this.ifs = ifs;
if (ifs == null) {
this.ifs = new ArrayList();
}
for(PythonTree t : this.ifs) {
addChild(t);
}
}
@ExposedGet(name = "repr")
public String toString() {
return "comprehension";
}
public String toStringTree() {
StringBuffer sb = new StringBuffer("comprehension(");
sb.append("target=");
sb.append(dumpThis(target));
sb.append(",");
sb.append("iter=");
sb.append(dumpThis(iter));
sb.append(",");
sb.append("ifs=");
sb.append(dumpThis(ifs));
sb.append(",");
sb.append(")");
return sb.toString();
}
public R accept(VisitorIF visitor) throws Exception {
traverse(visitor);
return null;
}
public void traverse(VisitorIF> visitor) throws Exception {
if (target != null)
target.accept(visitor);
if (iter != null)
iter.accept(visitor);
if (ifs != null) {
for (PythonTree t : ifs) {
if (t != null)
t.accept(visitor);
}
}
}
public PyObject __dict__;
@Override
public PyObject fastGetDict() {
ensureDict();
return __dict__;
}
@ExposedGet(name = "__dict__")
public PyObject getDict() {
return fastGetDict();
}
private void ensureDict() {
if (__dict__ == null) {
__dict__ = new PyStringMap();
}
}
/* Traverseproc implementation */
@Override
public int traverse(Visitproc visit, Object arg) {
int retVal = super.traverse(visit, arg);
if (retVal != 0) {
return retVal;
}
if (iter != null) {
retVal = visit.visit(iter, arg);
if (retVal != 0) {
return retVal;
}
}
if (ifs != null) {
for (PyObject ob: ifs) {
if (ob != null) {
retVal = visit.visit(ob, arg);
if (retVal != 0) {
return retVal;
}
}
}
}
return target != null ? visit.visit(target, arg) : 0;
}
@Override
public boolean refersDirectlyTo(PyObject ob) {
if (ob == null) {
return false;
} else if (ifs != null && ifs.contains(ob)) {
return true;
} else {
return ob == iter || ob == target || super.refersDirectlyTo(ob);
}
}
}