src/compiler/HIR.h
changeset 256 3c184218462d
parent 247 7721042bdb67
child 263 ba85a47ee414
     1.1 --- a/src/compiler/HIR.h	Tue Jan 01 20:08:34 2013 -0800
     1.2 +++ b/src/compiler/HIR.h	Sun Jan 06 13:52:21 2013 -0800
     1.3 @@ -31,6 +31,7 @@
     1.4      _(Integer)                          \
     1.5      _(Float)                            \
     1.6      _(String)                           \
     1.7 +    _(Import)                           \
     1.8      _(Array)                            \
     1.9      _(Store)                            \
    1.10      _(ToRef)                            \
    1.11 @@ -39,6 +40,7 @@
    1.12      _(Index)                            \
    1.13      _(Local)                            \
    1.14      _(Global)                           \
    1.15 +    _(Field)                            \
    1.16      /* End LValues */                   \
    1.17      _(Unary)                            \
    1.18      _(Binary)                           \
    1.19 @@ -184,6 +186,24 @@
    1.20      ScopedRoot<String> string_;
    1.21  };
    1.22  
    1.23 +class HImport : public HIR
    1.24 +{
    1.25 +  public:
    1.26 +    HImport(AstNode *node, Type *type, unsigned index)
    1.27 +      : HIR(node, type),
    1.28 +        index_(index)
    1.29 +    {
    1.30 +    }
    1.31 +
    1.32 +    DEFINE_HIR(Import);
    1.33 +    unsigned index() const {
    1.34 +        return index_;
    1.35 +    }
    1.36 +
    1.37 +  private:
    1.38 +    unsigned index_;
    1.39 +};
    1.40 +
    1.41  class HArray : public HIR
    1.42  {
    1.43    public:
    1.44 @@ -319,6 +339,37 @@
    1.45      HIR *right_;
    1.46  };
    1.47  
    1.48 +class HField : public HLValue
    1.49 +{
    1.50 +  public:
    1.51 +    HField(AstNode *node, HIR *left, Type *type, unsigned index)
    1.52 +      : HLValue(node, type),
    1.53 +        base_(left),
    1.54 +        index_(index)
    1.55 +    {
    1.56 +    }
    1.57 +
    1.58 +    DEFINE_HIR(Field);
    1.59 +
    1.60 +    void bind(HIRVisitor *visitor, BytecodeEmitter &emitter_);
    1.61 +    void hold(BytecodeEmitter &emitter_);
    1.62 +    void swapAndPick(BytecodeEmitter &emitter_);
    1.63 +    void store(BytecodeEmitter &emitter_);
    1.64 +    void load(BytecodeEmitter &emitter_);
    1.65 +    bool ref(BytecodeEmitter &emitter_);
    1.66 +
    1.67 +    HIR *base() const {
    1.68 +        return base_;
    1.69 +    }
    1.70 +    unsigned index() const {
    1.71 +        return index_;
    1.72 +    }
    1.73 +
    1.74 +  private:
    1.75 +    HIR *base_;
    1.76 +    unsigned index_;
    1.77 +};
    1.78 +
    1.79  class HGlobal : public HLValue
    1.80  {
    1.81    public: