disq(1 + x, incl_expr = TRUE)
depth pc opcode op args expr
1 0 1 16 LDCONST 1 NULL
2 0 3 20 GETVAR x NULL
3 0 5 44 ADD NULL 1 + x
4 0 7 1 RETURN NULL NULL
A tree representation of the syntax of the code written in a language.
A compiler targetting the compilation of low-level assembly code to bytecode.
The AST Interpreter is one mechanism by which R code is evaluated.
R code is first parsed into an AST. The AST interpreter then walks through the tree structure resoloving the value of expressions at each node of the tree.
bcdf
byte code data.frameAs an intermediate step in producing an executable R bytecode object from R bytecode assembly, a data.frame is created which contains the information extracted when parsing the input code.
It includes the following columns:
depth
- the recursion depth of this code in terms of nestedd promises and closurespc
the program counter indicating the index of each instruction.opcode
the integer used within the R bytecode object to represent the instructionop
the string representation of the instructionargs
a list column holding the arguments for the instruction. This never includes the stored expression.expr
the stored expression with this instruction. This may only be included if incl_expr
is included in the call to dis()
bcdf
objects are produced by the disassembler (dis()
) and also as an intermediate stem when assembling using asm()
(i.e. output from parse_code()
)
disq(1 + x, incl_expr = TRUE)
depth pc opcode op args expr
1 0 1 16 LDCONST 1 NULL
2 0 3 20 GETVAR x NULL
3 0 5 44 ADD NULL 1 + x
4 0 7 1 RETURN NULL NULL
The text representation of the bytecode instructions understood by the R bytecode VM e.g
LDCONST 1
LDCONST 2
ADD
RETURN
For R code, once the AST is compiled to a bytecode object, this object is executed by the R bytecode VM.
When R code is compiled to bytecode the result is an R bytecode object.
When R bytecode assembly is compiled the result is again an R bytecode object.
An R bytecode object can be directly executed via a call to eval()
A mechanism for turning instructions from one format to another e.g. R code to AST.