Commit graph

78 commits

Author SHA1 Message Date
Randy Heit
806d9d7a95 Add an AddField() override to PClass that extends the default instance 2016-04-03 16:21:47 -05: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
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
Randy Heit
973b0f5c56 Change PFunction's superclass from PNamedType to PSymbol 2013-08-10 20:17:55 -05:00
Randy Heit
6575499f37 Added basic implementation for PField.
- I don't know why this didn't give me trouble before, but I needed to add IMPLEMENT_CLASS for PField.
2013-08-10 20:17:29 -05:00
Randy Heit
3e46e6376c Added NewPrototype() function 2013-08-10 20:06:54 -05:00
Randy Heit
f18c7b8959 Make FType::Hash work for PPrototype
- For Prototypes, Hash is passed the address of two TArrays. If we blindly
  hash those without checking their contents, then we can forget about
  ever finding any matching prototypes in the type table. (Not that I
  remember why I wanted them to be unique, but I'm sure I must have had my
  reasons.)
2013-08-10 20:05:42 -05:00
Randy Heit
93cbdd37a5 PArray's size should take alignment into account. 2013-08-08 22:27:40 -05:00
Randy Heit
6c1f3a1396 Added PStruct::AddField() 2013-08-08 22:27:40 -05:00
Randy Heit
476a98652c Remove extraneous PField class
- Remove the existing PField class, rename PMemberField to PField, and
  derive it from PSymbol instead of the old PField.
2013-08-08 22:27:39 -05:00
Randy Heit
7e24f6b00c - Added NewStruct() function. 2013-08-08 22:27:39 -05:00
Randy Heit
0ec33191aa - Added NewEnum() function. 2013-08-08 22:27:39 -05:00
Randy Heit
dbaf72772b Move the symbol table from PClass to PStruct. 2013-08-08 22:27:38 -05:00
Randy Heit
4a1fbdb32a Remove all state expression/param stuff
- This all became vestigial code after the relevant information was all
  moved into FStateTempCall. Now that the MBF code pointer code has been
  converted, I can be sure it wasn't still used anywhere.
2013-07-27 22:34:44 -05:00
Randy Heit
7171281507 - Compatibility fix: Classes redefined in DECORATE should cause the newer one to replace the
older one in the type table.

SVN r3913 (scripting)
2012-10-27 02:04:35 +00:00
Randy Heit
c043627cc1 - Some abstract syntax tree creation stuff. (Plus some tentative type creation stuff that made
me realize I would be better off creating a type-agnostic AST for the entire input instead
  of trying to tentatively create types before they're seen.)

SVN r2354 (scripting)
2010-06-06 04:15:28 +00:00
Randy Heit
50d126e78b - Clear the TypeTable on shutdown so that the objects in it can be collected.
SVN r2301 (scripting)
2010-04-24 03:10:58 +00:00