summaryrefslogtreecommitdiff
path: root/src/lparser.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 10:23:32 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 10:56:03 +0100
commitae8b95ee9c3871f506b20c74367fdc9e8cb098e2 (patch)
tree6348ab52aad93905af66196f5d071628ac60adb5 /src/lparser.js
parent74dda64eab7951da520dc451a1f3bbb8c7d62706 (diff)
downloadfengari-ae8b95ee9c3871f506b20c74367fdc9e8cb098e2.tar.gz
fengari-ae8b95ee9c3871f506b20c74367fdc9e8cb098e2.tar.bz2
fengari-ae8b95ee9c3871f506b20c74367fdc9e8cb098e2.zip
lua_load will load both binary and text
Diffstat (limited to 'src/lparser.js')
-rw-r--r--src/lparser.js44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/lparser.js b/src/lparser.js
index 074542a..40d6c88 100644
--- a/src/lparser.js
+++ b/src/lparser.js
@@ -7,7 +7,7 @@ const lfunc = require('./lfunc.js');
const llex = require('./llex.js');
const llimit = require('./llimit.js');
const lobject = require('./lobject.js');
-const lopcode = require('./lopcode.js');
+const lopcode = require('./lopcodes.js');
const lua = require('./lua.js');
const BinOpr = lcode.BinOpr;
const CT = lua.constants_type;
@@ -106,6 +106,47 @@ class FuncState {
}
}
+ /* description of active local variable */
+class Vardesc {
+ constructor() {
+ this.idx = NaN; /* variable index in stack */
+ }
+}
+
+
+/* description of pending goto statements and label statements */
+class Labeldesc {
+ constructor() {
+ this.name = null; /* label identifier */
+ this.pc = NaN; /* position in code */
+ this.line = NaN; /* line where it appeared */
+ this.nactvar = NaN; /* local level where it appears in current block */
+ }
+}
+
+
+/* list of labels or gotos */
+class Labellist {
+ constructor() {
+ this.arr = []; /* array */
+ this.n = NaN; /* number of entries in use */
+ this.size = NaN; /* array size */
+ }
+}
+
+/* dynamic structures used by the parser */
+class Dyndata {
+ constructor() {
+ this.actvar = { /* list of active local variables */
+ arr: [],
+ n: NaN,
+ size: NaN
+ };
+ this.gt = new Labellist();
+ this.label = new Labellist();
+ }
+}
+
const semerror = function(ls, msg) {
ls.t.token = 0; /* remove "near <token>" from final message */
llex.luaX_syntaxerror(ls, msg);
@@ -1511,6 +1552,7 @@ const luaY_parser = function(L, z, buff, dyd, name, firstchar) {
};
+module.exports.Dyndata = Dyndata;
module.exports.expkind = expkind;
module.exports.luaY_parser = luaY_parser;
module.exports.vkisinreg = vkisinreg; \ No newline at end of file