void Executor::ExecArrayRead(MethodFrame *frame, Insn *insn) { int index = frame->reg_values_[insn->src_regs_[0]->id_].num_.int_part; if (insn->obj_reg_) { Object *array_obj = frame->reg_values_[insn->obj_reg_->id_].object_; CHECK(array_obj); CHECK(ArrayWrapper::IsIntArray(array_obj)); IntArray *array = ArrayWrapper::GetIntArray(array_obj); frame->reg_values_[insn->dst_regs_[0]->id_].num_ = array->Read(index); frame->reg_values_[insn->dst_regs_[0]->id_].num_.type = array->GetWidth(); } else { // local array. CHECK(insn->src_regs_.size() == 2); Value &array = frame->reg_values_[insn->src_regs_[1]->id_]; Value &index = frame->reg_values_[insn->src_regs_[0]->id_]; frame->reg_values_[insn->dst_regs_[0]->id_].num_ = array.local_int_array_->Read(numeric::Numeric::GetInt(index.num_)); frame->reg_values_[insn->dst_regs_[0]->id_].type_ = Value::NUM; } }
void Executor::MemoryRead(int addr, numeric::Number *res) { IntArray *mem = thr_->GetVM()->GetDefaultMemory(); *res = mem->Read(addr); }