Closed
Description
Hi,
I am using AssemblyScript to convert my RLE decode code written in TypeScript to WebAssembly.
This is what I did,
- This is my decodeRLE code which is in my index.ts file which I am trying to convert to wasm.
export function decodeRLE(encodedBuffer: Uint8Array): Uint8Array {
var decodedBuffer = [];
var encoderDataLength = encodedBuffer.byteLength;
var pos = 8;
let isRip: boolean;
let isRun: boolean;
let ripCount: number;
let runCount: number;
while (pos < encoderDataLength)
{
var cmd: number = getInt8(encodedBuffer[pos]);
isRip= cmd<0;
isRun= cmd>0;
if(cmd<0){ // rip
cmd=Math.abs(cmd);
pos+=1;
var posIndex = pos;
for (var i = 0; i < cmd; i++)
{
var myvalue = encodedBuffer[posIndex];
decodedBuffer.push(myvalue);
posIndex++;
}
pos+=cmd;
}
else // run
{
cmd +=2;
var v =encodedBuffer[pos + 1];
if(v != 0)
{
for (var j = 0; j < cmd; j++) {
decodedBuffer.push(v)
};
}
else
{
for (var j = 0; j < cmd; j++) {
decodedBuffer.push(0)
};
}
pos+=2;
}
};
return decodedBuffer;
}
- Errors:
ERROR AS100: Operation not supported.
var decodedBuffer = [];
in assembly/index.ts(97,24)
ERROR TS2339: Property 'push' does not exist on type 'i32'.
decodedBuffer.push(myvalue);
in assembly/index.ts(116,24)
ERROR AS200: Conversion from type 'f64' to 'i32' requires an explicit cast.
pos+=cmd;
in assembly/index.ts(119,13)
I would like to know how we can create a array (UInt8Array) in AssemblyScript? I aso want to return the created array back to consumers of my WASM. So that I can move the decode code to WASM.
Thanks
Basanth
Metadata
Metadata
Assignees
Labels
No labels