use of org.cafebabepy.runtime.object.proxy.PyLexicalScopeProxyObject in project cafebabepy by cafebabepy.
the class PyInterpretFunctionObject method call.
@Override
public PyObject call(PyObject... args) {
PyObject lexicalContext = new PyLexicalScopeProxyObject(this.context);
PyObjectScope scope = lexicalContext.getScope();
this.runtime.getattrOptional(this.args, "args").ifPresent(argslist -> this.runtime.iterIndex(argslist, (a, i) -> {
PyObject arg = this.runtime.getattr(a, "arg");
scope.put(arg.toJava(String.class), args[i]);
}));
return evaluator.eval(lexicalContext, body);
}
use of org.cafebabepy.runtime.object.proxy.PyLexicalScopeProxyObject in project cafebabepy by cafebabepy.
the class InterpretEvaluator method evalListComp.
private PyObject evalListComp(PyObject context, PyObject node) {
PyObject elt = this.runtime.getattr(node, "elt");
PyObject generators = this.runtime.getattr(node, "generators");
List<PyObject> generatorList = this.runtime.toList(generators);
List<PyObject> resultList = new ArrayList<>();
PyLexicalScopeProxyObject lexicalContext = new PyLexicalScopeProxyObject(context);
evalGenerators(lexicalContext, elt, generatorList, resultList);
return this.runtime.list(resultList);
}
Aggregations