Commit Graph

235 Commits (16641d3841b9529d8ac5ce8cefa88716c3be0ba7)

Author SHA1 Message Date
Nicolas Hake 16641d3841 C4AulScriptFunc::DumpByteCode: properly align BCC names
The old code just appended eight spaces when the type of the BCC was
shorter than eight chars.
2016-05-11 17:15:47 +02:00
Nicolas Hake 33f7fb935f C4AulCompiler: Rename iStack to stack_height 2016-05-09 12:33:51 +02:00
Nicolas Hake 41000a8f9a C4AulCompiler: Rename pLoopStack to active_loops 2016-05-09 12:21:33 +02:00
Nicolas Hake d0dbe05876 C4AulCompiler: Rename fJump to at_jump_target
You have no idea how much I hate systems hungarian.
2016-05-09 12:21:33 +02:00
Nicolas Hake 7a135a060f C4AulParse: Take GetTokenName out of public interface 2016-05-09 12:21:33 +02:00
Nicolas Hake 0a3b31e735 C4AulParse::AddVarAccess: Move to C4AulCompiler 2016-05-09 12:21:33 +02:00
Nicolas Hake 792e12adad C4AulCompiler: Split into separate file 2016-05-09 12:21:33 +02:00
Nicolas Hake c8d71d47c0 C4CodeGen: Rename to C4AulCompiler
I need to split up C4CodeGen into smaller parts, and having the bit that
actually generates the bytecode named C4CodeGenCodeGen would be silly.
2016-05-09 12:21:33 +02:00
Günther Brammer 9741af42fd Replace all usages of the old local variables list with properties 2016-05-01 00:28:37 +02:00
Günther Brammer 7792acdff0 Script: Check for functions before keywords
This unifies the lookup for local variables and functions. Its slightly
awkward that global functions can overload if and Par now, but local
variables already could.
2016-05-01 00:28:37 +02:00
Günther Brammer 30f7457d89 Remove unused macros leftover from removed script features 2016-05-01 00:28:37 +02:00
Günther Brammer b8f2d0ca87 Script: Repeat the parser error message when executing a broken function 2016-05-01 00:28:37 +02:00
Günther Brammer 17b18da26c Make bytecode dump work again
Dumping the bytecode before adding EOFN while depending on that to signal
the end isn't such a hot idea.
2016-05-01 00:28:37 +02:00
Günther Brammer 4092911349 Move code generation into its own class 2016-04-28 03:25:47 +02:00
Günther Brammer b00b8554ab Merge branch script 2016-04-28 03:25:44 +02:00
Günther Brammer d45ac946fe Add C4AulParseError constructor and cease reusing it for warnings
The nontrivial code that formats the position is now a function of
C4AulParse used by both warnings and errors.
2016-04-28 02:59:12 +02:00
Nicolas Hake a8f4bd3960 C4AulParseError: Avoid the second string parameter
While I'm not a big fan of hiding flow control in a function, Error()
handles formatting and saves me from calling FormatString().getData() a
lot.
2016-04-28 02:59:12 +02:00
Günther Brammer 525cdc11a3 Deduplicate calculation of the relative stack position of local variables 2016-04-28 02:59:11 +02:00
Günther Brammer 071feaa78f Deduplicate loop control handling in the script parser 2016-04-28 02:59:11 +02:00
Günther Brammer e22ca51f72 Don't leak references to Strings on script errors (#583) 2016-04-24 19:40:27 +02:00
Günther Brammer 5fbac346d3 Incompatible type warnings work for parameters with type declarations 2016-04-24 19:40:27 +02:00
Nicolas Hake 19a3d43558 Fix definition of explicitly sized enums 2016-04-24 15:20:28 +02:00
Nicolas Hake caf44e2473 Remove specious space from Aul operator table 2016-04-24 14:01:23 +02:00
Nicolas Hake 770be2dafe Aul: Allow AB_ERR to carry more detailed error information 2016-04-24 14:01:23 +02:00
Nicolas Hake 367f58b1cc C4AulParseError: Enable creation from host and source pointer
Instead of having a C4AulParseError constructor read the location data
from the parse state, allow explicit construction from a known location.
2016-04-24 14:01:23 +02:00
Nicolas Hake cfdb1142b8 Move C4AulParse declaration into separate header 2016-04-24 14:01:23 +02:00
Nicolas Hake aa06b3b6f6 C4AulParse: Drop unused ATT_STAR
ATT_STAR has been rolled into ATT_OPERATOR and is no longer used
anywhere.
2016-04-07 20:52:31 +02:00
Nicolas Hake f963a398aa Define NORETURN annotation for MSVC 2016-04-07 20:52:28 +02:00
Nicolas Hake eabca223f5 Update all copyright notices for 2016 2016-04-03 20:24:42 +02:00
Nicolas Hake 493c276126 Rewrite header inclusions to #include "path/to/file.h" style 2016-04-03 20:24:42 +02:00
Günther Brammer b54ddc7663 Merge branch script 2016-03-01 03:04:17 +01:00
Günther Brammer 0c0c64642a Remove unused #define in C4AulParse 2016-02-12 17:15:46 +01:00
Günther Brammer fdbad8fe83 Simplify the test for loop end in parameter parsing
Instead of storing in fDone whether the token is a ')', make that the loop
condition.
2016-02-02 02:57:50 +01:00
Günther Brammer f1b99aa355 Avoid pushing and popping an unused parameter with ... 2016-02-02 02:57:49 +01:00
Günther Brammer 6a6c0d8b0b Optionally warn about too many parameters in -> calls, too
While at it, only consult the right function for direct calls, not any
other function with the same name.
2016-02-02 02:57:49 +01:00
Günther Brammer b2c263bd0e Don't mark the condition of do-while as a jump target without a continue
In contrast to the other loops, where the condition is always jumped to.
2016-02-02 02:57:49 +01:00
Günther Brammer 00f013d59e Optimize accessing the same variable as was just now set 2016-02-02 02:57:49 +01:00
Günther Brammer b7eff7f55f Set jump target flag for bytecode added after MakeSetter removed one
Also avoid removing the original bytecode if it is DUP, LOCALN or GLOBALN.
This way, setting the jump target flag can be avoided in some cases.
2016-02-02 02:57:49 +01:00
Günther Brammer 532b47ed27 Optimize do; while(!...) from two bytecodes to one
This revealed that the code for setting Par.i was wrong before, but didn't
matter because the jump target for all CONDN was set afterwards. But the
jumptarget for COND was set directly, and must be adjusted to account for
the bytecode that gets optimized away.
2016-02-02 02:57:49 +01:00
Günther Brammer 168ac8bb40 Remove pointer to start of variables from function context
It pointed always to Pars + Func->GetParCount(). The only users were
VARN_CONTEXT, which can be replaced with PARN_CONTEXT that way, and
FOREACH_NEXT, where the parser can do the math and simply give a number
relative to the current stack position, like regular variable usages do.
2016-02-02 02:57:48 +01:00
Günther Brammer 5bb3d7cb77 Use a null C4ScriptHost to parse DirectExec code
This mostly makes Parse_Expression use the case for functions in proplists
instead of the other for local variable lookup.
2016-02-02 02:57:48 +01:00
Günther Brammer 6f98fb2e66 Remove C4AulScript class
It isn't needed to hold engine functions anymore, because those are just
put into C4PropLists.
2016-02-02 02:57:47 +01:00
Günther Brammer 9742a404ff Move Script Parser warning function to C4ScriptHost 2016-02-02 02:57:47 +01:00
Günther Brammer b21acff0c7 Move Scriptparser State into C4ScriptHost 2016-02-02 02:57:46 +01:00
Günther Brammer 2ebd1a98ad Script: Functions in constant proplists can access their properties 2016-02-02 02:57:46 +01:00
Günther Brammer f757706e68 Make the C4Script tokenizer context-independant 2016-02-02 02:57:46 +01:00
Günther Brammer 9193c8938b Retire the split between Parse_Expression and Parse_Expression2
In earlier C4Script versions, there were multiple variants of expressions,
all followed by the same operator options, but nowadays everything is more
uniform.
2016-02-02 02:57:46 +01:00
Günther Brammer 4f620c1537 Parse array expression with fewer lines of code
Instead of tracking the status with a variable, simply test the loop-end
condition directly, and reduce code duplication between empty and non-empty
array contents.
2016-01-24 12:27:23 +01:00
Günther Brammer b7bd48a73f Unify the various Parse_-Functions to consume the last token they match 2016-01-24 12:27:23 +01:00
Günther Brammer 6a5b571fe3 Drop warning about trailing comma at the end of a parameter list
A trailing comma does not change the behaviour of a function call, so it is
totally harmless.
2016-01-24 12:27:23 +01:00