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.
* python script to generate cpp file with BareDistro content
poltool cmd to generate the files
* updated baredistro, fixed compilation
* fix warning, ignore autogenerated file in stylechecker
* test for pol?
uoconvert got a new argument outdir for the cfg file output
single thread decay has now a upper limit of sleeptime
fixed that the exit_code can only get worse
basic files for core testing in testsuite
added a not really nice way to set it up via ctest
integrated in CI with upload of log output
* testenv
* update poltool filegeneration to c++17
* first real tests
* first npc test
* equip a backpack and test a bit aos props
* fixed early returns
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
* origin/master:
fixed leak in compiler and xml filemod ecompile/runecl no longer try to log to pol logs activated xml unittest print stderr on testfailure
Conflicts:
testsuite/escript/config/fileaccess.cfg
testsuite/escript/filemod/xml.ins
* origin/master: (58 commits)
fixed style
fixed namespaces of moved files
moved polfile/uofile files into plib to cleanup atleast a bit the compile dependencies
fixed cpu usage of usesinglethreadlogin
fixed warning
PolCore().internal(6, scriptname) logs name and memoryusage of variables for given script into log/scriptmemory.log. Globals, locals and all current call stacks. scriptname has to be the relative path from root with ecl ending. Precondition is an existing .dbg file for the given script, this will be created by compiling the script with -x
added PolCore().internal(5) logs memoryusage in bytes of each script instance into log/memoryusagescripts.log
updated flyweight memory report (used for memory saving of strings) enable via ENABLE_FLYWEIGHT_REPORT cmake option
Turns out that Windows has the same wrong format specifier
Fix wrong format specifier for pointers (fmtlib)
Mentioned the ENTEREDAREA and LEFTAREA events for items in the docs
Changed core-changes.txt so that there was only one date entry for my additions.
Fixed more documentation errors for the ListObjectsInBoxOfClass and ListItemsInBoxOfObjType functions.
Fixed prototype in XML docs for ListObjectsInBoxOfClass and ListObjectsInBoxOfObjType
** Fix docs for ListObjectsInBoxOfClass and remove commented debug code.
**** Commit for 2018-11-25 **** Added ListObjectsInBox to uo.em.
**** Commit for 2018-11-25 **** Added ListItemsInBoxOfObjType( objtype, x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM) to uo.em Updated core-changes.txt with the ListItemsInBoxOfObjType info. Updated uo.em docs with the ListItemsInBoxOfObjType info.
silence old core-changes.txt format warnings
Update web server docs.
More gitignore
...
* upstream/master: (45 commits)
renamed mobile syshook to character used unique_ptr for all syshooks
added docs
code simplification, deprecate warning for uoclient.cfg MethodScript entry
party and guild ref support docs and testing left?
custom methods for client and account references
fixed line length
syshooks for npc/mobiles
first round for scripted object class methods
Fixed formatting error.
Added new return option to consume ammunition hook which allows the hook to make the core continue with the usual ammunition checks.
Fix critical bug in FindObjtypeInContainer()
fixed compiler warning
fixed linesize
windows fixes
Added cmake option to run clang-tidy used everywhere nullptr
Changed classes to be final if possible, removed override macro
Added additional documentation.
next..
clang 7 is currently untrusted... next try 6 ;)
fixed new clang warnings, new compiler version on travis (lets see how many commits are needed till it works)
...
Conflicts:
.travis.yml
pol-core/bscript/impstr.h
pol-core/clib/cfgfile.cpp
pol-core/pol/module/npcmod.cpp