Commit Graph

122 Commits

Author SHA1 Message Date
Christoph Oelckers c9dad70408 - removed the GetConstantInt overloads since it appears they are not needed. 2016-11-03 16:46:55 +01:00
Christoph Oelckers 995f01f8aa - removed obsolete code from a_bossbrain.cpp.
- fixed: divisions wasted one register for each operation due to a double allocation.
- changed math operations to use less registers. There was a well-intended change to allocate the destination first, but the better approach is to first allocate the operands and free then before allocating the destination register.
2016-11-03 14:23:29 +01:00
Christoph Oelckers a45523fb63 - scriptified A_SpawnFly.
- added support for global variables to the code generator - not the compiler, though. For the handful of entries this is needed for it may just as well be done manually. So far FLevelLocals level is the only one being exported.
- fixed: The VM disassembler truncated 64 bit pointers to 15 digits because the output buffer was too small.
- resolve entire FxSequences instead of aborting on the first failed entry. This allows to output all errors at once.
2016-11-03 13:38:40 +01:00
Christoph Oelckers 6aecb29995 - fixed: The VM function builder was set up with the wrong number of implicit arguments. 2016-11-02 16:05:57 +01:00
Christoph Oelckers ff66dc3189 - flatten FxBinaryLogical chains into a single node for more efficient processing. 2016-11-02 15:46:15 +01:00
Christoph Oelckers 570572fcf2 - scriptified a_hereticimp.cpp.
- fixed the comparison against 0 simplification which did not negate the result for '=='.
2016-11-02 11:44:48 +01:00
Christoph Oelckers 703aaa373e SHA-1: 8852bc7278d033bbed66c51bf23aee841ee977a9
* Revert "Modify CMPJMP to produce more compact code (as far as VC++ is concerned, anyway)"

This reverts commit 6ff973a06b.

This modification did not work and broke the comparisons. Actually this had three problems:

* the asserts checked the wrong instruction
* the mask was not applied to regular comparisons.
* incrementing PC before testing does not work because 'test' references the PC.
2016-11-02 11:40:43 +01:00
Christoph Oelckers 88fd47247d - scriptified several trivial functions from a_action.cpp. 2016-11-01 16:32:47 +01:00
Edoardo Prezioso 7137e87b4b - Fixed GCC/Clang errors from recent commits. 2016-11-01 10:35:45 +01:00
Christoph Oelckers e620c9bd7d - scriptified parts of a_bossbrain.cpp. Some things cannot be done yet, the script code is there but commented out.
- exported thinker iterator and drop item chain to scripting. Unlike its native counterpart the script-side iterator is wrapped into a DObject to allow proper handling for memory management.
- fixed: The VMFunctionBuilder only distinguished between member and action functions but failed on static ones.
- fixed: FxAssign did not add all needed type casts. Except for purely numeric types it will now wrap the expression in an FxTypeCast. Numeric handling remains unchanged for both performance reasons and not altering semantics for DECORATE.
- exported all internal flags as variables to scripting. They still cannot be used in an actor definition.
- make ATAG_STATE the same as ATAG_GENERIC. Since state pointers exist as actual variables they can take both values which on occasion can trigger some asserts.
- gave PClass a bExported flag, so that scripts cannot see purely internal classes. Especially the types like PInt can cause problems.

