Update lib/wamr.js

This commit is contained in:
Namhyeon Go 2022-02-23 17:31:56 +09:00
parent bc88f76d32
commit be87627789
5 changed files with 58 additions and 36 deletions

View File

@ -1,4 +0,0 @@
@echo off
xcopy /s welsonjs\* %SYSTEMDRIVE%\welsonjs\
pushd %SYSTEMDRIVE%\welsonjs
bootstrap.bat

View File

@ -1,2 +0,0 @@
@echo off
copy /b "bin\7zs.sfx" + 7zs_config.txt + "..\\welsonjs.7z" "..\\welsonjs-portable.exe"

View File

@ -1,5 +0,0 @@
;!@Install@!UTF-8!
Title="WelsonJS Portable"
BeginPrompt="Do you want start WelsonJS Potable?"
RunProgram="welsonjs\\bootstrap.bat"
;!@InstallEnd@!

58
lib/wamr.js Normal file
View File

@ -0,0 +1,58 @@
// WAMR for WelsonJS
// - WAMR: https://github.com/bytecodealliance/wasm-micro-runtime
// - WelsonJS: https://github.com/gnh1201/welsonjs
var SHELL = require("lib/shell");
var WAMRObject = function() {
this.binPath = "bin\\iwasm";
this.verbose = 0;
this.stackSize = 0;
this.heapSize = 0;
this.repl = false;
this.env = {};
this.dirs = [];
this.exec = function(f1, f2) {
var cmd = [];
cmd.push(binPath);
if (this.verbose > 0) {
cmd.push("-v=" + this.verbose);
}
if (this.stackSize > 0) {
cmd.push("--stack-size=" + this.stackSize);
}
if (this.heapSize > 0) {
cmd.push("--heap-size=" + this.heapsize);
}
if (Object.keys(env).length > 0) {
for (var k in env) {
cmd.push("--env=\"" + k + "=" + env[k] + "\"");
}
}
if (dirs.length > 0) {
for (var i = 0; i < dirs.length; i++) {
cmd.push("--dir=" + dirs[i]);
}
}
if (typeof f2 !== "undefined") {
cmd.push("--function-name=" + f2);
}
cmd.push(f1);
return SHELL.exec(cmd);
};
};
exports.create = function() {
return new WAMRObject();
};

View File

@ -1,25 +0,0 @@
// WebAssembly Module for WelsonJS (Based on Microsoft JScript)
var WebAssemblyObject = function() {
this.instantiate = function(bufferSource, importObject) {
// ... todo ...
};
this.instantiateStreaming = function(source, importObject) {
// ... todo ...
};
this.compile = function(bufferSource) {
// ... todo ...
};
this.compileStreaming = function(source) {
// ... todo ...
};
this.validate = function(bufferSource) {
// ... todo ...
};
};
exports.WebAssembly = new WebAssemblyObject();