Correct how slices are iterated over

This commit fixes how the `getArrayJsValueFromWasm` function is defined to
correctly iterate over the slice by looking at the values rather than the
indices.

Closes #169
This commit is contained in:
Alex Crichton
2018-04-25 21:57:44 -07:00
parent b2ecf56cb6
commit faed98b843
2 changed files with 36 additions and 3 deletions

View File

@ -225,7 +225,6 @@ impl<'a> Context<'a> {
Ok(format!("
function(ptr, len) {{
let a;
console.log(ptr, len);
if (ptr === 0) {{
a = Symbol();
}} else {{
@ -889,8 +888,8 @@ impl<'a> Context<'a> {
const mem = getUint32Memory();
const slice = mem.slice(ptr / 4, ptr / 4 + len);
const result = [];
for (ptr in slice) {{
result.push(getObject(ptr))
for (let i = 0; i < slice.length; i++) {{
result.push(getObject(slice[i]))
}}
return result;
}}