Todo: we need readonly references to safely expose the actor defaults. Right now some badly behaving code could overwrite them.
2016-10-31 17:03:26 +01:00
Marisa Heit 6ff973a06b Modify CMPJMP to produce more compact code (as far as VC++ is concerned, anyway) 2016-10-30 22:16:02 -05:00
Christoph Oelckers 2857fac338 - scriptified a_archvile.cpp.
- fixed the type checks for the conditional operator.
2016-10-30 18:41:39 +01:00
Christoph Oelckers a652c5f259 - fixed: For named functions the prototype needs to be set before the code generator starts resolving. Otherwise it will crash on incompletely set up forward declarations. 2016-10-30 16:21:44 +01:00
Christoph Oelckers f8ccda2dc8 - scriptified A_Mushroom to test something a bit more complex.
- fixed: FxMinusSign trashed local variables that were used with negation.
- fixed: FxConditional only handled ints and floats, but not pointers and strings.
- fixed: A 'no states in non-actors' error was triggered, even for classes without any states.
2016-10-30 14:00:11 +01:00
Christoph Oelckers 9eeb56212b - fixed: A VM function's NumArgs value needs to count stack arguments, not logical ones, meaning that for vectors each element needs to count separately.
- renamed VMFunction::Defaults to DefaultArgs to make searching easier.
- let ZCCCompiler process vector defaults for function parameters.
2016-10-30 09:05:42 +01:00
Leonard2 06ec6318a9 Fixed: A vector value could point to garbage data after being 'unnested' 2016-10-30 07:37:13 +01:00
Leonard2 5643d6c692 Make sure to use the REGT_MULTIREG flags for opcodes that need it 2016-10-30 07:37:12 +01:00
Leonard2 8be7af41a9 Don't use a struct reference for vectors as return type just like for parameters 2016-10-30 07:36:00 +01:00
Leonard2 94410accf4 Renamed "VectorInitializer" to "VectorValue"
This was really confusing for me as this is an actual vector "value" rather than an "initializer"
2016-10-30 07:34:14 +01:00
Christoph Oelckers ac1c022911 - implemented the 'is' operator (i.e. class type check.) 2016-10-30 01:05:56 +02:00
Christoph Oelckers 78a18acf46 - added string handling to comparison operators. 2016-10-29 18:57:56 +02:00
Christoph Oelckers 853c6f6684 - fixed initialization of local variables with other local variables.
- fixed several occurenced where vectors were treated as floats. NOTE: The entire codegen.cpp file needs to be carefully reviewed for bad use of the REGT_ constants, there's probably more places where using them has broken some type checks.
- fixed: committed test version of zscript.txt instead of changed actor.txt by accident.

