Commit Graph

118 Commits (368a073415064957c292242483e2967a4c3e28b3)

Author SHA1 Message Date
Peter Wortmann 88ef1d40fa Warning fixes
Actually pretty sure a few of them were bugs
2015-08-31 19:52:39 +01:00
Günther Brammer b7a022852e Revert "Move C4Aul code into separate subdirectory"
The distinction between the "aul" and "non-aul" parts of
the script engine are mostly historical accident, and the
current organization of the source code does not use
sub-subdirectories. I'd like to keep it that way.

This reverts commit 69ba06b8d0.
2014-05-12 02:24:19 +02:00
Nicolas Hake 69ba06b8d0 Move C4Aul code into separate subdirectory 2014-05-11 16:17:48 +02:00
Sven Eberhardt 445d759a72 Change == and != to do pointer comparison on arrays and proplists (formerly === and !==). Remove === and !=== and introduce function DeepEqual for contents comparison.
There have been some bugs and crashes related to unwanted deep comparison (e.g. in the maze scenario). Scripters very rarely need deep comparison, so it should not be the default for the most commonly used operator.

This also changes behaviour of GetIndexOf to do pointer comparison.

This change has Guenther's seal of approval.
2014-04-19 22:33:31 +02:00
Julius Michaelis f4e93d13bf Add parameter type check for FnCall 2014-04-17 19:24:36 +02:00
Sven Eberhardt dd0438b55d Added helper function LogCallStack.
Useful when you need a stack trace but don't want to break execution flow.
2014-01-04 14:22:41 +01:00
Nicolas Hake e0dc30c59a Update copyright notices
As discussed in http://forum.openclonk.org/topic_show.pl?tid=2917, I
have merged all copyright notices into a single file and referenced that
merged file from each source file.

For the updated source files, the timeline has been split into three
parts:
 1. Pre-RWD code (before 2001)
 2. RWD code (2001 through 2009)
 3. OpenClonk code (2009 and later)
