1.1 --- a/src/compiler/HIR.cpp Sun Nov 18 22:18:23 2012 -0800
1.2 +++ b/src/compiler/HIR.cpp Mon Nov 19 01:13:44 2012 -0800
1.3 @@ -115,8 +115,14 @@
1.4 void
1.5 HLocal::bind(HIRVisitor *visitor, BytecodeEmitter &emitter_)
1.6 {
1.7 - if (sym_->type()->isReference())
1.8 - __ getlocal(sym_);
1.9 + if (sym_->type()->isReference()) {
1.10 + if (sym_->storage() == VariableSymbol::Local)
1.11 + __ getlocal(sym_);
1.12 + else if (sym_->storage() == VariableSymbol::Arg)
1.13 + __ getarg(sym_);
1.14 + else
1.15 + assert(false);
1.16 + }
1.17 }
1.18
1.19 void
1.20 @@ -140,10 +146,16 @@
1.21 void
1.22 HLocal::store(BytecodeEmitter &emitter_)
1.23 {
1.24 - if (sym_->type()->isReference())
1.25 + if (sym_->type()->isReference()) {
1.26 __ setref(sym_->type()->contained_ref());
1.27 - else
1.28 - __ setlocal(sym_);
1.29 + } else {
1.30 + if (sym_->storage() == VariableSymbol::Local)
1.31 + __ setlocal(sym_);
1.32 + else if (sym_->storage() == VariableSymbol::Arg)
1.33 + __ setarg(sym_);
1.34 + else
1.35 + assert(false);
1.36 + }
1.37 }
1.38
1.39 void
1.40 @@ -151,8 +163,12 @@
1.41 {
1.42 if (sym_->type()->isReference())
1.43 __ getref(sym_->type());
1.44 + else if (sym_->storage() == VariableSymbol::Local)
1.45 + __ getlocal(sym_);
1.46 + else if (sym_->storage() == VariableSymbol::Arg)
1.47 + __ getarg(sym_);
1.48 else
1.49 - __ getlocal(sym_);
1.50 + assert(false);
1.51 }
1.52
1.53 void
1.54 @@ -206,7 +222,8 @@
1.55 void
1.56 HIRTranslator::visitGlobal(HGlobal *global)
1.57 {
1.58 - __ getglobal(global->sym());
1.59 + global->bind(this, emitter_);
1.60 + global->load(emitter_);
1.61 }
1.62
1.63 static inline Opcode