* Update grammar; add tests
String literals inside an interpolated string cannot start with `}`, as it must be a DOUBLE_RBRACE `}}`
* Fix interpolate string token reading
* Update core-changes
* Add cppdap debugger library and simple server (#508)
* Add cppdap library
* Add cppdap server
* fixup cmake scripts for windows
* Enable caching of cppdap on GitHub actions
* Fix CMake for cppdap target
* Wait 1s for session close before thread ends
* Address review comments
- Remove unnecessary use of wait_for
- Fix wait_for method
* Do not use SocketClientThread for cppdap clients
* Address review comments
- Cleanup object ownership
* Add authorization and event handling (#510)
* Add authorization and event handling [WIP]
* Use std::weak_ptr; Only allow one debugger conn
* Only attach debugger if dbg file exists
* Cleanup weak_ptr; Fix listeners; Add handler stubs
* Address review comments
- PolLock on uoexec and weakptr access
- Use make_shared when creating client thread
* Add ExecutorDebugListener on_destroy callback
* Use cppdap sockets instead of clib sockets
* Update cppdap repository to 2703cf4
* Implement server address binding
* Update cppdap repository to eeca5ce
* Fix warnings
* Use weak_from_this
* Fix stalled executors on disconnect
* Fix stalled executors on re-attach
* Clear uoexec weakptr on all debugger detaches
* Move server to gamestate
* move DapDebugServer into Network namespace
* move DapDebugServer into GameState for storage
* Move DapDebugServer into NetworkManager
* Fix missing memory include
* Add more events (#513)
* Add more events
* Implement dbg_step_out
* Fix breakpoint clearing
* Add even more events (#515)
* add launch request
* Add custom `processes` command
* fixup loop
* Refactoring to move handlers to member functions
* Add VariablesRequest and ScopesRequest
* use std::varaint for Handles
* add pollocks
* refactor Handles to new file
* move custom messages to proto.h
* move clientthread
* some formatting / cleanup
* Add missing PolLock
* move dap variables creation to Handles
* appobj members
* rename ClientThread to DebugClientThread
* rename LaunchRequest args to arg
* Fix compiler error on size_t
* Add support for EvaluateRequest and SetVariableRequest (#519)
* Update grammar for evaluateUnit
* Cleanup various compiler code
* Add support for EvaluateRequest
Only supports values, variables, element access, member access
* Add report clearing to reinitialize state
* Add support for SetVariableRequest
* Fix CI build errors
* Move ExpressionEvaluator to Bscript
* Fix formatting
* Fix include
* Refactor global and frame variable references
* Encapsulate Executor debugging environment; Fix step over (#524)
* Fix step over
* Some cleanup of executor
- Remove unused debug states
- Rename members for consistency
* move debugging environment to new class
* Move instruction inspection to class
* Cleanup slashes on Windows; Add Executor state to processes response (#527)
* Fix backspaces in script names on Windows
* Fix compilation warnings with data loss
* Use boost::icontains for string comparison
* Add Executor state to processes response
* Updates for libfmt
* Fix tests; Fix cppdap build for Mac universal binary (#607)
* fix tests
* fix cppdap build for mac universal binary
* Update cppdap to 2a4c7cf
* Add tests; Modify launch behavior to not stop at entry (redo) (#609)
* Remove unused setExceptionBreakpoints handler
* Add debugger tests
* Launching a script should not set attaching state
* Add launch tests
* Do not check for connection in debugger tests
* Rename `program` to `script` in protocol structs
* Fix launch stopAtEntry; quote string var values
* Fix compilation error on Windows
* Add configfiles doc entry
* Various fixes for finishing touches; Add core-changes (#610)
* switch cmake projects
* simple docs
* cmake move make_directory
* Fix launch request with relative, absolute, package paths
* make relative paths as absolute in source request
* Add true, false, uninit to ExpressionEvaluator
* Re-add setExceptionBreakpoints to avoid unhandled message errors
* Better debug thread logging with instance numbers
* launched scripts should terminate on disconnect (according to DAP spec)
* Properly handle exited event in client thread
* Add core-changes
* Address Discord comments
- Mention vscode-escript in core-changes
- Re-add "cppdap already built" in cmake
* change cmake escriptgrammarlib visibility to public
* use std::to_chars for doubles
* fixed cmake errors when an escript error occurs
* macos 13 with clang15
* CI: macos new cache version
* guessing game
* guess no2
* test shipped clang with deloytarget env
* adapted testdata, lets see if all platforms behave the same
* explicit test if high precision double can get packed+unpacked
* log testclient receive buffer on error
* added docs
* added test for pack/unpack double which has exponent representation. Bug
in vs 2022 17.8..
removed unneeded minimum versions of cmake, root cmake file has a higher
minimum version
* switch back to vs2019
* force rebuild external libs
* docs
* OpenXMLFile: return error if file does not exist instead of xmlobject in
error state
* added docs
* translate every xml open/parsing error to BError
* updated core changes entry, to reflect the latest changes
* updated strformattime to allow c++11 specifiers, removed 100 chr
limitation
* ambiguous std::max on windows
* fixed utc dependent testdata
* print output file on runecl error
* vs2019 seems to not support E and 0 formats
* use vector of chars as buffer to avoid potential UB
* resize vector, extended test
* Build on OSX
* Add macos-latest to build matrix
* Fix case sensitivity checks/tests
* On osx builds, cope with unpacking a double that might be followed by either an exponent or an error (as part of an array).
Also, remove static unpack(const char*) forms that were never called.
Co-authored-by: turleypol <turley@polserver.com>
* Fixed: if too many parameters were passed in a function call, an incorrect error message was displayed, and the compiler could even crash.
Also updated all of the error messages related to function call parameters to include the function name.
There is one part that differs from const declarations: 0-parameter function calls are allowed (by accident) as const values, but not for default parameter values.
Adds:
- ast/CaseDispatchDefaultSelector: AST node for a "default:" selector
- ast/CaseDispatchGroup: AST node for a collection of selectors and the code to execute
- ast/CaseDispatchGroups: AST node holding all groups in a case statement
- ast/CaseDispatchSelectors: AST node holding all selectors for one group
- ast/CaseStatement: AST node for a whole case statement
- codegen/CaseDispatchGroupVisitor: knows what to put in a case jump dispatch table
- codegen/CaseJumpDataBlock: knows how to build the entries in the data block
Also, detect multiple case selectors with the same value (or default). This is different from the OG compiler, which only detected duplicate `default:` selectors.
The OG compiler looks up function ids for most tokens, even when it doesn't need to. When this happens, it assigns the module id as the module of the function.
When the token is later found not to be a function call, the parser changes the id to TOK_IDENT and the type to TYP_OPERAND, but leaves the module id.
We can see this in the included script, which adds members, which have names that match module function names, to a struct.
This doesn't cause problems during execution because the executor ignores the type for the emitted instructions.
It does cause problems when comparing .ecl output for parity between the old compiler and the new compiler, because the new compiler does not look up every identifier to see if it's a function.
This change assigns module = Mod_Basic along with id and type for tokens that are identifiers.
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.
optimize_token() is meant to return true only if it performs an optimization.
By returning true when it did not, it makes the optimizer stop trying.
A script like this can trigger the condition:
var i := 3;
var ii;
ii := 1 - (--i);
print(i);
print(ii);
Notice that line 4 does not optimize to an 'assign-consume' and therefore does not optimize to 'assign global`
Listfile before (see instructions 6-12):
/vagrant/testsuite/escript/opt/opt005-stopped-optimizing-early.src, Line 1
var i := 3;
0: decl global #0
1: 3L
2: :=
3: #
var ii;
4: decl global #1
5: #
ii := 1 - (--i);
6: global #1
7: 1L
8: global #0
9: unary --
10: -
11: :=
12: #
print(i);
13: global #0
14: Func(1,0): Print
15: #
print(ii);
16: global #1
17: Func(1,0): Print
18: #
19: progend
Listfile after (see instructions 6-10):
/vagrant/testsuite/escript/opt/opt005-stopped-optimizing-early.src, Line 1
var i := 3;
0: decl global #0
1: 3L
2: :=
3: #
var ii;
4: decl global #1
5: #
ii := 1 - (--i);
6: 1L
7: global #0
8: unary --
9: -
10: global1 :=
print(i);
11: global #0
12: Func(1,0): Print
13: #
print(ii);
14: global #1
15: Func(1,0): Print
16: #
17: progend
The RSV_LOCAL offset should be the the local variable, not of the local variable within the block
Notice though, that the executor doesn't even use it.
There is more detail in the attached script.
listfile before:
/vagrant/testsuite/escript/bug/bug013-local-variable-index.src, Line 7
program foo()
var a; // should be 0
0: decl local #0
1: #
if ( a )
2: local #0
3: if false goto 17
var b; // should be 1 actually emitted 0
4: decl local #0
5: #
var c; // should be 2 actually emitted 1
6: decl local #1
7: #
if ( b )
8: local #1
9: if false goto 16
var d; // should be 3 actually emitted 0
10: decl local #0
11: #
print(d);
12: local #3
13: Func(1,0): Print
14: #
15: leave block(1)
16: leave block(2)
17: leave block(1)
18: progend
listfile after:
/vagrant/testsuite/escript/bug/bug013-local-variable-index.src, Line 7
program foo()
var a; // should be 0
0: decl local #0
1: #
if ( a )
2: local #0
3: if false goto 17
var b; // should be 1 actually emitted 0
4: decl local #1
5: #
var c; // should be 2 actually emitted 1
6: decl local #2
7: #
if ( b )
8: local #1
9: if false goto 16
var d; // should be 3 actually emitted 0
10: decl local #3
11: #
print(d);
12: local #3
13: Func(1,0): Print
14: #
15: leave block(1)
16: leave block(2)
17: leave block(1)
18: progend