src/compiler/HIR.cpp
changeset 256 3c184218462d
parent 247 7721042bdb67
child 263 ba85a47ee414
     1.1 --- a/src/compiler/HIR.cpp	Tue Jan 01 20:08:34 2013 -0800
     1.2 +++ b/src/compiler/HIR.cpp	Sun Jan 06 13:52:21 2013 -0800
     1.3 @@ -50,9 +50,11 @@
     1.4      void visitGlobal(HGlobal *global);
     1.5      void visitConvert(HConvert *convert);
     1.6      void visitIndex(HIndex *index);
     1.7 +    void visitField(HField *field);
     1.8      void visitPostIncDec(HPostIncDec *hir);
     1.9      void visitToRef(HToRef *hir);
    1.10      void visitNewDependentArray(HNewDependentArray *hir);
    1.11 +    void visitImport(HImport *import);
    1.12  
    1.13    private:
    1.14      Zone *zone_;
    1.15 @@ -286,6 +288,45 @@
    1.16  }
    1.17  
    1.18  void
    1.19 +HField::bind(HIRVisitor *visitor, BytecodeEmitter &emitter_)
    1.20 +{
    1.21 +    __ note_position(node()->pos());
    1.22 +    base_->accept(visitor);
    1.23 +}
    1.24 +
    1.25 +void
    1.26 +HField::hold(BytecodeEmitter &emitter_)
    1.27 +{
    1.28 +    __ dup();
    1.29 +}
    1.30 +
    1.31 +void
    1.32 +HField::swapAndPick(BytecodeEmitter &emitter_)
    1.33 +{
    1.34 +    // BASE VALUE
    1.35 +    __ swap();      // VALUE BASE
    1.36 +    __ pick2();     // VALUE BASE VALUE
    1.37 +}
    1.38 +
    1.39 +void
    1.40 +HField::store(BytecodeEmitter &emitter_)
    1.41 +{
    1.42 +    __ setfield(index_, type());
    1.43 +}
    1.44 +
    1.45 +void
    1.46 +HField::load(BytecodeEmitter &emitter_)
    1.47 +{
    1.48 +    __ getfield(index_, type());
    1.49 +}
    1.50 +
    1.51 +bool
    1.52 +HField::ref(BytecodeEmitter &emitter_)
    1.53 +{
    1.54 +    return false;
    1.55 +}
    1.56 +
    1.57 +void
    1.58  HIRTranslator::visitLocal(HLocal *local)
    1.59  {
    1.60      local->bind(this, emitter_);
    1.61 @@ -300,6 +341,13 @@
    1.62  }
    1.63  
    1.64  void
    1.65 +HIRTranslator::visitField(HField *field)
    1.66 +{
    1.67 +    field->bind(this, emitter_);
    1.68 +    field->load(emitter_);
    1.69 +}
    1.70 +
    1.71 +void
    1.72  HIRTranslator::visitGlobal(HGlobal *global)
    1.73  {
    1.74      global->bind(this, emitter_);
    1.75 @@ -486,11 +534,6 @@
    1.76  
    1.77      Local<ArrayType> type(zone_, ArrayType::cast(hir->type()));
    1.78  
    1.79 -    // Attach an actual map to the dependent type, in case it's a new
    1.80 -    // type.
    1.81 -    if (!ArrayMap::Attach(zone_, type))
    1.82 -        return;
    1.83 -
    1.84      // The dependent map is used for the opcode, but is not attached.
    1.85      Local<ArrayMap> map(zone_, ArrayMap::NewDependent(zone_, type));
    1.86      if (!map)
    1.87 @@ -500,6 +543,12 @@
    1.88  }
    1.89  
    1.90  void
    1.91 +HIRTranslator::visitImport(HImport *import)
    1.92 +{
    1.93 +    __ import(import->index());
    1.94 +}
    1.95 +
    1.96 +void
    1.97  ke::EmitHIR(Zone *zone, BytecodeEmitter &emitter, HIR *hir)
    1.98  {
    1.99      HIRTranslator translator(zone, emitter);