wire/data
Vurv 5fc05d58f9
Add try/catch stmt, @strict directive & runtime error handling to E2 (#2174)
* Add try/catch statement to E2.

Adds a try / catch statement to E2 that allows users to catch any errors that occur inside of the block, and if so, run the catch block, setting the variable name provided to a new local variable that contains the error string.

* Add not enough memory & table overflow to uncatchable

* Lot of combined changes

* Made ``exit`` skip the try catch block as a whole.
* Added ``@strict`` directive
* Refactored the directives a bit to add ``@strict``
* Added a ``throw`` function to registerFunction that either throws an error or returns the default value of the function inside using the type defined. You can override this with the second argument.
* Edited the preprocessor for this ^
* Edited the entire core/entity file to preview how this would look.
* Some copytype calls still existed and were replaced with ``E2Lib.fixDefault``

* Some missing ``throw``s

* self:throw and explicit returns

Throwing is much more explicit now. You call self:throw(msg, var) and var is returned if the chip isn't strict. Got rid of the throw hack to try and get the default type. The only problem here now is trying to get some debug info about where the error happened. Right now it's not very useful and isn't able to point to the function calling self:throw for some reason.

* Fix travis lint

Hardcoded the starting point for this line.  (#"trigger" + 2)

* Can only catch e2 errors & thrown errors

Native lua/glua error() will always error try and catch blocks for security reasons.

The only errors that will be caught are created by E2Lib.catchableError. (self.throw and e2's error)

Replaced context:throw with context.throw to be more memory efficient i guess.

* Throw compat with a lot more libraries

Added ``@strict`` compat to a lot more libraries. I think adding more would make this PR too big, it's already pretty huge.
Additionally made some code a bit more clean and optimized & used E2Lib.newE2Table more. (Notably with bone fwd up right)

* Fix compile errors

* Have compile traces be sent to runtime

* E2 instances/contexts now have a ``trace`` field, which contains the latest trace from EvaluateStatement & the ``seq`` instruction. Thrown errors will now show as something like ``Expression 2 (generic): Runtime error 'Invalid physics object!' at line 10, char 16``.

* Fixed some compiler quirks (Some functions called from the Compiler global object instead of self, which wouldn't allow for multiple compilers iirc)

* Also added Compiler:CallInstruction which does self["Instr"...] etc for you
* Localized string.upper use

* Fix udf errors

* Make stringcalls able to be caught

Forgot to re-implement this since we opted for a whitelisted error instead.

* Fix some core error

* Add strict test to unit tests, fix exit, assert

* Add a ``strict.txt`` unit test to data/expression2/tests.
* Also add a small try/catch test to ``parsing.txt``

* Fix assert() e2function not throwing a catchable error. It now provides a runtime src position like the rest of the errors

* Fix exit() not exiting the chip. The ``Skip`` table was just making exit() exit the try / catch block rather than passing it to the error handler to exit the whole chip.

* Fix #include, Runtime traces

* Include was messed up because whoever implemented it didn't think about needing the scope after erroring. It didn't load the old scope back which messed up trying to use try/catch.

* Fixed runtime traces because before I tried to make it only take from the seq instruction which would always make the error come from where the first instruction is.

* Renamed E2Lib.catchableError to raiseException to be more clear. Also has a 4th param for whether it's catchable, that is default true.

* Added E2Lib.unpackException(struct) which is a boilerplate bridge function for when you want backwards compatibility with error messages & error structs in pcalls.

* Remove debug stuff

* Squashed commit of the following:

commit 02d5dfd0ae
Author: stepa2 <sssstepa452@yandex.ru>
Date:   Thu Jul 29 20:48:37 2021 +0300

    Implemented do-while statement for E2 (issue #2191) (#2193)

    * Allow calling entity:setPos and entity:setAng on entities without collisions
    Also allow calling entity:propManipulate, but position and rotation is only updated

    * Update prop.lua

    Removed tailing whitespace, fixed luacheck warning

    * Implemented do-while statement for E2 (#2191)

    * Removed debug messages I fogot to remove, added parsing tests, disabled bugged optimization

    * Linting pass

commit 73b4dbf208
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Sun Jul 25 00:52:11 2021 -0400

    Fix explodeRE (#2204)

commit 6a5d4a214f
Author: Derpius <49565664+Derpius@users.noreply.github.com>
Date:   Sat Jul 24 23:58:13 2021 +0100

    Add 4th option to view request bypass (#2198)

    * Add 4th option to view request bypass

    * Update comment

commit adca748833
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Sat Jul 24 18:57:53 2021 -0400

    Fix light sprite size (#2201)

    * Fix light sprite size

    * Revert sizing code. Also simplified because you can't even see the smaller sprites

    * Made spritesize an option/input

    * Add back tube light sprites

    * Add missing clamp

commit c4d333aef3
Author: Divran <arviddivran@gmail.com>
Date:   Sat Jul 24 23:19:26 2021 +0200

    fixed crash exploit

commit 966b1e4dc9
Author: AbigailBuccaneer <AbigailBuccaneer@users.noreply.github.com>
Date:   Sat Jul 17 15:09:26 2021 +0100

    Restore expression2 ghost functionality

    Commit ec99005dd4 accidentally prevent the
    E2 tool from showing ghosts.

commit 01c36ae2aa
Merge: f85c234d 1a1ddd36
Author: Divran <arviddivran@gmail.com>
Date:   Tue Jul 13 22:54:54 2021 +0200

    Merge pull request #2197 from sammyt291/patch-1

    Light sprite colors and size

commit 1a1ddd36a4
Author: sammyt291 <samuel_canning@hotmail.co.uk>
Date:   Sun Jul 11 20:07:42 2021 +0100

    Light sprite colors and size

    Changed the smaller 3 sprites on the tubular light to match the color of the main sprite on the light
    Allowed the sprite overlay to be sized according to the size slider already present, clamped to 128 to avoid changing existing contraptions with large-size glows enabled.

commit f85c234d77
Author: stepa2 <sssstepa452@yandex.ru>
Date:   Sat Jul 3 03:35:04 2021 +0300

    Allow calling entity:setPos and entity:setAng on entities without collisions (#2188)

    * Allow calling entity:setPos and entity:setAng on entities without collisions
    Also allow calling entity:propManipulate, but position and rotation is only updated

    * Update prop.lua

    Removed tailing whitespace, fixed luacheck warning

commit 860604bbb9
Author: CoreyLee Hassell <Anticept@users.noreply.github.com>
Date:   Fri Jul 2 20:34:47 2021 -0400

    Revert "Delete json funcs until https://github.com/Facepunch/garrysmod-issues/issues/4976 is fixed (#2177)" (#2185)

    This reverts commit c6ea454243.

commit eb3841f19c
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Fri Jun 25 19:50:34 2021 -0400

    Improve regex and fix pcall not returning (#2186)

    * Improve regex and fix pcall not returning

    * Don't use %b

commit 1ef0f63dd1
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Thu Jun 24 02:25:28 2021 -0400

    Add level setting, also play regardless of distance/location (#2183)

commit ec99005dd4
Author: 100PXSquared <100pxsquared@gmail.com>
Date:   Wed Jun 23 08:01:26 2021 +0100

    E2 View Requests System (#2157)

    * Add E2 view requests system

    * Prevent prop protection stopping view requests

    * Perform CanTool check if chip owner is invalid

    * Refactor checks in TOOL:Think

    * Add SteamID whitelist convar to view requests

    * Fix request answer netmsg validation

    * Add EoF newline

    * Refactor E2 view requests

    * Replace bypass list with bypass mode convar

    * Implement allow always

    * Replace checks in remote updater code request

    * Fix copy paste induced bug

commit f888eb12e7
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Wed Jun 23 02:39:23 2021 -0400

    Fix turret behavior if parented (#2184)

commit f8335f9711
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Fri Jun 18 11:35:20 2021 -0400

    Limit regex cpu consumption (#2181)

    * Limit regex cpu consumption. Fixes: #2063 Related (https://github.com/Facepunch/garrysmod-requests/issues/1878)

    * Better error message

commit d0a84b700f
Author: Divran <arviddivran@gmail.com>
Date:   Fri Jun 18 00:44:56 2021 +0200

    sound duration is very expensive

commit f54ff0a120
Author: Divran <arviddivran@gmail.com>
Date:   Fri Jun 18 00:13:01 2021 +0200

    fixed auto indenting

    auto un-indenting after typing } was broken (triggered even if the same
    line contained a {), and did not add itself to the undo table, so could
    not be undone.
    auto indenting after typing { was also broken if the same line contained
    a }

    adjusted digi screen bandwidth
    slowed down clientside digi screen rendering to prevent fps lag

    fixed hologram queues after last update broke it

commit 4855366a2f
Author: Divran <arviddivran@gmail.com>
Date:   Wed Jun 16 18:58:31 2021 +0200

    digi screen max global bandwidth

commit 7b5ac40cb9
Author: Divran <arviddivran@gmail.com>
Date:   Wed Jun 16 02:18:54 2021 +0200

    improved digi screen performance

    added cpu time based usage checks serverside
    and coroutine processing clientside
    hopefully this is (at least v1 of) the final strip of duct tape for this
    notorious entity

commit d8cdc76bcb
Author: Divran <arviddivran@gmail.com>
Date:   Tue Jun 15 22:37:39 2021 +0200

    fixed multiple crash and lag exploits

    reset() no longer resets e2 quotas
    emergency ram shutdown now also clears gtable memory
    hologram scale/clip update rate limited to 0.1s and opcost increased to
    30
    and a few others

commit c6ea454243
Author: thegrb93 <grbrown93@sbcglobal.net>
Date:   Sat Jun 12 19:13:26 2021 -0400

    Delete json funcs until https://github.com/Facepunch/garrysmod-issues/issues/4976 is fixed (#2177)

* Revert "Squashed commit of the following:"

This reverts commit 9f0b2f0e46.

* Return keyword

* Fixed expressions being missing thanks to missing return keyword
* Removed useless local variable in var operator

* Remove unused test code

Not a bug or anything but something I randomly came across..
2021-08-14 17:38:35 -04:00
..
cpuchip
expression2 Add try/catch stmt, @strict directive & runtime error handling to E2 (#2174) 2021-08-14 17:38:35 -04:00
gpuchip
soundlists
spuchip/examples