diff options
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/preamble.js b/src/preamble.js index 103b786d..f19a68f1 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -752,6 +752,25 @@ function intArrayToString(array) { } Module['intArrayToString'] = intArrayToString; +// Write a Javascript array to somewhere in the heap +function writeStringToMemory(string, buffer, dontAddNull) { + var i = 0; + while (i < string.length) { + var chr = string.charCodeAt(i); + if (chr > 0xFF) { +#if ASSERTIONS + assert(false, 'Character code ' + chr + ' (' + string[i] + ') at offset ' + i + ' not in 0x00-0xFF.'); +#endif + chr &= 0xFF; + } + {{{ makeSetValue('buffer', 'i', 'chr', 'i8') }}} + i = i + 1; + } + if (!dontAddNull) { + {{{ makeSetValue('buffer', 'i', '0', 'i8') }}} + } +} + {{{ unSign }}} {{{ reSign }}} |