[qfcc] Sanitize expr type enum

Got tired of dealing with out of date string tables.
This commit is contained in:
Bill Currie 2022-01-07 23:12:20 +09:00
parent e186d5064d
commit f5be54b6d2
3 changed files with 65 additions and 35 deletions

View file

@ -40,28 +40,12 @@
/** Type of the exression node in an expression tree. /** Type of the exression node in an expression tree.
*/ */
#define EX_EXPR(expr) ex_##expr,
typedef enum { typedef enum {
ex_error, ///< error expression. used to signal an error #include "tools/qfcc/include/expr_names.h"
ex_state, ///< state expression (::ex_state_t)
ex_bool, ///< short circuit boolean logic expression (::ex_bool_t)
ex_label, ///< goto/branch label (::ex_label_t)
ex_labelref, ///< label reference (::ex_labelref_t)
ex_block, ///< statement block expression (::ex_block_t)
ex_expr, ///< binary expression (::ex_expr_t)
ex_uexpr, ///< unary expression (::ex_expr_t)
ex_def, ///< non-temporary variable (::def_t)
ex_symbol, ///< non-temporary variable (::symbol_t)
ex_temp, ///< temporary variable (::ex_temp_t)
ex_vector, ///< "vector" expression (::ex_vector_t)
ex_selector, ///< selector expression (::ex_selector_t)
ex_nil, ///< umm, nil, null. nuff said (0 of any type)
ex_value, ///< constant value (::ex_value_t)
ex_compound, ///< compound initializer
ex_memset, ///< memset needs three params...
ex_count, ///< number of valid expression types ex_count, ///< number of valid expression types
} expr_type; } expr_type;
#undef EX_EXPR
/** Binary and unary expressions. /** Binary and unary expressions.

View file

@ -0,0 +1,58 @@
/*
expr.h
expression construction and manipulations
Copyright (C) 2022 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2022/01/7
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
/** \defgroup qfcc_expr Expressions
\ingroup qfcc
*/
///@{
#ifndef EX_EXPR
#define EX_EXPR(expr)
#endif
EX_EXPR(error) ///< error expression. used to signal an error
EX_EXPR(state) ///< state expression (::ex_state_t)
EX_EXPR(bool) ///< short circuit boolean logic expression (::ex_bool_t)
EX_EXPR(label) ///< goto/branch label (::ex_label_t)
EX_EXPR(labelref) ///< label reference (::ex_labelref_t)
EX_EXPR(block) ///< statement block expression (::ex_block_t)
EX_EXPR(expr) ///< binary expression (::ex_expr_t)
EX_EXPR(uexpr) ///< unary expression (::ex_expr_t)
EX_EXPR(def) ///< non-temporary variable (::def_t)
EX_EXPR(symbol) ///< non-temporary variable (::symbol_t)
EX_EXPR(temp) ///< temporary variable (::ex_temp_t)
EX_EXPR(vector) ///< "vector" expression (::ex_vector_t)
EX_EXPR(selector) ///< selector expression (::ex_selector_t)
EX_EXPR(nil) ///< umm, nil, null. nuff said (0 of any type)
EX_EXPR(value) ///< constant value (::ex_value_t)
EX_EXPR(compound) ///< compound initializer
EX_EXPR(memset) ///< memset needs three params...
///@}

View file

@ -55,25 +55,13 @@
#include "tools/qfcc/source/qc-parse.h" #include "tools/qfcc/source/qc-parse.h"
#define EX_EXPR(expr) #expr,
const char *expr_names[] = const char *expr_names[] =
{ {
"error", #include "tools/qfcc/include/expr_names.h"
"state", 0
"bool",
"label",
"labelref",
"block",
"expr",
"uexpr",
"def",
"symbol",
"temp",
"vector",
"nil",
"value",
"compound",
"memset",
}; };
#undef EX_EXPR
const char * const char *
get_op_string (int op) get_op_string (int op)