* all except pol
* pol and includes under defines
* something weird has happened
* remove own folder from include searchpath
* fixed remaining, adapted include style for external headers
* missing include
* 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
Adds:
- model/LocalVariableScopeInfo.h
Stores, for local variable blocks:
- the names of the local variables in the block
- the "base index" of those local variables within the current scope
The code generator uses these to clean up local variables as they go out of scope.
We also need this when writing debug information.
Adds:
- analyzer/LocalVariableScope: tracks local variables created within a given scope.
- Instantiated on the stack during semantic analysis, this registers itself with LocalVariableScopes during construction and deregisters itself during destruction.
- Detects unused variables during deregistration
- analyzer/LocalVariableScopes: this is what LocalVariableScope registers with.
- keeps track of the stack of local scopes.
- can provide the current local scope, for var statements.
Other notes:
"Shadowed" variables: this is when a variable in one scope hides a variable in another, like so:
var a := 2;
if (a)
var a := 3;
a := 4;
endif
print(a); // still 2
"debug_variables": We'll use these later when writing debug files.