Commit graph

92 commits

Author SHA1 Message Date
Christoph Oelckers
49f18c0a19 - renamed the symbol tables holding the tree nodes so that the code becomes clearer to read. Necessary because the unclear naming caused:
- fixed: The tree nodes for classes and struct members were stored in the global tree nodes table.
- sort variable declarations into their own list for processing.
2016-10-09 09:09:17 +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
d139ee9f68 - give the 'default' block its own node type in the AST.
- group a class's body the same way as the global AST. Only partially implemented so far so that constants can be processed.
2016-10-08 15:27:20 +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
e101014432 - converted the user variable serializer. 2016-09-20 18:27:47 +02:00
Leonard2
8437313e7c Added post/pre increment/decrement operators to DECORATE 2016-08-07 22:10:01 +02:00
Christoph Oelckers
3fd0d27efa - removed some leftover fixed point handling from PType. 2016-04-27 15:35:01 +02: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
55142078d8 Normalize line endings 2016-03-01 09:47:10 -06:00
Randy Heit
f23c0121c5 Use new type system with DECORATE 2016-02-29 21:11:59 -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
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
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
8cb269388e Eliminate .mreg section
- Member variables are now declared all in one place: InitThingdef(). They
  are not partially defined in thingdef_expression.cpp and further refined
  in actor.txt.
- This left ParseNativeVariable() parsing only functions, so it has been
  renamed to ParseNativeFunction().
- Note that their declarations in InitThingdef() are expected to be
  temporary.
2015-03-14 22:16:05 -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
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
dbc9fd6c0e Pad PSymbolConstNumeric to ensure it's the same size as PSymbolConstString 2013-10-25 22:30:12 -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
Randy Heit
0fb9f98a96 Add void and error types; rejigger pointer types
- Added TypeVoid for statements, which produce no type.
- Added TypeError for expressions whose arguments are incompatible.
- Pointers now derive from PBasicType instead of PInt. Since they have their own register sets in the VM, this seems to make more sense than treating them as integers.
2013-09-20 21:10:20 -05:00
Randy Heit
2ab3974752 Add a PSymbolConstString class
- Constants can be strings, but the existing PSymbolConst couldn't handle
  them. The old PSymbolConst is now PSymbolConstNumeric, and the new
  PSymbolConst is a now a baseclass for it and PSymbolConstString.
2013-09-10 22:01:00 -05:00
Randy Heit
6584819d01 Use PType for typing things in PSymbolConst. 2013-09-07 20:35:46 -05:00
Randy Heit
2f7183b937 Use PField instead of PSymbolVariable for DECORATE expressions
- The type systems used by PField and FxExpression are completely
  incompatible, but I think I got the differences taken care of as far
  as ParseNativeVariable(), ParseUserVariable(), and FxClassMember are
  concerned.
- Support for declaring native bool variables has been removed for the time
  being. It wasn't used anyway.
- Removed PSymbolVariable.
2013-08-23 22:02:51 -05:00
Randy Heit
0d1973a659 Make PStruct::AddField() check for duplicates
- PStruct::AddField() now checks the symbol table for a symbol of the same
  name before adding a new field. If the name is in use, it returns NULL.
2013-08-23 21:56:18 -05:00
Randy Heit
263b160905 Add PFixed and PArray types
- These are types that are stored as integers but otherwise handled as floating point values.
2013-08-23 21:53:54 -05:00
Randy Heit
b5d37348f6 Add code generation simplification methods to PType
- To assist with using PType with DECORATE expression code generation,
  added GetStoreOp(), GetLoadOp(), and GetRegType() to PType.
2013-08-23 21:52:04 -05:00
Randy Heit
2ec3cbddb9 Mark PType's GetValueInt method as const 2013-08-23 21:50:33 -05:00
Randy Heit
5aff8156ba Use PField and not PSymbolVariable for ACS's Get/SetUserVariable 2013-08-21 22:39:28 -05:00
Randy Heit
4cf0ef7e3f Minor PField changes.
- Rename FieldOffset and FieldType so they no longer have the "Field" prefix
- Add a Flags field.
2013-08-21 22:38:05 -05:00
Randy Heit
e50c00c856 Add generic integer setters and getters for PInt and PFloat types 2013-08-21 22:36:46 -05:00
Randy Heit
cf87d0f1e9 Use PFunction instead of PSymbolActionFunction in DECORATE parser 2013-08-14 22:00:16 -05:00
Randy Heit
8fbb4b90fb Add some flags for PFunction 2013-08-14 21:56:21 -05:00
Randy Heit
ed1c22186f Add PStatePointer type 2013-08-14 21:53:03 -05:00
Randy Heit
55bec365e8 Added a way to specify paramater flags for PFunction
- And right now, the only flag is "Optional".
2013-08-10 20:24:12 -05:00