src/AST.h
changeset 146 dc7d3b7a918c
parent 145 e9d804821c48
child 148 c0740249963c
     1.1 --- a/src/AST.h	Wed Aug 01 22:32:59 2012 -0700
     1.2 +++ b/src/AST.h	Sat Aug 04 17:51:43 2012 -0700
     1.3 @@ -49,7 +49,8 @@
     1.4      _(IncDecExpression)         \
     1.5      _(UnaryExpression)          \
     1.6      _(TernaryExpression)        \
     1.7 -    _(BooleanLiteral)
     1.8 +    _(BooleanLiteral)           \
     1.9 +    _(StructureStatement)
    1.10  
    1.11  // Forward declarations.
    1.12  #define _(name) class name;
    1.13 @@ -866,6 +867,72 @@
    1.14      }
    1.15  };
    1.16  
    1.17 +class StructureStatement : public Statement
    1.18 +{
    1.19 +  public:
    1.20 +    class Field : public PoolObject
    1.21 +    {
    1.22 +        SourcePosition pos_;
    1.23 +        BoundName *type_;
    1.24 +        ScopedRoot<String> name_;
    1.25 +        ExpressionList *dimensions_;
    1.26 +
    1.27 +      public:
    1.28 +        Field(const SourcePosition &pos,
    1.29 +              BoundName *type,
    1.30 +              Handle<String> name,
    1.31 +              ExpressionList *dimensions)
    1.32 +          : pos_(pos),
    1.33 +            type_(type),
    1.34 +            name_(name),
    1.35 +            dimensions_(dimensions)
    1.36 +        {
    1.37 +        }
    1.38 +
    1.39 +        const SourcePosition &pos() const {
    1.40 +            return pos_;
    1.41 +        }
    1.42 +        BoundName *type() const {
    1.43 +            return type_;
    1.44 +        }
    1.45 +        String *name() const {
    1.46 +            return name_;
    1.47 +        }
    1.48 +        ExpressionList *dimensions() const {
    1.49 +            return dimensions_;
    1.50 +        }
    1.51 +    };
    1.52 +
    1.53 +    typedef PoolList<StructureStatement::Field *> FieldList;
    1.54 +
    1.55 +  public:
    1.56 +    StructureStatement(const SourcePosition &pos, NamedType *decl, FieldList *fields)
    1.57 +      : Statement(pos),
    1.58 +        decl_(decl),
    1.59 +        fields_(fields)
    1.60 +    {
    1.61 +    }
    1.62 +
    1.63 +    Kind kind() const {
    1.64 +        return kStructureStatement;
    1.65 +    }
    1.66 +    FieldList *fields() const {
    1.67 +        return fields_;
    1.68 +    }
    1.69 +    NamedType *decl() const {
    1.70 +        return decl_;
    1.71 +    }
    1.72 +    void accept(AstVisitor *visitor) {
    1.73 +        visitor->visit(this);
    1.74 +    }
    1.75 +
    1.76 +  private:
    1.77 +    NamedType *decl_;
    1.78 +    FieldList *fields_;
    1.79 +};
    1.80 +
    1.81 +typedef StructureStatement::FieldList FieldList;
    1.82 +
    1.83  class Scope;
    1.84  
    1.85  typedef PoolList<NameProxy *> NameProxyList;