* Introduce FunctionReferenceRegistrar
- Track function references created by functors
- Remove ValueStack-held attributes for functors
- Add Function References section to escript program
- Use Function References section in ins_functor
- Update escript version
* Update listfile snapshots
- Remove ValueStack-held attributes created by functors
* Add function reference tracking to function references
- `emit.function_reference` uses funcref registrar + emits that index
- `ins_funcref` uses parameter count + is variadic from prog funcref table
- update listfile snapshots
* Add core-changes
* initial poc of function expressions
- update grammar
- mock AST builder to return BBoolean(true) for a func expr
- update prettifier for skeleton implementation
* more skeleton work
create AST class FunctionExpression mimicking boolean value
* create ast UserFunction, add to workspace from functexpr
* can generate instructions
* reorg tests; add test for instructions
* can track FunctionDepth in Variable
* can get captures for funcexprs inside funcs.. tbd if this way of nesting works
* Implement create-functor instruction
- Move function depth from Variable to Variables
- Introduce stacking of `Variables` for function expresions via `FunctionVariableScope`
- Add `TOK_FUNCTOR` instruction for 'create-functor'
- Handle emitting a `FunctionExpression` AST node
- Update `emit.declare_variable` and `emit.access_variable` to account for function captures
- Remove `in_function` from instruction generator, as it is tracked via `UserFunction` stack
- Update tests
* Address Discord comments
- Swap pop param order
* Bubble up captured variables through nested functions
* Improve testing infrastructure; add some test cases
* Fix compilation error
* prepend captures to function parameters in funcref mth_call
* update tests
* move from function{} to @{}
* implementation fix
* some more tests
* update docs
* Some cleanup
* fix CI annotation warning
- 'argument': conversion from 'size_t' to 'VariableIndex', possible loss of data
* Address review comments
- Add `passert_always`
- Use better example in docs
* Some cleanup
- Remove unused functions
Also: OG compiler debug info for foreach iterator changed to match actual variable name
Adds:
- ast/DebugStatementMarker: for "intrusive debug" (ecompile -i) instructions
- codegen/DebugBlockGuard: pushes and pops debug block #
- format/DebugStoreSerializer: writes .dbg and .dbg.txt files
- representation/DebugBlock: holds parent block # and local variable names for each block
- representation/DebugStore: holds all debug information
Adds:
- ast/UserFunction AST node for user-defined functions.
- astbuilder/AvailableUserFunction: reference to a parse tree for a user function.
- The AST builder only generates ASTs for user functions that are actually referenced.
- astbuilder/UserFunctionVisitor: visits (builds an AST for) a parse tree for a user function.
- This happens after the .src or .inc file has been otherwise processed, so this class serves to hook up the correct SourceFileIdentifier to the AST.
Adds:
- ast/Argument: AST node for an argument passed to a function.
- ast/FunctionCall: AST node for a function call.
- codegen/ModuleDeclarationRegistrar: The code generator registers module function declarations with this in order to determine module indexes and function indexes for instructions.
- model/FunctionLink: this is a reference either:
- from: a FunctionCall or a FunctionReference
- to: a ModuleFunctionDeclaration or a UserFunction
- optimizer/ReferencedFunctionGatherer: a visitor that determines which module functions and user functions are referenced, by looking at function calls and function references.
Also:
- CodeGenerator registers module functions
- InstructionGenerator generates code for function calls
- InstructionEmitter generates TOK_FUNC instructions
- StoredTokenDecoder decodes TOK_FUNC instructions
After all of this, the compiler can compile print("hello, world");
* Add codegen/InstructionEmitter
* Add codegen/InstructionGenerator
* CodeGenerator: emit progend
Checkpoint: compiler can compile an empty file
* Comment reason for having both emit and emitter.