Commit graph

8096 commits

Author SHA1 Message Date
Christoph Oelckers
8f722a3633 - fixed: FxCVar must free its address register. 2016-11-20 23:26:32 +01:00
Christoph Oelckers
e93961da96 - removed all constant versions of vector instructions. The vector code does not use compound constants so there's no need to have instructions for them.
- fixed: The code generator had no good safeguards for exceeding the maximum amount of registers.

All there was was a handful of pitiful asserts which in production code do nothing at all but generate broken output.
Even worse, the VM was hardwired to at most 255 constants per type per function by storing the constant count in a byte! This has been extended to 65535, but since many instructions only have a byte available for the constant index, a workaround had to be added to do a two-instruction setup if larger indices are needed.
2016-11-20 23:00:05 +01:00
Christoph Oelckers
1c2c26eb08 - implemented direct CVar access. 2016-11-20 20:24:39 +01:00
Christoph Oelckers
159f09105e - used static constant arrays to shorten some code. 2016-11-20 18:34:27 +01:00
Christoph Oelckers
5951a9449c - added static constant arrays. At the moment they can only be defined inside functions due to lack of dedicated storage inside classes for static data.
- added new VM instructions to access the constant tables with a variable index.
- refactored VMFunctionBuilder's constant tables so that they are not limited to one entry per value. While this works fine for single values, it makes it impossible to store constant arrays in here.
2016-11-20 18:00:37 +01:00
Christoph Oelckers
bb25c5faaa - scriptified the remaining Doom weapon code.
- implemented method calls from struct instances.
- optimized disassembly of VM call instructions to print the function's name at the end where it is more visible and does not need to be truncated. Also use the printable name for script functions here.
2016-11-20 12:27:26 +01:00
Christoph Oelckers
ab6b2f369e - fixed: For varargs, not only the type but also the flag of the last specified argument need to be stored for later parameters. 2016-11-20 09:47:46 +01:00
Christoph Oelckers
3c726aa570 - scriptified A_FirePlasma. 2016-11-20 01:18:21 +01:00
Christoph Oelckers
fdab994fcb - scriptified the Rocket launcher. 2016-11-20 01:11:01 +01:00
Christoph Oelckers
814493b68d - scriptified the Super Shotgun. 2016-11-20 00:45:06 +01:00
Christoph Oelckers
af34d82888 - scriptified A_Saw.
- implemented multiple-return-value assignment. Due to some grammar conflicts the originally intended Lua-inspired syntax of 'a, b = Function()' could not be done, so it's '[a, b] = Function()'
2016-11-20 00:25:38 +01:00
Christoph Oelckers
74c5659fc5 - explicitly call Destroy in PClass::StaticShutdown because some class type objects were no longer automatically collected. 2016-11-19 18:09:34 +01:00
Christoph Oelckers
7595343aaa - fixed: Completely empty if statements left the code generator in a broken state. 2016-11-19 18:02:07 +01:00
Christoph Oelckers
0b70df88d8 - scriptified A_FireShotgun and A_FireChaingun. 2016-11-19 16:39:45 +01:00
Christoph Oelckers
d50da34664 - scriptified the pistol to test if struct member functions work.
- made APlayerPawn::PlayAttacking(2) virtual script functions so that mods have better control over player animations. Note that these have no native base so they skip the templated interface for managing virtual functions.
2016-11-19 13:56:29 +01:00
Christoph Oelckers
de8cacc465 - for struct member calls an address request is needed. 2016-11-19 12:41:00 +01:00
Christoph Oelckers
25e285b65d - fixed bad conversion from FString to const char * in state label type cast. 2016-11-19 12:25:53 +01:00
Christoph Oelckers
9fab8380ff - fixed: FxVMFunctionCall::GetDirectFunction did not check if the function could be called with no arguments. 2016-11-19 12:22:58 +01:00
Christoph Oelckers
f11f020b6c - allow functions in structs. This is needed for several internal data types like players, sectors, lines, etc.
- added a new type 'NativeStruct'. This will be used for types that cannot be instantiated, and is also needed to cleanly handle many internal types that only can exist as reference.
2016-11-19 12:12:29 +01:00
Christoph Oelckers
df4e9324c9 - added terminators to all flag lists. 2016-11-19 09:24:54 +01:00
Christoph Oelckers
10bc01c000 - fixed yet another place where VS did not warn about improper use of NULL. 2016-11-19 09:10:31 +01:00
Christoph Oelckers
3ce699bf9b - implemented pass-by-reference arguments - so far only for memory based variables.
- changed Dehacked weapon function lookup to check the symbol table instead of directly referencing the VM functions. Once scriptified these pointers will no longer be available.
- removed all special ATAGs from the VM. While well intentioned any pointer tagged with them is basically unusable because it'd trigger asserts all over the place.
- scriptified A_Punch for testing pass-by-reference parameters and stack variables.
2016-11-19 01:23:56 +01:00
Christoph Oelckers
7ff5069617 - added all missing things to enable the scriptified version of A_BrainSpit.
This uses a global function, this has been placed into DObject for now because the scripting interface does not allow non-class-owned functions yet.
2016-11-18 22:12:53 +01:00
Christoph Oelckers
aa32d8970b - scriptified a_hereticmisc.cpp. 2016-11-18 21:34:06 +01:00
Christoph Oelckers
34c949f84b - implemented the string concatenation operator '..'. This is capable of stringifying all of the common types for output.
- gave OP_CONCAT some sane semantics. The way this was defined, by specifying the source operands as a range of registers instead of a pair like everything else made it completely useless for the task at hand.
- changed formatting for floats to %.5f which for normal output in a game makes more sense. For special cases there should be a special formatting function for ints and floats that can do more specialized conversions.
2016-11-18 17:44:25 +01:00
Christoph Oelckers
24481781b4 - added missing unsigned casts to the VM.
- make the pointer to string cast a bit more useful by using the actual object's type rather than 'Object' which can be a great asset when debugging.
- fixed a few bad asserts.
2016-11-18 14:50:21 +01:00
Christoph Oelckers
f71aad4cdd - cleanup of the remaining FxBinary operators.
- changed FxCompareEq with strings and other types that can be cast to from a string always convert the string to the other type before comparing.
2016-11-18 14:19:55 +01:00
Christoph Oelckers
d9953eb3bd - cleaned up FxCompareRel::Resolve. Also added unsigned integer support to it and FxMulDiv (these, aside from the float cast, are the only two operations where this is important.) 2016-11-18 12:23:58 +01:00
Christoph Oelckers
b6801d526b - same as last commit for FxMulDiv and FxPow.
- some streamlining of FxAddSub.
2016-11-18 11:53:18 +01:00
Christoph Oelckers
a00181c899 - started refactoring binary operators by starting to movw the relevant parts or ResolveLR into the respective Resolve methods. FxAddSub complete.
This one-size-fits all function has become too unwieldy with all its special cases and makes improvements harder than necessary.
2016-11-18 11:28:15 +01:00
Christoph Oelckers
8650d6806e - script export of player_t.
- replaced __alignof with the standard alignof equivalent.
2016-11-18 00:42:04 +01:00
Christoph Oelckers
6461f5995b - fixed: Script defined pointers were not added to the FlatPointers array. 2016-11-17 22:21:08 +01:00
Christoph Oelckers
e4dfb13d25 - fixed: OP_LO was missing a read barrier. 2016-11-17 20:41:59 +01:00
Christoph Oelckers
3bcd85eb8a added class pointer casts. Due to grammar problems the type has to be put into parentheses to get the class token out of the global parsing namespace:
class<Actor> myclass = (class<Actor>)(GetClass());
2016-11-17 20:31:53 +01:00
Christoph Oelckers
022228d8a9 - fixed code generation of class type cast for local variables. 2016-11-17 19:30:30 +01:00
Christoph Oelckers
8205e6cf08 - optimize access to array members with constant index. Like with struct members this can be combined with the outer index/address.
- fixed register allocation with array indices and stack variables.
2016-11-17 18:06:56 +01:00
Christoph Oelckers
2cc48ec378 - implemented code generation for stack variables.
- fixed code generation for using local variables as array index. This must use a different register for the array element offset because the original register may not be overwritten.
2016-11-17 16:44:41 +01:00
Christoph Oelckers
d86f03e2e0 - reverted most of the last commit after realizing that trying to manage constructing/destructing per variable is not going to work because it'd require some extensive exception management in the compiled VM code.
- instead add a list of SpecialInits to VMScriptFunction so this can be done transparently when setting up and popping the stack frame. The only drawback is that this requires permanent allocation of stack objects for the entire lifetime of a function but this is a relatively small tradeoff for significantly reduced maintenance work throughout.
- removed most #include "vm.h", because nearly all files already pull this in through dobject.h.
2016-11-17 13:10:19 +01:00
Christoph Oelckers
30e6e8e25f - added bookkeeping info to types for allowing data on the stack that requires construction and destruction.
- removed unused PVector type.
2016-11-17 11:16:00 +01:00
Christoph Oelckers
21a1d5ffc8 - scriptified Hexen's Wraith and parts of the Spike. 2016-11-17 00:44:43 +01:00
Christoph Oelckers
df43ee96ce - fixed a lost '='.
- scriptified A_TimeBomb.
2016-11-16 21:12:16 +01:00
Christoph Oelckers
7a29e6cfdc - scriptified Hexen's fog. 2016-11-16 20:00:25 +01:00
Christoph Oelckers
063e94971d - removed incorrect _DEF. 2016-11-16 19:47:07 +01:00
Major Cooke
af3bda3f2a Removed _DEF. 2016-11-16 19:47:06 +01:00
Major Cooke
60d93008ba Exported TryMove. 2016-11-16 19:47:06 +01:00
Christoph Oelckers
76a74e0364 - scriptified Hexen's Dragon.
- fixed several places in the code generator that did not consider locked registers for local variables: array indices, abs and floating point builtin functions.
- added some debug aids to the bounds opcode. Just triggering an exception here which loses all relevant info is perfectly useless in a debug situation.
2016-11-16 19:18:21 +01:00
Christoph Oelckers
633da6e5d8 - scriptified two of the Acolyte's functions.
- added a DActorIterator class.
- fixed: It was not possible to have functions of the same name in two different classes because the name they were searched for was not qualified by the class. Changed so that the class name is included now, but to avoid renaming several hundreds of functions all at once, if the search fails, it will repeat with 'Actor' as class name.

This commit contains preparations for scriptifying Hexen's Dragon, but that doesn't work yet so it's not included.
2016-11-16 01:36:21 +01:00
Christoph Oelckers
a2e17c0ab5 - implemented usage restrictions for action functions. 2016-11-15 21:38:12 +01:00
Christoph Oelckers
1d006b37c3 - fixed: The distance check in CheckIfCloser used the wrong variable. 2016-11-15 17:41:49 +01:00
Christoph Oelckers
4cc7d95ba5 - fixed: A_ZoomFactor and A_SetCrosshair need to be declared 'action'. 2016-11-15 16:05:42 +01:00