pg.mutfun.Code¶
Accessible via pg.mutfun.Code
.
- class Code[source]¶
Bases:
pg.Object
Interface for code entity.
Methods:
compile
()Compiles current instruction.
evaluate
(context)Evaluates current instruction with variable dictionary.
format
([compact, verbose, root_indent])Overrides pg.Symbolic.format to support Python program representation.
input_defs
([transitive])Returns the symbol definitions for the inputs of this code entity.
input_vars
([transitive])Returns the input context from this code entity.
line
()Returns the top-level code entity of current line.
Returns the 0-based line number of current line within its function.
output_refs
([transitive])Returns the references to the symbols that this code outputs.
output_vars
([transitive])Returns the output context from this instruction.
Returns the parent code entity of current code entity.
Returns the parent function of current code entity.
Iterates the preceding lines (first first).
Iterates the preceding lines in reversed order (recent first).
python_repr
([block_indent])Returns a Python code representation of current instruction.
Returns seen context prior to this instruction.
Iterates the top-level instructions of succeeding lines.
- abstract evaluate(context)[source]¶
Evaluates current instruction with variable dictionary.
- Return type:
- format(compact=True, verbose=False, root_indent=0, **kwargs)[source]¶
Overrides pg.Symbolic.format to support Python program representation.
- Return type:
- input_defs(transitive=True)[source]¶
Returns the symbol definitions for the inputs of this code entity.
- Return type:
- Parameters:
transitive – If True, transitive inputs will be included. Otherwise, only the direct dependencies will be included.
- Returns:
A list of SymbolDefinition in their declaration order that produce the inputs required for current code entity.
- line_number()[source]¶
Returns the 0-based line number of current line within its function.
- Return type:
- output_refs(transitive=True)[source]¶
Returns the references to the symbols that this code outputs.
- Return type:
- Parameters:
transitive – If True, transitive symbol references will be included. Otherwise, only the direct dependencies will be included.
- Returns:
A list of
Var` or ``FunctionCall
in their definition order that consume the outputs of current instruction. Users can useparent_instruction
orline
to get their context.
- preceding_lines_reversed()[source]¶
Iterates the preceding lines in reversed order (recent first).
- Return type:
- abstract python_repr(block_indent=0)[source]¶
Returns a Python code representation of current instruction.
- Return type: