rust contract sample

This commit is contained in:
NikVolf
2017-04-13 01:03:41 +03:00
parent fe575b4eaa
commit 43130dd5c2
2 changed files with 49 additions and 3 deletions
+30 -3
View File
@@ -28,6 +28,16 @@
(import "env" "_abort" (func (;3;) (type 1)))
(import "env" "___setErrNo" (func (;4;) (type 2)))
(import "env" "invoke_vi" (func (;4;) (type 3)))
(import "env" "invoke_v" (func (;5;) (type 1)))
(import "env" "_rust_begin_unwind" (func (;6;) (type 4)))
(import "env" "_emscripten_memcpy_big" (func (;9;) (type 5)))
(import "env" "___gxx_personality_v0" (func (;10;) (type 6)))
(import "env" "_llvm_trap" (func (;11;) (type 0)))
(import "env" "___resumeException" (func (;12;) (type 1)))
(import "env" "___cxa_find_matching_catch_2" (func (;13;) (type 2)))
(import "env" "___gxx_personality_v0" (func (;14;) (type 7)))
(import "env" "memory" (memory (;0;) 256 256))
(import "env" "table" (table (;0;) 0 0 anyfunc))
(import "env" "memoryBase" (global (;3;) i32))
@@ -40,8 +50,25 @@
env.enlargeMemory = env.enlargeMemory || function() { throw "error enlarging memory"; };
env.getTotalMemory = env.getTotalMemory || function() { return 65536 * 256; };
env.abortOnCannotGrowMemory = env.abortOnCannotGrowMemory || function() { throw "abort growing memory"; };
env._abort = env.abortOnCannotGrowMemory || function() { throw "abort"; };
env.___setErrNo = env.abortOnCannotGrowMemory || function() { throw "setting error no"; };
env._abort = env._abort || function() { throw "_abort"; };
env.abort = env.abort || function() { throw "abort"; };
env.___setErrNo = env.___setErrNo || function() { throw "setting error no"; };
// dead symbols in rust wasm32-unknown-emscripten target
// todo: strip/raise issue in rust compiler
env.invoke_vi = function() { throw "invoke_vi: unreachable!"; }
env.invoke_v = function() { throw "invoke_v: unreachable!"; }
// todo: also test unwind about those two
env._rust_begin_unwind = function() { throw "_rust_begin_unwind: unreachable!"; }
env._llvm_trap = function() { throw "_llvm_trap: unreachable!"; }
env._emscripten_memcpy_big = function() { throw "_emscripten_memcpy_big: unreachable!"; }
env.___gxx_personality_v0 = function() { throw "___gxx_personality_v0: unreachable!"; }
env.___resumeException = function() { throw "___resumeException: unreachable!"; }
env.___cxa_find_matching_catch_2 = function() { throw "___cxa_find_matching_catch_2: unreachable!"; }
env.___gxx_personality_v0 = function() { throw "___gxx_personality_v0: unreachable!"; }
env.memoryBase = env.memoryBase || 0;
env.tableBase = env.tableBase || 0;
@@ -53,7 +80,7 @@
imports.env.memory = new WebAssembly.Memory({ initial: 256, maximum: 256 });
}
if (!imports.env.table) {
imports.env.table = new WebAssembly.Table({ initial: 0, maximum: 0, element: 'anyfunc' });
imports.env.table = new WebAssembly.Table({ initial: 8, maximum: 8, element: 'anyfunc' });
}
return new WebAssembly.Instance(module, imports);
});