Commit graph

254 commits

Author SHA1 Message Date
Christoph Oelckers
96631e8808 - make PClass not inherit from PStruct.
Having these two types related can cause problems with detection in the compiler because for some parts they need quite different handling.
Common handling for the fields has been moved into PSymbolTable but overall redundancy was quite minor as both types share surprisingly little functionality.
2017-04-12 17:21:13 +02:00
Christoph Oelckers
0d7b7d6ab1 - merged PStruct and PNativeStruct.
There were exactly 4 places in the code that checked for the difference, this is better done with a flag.
2017-04-12 15:12:41 +02:00
Christoph Oelckers
63eb3e331e - un-const-ify some functions. 2017-04-12 14:40:29 +02:00
Christoph Oelckers
abc4481431 - set PointedType to null for PClassPointer to simplify the functions for this class. 2017-04-12 13:11:59 +02:00
Christoph Oelckers
6308251084 - added a FindSymbol wrapper to PClass so that other code does not need to access the symbol table directly.
- added an isActor utility function to codegen.cpp to simplify a few constructs.
2017-04-12 13:08:41 +02:00
Christoph Oelckers
bc486904cd - split PPointer into PPointer and PObjectPointer.
A pointer to an object has quite different semantics so let's do this with proper virtual inheritance. This should allow to simplify a lot of pointer related checks in the compiler.
2017-04-12 10:52:54 +02:00
Christoph Oelckers
9c9b2ccf6d - replaced more dyn_casts and checks for RUNTIME_CLASS(PClassActor)
It is preferable to use IsDescendantOf wherever possible if we ever want to be able to separate PClass from PType.
2017-04-12 10:20:58 +02:00
Christoph Oelckers
5350721ec5 - removed PClass::DeriveData because it is no longer needed.
- fixed: IsVisibleToPlayer and optimized it a bit more.
- moved SourceLumpName to PClass, so that it can also be used for non-actors (there's a lot of non-Actor classes already.)
- separated the serializer for PClassPointer from PPointer. Even though not doable, a pointer to a class type is something entirely different than a class pointer with a restriction so each should handle its own case.
2017-04-12 09:55:27 +02:00
Christoph Oelckers
05240ccbe5 - fixed redundant reallocation of constructable meta fields.
- some optimization of access to OwnedStates in old DECORATE.
- consolidate all places that print a state name into a subfunction.
- allocate states from the ClassDataAllocator memory arena. States do not need to be freed separately from the rest of the static class data.
2017-04-11 21:48:41 +02:00
alexey.lysiuk
4c1e03ebff Fixed alignment issue with GCC/Clang i386 build 2017-04-10 22:20:34 +03:00
Christoph Oelckers
04c2565d7f - added Get/SetValue functions to PBool. 2017-03-22 15:44:54 +01:00
Christoph Oelckers
5fd86cf98c - added some syntactic help to the ZScript parser to allow defining the arrays with native structs on the script side instead of having to define them internally. 2017-03-13 12:51:09 +01:00
Christoph Oelckers
d2beacfc5f - except for DWORD, all homegrown integer types are gone - a handful were left where they represent genuine Windows types. 2017-03-09 19:54:41 +01:00
Christoph Oelckers
878e6015df - made all iterator classes natively abstract so that they do not get a ConstructNative method so that OP_NEW can refuse creating them without the need to mark them as abstract.
- block creation of actors with the 'new' instruction. Unlike the above these cannot be made abstract because without ConstructNative they cannot be serialized.
2017-03-09 17:21:37 +01:00
Christoph Oelckers
ba0f5a3f94 - most WORD and SWORD are gone. 2017-03-08 18:55:55 +01:00
Christoph Oelckers
8ab562ef13 - the fourth. 2017-03-08 18:55:54 +01:00
Christoph Oelckers
6c6bab73ad - more of the same. 2017-03-08 18:55:53 +01:00
Christoph Oelckers
8a5daf211c - added version check for member variables. 2017-03-05 20:41:41 +01:00
Christoph Oelckers
456ac64723 - implemented version checks for compile-time type determination and for class inheritance.
Note that in this system, DECORATE counts as version 2.0, so any data that should be available to DECORATE should not use version restriction.
2017-03-05 17:58:55 +01:00
Christoph Oelckers
fd20e1d78f - allow hooking custom serializers into PPointer so that serializable types can be handled without having to create new type classes which would be a bit unwieldy thanks to how the type system works. 2017-03-03 20:11:13 +01:00
Christoph Oelckers
217bcb847d - fixed: When the savegame code errors out, some cleanup is required in G_DoSaveGame. 2017-03-03 19:19:19 +01:00
Christoph Oelckers
9b2f31e692 - had to add a hack because some people had to exploit implementation-dependent behavior of the PulseLight type. 2017-03-01 20:54:37 +01:00
Christoph Oelckers
b5d4a59465 - fixed: Meta properties must not be serialized. 2017-03-01 20:10:24 +01:00
Christoph Oelckers
5f6da0d222 fixed double allocation of metadata. 2017-02-28 14:44:18 +01:00
Christoph Oelckers
1311f08f47 - scriptified Actor.GetBloodType as a virtual function to allow mods more flexibility here.
- made CameraHeight a modifiable actor property - it was readonly before.
- allow accessing the type constants from ZScript, this required quite a bit of explicit coding because the type system has no capabilities to search for basic types by name.
2017-02-28 12:11:25 +01:00
Christoph Oelckers
78a66e001a - properly handle all meta properties for inventory items. 2017-02-28 00:45:16 +01:00
Christoph Oelckers
f343d36ea9 - implemented the basics of a working metadata system.
This will store class meta properties in a separate memory block so that it won't have to muck around with PClass - which made the implementation from the scripting branch relatively useless because extending the data wasn't particularly easy and also not well implemented. This can now be handled just like the defaults.
2017-02-27 23:28:19 +01:00
Christoph Oelckers
65c4653f59 - restored some code in PClass::CreateDerivedClass that accidentally got removed. 2017-02-23 19:03:31 +01:00
Thomas Hume
17f04c5043 Correct two overflows in PInt ctor 2017-02-23 10:10:58 +01:00
Christoph Oelckers
d8ebbcfc08 - fixed: When loading a savegame the player class in the userinfo needs to be updated.
- fixed: Class pointers should not be added to the list of garbage collected pointers.
- fixed several warnings in the event code.
2017-02-15 11:55:08 +01:00
Christoph Oelckers
7877bcbdcb - exported more parts of the joystick menus and also exported all strings for them to the string table.
- exported the skeleton definition for list menus.
2017-02-13 17:45:03 +01:00
Christoph Oelckers
bb6def820f - everything compiles and mostly works again. 2017-02-12 14:04:48 +01:00
Christoph Oelckers
947b625c50 - all menu items scriptified, but not yet active. 2017-02-11 16:11:48 +01:00
Christoph Oelckers
ccecfeb45c - to avoid problems with the final garbage collection, the players' PendingWeapon needs to be cleared manually.
This is because it can point to a non-standard value which the garbage collector cannot deal with during engine shutdown.
2017-02-09 01:34:07 +01:00
Christoph Oelckers
36a07b8e6e - remove all type table entries from garbage collection.
Like the symbols and the VM functions this is data that is static from startup until shutdown and has no need to be subjected to garbage collection. All things combined this reduces the amount of GC-sensitive objects at startup from 9600 to 600.
2017-02-08 22:43:20 +01:00
Christoph Oelckers
8277299135 - Turned DropItem into a plain struct again like it was before the scripting branch got merged.
Making this an object had little to no advantage, except being able to remove the deleter code. Now, with some of the class data already being allocated in a memory arena so that freeing it is easier, this can also be used for the drop item lists which makes it unnecessary to subject them to the GC. This also merges the memory arenas for VM functions and flat pointers because both get deleted at the same time so they can share the same one.
2017-02-08 20:37:22 +01:00
Christoph Oelckers
9499c22dfe - restored ZDoom 2.8.1's version of FindClassTentative which just modified the existing class instead of replacing it and having to run a costly and volatile PointerSubstitution call to replace all pointers to the old one. 2017-02-08 19:52:33 +01:00
Christoph Oelckers
17a2666bd4 - moved DisplayName, the last remaining PlayerPawn meta property, to PClassActor so that PClassPlayerPawn could be removed.
Now all actors have the same metaclass and therefore it will always be the same size which will finally allow some needed changes to the type system which couldn't be done because it was occasionally necessary to replace tentatively created classes due to size mismatches.
2017-02-08 19:42:24 +01:00
Christoph Oelckers
c77f6636f8 - moved the three remaining variables from PClassInventory to PClassActor so that PClassInventory can be removed. 2017-02-08 18:11:23 +01:00
Christoph Oelckers
31223ca180 - remove all symbols that get linked into the symbol table from the garbage collector.
Symbols are very easy to manage once they are in a symbol table and there's lots of them so this reduces the amount of work the GC needs to do quite considerably.
After cleaning out compile-time-only symbols there will still be more than 2000 left, one for each function and one for each member variable of a class or struct.
This means more than 2000 object that won't need to tracked constantly by the garbage collector.

Note that loose fields which do occur during code generation will be GC'd just as before.
2017-02-08 14:34:39 +01:00
Christoph Oelckers
f1b3d60b2f - PSymbol does not need to inherit from PTypeBase. This also means that there are no remaining references to any symbol object outside of the symbol tables. 2017-02-08 13:37:13 +01:00
Christoph Oelckers
18c532c307 - moved the compiler symbols into their own file.
- removed all pointer declarations to types from the symbols. All types must be placed into the type table which means that they can be considered static.
2017-02-08 13:17:25 +01:00
Christoph Oelckers
5a81a4ca16 - moved a few things around to have them into better fitting places. 2017-02-08 12:24:08 +01:00
Christoph Oelckers
3cbd62479b - took VMFunction out of the DObject hierarchy.
As it stood, just compiling the internal ZScript code created more than 9000 DObjects, none of which really need to be subjected to garbage collection, aside from allowing lazy deallocation.
This puts an incredible drag on the garbage collector which often needs several minutes to finish processing before actual deletion can start.

The VM functions with roughly 1800 of these objects were by far the easiest to refactor so they are now. They also use a memory arena now which significantly reduces their memory footprint.
2017-02-08 11:13:41 +01:00
Christoph Oelckers
3cddcc8524 - removed PClassType and PClassClass.
All non-actors now use PClass exclusively as their type descriptor.
Getting rid of these two classes already removes a lot of obtuse code from the type system, but there's still three more classes to go before a major cleanup can be undertaken.
2017-02-07 20:45:56 +01:00
Christoph Oelckers
e3d07bddab - moved the TypeTableType pointer from PClassType to PType.
Removing this variable is needed to remove PClassType and PClassClass as the next step to eliminate all of PClass's subclasses in order to clean up the type system.
2017-02-07 20:25:52 +01:00
Christoph Oelckers
7ed554158c - got rid of PClassWeapon.
Still 5 subclasses of PClass left...
2017-02-07 19:02:27 +01:00
Christoph Oelckers
56024a1ebe - implemented the backend for dynamic arrays. Still needs thorough testing but it should be complete.
- use a memory arena to store flat pointers so that the messed up cleanup can be avoided by deallocating this in bulk.
- added a new SO opcode to the VM to execute a write barrier. This is necessary for all objects that are not linked into one global table, i.e. everything except thinkers and class types.
- always use the cheaper LOS opcode for reading pointers to classes and defaults because these cannot be destroyed during normal operation.
- removed the pointless validation from String.Mid. If the values are read as unsigned the internal validation of FString::Mid will automatically ensure proper results.
2017-02-07 14:48:27 +01:00
Christoph Oelckers
ca48a687f8 - major work on dynamic array support. Mostly working, some issues still exist with Move and Copy methods and with assignments in stack variables. 2017-02-06 21:39:21 +01:00
Christoph Oelckers
b570d0819b - streamlined font handling for scripts a bit.
- moved the two 'you raised the alarm' messages for Strife to the string table
2017-02-05 13:14:22 +01:00