Commit Graph

29 Commits (61962fe70abd22a665446cc09fcef163bf0e3862)

Author SHA1 Message Date
Nicolas Hake 60829ae5e4 Aul: Don't let exceptions escape from constant resolver
Letting the constant resolver throw exceptions prevented us from doing
checking on later initializers anyway, so instead we'll send them to the
error handler. As a special bonus this makes it so we don't crash when
a global variable initializer has errors. Fixes #1850, #1855.
2016-11-30 13:37:33 +01:00
Sven Eberhardt c5623aa7a2 Fix crash on script error in DirectExec scripts 2016-11-20 13:14:57 -05:00
Nicolas Hake 34bdab6ba5 Aul: Don't force assertions active
Assertions are great for debugging, but in public builds they just kill
apps dead.
2016-11-13 11:07:22 +01:00
Nicolas Hake eda6cc9c7f Aul: Gracefully handle errors in codegen (#1840)
By continuing to generate bytecode even after an error is found, we're
able to find more syntax errors and will also be able to keep the value
stack at the expected height.
2016-11-13 11:07:21 +01:00
Nicolas Hake ff0325dfac Aul: Always reset the current function when a declaration ends (#1839)
When an error occurred during codegen of a function, the current
function pointer would not be reset to 0, leading to spurious warnings
about redeclaration of functions.
2016-11-13 11:07:01 +01:00
Sven Eberhardt ebda8193ef Replace NULL by nullptr in C++ sources
We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
2016-11-02 19:58:02 -04:00
Lukas Werling 9c98227a03 Fix all -Wformat warnings 2016-10-31 23:39:45 +01:00
Nicolas Hake 194e7d709b Aul codegen: Handle errors at codegen time better (#1837)
If a parse error occurs inside a declaration, the codegen should just go
on and deal with the next declaration instead of completely giving up on
the entire script.
2016-10-31 11:17:43 +01:00
Sven Eberhardt f2231e848e AulCompiler: Fix static parameter type check 2016-10-24 22:00:30 -04:00
Nicolas Hake cada67c097 Prohibit overriding local vars with functions (#1831)
The old parser threw a standard compile error in this case; the
AST-based parser threw an ICE, which is ultimately the same thing but
made it sound like the parser was at fault. And maybe it is, and we
should allow code like "local a; func a() {}" but that seems like it
should be a conscious design decision.
2016-10-21 22:32:24 +02:00
Nicolas Hake 5915f79960 Don't entirely recreate global vars in second compile pass
This allows people to properly cross-reference two proplists from each
proplist's initializer.
2016-10-19 14:20:48 +02:00
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 1a8db9e109 Make C4ScriptHost store C4Value refs to owned functions
C4Value already handles refcounting properly for us, so we don't need to
do it manually. It might still be worth manually refcounting them
to avoid the boxing/unboxing overhead, but it's only needed at load and
unload so it's not a priority at the moment.
2016-10-19 14:20:46 +02:00
Nicolas Hake 5f3dbdd417 Reject function expressions inside proplists inside functions
These aren't supported by the codegen on account of not working in
savegames.
2016-10-19 14:20:45 +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 f7a04624eb Remove references to functions defined in unloading defs (#1776) 2016-10-19 13:45:59 +02:00
Nicolas Hake ab1e6bd5a4 Allow proplist-local funcs to access vars of their owner's prototype
Thanks to JCaesar for providing this test case.
2016-10-19 13:45:35 +02:00
Nicolas Hake 370a1dd3d1 Aul: Re-enable parameter type checking after AST rewrite 2016-05-13 16:22:37 +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 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 26334cb4d7 Aul: Join AB_INT + AB_Neg 2016-05-09 12:33:59 +02:00
Nicolas Hake 34556e3e81 Aul: Join AB_STRING+AB_ARRAYA to AB_PROP 2016-05-09 12:33:58 +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 f0b4ef46a5 GetStackValue: Remove "default: /* unreachable */"
Without an explicit default case, the compiler can warn about unhandled
enum values inside the switch.
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 0342711cd4 C4AulCompiler: Take GetStackValue out of public interface 2016-05-09 12:21:33 +02:00
Nicolas Hake 792e12adad C4AulCompiler: Split into separate file 2016-05-09 12:21:33 +02:00