Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kubo39 committed May 5, 2024
1 parent 33c97b9 commit 15b5a39
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions source/execution/runtime.d
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,19 @@ private:
stack_unwind(this.stack, frame.sp, frame.arity);
},
(I32Store i32store) {
const value_ = this.stack.back;
this.stack.popBack();
const valueAddr = this.stack.back;
const value = this.stack.back.match!(
(I32 i32) => i32.i,
_ => assert(false)
);
this.stack.popBack();
const addr = cast(size_t) valueAddr.match!(
(I32 value) => value.i,
const addr = this.stack.back.match!(
(I32 value) => size_t(value.i),
_ => assert(false)
);
const offset = cast(size_t) i32store.offset;
this.stack.popBack();
const offset = size_t(i32store.offset);
const at = addr + offset;
auto memory = this.store.memories[0];
const int value = value_.match!(
(I32 i32) => i32.i,
_ => assert(false)
);
memory.data.write!(int, Endian.littleEndian)(value, at);
},
(I32Const i32const) {
Expand Down Expand Up @@ -283,10 +281,7 @@ public:
(binary.types.Func func) => func.idx
);
const funcInst = this.store.funcs[idx];
foreach (arg; args)
{
this.stack ~= arg;
}
this.stack ~= args;
return funcInst.match!(
(InternalFuncInst func) => invokeInternal(func),
(ExternalFuncInst func) => invokeExternal(func),
Expand Down

0 comments on commit 15b5a39

Please sign in to comment.