-
Notifications
You must be signed in to change notification settings - Fork 5
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
0 parents
commit 51d705c
Showing
10 changed files
with
122 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty AssemblyScript Project |
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,15 @@ | ||
// ewasm imports | ||
declare function ethereum_return(dataOffset: i32, length: i32): void; | ||
declare function ethereum_revert(dataOffset: i32, length: i32): void; | ||
declare function ethereum_callDataCopy(resultOffset: i32, dataOffset: i32, length: i32): void; | ||
declare function ethereum_callDataSize(): i32; | ||
declare function ethereum_storageStore(pathOffset: i32, valueOffset: i32): void; | ||
declare function ethereum_storageLoad(pathOffset: i32, resultOffset: i32): void; | ||
|
||
// TODO: need to implement a nice wrapper over the native functions which use native types and handle the memory | ||
|
||
// ewasm main function | ||
export function main(): void { | ||
// assume the memory is already expanded.. | ||
ethereum_return(0, ethereum_callDataSize()) | ||
} |
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,6 @@ | ||
{ | ||
"extends": "../node_modules/assemblyscript/std/assembly.json", | ||
"include": [ | ||
"./**/*.ts" | ||
] | ||
} |
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,24 @@ | ||
const gulp = require("gulp"); | ||
|
||
gulp.task("build", callback => { | ||
const asc = require("assemblyscript/bin/asc"); | ||
asc.main([ | ||
"main.ts", | ||
"--baseDir", "assembly", | ||
"--binaryFile", "../out/main.wasm", | ||
"--sourceMap", | ||
"--measure" | ||
], callback); | ||
}); | ||
|
||
gulp.task("default", ["build"]); | ||
|
||
gulp.task("project:load", () => { // WebAssembly Studio only | ||
const utils = require("@wasm/studio-utils"); | ||
utils.eval(utils.project.getFile("setup.js").getData(), { | ||
logLn, | ||
project, | ||
monaco, | ||
fileTypeForExtension, | ||
}); | ||
}); |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
{ | ||
"name": "@wasm/empty_ts", | ||
"description": "", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "gulp" | ||
}, | ||
"devDependencies": { | ||
"assemblyscript": "AssemblyScript/assemblyscript", | ||
"gulp": "^3.9.1" | ||
}, | ||
"wasmStudio": { | ||
"name": "Empty AssemblyScript Project", | ||
"description": "# Empty AssemblyScript Project\n\n[AssemblyScript](https://github.com/AssemblyScript/assemblyscript) compiles strictly typed TypeScript to WebAssembly using Binaryen.\n\nSee the [AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) for further instructions and documentation.", | ||
"icon": "typescript-lang-file-icon" | ||
} | ||
} |
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,33 @@ | ||
// WebAssembly Studio only | ||
require.config({ | ||
paths: { | ||
"binaryen": "https://rawgit.com/AssemblyScript/binaryen.js/master/index", | ||
"assemblyscript": "https://rawgit.com/AssemblyScript/assemblyscript/master/dist/assemblyscript", | ||
"assemblyscript/bin/asc": "https://rawgit.com/AssemblyScript/assemblyscript/master/dist/asc" | ||
} | ||
}); | ||
logLn("Loading AssemblyScript compiler ..."); | ||
require(["assemblyscript/bin/asc"], asc => { | ||
monaco.languages.typescript.typescriptDefaults.addExtraLib(asc.definitionFiles.assembly); | ||
asc.main = (main => (args, options, fn) => { | ||
if (typeof options === "function") { | ||
fn = options; | ||
options = undefined; | ||
} | ||
return main(args, options || { | ||
stdout: asc.createMemoryStream(), | ||
stderr: asc.createMemoryStream(logLn), | ||
readFile: (filename) => { | ||
const file = project.getFile(filename.replace(/^\//, "")); | ||
return file ? file.data : null; | ||
}, | ||
writeFile: (filename, contents) => { | ||
const name = filename.startsWith("/") ? filename.substring(1) : filename; | ||
const type = fileTypeForExtension(name.substring(name.lastIndexOf(".") + 1)); | ||
project.newFile(name, type, true).setData(contents); | ||
}, | ||
listFiles: (dirname) => [] | ||
}, fn); | ||
})(asc.main); | ||
logLn("AssemblyScript compiler is ready!"); | ||
}); |
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,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
<body style="background: #fff"> | ||
<span id="container"></span> | ||
<script src="./main.js"></script> | ||
</body> | ||
</html> |
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,15 @@ | ||
WebAssembly.instantiateStreaming(fetch("../out/main.wasm"), { | ||
env: { | ||
ethereum_callDataSize: function() { | ||
console.log("callDataSize -> 32"); | ||
return 32; | ||
}, | ||
ethereum_return: function(offest, length) { | ||
console.log("return(" + offset + "," + length + ")"); | ||
} | ||
} | ||
}).then(result => { | ||
const exports = result.instance.exports; | ||
exports.main(); | ||
}).catch(console.error); | ||
|