Commit graph

3991 commits

Author SHA1 Message Date
Randy Heit
ec6624dfc7 Prioritize single->double conversions for FindBestProto()
- The binary form of ZCC_OpInfoType::FindBestProto() needs special
  handling for conversion from single to double precision floating point
  so that it doesn't choose an integer form over a floating point form
  when picking the best prototype.
2013-11-01 22:05:49 -05:00
Randy Heit
3063df4f74 Add single <-> double conversions.
- With explicit casting now possible, converting from double to single
  precision floating point and back again needs to be possible, too.
2013-11-01 21:45:02 -05:00
Randy Heit
b66de4116d Remove IsUnary() and IsBinary()
- This information is already stored in the node's NodeType field, so
  there's no reason to go do a table lookup for it elsewhere. Must have
  been a brain fart when I wrote them in the first place.
2013-11-01 21:28:00 -05:00
Randy Heit
16fc9be411 Interpret function calls to type refs as type casts 2013-10-30 20:53:02 -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
39d7fa0605 Allow access to the numeric properties.
- Identifiers can now evaluate to type references.
- The dot operator can now find symbols in type references.
2013-10-29 22:06:14 -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
6c7788d2ad Make global symbols survive GC runs
- The global symbol table was never marked by the GC, so anything pointed
  only by it was fair game to disappear.
- Don't clear the global symbol table during DECORATE parsing. Junk in
  there should be considered constant after initialization.
2013-10-29 22:05:43 -05:00
Randy Heit
61b419c187 Remove duplicated names from namedef.h
- Added an assertion in FName::NameManager::InitBuckets() that makes these
  errors easier to spot in the future.
2013-10-29 22:05:32 -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
03c4244fd8 Accept only one identifier for class names. 2013-10-29 22:05:09 -05:00
Randy Heit
2b96db5fac Do not share constant 1 for enum autoincrements.
- AST nodes cannot be shared, because type conversion changes them in
  place, and what's appropriate for one use is by no means appropriate for
  all uses.
2013-10-25 22:30:25 -05:00
Randy Heit
6384613487 Allow using constants in other constants before their definitions.
- Something like this is now valid:
    const foo = bar + 10;
    const bar = 1000;
2013-10-25 22:30:25 -05:00
Randy Heit
76d2e8cfc4 Set node type when nil-ing an id node.
- Nodes can't stay as type AST_ExprID if they don't also have the
  operation PEX_ID.
2013-10-25 22:30:25 -05:00
Randy Heit
850055a766 Add evaluation of constant unary and binary expressions
- Added ZCCCompiler class as a place to generate IR and symbols from an
  AST. Right now, all it does is simplify constant expressions into
  constant values.
- Do type promotion on the AST where appropriate.
- Added true and false tokens to the parser driver.
2013-10-25 22:30:24 -05:00
Randy Heit
d0968af9a6 Separate the AST from the parser state. 2013-10-25 22:30:24 -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
4bd5bf310b Do not use GT, GTEQ, or NEQ operators in the AST.
- Since the VM doesn't directly support the GT, GTEQ, and NEQ comparisons,
  don't use them in the trees either. Instead, wrap them as LTEQ, LT, and
  EQEQ inside a BoolNot operator.
2013-10-02 23:28:06 -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
1948642758 Add Printf extension %H
- This conversion has behavior similar to %g: It automatically behaves like
  %f or %e based on the number of output characters. However, unlike %g,
  this decision is also based on what will produce the smallest string
  without truncating the output. The precision field (the * in %.*f) is
  ignored. Converting a double to text with %H and then back to a double
  should be lossless.
2013-09-25 20:46:45 -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
743b05189e Give the parser knowledge of constants for unary - and +
- Since the tokenizer never gives the parser negative numbers but always a
  unary minus followed by a positive number, it seems reasonable to make
  the parser smart enough to turn these into negative constants without
  generating extra tree nodes.
- And since we're doing it for unary -, we might as well do it for unary +
  as well and avoid extra nodes when we know we don't need them.
2013-09-12 22:22:43 -05:00
Randy Heit
2a1414ad66 Use labels in autogenerated enum value expressions
- For an enum like this:
    enum { value1 = SOME_NUM*2, value2 };
  Generate an increment expression for value2 of the form
    (add (id value1) 1)
  and not
    (add (* SOME_NUM 2) 1)
