Respect current byteOffset in Array#subarray (#329)

This commit is contained in:
Linus Unnebäck
2018-11-09 11:29:39 +00:00
committed by Daniel Wirtz
parent 4f95dce6e2
commit 63b64ba69e
3 changed files with 272 additions and 1 deletions

View File

@ -90,7 +90,7 @@ export abstract class TypedArray<T,V> {
else end = max(min(end, length), begin);
var slice = memory.allocate(offsetof<this>());
store<usize>(slice, this.buffer, offsetof<this>("buffer"));
store<i32>(slice, begin << alignof<T>(), offsetof<this>("byteOffset"));
store<i32>(slice, this.byteOffset + (begin << alignof<T>()), offsetof<this>("byteOffset"));
store<i32>(slice, (end - begin) << alignof<T>(), offsetof<this>("byteLength"));
return changetype<this>(slice);
}