some words explaining struct inst a little
This commit is contained in:
1 parent
34ff993059
commit
dcc93042d3
1 file changed
+22
-8
@@ -6,6 +6,18 @@
|
|||||||
#include "bytecode.h"
|
#include "bytecode.h"
|
||||||
#include "locfile.h"
|
#include "locfile.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
The intermediate representation for jq filters is as a sequence of
|
||||||
|
struct inst, which form a doubly-linked list via the next and prev
|
||||||
|
pointers.
|
||||||
|
|
||||||
|
A "block" represents a sequence of "struct inst", which may be
|
||||||
|
empty.
|
||||||
|
|
||||||
|
Blocks are generated by the parser bottom-up, so may have free
|
||||||
|
variables (refer to things not defined). See inst.bound_by and
|
||||||
|
inst.symbol.
|
||||||
|
*/
|
||||||
struct inst {
|
struct inst {
|
||||||
struct inst* next;
|
struct inst* next;
|
||||||
struct inst* prev;
|
struct inst* prev;
|
||||||
@@ -22,18 +34,20 @@ struct inst {
|
|||||||
location source;
|
location source;
|
||||||
|
|
||||||
// Binding
|
// Binding
|
||||||
// An instruction requiring binding (for parameters/variables)
|
// An instruction requiring binding (for parameters/variables/functions)
|
||||||
// is in one of three states:
|
// is in one of three states:
|
||||||
// bound_by = NULL - Unbound free variable
|
// inst->bound_by = NULL - Unbound free variable
|
||||||
// bound_by = self - This instruction binds a variable
|
// inst->bound_by = inst - This instruction binds a variable
|
||||||
// bound_by = other - Uses variable bound by other instruction
|
// inst->bound_by = other - Uses variable bound by other instruction
|
||||||
// The immediate field is generally not meaningful until instructions
|
// Unbound instructions (references to other things that may or may not
|
||||||
// are bound, and even then only for instructions which bind.
|
// exist) are created by "gen_foo_unbound", and bindings are created by
|
||||||
|
// block_bind(definition, body), which binds all instructions in
|
||||||
|
// body which are unboudn and refer to "definition" by name.
|
||||||
struct inst* bound_by;
|
struct inst* bound_by;
|
||||||
char* symbol;
|
char* symbol;
|
||||||
|
|
||||||
block subfn;
|
block subfn; // used by CLOSURE_CREATE (body of function)
|
||||||
block arglist;
|
block arglist; // used by CLOSURE_CREATE (formals) and CALL_JQ (arguments)
|
||||||
|
|
||||||
// This instruction is compiled as part of which function?
|
// This instruction is compiled as part of which function?
|
||||||
// (only used during block_compile)
|
// (only used during block_compile)
|
||||||
|
|||||||
Reference in new issue
Block a user