summaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-15 14:28:17 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-15 14:28:17 -0700
commited85a5dd4b36f4a583fc321b6d8d49a050d48678 (patch)
treed16e626b04970a1bd9ca667cbb9f100b55def7f6 /ast.h
parent7f9d30974317a4050fb8990ce1a3eebbb190483a (diff)
Add new constructors for ast_type_specifier
Add a constructor that uses an ast_struct_specifier and one that uses a type name. This saves a (trivial) bit of code, but it also ensures some of the class invariants (i.e., type_name != NULL) are met.
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/ast.h b/ast.h
index 32cd5b6b4f..1bc38d355c 100644
--- a/ast.h
+++ b/ast.h
@@ -357,6 +357,22 @@ class ast_type_specifier : public ast_node {
public:
ast_type_specifier(int specifier);
+ /** Construct a type specifier from a type name */
+ ast_type_specifier(const char *name)
+ : type_specifier(ast_type_name), type_name(name), structure(NULL),
+ is_array(false), array_size(NULL), precision(ast_precision_high)
+ {
+ /* empty */
+ }
+
+ /** Construct a type specifier from a structure definition */
+ ast_type_specifier(ast_struct_specifier *s)
+ : type_specifier(ast_struct), type_name(s->name), structure(s),
+ is_array(false), array_size(NULL), precision(ast_precision_high)
+ {
+ /* empty */
+ }
+
virtual void print(void) const;
enum ast_types type_specifier;