Initialization and assignment for strings is working with this commit.
2016-10-29 16:49:21 +02:00
Christoph Oelckers 4dc97a6ed0 - fixed register allocation for vector arguments to script functions.
- handle 2D and 3D vectors in SetReturn.
2016-10-29 13:42:37 +02:00
Christoph Oelckers 7209f9edd6 - implemented passing vectors as parameters. So far working for native functions.
- removed the bogus optional value from the first A_Jump argument. A quick test with an older ZDoom revealed that this was never working - and implementing it would make things a lot more complicated, especially error checking in the code generator.
- fixed: The check for insufficient parameters to a function call was missing.
2016-10-29 13:10:27 +02:00
Christoph Oelckers f5d1b1a491 - added vector builtins Length() and Unit().
This should complete the vector type except for use as function parameter.
2016-10-29 10:43:22 +02:00
Christoph Oelckers b5222f08e8 - implemented dot and cross products (not that I'd ever expect these to become useful in a game like Doom...) 2016-10-29 10:16:00 +02:00
Leonard2 594a0c2008 Fixed: FxVMFunctionCall didn't check for varargs while checking argument count 2016-10-29 02:18:15 +02:00
Christoph Oelckers e5878f0cb2 - implemented vector operations. Vectors are now fully working as local variables.
- removed mulv_kr and divv_kr instructions. The first are redundant and the second are useless. Maybe remove all other vector/const operations as well? They won't get used by the code generator.
- fixed disassembly of vector multiplication and division instructions.
2016-10-29 01:39:25 +02:00
Christoph Oelckers 9400f97189 - implemented local vector variables. Currently only the definition plus initial assignment works.
- removed all vector4 handling that had already been added, now that this type can no longer be defined.
2016-10-28 15:15:30 +02:00
Christoph Oelckers f511a9398e - changed GetStore/LoadMoveOp and GetRegType to be based on a set of member variables instead of using virtual functions to return such trivial values. This not only creates significantly better code but also allows overriding these settings without having to create a new class just for changing them (as is needed for vectors.) 2016-10-28 10:44:01 +02:00
Christoph Oelckers 3b1f411dce - added a full set of 2D vector instructions to the VM. The existing one was 3D only but there's also need to handle two-dimensional vectors.
- added the missing divv* instructions.
2016-10-28 10:13:07 +02:00
Christoph Oelckers 35cd48b86b - fixed grammar rule for two-dimensional vectors. 2016-10-28 09:47:22 +02:00
Christoph Oelckers 3fa315aaea - replaced 'vector<2>' and 'vector<3>' with 'vector2' and 'vector3'.
- added initializer syntax for vectors. A vector can be set with vectorvar = (x,y,z); for a 3-dimensional vector and vectorvar = (x, y); for a 2-dimensional one.
2016-10-28 01:14:21 +02:00
Christoph Oelckers 286f9510d4 - got rid of all default parameter redundancies.
- scriptified a few more functions.
2016-10-28 00:32:52 +02:00
Christoph Oelckers 03efb63e93 - fixed bad register use in postincrement operator. 2016-10-27 19:14:16 +02:00
Christoph Oelckers c7347608a4 - scriptified A_FatAttack*.
- swapped parameters of two-parameter VelToAngle method, so that internal and script version are in line.
- fixed parameter asserts to handle NULL pointers properly.
2016-10-27 17:47:46 +02:00
Christoph Oelckers 948ef62fcd - use the function defaults from the script instead of explicitly setting them again in the code. This is a needless cause of potential errors and since the values are readily available now it's better to use them in the functions.
- fixed: ZCCCompiler did not process array access nodes.
- fixed: Function argument names were not placed in the destination list by the compiler.
- scriptified several trivial functions from p_actionfunctions.cpp.
2016-10-27 15:53:53 +02:00
Christoph Oelckers 66b1f36e56 - actually evaluate the default parameters and store them in the VMFunction.
- disabled the assert in PType::GetRegType. This assert blocks any use to check for types that are incompatible with function parameters.
- pass the default parameter constants to the native functions. At the moment this is not used yet.
- use the function defaults to complete argument lists to script functions.
- fixed all default values that got flagged by the expression evaluator as non-constant. Most were state labels and colors which were defaulted to "". The proper value is null for states and 0 for colors.
- also replaced all "" defaults for names with "none".
2016-10-27 01:30:34 +02:00
Christoph Oelckers d32d52c0b9 - scriptified a_spidermaster.cpp.
- fixed bad assert in XOR_RK instruction.
2016-10-26 17:21:25 +02:00
Christoph Oelckers a166183ab4 -fixed type handling for varargs (i.e. A_Jump.) 2016-10-26 14:15:11 +02:00
Christoph Oelckers 7c759f9fcf - removed the FxDamageValue hack and implemented it properly using FxReturnStatement.
- added handling of damage functions for ZScript.
2016-10-26 14:04:49 +02:00
Christoph Oelckers e50315bd31 - fixed: Deprecation messages should never appear in DECORATE.
- removed some console message spam.
2016-10-26 13:22:36 +02:00
Christoph Oelckers 823c52aeb2 - scriptified the functions in a_possessed.cpp and added the needed exports and constants.
- fixed: Script functions did not receive the function name when being created.
- relaxed the asserts for PARAM_STATE, because the VM knows nothing about ATAG_STATE. Any state variable's content (e.g. Actor.SeeState) will receive ATAG_GENERIC, rather than ATAG_STATE.
- added a 'NeedResult' flag so that certain operations can create shorter code if the result of the expression is not needed. So far only used for postdecrement/increment statements on local variables (which is the most frequent case where this matters.)
- fixed postincrement and decrement for local variables. Due to the result preservation semantics it created faulty code.
2016-10-26 11:30:30 +02:00
Christoph Oelckers 33d00070b5 - made some variables signed that should not be unsigned. 2016-10-25 17:07:19 +02:00
Edoardo Prezioso be4ce05aee - Fixed Clang compiler errors and some warnings. 2016-10-25 16:53:14 +02:00
Christoph Oelckers 142278a818 - fixed incomplete commit for bounce flags
- fixed flag clearing in new function.
2016-10-25 13:29:58 +02:00
Christoph Oelckers ae728cc61a - made the count flags and NOBLOCKMAP and NOSECTOR read-only. These require special treatment to work which can only be done by a setter function. 2016-10-25 09:55:13 +02:00
Christoph Oelckers f810b98167 - implement flag variables with the VM's sbit and lbit instructions.
- synthesize PField entries from the flag list for AActor. This intentionally excludes the bounce flags for now.
- allow deprecated flags that do not call the deprecated flag handler.
- disallow constructs like (a = b) = c by not allowing an address request on an assignment operation.
- restrict modify/assign on boolean variables to the bit operators. Everything else needs to promote the result to an integer to make sense so it should be disallowed.
2016-10-24 17:18:20 +02:00
Christoph Oelckers 808188ff18 - added handling for structs. When defined inside classes or other structs the double member access will be merged, so there is no performance hit by using structs to group data. 2016-10-24 13:18:13 +02:00
Christoph Oelckers 3f1673f34f - scriptified A_HeadAttack, A_CyberAttack and A_Hoof. 2016-10-24 00:50:28 +02:00