1.1 --- a/jitcraft/AST.h Mon Jun 25 21:20:01 2012 -0700
1.2 +++ b/jitcraft/AST.h Tue Jun 26 00:35:15 2012 -0700
1.3 @@ -38,7 +38,8 @@
1.4 _(FunctionStatement) \
1.5 _(CallExpression) \
1.6 _(IfStatement) \
1.7 - _(IndexExpression)
1.8 + _(IndexExpression) \
1.9 + _(EnumStatement)
1.10
1.11 // Forward declarations.
1.12 #define _(name) class name;
1.13 @@ -501,6 +502,48 @@
1.14 }
1.15 };
1.16
1.17 +class EnumStatement : public Statement
1.18 +{
1.19 + Name *name_;
1.20 +
1.21 + public:
1.22 + struct Entry {
1.23 + NamedConstant *name;
1.24 + Expression *expr;
1.25 +
1.26 + Entry(NamedConstant *name, Expression *expr)
1.27 + : name(name),
1.28 + expr(expr)
1.29 + {
1.30 + }
1.31 + };
1.32 +
1.33 + typedef std::vector<Entry> EntryList;
1.34 +
1.35 + public:
1.36 + EnumStatement(Name *name, EntryList *entries)
1.37 + : name_(name),
1.38 + entries_(entries)
1.39 + {
1.40 + }
1.41 +
1.42 + Kind kind() const {
1.43 + return kEnumStatement;
1.44 + }
1.45 + Name *name() const {
1.46 + return name_;
1.47 + }
1.48 + EntryList *entries() const {
1.49 + return entries_;
1.50 + }
1.51 + void accept(AstVisitor *visitor) {
1.52 + visitor->visit(this);
1.53 + }
1.54 +
1.55 + private:
1.56 + EntryList *entries_;
1.57 +};
1.58 +
1.59 class Scope;
1.60
1.61 typedef std::vector<NameProxy *> NameProxyList;