Scripting language changes, cleanup and documentation#1712
Open
marauder2k7 wants to merge 1 commit intoTorqueGameEngines:developmentfrom
Open
Scripting language changes, cleanup and documentation#1712marauder2k7 wants to merge 1 commit intoTorqueGameEngines:developmentfrom
marauder2k7 wants to merge 1 commit intoTorqueGameEngines:developmentfrom
Conversation
d4858db to
991b025
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alot of changes here so lets go through them from the ground up
Firstly the CMDGram.y and CMDscan.l (bison/flex) files have some added documentation to hopefully make it easier to make modifications in future.
Error reporting now correctly resets the line number when crossing different files in a compile chain
rwNAMESPACE and rwCLASS were declared but had no lexer rule, nor did they contribute to any grammar so they have been removed.
STMT_SEP, opMDASN, opNDASN, opNTASN were listed here but were never defined so removed them.
opSTREQ and opSTRNE where never declared which may have caused confusion due to the compiler not knowing their semantic type.
Cleaned up commented out gramar rules.
Next ConsoleValue
only cvString was heap allocated so it was the only type we were required to free, this was a confusing point during the last time we made changes in this class so to make this clearer there is now a setStringOwned function that makes this clear, setStringRef is still there as a passthrough.
Entire class has had their functions moved for improved readability of the class, getters at the top setters down below, queries below that.
new copyFrom and transferFrom functions to group that logic so it is no longer repeated throughout the class.
move constructor and assignment, this was previously being executed without a definition from a few key sites where the compiler was expecting a move. This means that this was being done by a copy before which meant the var was not being freed until it went out of scope. Potential danger point of dangling pointer so hard free with the move.
Next ASTNodes
ConstantNode was always returning the incoming ip, now it returns codestream.tell in case the compile statements expand the codestream.
propagateSwitchExpr was calling getSwitchOr which created a recursive or expression tree that O(n) deep for n cases. This had a chance of overflowing for large switch statments if there was 100+ cases the gStack would of overflown. Now this is changed to build a left associative chain instead. This avoids deep recursion and should be safer. Further expansion on this may be required.
Default Function Arguments:
The default function arguments previously were creating a ConsoleValue at compile time for each value that was presented as a default, furthermore no matter what function was being called if it had defaults or not these consolevalues were tacked on to the namespace of the function. This was prone to leaks and some dangers if not handled absolutely correctly.
The changes here now hold the default offsets and these vars are compiled during the function call. This allows more dynamic allocation of default argument for function callsits eg:
This is now perfectly valid and will update based on the global var. This made it so that you could also use previously defined functions as the default value eg: