Commit Graph

256 Commits (a0c9bfd931e42ab6ef95e12b24be1d072cf5b3a6)

Author SHA1 Message Date
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
Günther Brammer a3fab0234e Create PropLists with one bytecode instead of one per property 2011-04-09 21:35:16 +02:00
Günther Brammer 6768614feb Silence various warnings 2011-03-28 20:58:42 +02:00
Günther Brammer 24fe22faff Remove redundant check for AB_FUNC bytecode having a function
AB_FUNC always has a function.
2011-03-28 20:57:51 +02:00
Julius Michaelis 61d93c39cf Fixed some files which didn't include C4Include properly (all except C4Globals.cpp caused by 17d0ceb9ef2f) 2011-03-14 16:32:01 +01:00
Armin Burgmeier 41a1b5867d Change .c4g extension to .ocg 2011-03-13 16:16:45 +01:00
Günther Brammer 264009060c Script: Remove Method from function descs 2011-03-03 02:25:01 +01:00
Günther Brammer 7ce65373a3 Replace C4AList with some std::lists 2011-02-26 00:48:19 +01:00
Günther Brammer 5c18c7aa33 Reduce the time a C4String pointer sits in an integer variable 2011-02-22 00:07:08 +01:00
Günther Brammer 0bad4b7f59 Script: Parse negative numbers in nested constant expressions
Previously, local foo = [-1]; would complain about an unexpected '-'
operator.
2011-02-19 22:37:42 +01:00
Günther Brammer b9cf00d824 Script: obj->~foo() cannot have whitespace between -> and ~ anymore
This slightly simplifies the parser, as ->~ is now one token and ~ does not
double as binary not and call failsafety indicator.
2011-02-19 22:18:27 +01:00
Günther Brammer 16511790a9 Script: Do not disguise '.' and '=' as unrecognized tokens 2011-02-25 18:12:36 +01:00
Günther Brammer c667de49b5 Script: Crash when parsing a function call with more than ten parameters 2011-02-12 20:24:52 +01:00
Günther Brammer 7be90977bf Make C4ScriptHost have a C4ComponentHost member instead of inheriting
Previously, C4ScriptHost needlessly derived from two classes.
2011-02-06 21:37:19 +01:00
Günther Brammer cde66b249f C4Include.h: Do not include C4Gui.h
The two dialogs in headers included in C4Game.h are only used by classes in
those headers, and do not need to be defined in the headers.
2011-01-24 01:15:58 +01:00
Günther Brammer e939795a93 Script: Optionally warn about empty array expression entries 2011-02-02 22:07:46 +01:00
Günther Brammer 73d1d35800 Script: Optionally warn about empty function call parameters 2011-02-02 22:06:53 +01:00
Günther Brammer 5d3eff754b Script: Empty function parameters default to nil instead of 0 2011-02-02 21:45:46 +01:00
Günther Brammer ec7e35a25a Script: Optional warnings about deprecated functions and 0->nil conversion 2011-01-16 21:26:18 +01:00
Günther Brammer 846e707134 objects: Remove OCF_Living in favor of OCF_Alive 2011-01-02 19:40:48 +01:00
Günther Brammer be342d4a51 copyright notices update 2010
This time with more manual checking and using git blame -M -C, so that
a few cases of copied code get a copyright notice corresponding to
their initial introduction.
2010-12-23 01:01:24 +01:00
Günther Brammer 6025602038 Script: Correctly backtrace exceptions
Global functions conspire with appendto/include to make this all horribly
fragile.
2010-12-22 04:26:37 +01:00
Günther Brammer 40c24961dd Correctly map bytecode to linenumber for global/appended/included functions
The method to get the C4AulScript instance that stores the bytecode of a
function is ridiculous, but at least it's now capsuled in a function. While
at it, this also always stores the bytecode index instead of a bytecode
pointer in the function.
2010-12-22 02:10:58 +01:00
Günther Brammer b562acb32c Script: Remove EffectVar, update effect documentation 2010-12-21 21:57:40 +01:00
Nicolas Hake dbb75f98cb win64: Fix crash when a C4String gets allocated at >4GB 2010-12-16 17:26:52 +01:00
Günther Brammer 26c670b29d Improve internal C4PropList interface for predefined property names
SetProperty now also has a wrapper, and the common case of
GetPropertyVal(P_Foo) is now GetProperty(P_Foo).
2010-12-06 16:19:15 +01:00
Sven Eberhardt 7e971d7405 fix error when accessing &Code[0] on empty code during script parsing
caused by 4d1af7ffee78, when code was changed from a C style array into a std::vector
2010-12-07 19:27:59 +01:00
Günther Brammer d02c424dab Script: Split SPos out of the bytecode into an extra vector for speed
SPos is only needed to display debug messages. Not having that data in the
cache for normal execution speeds up script execution by ten percent on at
least one artificial benchmark.
2010-10-25 23:48:08 +02:00
Günther Brammer 4a256d1953 Script: Every identifier is allowed after a dot
Previously, the tokenizer would emit special tokens for a few keywords. Now
every keyword is handled by the parser. This allows one to use keywords as
identifiers everywhere it is unambiguous.
2010-10-20 00:37:31 +02:00
Armin Burgmeier 479362b87c Fix a crash bug on 64 bit 2010-09-22 02:14:16 +02:00
Günther Brammer 64f424cc51 Script: Add | operator to constants
This is the only operator that is necessary for the ActMaps. Ideally, every
operator would work, but I don't know how to achieve that without massive
code duplication. So just duplicate a little to make it work.
2010-09-09 22:41:41 +02:00
Günther Brammer b55c88d486 Script: Add initialization to local named variables (properties) 2010-09-09 22:36:00 +02:00
Günther Brammer ef76b26c4a Script: Save readonly proplists inline so that they do not need a number 2010-09-08 20:09:27 +02:00
Günther Brammer bf9137149c Script: Initial proplists are readonly at runtime
That way, recreating them from game data during savegame load won't
suddenly revert changes, because there aren't any changes.
2010-09-08 14:54:39 +02:00
Günther Brammer 984c3430ac Script: constants can contain proplists and arrays
Only supporting the literal syntax for them, with the same
constraints for the contents as for toplevel constants.
2010-09-09 02:18:19 +02:00
Günther Brammer e342dc9b35 Script: Remove last, already dead, traces of C4ID constants 2010-08-19 19:05:48 +02:00
Günther Brammer b34efab246 Script: Add foo.bar syntactic sugar for foo["bar"] 2010-08-15 01:53:18 +02:00
Günther Brammer 713531bb91 Script: Remove obsolete '&' token (always an operator now) 2010-08-14 23:02:07 +02:00
Peter Wortmann 9c9a898911 Fixed a few scripts to work without references, to the best of my knowledge. 2010-08-03 22:33:03 +01:00
Peter Wortmann 24cfd14f1c Support for setting array slices 2010-08-03 21:47:45 +01:00
Peter Wortmann cf4e83c151 Merge with default, including some small Script cleanups 2010-08-01 16:23:36 +01:00
Günther Brammer 696520dfb4 Script: Avoid conversion warning false positives (#246) 2010-07-31 19:29:31 +02:00
Günther Brammer 06c62b31bd Script: Only warn about missing functions in the Parser
Non-failsafe calls will abort at runtime, but they might
only be used in a never taken branch, so unconditionally
aborting the function is wrong.
2010-06-27 02:03:23 +02:00
Armin Burgmeier 9f65838ae8 Fix a couple of compiler warnings 2010-04-28 23:43:25 +02:00
Peter Wortmann edb4a4a0b2 Completely removed references from the engine, changed array semantics to not copy automatically, implemented postfix ++/-- correctly 2010-04-08 02:47:45 +02:00
Peter Wortmann efb5925129 Modified parser to use setter bytecode in place of references.
Currently kills:
* a[...] = ... -> Currently a copy is changed and then discarded, need to rework array semantics.
* bla->EffectVar(...) = ... -> Normal EffectVar is rewritten to SetEffectVar - but this won't work for calls. We need a better solution anyway.
* All scripts that use references, obviously. Just have a look at the parser warnings.
2010-04-07 15:04:19 +02:00
Benjamin Herr adc278dc57 Add array slicing syntax ary[begin:end]
... which evaluates to a copy of the elements with indices in the range
[begin,end), where either index might be omitted, defaulting to 0 or the
length of the string respectively
2010-04-05 17:41:36 +02:00
Armin Burgmeier c2924041c9 Fix seperate->separate everywhere 2010-04-01 23:08:06 +02:00
Benjamin Herr 4378de147c Rerun astyle with missing \ added 2010-03-28 20:58:01 +02:00
Günther Brammer 5a44edb613 Store objectlocal named variables as properties
One still has to declare them in before usage, but LocalN can create new
variables now.
2010-03-27 18:52:32 +01:00
Günther Brammer 99040a3dd1 Script: Remove ne, eq and S= 2010-03-22 22:26:41 +01:00
Günther Brammer 1446f585d7 Rename C4V_pC4Value to C4V_Ref 2010-03-22 22:16:46 +01:00
Günther Brammer 8c13465ef3 Script: += and friends result in integers, and check for them
Before, var a = nil; a+=25; would result in any/25, violating a constraint.
The operators also didn't check that the input was an integer.

/= and / now raise an exception on division-by-zero.
2010-03-18 23:59:50 +01:00
Armin Burgmeier 7b7414a8bb C4AulParseState: Fix usage of unintialized variable
ClearToken checks TokenType which might not be initialized yet
2010-03-18 20:15:13 +01:00
Armin Burgmeier 7d17cb28e6 Fix a few compiler warnings 2010-03-16 12:39:58 +01:00
Günther Brammer 8753019c77 Script: Remove last remains of obj->C4ID::Foo()
They didn't do anything anyway anymore besides using a TODO marker.
2010-03-06 20:51:14 +01:00
Günther Brammer 3e6153098b Script: Warn about type conversions that are going to fail
At the moment, only function parameters are checked, and only immediate
type errors are catched - if there's a variable in between, the parser
won't see it. Still useful to catch some errors before running the
code.
2010-03-06 20:49:29 +01:00
Günther Brammer e09b3b02b3 Scriptparser: Fix crash on C4ID starting with a number
The C4ID syntax removal was not thorough enough: The tokenizer did
nothing in the C4ID state anymore except traversing the string, but not all
instances of reaching that state were removed. As a result, the tokenizer
read past the script end.
2010-03-05 00:26:29 +01:00
Günther Brammer e3292ad0f5 Remove obsolete code introduced by the debugger merge 2010-03-05 22:25:37 +01:00
Martin Plicht 4902679b56 DirectExec and C4ControlScript support executing script expressions that access variables and parameters of the parent context (used for watch expressions while debugging) 2010-04-26 22:16:45 +02:00
Sven Eberhardt 6158aec581 Removed internal score counting by player wealth/owned objects
Unified and renamed all Points/Value/Score functions/field names into Score
Some MSVC warning fixes
2010-04-21 21:12:49 +02:00
Armin Burgmeier 70ac17c040 Mingw64 build fixes 2010-04-18 22:02:01 +02:00
Günther Brammer b81931a419 Miscellanous FIXME removals 2010-02-23 21:49:57 +01:00
Martin Plicht cf382f34ce Merge, resolving C4NetIO conflict 2010-02-03 03:39:21 +01:00
Sven Eberhardt dfbcfb29e3 fix script string table leak 2010-01-30 17:51:26 +01:00
Benjamin Herr f3b35227ea avoid lots of gcc warnings 2010-01-25 05:00:59 +01:00
Nicolas Hake ed6f9424d7 Allow IDs longer than 4 characters
All C4IDs are now stored in auto-created global constants with the same name
as the ID itself. There is no special parsing of IDs anymore; this means that
you need to use the C4Id function if you aren't sure whether an ID exists.

IDs in portrait strings aren't working, since I expect portrait support to be
removed from the engine.
2010-01-25 16:57:57 +01:00
Nicolas Hake a41f896921 Replace global C4ID consts with member consts 2010-01-25 04:14:52 +01:00
Martin Plicht 6333f0e6ba Add a NULL check in C4AulScriptContext::ReturnDump and restore put AB_DEBUG chunk before AB_RETURN 2010-01-13 18:42:15 +01:00
Martin Plicht f1b615e7ec Merge default into debug 2010-01-13 18:07:58 +01:00
mizipzor a53dae0c1b Fixed compilation in MSVC2010 2009-11-25 19:38:54 +01:00
Nicolas Hake 8736ab11bc Script: Allow \n, \x??, \??? escapes 2009-10-21 04:34:15 +02:00
Nicolas Hake 86e52a9295 #24: C4Script: Allow strings of arbitrary length 2009-10-21 03:41:55 +02:00
Nicolas Hake 52bde5a579 Remove BIG_C4INCLUDE define 2009-10-20 06:21:12 +02:00
Günther Brammer e25ae9ef9f C4Script: add do-while-loop
A very old feature request.
2009-08-28 04:44:53 +02:00
Günther Brammer 6c61db0fab Recognize global constants even if they begin a statement
Feuermonster reported that

static const foo = 0;
func bar() { foo = 5; }

resulted in a confusing error message.
2009-08-26 16:59:00 +02:00
Günther Brammer 9a8b5dd739 Replace BOOL by bool, TRUE by true, FALSE by false 2009-08-15 20:50:32 +02:00
Günther Brammer 572d00c32e Move all source files
This might make stuff easier to find.
2009-08-10 17:59:18 +02:00