2013-09-12 22:06:57 -05:00
Randy Heit
af8e0f2ba6 Represent enumerations as constant definitions
- Instead of representating enumeration values with a special node type,
  use the same ZCC_ConstantDef nodes that const_def produces. These are
  created at the same scope as the ZCC_Enum, rather than being contained
  entirely within it. To mark the end of enums for a single instance of
  ZCC_Enum, a ZCC_EnumTerminator node is now appended to the chain of
  ZCC_ConstantDefs.
2013-09-12 22:00:49 -05:00
Randy Heit
d5fa550118 Make ZCC_TreeNode::AppendSibling() work with lists
- Previously, you could only append lone nodes to ZCC_TreeNode lists.
  Now you can append one list to another.
2013-09-12 22:00:49 -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
33e835b58d Accept name constants in the grammar 2013-09-10 21:56:13 -05:00
Randy Heit
b6e525d935 Add missing closing " for string constants in AST dumps 2013-09-10 21:50:27 -05:00
Randy Heit
52d5e74e7e Mark unsigned constants in AST dumps.
- Add the u suffix to unsigned integer constants printed in AST dumps.
2013-09-10 21:48:15 -05:00
Randy Heit
1b4851224e Let the grammar accept unsigned integer constants 2013-09-10 21:44:32 -05:00
Randy Heit
33344201fa Let the scanner returned unsigned integers
- The scanner already recognized the u suffix for unsigned integers, but
  otherwise ignored it. Return it as a proper token.
2013-09-10 21:40:05 -05:00
Randy Heit
aec6aff7a8 Don't accept l as a suffix for floating point numbers in the scanner
- We're never going to support long doubles, so don't pretend.
2013-09-10 21:30:33 -05:00
Randy Heit
6545c48e07 Accept constant definitions at global scope 2013-09-10 21:25:50 -05:00
Randy Heit
3044fdd0a9 Use %f instead of %g in AST dumps
- To ensure that floating point constants are identifiable as floating
  point, FLispString::AddFloat() now prints them with %f.
2013-09-10 21:24:32 -05:00
Randy Heit
61666e1515 Consolidate constant expression nodes into a single type
- Instead of having ZCC_ExprString, ZCC_ExprInt, and ZCC_ExprFloat,
  just use a single ZCC_ExprConstant. It should simplify type
  promotion and constant folding in the future.
2013-09-10 21:10:48 -05:00
Randy Heit
f9f8d1e79b Add a type field for ZCC expressions.
- Constants can fill out the type field right away. Other expressions will need
  to wait until a later pass, after names have been resolved, so they get
  initialized to NULL.
2013-09-10 20:50:21 -05:00
Randy Heit
6584819d01 Use PType for typing things in PSymbolConst. 2013-09-07 20:35:46 -05:00
Christoph Oelckers
251cdacf26 Merge branch 'master' into scripting
Conflicts:
	src/g_shared/a_randomspawner.cpp
	src/g_strife/a_strifeweapons.cpp
	src/thingdef/thingdef_parse.cpp
	wadsrc/static/actors/constants.txt
2013-09-03 09:01:28 +02:00
Christoph Oelckers
18386e4b23 Merge branch 'maint' 2013-09-03 08:44:52 +02:00
Christoph Oelckers
11c026ee84 - fixed: displaying sprites on the automap ignored both the actor's scale and translation. 2013-09-03 08:34:55 +02:00
Christoph Oelckers
75dd5503cf - fixed: Cost strings for dialogues must not be added in the dialogue parser but while displaying the message to properly handle stringtable entries. 2013-09-03 08:24:47 +02:00
Christoph Oelckers
4ed27c22fd Merge branch 'master' of https://github.com/MazterQyou/zdoom 2013-09-03 07:59:37 +02:00
Alex Qyoun-ae
b6baeecd9a Fixed compilation with LLVM compilers 2013-09-03 03:49:39 +04:00
Christoph Oelckers
ba2a07fb26 - removed all uses of single precision floats from FraggleScript code. 2013-09-02 09:08:47 +02:00
Randy Heit
267030c759 Merge branch 'maint' 2013-08-30 23:13:32 -05:00
Randy Heit
260ce62175 Don't abort for TEXTUREx lumps that define textures with no patches
- A texture defined in TEXTUREx without any patches isn't necessarily an
  error, so accept. This also means they shouldn't be used for determining
  if a TEXTURE directory belongs to Strife instead of Doom.
2013-08-30 23:10:20 -05:00