aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/llex.js7
-rw-r--r--src/lzio.js5
2 files changed, 8 insertions, 4 deletions
diff --git a/src/llex.js b/src/llex.js
index 5bcd744..779557a 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -237,7 +237,7 @@ const read_numeral = function(ls, seminfo) {
// save(ls, 0);
let obj = new lobject.TValue();
- if (lobject.luaO_str2num(ls.buff.buffer, obj) === 0) /* format error? */
+ if (lobject.luaO_str2num(lzio.luaZ_buffer(ls.buff), obj) === 0) /* format error? */
lexerror(ls, defs.to_luastring("malformed number", true), R.TK_FLT);
if (obj.ttisinteger()) {
seminfo.i = obj.value;
@@ -254,7 +254,7 @@ const txtToken = function(ls, token) {
case R.TK_NAME: case R.TK_STRING:
case R.TK_FLT: case R.TK_INT:
// save(ls, 0);
- return lobject.luaO_pushfstring(ls.L, defs.to_luastring("'%s'", true), ls.buff.buffer);
+ return lobject.luaO_pushfstring(ls.L, defs.to_luastring("'%s'", true), lzio.luaZ_buffer(ls.buff));
default:
return luaX_token2str(ls, token);
}
@@ -561,8 +561,7 @@ const llex = function(ls, seminfo) {
do {
save_and_next(ls);
} while (ljstype.lislalnum(ls.current));
-
- let ts = luaX_newstring(ls, ls.buff.buffer);
+ let ts = luaX_newstring(ls, lzio.luaZ_buffer(ls.buff));
seminfo.ts = ts;
let kidx = token_to_index[lstring.luaS_hashlongstr(ts)];
if (kidx !== void 0 && kidx <= 22) /* reserved word? */
diff --git a/src/lzio.js b/src/lzio.js
index 9aa25bd..3d877aa 100644
--- a/src/lzio.js
+++ b/src/lzio.js
@@ -10,6 +10,10 @@ class MBuffer {
}
}
+const luaZ_buffer = function(buff) {
+ return buff.buffer;
+};
+
const luaZ_buffremove = function(buff, i) {
buff.n -= i;
};
@@ -84,6 +88,7 @@ const luaZ_read = function(z, b, b_offset, n) {
};
module.exports.EOZ = EOZ;
+module.exports.luaZ_buffer = luaZ_buffer;
module.exports.luaZ_buffremove = luaZ_buffremove;
module.exports.luaZ_fill = luaZ_fill;
module.exports.luaZ_read = luaZ_read;