Commit graph

126 commits

Author SHA1 Message Date
Christoph Oelckers
ad43f2bc7e - parse the list of class/struct fields and add the PField entries to their type.
- fixed a few issues with trying to access a class's Type before it got initialized.
2016-10-09 21:54:23 +02:00
Christoph Oelckers
08f313d011 - implemented complete resolving of constants - both global and class-local.
This uses a different algorithm as the old implementation - instead of recursively resolving unknown symbols it will first collect all constants from all scopes and then process them in one operation, doing multiple passes over the list until no more constants can be resolved anymore.
2016-10-08 22:16:10 +02:00
Christoph Oelckers
82ac2081b6 - create struct types.
- fixed class creation. There was an infinite loop and some missing checks for native classes.
- do not write the compiler's symbols to the same symbol table as the output. The output must go to GlobalSymbols but the internal symbols must go to a namespace specific table that can be discarded after compilation.
2016-10-08 13:34:37 +02:00
Christoph Oelckers
d819aafcf3 - changed handling of duplicate classes in DECORATE.
Instead of replacing the original, the second class will get renamed now, using the originating file as an identifier. In the vast majority of cases this should do exactly what is needed: Create an unconflicting second class that can coexist with the original. Unless the class is used by name this should eliminate all problems with this, but so far I haven't seen anything that used them by name.

This is choosing the lesser of two evils. While some mod out there may get broken, the old setup meant that the first class of a given name could not be written out to a savegame because it was not retrievable when loading it back.
2016-10-07 15:28:25 +02:00
Christoph Oelckers
06ca41f8b5 - do not declare PNamedType::Outer as DObject.
Ultimately we may have to get a fully qualified name out of this, so Outer should be a type that can handle this feature. The new class for this is currently used as base for PType and PSymbol so that PNamedType inherits from it and maybe later a namespace symbol can, too.
2016-10-07 13:59:29 +02:00
Christoph Oelckers
86e9282193 - removed the sequential processing of JSON objects because the benefit is too small.
After testing with a savegame on ZDCMP2 which is probably the largest map in existence, timing both methods resulted in a speed difference of less than 40 ms (70 vs 110 ms for reading all sectory, linedefs, sidedefs and objects).
This compares to an overall restoration time, including reloading the level, precaching all textures and setting everything up, of approx. 1.2 s, meaning an increase of 3% of the entire reloading time.
That's simply not worth all the negative side effects that may happen with a method that highly depends on proper code construction.
On the other hand, using random access means that a savegame version change is only needed now when the semantics of a field change, but not if some get added or deleted.

- do not I_Error out in the serializer unless caused by a programming error.

It is better to let the serializer finish, collect all the errors and I_Error out when the game is known to be in a stable enough state to allow unwinding.
2016-09-23 14:04:05 +02:00
Christoph Oelckers
970c168b13 - re-added serialization of treanslations.
- removed more dead code.
2016-09-20 19:45:32 +02:00
Christoph Oelckers
e101014432 - converted the user variable serializer. 2016-09-20 18:27:47 +02:00
Christoph Oelckers
42e38f6cc1 - more cleanup to reduce references to FArchive. 2016-09-20 10:59:48 +02:00
Christoph Oelckers
e04055dbb2 - added multiple message levels for 'developer' CVAR so that the important stuff won't get drowned in pointless notification spam that's of no use to anyone.
- made 'developer' CVAR persist across launches and added some menu entries for it.
- added checks for 'developer' to ACS's CheckInventory function.
2016-08-28 09:55:04 +02:00
Leonard2
bbdc64a955 Fixed bad serialization of float types
The value was written twice if it couldn't be reduced to a single precision value
2016-07-12 19:37:00 +02:00
Christoph Oelckers
ef86b3975a - added 'strictdecorate' CVAR. If this is set to 'true', any DECORATE error that had to be demoted to a warning for backwards compatibility will be treated as an actual error. 2016-06-08 10:56:11 +02:00
Christoph Oelckers
3fd0d27efa - removed some leftover fixed point handling from PType. 2016-04-27 15:35:01 +02:00
Christoph Oelckers
db86385cf6 - removed STACK_ARGS.
The only reason this even existed was that ZDoom's original VC projects used __fastcall. The CMake generated project do not, they stick to __cdecl.
Since no performance gain can be seen by using __fastcall the best course of action is to just remove all traces of it from the source and forget that it ever existed.
2016-04-11 10:46:30 +02:00
Christoph Oelckers
1a5a00a76e Merge branch 'floatcvt' 2016-04-05 21:42:09 +02:00
Randy Heit
6f60253590 Don't waste time looking for variables to (de)init in native classes 2016-04-04 14:57:43 -05:00
Christoph Oelckers
fd27c8db9e Merge branch 'master' into floatcvt
# Conflicts:
#	src/dobjtype.cpp
#	src/dobjtype.h
#	src/version.h
2016-04-04 01:21:24 +02:00
Randy Heit
7c8cff64e6 Added code to initialize and destroy string variables in classes
- Will require being able to add strings to non-native classes to actually
  test this.
