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.
This commit is contained in:
parent
d0968af9a6
commit
850055a766
10 changed files with 1265 additions and 108 deletions
|
|
@ -442,61 +442,11 @@ static void PrintClassType(FLispString &out, ZCC_TreeNode *node)
|
|||
|
||||
static void OpenExprType(FLispString &out, EZCCExprType type)
|
||||
{
|
||||
static const char *const types[] =
|
||||
{
|
||||
"nil",
|
||||
"id",
|
||||
"super",
|
||||
"self",
|
||||
"const",
|
||||
"func-call",
|
||||
"array-access",
|
||||
"member-access",
|
||||
"post-inc",
|
||||
"post-dec",
|
||||
"pre-inc",
|
||||
"pre-dec",
|
||||
"negate",
|
||||
"anti-negate",
|
||||
"bit-not",
|
||||
"bool-not",
|
||||
"size-of",
|
||||
"align-of",
|
||||
"add",
|
||||
"sub",
|
||||
"mul",
|
||||
"div",
|
||||
"mod",
|
||||
"pow",
|
||||
"cross-product",
|
||||
"dot-product",
|
||||
"left-shift",
|
||||
"right-shift",
|
||||
"concat",
|
||||
"lt",
|
||||
"gt",
|
||||
"lteq",
|
||||
"gteq",
|
||||
"ltgteq",
|
||||
"is",
|
||||
"eqeq",
|
||||
"neq",
|
||||
"apreq",
|
||||
"bit-and",
|
||||
"bit-or",
|
||||
"bit-xor",
|
||||
"bool-and",
|
||||
"bool-or",
|
||||
"scope",
|
||||
"trinary",
|
||||
};
|
||||
assert(countof(types) == PEX_COUNT_OF);
|
||||
|
||||
char buf[32];
|
||||
|
||||
if (unsigned(type) < countof(types))
|
||||
if (unsigned(type) < PEX_COUNT_OF)
|
||||
{
|
||||
mysnprintf(buf, countof(buf), "expr-%s", types[type]);
|
||||
mysnprintf(buf, countof(buf), "expr-%s", ZCC_OpInfo[type].OpName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue