forked from AssemblyScript/assemblyscript
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ef003c
commit 10aca34
Showing
11 changed files
with
2,742 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// @ts-ignore: decorator | ||
@builtin | ||
export declare const __memory_base: usize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
exports.preInstantiate = function(imports, exports) { | ||
exports.preInstantiate = function (imports, exports) { | ||
// compiler generates initial = 1 because it doesn't know the imported value | ||
// of env.memory_base yet, hence we need to import a suitable memory as well: | ||
imports["env"] = { | ||
"abort": (mesg, file, line, colm) => { | ||
console.log("abort", mesg, file, line, colm) | ||
assert(false, "abort was called") | ||
|
||
}, | ||
"memory": new WebAssembly.Memory({ initial: 2 }), | ||
"memory_base": 2, | ||
"memory_base": 1000, | ||
"table_base": 100, | ||
"log":(offset,length)=>{ | ||
let view=new Uint16Array(imports["env"].memory.buffer,offset,length) | ||
let str=String.fromCharCode.apply(null,view) | ||
assert(str==="relocatable",`expected relocatable got'${str}' at index ${offset}`) | ||
"log": (offset, length) => { | ||
imports["env"].checkPtr(offset) | ||
let view = new Uint16Array(imports["env"].memory.buffer, offset, length) | ||
let str = String.fromCharCode.apply(null, view) | ||
console.log("val",offset,length,str) | ||
assert(str === "relocatable", `expected relocatable got'${str}' at index ${offset} with length ${length}`) | ||
}, | ||
"checkPtr":(offset)=>{ | ||
assert(offset>imports["env"].memory_base, `offset ${offset} is less than memory_base ${imports["env"].memory_base}`) | ||
} | ||
}; | ||
}; | ||
|
||
exports.postInstantiate=function(instance){ | ||
exports.postInstantiate = function (instance) { | ||
instance.exports.main() | ||
} |
Oops, something went wrong.