src/compiler/AST.h
changeset 256 3c184218462d
parent 251 ca99a81745fe
child 258 241d082d6d89
     1.1 --- a/src/compiler/AST.h	Tue Jan 01 20:08:34 2013 -0800
     1.2 +++ b/src/compiler/AST.h	Sun Jan 06 13:52:21 2013 -0800
     1.3 @@ -28,6 +28,7 @@
     1.4  namespace ke {
     1.5  
     1.6  class Scope;
     1.7 +class Importable;
     1.8  struct PathComponent;
     1.9  
    1.10  #define ASTKINDS(_)             \
    1.11 @@ -128,21 +129,11 @@
    1.12  
    1.13  class Expression : public AstNode
    1.14  {
    1.15 -    ScopedRoot<Type> type_;
    1.16 -
    1.17    public:
    1.18      Expression(const SourcePosition &pos)
    1.19 -      : AstNode(pos),
    1.20 -        type_(NULL)
    1.21 +      : AstNode(pos)
    1.22      {
    1.23      }
    1.24 -
    1.25 -    void setType(Type *type) {
    1.26 -        type_ = type;
    1.27 -    }
    1.28 -    Type *type() const {
    1.29 -        return type_;
    1.30 -    }
    1.31  };
    1.32  
    1.33  typedef PoolList<Statement *> StatementList;
    1.34 @@ -497,14 +488,12 @@
    1.35  {
    1.36      Expression *left_;
    1.37      ScopedRoot<String> field_;
    1.38 -    unsigned fieldIndex_;
    1.39  
    1.40    public:
    1.41      FieldExpression(const SourcePosition &pos, Expression *left, Handle<String> field)
    1.42        : Expression(pos),
    1.43          left_(left),
    1.44 -        field_(field),
    1.45 -        fieldIndex_(unsigned(-1))
    1.46 +        field_(field)
    1.47      {
    1.48      }
    1.49  
    1.50 @@ -513,17 +502,9 @@
    1.51      Expression *left() const {
    1.52          return left_;
    1.53      }
    1.54 -    String *field() const {
    1.55 +    Handle<String> field() const {
    1.56          return field_;
    1.57      }
    1.58 -    void setFieldIndex(unsigned index) {
    1.59 -        assert(fieldIndex_ == unsigned(-1));
    1.60 -        fieldIndex_ = index;
    1.61 -    }
    1.62 -    unsigned fieldIndex() const {
    1.63 -        assert(fieldIndex_ != unsigned(-1));
    1.64 -        return fieldIndex_;
    1.65 -    }
    1.66  };
    1.67  
    1.68  class CallExpression : public Expression
    1.69 @@ -1105,11 +1086,9 @@
    1.70  class ImportStatement : public Statement
    1.71  {
    1.72    public:
    1.73 -    ImportStatement(const SourcePosition &pos, PathComponent *path, TokenKind suffix)
    1.74 +    ImportStatement(const SourcePosition &pos, PathComponent *path)
    1.75        : Statement(pos),
    1.76 -        path_(path),
    1.77 -        suffix_(suffix),
    1.78 -        source_(NULL)
    1.79 +        path_(path)
    1.80      {
    1.81      }
    1.82  
    1.83 @@ -1118,20 +1097,23 @@
    1.84      PathComponent *path() const {
    1.85          return path_;
    1.86      }
    1.87 -    void setImportSource(TranslationUnit *unit) {
    1.88 -        source_ = unit;
    1.89 +    void setSource(Importable *source) {
    1.90 +        source_ = source;
    1.91      }
    1.92 -    TranslationUnit *source() const {
    1.93 +    Handle<Importable> source() {
    1.94          return source_;
    1.95      }
    1.96 -    TokenKind suffix() const {
    1.97 -        return suffix_;
    1.98 +    unsigned importIndex() {
    1.99 +        return importIndex_;
   1.100 +    }
   1.101 +    void setImportIndex(unsigned index) {
   1.102 +        importIndex_ = index;
   1.103      }
   1.104  
   1.105    private:
   1.106      PathComponent *path_;
   1.107 -    TokenKind suffix_;
   1.108 -    TranslationUnit *source_;
   1.109 +    ScopedRoot<Importable> source_;
   1.110 +    unsigned importIndex_;
   1.111  };
   1.112  
   1.113  typedef StructureStatement::FieldList FieldList;