Günther Brammer
ceb9c45984
Fix Script runtime reload
...
Just removing the right amount of functions from the proplists is
somewhat tricky, unfortunately.
2012-05-25 17:25:53 +02:00
Nicolas Hake
7efd9a9b9a
Aul: Add new nil-coalescing operator ??
...
This short-circuiting operator will evaluate to its first operand if the operand
is not nil, or to its second operand otherwise. Its intended use is to simplify
defaulting expressions that may evaluate to nil to a valid value.
2012-04-15 15:44:01 +02:00
Günther Brammer
f89f19b2cb
Script: No #appendto in Defs or global functions in #appendtos ( #734 )
...
So the only thing #appendtos may contain are lokal functions and variables,
which are only reachable via the Definition the script is appended to, and
global constants and variables, which only need to be parsed once. Thus,
#appendto scripts can skip being parsed without a definition, and the
errors that sometimes produces are gone.
2012-04-13 21:43:43 +02:00
Günther Brammer
f245af8972
Rename C4AulParseState to C4AulParse
2012-04-12 21:03:14 +02:00
Günther Brammer
6486ea9e19
Script: Disallow "new Clonk {}" for now
...
Eventually, "new Clonk {}" will create a C4Object. Prevent anyone from
using it before then.
2012-02-25 22:10:03 +01:00
Günther Brammer
67d8ac47e9
Keep functions across script reloads
...
For functions that are not appended/included, this is done by reusing them.
Functions that are not in the new script version are left with their code
raising and error. Appended/included functions are handled by a reference count.
2012-02-02 01:16:14 +01:00
Günther Brammer
8091dff419
Clean up C4AulScriptFunc API
2012-02-01 03:49:50 +01:00
Günther Brammer
65801a5188
Remove C4AulFunc::LinkedTo
...
The parser doesn't need it to find the functions it has to parse anymore.
And the global proplist can be cleared before removing the functions,
instead of having engine functions deregister themselves and script
functions being deregistered when their linked function is removed.
2012-02-13 22:20:10 +01:00
Günther Brammer
42679e48fb
Script: Inherit local variable initialization from #included scripts
...
This is done by creating their values in the parser. Global constants are
still created in the preparser so that they are available to the parser.
2012-01-25 00:36:11 +01:00
Günther Brammer
378e502c85
C4Script parser goes through the entire script instead of only functions
...
This should not change anything about which functions are created
by include/appendto and what inherited calls.
2012-01-27 00:42:41 +01:00
Günther Brammer
18038f45d3
Implement the function overload tree using the proplists
...
Instead of carefully inserting functions at the start or end of the list,
build the list just before the parser runs, at the same time as filling
the proplist where the functions are looked up.
This way, the overloaded function is simply the one that was previously in
the proplist, is not needed outside of the overloading function, and can thus
be replaced in the proplist.
2012-01-27 00:20:55 +01:00
Günther Brammer
f61ebfc453
Replace C4AulScript tree structure with a list
2012-01-25 04:15:39 +01:00
Günther Brammer
a7008e8a77
Script: Add "new p {}" syntactic sugar for "{ Prototype = p }"
2011-11-07 01:39:43 +01:00
Günther Brammer
24031a94bd
Simplify the C4Script tokenizer a bit
...
This shouldn't change any user-visible behaviour.
2012-01-24 18:35:21 +01:00
Günther Brammer
d07cc0c168
Some slight parser refactoring
2011-12-22 21:57:17 +01:00
Günther Brammer
dc7ca92936
Some parser code cleanups
2011-10-24 01:00:29 +02:00
Günther Brammer
ae11dfd1e4
Remove #strict infrastructure
...
The next incompatible changes to C4Script will probably use something else
anyway.
2012-01-25 04:15:53 +01:00
Günther Brammer
f3854e87f8
Replace C4AulScript::GetFunc with C4PropList::GetFunc/Call
2011-10-15 22:07:45 +02:00
Günther Brammer
497cd5cffc
Script: '->' also works with proplists
2011-10-15 02:30:30 +02:00
Günther Brammer
04e512fe00
Replace C4AulScript::GetFuncRecursive with C4PropList::GetFunc/Call
2011-10-15 02:27:02 +02:00
Günther Brammer
a684ab4aba
Script: Infrastructure for functions as a value type
2011-09-25 01:20:18 +02:00
Günther Brammer
b3aff643f3
Script reloading does not clear local variable defaults
...
The defaults are filled in by the preparser, which is only invoked for
changed scripts.
2011-10-04 22:16:27 +02:00
Günther Brammer
f166fdaed7
Move Parser from C4AulScript to C4ScriptHost
2011-10-13 18:01:02 +02:00
Günther Brammer
843642271d
Script: local variables work for the Scenario and definition calls
...
This requires replacing C4AulScript::Def with C4AulScript::GetPropList() and
C4DefScriptHost::Def, and making C4GameScriptHost::GetPropList return the
scenario proplist prototype.
Definition calls won't be able to change the local variables, of course.
Other proplists will be able to use local variables once they can have
functions.
2011-09-29 03:49:21 +02:00
Günther Brammer
a24ebc4936
Script: Add a proplist representing the scenario, named "Scenario"
...
The proplist is accessible from script via a global constant.
2011-09-25 23:24:29 +02:00
Günther Brammer
c63b66e909
Script: Add def and effect parameter types
2011-09-24 18:37:28 +02:00
Günther Brammer
32e7eb2904
Only use C4V_C4Object as typecheck target, tag the values with C4V_Proplist
...
This simplifies a few places which had to check for both tags before.
2011-09-26 20:22:31 +02:00
Günther Brammer
0fa37ef35d
Optimize if(!...) from two bytecodes to one
2011-10-14 00:28:32 +02:00
Günther Brammer
283876696d
Optimize away STACK 0 bytecodes
...
They got created for this without parentheses.
2011-05-07 00:18:00 +02:00
Günther Brammer
0c2ea0b6b5
C4AulParseState::AddBCC returns the position of the added chunk
2011-10-14 00:28:29 +02:00
Günther Brammer
c1d1424a56
Annotate Bytecode debug output with jump target labels
2011-05-07 00:19:01 +02:00
Günther Brammer
0cd46a2ebc
Wrap C4AulFunc::Name in C4AulFunc::GetName()
2011-10-14 00:40:55 +02:00
Günther Brammer
65a11ef1c3
Script: Remove unused function "descs"
2011-09-29 02:46:26 +02:00
Günther Brammer
9bc61db360
copyright notices update 2011
2011-09-01 16:58:52 +02:00
Nicolas Hake
fe747db554
Clean up copyright notices
...
Use real names for copyright attribution wherever they are known,
drop duplicates
2011-09-01 12:47:54 +02:00
Maikel de Vries
248f85c2eb
Removed Defcore:Edible and OCF_Edible
...
Had no use in the engine, should therefore be defined in C4Script if deemed necessary.
2011-07-05 13:10:56 +02:00
Günther Brammer
f97cde74c3
Split C4V_Any into C4V_Nil for the data type and C4V_Any for the typecheck
2011-05-09 14:37:28 +02:00
Günther Brammer
af52109912
Small parser cleanups
2011-05-02 23:52:41 +02:00
Günther Brammer
9c4dabc810
Maintain a pointer to the last added bcc, instead of one after that
2011-04-13 02:16:55 +02:00
Günther Brammer
e3bcd14db0
Simplify Parse_FuncHead
2011-04-18 01:50:33 +02:00
Günther Brammer
baeffbc67f
Let script functions have less than 10 parameters
...
Script functions using ... or Par() still take all 10
parameters, but those are the exceptions now. This makes
calling functions with few parameters faster.
2011-04-18 01:48:37 +02:00
Günther Brammer
63a3b546d5
Use bytecode to push variables onto the stack
2011-04-17 23:52:55 +02:00
Günther Brammer
50b6fcf47a
Use AB_DUP instead of AB_PARN
2011-05-02 21:39:52 +02:00
Günther Brammer
0b8c2bba37
Use AB_DUP instead of AB_VARN
2011-05-02 21:53:58 +02:00
Günther Brammer
fadacd3bb4
Move StrToI32 to lib/
2011-05-01 18:55:02 +02:00
Günther Brammer
117cbe2b81
Script: Add warnings against wrong operator parameter types
2011-05-01 18:53:50 +02:00
Günther Brammer
7b640daedb
Script: Add "\t" escape for tabulator
2011-04-13 23:51:35 +02:00
Günther Brammer
51d75e891b
Move script operator parameter types from a table into the code
...
This makes the target type visible to the compiler.
2011-05-01 17:16:02 +02:00
Günther Brammer
dbe7c37db0
Script: Only debug if the debugger was present before compilation
...
This saves a lot of AB_DEBUG bytecodes in the normal case.
2011-04-10 03:40:55 +02:00
Günther Brammer
435ed78cd9
Script: Remove unimplemented Par(n)=foo
2011-04-10 02:05:11 +02:00