Commit graph

83 commits

Author SHA1 Message Date
Eric Swanson
49ec52beae
Add ecompile mode: compare old and new compiler output (#187)
* Add -G / CompareCompilerOutput ecompile mode that runs old and new compiler and compares output.
Add LegacyFunctionOrder because parity needs to know how the old compiler ordered functions.

* Fix class/struct mixup, add to cmake sources
2020-08-05 09:01:07 +02:00
Eric Swanson
a0e681c841 - Add Facility::Compiler interface for both original and new compiler to implement.
- Make original compiler implement
- Alter ECompileMain to use this interface
2020-08-03 23:11:03 -07:00
Eric Swanson
8b98737829 Move Compiler.verbosity_level_ to CompilerConfig.VerbosityLevel 2020-08-03 00:31:27 -07:00
Eric Swanson
07249b0b3f *** OG Compiler: decouple web script preprocessing from FileContents 2020-07-30 20:46:18 -07:00
Eric Swanson
13ba4ad940 Fix a bug in the legacy compiler .ecl output
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
2020-07-29 00:05:52 -07:00
Eric Swanson
a0c6007079 Move compiler to Legacy namespace 2020-07-28 19:08:50 -07:00
turleypol
07f324040f
Merge pull request #149 from polserver/syz-fix-em-param-name-clash
Fix compiler bug with user function names that match module function argument names
2020-06-16 21:29:03 +02:00
Eric Swanson
e7733ccf19 Fix compiler bug: user functions should be able to have the same name as module function parameter names 2020-06-15 22:27:57 -07:00
Eric Swanson
8480c6e2d8 Fix the fix 2020-06-14 04:24:49 -07:00
Eric Swanson
fd6b722eaf Fix optimization error: will sometimes patch an offset of the wrong instruction when
rolling back an if statement branch.
2020-06-14 03:31:03 -07:00
Eric Swanson
1c3a96d2d6 Remove 'declare' keyword 2020-05-07 00:18:10 -07:00
Eric Swanson
38992ce457 Remove dead code from the compiler 2020-05-01 14:56:39 -07:00
Eric Swanson
36d8603666 Add elvis operator:
a ?: b

Evaluates to a if a is true (not: false, 0, undefined, etc)
Otherwise evaluates to b

Short-circuit evaluation
2020-04-29 02:50:11 -07:00
Eric Swanson
3c1422a72e
Add Compiler::read_subexpression for DRY (#135) 2020-04-28 17:26:11 -07:00
Eric Swanson
88e22c1fcb
Make getUserArgs optimize arguments, rename Expression::eat2 -> consume_tokens (#134)
* getUserArgs: optimize arguments immediately

This would have also happened when the whole expression (function call + arguments) was processed.

Doing it here reduces the number of places that call IIP directly.

* remove dead code Expression::eat

* rename Expression::eat2() to consume_tokens(), and modernize
2020-04-28 14:02:16 -07:00
Eric Swanson
df5c3ced7b Move Expression class to expression.cpp/h 2020-04-24 13:37:26 -07:00
turleypol
8bbc8a19dd fixed compilation error 2019-10-07 21:12:45 +02:00
turleypol
59c816cab1 added ecompile.cfg and cmdline flag to trigger error when include
directives use the wrong capitalization. The existing warning will now
lead to an error when warnings get treated as errors.
2019-10-07 21:01:26 +02:00
turleypol
4ac7f227c7 ecompile now writes errors and warnings to stderr.
exit code is 1 when any compilation fails.
2019-10-05 13:19:38 +02:00
turleypol
fc523320d9 added support of ++/-- for object members. 2019-09-26 07:06:45 +02:00
turleypol
169c1ec4e3 added i--, corrected that no warning appears when using i++. Extended
tests
2019-09-22 11:04:57 +02:00
turleypol
f1c30f05c3 changed endless if statement to switch 2019-09-21 21:33:34 +02:00
turleypol
20994e6b5f do not trigger a warning when ++i is the only statement in the line 2019-09-21 15:11:00 +02:00
turleypol
04066c309d moved unicode sanitize functions to clib as a preparation to sanitize
only once
renamed mklower/mkupper to make it clear that it should only be used
for pure ascii texts
compiler triggers only once a warning about invalid unicode file
2019-01-12 11:46:30 +01:00
turleypol
1898b1687c Merge remote-tracking branch 'origin/master' into utf8
* 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
2018-12-23 14:28:37 +01:00
turleypol
ea0c533364 fixed leak in compiler and xml filemod
ecompile/runecl no longer try to log to pol logs
activated xml unittest
print stderr on testfailure
2018-12-23 13:55:47 +01:00
turleypol
8d9de3918a Merge remote-tracking branch 'origin/master' into utf8
* 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
  ...
2018-12-22 10:43:32 +01:00
turleypol
bbc3cae53e fixed reported warnings from coverty 2018-11-01 17:57:03 +01:00
turleypol
4f40aa7997 removed Clib::decint and used Clib::tostring, changed Clib::hexint to
template function for all integers
2018-10-28 09:31:58 +01:00
turleypol
366f7e7122 Merge remote-tracking branch 'upstream/master'
* 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
2018-10-14 14:00:33 +02:00
turleypol
0864d3a31e fixed linesize 2018-10-09 19:07:53 +02:00
turleypol
a5e6206164 Added cmake option to run clang-tidy
used everywhere nullptr
2018-10-09 16:36:35 +02:00
turleypol
72574d581b compiler can now handle files with BOM 2018-06-25 19:31:00 +02:00
turleypol
ea0f465e6d Some better error handlings 2018-04-27 23:08:26 +02:00
Gabriele Tozzi
b72f725e02 Whitespace fixes 2018-04-03 04:13:03 +02:00
turleypol
3afc41241b
CMake on windows (#48)
CMake can now also be used for windows
2018-02-24 22:34:55 +01:00
Kevin Eady
66da8ac805 Changed reference to unary @ operator 2018-02-05 19:21:27 +01:00
turleypol
d7fbb4ac8e cleanup debug prints
fixed funcref implementation
2018-02-04 11:58:26 +01:00
turleypol
0d04d5e19b Current FunctionRef status. Mixed with a few more cmake stuff 2018-02-03 19:05:22 +01:00
turleypol
dbb25bdb62
Include and buildsystem cleanup (#45)
Include cleanup
Reworked buildsystem (Linux only)
Removed dynamic libs, Linux now again uses static linking (like windows)
2018-01-29 21:55:48 +01:00
turleypol
798eda5b63 Cleanup of header includes. 2018-01-01 21:52:14 +01:00
turley
842dde97c0 dead code 2016-12-09 20:59:13 +01:00
turley
189cad3479 Formating everything
Authors are not forced to use the clang-format setting, but should
atleast be inspired by the style.
The only thing which is now not allowed are tabs for ident/alignment!
2016-02-19 19:26:35 +01:00
Gabriele Tozzi
d1ac902926 Documentation: reformatted headers for DoxyGen 2016-01-28 14:52:40 +01:00
Gabriele Tozzi
5bf416ca24 Merge branch 'cmake'
Conflicts:
- pol-core/clib/xmain.cpp
- pol-core/ecompile/ecompile.cpp
2015-12-18 23:41:43 +01:00
Gabriele Tozzi
144f0600f7 Documentation: improving comments in code
Most of them coming from the "unicode" branch
2015-12-15 02:53:58 +01:00
Gabriele Tozzi
1cd1e5c7bf Documentation: added some comments in ecompile
Also removed a couple of unused functions from the header file
2015-12-10 22:41:14 +01:00
Gabriele Tozzi
24eee9ecf4 Merge branch 'master' of https://github.com/polserver/polserver into cmake
Conflicts solved, still need to test and review it before merging into master.
2015-11-27 06:26:46 +01:00
Thomas Volkert
0a0d1974a8 Fixed Windows build for clib 2015-11-11 00:34:18 +01:00
Gabriele Tozzi
70f83638dc Fixed: minor bug in the compiler handling "unused" keyword
It was partially ignoring DisplayWarnings and ErrorOnWarning settings
2015-09-06 05:27:37 +02:00