summaryrefslogtreecommitdiff
path: root/src/lua.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann@users.noreply.github.com>2017-03-01 11:54:57 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 12:19:22 +0100
commit166b951b9d05eff654ef664124f17c8a37f418a6 (patch)
treea783d5f05cd640d06065c514b87bc7cf74f5e506 /src/lua.js
parent94a301a27a8a75c4684790a99a898262b8354f68 (diff)
parent444182dbbb18f44cf7cafc378f092c28006be365 (diff)
downloadfengari-166b951b9d05eff654ef664124f17c8a37f418a6.tar.gz
fengari-166b951b9d05eff654ef664124f17c8a37f418a6.tar.bz2
fengari-166b951b9d05eff654ef664124f17c8a37f418a6.zip
Merge pull request #2 from giann/feature/lex-parse
Lexing & Parsing
Diffstat (limited to 'src/lua.js')
-rw-r--r--src/lua.js73
1 files changed, 58 insertions, 15 deletions
diff --git a/src/lua.js b/src/lua.js
index c7d1fd7..ef5385c 100644
--- a/src/lua.js
+++ b/src/lua.js
@@ -5,6 +5,9 @@ const assert = require('assert');
const lualib = require('./lualib.js');
const luaconf = require('./luaconf.js');
+/* mark for precompiled code ('<esc>Lua') */
+const LUA_SIGNATURE = "\x1bLua";
+
const LUA_VERSION_MAJOR = "5";
const LUA_VERSION_MINOR = "3";
const LUA_VERSION_NUM = 503;
@@ -25,8 +28,10 @@ const FENGARI_RELEASE = FENGARI_VERSION + "." + FENGARI_VERSION_RELEASE;
const FENGARI_COPYRIGHT = FENGARI_RELEASE + " Copyright (C) 2017 BenoƮt Giannangeli\nBased on: " + LUA_COPYRIGHT;
const FENGARI_AUTHORS = "B. Giannangeli";
+const LUA_VERSUFFIX = "_" + LUA_VERSION_MAJOR + "_" + LUA_VERSION_MINOR;
+
const LUA_INIT_VAR = "LUA_INIT";
-const LUA_INITVARVERSION = LUA_INIT_VAR + lualib.LUA_VERSUFFIX;
+const LUA_INITVARVERSION = LUA_INIT_VAR + LUA_VERSUFFIX;
const thread_status = {
LUA_OK: 0,
@@ -52,6 +57,8 @@ const constant_types = {
LUA_NUMTAGS: 9
};
+const CT = constant_types;
+
constant_types.LUA_TSHRSTR = constant_types.LUA_TSTRING | (0 << 4); /* short strings */
constant_types.LUA_TLNGSTR = constant_types.LUA_TSTRING | (1 << 4); /* long strings */
@@ -62,6 +69,25 @@ constant_types.LUA_TLCL = constant_types.LUA_TFUNCTION | (0 << 4); /* Lua closu
constant_types.LUA_TLCF = constant_types.LUA_TFUNCTION | (1 << 4); /* light C function */
constant_types.LUA_TCCL = constant_types.LUA_TFUNCTION | (2 << 4); /* C closure */
+/*
+** Comparison and arithmetic functions
+*/
+
+const LUA_OPADD = 0; /* ORDER TM, ORDER OP */
+const LUA_OPSUB = 1;
+const LUA_OPMUL = 2;
+const LUA_OPMOD = 3;
+const LUA_OPPOW = 4;
+const LUA_OPDIV = 5;
+const LUA_OPIDIV = 6;
+const LUA_OPBAND = 7;
+const LUA_OPBOR = 8;
+const LUA_OPBXOR = 9;
+const LUA_OPSHL = 10;
+const LUA_OPSHR = 11;
+const LUA_OPUNM = 12;
+const LUA_OPBNOT = 13;
+
const LUA_OPEQ = 0;
const LUA_OPLT = 1;
const LUA_OPLE = 2;
@@ -87,25 +113,26 @@ const print_version = function() {
class lua_Debug {
constructor() {
- // int event;
- // const char *name; /* (n) */
- // const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
- // const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
- // const char *source; /* (S) */
- // int currentline; /* (l) */
- // int linedefined; /* (S) */
- // int lastlinedefined; /* (S) */
- // unsigned char nups; /* (u) number of upvalues */
- // unsigned char nparams;/* (u) number of parameters */
- // char isvararg; /* (u) */
- // char istailcall; /* (t) */
- // char short_src[LUA_IDSIZE]; /* (S) */
+ this.event = NaN;
+ this.name = null; /* (n) */
+ this.namewhat = null; /* (n) 'global', 'local', 'field', 'method' */
+ this.what = null; /* (S) 'Lua', 'C', 'main', 'tail' */
+ this.source = null; /* (S) */
+ this.currentline = NaN; /* (l) */
+ this.linedefined = NaN; /* (S) */
+ this.lastlinedefined = NaN; /* (S) */
+ this.nups = NaN; /* (u) number of upvalues */
+ this.nparams = NaN; /* (u) number of parameters */
+ this.isvararg = NaN; /* (u) */
+ this.istailcall = NaN; /* (t) */
+ this.short_src = null; /* (S) */
/* private part */
- // struct CallInfo *i_ci; /* active function */
+ this.i_ci = null; /* active function */
}
}
+module.exports.CT = CT;
module.exports.FENGARI_AUTHORS = FENGARI_AUTHORS;
module.exports.FENGARI_COPYRIGHT = FENGARI_COPYRIGHT;
module.exports.FENGARI_RELEASE = FENGARI_RELEASE;
@@ -121,19 +148,35 @@ module.exports.LUA_INIT_VAR = LUA_INIT_VAR;
module.exports.LUA_MINSTACK = LUA_MINSTACK;
module.exports.LUA_MULTRET = -1;
module.exports.LUA_NUMTAGS = LUA_NUMTAGS;
+module.exports.LUA_OPADD = LUA_OPADD;
+module.exports.LUA_OPBAND = LUA_OPBAND;
+module.exports.LUA_OPBNOT = LUA_OPBNOT;
+module.exports.LUA_OPBOR = LUA_OPBOR;
+module.exports.LUA_OPBXOR = LUA_OPBXOR;
+module.exports.LUA_OPDIV = LUA_OPDIV;
module.exports.LUA_OPEQ = LUA_OPEQ;
+module.exports.LUA_OPIDIV = LUA_OPIDIV;
module.exports.LUA_OPLE = LUA_OPLE;
module.exports.LUA_OPLT = LUA_OPLT;
+module.exports.LUA_OPMOD = LUA_OPMOD;
+module.exports.LUA_OPMUL = LUA_OPMUL;
+module.exports.LUA_OPPOW = LUA_OPPOW;
+module.exports.LUA_OPSHL = LUA_OPSHL;
+module.exports.LUA_OPSHR = LUA_OPSHR;
+module.exports.LUA_OPSUB = LUA_OPSUB;
+module.exports.LUA_OPUNM = LUA_OPUNM;
module.exports.LUA_REGISTRYINDEX = LUA_REGISTRYINDEX;
module.exports.LUA_RELEASE = LUA_RELEASE;
module.exports.LUA_RIDX_GLOBALS = LUA_RIDX_GLOBALS;
module.exports.LUA_RIDX_LAST = LUA_RIDX_LAST;
module.exports.LUA_RIDX_MAINTHREAD = LUA_RIDX_MAINTHREAD;
+module.exports.LUA_SIGNATURE = LUA_SIGNATURE;
module.exports.LUA_VERSION = LUA_VERSION;
module.exports.LUA_VERSION_MAJOR = LUA_VERSION_MAJOR;
module.exports.LUA_VERSION_MINOR = LUA_VERSION_MINOR;
module.exports.LUA_VERSION_NUM = LUA_VERSION_NUM;
module.exports.LUA_VERSION_RELEASE = LUA_VERSION_RELEASE;
+module.exports.LUA_VERSUFFIX = LUA_VERSUFFIX;
module.exports.constant_types = constant_types;
module.exports.lua_Debug = lua_Debug;
module.exports.lua_upvalueindex = lua_upvalueindex;