2016-04-03 17:45:04 -05:00
Randy Heit
15208188de Remove PClass::Extend() 2016-04-03 16:25:08 -05:00
Randy Heit
85c8218441 Added methods for PTypes to serialize their values
- Values are tagged to allow for some measure of changing variable types
  without automatically breaking savegames.
- Use these new methods to serialize the non-native variables in an
  object. This allows for achiving non-ints.
2016-04-03 16:21:48 -05:00
Randy Heit
806d9d7a95 Add an AddField() override to PClass that extends the default instance 2016-04-03 16:21:47 -05:00
Christoph Oelckers
0eb35d6c6e Merge branch 'master' into floatcvt
# Conflicts:
#	src/dobjtype.cpp
#	src/dobjtype.h
2016-03-30 09:47:25 +02:00
Randy Heit
299019ea15 Add GetValueFloat() for numeric PTypes 2016-03-29 22:41:37 -05:00
Randy Heit
feb5ab31cc Add double variants of SetValue() for numeric PTypes 2016-03-29 22:05:25 -05:00
Randy Heit
e2711a74e7 Add float user vars for DECORATE
- PClass::Extend now takes alignment into consideration.
2016-03-29 21:48:57 -05:00
Christoph Oelckers
2b33601d00 - The fixed_t type for the VM also is not needed any longer and was removed. 2016-03-25 15:50:39 +01:00
Christoph Oelckers
3a598d672e - removed the angle_t type from the VM, now that nothing in the interface requires it anymore. 2016-03-25 14:55:01 +01:00
Randy Heit
aaae9f2e05 Store known but uncompiled nodes in the symbol table
- Don't bother keeping track of uncompiled nodes in a special table. Use
  the regular symbol table instead. This should in the future make
  compiling nodes referenced deeper than (and before) their definitions
  fairly straightforward.
- Also, break up the compiler's Message() function into Warn() and Error()
  and get rid of zcc_errors.h. I can't really see having a set of error
  numbers being useful.
2016-03-18 19:34:32 -05:00
Randy Heit
e3d35f4fe8 PClassPointer should use its own type as the metatype in the type table
- I don't remember why I thought using PPointer as the metatype for
  PClassPointer would be preferable, but it means that PPointer's MatchID
  can potentially be called for PClassPointer entries.
2016-03-03 17:31:01 -06:00
Randy Heit
55142078d8 Normalize line endings 2016-03-01 09:47:10 -06:00
Randy Heit
b2ccd0bd28 Use action function return value to make state jumps happen
- The A_Jump family of action functions now return the state to jump
  to (NULL if no jump is to be taken) instead of jumping directly.
  It is the caller's responsibility to handle the jump. This will
  make it possible to use their results in if statements and
  do something other than jump.
- DECORATE return statements can now return the result of a function
  (but not any random expression--it must be a function call). To
  make a jump happen from inside a multi-action block, you must
  return the value of an A_Jump function. e.g.:
    { return A_Jump(128, "SomeState"); }
- The VMFunction class now contains its prototype instead of storing
  it at a higher level in PFunction. This is so that
  FState::CallAction can easily tell if a function returns a state.