All pre-RWD copyright notices have been left intact, as have RWD-era
copyright notices where the file did not have a RedWolf design copyright
notice but only individual author ones. All copyright notices of the
OpenClonk era have been replaced by a single notice ranging from the
first recorded year to the current year (2013). Mape code did not get a
OpenClonk Team copyright notice because it is somewhat separate from the
main OpenClonk codebase and has only been touched by Armin Burgmeier.
2013-12-23 13:03:19 +01:00
Tobias Zwick fe2a400c02 replace global function GetTime() with class function C4TimeMilliseconds::Now() 2013-12-07 21:27:01 +07:00
Tobias Zwick 94c618d153 add new type C4TimeMilliseconds for time measurements to solve problems when GetTime() overflows (#251)
The new type C4TimeMilliseconds behaves for the most part like a uint32_t but is overflow-proof in comparisons.
In some places, a 0-value (or uint_max) of the variable storing the time had the special meaning "not set yet". This has been resolved by having it as a pointer to C4TimeMilliseconds with NULL meaning that it has not been set yet.
2013-12-04 19:35:07 +07:00
Nicolas Hake 003f897cbe C4AulFunc: Improve const correctness 2013-11-02 13:40:33 +01:00
Martin Plicht 91f8d32d69 debugger: Make it work again (some issues remaining, setting breakpoints on included scripts is questionable and listener socket setup sometimes hangs..) 2013-10-13 23:03:25 +02:00
Martin Plicht eaf93d6a0e Also check for DebugRec flag in #ifdef DEBUGREC_* blocks 2013-05-25 23:01:41 +02:00
Sven Eberhardt cc44b71756 Fix SIGFPE exception on INT_MIN/-1 and INT_MIN%-1 in C4Script 2013-02-26 21:41:27 +01:00
Günther Brammer 42608c5209 Remove C4DirectExecScript, use an existing scripthost for the eval function
Since the scripthost isn't used to store the bytecode anymore,
Parse_Expression doesn't modify it anymore. So there is no need for a
temporary one.
2013-01-23 21:36:21 +01:00
Günther Brammer 864c5c7ea8 copyright notices update 2012 2013-01-12 16:31:40 +01:00
Günther Brammer af62ab7931 Move script bytecode from C4ScriptHost into C4AulScriptFunc
This makes functions independent of their "Code Owner"s, which removes the
necessity to maintain that connection and carefully reset functions when
their scripthost is cleared.
2012-10-21 18:14:32 +02:00
Günther Brammer bfdc02900c Change C4AulScript::GetPropList() return type to C4PropListStatic*
This doesn't actually change the type of any object, but shifts some casts
around.
2012-08-09 01:17:26 +02:00
Günther Brammer 7f9ab9ac19 Script: this returns nil after RemoveObject instead of throwing
Because the interpreter throws for every function that is called with a
this parameter that has been removed, this() isn't a function anymore.
The function could stay around so that Call("this") or foo->this()
would still work, but I doubt any script ever did that.
2012-06-18 04:07:36 +02:00
Günther Brammer 23d1246be1 Script: Add === and !== operators
These operators have a stricter definition of equality than the == and !=
operators. Those are already stricter than in some other languages, so the
new ones are probably not needed very often. But if the need does arise,
there's no workaround short of modifying the data structures and checking
whether they are still the same.
2012-06-11 00:47:28 +02:00
Günther Brammer bd371e38c1 Make the child pointers of the scriptengine C4AulScript*s again
The rope will create a C4AulScript for the rope engine functions instead of
putting them into the global scope, and we might want to put C4Object-only
functions into a separate C4AulScript some day, too.
2012-06-07 21:07:31 +02:00
Günther Brammer c6fe23729b Replace function list from C4AulScript with proplist enumeration
This finally makes the function list in C4AulScript unnecessary.
2012-05-28 00:50:13 +02:00
Günther Brammer 487a0ea38f Store a copy of the proplist the preparser created for include/appendto
The parser now copies the contents of the proplists in the order of their
source scripts into the final proplist. This way, local variable contents
get properly included, and the list of functions has one user less.
2012-05-28 00:31:55 +02:00
Günther Brammer 9d30869e87 Remove unused C4ScriptFnDef::FunctionC4V
Also move C4AulDefFunc and C4ScriptFnDef to the same header the template
helper classes are in. Like them, these classes are a mostly invisible
implementation detail of the engine script functions.
2012-05-20 02:39:57 +02:00
Günther Brammer 62bc721a65 Make the child pointers of the scriptengine C4ScriptHost*s
This only tightens up the types a bit.
2012-05-15 19:32:58 +02:00
Günther Brammer a10ebdfabe Remove unused C4AulContext
The C4AulScriptContext is now an implementation detail of C4AulExec.
Also consolidate the C4Object * Obj and C4PropList * Def members to just
C4PropList * Obj and convert that to C4Object * on demand.
2012-06-04 00:03:49 +02:00
Günther Brammer 6815515a00 Consolidate C4AulFunc::Exec into just one virtual function
Deriving classes only need to implement one variant. The second Exec is a
trivial wrapper that doesn't have to be virtual.
2012-05-27 23:35:23 +02:00
Günther Brammer 09d08298bf Replace C4AulContext* this of C4Script engine functions with C4PropList*
This mainly removes some indirection and a superfluous struct.
2012-05-15 03:03:47 +02:00
Günther Brammer 0e6f972de4 Remove unused C4Object* parameter from C4AulExecError 2012-05-15 03:11:23 +02:00
Günther Brammer c86eadf5eb Script: Show the this parameter in callstacks before the function with ->
Also reuse the display code from C4Value instead of yet another format.
2012-05-15 03:51:20 +02:00
Günther Brammer fb4bac65be Remove C4AulContext::Caller 2012-04-28 21:32:29 +02:00
Günther Brammer 133e987902 Script: Throw instead of silently using nil for this after RemoveObject 2012-04-29 16:53:29 +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 ac02380b58 Script: this->RemoveObject() changes this to nil (#722) 2012-04-13 20:28:30 +02:00
Günther Brammer 6126df616c Make engine compile with debugrecs again 2012-03-11 17:52:00 +01:00
Günther Brammer dfea0914a9 Merge the functions pointer branch 2012-03-09 17:42:48 +01:00
Julius Michaelis 5716bb1e47 C4AulScript::DirectExec: Throw on parsing errors, too, when fPassErrors is set. 2012-03-09 11:45:25 +01:00
Günther Brammer ce27d42ac7 Remove unused C4AulScript::Owner
C4AulScript::Translate referenced it, but used it only when called from
eval, which is not done.
2012-02-17 01:04:05 +01:00
Günther Brammer 8091dff419 Clean up C4AulScriptFunc API 2012-02-01 03:49:50 +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 f61ebfc453 Replace C4AulScript tree structure with a list 2012-01-25 04:15:39 +01:00
Günther Brammer 4a3e692962 System.ocg scripts have a proplist for parsing purposes 2011-10-24 17:02:27 +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 497cd5cffc Script: '->' also works with proplists 2011-10-15 02:30:30 +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 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 b4021015f7 Make C4AulFunc::Exec take a proplist instead of an object 2011-09-25 23:49:17 +02:00
Günther Brammer d723d43d92 Make C4AulContext::Def a proplist 2011-10-13 23:39:35 +02:00
Günther Brammer 2afeb25df6 Script: remove redundant check for 0 in object call
0 is neither object nor definition, so the ordinary typecheck suffices.

Also change the error message to use '->' instead of object or definition
call.
2011-09-26 20:29:32 +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