aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-10-09 17:02:08 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-10-09 17:02:08 +0800
commitc49bd0cb2bcec4c75cc1a50de775635e8d33ee66 (patch)
tree60b7b9d4ceb903aa240d031fdad9c42656ae2537
parent98b470b913e71055f594b33429cb27e573811bfc (diff)
downloaddexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.tar
dexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.tar.gz
dexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.tar.bz2
dexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.tar.lz
dexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.tar.xz
dexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.tar.zst
dexon-bls-c49bd0cb2bcec4c75cc1a50de775635e8d33ee66.zip
[js] use funcions in preamble.js
-rw-r--r--docs/demo/bls.js33
1 files changed, 11 insertions, 22 deletions
diff --git a/docs/demo/bls.js b/docs/demo/bls.js
index 4f6c21b..f4cbb9f 100644
--- a/docs/demo/bls.js
+++ b/docs/demo/bls.js
@@ -32,10 +32,11 @@ function define_bls_extra_functions(mod) {
throw('err gen_str:' + x)
}
if (doesReturnString) {
- let s = ''
- for (let i = 0; i < n; i++) {
- s += String.fromCharCode(mod.HEAP8[pos + i])
- }
+// let s = ''
+// for (let i = 0; i < n; i++) {
+// s += String.fromCharCode(mod.HEAP8[pos + i])
+// }
+ let s = mod.Pointer_stringify(pos, n)
mod.Runtime.stackRestore(stack)
return s
} else {
@@ -56,13 +57,9 @@ function define_bls_extra_functions(mod) {
let stack = mod.Runtime.stackSave()
let pos = mod.Runtime.stackAlloc(buf.length)
if (typeof(buf) == "string") {
- for (let i = 0; i < buf.length; i++) {
- mod.HEAP8[pos + i] = buf.charCodeAt(i)
- }
+ mod.writeAsciiToMemory(buf, pos)
} else {
- for (let i = 0; i < buf.length; i++) {
- mod.HEAP8[pos + i] = buf[i]
- }
+ mod.writeArrayToMemory(pos, buf)
}
let r = func(pos, buf.length, ioMode)
mod.Runtime.stackRestore(stack)
@@ -75,13 +72,9 @@ function define_bls_extra_functions(mod) {
let stack = mod.Runtime.stackSave()
let pos = mod.Runtime.stackAlloc(buf.length)
if (typeof(buf) == "string") {
- for (let i = 0; i < buf.length; i++) {
- mod.HEAP8[pos + i] = buf.charCodeAt(i)
- }
+ mod.writeAsciiToMemory(buf, pos)
} else {
- for (let i = 0; i < buf.length; i++) {
- mod.HEAP8[pos + i] = buf[i]
- }
+ mod.writeArrayToMemory(pos, buf)
}
let r = func(x1, pos, buf.length, ioMode)
mod.Runtime.stackRestore(stack)
@@ -94,13 +87,9 @@ function define_bls_extra_functions(mod) {
let stack = mod.Runtime.stackSave()
let pos = mod.Runtime.stackAlloc(buf.length)
if (typeof(buf) == "string") {
- for (let i = 0; i < buf.length; i++) {
- mod.HEAP8[pos + i] = buf.charCodeAt(i)
- }
+ mod.writeAsciiToMemory(buf, pos)
} else {
- for (let i = 0; i < buf.length; i++) {
- mod.HEAP8[pos + i] = buf[i]
- }
+ mod.writeArrayToMemory(pos, buf)
}
let r = func(x1, x2, pos, buf.length, ioMode)
mod.Runtime.stackRestore(stack)