- Removed the FxTailable class because with explicit return
  statements, it's not useful anymore.
2016-02-18 20:39:40 -06:00
Christoph Oelckers
e2de258498 - remove debug output. 2016-02-10 12:09:14 +01:00
Christoph Oelckers
bc616dbf06 - fixed: APowerupGiver::PowerupType also needs replacement handling for placeholder classes. 2016-02-10 10:04:52 +01:00
Christoph Oelckers
6ce0c9f78e - split up PClass::Derive and its child functions because part of them is also needed when initializing an inherited native class with the properties of its parent - but calling the base version in PClass is not possible.
- moved a few AActor properties out of the EXE so that I could easily test if it works.
2016-02-10 00:17:00 +01:00
Christoph Oelckers
b484cbf18a - fixed: It is not guaranteed that the class object that is created by FindClassTentative actually matches the real object that is required later, so it needs to be replaced wherever it could be referenced once the real object is created.
- removed some unneeded code from earlier attempts to fix the class type resolving issue.
2016-02-09 23:08:51 +01:00
Christoph Oelckers
6c92525fcd - added an option to FindClassTentative to make eventual failure to declare the missing class non-fatal.
Damn those old mods with broken actor references. Thanks to those FxClassTypeCast may not throw fatal errors.
2016-02-09 12:26:00 +01:00
Randy Heit
4228721351 Enable running when built with Clang's -fsanitize=address 2016-02-05 16:04:50 -06:00
Christoph Oelckers
7b6b473ec4 - some GCC fixed by Edward-san. 2015-04-29 11:28:04 +02:00
Christoph Oelckers
afa022605a - some more fixes of 'Restart'. Still not working as intended. 2015-04-28 19:03:52 +02:00
Christoph Oelckers
91b05366d6 - tried to make 'restart' CCMD work again.
This requires quite a bit more thorough cleanup. I got it to the point where the titlepic appears after restarting, but it still crashes when starting the game so there's more data that needs to be cleaned up...
2015-04-28 16:39:20 +02:00
Christoph Oelckers
2d0f6339f7 - fixed some memory leaks: The global symbol table and the argument list for DECORATE called action specials were never freed. 2015-04-28 15:34:48 +02:00
Randy Heit
1e7cce5a2c Add missing NewPointer() function 2015-03-14 22:04:53 -05:00
Randy Heit
2adf5782b9 Return propertype conversion routes larger than 1
- Fixed: PType::FindConversion() gave all but the source type a distance of
  0, so it only ever returned just one step of a route that requires more
  than one step.
2013-10-30 20:52:46 -05:00
Randy Heit
e7616ec0bd Add D-style properties to the numeric types
- This is stuff like min and max for integral types and infinity and nan
  for floating point types.
2013-10-29 22:06:03 -05:00
Randy Heit
fe21ceec56 Add a constructor to PSymbolTable that takes a parent table as input 2013-10-29 22:05:56 -05:00
Randy Heit
e696fff0be Capitalize some names that weren't before.
- Since this caused several duplicate names to creep in, try to be more
  consistant abount name capitalization.
2013-10-29 22:05:49 -05:00
Randy Heit
82c22459dc Give all types a symbol table, not just structs and derivatives 2013-10-29 22:05:25 -05:00
Randy Heit
b227a2f508 Add the basic types to the global symbol table 2013-10-29 22:05:16 -05:00
Randy Heit
c7e817dfb9 Added type conversion search routines
- PType::FindConversion() can find a path to convert one type to another.
  This is completely generic and can handle any number of conversion
  functions.
2013-10-23 22:39:51 -05:00
Randy Heit
a0dbcb5d5b Add TRUE and FALSE terminals to the zcc grammar
- I can't believe I completely forgot to let the parser handle true and
  false literals.
- Consolidate all the %include blocks in zcc-parse.lemon into a single
  one, because Lemon all of a sudden decided it didn't like me having more
  than one in the grammar file.
- Added a PBool type to represent boolean values with.
2013-09-28 21:16:44 -05:00