Nicolas Hake
021a6e89f5
Implement direct execution of whole function definitions
...
This implements the changes made in c6e4bfd
on the AST-based parser.
2016-10-19 14:20:47 +02:00
Nicolas Hake
9caaf1e298
Aul: Split out error handling into a separate class for easier testing
...
By using an extern error handler in the script engine, we can mock that
handler and make sure something that should fail actually does, instead
of having to parse log messages.
2016-10-19 14:20:41 +02:00
Nicolas Hake
eca8f2cce8
Aul: && returns either parameter, not bool
2016-05-13 16:20:17 +02:00
Nicolas Hake
43c6f946dd
Aul: Split assignment op from standard BinOp
...
Assignment was special-cased everywhere, so it can just as well get a
separate AST node.
2016-05-13 13:50:29 +02:00
Nicolas Hake
daf3424e63
Delete some commented-out legacy function parameters
2016-05-13 13:14:23 +02:00
Nicolas Hake
092a23c2f7
Aul: Parse scripts into an AST, then generate bytecode from that
...
This commit contains a fairly substantial rewrite of the C4Script code
generator. Instead of generating bytecode while parsing the script,
we're now parsing the script into a syntax tree, and have any further
processing happen on that instead of the raw source.
At this time, the code generator emits the same bytecode as the old
parser; there are several optimization opportunities that arise from the
new possibility to emit code out of order from its specification by the
author.
Compared to the old compiler, this one is still rather deficient when
dealing with incorrect code; it's also not emitting several warnings
that used to be diagnosed.
2016-05-12 19:43:48 +02:00
Nicolas Hake
10abb1bbdb
Remove unused C4AUL_CodeBufSize
2016-05-11 17:15:47 +02:00
Nicolas Hake
a100b93e7f
DEBUG_BYTECODE_DUMP: Allow setting from build system
2016-05-11 17:15:47 +02:00
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