Class PyFrame

All Implemented Interfaces:
Serializable, Traverseproc

public class PyFrame extends PyObject implements Traverseproc
A Python frame object.
See Also:
  • Field Details

    • TYPE

      public static final PyType TYPE
    • f_back

      public PyFrame f_back
      Previous frame or null.
    • f_code

      public PyBaseCode f_code
      The underyling code object.
    • f_builtins

      public PyObject f_builtins
      builtin symbol table.
    • f_globals

      public PyObject f_globals
      Global symbol table.
    • f_locals

      public PyObject f_locals
      Local symbol table.
    • f_lineno

      public int f_lineno
      Current line number.
    • f_fastlocals

      public PyObject[] f_fastlocals
    • f_env

      public PyCell[] f_env
      Nested scopes: cell + free env.
    • f_ncells

      public int f_ncells
    • f_nfreevars

      public int f_nfreevars
    • f_lasti

      public int f_lasti
    • f_savedlocals

      public Object[] f_savedlocals
    • f_exits

      public PyObject[] f_exits
      with context exits - used by generated bytecode
    • tracefunc

      public TraceFunction tracefunc
      An interface to functions suitable for tracing, e.g. via sys.settrace().
  • Constructor Details

  • Method Details

    • getGeneratorInput

      public Object getGeneratorInput()
    • checkGeneratorInput

      public Object checkGeneratorInput()
    • getLocals

      public PyObject getLocals()
      Return the locals dict. First merges the fast locals into f_locals, then returns the updated f_locals.
      Returns:
      a PyObject mapping of locals
    • getTrace

      public PyObject getTrace()
    • setTrace

      public void setTrace(PyObject trace)
    • delTrace

      public void delTrace()
    • getf_locals

      public PyObject getf_locals()
      Return the current f_locals dict.
      Returns:
      a PyObject mapping of locals
    • setline

      public void setline(int line)
      Track the current line number. Called by generated code. This is not to be confused with the CPython method frame_setlineno() which causes the interpreter to jump to the given line.
    • getline

      public int getline()
    • getlocal

      public PyObject getlocal(int index)
    • getname

      public PyObject getname(String index)
    • getglobal

      public PyObject getglobal(String index)
    • setlocal

      public void setlocal(int index, PyObject value)
    • setlocal

      public void setlocal(String index, PyObject value)
    • setglobal

      public void setglobal(String index, PyObject value)
    • dellocal

      public void dellocal(int index)
    • dellocal

      public void dellocal(String index)
    • delglobal

      public void delglobal(String index)
    • getclosure

      public PyObject getclosure(int index)
    • getderef

      public PyObject getderef(int index)
    • setderef

      public void setderef(int index, PyObject value)
    • to_cell

      public void to_cell(int parm_index, int env_index)
    • traverse

      public int traverse(Visitproc visit, Object arg)
      Description copied from interface: Traverseproc
      Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc.visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc.visit(PyObject, Object) must not be called with a null PyObject-argument.
      Specified by:
      traverse in interface Traverseproc
    • refersDirectlyTo

      public boolean refersDirectlyTo(PyObject ob) throws UnsupportedOperationException
      Description copied from interface: Traverseproc
      Optional operation. Should only be implemented if it is more efficient than calling Traverseproc.traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.
      Specified by:
      refersDirectlyTo in interface Traverseproc
      Throws:
      UnsupportedOperationException