14  Appendix: Glossary

14.1 Abstract Syntax Tree, AST

A tree representation of the syntax of the code written in a language.

14.2 Assembler

A compiler targetting the compilation of low-level assembly code to bytecode.

14.3 AST Interpreter

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.

14.4 bcdf byte code data.frame

As 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 closures
  • pc the program counter indicating the index of each instruction.
  • opcode the integer used within the R bytecode object to represent the instruction
  • op the string representation of the instruction
  • args 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()

14.4.1 Example BCDF

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

14.5 Bytecode assembly

The text representation of the bytecode instructions understood by the R bytecode VM e.g

LDCONST 1
LDCONST 2
ADD
RETURN

14.6 Bytecode VM

For R code, once the AST is compiled to a bytecode object, this object is executed by the R bytecode VM.

14.7 Bytecode object

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()

14.8 Compiler

A mechanism for turning instructions from one format to another e.g. R code to AST.