diff -r a8735148dcf0 -r e9d804821c48 src/AST.h --- a/src/AST.h Mon Jul 30 22:30:38 2012 -0700 +++ b/src/AST.h Wed Aug 01 22:32:59 2012 -0700 @@ -98,36 +98,6 @@ #undef _ }; -class NameLocation -{ - public: - enum Kind { - LOCAL - }; - - static NameLocation Local(VariableDeclaration *decl) { - NameLocation loc; - loc.kind_ = LOCAL; - loc.u_.decl = decl; - return loc; - } - - Kind kind() const { - return kind_; - } - - VariableDeclaration *local() const { - assert(kind() == LOCAL); - return u_.decl; - } - - private: - Kind kind_; - union { - VariableDeclaration *decl; - } u_; -}; - class Statement : public AstNode { public: @@ -164,23 +134,24 @@ Variable *variable_; Expression *initialization_; ExpressionList *postDimensions_; - ScopedRoot tag_; + BoundName *type_; TokenKind declarator_; public: VariableDeclaration(const SourcePosition &pos, TokenKind declarator, Variable *var, - Handle tag, ExpressionList *postDimensions, + BoundName *type, ExpressionList *postDimensions, Expression *initialization) : Statement(pos), variable_(var), initialization_(initialization), postDimensions_(postDimensions), - tag_(tag) + type_(type), + declarator_(declarator) { } - String *tag() const { - return tag_; + BoundName *type() const { + return type_; } Kind kind() const { return kVariableDeclaration; @@ -205,17 +176,17 @@ class Parameter : public PoolObject { Variable *variable_; - ScopedRoot tag_; + BoundName *type_; bool reference_; bool const_; ExpressionList *dimensions_; Expression *initializer_; public: - Parameter(Variable *var, Handle tag, bool reference, bool isConst, + Parameter(Variable *var, BoundName *type, bool reference, bool isConst, ExpressionList *dimensions, Expression *initializer) : variable_(var), - tag_(tag), + type_(type), reference_(reference), const_(isConst), dimensions_(dimensions), @@ -223,8 +194,8 @@ { } - String *tag() const { - return tag_; + BoundName *type() const { + return type_; } Variable *variable() const { return variable_; @@ -366,7 +337,7 @@ { Expression *expression_; TokenKind token_; - ScopedRoot tag_; + BoundName *type_; public: UnaryExpression(const SourcePosition &pos, TokenKind token, Expression *expr) @@ -377,11 +348,11 @@ } UnaryExpression(const SourcePosition &pos, TokenKind token, Expression *expr, - Handle tag) + BoundName *type) : Expression(pos), expression_(expr), token_(token), - tag_(tag) + type_(type) { } @@ -394,8 +365,8 @@ TokenKind token() const { return token_; } - String *tag() const { - return tag_; + BoundName *type() const { + return type_; } void accept(AstVisitor *visitor) { visitor->visit(this); @@ -739,18 +710,18 @@ Statement *body_; ParameterList *parameters_; bool explicitReturn_; - ScopedRoot tag_; + BoundName *returnType_; public: FunctionStatement(const SourcePosition &pos, Scope *scope, NamedFunction *fun, Statement *body, - ParameterList *parameters, Handle returnTag, bool explicitReturn) + ParameterList *parameters, BoundName *returnType, bool explicitReturn) : Statement(pos), scope_(scope), fun_(fun), body_(body), parameters_(parameters), explicitReturn_(explicitReturn), - tag_(returnTag) + returnType_(returnType) { } @@ -775,8 +746,8 @@ bool hasExplicitReturn() const { return explicitReturn_; } - String *returnTag() const { - return tag_; + BoundName *returnType() const { + return returnType_; } }; @@ -818,6 +789,7 @@ class EnumStatement : public Statement { ScopedRoot name_; + NamedType *type_; public: struct Entry { @@ -834,9 +806,10 @@ typedef PoolList EntryList; public: - EnumStatement(const SourcePosition &pos, Handle name, EntryList *entries) + EnumStatement(const SourcePosition &pos, NamedType *type, Handle name, EntryList *entries) : Statement(pos), name_(name), + type_(type), entries_(entries) { } @@ -850,6 +823,9 @@ EntryList *entries() const { return entries_; } + NamedType *decl() const { + return type_; + } void accept(AstVisitor *visitor) { visitor->visit(this); }