Commit graph

44 commits

Author SHA1 Message Date
turleypol
1463b76c7c
Includes are now all relative to pol-core basefolder (#906)
* 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
2026-07-25 23:01:18 +02:00
turleypol
21577d8e5b
Clang Tidy concat namespaces (#855)
* tidy

* Automated clang-tidy change: modernize-concat-nested-namespaces

* compile test

* fix namespace

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-17 10:30:21 +01:00
turleypol
c882c42a31
misc clang-tidy (#853)
* trigger tidy

* Automated clang-tidy change: modernize-use-equals-delete,modernize-make-shared,modernize-make-unique,modernize-use-constraints,readability-container-size-empty,modernize-redundant-void-arg,modernize-use-emplace

* removed non needed macros

* missed to disable tidy build

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-16 12:22:43 +00:00
turleypol
7090c64840
Short Circuit Optimizer (#797)
* first working short curcuit for && and or
creates jumps after each expressions to skip the following

* fixed valuestack when short circuit jmp does not jump

* use specialized instructions for short circuit && and ||

1: lhs
2: logical jump if false/true goto 4 <- if jmp do logical convert
3: rhs
4: logical convert
5: rest

logical convert is needed since "normal" && || operations convert isTrue
to BLong

added BObjectRef BObjectImp set specialization to remove noise

* fixed converted objimp when jump on false values

* first version of short circuit warning
should be moved to analyzer
added whitelist of module functions which have no sideeffect to reduce
the number of warnings

* moved warning visitor to analyzer and added it as extra compile step
fixed sourceline print and cache the content

* missing include, unused member

* included the correct header

* ecompile.cfg to activate and warn
ecompile cmdline arg to activate it
run all tests also with it active
fixed that only the most right side statement was checked

* ecompile cmdline

* increase ecompile version
cleanup

* compilation error

* missing header

* allow -S- to deactivate shortcircuit like the other params do

* extended whitelist functions

* revert fileformat version increase
fixed escript test cmake

* use the correct arg

* escript testoutput can now be different if shortcircuit is active

* docs

* additional test

* addressed comments
2025-07-28 21:48:34 +02:00
Kevin Eady
ec344a395d
Add support for sequence and index bindings (#760)
* update grammar

* add ast nodes; ast building

* Rename to unpacking

* semantic analysis

* executor work part 1, unpacking indices

* renamings; implement index binding

* small cleanup

* use multi_index; more tests

* use multi_index only for rest, otherwise list

* initial formatting

* add missing token decoding

* address self-review comments

* formatting tweaks

* add test for var binding in classes

* add StringIterator

* fix spread tests

* add cfgfile iterator; add cfgelem opersubscript; tests

* add iterator for SQLResultSet and SQLRow; tests

* Copy value in take global/local

* Allow any iterable can index rest unpacking
Always use dictionary as rest object in index unpacking

* add docs, core-changes, doc tests

* formatting changes...

* address self-review comments

* update formatter, format all binding test srcs

* address review comments
- unset var scope

* add cfgfile/cfgelem docs

* reformat objref svg
2025-02-17 21:59:42 +01:00
Kevin Eady
0527692a78
Add Script object script method stacktrace (#739)
* Initial implementation, tests

* Enhance tests

* Add quiet to read_dbg_file

* Add pc to array format

* Add docs, core-changes

* fix bad PCs

* touchup on corechanges
2025-01-05 17:22:55 +01:00
Kevin Eady
1c190f7d3e Fix is operator to work across executors (#711)
* Update funcref table
- Add ctor funcref index
- Switch ctor list to be type tag offsets instead of funcref indexes

* Add pol tests for is, set-member across scripts

* Address GitHub CI annotations
- unused variable ‘uf’

* return longs instead of bools
2024-10-10 18:06:04 +02:00
Kevin Eady
a953a37fa7 Support function reference calls with default parameters (#710)
* Support default args in funcref calls
- Simplify BFunctionRef by using funcref index
- Emit default args when visiting function reference

* Move default args gen to second-pass visit

* Better error message on param count errors

* Check for constructor in MTH_NEW

* Address self-review comments
- Update code comments

* Introduce ResourceManager to pol testsuite
- Create a new class-based resource manager for deleting resources
(item NPCs, multis) after each test.
- Migrate house_set_multiid test to use new ResourceManager.

* Move resource cleanup
2024-10-10 18:06:04 +02:00
Kevin Eady
d7cdcff383 Add classinst.function member; Add is binary operator; Add funcref MTH_NEW (#701)
* Update grammar

* Implement selfIs in BObjectImp

* Add tests

* Update grammar

* Support obj.function as a MemberAccess [1/2]
- AST generation changes

* Support obj.function as a MemberAccess [2/2]
- add funcref index to eprog class table ctor entry
- allow check_mro on non-class inst (skip ctor calls)

* Move address of funcref into funcref table

* Add funcref.new()
- Add class index to funcref table entry
- Add MTH_NEW

* Fix formatting

* Address self-review comments

* Some more tests

* Address self-review comments

* Update grammar

* Remove ObjMember read_only, hidden
No need to special-handle MBR_FUNCTION

* Addres GitHub CI annotations
- '=': conversion from 'size_t' to 'unsigned int', possible loss of data
2024-10-10 18:06:04 +02:00
Kevin Eady
67aa0c25b0 Initial support for class instances in Executor (#699)
* Associate class descriptor with class instance

* Skeleton of BClassInstance, update tests

* Correctly handle methods on class instances

* Support calling members as methods

* Update super-multiple test

* Track called ctors; Introduce ins_check_mro

* Move class method funcref class to Executor

* Address GitHub CI annotations
- 'argument': conversion from 'size_t' to 'unsigned int'

* Update pol-core/bscript/bclassinstance.cpp

* Introduce BConstObject for class instances

* Fix unnecessary include in uotool

* Removed fixedalloc from BConstObject

* Additional test case

* Address Discord comments
- Reintroduce deleted copy assignment
2024-10-10 18:06:04 +02:00
Kevin Eady
37a6179971 Add reading, writing of function table to ecl program (#697)
* Make ClassDeclaration only track class methods

* Keep methods, constructors in compiler workspace
- Fix UserFunctionBuilder to force reference to methods, constructors
- Fix Optimizer to include methods, constructors in referenced functions

* WIP for ClassDeclarationRegistrar
- Stub implementation of ClassDeclaration and its Registration
- Create "function table entry" via debug statements

* Use function links in methods

* Finish up ClassDescriptor
- Introduce MethodDescriptor for encapsulation
- ClassDeclarationRegistrar can register and take descriptors

* Handle read and write class table in eprog

* Pass Report to code generator for debug statements

* Fix implementation
- It _is_ possible for the constructor to be empty, ie. static classes

* Update DebugStoreSerializer
Print class table to dbg txt file

* Add missing method_names insertion

* Address GitHub CI Annotations
- unused variable 'uf'
- '=': conversion from 'size_t' to 'unsigned int'
2024-10-10 18:06:04 +02:00
Kevin Eady
a780712ec7
Add spread operator for array initializers, function calls, and method calls (#684)
* Update grammar

* Update parser and AST generator

* Update semantic analysis, tests

* Handle instruction generation

* Executor implementation
- Instruction `ins_storestackcount`
- Instruction `ins_spread`
- Update listfile tests for new `storestackcount`` instruction

* Add tests targetting resource tracker

* Revert "Executor implementation"

This reverts commit f0caede24179cb11b6d98c8cd1fecd91ce546148.

* New instruction implementation
- Introduce `BSpread` object to manage spreading an object at runtime.

* More tests

* Fix memory leak

* Add test spreading non-arrays

* Add failure reason to bfunc method call
Better than getting uninit

* Core changes; docs + accompanying tests for docs

* Resolve CI annotation warnings
- this statement may fall through

* Fix listfile snapshots due to base rebase, whoops
2024-08-06 23:34:24 +02:00
Kevin Eady
6ed593ac81
Add function reference table to EScriptProgram (#686)
* 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
2024-08-06 20:29:02 +02:00
Kevin Eady
f381f46dc3
Add compiler support for function expressions (#671)
* 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
2024-07-29 22:30:52 +02:00
Kevin Eady
2de1995c19
Fix compiler for escaping } correctly in interpolated strings (#620)
* 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
2024-02-06 10:44:26 +01:00
Kevin Eady
593cfffb83
Add uninit, true, false keywords to grammar (#596)
* Update grammar

* Update expression handling for uninit

* update existing tests

* Add new tests

* Remove fullpath from escriptgrammar generation comment

* fix tests

* Update eScript guide

* Declare escript version 0x11

* Add core-changes

* Add `true` and `false` to grammar

* true/false implementation

* Fix existing tests

* Add new tests

* Update core changes

* add docs

* Fix BooleanValue::describe_to

* bool optimizations

* optimize uninit

* remove unused var assignments

* Update grammar for case labels for uninit, booleans

* Fix case label handling for uninit, true, false

* Tests

* Fix compiler version display v1.1700000017881393 -> v1.17

* optimize boolean binary operations

* fix unary boolean optimizer

* add boolean, uninit optimizer test

* Use new fmt lib apis

* Fix compiler warning

* really fix warning lol

* Add Executor[Module]::getParam for bools, FindSubstance test
2024-01-20 05:38:25 +01:00
turleypol
0e675c516a
use new formatter for ERROR_PRINT, added ERROR_PRINTLN (#595)
* use new formatter for ERROR_PRINT, added ERROR_PRINTLN

* remove old log define

* fix comments
2024-01-12 06:51:44 +01: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
turleypol
fc523320d9 added support of ++/-- for object members. 2019-09-26 07:06:45 +02: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
a5e6206164 Added cmake option to run clang-tidy
used everywhere nullptr
2018-10-09 16:36:35 +02:00
turleypol
ea0f465e6d Some better error handlings 2018-04-27 23:08:26 +02:00
turleypol
239295f236 added options to enable clang/gcc sanitizer
fixed a few errors in runecl/ecompile code
2018-04-26 10:42:19 +02:00
turleypol
3afc41241b
CMake on windows (#48)
CMake can now also be used for windows
2018-02-24 22:34:55 +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
6c772dcffc Fixed unreachable code warnings. 2016-12-19 17:22:09 +01:00
turley
099c81d572 Fixed some variable names hiding class members 2016-08-28 15:38:35 +02: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
turley
ed7b16b233 normalized lineendings 2016-02-11 22:54:43 +01:00
Gabriele Tozzi
6941efa185 Documentation: minor 2016-01-26 07:47:52 +01:00
frozenblit
a704a90208 Another round of stl_inc.h cleanups 2014-11-01 22:27:42 +01:00
turley
1a054e76e3 moved some escript function names into flyweight. 2014-08-15 15:27:46 +02:00
turley
31ee263a45 activated new logging facility 2014-01-18 13:29:38 +00:00
turley
99d7dc3037 namespaces...finally :)
Hard part is finished every file is touched. Namespaces are currently rough named by directory name.
Maybe we could split it more
2013-12-21 09:10:46 +00:00
turley
b0338db350 some c++11 changes 2013-09-21 09:45:04 +00:00
turley
fac3213f2a finally support for +=,-=,*=,/=,%= with objectmembers, like who.resist_fire_mod+=1 2012-01-03 14:53:36 +00:00
turley
03dc8c934e linux fixes for 64bit 2011-12-23 14:49:51 +00:00
turley
4e7e400254 64bit compilation.. 2011-12-23 13:28:38 +00:00
turley
e10cd27cea sync: shini - long to int (prerequisit for 64-bit) 2010-03-29 14:52:03 +00:00
muaddib_pol
4f01460d16 + bscript project upgrade to use literal paths. Removed include of ".."
+ Couple format/cleanup
2009-09-11 12:15:05 +00:00
muaddib_pol
d032ee448f + POL is now, open source. 2009-09-03 19:44:42 +00:00