From abb44782d19e07fe231762c1cb0e71263283ca27 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Fri, 29 May 2026 17:01:17 +0100 Subject: [PATCH 01/11] Working towards exporting correct members --- babel.config.cjs | 5 + eslint.config.js | 23 + jest.config.cjs | 201 +++++ package.json | 7 +- src/defs.js | 289 +++---- src/fengari.js | 34 +- src/fengaricore.js | 47 +- src/fengarilib.js | 40 +- src/lapi.js | 758 ++++++++--------- src/lauxlib.js | 401 ++++----- src/lbaselib.js | 201 +++-- src/lcode.js | 478 +++++------ src/lcorolib.js | 75 +- src/ldblib.js | 191 ++--- src/ldebug.js | 355 ++++---- src/ldo.js | 328 +++---- src/ldump.js | 34 +- src/lfunc.js | 15 +- src/linit.js | 41 +- src/liolib.js | 91 +- src/ljstype.js | 11 +- src/llex.js | 203 ++--- src/llimits.js | 17 +- src/lmathlib.js | 114 ++- src/loadlib.js | 192 ++--- src/lobject.js | 175 ++-- src/lopcodes.js | 165 ++-- src/loslib.js | 151 ++-- src/lparser.js | 206 ++--- src/lstate.js | 87 +- src/lstring.js | 31 +- src/lstrlib.js | 255 +++--- src/ltable.js | 92 +- src/ltablib.js | 109 +-- src/ltm.js | 121 ++- src/lua.js | 198 +---- src/luaconf.js | 160 ++-- src/lualib.js | 88 +- src/lundump.js | 141 ++-- src/lutf8lib.js | 68 +- src/lvm.js | 1269 ++++++++++++++-------------- src/lzio.js | 20 +- test/defs.test.js | 91 +- test/lapi.test.js | 136 +-- test/lauxlib.test.js | 12 +- test/lbaselib.test.js | 58 +- test/lcorolib.test.js | 18 +- test/ldblib.test.js | 46 +- test/ldebug.test.js | 32 +- test/lexparse.test.js | 142 ++-- test/lmathlib.test.js | 34 +- test/load.test.js | 34 +- test/loadlib.test.js | 18 +- test/loslib.test.js | 24 +- test/lstrlib.test.js | 116 +-- test/ltablib.test.js | 22 +- test/ltm.test.js | 82 +- test/lua.test.js | 12 +- test/lutf8lib.test.js | 24 +- test/lvm.test.js | 96 +-- test/manual-tests/debug-cli.js | 4 +- test/test-suite/api.test.js | 196 ++--- test/test-suite/attrib.test.js | 32 +- test/test-suite/bitwise.test.js | 36 +- test/test-suite/calls.test.js | 68 +- test/test-suite/closure.test.js | 36 +- test/test-suite/code.test.js | 60 +- test/test-suite/constructs.test.js | 18 +- test/test-suite/coroutine.test.js | 148 ++-- test/test-suite/db.test.js | 116 +-- test/test-suite/errors.test.js | 146 ++-- test/test-suite/events.test.js | 56 +- test/test-suite/goto.test.js | 28 +- test/test-suite/literals.test.js | 64 +- test/test-suite/locals.test.js | 14 +- test/test-suite/ltests.js | 298 +++---- test/test-suite/math.test.js | 152 ++-- test/test-suite/nextvar.test.js | 104 +-- test/test-suite/pm.test.js | 80 +- test/test-suite/sort.test.js | 52 +- test/test-suite/strings.test.js | 50 +- test/test-suite/tpack.test.js | 68 +- test/test-suite/utf8.test.js | 40 +- test/test-suite/vararg.test.js | 20 +- test/tests.js | 12 +- 85 files changed, 4785 insertions(+), 5597 deletions(-) create mode 100644 babel.config.cjs create mode 100644 eslint.config.js create mode 100644 jest.config.cjs diff --git a/babel.config.cjs b/babel.config.cjs new file mode 100644 index 00000000..c37918e3 --- /dev/null +++ b/babel.config.cjs @@ -0,0 +1,5 @@ +module.exports = { + "presets": [ + "@babel/preset-env", + ], +}; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..c58eb459 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,23 @@ +import js from "@eslint/js"; +import globals from "globals"; +import { defineConfig } from "eslint/config"; +import stylistic from "@stylistic/eslint-plugin"; + +export default defineConfig([ + { ignores: ["dist", "node_modules", "*.config.*"] }, + { files: ["**/*.js"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: { ...globals.node, ...globals.browser, ...globals.worker } } }, + { files: ["**/*.test.js"], languageOptions: { globals: { ...globals.node, ...globals.browser, ...globals.worker, ...globals.jest } } }, + { plugins: {'@stylistic': stylistic} }, + { + rules: { + "@typescript-eslint/no-explicit-any": "off", + '@stylistic/quotes': ['error', 'single'], + '@stylistic/no-extra-semi': 'error', + '@stylistic/semi': ['error', 'always'], + '@stylistic/curly-newline': 'error', + '@stylistic/indent': ['error', 4], + '@stylistic/comma-dangle': ['error', 'never'], + 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }] + } + } +]); diff --git a/jest.config.cjs b/jest.config.cjs new file mode 100644 index 00000000..3d53a3db --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,201 @@ +/** + * For a detailed explanation regarding each configuration property, visit: + * https://jestjs.io/docs/configuration + */ + +/** @type {import('jest').Config} */ +const config = { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/tmp/jest_rt", + + // Automatically clear mock calls, instances, contexts and results before every test + // clearMocks: false, + + // Indicates whether the coverage information should be collected while executing the test + // collectCoverage: false, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: undefined, + + // The directory where Jest should output its coverage files + // coverageDirectory: undefined, + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // Indicates which provider should be used to instrument code for coverage + // coverageProvider: "babel", + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: undefined, + + // A path to a custom dependency extractor + // dependencyExtractor: undefined, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // The default configuration for fake timers + // fakeTimers: { + // "enableGlobally": false + // }, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: undefined, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: undefined, + + // A set of global variables that need to be available in all test environments + // globals: {}, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "mjs", + // "cjs", + // "jsx", + // "ts", + // "tsx", + // "json", + // "node" + // ], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + //moduleNameMapper: {}, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + // preset: undefined, + + // Run tests from one or more projects + // projects: undefined, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state before every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: undefined, + + // Automatically restore mock state and implementation before every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: undefined, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + // setupFiles: [], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // The number of seconds after which a test is considered as slow and reported as such in the results. + // slowTestThreshold: 5, + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + testEnvironment: "node", + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + testMatch: [ + "./test/**/*.test.js", + ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + testPathIgnorePatterns: [ + "/node_modules/", + "/dist/", + "/test/test-suite/" + ], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: undefined, + + // This option allows use of a custom test runner + // testRunner: "jest-circus/runner", + + // A map from regular expressions to paths to transformers + transform: { + "^.+\\.js$": "babel-jest", + }, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "/node_modules/", + // "\\.pnp\\.[^\\/]+$" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: undefined, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; + +module.exports = config; diff --git a/package.json b/package.json index 862dcf9e..9a5c8f59 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,11 @@ }, "homepage": "https://github.com/fengari-lua/fengari#readme", "devDependencies": { - "eslint": "^9.39.2", - "jest": "^30.2.0" + "@babel/core": "^7.29.7", + "@babel/preset-env": "^7.29.7", + "babel-jest": "^30.4.1", + "eslint": "^5.15.1", + "jest": "^24.5.0" }, "dependencies": { "readline-sync": "^1.4.10", diff --git a/src/defs.js b/src/defs.js index daa5f702..b7c3f1c4 100644 --- a/src/defs.js +++ b/src/defs.js @@ -1,64 +1,52 @@ -"use strict"; - /* * Fengari specific string conversion functions */ -let luastring_from; -if (typeof Uint8Array.from === "function") { - luastring_from = Uint8Array.from.bind(Uint8Array); -} else { - luastring_from = function(a) { +export const luastring_from = typeof Uint8Array.from === 'function' ? + Uint8Array.from.bind(Uint8Array) : + function (a) { let i = 0; let len = a.length; let r = new Uint8Array(len); while (len > i) r[i] = a[i++]; return r; }; -} -let luastring_indexOf; -if (typeof (new Uint8Array().indexOf) === "function") { - luastring_indexOf = function(s, v, i) { +export const luastring_indexOf = typeof (new Uint8Array().indexOf) === 'function' ? + function (s, v, i) { return s.indexOf(v, i); - }; -} else { - /* Browsers that don't support Uint8Array.indexOf seem to allow using Array.indexOf on Uint8Array objects e.g. IE11 */ - let array_indexOf = [].indexOf; - if (array_indexOf.call(new Uint8Array(1), 0) !== 0) throw Error("missing .indexOf"); - luastring_indexOf = function(s, v, i) { + } : + function (s, v, i) { + let array_indexOf = [].indexOf; + if (array_indexOf.call(new Uint8Array(1), 0) !== 0) throw Error('missing .indexOf'); return array_indexOf.call(s, v, i); }; -} -let luastring_of; -if (typeof Uint8Array.of === "function") { - luastring_of = Uint8Array.of.bind(Uint8Array); -} else { - luastring_of = function() { +export const luastring_of = typeof Uint8Array.of === 'function' ? + Uint8Array.of.bind(Uint8Array) : + function () { return luastring_from(arguments); }; -} -const is_luastring = function(s) { +export const is_luastring = function (s) { return s instanceof Uint8Array; }; /* test two lua strings for equality */ -const luastring_eq = function(a, b) { +export const luastring_eq = function (a, b) { if (a !== b) { let len = a.length; if (len !== b.length) return false; /* XXX: Should this be a constant time algorithm? */ - for (let i=0; i 0xF4) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; } else if (u0 <= 0xDF) { /* two byte sequence */ if (i >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u1 = value[i++]; - if ((u1&0xC0) !== 0x80) { + if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } str += String.fromCharCode(((u0 & 0x1F) << 6) + (u1 & 0x3F)); } else if (u0 <= 0xEF) { /* three byte sequence */ - if (i+1 >= to) { + if (i + 1 >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u1 = value[i++]; - if ((u1&0xC0) !== 0x80) { + if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u2 = value[i++]; - if ((u2&0xC0) !== 0x80) { + if ((u2 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u = ((u0 & 0x0F) << 12) + ((u1 & 0x3F) << 6) + (u2 & 0x3F); @@ -119,27 +107,27 @@ const to_jsstring = function(value, from, to, replacement_char) { } } else { /* four byte sequence */ - if (i+2 >= to) { + if (i + 2 >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u1 = value[i++]; - if ((u1&0xC0) !== 0x80) { + if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u2 = value[i++]; - if ((u2&0xC0) !== 0x80) { + if ((u2 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u3 = value[i++]; - if ((u3&0xC0) !== 0x80) { + if ((u3 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } /* Has to be astral codepoint */ @@ -154,21 +142,21 @@ const to_jsstring = function(value, from, to, replacement_char) { }; /* bytes allowed unescaped in a uri */ -const uri_allowed = (";,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*'()#").split('').reduce(function(uri_allowed, c) { +const uri_allowed = (';,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*\'()#').split('').reduce(function (uri_allowed, c) { uri_allowed[c.charCodeAt(0)] = true; return uri_allowed; }, {}); /* utility function to convert a lua string to a js string with uri escaping */ -const to_uristring = function(a) { - if (!is_luastring(a)) throw new TypeError("to_uristring expects a Uint8Array"); - let s = ""; - for (let i=0; i= 0xD800 && u <= 0xDBFF && (i+1) < len) { + if (u >= 0xD800 && u <= 0xDBFF && (i + 1) < len) { /* is first half of surrogate pair */ - let v = str.charCodeAt(i+1); + let v = str.charCodeAt(i + 1); if (v >= 0xDC00 && v <= 0xDFFF) { /* is valid low surrogate */ i++; @@ -224,74 +212,53 @@ const to_luastring = function(str, cache) { return outU8Array; }; -const from_userstring = function(str) { +export const from_userstring = function (str) { if (!is_luastring(str)) { - if (typeof str === "string") { + if (typeof str === 'string') { str = to_luastring(str); } else { - throw new TypeError("expects an array of bytes or javascript string"); + throw new TypeError('expects an array of bytes or javascript string'); } } return str; }; -module.exports.luastring_from = luastring_from; -module.exports.luastring_indexOf = luastring_indexOf; -module.exports.luastring_of = luastring_of; -module.exports.is_luastring = is_luastring; -module.exports.luastring_eq = luastring_eq; -module.exports.to_jsstring = to_jsstring; -module.exports.to_uristring = to_uristring; -module.exports.to_luastring = to_luastring; -module.exports.from_userstring = from_userstring; +/* mark for precompiled code ('Lua') */ +const LUA_SIGNATURE = to_luastring('\x1bLua'); +const LUA_VERSION_MAJOR = '5'; +const LUA_VERSION_MINOR = '3'; +export const LUA_VERSION_NUM = 503; +const LUA_VERSION_RELEASE = '4'; -/* mark for precompiled code ('Lua') */ -const LUA_SIGNATURE = to_luastring("\x1bLua"); - -const LUA_VERSION_MAJOR = "5"; -const LUA_VERSION_MINOR = "3"; -const LUA_VERSION_NUM = 503; -const LUA_VERSION_RELEASE = "4"; - -const LUA_VERSION = "Lua " + LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; -const LUA_RELEASE = LUA_VERSION + "." + LUA_VERSION_RELEASE; -const LUA_COPYRIGHT = LUA_RELEASE + " Copyright (C) 1994-2017 Lua.org, PUC-Rio"; -const LUA_AUTHORS = "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"; - -module.exports.LUA_SIGNATURE = LUA_SIGNATURE; -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_VERSION = LUA_VERSION; -module.exports.LUA_RELEASE = LUA_RELEASE; -module.exports.LUA_COPYRIGHT = LUA_COPYRIGHT; -module.exports.LUA_AUTHORS = LUA_AUTHORS; - - -const thread_status = { - LUA_OK: 0, - LUA_YIELD: 1, - LUA_ERRRUN: 2, +const LUA_VERSION = 'Lua ' + LUA_VERSION_MAJOR + '.' + LUA_VERSION_MINOR; +const LUA_RELEASE = LUA_VERSION + '.' + LUA_VERSION_RELEASE; +export const LUA_COPYRIGHT = LUA_RELEASE + ' Copyright (C) 1994-2017 Lua.org, PUC-Rio'; +const LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo, W. Celes'; + + +export const thread_status = { + LUA_OK: 0, + LUA_YIELD: 1, + LUA_ERRRUN: 2, LUA_ERRSYNTAX: 3, - LUA_ERRMEM: 4, - LUA_ERRGCMM: 5, - LUA_ERRERR: 6 + LUA_ERRMEM: 4, + LUA_ERRGCMM: 5, + LUA_ERRERR: 6 }; -const constant_types = { - LUA_TNONE: -1, - LUA_TNIL: 0, - LUA_TBOOLEAN: 1, +export const constant_types = { + LUA_TNONE: -1, + LUA_TNIL: 0, + LUA_TBOOLEAN: 1, LUA_TLIGHTUSERDATA: 2, - LUA_TNUMBER: 3, - LUA_TSTRING: 4, - LUA_TTABLE: 5, - LUA_TFUNCTION: 6, - LUA_TUSERDATA: 7, - LUA_TTHREAD: 8, - LUA_NUMTAGS: 9 + LUA_TNUMBER: 3, + LUA_TSTRING: 4, + LUA_TTABLE: 5, + LUA_TFUNCTION: 6, + LUA_TUSERDATA: 7, + LUA_TTHREAD: 8, + LUA_NUMTAGS: 9 }; constant_types.LUA_TSHRSTR = constant_types.LUA_TSTRING | (0 << 4); /* short strings */ @@ -308,38 +275,39 @@ 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_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_OPBOR = 8; const LUA_OPBXOR = 9; -const LUA_OPSHL = 10; -const LUA_OPSHR = 11; -const LUA_OPUNM = 12; -const LUA_OPBNOT = 13; +const LUA_OPSHL = 10; +const LUA_OPSHR = 11; +export const LUA_OPUNM = 12; +export const LUA_OPBNOT = 13; -const LUA_OPEQ = 0; -const LUA_OPLT = 1; -const LUA_OPLE = 2; +export const LUA_OPEQ = 0; +export const LUA_OPLT = 1; +export const LUA_OPLE = 2; const LUA_MINSTACK = 20; -const { LUAI_MAXSTACK } = require('./luaconf.js'); -const LUA_REGISTRYINDEX = -LUAI_MAXSTACK - 1000; +const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); +const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; +export const LUA_REGISTRYINDEX = -LUAI_MAXSTACK - 1000; -const lua_upvalueindex = function(i) { +const lua_upvalueindex = function (i) { return LUA_REGISTRYINDEX - i; }; /* predefined values in the registry */ const LUA_RIDX_MAINTHREAD = 1; -const LUA_RIDX_GLOBALS = 2; -const LUA_RIDX_LAST = LUA_RIDX_GLOBALS; +export const LUA_RIDX_GLOBALS = 2; +const LUA_RIDX_LAST = LUA_RIDX_GLOBALS; class lua_Debug { constructor() { @@ -364,54 +332,17 @@ class lua_Debug { /* ** Event codes */ -const LUA_HOOKCALL = 0; -const LUA_HOOKRET = 1; -const LUA_HOOKLINE = 2; -const LUA_HOOKCOUNT = 3; +const LUA_HOOKCALL = 0; +const LUA_HOOKRET = 1; +const LUA_HOOKLINE = 2; +const LUA_HOOKCOUNT = 3; const LUA_HOOKTAILCALL = 4; - +export const LUA_MULTRET = -1; /* ** Event masks */ -const LUA_MASKCALL = (1 << LUA_HOOKCALL); -const LUA_MASKRET = (1 << LUA_HOOKRET); -const LUA_MASKLINE = (1 << LUA_HOOKLINE); -const LUA_MASKCOUNT = (1 << LUA_HOOKCOUNT); - -module.exports.LUA_HOOKCALL = LUA_HOOKCALL; -module.exports.LUA_HOOKCOUNT = LUA_HOOKCOUNT; -module.exports.LUA_HOOKLINE = LUA_HOOKLINE; -module.exports.LUA_HOOKRET = LUA_HOOKRET; -module.exports.LUA_HOOKTAILCALL = LUA_HOOKTAILCALL; -module.exports.LUA_MASKCALL = LUA_MASKCALL; -module.exports.LUA_MASKCOUNT = LUA_MASKCOUNT; -module.exports.LUA_MASKLINE = LUA_MASKLINE; -module.exports.LUA_MASKRET = LUA_MASKRET; -module.exports.LUA_MINSTACK = LUA_MINSTACK; -module.exports.LUA_MULTRET = -1; -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_RIDX_GLOBALS = LUA_RIDX_GLOBALS; -module.exports.LUA_RIDX_LAST = LUA_RIDX_LAST; -module.exports.LUA_RIDX_MAINTHREAD = LUA_RIDX_MAINTHREAD; -module.exports.constant_types = constant_types; -module.exports.lua_Debug = lua_Debug; -module.exports.lua_upvalueindex = lua_upvalueindex; -module.exports.thread_status = thread_status; +const LUA_MASKCALL = (1 << LUA_HOOKCALL); +const LUA_MASKRET = (1 << LUA_HOOKRET); +export const LUA_MASKLINE = (1 << LUA_HOOKLINE); +export const LUA_MASKCOUNT = (1 << LUA_HOOKCOUNT); diff --git a/src/fengari.js b/src/fengari.js index 147756fe..fca3ee92 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -6,32 +6,8 @@ Copyright © 2017-2019 Daurnimator Copyright © 1994–2017 Lua.org, PUC-Rio. */ -"use strict"; - -const core = require("./fengaricore.js"); - -module.exports.FENGARI_AUTHORS = core.FENGARI_AUTHORS; -module.exports.FENGARI_COPYRIGHT = core.FENGARI_COPYRIGHT; -module.exports.FENGARI_RELEASE = core.FENGARI_RELEASE; -module.exports.FENGARI_VERSION = core.FENGARI_VERSION; -module.exports.FENGARI_VERSION_MAJOR = core.FENGARI_VERSION_MAJOR; -module.exports.FENGARI_VERSION_MINOR = core.FENGARI_VERSION_MINOR; -module.exports.FENGARI_VERSION_NUM = core.FENGARI_VERSION_NUM; -module.exports.FENGARI_VERSION_RELEASE = core.FENGARI_VERSION_RELEASE; - -module.exports.luastring_eq = core.luastring_eq; -module.exports.luastring_indexOf = core.luastring_indexOf; -module.exports.luastring_of = core.luastring_of; -module.exports.to_jsstring = core.to_jsstring; -module.exports.to_luastring = core.to_luastring; -module.exports.to_uristring = core.to_uristring; - -const luaconf = require('./luaconf.js'); -const lua = require('./lua.js'); -const lauxlib = require('./lauxlib.js'); -const lualib = require('./lualib.js'); - -module.exports.luaconf = luaconf; -module.exports.lua = lua; -module.exports.lauxlib = lauxlib; -module.exports.lualib = lualib; +export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from './fengaricore.js'; +export * as luaconf from './luaconf.js'; +export * as lua from './lua.js'; +export * as lauxlib from './lauxlib.js'; +export * as lualib from './lualib.js'; diff --git a/src/fengaricore.js b/src/fengaricore.js index 4ed5ddef..26235b1f 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,31 +6,24 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ -const defs = require("./defs.js"); +export { + LUA_COPYRIGHT, + is_luastring, + luastring_eq, + luastring_from, + luastring_indexOf, + luastring_of, + to_jsstring, + to_luastring, + to_uristring, + from_userstring +} from './defs.js'; -const FENGARI_VERSION_MAJOR = "0"; -const FENGARI_VERSION_MINOR = "1"; -const FENGARI_VERSION_NUM = 1; -const FENGARI_VERSION_RELEASE = "5"; -const FENGARI_VERSION = "Fengari " + FENGARI_VERSION_MAJOR + "." + FENGARI_VERSION_MINOR; -const FENGARI_RELEASE = FENGARI_VERSION + "." + FENGARI_VERSION_RELEASE; -const FENGARI_AUTHORS = "B. Giannangeli, Daurnimator"; -const FENGARI_COPYRIGHT = FENGARI_RELEASE + " Copyright (C) 2017-2019 " + FENGARI_AUTHORS + "\nBased on: " + defs.LUA_COPYRIGHT; - -module.exports.FENGARI_AUTHORS = FENGARI_AUTHORS; -module.exports.FENGARI_COPYRIGHT = FENGARI_COPYRIGHT; -module.exports.FENGARI_RELEASE = FENGARI_RELEASE; -module.exports.FENGARI_VERSION = FENGARI_VERSION; -module.exports.FENGARI_VERSION_MAJOR = FENGARI_VERSION_MAJOR; -module.exports.FENGARI_VERSION_MINOR = FENGARI_VERSION_MINOR; -module.exports.FENGARI_VERSION_NUM = FENGARI_VERSION_NUM; -module.exports.FENGARI_VERSION_RELEASE = FENGARI_VERSION_RELEASE; -module.exports.is_luastring = defs.is_luastring; -module.exports.luastring_eq = defs.luastring_eq; -module.exports.luastring_from = defs.luastring_from; -module.exports.luastring_indexOf = defs.luastring_indexOf; -module.exports.luastring_of = defs.luastring_of; -module.exports.to_jsstring = defs.to_jsstring; -module.exports.to_luastring = defs.to_luastring; -module.exports.to_uristring = defs.to_uristring; -module.exports.from_userstring = defs.from_userstring; +export const FENGARI_VERSION_MAJOR = '0'; +export const FENGARI_VERSION_MINOR = '1'; +export const FENGARI_VERSION_NUM = 1; +export const FENGARI_VERSION_RELEASE = '4'; +export const FENGARI_VERSION = 'Fengari ' + FENGARI_VERSION_MAJOR + '.' + FENGARI_VERSION_MINOR; +export const FENGARI_RELEASE = FENGARI_VERSION + '.' + FENGARI_VERSION_RELEASE; +export const FENGARI_AUTHORS = 'B. Giannangeli, Daurnimator'; +export const FENGARI_COPYRIGHT = FENGARI_RELEASE + ' Copyright (C) 2017-2019 ' + FENGARI_AUTHORS + '\nBased on: ' + LUA_COPYRIGHT; diff --git a/src/fengarilib.js b/src/fengarilib.js index 158fb034..09a852fd 100644 --- a/src/fengarilib.js +++ b/src/fengarilib.js @@ -1,42 +1,24 @@ -const { - lua_pushinteger, - lua_pushliteral, - lua_setfield -} = require('./lua.js'); -const { - luaL_newlib -} = require('./lauxlib.js'); -const { - FENGARI_AUTHORS, - FENGARI_COPYRIGHT, - FENGARI_RELEASE, - FENGARI_VERSION, - FENGARI_VERSION_MAJOR, - FENGARI_VERSION_MINOR, - FENGARI_VERSION_NUM, - FENGARI_VERSION_RELEASE, - to_luastring -} = require("./fengaricore.js"); +import { lua_pushinteger, lua_pushliteral, lua_setfield } from './lua.js'; +import { luaL_newlib } from './lauxlib.js'; +import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, to_luastring } from './fengaricore.js'; const luaopen_fengari = function(L) { luaL_newlib(L, {}); lua_pushliteral(L, FENGARI_AUTHORS); - lua_setfield(L, -2, to_luastring("AUTHORS")); + lua_setfield(L, -2, to_luastring('AUTHORS')); lua_pushliteral(L, FENGARI_COPYRIGHT); - lua_setfield(L, -2, to_luastring("COPYRIGHT")); + lua_setfield(L, -2, to_luastring('COPYRIGHT')); lua_pushliteral(L, FENGARI_RELEASE); - lua_setfield(L, -2, to_luastring("RELEASE")); + lua_setfield(L, -2, to_luastring('RELEASE')); lua_pushliteral(L, FENGARI_VERSION); - lua_setfield(L, -2, to_luastring("VERSION")); + lua_setfield(L, -2, to_luastring('VERSION')); lua_pushliteral(L, FENGARI_VERSION_MAJOR); - lua_setfield(L, -2, to_luastring("VERSION_MAJOR")); + lua_setfield(L, -2, to_luastring('VERSION_MAJOR')); lua_pushliteral(L, FENGARI_VERSION_MINOR); - lua_setfield(L, -2, to_luastring("VERSION_MINOR")); + lua_setfield(L, -2, to_luastring('VERSION_MINOR')); lua_pushinteger(L, FENGARI_VERSION_NUM); - lua_setfield(L, -2, to_luastring("VERSION_NUM")); + lua_setfield(L, -2, to_luastring('VERSION_NUM')); lua_pushliteral(L, FENGARI_VERSION_RELEASE); - lua_setfield(L, -2, to_luastring("VERSION_RELEASE")); + lua_setfield(L, -2, to_luastring('VERSION_RELEASE')); return 1; }; - -module.exports.luaopen_fengari = luaopen_fengari; diff --git a/src/lapi.js b/src/lapi.js index 7443fb78..4aa297d4 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1,6 +1,5 @@ -"use strict"; - -const { +import * as defs from './defs.js'; +import { LUA_MULTRET, LUA_OPBNOT, LUA_OPEQ, @@ -10,138 +9,171 @@ const { LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS, LUA_VERSION_NUM, - constant_types: { - LUA_NUMTAGS, - LUA_TBOOLEAN, - LUA_TCCL, - LUA_TFUNCTION, - LUA_TLCF, - LUA_TLCL, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNONE, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR, - LUA_TTABLE, - LUA_TTHREAD, - LUA_TUSERDATA - }, - thread_status: { LUA_OK }, + constant_types, + thread_status, from_userstring, - to_luastring, -} = require('./defs.js'); -const { api_check } = require('./llimits.js'); -const ldebug = require('./ldebug.js'); -const ldo = require('./ldo.js'); -const { luaU_dump } = require('./ldump.js'); -const lfunc = require('./lfunc.js'); -const lobject = require('./lobject.js'); -const lstate = require('./lstate.js'); + to_luastring +} from './defs.js'; +import {api_check} from './llimits.js'; +import {luaG_errormsg} from './ldebug.js'; +import {luaD_growstack, adjust_top, luaD_callnoyield, luaD_protectedparser, luaD_call, luaD_pcall} from './ldo.js'; +import {luaU_dump} from './ldump.js'; +import {MAXUPVAL} from './lfunc.js'; +import { + TValue as _TValue, + CClosure as _CClosure, + luaO_nilobject, + setobj2s, + pushobj2s, + setobjs2s, + pushsvalue2s, + luaO_pushvfstring, + Udata, + luaO_tostring, + luaO_str2num, + luaO_arith +} from './lobject.js'; +import {EXTRA_STACK, lua_State, CIST_LUA, CIST_OAH, CIST_YPCALL} from './lstate.js'; +import {luaS_bless, luaS_new, luaS_newliteral} from './lstring.js'; +import {ttypename} from './ltm.js'; +import {LUAI_MAXSTACK} from './luaconf.js'; +import { + settable, + luaV_gettable, + cvt2str, + tointeger, + tonumber, + luaV_equalobj, + luaV_lessthan, + luaV_lessequal, + luaV_concat, + luaV_objlen +} from './lvm.js'; +import { + luaH_getint, + luaH_setfrom, + invalidateTMcache, + luaH_setint, + luaH_get, + luaH_new, + luaH_getn, + luaH_next +} from './ltable.js'; +import {ZIO} from './lzio.js'; + +const TValue = _TValue; +const CClosure = _CClosure; + +const {LUA_OK} = thread_status; const { - luaS_bless, - luaS_new, - luaS_newliteral -} = require('./lstring.js'); -const ltm = require('./ltm.js'); -const { LUAI_MAXSTACK } = require('./luaconf.js'); -const lvm = require('./lvm.js'); -const ltable = require('./ltable.js'); -const { ZIO } = require('./lzio.js'); -const TValue = lobject.TValue; -const CClosure = lobject.CClosure; - -const api_incr_top = function(L) { + LUA_NUMTAGS, + LUA_TBOOLEAN, + LUA_TCCL, + LUA_TFUNCTION, + LUA_TLCF, + LUA_TLCL, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNONE, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, + LUA_TTABLE, + LUA_TTHREAD, + LUA_TUSERDATA +} = constant_types; + +export const api_incr_top = function (L) { L.top++; - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); }; -const api_checknelems = function(L, n) { - api_check(L, n < (L.top - L.ci.funcOff), "not enough elements in the stack"); +const api_checknelems = function (L, n) { + api_check(L, n < (L.top - L.ci.funcOff), 'not enough elements in the stack'); }; -const fengari_argcheck = function(c) { - if (!c) throw TypeError("invalid argument"); +const fengari_argcheck = function (c) { + if (!c) throw TypeError('invalid argument'); }; -const fengari_argcheckinteger = function(n) { - fengari_argcheck(typeof n === "number" && (n|0) === n); +const fengari_argcheckinteger = function (n) { + fengari_argcheck(typeof n === 'number' && (n | 0) === n); }; -const isvalid = function(o) { - return o !== lobject.luaO_nilobject; +const isvalid = function (o) { + return o !== luaO_nilobject; }; -const lua_version = function(L) { +const lua_version = function (L) { if (L === null) return LUA_VERSION_NUM; else return L.l_G.version; }; -const lua_atpanic = function(L, panicf) { +const lua_atpanic = function (L, panicf) { let old = L.l_G.panic; L.l_G.panic = panicf; return old; }; -const lua_atnativeerror = function(L, errorf) { +const lua_atnativeerror = function (L, errorf) { let old = L.l_G.atnativeerror; L.l_G.atnativeerror = errorf; return old; }; // Return value for idx on stack -const index2addr = function(L, idx) { +const index2addr = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), "unacceptable index"); - if (o >= L.top) return lobject.luaO_nilobject; + api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); + if (o >= L.top) return luaO_nilobject; else return L.stack[o]; } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, "invalid index"); + api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); return L.stack[L.top + idx]; } else if (idx === LUA_REGISTRYINDEX) { return L.l_G.l_registry; } else { /* upvalues */ idx = LUA_REGISTRYINDEX - idx; - api_check(L, idx <= lfunc.MAXUPVAL + 1, "upvalue index too large"); + api_check(L, idx <= MAXUPVAL + 1, 'upvalue index too large'); if (ci.func.ttislcf()) /* light C function? */ - return lobject.luaO_nilobject; /* it has no upvalues */ + return luaO_nilobject; /* it has no upvalues */ else { - return idx <= ci.func.value.nupvalues ? ci.func.value.upvalue[idx - 1] : lobject.luaO_nilobject; + return idx <= ci.func.value.nupvalues ? ci.func.value.upvalue[idx - 1] : luaO_nilobject; } } }; // Like index2addr but returns the index on stack; doesn't allow pseudo indices -const index2addr_ = function(L, idx) { +const index2addr_ = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), "unacceptable index"); + api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); if (o >= L.top) return null; else return o; } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, "invalid index"); + api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); return L.top + idx; } else { /* registry or upvalue */ - throw Error("attempt to use pseudo-index"); + throw Error('attempt to use pseudo-index'); } }; -const lua_checkstack = function(L, n) { +const lua_checkstack = function (L, n) { let res; let ci = L.ci; - api_check(L, n >= 0, "negative 'n'"); + api_check(L, n >= 0, 'negative \'n\''); if (L.stack_last - L.top > n) /* stack large enough? */ res = true; else { /* no; need to grow stack */ - let inuse = L.top + lstate.EXTRA_STACK; + let inuse = L.top + EXTRA_STACK; if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */ res = false; /* no */ else { /* try to grow stack */ - ldo.luaD_growstack(L, n); + luaD_growstack(L, n); res = true; } } @@ -152,15 +184,15 @@ const lua_checkstack = function(L, n) { return res; }; -const lua_xmove = function(from, to, n) { +const lua_xmove = function (from, to, n) { if (from === to) return; api_checknelems(from, n); - api_check(from, from.l_G === to.l_G, "moving among independent states"); - api_check(from, to.ci.top - to.top >= n, "stack overflow"); + api_check(from, from.l_G === to.l_G, 'moving among independent states'); + api_check(from, to.ci.top - to.top >= n, 'stack overflow'); from.top -= n; for (let i = 0; i < n; i++) { - to.stack[to.top] = new lobject.TValue(); - lobject.setobj2s(to, to.top, from.stack[from.top + i]); + to.stack[to.top] = new _TValue(); + setobj2s(to, to.top, from.stack[from.top + i]); delete from.stack[from.top + i]; to.top++; } @@ -173,44 +205,44 @@ const lua_xmove = function(from, to, n) { /* ** convert an acceptable stack index into an absolute index */ -const lua_absindex = function(L, idx) { +const lua_absindex = function (L, idx) { return (idx > 0 || idx <= LUA_REGISTRYINDEX) ? idx : (L.top - L.ci.funcOff) + idx; }; -const lua_gettop = function(L) { +const lua_gettop = function (L) { return L.top - (L.ci.funcOff + 1); }; -const lua_pushvalue = function(L, idx) { - lobject.pushobj2s(L, index2addr(L, idx)); - api_check(L, L.top <= L.ci.top, "stack overflow"); +const lua_pushvalue = function (L, idx) { + pushobj2s(L, index2addr(L, idx)); + api_check(L, L.top <= L.ci.top, 'stack overflow'); }; -const lua_settop = function(L, idx) { +const lua_settop = function (L, idx) { let func = L.ci.funcOff; let newtop; if (idx >= 0) { - api_check(L, idx <= L.stack_last - (func + 1), "new top too large"); + api_check(L, idx <= L.stack_last - (func + 1), 'new top too large'); newtop = func + 1 + idx; } else { - api_check(L, -(idx + 1) <= L.top - (func + 1), "invalid new top"); + api_check(L, -(idx + 1) <= L.top - (func + 1), 'invalid new top'); newtop = L.top + idx + 1; /* 'subtract' index (index is negative) */ } - ldo.adjust_top(L, newtop); + adjust_top(L, newtop); }; -const lua_pop = function(L, n) { +const lua_pop = function (L, n) { lua_settop(L, -n - 1); }; -const reverse = function(L, from, to) { +const reverse = function (L, from, to) { for (; from < to; from++, to--) { let fromtv = L.stack[from]; let temp = new TValue(fromtv.type, fromtv.value); - lobject.setobjs2s(L, from, to); - lobject.setobj2s(L, to, temp); + setobjs2s(L, from, to); + setobj2s(L, to, temp); } }; @@ -218,33 +250,33 @@ const reverse = function(L, from, to) { ** Let x = AB, where A is a prefix of length 'n'. Then, ** rotate x n === BA. But BA === (A^r . B^r)^r. */ -const lua_rotate = function(L, idx, n) { +const lua_rotate = function (L, idx, n) { let t = L.top - 1; let pIdx = index2addr_(L, idx); let p = L.stack[pIdx]; - api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, "index not in the stack"); - api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), "invalid 'n'"); + api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, 'index not in the stack'); + api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), 'invalid \'n\''); let m = n >= 0 ? t - n : pIdx - n - 1; /* end of prefix */ reverse(L, pIdx, m); reverse(L, m + 1, L.top - 1); reverse(L, pIdx, L.top - 1); }; -const lua_copy = function(L, fromidx, toidx) { +const lua_copy = function (L, fromidx, toidx) { let from = index2addr(L, fromidx); index2addr(L, toidx).setfrom(from); }; -const lua_remove = function(L, idx) { +const lua_remove = function (L, idx) { lua_rotate(L, idx, -1); lua_pop(L, 1); }; -const lua_insert = function(L, idx) { +const lua_insert = function (L, idx) { lua_rotate(L, idx, 1); }; -const lua_replace = function(L, idx) { +const lua_replace = function (L, idx) { lua_copy(L, -1, idx); lua_pop(L, 1); }; @@ -253,36 +285,36 @@ const lua_replace = function(L, idx) { ** push functions (JS -> stack) */ -const lua_pushnil = function(L) { +const lua_pushnil = function (L) { L.stack[L.top] = new TValue(LUA_TNIL, null); api_incr_top(L); }; -const lua_pushnumber = function(L, n) { - fengari_argcheck(typeof n === "number"); +const lua_pushnumber = function (L, n) { + fengari_argcheck(typeof n === 'number'); L.stack[L.top] = new TValue(LUA_TNUMFLT, n); api_incr_top(L); }; -const lua_pushinteger = function(L, n) { +export const lua_pushinteger = function (L, n) { fengari_argcheckinteger(n); L.stack[L.top] = new TValue(LUA_TNUMINT, n); api_incr_top(L); }; -const lua_pushlstring = function(L, s, len) { +const lua_pushlstring = function (L, s, len) { fengari_argcheckinteger(len); let ts; if (len === 0) { - s = to_luastring("", true); + s = to_luastring('', true); ts = luaS_bless(L, s); } else { s = from_userstring(s); - api_check(L, s.length >= len, "invalid length to lua_pushlstring"); + api_check(L, s.length >= len, 'invalid length to lua_pushlstring'); ts = luaS_new(L, s.subarray(0, len)); } - lobject.pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushsvalue2s(L, ts); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return ts.value; }; @@ -292,53 +324,53 @@ const lua_pushstring = function (L, s) { L.top++; } else { let ts = luaS_new(L, from_userstring(s)); - lobject.pushsvalue2s(L, ts); + pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return s; }; const lua_pushvfstring = function (L, fmt, argp) { fmt = from_userstring(fmt); - return lobject.luaO_pushvfstring(L, fmt, argp); + return luaO_pushvfstring(L, fmt, argp); }; const lua_pushfstring = function (L, fmt, ...argp) { fmt = from_userstring(fmt); - return lobject.luaO_pushvfstring(L, fmt, argp); + return luaO_pushvfstring(L, fmt, argp); }; /* Similar to lua_pushstring, but takes a JS string */ -const lua_pushliteral = function (L, s) { +export const lua_pushliteral = function (L, s) { if (s === undefined || s === null) { L.stack[L.top] = new TValue(LUA_TNIL, null); L.top++; } else { - fengari_argcheck(typeof s === "string"); + fengari_argcheck(typeof s === 'string'); let ts = luaS_newliteral(L, s); - lobject.pushsvalue2s(L, ts); + pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return s; }; -const lua_pushcclosure = function(L, fn, n) { - fengari_argcheck(typeof fn === "function"); +const lua_pushcclosure = function (L, fn, n) { + fengari_argcheck(typeof fn === 'function'); fengari_argcheckinteger(n); if (n === 0) L.stack[L.top] = new TValue(LUA_TLCF, fn); else { api_checknelems(L, n); - api_check(L, n <= lfunc.MAXUPVAL, "upvalue index too large"); + api_check(L, n <= MAXUPVAL, 'upvalue index too large'); let cl = new CClosure(L, fn, n); - for (let i=0; i0) + if (n > 0) --L.top; L.stack[L.top].setclCvalue(cl); } @@ -347,29 +379,29 @@ const lua_pushcclosure = function(L, fn, n) { const lua_pushjsclosure = lua_pushcclosure; -const lua_pushcfunction = function(L, fn) { +const lua_pushcfunction = function (L, fn) { lua_pushcclosure(L, fn, 0); }; const lua_pushjsfunction = lua_pushcfunction; -const lua_pushboolean = function(L, b) { +const lua_pushboolean = function (L, b) { L.stack[L.top] = new TValue(LUA_TBOOLEAN, !!b); api_incr_top(L); }; -const lua_pushlightuserdata = function(L, p) { +const lua_pushlightuserdata = function (L, p) { L.stack[L.top] = new TValue(LUA_TLIGHTUSERDATA, p); api_incr_top(L); }; -const lua_pushthread = function(L) { +const lua_pushthread = function (L) { L.stack[L.top] = new TValue(LUA_TTHREAD, L); api_incr_top(L); return L.l_G.mainthread === L; }; -const lua_pushglobaltable = function(L) { +const lua_pushglobaltable = function (L) { lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); }; @@ -380,29 +412,29 @@ const lua_pushglobaltable = function(L) { /* ** t[k] = value at the top of the stack (where 'k' is a string) */ -const auxsetstr = function(L, t, k) { +const auxsetstr = function (L, t, k) { let str = luaS_new(L, from_userstring(k)); api_checknelems(L, 1); - lobject.pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ - api_check(L, L.top <= L.ci.top, "stack overflow"); - lvm.settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); + pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ + api_check(L, L.top <= L.ci.top, 'stack overflow'); + settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_setglobal = function(L, name) { - auxsetstr(L, ltable.luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS), name); +const lua_setglobal = function (L, name) { + auxsetstr(L, luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS), name); }; -const lua_setmetatable = function(L, objindex) { +const lua_setmetatable = function (L, objindex) { api_checknelems(L, 1); let mt; let obj = index2addr(L, objindex); if (L.stack[L.top - 1].ttisnil()) mt = null; else { - api_check(L, L.stack[L.top - 1].ttistable(), "table expected"); + api_check(L, L.stack[L.top - 1].ttistable(), 'table expected'); mt = L.stack[L.top - 1].value; } @@ -422,58 +454,58 @@ const lua_setmetatable = function(L, objindex) { return true; }; -const lua_settable = function(L, idx) { +const lua_settable = function (L, idx) { api_checknelems(L, 2); let t = index2addr(L, idx); - lvm.settable(L, t, L.stack[L.top - 2], L.stack[L.top - 1]); + settable(L, t, L.stack[L.top - 2], L.stack[L.top - 1]); delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_setfield = function(L, idx, k) { +export const lua_setfield = function (L, idx, k) { auxsetstr(L, index2addr(L, idx), k); }; -const lua_seti = function(L, idx, n) { +const lua_seti = function (L, idx, n) { fengari_argcheckinteger(n); api_checknelems(L, 1); let t = index2addr(L, idx); L.stack[L.top] = new TValue(LUA_TNUMINT, n); api_incr_top(L); - lvm.settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); + settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_rawset = function(L, idx) { +const lua_rawset = function (L, idx) { api_checknelems(L, 2); let o = index2addr(L, idx); - api_check(L, o.ttistable(), "table expected"); + api_check(L, o.ttistable(), 'table expected'); let k = L.stack[L.top - 2]; let v = L.stack[L.top - 1]; - ltable.luaH_setfrom(L, o.value, k, v); - ltable.invalidateTMcache(o.value); + luaH_setfrom(L, o.value, k, v); + invalidateTMcache(o.value); delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_rawseti = function(L, idx, n) { +const lua_rawseti = function (L, idx, n) { fengari_argcheckinteger(n); api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), "table expected"); - ltable.luaH_setint(o.value, n, L.stack[L.top - 1]); + api_check(L, o.ttistable(), 'table expected'); + luaH_setint(o.value, n, L.stack[L.top - 1]); delete L.stack[--L.top]; }; -const lua_rawsetp = function(L, idx, p) { +const lua_rawsetp = function (L, idx, p) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), "table expected"); + api_check(L, o.ttistable(), 'table expected'); let k = new TValue(LUA_TLIGHTUSERDATA, p); let v = L.stack[L.top - 1]; - ltable.luaH_setfrom(L, o.value, k, v); + luaH_setfrom(L, o.value, k, v); delete L.stack[--L.top]; }; @@ -481,118 +513,119 @@ const lua_rawsetp = function(L, idx, p) { ** get functions (Lua -> stack) */ -const auxgetstr = function(L, t, k) { +const auxgetstr = function (L, t, k) { let str = luaS_new(L, from_userstring(k)); - lobject.pushsvalue2s(L, str); - api_check(L, L.top <= L.ci.top, "stack overflow"); - lvm.luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); + pushsvalue2s(L, str); + api_check(L, L.top <= L.ci.top, 'stack overflow'); + luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; -const lua_rawgeti = function(L, idx, n) { +const lua_rawgeti = function (L, idx, n) { let t = index2addr(L, idx); fengari_argcheckinteger(n); - api_check(L, t.ttistable(), "table expected"); - lobject.pushobj2s(L, ltable.luaH_getint(t.value, n)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, t.ttistable(), 'table expected'); + pushobj2s(L, luaH_getint(t.value, n)); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return L.stack[L.top - 1].ttnov(); }; -const lua_rawgetp = function(L, idx, p) { +const lua_rawgetp = function (L, idx, p) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), "table expected"); + api_check(L, t.ttistable(), 'table expected'); let k = new TValue(LUA_TLIGHTUSERDATA, p); - lobject.pushobj2s(L, ltable.luaH_get(L, t.value, k)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushobj2s(L, luaH_get(L, t.value, k)); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return L.stack[L.top - 1].ttnov(); }; -const lua_rawget = function(L, idx) { +const lua_rawget = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(t), "table expected"); - lobject.setobj2s(L, L.top - 1, ltable.luaH_get(L, t.value, L.stack[L.top - 1])); + api_check(L, t.ttistable(t), 'table expected'); + setobj2s(L, L.top - 1, luaH_get(L, t.value, L.stack[L.top - 1])); return L.stack[L.top - 1].ttnov(); }; // narray and nrec are mostly useless for this implementation -const lua_createtable = function(L, narray, nrec) { - let t = new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L)); +const lua_createtable = function (L, narray, nrec) { + let t = new _TValue(LUA_TTABLE, luaH_new(L)); L.stack[L.top] = t; api_incr_top(L); }; -const luaS_newudata = function(L, size) { - return new lobject.Udata(L, size); +const luaS_newudata = function (L, size) { + return new Udata(L, size); }; -const lua_newuserdata = function(L, size) { +const lua_newuserdata = function (L, size) { let u = luaS_newudata(L, size); - L.stack[L.top] = new lobject.TValue(LUA_TUSERDATA, u); + L.stack[L.top] = new _TValue(LUA_TUSERDATA, u); api_incr_top(L); return u.data; }; -const aux_upvalue = function(L, fi, n) { +const aux_upvalue = function (L, fi, n) { fengari_argcheckinteger(n); - switch(fi.ttype()) { + switch (fi.ttype()) { case LUA_TCCL: { /* C closure */ let f = fi.value; if (!(1 <= n && n <= f.nupvalues)) return null; return { - name: to_luastring("", true), - val: f.upvalue[n-1] + name: to_luastring('', true), + val: f.upvalue[n - 1] }; } case LUA_TLCL: { /* Lua closure */ let f = fi.value; let p = f.p; if (!(1 <= n && n <= p.upvalues.length)) return null; - let name = p.upvalues[n-1].name; + let name = p.upvalues[n - 1].name; return { - name: name ? name.getstr() : to_luastring("(*no name)", true), - val: f.upvals[n-1] + name: name ? name.getstr() : to_luastring('(*no name)', true), + val: f.upvals[n - 1] }; } - default: return null; /* not a closure */ + default: + return null; /* not a closure */ } }; -const lua_getupvalue = function(L, funcindex, n) { +const lua_getupvalue = function (L, funcindex, n) { let up = aux_upvalue(L, index2addr(L, funcindex), n); if (up) { let name = up.name; let val = up.val; - lobject.pushobj2s(L, val); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushobj2s(L, val); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return name; } return null; }; -const lua_setupvalue = function(L, funcindex, n) { +const lua_setupvalue = function (L, funcindex, n) { let fi = index2addr(L, funcindex); api_checknelems(L, 1); let aux = aux_upvalue(L, fi, n); if (aux) { let name = aux.name; let val = aux.val; - val.setfrom(L.stack[L.top-1]); + val.setfrom(L.stack[L.top - 1]); delete L.stack[--L.top]; return name; } return null; }; -const lua_newtable = function(L) { +const lua_newtable = function (L) { lua_createtable(L, 0, 0); }; -const lua_register = function(L, n, f) { +const lua_register = function (L, n, f) { lua_pushcfunction(L, f); lua_setglobal(L, n); }; -const lua_getmetatable = function(L, objindex) { +const lua_getmetatable = function (L, objindex) { let obj = index2addr(L, objindex); let mt; let res = false; @@ -615,79 +648,79 @@ const lua_getmetatable = function(L, objindex) { return res; }; -const lua_getuservalue = function(L, idx) { +const lua_getuservalue = function (L, idx) { let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), "full userdata expected"); + api_check(L, o.ttisfulluserdata(), 'full userdata expected'); let uv = o.value.uservalue; L.stack[L.top] = new TValue(uv.type, uv.value); api_incr_top(L); return L.stack[L.top - 1].ttnov(); }; -const lua_gettable = function(L, idx) { +const lua_gettable = function (L, idx) { let t = index2addr(L, idx); - lvm.luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); + luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; -const lua_getfield = function(L, idx, k) { +const lua_getfield = function (L, idx, k) { return auxgetstr(L, index2addr(L, idx), k); }; -const lua_geti = function(L, idx, n) { +const lua_geti = function (L, idx, n) { let t = index2addr(L, idx); fengari_argcheckinteger(n); L.stack[L.top] = new TValue(LUA_TNUMINT, n); api_incr_top(L); - lvm.luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); + luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; -const lua_getglobal = function(L, name) { - return auxgetstr(L, ltable.luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS), name); +const lua_getglobal = function (L, name) { + return auxgetstr(L, luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS), name); }; /* ** access functions (stack -> JS) */ -const lua_toboolean = function(L, idx) { +const lua_toboolean = function (L, idx) { let o = index2addr(L, idx); return !o.l_isfalse(); }; -const lua_tolstring = function(L, idx) { +const lua_tolstring = function (L, idx) { let o = index2addr(L, idx); if (!o.ttisstring()) { - if (!lvm.cvt2str(o)) { /* not convertible? */ + if (!cvt2str(o)) { /* not convertible? */ return null; } - lobject.luaO_tostring(L, o); + luaO_tostring(L, o); } return o.svalue(); }; -const lua_tostring = lua_tolstring; +const lua_tostring = lua_tolstring; -const lua_tojsstring = function(L, idx) { +const lua_tojsstring = function (L, idx) { let o = index2addr(L, idx); if (!o.ttisstring()) { - if (!lvm.cvt2str(o)) { /* not convertible? */ + if (!cvt2str(o)) { /* not convertible? */ return null; } - lobject.luaO_tostring(L, o); + luaO_tostring(L, o); } return o.jsstring(); }; -const lua_todataview = function(L, idx) { +const lua_todataview = function (L, idx) { let u8 = lua_tolstring(L, idx); return new DataView(u8.buffer, u8.byteOffset, u8.byteLength); }; -const lua_rawlen = function(L, idx) { +const lua_rawlen = function (L, idx) { let o = index2addr(L, idx); switch (o.ttype()) { case LUA_TSHRSTR: @@ -696,53 +729,54 @@ const lua_rawlen = function(L, idx) { case LUA_TUSERDATA: return o.value.len; case LUA_TTABLE: - return ltable.luaH_getn(o.value); + return luaH_getn(o.value); default: return 0; } }; -const lua_tocfunction = function(L, idx) { +const lua_tocfunction = function (L, idx) { let o = index2addr(L, idx); if (o.ttislcf() || o.ttisCclosure()) return o.value; else return null; /* not a C function */ }; -const lua_tointeger = function(L, idx) { +const lua_tointeger = function (L, idx) { let n = lua_tointegerx(L, idx); return n === false ? 0 : n; }; -const lua_tointegerx = function(L, idx) { - return lvm.tointeger(index2addr(L, idx)); +const lua_tointegerx = function (L, idx) { + return tointeger(index2addr(L, idx)); }; -const lua_tonumber = function(L, idx) { +const lua_tonumber = function (L, idx) { let n = lua_tonumberx(L, idx); return n === false ? 0 : n; }; -const lua_tonumberx = function(L, idx) { - return lvm.tonumber(index2addr(L, idx)); +const lua_tonumberx = function (L, idx) { + return tonumber(index2addr(L, idx)); }; -const lua_touserdata = function(L, idx) { +const lua_touserdata = function (L, idx) { let o = index2addr(L, idx); switch (o.ttnov()) { case LUA_TUSERDATA: return o.value.data; case LUA_TLIGHTUSERDATA: return o.value; - default: return null; + default: + return null; } }; -const lua_tothread = function(L, idx) { +const lua_tothread = function (L, idx) { let o = index2addr(L, idx); return o.ttisthread() ? o.value : null; }; -const lua_topointer = function(L, idx) { +const lua_topointer = function (L, idx) { let o = index2addr(L, idx); switch (o.ttype()) { case LUA_TTABLE: @@ -765,7 +799,7 @@ const lua_topointer = function(L, idx) { const seen = new WeakMap(); /* is the passed object a proxy? is it from the given state? (if passed) */ -const lua_isproxy = function(p, L) { +const lua_isproxy = function (p, L) { let G = seen.get(p); if (!G) return false; @@ -773,9 +807,9 @@ const lua_isproxy = function(p, L) { }; /* Use 'create_proxy' helper function so that 'L' is not in scope */ -const create_proxy = function(G, type, value) { - let proxy = function(L) { - api_check(L, L instanceof lstate.lua_State && G === L.l_G, "must be from same global state"); +const create_proxy = function (G, type, value) { + let proxy = function (L) { + api_check(L, L instanceof lua_State && G === L.l_G, 'must be from same global state'); L.stack[L.top] = new TValue(type, value); api_incr_top(L); }; @@ -783,14 +817,14 @@ const create_proxy = function(G, type, value) { return proxy; }; -const lua_toproxy = function(L, idx) { +const lua_toproxy = function (L, idx) { let tv = index2addr(L, idx); /* pass broken down tv incase it is an upvalue index */ return create_proxy(L.l_G, tv.type, tv.value); }; -const lua_compare = function(L, index1, index2, op) { +const lua_compare = function (L, index1, index2, op) { let o1 = index2addr(L, index1); let o2 = index2addr(L, index2); @@ -798,19 +832,26 @@ const lua_compare = function(L, index1, index2, op) { if (isvalid(o1) && isvalid(o2)) { switch (op) { - case LUA_OPEQ: i = lvm.luaV_equalobj(L, o1, o2); break; - case LUA_OPLT: i = lvm.luaV_lessthan(L, o1, o2); break; - case LUA_OPLE: i = lvm.luaV_lessequal(L, o1, o2); break; - default: api_check(L, false, "invalid option"); + case LUA_OPEQ: + i = luaV_equalobj(L, o1, o2); + break; + case LUA_OPLT: + i = luaV_lessthan(L, o1, o2); + break; + case LUA_OPLE: + i = luaV_lessequal(L, o1, o2); + break; + default: + api_check(L, false, 'invalid option'); } } return i; }; -const lua_stringtonumber = function(L, s) { +const lua_stringtonumber = function (L, s) { let tv = new TValue(); - let sz = lobject.luaO_str2num(s, tv); + let sz = luaO_str2num(s, tv); if (sz !== 0) { L.stack[L.top] = tv; api_incr_top(L); @@ -818,91 +859,91 @@ const lua_stringtonumber = function(L, s) { return sz; }; -const f_call = function(L, ud) { - ldo.luaD_callnoyield(L, ud.funcOff, ud.nresults); +const f_call = function (L, ud) { + luaD_callnoyield(L, ud.funcOff, ud.nresults); }; -const lua_type = function(L, idx) { +const lua_type = function (L, idx) { let o = index2addr(L, idx); - return isvalid(o) ? o.ttnov() : LUA_TNONE; + return isvalid(o) ? o.ttnov() : LUA_TNONE; }; -const lua_typename = function(L, t) { - api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); - return ltm.ttypename(t); +const lua_typename = function (L, t) { + api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, 'invalid tag'); + return ttypename(t); }; -const lua_iscfunction = function(L, idx) { +const lua_iscfunction = function (L, idx) { let o = index2addr(L, idx); return o.ttislcf(o) || o.ttisCclosure(); }; -const lua_isnil = function(L, n) { +const lua_isnil = function (L, n) { return lua_type(L, n) === LUA_TNIL; }; -const lua_isboolean = function(L, n) { +const lua_isboolean = function (L, n) { return lua_type(L, n) === LUA_TBOOLEAN; }; -const lua_isnone = function(L, n) { +const lua_isnone = function (L, n) { return lua_type(L, n) === LUA_TNONE; }; -const lua_isnoneornil = function(L, n) { +const lua_isnoneornil = function (L, n) { return lua_type(L, n) <= 0; }; -const lua_istable = function(L, idx) { +const lua_istable = function (L, idx) { return index2addr(L, idx).ttistable(); }; -const lua_isinteger = function(L, idx) { +const lua_isinteger = function (L, idx) { return index2addr(L, idx).ttisinteger(); }; -const lua_isnumber = function(L, idx) { - return lvm.tonumber(index2addr(L, idx)) !== false; +const lua_isnumber = function (L, idx) { + return tonumber(index2addr(L, idx)) !== false; }; -const lua_isstring = function(L, idx) { +const lua_isstring = function (L, idx) { let o = index2addr(L, idx); - return o.ttisstring() || lvm.cvt2str(o); + return o.ttisstring() || cvt2str(o); }; -const lua_isuserdata = function(L, idx) { +const lua_isuserdata = function (L, idx) { let o = index2addr(L, idx); return o.ttisfulluserdata(o) || o.ttislightuserdata(); }; -const lua_isthread = function(L, idx) { +const lua_isthread = function (L, idx) { return lua_type(L, idx) === LUA_TTHREAD; }; -const lua_isfunction = function(L, idx) { +const lua_isfunction = function (L, idx) { return lua_type(L, idx) === LUA_TFUNCTION; }; -const lua_islightuserdata = function(L, idx) { +const lua_islightuserdata = function (L, idx) { return lua_type(L, idx) === LUA_TLIGHTUSERDATA; }; -const lua_rawequal = function(L, index1, index2) { +const lua_rawequal = function (L, index1, index2) { let o1 = index2addr(L, index1); let o2 = index2addr(L, index2); - return isvalid(o1) && isvalid(o2) ? lvm.luaV_equalobj(null, o1, o2) : 0; + return isvalid(o1) && isvalid(o2) ? luaV_equalobj(null, o1, o2) : 0; }; -const lua_arith = function(L, op) { +const lua_arith = function (L, op) { if (op !== LUA_OPUNM && op !== LUA_OPBNOT) api_checknelems(L, 2); /* all other operations expect two operands */ else { /* for unary operations, add fake 2nd operand */ api_checknelems(L, 1); - lobject.pushobj2s(L, L.stack[L.top-1]); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushobj2s(L, L.stack[L.top - 1]); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } /* first operand at top - 2, second at top - 1; result go to top - 2 */ - lobject.luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); + luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); delete L.stack[--L.top]; /* remove second operand */ }; @@ -910,18 +951,18 @@ const lua_arith = function(L, op) { ** 'load' and 'call' functions (run Lua code) */ -const default_chunkname = to_luastring("?"); -const lua_load = function(L, reader, data, chunkname, mode) { +const default_chunkname = to_luastring('?'); +const lua_load = function (L, reader, data, chunkname, mode) { if (!chunkname) chunkname = default_chunkname; else chunkname = from_userstring(chunkname); if (mode !== null) mode = from_userstring(mode); let z = new ZIO(L, reader, data); - let status = ldo.luaD_protectedparser(L, z, chunkname, mode); + let status = luaD_protectedparser(L, z, chunkname, mode); if (status === LUA_OK) { /* no errors? */ let f = L.stack[L.top - 1].value; /* get newly created function */ if (f.nupvalues >= 1) { /* does it have an upvalue? */ /* get global table from registry */ - let gt = ltable.luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS); + let gt = luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS); /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ f.upvals[0].setfrom(gt); } @@ -929,57 +970,57 @@ const lua_load = function(L, reader, data, chunkname, mode) { return status; }; -const lua_dump = function(L, writer, data, strip) { +const lua_dump = function (L, writer, data, strip) { api_checknelems(L, 1); - let o = L.stack[L.top -1]; + let o = L.stack[L.top - 1]; if (o.ttisLclosure()) return luaU_dump(L, o.value.p, writer, data, strip); return 1; }; -const lua_status = function(L) { +const lua_status = function (L) { return L.status; }; -const lua_setuservalue = function(L, idx) { +const lua_setuservalue = function (L, idx) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), "full userdata expected"); + api_check(L, o.ttisfulluserdata(), 'full userdata expected'); o.value.uservalue.setfrom(L.stack[L.top - 1]); delete L.stack[--L.top]; }; -const checkresults = function(L,na,nr) { +const checkresults = function (L, na, nr) { api_check(L, nr === LUA_MULTRET || (L.ci.top - L.top >= (nr) - (na)), - "results from function overflow current stack size"); + 'results from function overflow current stack size'); }; -const lua_callk = function(L, nargs, nresults, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & lstate.CIST_LUA), "cannot use continuations inside hooks"); +const lua_callk = function (L, nargs, nresults, ctx, k) { + api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread"); + api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); checkresults(L, nargs, nresults); let func = L.top - (nargs + 1); if (k !== null && L.nny === 0) { /* need to prepare continuation? */ L.ci.c_k = k; L.ci.c_ctx = ctx; - ldo.luaD_call(L, func, nresults); + luaD_call(L, func, nresults); } else { /* no continuation or no yieldable */ - ldo.luaD_callnoyield(L, func, nresults); + luaD_callnoyield(L, func, nresults); } if (nresults === LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top; }; -const lua_call = function(L, n, r) { +const lua_call = function (L, n, r) { lua_callk(L, n, r, 0, null); }; -const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & lstate.CIST_LUA), "cannot use continuations inside hooks"); +const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { + api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread"); + api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); checkresults(L, nargs, nresults); let status; let func; @@ -994,7 +1035,7 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) { funcOff: funcOff, nresults: nresults /* do a 'conventional' protected call */ }; - status = ldo.luaD_pcall(L, f_call, c, funcOff, func); + status = luaD_pcall(L, f_call, c, funcOff, func); } else { /* prepare continuation (call is already protected by 'resume') */ let ci = L.ci; ci.c_k = k; /* prepare continuation (call is already protected by 'resume') */ @@ -1003,10 +1044,10 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) { ci.extra = funcOff; ci.c_old_errfunc = L.errfunc; L.errfunc = func; - ci.callstatus &= ~lstate.CIST_OAH | L.allowhook; - ci.callstatus |= lstate.CIST_YPCALL; /* function can do error recovery */ - ldo.luaD_call(L, funcOff, nresults); /* do the call */ - ci.callstatus &= ~lstate.CIST_YPCALL; + ci.callstatus &= ~CIST_OAH | L.allowhook; + ci.callstatus |= CIST_YPCALL; /* function can do error recovery */ + luaD_call(L, funcOff, nresults); /* do the call */ + ci.callstatus &= ~CIST_YPCALL; L.errfunc = ci.c_old_errfunc; status = LUA_OK; } @@ -1017,7 +1058,7 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) { return status; }; -const lua_pcall = function(L, n, r, f) { +const lua_pcall = function (L, n, r, f) { return lua_pcallk(L, n, r, f, 0, null); }; @@ -1025,16 +1066,16 @@ const lua_pcall = function(L, n, r, f) { ** miscellaneous functions */ -const lua_error = function(L) { +const lua_error = function (L) { api_checknelems(L, 1); - ldebug.luaG_errormsg(L); + luaG_errormsg(L); }; -const lua_next = function(L, idx) { +const lua_next = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), "table expected"); + api_check(L, t.ttistable(), 'table expected'); L.stack[L.top] = new TValue(); - let more = ltable.luaH_next(L, t.value, L.top - 1); + let more = luaH_next(L, t.value, L.top - 1); if (more) { api_incr_top(L); return 1; @@ -1045,37 +1086,37 @@ const lua_next = function(L, idx) { } }; -const lua_concat = function(L, n) { +const lua_concat = function (L, n) { api_checknelems(L, n); if (n >= 2) - lvm.luaV_concat(L, n); + luaV_concat(L, n); else if (n === 0) { - lobject.pushsvalue2s(L, luaS_bless(L, to_luastring("", true))); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushsvalue2s(L, luaS_bless(L, to_luastring('', true))); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } }; -const lua_len = function(L, idx) { +const lua_len = function (L, idx) { let t = index2addr(L, idx); let tv = new TValue(); - lvm.luaV_objlen(L, tv, t); + luaV_objlen(L, tv, t); L.stack[L.top] = tv; api_incr_top(L); }; -const getupvalref = function(L, fidx, n) { +const getupvalref = function (L, fidx, n) { let fi = index2addr(L, fidx); - api_check(L, fi.ttisLclosure(), "Lua function expected"); + api_check(L, fi.ttisLclosure(), 'Lua function expected'); let f = fi.value; fengari_argcheckinteger(n); - api_check(L, 1 <= n && n <= f.p.upvalues.length, "invalid upvalue index"); + api_check(L, 1 <= n && n <= f.p.upvalues.length, 'invalid upvalue index'); return { f: f, i: n - 1 }; }; -const lua_upvalueid = function(L, fidx, n) { +const lua_upvalueid = function (L, fidx, n) { let fi = index2addr(L, fidx); switch (fi.ttype()) { case LUA_TLCL: { /* lua closure */ @@ -1084,17 +1125,17 @@ const lua_upvalueid = function(L, fidx, n) { } case LUA_TCCL: { /* C closure */ let f = fi.value; - api_check(L, (n|0) === n && n > 0 && n <= f.nupvalues, "invalid upvalue index"); + api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, 'invalid upvalue index'); return f.upvalue[n - 1]; } default: { - api_check(L, false, "closure expected"); + api_check(L, false, 'closure expected'); return null; } } }; -const lua_upvaluejoin = function(L, fidx1, n1, fidx2, n2) { +const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { let ref1 = getupvalref(L, fidx1, n1); let ref2 = getupvalref(L, fidx2, n2); let up2 = ref2.f.upvals[ref2.i]; @@ -1102,129 +1143,20 @@ const lua_upvaluejoin = function(L, fidx1, n1, fidx2, n2) { }; // This functions are only there for compatibility purposes -const lua_gc = function () {}; +const lua_gc = function () { +}; const lua_getallocf = function () { - console.warn("lua_getallocf is not available"); + console.warn('lua_getallocf is not available'); return 0; }; const lua_setallocf = function () { - console.warn("lua_setallocf is not available"); + console.warn('lua_setallocf is not available'); return 0; }; const lua_getextraspace = function () { - console.warn("lua_getextraspace is not available"); + console.warn('lua_getextraspace is not available'); return 0; }; - -module.exports.api_incr_top = api_incr_top; -module.exports.api_checknelems = api_checknelems; -module.exports.lua_absindex = lua_absindex; -module.exports.lua_arith = lua_arith; -module.exports.lua_atpanic = lua_atpanic; -module.exports.lua_atnativeerror = lua_atnativeerror; -module.exports.lua_call = lua_call; -module.exports.lua_callk = lua_callk; -module.exports.lua_checkstack = lua_checkstack; -module.exports.lua_compare = lua_compare; -module.exports.lua_concat = lua_concat; -module.exports.lua_copy = lua_copy; -module.exports.lua_createtable = lua_createtable; -module.exports.lua_dump = lua_dump; -module.exports.lua_error = lua_error; -module.exports.lua_gc = lua_gc; -module.exports.lua_getallocf = lua_getallocf; -module.exports.lua_getextraspace = lua_getextraspace; -module.exports.lua_getfield = lua_getfield; -module.exports.lua_getglobal = lua_getglobal; -module.exports.lua_geti = lua_geti; -module.exports.lua_getmetatable = lua_getmetatable; -module.exports.lua_gettable = lua_gettable; -module.exports.lua_gettop = lua_gettop; -module.exports.lua_getupvalue = lua_getupvalue; -module.exports.lua_getuservalue = lua_getuservalue; -module.exports.lua_insert = lua_insert; -module.exports.lua_isboolean = lua_isboolean; -module.exports.lua_iscfunction = lua_iscfunction; -module.exports.lua_isfunction = lua_isfunction; -module.exports.lua_isinteger = lua_isinteger; -module.exports.lua_islightuserdata = lua_islightuserdata; -module.exports.lua_isnil = lua_isnil; -module.exports.lua_isnone = lua_isnone; -module.exports.lua_isnoneornil = lua_isnoneornil; -module.exports.lua_isnumber = lua_isnumber; -module.exports.lua_isproxy = lua_isproxy; -module.exports.lua_isstring = lua_isstring; -module.exports.lua_istable = lua_istable; -module.exports.lua_isthread = lua_isthread; -module.exports.lua_isuserdata = lua_isuserdata; -module.exports.lua_len = lua_len; -module.exports.lua_load = lua_load; -module.exports.lua_newtable = lua_newtable; -module.exports.lua_newuserdata = lua_newuserdata; -module.exports.lua_next = lua_next; -module.exports.lua_pcall = lua_pcall; -module.exports.lua_pcallk = lua_pcallk; -module.exports.lua_pop = lua_pop; -module.exports.lua_pushboolean = lua_pushboolean; -module.exports.lua_pushcclosure = lua_pushcclosure; -module.exports.lua_pushcfunction = lua_pushcfunction; -module.exports.lua_pushfstring = lua_pushfstring; -module.exports.lua_pushglobaltable = lua_pushglobaltable; -module.exports.lua_pushinteger = lua_pushinteger; -module.exports.lua_pushjsclosure = lua_pushjsclosure; -module.exports.lua_pushjsfunction = lua_pushjsfunction; -module.exports.lua_pushlightuserdata = lua_pushlightuserdata; -module.exports.lua_pushliteral = lua_pushliteral; -module.exports.lua_pushlstring = lua_pushlstring; -module.exports.lua_pushnil = lua_pushnil; -module.exports.lua_pushnumber = lua_pushnumber; -module.exports.lua_pushstring = lua_pushstring; -module.exports.lua_pushthread = lua_pushthread; -module.exports.lua_pushvalue = lua_pushvalue; -module.exports.lua_pushvfstring = lua_pushvfstring; -module.exports.lua_rawequal = lua_rawequal; -module.exports.lua_rawget = lua_rawget; -module.exports.lua_rawgeti = lua_rawgeti; -module.exports.lua_rawgetp = lua_rawgetp; -module.exports.lua_rawlen = lua_rawlen; -module.exports.lua_rawset = lua_rawset; -module.exports.lua_rawseti = lua_rawseti; -module.exports.lua_rawsetp = lua_rawsetp; -module.exports.lua_register = lua_register; -module.exports.lua_remove = lua_remove; -module.exports.lua_replace = lua_replace; -module.exports.lua_rotate = lua_rotate; -module.exports.lua_setallocf = lua_setallocf; -module.exports.lua_setfield = lua_setfield; -module.exports.lua_setglobal = lua_setglobal; -module.exports.lua_seti = lua_seti; -module.exports.lua_setmetatable = lua_setmetatable; -module.exports.lua_settable = lua_settable; -module.exports.lua_settop = lua_settop; -module.exports.lua_setupvalue = lua_setupvalue; -module.exports.lua_setuservalue = lua_setuservalue; -module.exports.lua_status = lua_status; -module.exports.lua_stringtonumber = lua_stringtonumber; -module.exports.lua_toboolean = lua_toboolean; -module.exports.lua_tocfunction = lua_tocfunction; -module.exports.lua_todataview = lua_todataview; -module.exports.lua_tointeger = lua_tointeger; -module.exports.lua_tointegerx = lua_tointegerx; -module.exports.lua_tojsstring = lua_tojsstring; -module.exports.lua_tolstring = lua_tolstring; -module.exports.lua_tonumber = lua_tonumber; -module.exports.lua_tonumberx = lua_tonumberx; -module.exports.lua_topointer = lua_topointer; -module.exports.lua_toproxy = lua_toproxy; -module.exports.lua_tostring = lua_tostring; -module.exports.lua_tothread = lua_tothread; -module.exports.lua_touserdata = lua_touserdata; -module.exports.lua_type = lua_type; -module.exports.lua_typename = lua_typename; -module.exports.lua_upvalueid = lua_upvalueid; -module.exports.lua_upvaluejoin = lua_upvaluejoin; -module.exports.lua_version = lua_version; -module.exports.lua_xmove = lua_xmove; diff --git a/src/lauxlib.js b/src/lauxlib.js index 2b8a5bf7..95620269 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -1,9 +1,6 @@ -"use strict"; - -const { - LUAL_BUFFERSIZE -} = require('./luaconf.js'); -const { +import fs from 'fs'; +import { LUAL_BUFFERSIZE } from './luaconf.js'; +import { LUA_ERRERR, LUA_MULTRET, LUA_REGISTRYINDEX, @@ -77,29 +74,29 @@ const { lua_type, lua_typename, lua_version -} = require('./lua.js'); -const { +} from './lua.js'; +import { from_userstring, luastring_eq, to_luastring, to_uristring -} = require("./fengaricore.js"); +} from './fengaricore.js'; /* extra error code for 'luaL_loadfilex' */ -const LUA_ERRFILE = LUA_ERRERR+1; +const LUA_ERRFILE = LUA_ERRERR + 1; /* key, in the registry, for table of loaded modules */ -const LUA_LOADED_TABLE = to_luastring("_LOADED"); +const LUA_LOADED_TABLE = to_luastring('_LOADED'); /* key, in the registry, for table of preloaded loaders */ -const LUA_PRELOAD_TABLE = to_luastring("_PRELOAD"); +const LUA_PRELOAD_TABLE = to_luastring('_PRELOAD'); -const LUA_FILEHANDLE = to_luastring("FILE*"); +const LUA_FILEHANDLE = to_luastring('FILE*'); -const LUAL_NUMSIZES = 4*16 + 8; +const LUAL_NUMSIZES = 4 * 16 + 8; -const __name = to_luastring("__name"); -const __tostring = to_luastring("__tostring"); +const __name = to_luastring('__name'); +const __tostring = to_luastring('__tostring'); const empty = new Uint8Array(0); @@ -118,7 +115,7 @@ const LEVELS2 = 11; /* size of the second part of the stack */ ** search for 'objidx' in table at index -1. ** return 1 + string at top if find a good name. */ -const findfield = function(L, objidx, level) { +const findfield = function (L, objidx, level) { if (level === 0 || !lua_istable(L, -1)) return 0; /* not found */ @@ -131,7 +128,7 @@ const findfield = function(L, objidx, level) { return 1; } else if (findfield(L, objidx, level - 1)) { /* try recursively */ lua_remove(L, -2); /* remove table (but keep name) */ - lua_pushliteral(L, "."); + lua_pushliteral(L, '.'); lua_insert(L, -2); /* place '.' between the two names */ lua_concat(L, 3); return 1; @@ -146,9 +143,9 @@ const findfield = function(L, objidx, level) { /* ** Search for a name for a function in all loaded modules */ -const pushglobalfuncname = function(L, ar) { +const pushglobalfuncname = function (L, ar) { let top = lua_gettop(L); - lua_getinfo(L, to_luastring("f"), ar); /* push function */ + lua_getinfo(L, to_luastring('f'), ar); /* push function */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); if (findfield(L, top + 1, 2)) { let name = lua_tostring(L, -1); @@ -168,22 +165,22 @@ const pushglobalfuncname = function(L, ar) { } }; -const pushfuncname = function(L, ar) { +const pushfuncname = function (L, ar) { if (pushglobalfuncname(L, ar)) { /* try first a global name */ - lua_pushfstring(L, to_luastring("function '%s'"), lua_tostring(L, -1)); + lua_pushfstring(L, to_luastring('function \'%s\''), lua_tostring(L, -1)); lua_remove(L, -2); /* remove name */ } else if (ar.namewhat.length !== 0) /* is there a name from code? */ - lua_pushfstring(L, to_luastring("%s '%s'"), ar.namewhat, ar.name); /* use it */ + lua_pushfstring(L, to_luastring('%s \'%s\''), ar.namewhat, ar.name); /* use it */ else if (ar.what && ar.what[0] === 109 /* 'm'.charCodeAt(0) */) /* main? */ - lua_pushliteral(L, "main chunk"); + lua_pushliteral(L, 'main chunk'); else if (ar.what && ar.what[0] === 76 /* 'L'.charCodeAt(0) */) /* for Lua functions, use */ - lua_pushfstring(L, to_luastring("function <%s:%d>"), ar.short_src, ar.linedefined); + lua_pushfstring(L, to_luastring('function <%s:%d>'), ar.short_src, ar.linedefined); else /* nothing left... */ - lua_pushliteral(L, "?"); + lua_pushliteral(L, '?'); }; -const lastlevel = function(L) { +const lastlevel = function (L) { let ar = new lua_Debug(); let li = 1; let le = 1; @@ -191,92 +188,92 @@ const lastlevel = function(L) { while (lua_getstack(L, le, ar)) { li = le; le *= 2; } /* do a binary search */ while (li < le) { - let m = Math.floor((li + le)/2); + let m = Math.floor((li + le) / 2); if (lua_getstack(L, m, ar)) li = m + 1; else le = m; } return le - 1; }; -const luaL_traceback = function(L, L1, msg, level) { +export const luaL_traceback = function (L, L1, msg, level) { let ar = new lua_Debug(); let top = lua_gettop(L); let last = lastlevel(L1); let n1 = last - level > LEVELS1 + LEVELS2 ? LEVELS1 : -1; if (msg) - lua_pushfstring(L, to_luastring("%s\n"), msg); + lua_pushfstring(L, to_luastring('%s\n'), msg); luaL_checkstack(L, 10, null); - lua_pushliteral(L, "stack traceback:"); + lua_pushliteral(L, 'stack traceback:'); while (lua_getstack(L1, level++, ar)) { if (n1-- === 0) { /* too many levels? */ - lua_pushliteral(L, "\n\t..."); /* add a '...' */ + lua_pushliteral(L, '\n\t...'); /* add a '...' */ level = last - LEVELS2 + 1; /* and skip to last ones */ } else { - lua_getinfo(L1, to_luastring("Slnt", true), ar); - lua_pushfstring(L, to_luastring("\n\t%s:"), ar.short_src); + lua_getinfo(L1, to_luastring('Slnt', true), ar); + lua_pushfstring(L, to_luastring('\n\t%s:'), ar.short_src); if (ar.currentline > 0) lua_pushliteral(L, `${ar.currentline}:`); - lua_pushliteral(L, " in "); + lua_pushliteral(L, ' in '); pushfuncname(L, ar); if (ar.istailcall) - lua_pushliteral(L, "\n\t(...tail calls..)"); + lua_pushliteral(L, '\n\t(...tail calls..)'); lua_concat(L, lua_gettop(L) - top); } } lua_concat(L, lua_gettop(L) - top); }; -const panic = function(L) { - let msg = "PANIC: unprotected error in call to Lua API (" + lua_tojsstring(L, -1) + ")"; +const panic = function (L) { + let msg = 'PANIC: unprotected error in call to Lua API (' + lua_tojsstring(L, -1) + ')'; throw new Error(msg); }; -const luaL_argerror = function(L, arg, extramsg) { +export const luaL_argerror = function (L, arg, extramsg) { let ar = new lua_Debug(); if (!lua_getstack(L, 0, ar)) /* no stack frame? */ - return luaL_error(L, to_luastring("bad argument #%d (%s)"), arg, extramsg); + return luaL_error(L, to_luastring('bad argument #%d (%s)'), arg, extramsg); - lua_getinfo(L, to_luastring("n"), ar); + lua_getinfo(L, to_luastring('n'), ar); - if (luastring_eq(ar.namewhat, to_luastring("method"))) { + if (luastring_eq(ar.namewhat, to_luastring('method'))) { arg--; /* do not count 'self' */ if (arg === 0) /* error is in the self argument itself? */ - return luaL_error(L, to_luastring("calling '%s' on bad self (%s)"), ar.name, extramsg); + return luaL_error(L, to_luastring('calling \'%s\' on bad self (%s)'), ar.name, extramsg); } if (ar.name === null) - ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring("?"); + ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring('?'); - return luaL_error(L, to_luastring("bad argument #%d to '%s' (%s)"), arg, ar.name, extramsg); + return luaL_error(L, to_luastring('bad argument #%d to \'%s\' (%s)'), arg, ar.name, extramsg); }; -const typeerror = function(L, arg, tname) { +const typeerror = function (L, arg, tname) { let typearg; if (luaL_getmetafield(L, arg, __name) === LUA_TSTRING) typearg = lua_tostring(L, -1); else if (lua_type(L, arg) === LUA_TLIGHTUSERDATA) - typearg = to_luastring("light userdata", true); + typearg = to_luastring('light userdata', true); else typearg = luaL_typename(L, arg); - let msg = lua_pushfstring(L, to_luastring("%s expected, got %s"), tname, typearg); + let msg = lua_pushfstring(L, to_luastring('%s expected, got %s'), tname, typearg); return luaL_argerror(L, arg, msg); }; -const luaL_where = function(L, level) { +export const luaL_where = function (L, level) { let ar = new lua_Debug(); if (lua_getstack(L, level, ar)) { - lua_getinfo(L, to_luastring("Sl", true), ar); + lua_getinfo(L, to_luastring('Sl', true), ar); if (ar.currentline > 0) { - lua_pushfstring(L, to_luastring("%s:%d: "), ar.short_src, ar.currentline); + lua_pushfstring(L, to_luastring('%s:%d: '), ar.short_src, ar.currentline); return; } } - lua_pushstring(L, to_luastring("")); + lua_pushstring(L, to_luastring('')); }; -const luaL_error = function(L, fmt, ...argp) { +export const luaL_error = function (L, fmt, ...argp) { luaL_where(L, 1); lua_pushvfstring(L, fmt, argp); lua_concat(L, 2); @@ -284,7 +281,7 @@ const luaL_error = function(L, fmt, ...argp) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_fileresult = function(L, stat, fname, e) { +const luaL_fileresult = function (L, stat, fname, e) { if (stat) { lua_pushboolean(L, 1); return 1; @@ -295,11 +292,11 @@ const luaL_fileresult = function(L, stat, fname, e) { message = e.message; errno = -e.errno; } else { - message = "Success"; /* what strerror(0) returns */ + message = 'Success'; /* what strerror(0) returns */ errno = 0; } if (fname) - lua_pushfstring(L, to_luastring("%s: %s"), fname, to_luastring(message)); + lua_pushfstring(L, to_luastring('%s: %s'), fname, to_luastring(message)); else lua_pushstring(L, to_luastring(message)); lua_pushinteger(L, errno); @@ -308,18 +305,18 @@ const luaL_fileresult = function(L, stat, fname, e) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_execresult = function(L, e) { +const luaL_execresult = function (L, e) { let what, stat; if (e === null) { lua_pushboolean(L, 1); - lua_pushliteral(L, "exit"); + lua_pushliteral(L, 'exit'); lua_pushinteger(L, 0); return 3; } else if (e.status) { - what = "exit"; + what = 'exit'; stat = e.status; } else if (e.signal) { - what = "signal"; + what = 'signal'; stat = e.signal; } else { /* XXX: node seems to have e.errno as a string instead of a number */ @@ -331,11 +328,11 @@ const luaL_execresult = function(L, e) { return 3; }; -const luaL_getmetatable = function(L, n) { +const luaL_getmetatable = function (L, n) { return lua_getfield(L, LUA_REGISTRYINDEX, n); }; -const luaL_newmetatable = function(L, tname) { +const luaL_newmetatable = function (L, tname) { if (luaL_getmetatable(L, tname) !== LUA_TNIL) /* name already in use? */ return 0; /* leave previous value on top, but return 0 */ lua_pop(L, 1); @@ -348,12 +345,12 @@ const luaL_newmetatable = function(L, tname) { }; -const luaL_setmetatable = function(L, tname) { +const luaL_setmetatable = function (L, tname) { luaL_getmetatable(L, tname); lua_setmetatable(L, -2); }; -const luaL_testudata = function(L, ud, tname) { +const luaL_testudata = function (L, ud, tname) { let p = lua_touserdata(L, ud); if (p !== null) { /* value is a userdata? */ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ @@ -367,95 +364,95 @@ const luaL_testudata = function(L, ud, tname) { return null; /* value is not a userdata with a metatable */ }; -const luaL_checkudata = function(L, ud, tname) { +const luaL_checkudata = function (L, ud, tname) { let p = luaL_testudata(L, ud, tname); if (p === null) typeerror(L, ud, tname); return p; }; -const luaL_checkoption = function(L, arg, def, lst) { +export const luaL_checkoption = function (L, arg, def, lst) { let name = def !== null ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); for (let i = 0; lst[i]; i++) if (luastring_eq(lst[i], name)) return i; - return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring("invalid option '%s'"), name)); + return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring('invalid option \'%s\''), name)); }; -const tag_error = function(L, arg, tag) { +const tag_error = function (L, arg, tag) { typeerror(L, arg, lua_typename(L, tag)); }; -const luaL_newstate = function() { +const luaL_newstate = function () { let L = lua_newstate(); if (L) lua_atpanic(L, panic); return L; }; -const luaL_typename = function(L, i) { +const luaL_typename = function (L, i) { return lua_typename(L, lua_type(L, i)); }; -const luaL_argcheck = function(L, cond, arg, extramsg) { +export const luaL_argcheck = function (L, cond, arg, extramsg) { if (!cond) luaL_argerror(L, arg, extramsg); }; -const luaL_checkany = function(L, arg) { +export const luaL_checkany = function (L, arg) { if (lua_type(L, arg) === LUA_TNONE) - luaL_argerror(L, arg, to_luastring("value expected", true)); + luaL_argerror(L, arg, to_luastring('value expected', true)); }; -const luaL_checktype = function(L, arg, t) { +export const luaL_checktype = function (L, arg, t) { if (lua_type(L, arg) !== t) tag_error(L, arg, t); }; -const luaL_checklstring = function(L, arg) { +const luaL_checklstring = function (L, arg) { let s = lua_tolstring(L, arg); if (s === null || s === undefined) tag_error(L, arg, LUA_TSTRING); return s; }; -const luaL_checkstring = luaL_checklstring; +export const luaL_checkstring = luaL_checklstring; -const luaL_optlstring = function(L, arg, def) { +const luaL_optlstring = function (L, arg, def) { if (lua_type(L, arg) <= 0) { return def === null ? null : from_userstring(def); } else return luaL_checklstring(L, arg); }; -const luaL_optstring = luaL_optlstring; +export const luaL_optstring = luaL_optlstring; -const interror = function(L, arg) { +const interror = function (L, arg) { if (lua_isnumber(L, arg)) - luaL_argerror(L, arg, to_luastring("number has no integer representation", true)); + luaL_argerror(L, arg, to_luastring('number has no integer representation', true)); else tag_error(L, arg, LUA_TNUMBER); }; -const luaL_checknumber = function(L, arg) { +const luaL_checknumber = function (L, arg) { let d = lua_tonumberx(L, arg); if (d === false) tag_error(L, arg, LUA_TNUMBER); return d; }; -const luaL_optnumber = function(L, arg, def) { +const luaL_optnumber = function (L, arg, def) { return luaL_opt(L, luaL_checknumber, arg, def); }; -const luaL_checkinteger = function(L, arg) { +export const luaL_checkinteger = function (L, arg) { let d = lua_tointegerx(L, arg); if (d === false) interror(L, arg); return d; }; -const luaL_optinteger = function(L, arg, def) { +export const luaL_optinteger = function (L, arg, def) { return luaL_opt(L, luaL_checkinteger, arg, def); }; -const luaL_prepbuffsize = function(B, sz) { +const luaL_prepbuffsize = function (B, sz) { let newend = B.n + sz; if (B.b.length < newend) { let newsize = Math.max(B.b.length * 2, newend); /* double buffer size */ @@ -466,21 +463,21 @@ const luaL_prepbuffsize = function(B, sz) { return B.b.subarray(B.n, newend); }; -const luaL_buffinit = function(L, B) { +const luaL_buffinit = function (L, B) { B.L = L; B.b = empty; }; -const luaL_buffinitsize = function(L, B, sz) { +const luaL_buffinitsize = function (L, B, sz) { luaL_buffinit(L, B); return luaL_prepbuffsize(B, sz); }; -const luaL_prepbuffer = function(B) { +const luaL_prepbuffer = function (B) { return luaL_prepbuffsize(B, LUAL_BUFFERSIZE); }; -const luaL_addlstring = function(B, s, l) { +const luaL_addlstring = function (B, s, l) { if (l > 0) { s = from_userstring(s); let b = luaL_prepbuffsize(B, l); @@ -489,66 +486,66 @@ const luaL_addlstring = function(B, s, l) { } }; -const luaL_addstring = function(B, s) { +const luaL_addstring = function (B, s) { s = from_userstring(s); luaL_addlstring(B, s, s.length); }; -const luaL_pushresult = function(B) { +const luaL_pushresult = function (B) { lua_pushlstring(B.L, B.b, B.n); /* delete old buffer */ B.n = 0; B.b = empty; }; -const luaL_addchar = function(B, c) { +const luaL_addchar = function (B, c) { luaL_prepbuffsize(B, 1); B.b[B.n++] = c; }; -const luaL_addsize = function(B, s) { +const luaL_addsize = function (B, s) { B.n += s; }; -const luaL_pushresultsize = function(B, sz) { +const luaL_pushresultsize = function (B, sz) { luaL_addsize(B, sz); luaL_pushresult(B); }; -const luaL_addvalue = function(B) { +const luaL_addvalue = function (B) { let L = B.L; let s = lua_tostring(L, -1); luaL_addlstring(B, s, s.length); lua_pop(L, 1); /* remove value */ }; -const luaL_opt = function(L, f, n, d) { +const luaL_opt = function (L, f, n, d) { return lua_type(L, n) <= 0 ? d : f(L, n); }; -const getS = function(L, ud) { +const getS = function (L, ud) { let s = ud.string; ud.string = null; return s; }; -const luaL_loadbufferx = function(L, buff, size, name, mode) { - return lua_load(L, getS, {string: buff}, name, mode); +export const luaL_loadbufferx = function (L, buff, size, name, mode) { + return lua_load(L, getS, { string: buff }, name, mode); }; -const luaL_loadbuffer = function(L, s, sz, n) { +export const luaL_loadbuffer = function (L, s, sz, n) { return luaL_loadbufferx(L, s, sz, n, null); }; -const luaL_loadstring = function(L, s) { +const luaL_loadstring = function (L, s) { return luaL_loadbuffer(L, s, s.length, s); }; -const luaL_dostring = function(L, s) { +const luaL_dostring = function (L, s) { return (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)); }; -const luaL_getmetafield = function(L, obj, event) { +export const luaL_getmetafield = function (L, obj, event) { if (!lua_getmetatable(L, obj)) /* no metatable? */ return LUA_TNIL; else { @@ -562,7 +559,7 @@ const luaL_getmetafield = function(L, obj, event) { } }; -const luaL_callmeta = function(L, obj, event) { +const luaL_callmeta = function (L, obj, event) { obj = lua_absindex(L, obj); if (luaL_getmetafield(L, obj, event) === LUA_TNIL) return false; @@ -573,24 +570,24 @@ const luaL_callmeta = function(L, obj, event) { return true; }; -const luaL_len = function(L, idx) { +const luaL_len = function (L, idx) { lua_len(L, idx); let l = lua_tointegerx(L, -1); if (l === false) - luaL_error(L, to_luastring("object length is not an integer", true)); + luaL_error(L, to_luastring('object length is not an integer', true)); lua_pop(L, 1); /* remove object */ return l; }; -const p_I = to_luastring("%I"); -const p_f = to_luastring("%f"); -const luaL_tolstring = function(L, idx) { +const p_I = to_luastring('%I'); +const p_f = to_luastring('%f'); +export const luaL_tolstring = function (L, idx) { if (luaL_callmeta(L, idx, __tostring)) { if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("'__tostring' must return a string")); + luaL_error(L, to_luastring('\'__tostring\' must return a string')); } else { let t = lua_type(L, idx); - switch(t) { + switch (t) { case LUA_TNUMBER: { if (lua_isinteger(L, idx)) lua_pushfstring(L, p_I, lua_tointeger(L, idx)); @@ -602,15 +599,15 @@ const luaL_tolstring = function(L, idx) { lua_pushvalue(L, idx); break; case LUA_TBOOLEAN: - lua_pushliteral(L, (lua_toboolean(L, idx) ? "true" : "false")); + lua_pushliteral(L, (lua_toboolean(L, idx) ? 'true' : 'false')); break; case LUA_TNIL: - lua_pushliteral(L, "nil"); + lua_pushliteral(L, 'nil'); break; default: { let tt = luaL_getmetafield(L, idx, __name); let kind = tt === LUA_TSTRING ? lua_tostring(L, -1) : luaL_typename(L, idx); - lua_pushfstring(L, to_luastring("%s: %p"), kind, lua_topointer(L, idx)); + lua_pushfstring(L, to_luastring('%s: %p'), kind, lua_topointer(L, idx)); if (tt !== LUA_TNIL) lua_remove(L, -2); break; @@ -627,7 +624,7 @@ const luaL_tolstring = function(L, idx) { ** if 'glb' is true, also registers the result in the global table. ** Leaves resulting module on the top. */ -const luaL_requiref = function(L, modname, openf, glb) { +const luaL_requiref = function (L, modname, openf, glb) { luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); lua_getfield(L, -1, modname); /* LOADED[modname] */ if (!lua_toboolean(L, -1)) { /* package not already loaded? */ @@ -645,21 +642,21 @@ const luaL_requiref = function(L, modname, openf, glb) { } }; -const find_subarray = function(arr, subarr, from_index) { +const find_subarray = function (arr, subarr, from_index) { var i = from_index >>> 0, sl = subarr.length, l = arr.length + 1 - sl; loop: for (; i < l; i++) { for (let j = 0; j < sl; j++) - if (arr[i+j] !== subarr[j]) + if (arr[i + j] !== subarr[j]) continue loop; return i; } return -1; }; -const luaL_gsub = function(L, s, p, r) { +const luaL_gsub = function (L, s, p, r) { let wild; let b = new luaL_Buffer(); luaL_buffinit(L, b); @@ -677,7 +674,7 @@ const luaL_gsub = function(L, s, p, r) { ** ensure that stack[idx][fname] has a table and push that table ** into the stack */ -const luaL_getsubtable = function(L, idx, fname) { +const luaL_getsubtable = function (L, idx, fname) { if (lua_getfield(L, idx, fname) === LUA_TTABLE) return true; /* table already there */ else { @@ -695,8 +692,8 @@ const luaL_getsubtable = function(L, idx, fname) { ** function gets the 'nup' elements at the top as upvalues. ** Returns with only the table at the stack. */ -const luaL_setfuncs = function(L, l, nup) { - luaL_checkstack(L, nup, to_luastring("too many upvalues", true)); +export const luaL_setfuncs = function (L, l, nup) { + luaL_checkstack(L, nup, to_luastring('too many upvalues', true)); for (let lib in l) { /* fill the table with given functions */ for (let i = 0; i < nup; i++) /* copy upvalues to the top */ lua_pushvalue(L, -nup); @@ -713,29 +710,29 @@ const luaL_setfuncs = function(L, l, nup) { ** this extra space, Lua will generate the same 'stack overflow' error, ** but without 'msg'.) */ -const luaL_checkstack = function(L, space, msg) { +export const luaL_checkstack = function (L, space, msg) { if (!lua_checkstack(L, space)) { if (msg) - luaL_error(L, to_luastring("stack overflow (%s)"), msg); + luaL_error(L, to_luastring('stack overflow (%s)'), msg); else luaL_error(L, to_luastring('stack overflow', true)); } }; -const luaL_newlibtable = function(L) { +const luaL_newlibtable = function (L) { lua_createtable(L); }; -const luaL_newlib = function(L, l) { +export const luaL_newlib = function (L, l) { lua_createtable(L); luaL_setfuncs(L, l, 0); }; /* predefined references */ -const LUA_NOREF = -2; +const LUA_NOREF = -2; const LUA_REFNIL = -1; -const luaL_ref = function(L, t) { +const luaL_ref = function (L, t) { let ref; if (lua_isnil(L, -1)) { lua_pop(L, 1); /* remove from stack */ @@ -756,7 +753,7 @@ const luaL_ref = function(L, t) { }; -const luaL_unref = function(L, t, ref) { +const luaL_unref = function (L, t, ref) { if (ref >= 0) { t = lua_absindex(L, t); lua_rawgeti(L, t, 0); @@ -767,10 +764,10 @@ const luaL_unref = function(L, t, ref) { }; -const errfile = function(L, what, fnameindex, error) { +const errfile = function (L, what, fnameindex, error) { let serr = error.message; let filename = lua_tostring(L, fnameindex).subarray(1); - lua_pushfstring(L, to_luastring("cannot %s %s: %s"), to_luastring(what), filename, to_luastring(serr)); + lua_pushfstring(L, to_luastring('cannot %s %s: %s'), to_luastring(what), filename, to_luastring(serr)); lua_remove(L, fnameindex); return LUA_ERRFILE; }; @@ -778,7 +775,7 @@ const errfile = function(L, what, fnameindex, error) { let getc; const utf8_bom = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ -const skipBOM = function(lf) { +const skipBOM = function (lf) { lf.n = 0; let c; let p = 0; @@ -799,7 +796,7 @@ const skipBOM = function(lf) { ** first "valid" character of the file (after the optional BOM and ** a first-line comment). */ -const skipcomment = function(lf) { +const skipcomment = function (lf) { let c = skipBOM(lf); if (c === 35 /* '#'.charCodeAt(0) */) { /* first line is a comment (Unix exec. file)? */ do { /* skip first line */ @@ -818,9 +815,9 @@ const skipcomment = function(lf) { } }; -let luaL_loadfilex; +export let luaL_loadfilex; -if (typeof process === "undefined") { +if (typeof process === 'undefined') { class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -831,7 +828,7 @@ if (typeof process === "undefined") { } } - const getF = function(L, ud) { + const getF = function (L, ud) { let lf = ud; if (lf.f !== null && lf.n > 0) { /* are there pre-read characters to be read? */ @@ -846,37 +843,37 @@ if (typeof process === "undefined") { return f; }; - getc = function(lf) { + getc = function (lf) { return lf.pos < lf.f.length ? lf.f[lf.pos++] : null; }; - luaL_loadfilex = function(L, filename, mode) { + luaL_loadfilex = function (L, filename, mode) { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - throw new Error("Can't read stdin in the browser"); + throw new Error('Can\'t read stdin in the browser'); } else { - lua_pushfstring(L, to_luastring("@%s"), filename); + lua_pushfstring(L, to_luastring('@%s'), filename); let path = to_uristring(filename); let xhr = new XMLHttpRequest(); - xhr.open("GET", path, false); + xhr.open('GET', path, false); /* Synchronous xhr in main thread always returns a js string. Some browsers make console noise if you even attempt to set responseType */ - if (typeof window === "undefined") { - xhr.responseType = "arraybuffer"; + if (typeof window === 'undefined') { + xhr.responseType = 'arraybuffer'; } xhr.send(); if (xhr.status >= 200 && xhr.status <= 299) { - if (typeof xhr.response === "string") { + if (typeof xhr.response === 'string') { lf.f = to_luastring(xhr.response); } else { lf.f = new Uint8Array(xhr.response); } } else { lf.err = xhr.status; - return errfile(L, "open", fnameindex, { message: `${xhr.status}: ${xhr.statusText}` }); + return errfile(L, 'open', fnameindex, { message: `${xhr.status}: ${xhr.statusText}` }); } } let com = skipcomment(lf); @@ -892,14 +889,12 @@ if (typeof process === "undefined") { let readstatus = lf.err; if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, "read", fnameindex, readstatus); + return errfile(L, 'read', fnameindex, readstatus); } lua_remove(L, fnameindex); return status; }; } else { - const fs = require('fs'); - class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -910,7 +905,7 @@ if (typeof process === "undefined") { } } - const getF = function(L, ud) { + const getF = function (L, ud) { let lf = ud; let bytes = 0; if (lf.n > 0) { /* are there pre-read characters to be read? */ @@ -919,7 +914,7 @@ if (typeof process === "undefined") { } else { /* read a block from file */ try { bytes = fs.readSync(lf.f, lf.buff, 0, lf.buff.length, lf.pos); /* read block */ - } catch(e) { + } catch (e) { lf.err = e; bytes = 0; } @@ -930,12 +925,12 @@ if (typeof process === "undefined") { else return null; }; - getc = function(lf) { + getc = function (lf) { let b = Buffer.alloc(1); let bytes; try { bytes = fs.readSync(lf.f, b, 0, 1, lf.pos); - } catch(e) { + } catch (e) { lf.err = e; return null; } @@ -943,18 +938,18 @@ if (typeof process === "undefined") { return bytes > 0 ? b.readUInt8() : null; }; - luaL_loadfilex = function(L, filename, mode) { + luaL_loadfilex = function (L, filename, mode) { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - lua_pushliteral(L, "=stdin"); + lua_pushliteral(L, '=stdin'); lf.f = process.stdin.fd; } else { - lua_pushfstring(L, to_luastring("@%s"), filename); + lua_pushfstring(L, to_luastring('@%s'), filename); try { - lf.f = fs.openSync(filename, "r"); + lf.f = fs.openSync(filename, 'r'); } catch (e) { - return errfile(L, "open", fnameindex, e); + return errfile(L, 'open', fnameindex, e); } } let com = skipcomment(lf); @@ -968,28 +963,28 @@ if (typeof process === "undefined") { lf.buff[lf.n++] = com.c; /* 'c' is the first character of the stream */ let status = lua_load(L, getF, lf, lua_tostring(L, -1), mode); let readstatus = lf.err; - if (filename) try { fs.closeSync(lf.f); } catch (e) {} /* close file (even in case of errors) */ + if (filename) try { fs.closeSync(lf.f); } catch (e) { } /* close file (even in case of errors) */ if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, "read", fnameindex, readstatus); + return errfile(L, 'read', fnameindex, readstatus); } lua_remove(L, fnameindex); return status; }; } -const luaL_loadfile = function(L, filename) { +export const luaL_loadfile = function (L, filename) { return luaL_loadfilex(L, filename, null); }; -const luaL_dofile = function(L, filename) { +const luaL_dofile = function (L, filename) { return (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0)); }; -const lua_writestringerror = function() { - for (let i=0; i 1) lua_writestring(to_luastring("\t")); + return luaL_error(L, to_luastring('\'tostring\' must return a string to \'print\'')); + if (i > 1) lua_writestring(to_luastring('\t')); lua_writestring(s); lua_pop(L, 1); } @@ -136,49 +131,49 @@ const luaB_print = function(L) { return 0; }; -const luaB_tostring = function(L) { +const luaB_tostring = function (L) { luaL_checkany(L, 1); luaL_tolstring(L, 1); return 1; }; -const luaB_getmetatable = function(L) { +const luaB_getmetatable = function (L) { luaL_checkany(L, 1); if (!lua_getmetatable(L, 1)) { lua_pushnil(L); return 1; /* no metatable */ } - luaL_getmetafield(L, 1, to_luastring("__metatable", true)); + luaL_getmetafield(L, 1, to_luastring('__metatable', true)); return 1; /* returns either __metatable field (if present) or metatable */ }; -const luaB_setmetatable = function(L) { +const luaB_setmetatable = function (L) { let t = lua_type(L, 2); luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, "nil or table expected"); - if (luaL_getmetafield(L, 1, to_luastring("__metatable", true)) !== LUA_TNIL) - return luaL_error(L, to_luastring("cannot change a protected metatable")); + luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, 'nil or table expected'); + if (luaL_getmetafield(L, 1, to_luastring('__metatable', true)) !== LUA_TNIL) + return luaL_error(L, to_luastring('cannot change a protected metatable')); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; }; -const luaB_rawequal = function(L) { +const luaB_rawequal = function (L) { luaL_checkany(L, 1); luaL_checkany(L, 2); lua_pushboolean(L, lua_rawequal(L, 1, 2)); return 1; }; -const luaB_rawlen = function(L) { +const luaB_rawlen = function (L) { let t = lua_type(L, 1); - luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, "table or string expected"); + luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, 'table or string expected'); lua_pushinteger(L, lua_rawlen(L, 1)); return 1; }; -const luaB_rawget = function(L) { +const luaB_rawget = function (L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_checkany(L, 2); lua_settop(L, 2); @@ -186,7 +181,7 @@ const luaB_rawget = function(L) { return 1; }; -const luaB_rawset = function(L) { +const luaB_rawset = function (L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_checkany(L, 2); luaL_checkany(L, 3); @@ -196,24 +191,24 @@ const luaB_rawset = function(L) { }; const opts = [ - "stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", - "isrunning" + 'stop', 'restart', 'collect', + 'count', 'step', 'setpause', 'setstepmul', + 'isrunning' ].map((e) => to_luastring(e)); -const luaB_collectgarbage = function(L) { - luaL_checkoption(L, 1, "collect", opts); +const luaB_collectgarbage = function (L) { + luaL_checkoption(L, 1, 'collect', opts); luaL_optinteger(L, 2, 0); - luaL_error(L, to_luastring("lua_gc not implemented")); + luaL_error(L, to_luastring('lua_gc not implemented')); }; -const luaB_type = function(L) { +const luaB_type = function (L) { let t = lua_type(L, 1); - luaL_argcheck(L, t !== LUA_TNONE, 1, "value expected"); + luaL_argcheck(L, t !== LUA_TNONE, 1, 'value expected'); lua_pushstring(L, lua_typename(L, t)); return 1; }; -const pairsmeta = function(L, method, iszero, iter) { +const pairsmeta = function (L, method, iszero, iter) { luaL_checkany(L, 1); if (luaL_getmetafield(L, 1, method) === LUA_TNIL) { /* no metamethod? */ lua_pushcfunction(L, iter); /* will return generator, */ @@ -227,7 +222,7 @@ const pairsmeta = function(L, method, iszero, iter) { return 3; }; -const luaB_next = function(L) { +const luaB_next = function (L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 2); /* create a 2nd argument if there isn't one */ if (lua_next(L, 1)) @@ -238,14 +233,14 @@ const luaB_next = function(L) { } }; -const luaB_pairs = function(L) { - return pairsmeta(L, to_luastring("__pairs", true), 0, luaB_next); +const luaB_pairs = function (L) { + return pairsmeta(L, to_luastring('__pairs', true), 0, luaB_next); }; /* ** Traversal function for 'ipairs' */ -const ipairsaux = function(L) { +const ipairsaux = function (L) { let i = luaL_checkinteger(L, 2) + 1; lua_pushinteger(L, i); return lua_geti(L, 1, i) === LUA_TNIL ? 1 : 2; @@ -255,7 +250,7 @@ const ipairsaux = function(L) { ** 'ipairs' function. Returns 'ipairsaux', given "table", 0. ** (The given "table" may not be a table.) */ -const luaB_ipairs = function(L) { +const luaB_ipairs = function (L) { // Lua 5.2 // return pairsmeta(L, "__ipairs", 1, ipairsaux); @@ -266,7 +261,7 @@ const luaB_ipairs = function(L) { return 3; }; -const b_str2int = function(s, base) { +const b_str2int = function (s, base) { try { s = to_jsstring(s); } catch (e) { @@ -274,12 +269,12 @@ const b_str2int = function(s, base) { } let r = /^[\t\v\f \n\r]*([+-]?)0*([0-9A-Za-z]+)[\t\v\f \n\r]*$/.exec(s); if (!r) return null; - let v = parseInt(r[1]+r[2], base); + let v = parseInt(r[1] + r[2], base); if (isNaN(v)) return null; - return v|0; + return v | 0; }; -const luaB_tonumber = function(L) { +const luaB_tonumber = function (L) { if (lua_type(L, 2) <= 0) { /* standard conversion? */ luaL_checkany(L, 1); if (lua_type(L, 1) === LUA_TNUMBER) { /* already a number? */ @@ -287,14 +282,14 @@ const luaB_tonumber = function(L) { return 1; } else { let s = lua_tostring(L, 1); - if (s !== null && lua_stringtonumber(L, s) === s.length+1) + if (s !== null && lua_stringtonumber(L, s) === s.length + 1) return 1; /* successful conversion to number */ } } else { let base = luaL_checkinteger(L, 2); luaL_checktype(L, 1, LUA_TSTRING); /* no numbers as strings */ let s = lua_tostring(L, 1); - luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + luaL_argcheck(L, 2 <= base && base <= 36, 2, 'base out of range'); let n = b_str2int(s, base); if (n !== null) { lua_pushinteger(L, n); @@ -306,7 +301,7 @@ const luaB_tonumber = function(L) { return 1; }; -const luaB_error = function(L) { +const luaB_error = function (L) { let level = luaL_optinteger(L, 2, 1); lua_settop(L, 1); if (lua_type(L, 1) === LUA_TSTRING && level > 0) { @@ -317,19 +312,19 @@ const luaB_error = function(L) { return lua_error(L); }; -const luaB_assert = function(L) { +const luaB_assert = function (L) { if (lua_toboolean(L, 1)) /* condition is true? */ return lua_gettop(L); /* return all arguments */ else { luaL_checkany(L, 1); /* there must be a condition */ lua_remove(L, 1); /* remove it */ - lua_pushliteral(L, "assertion failed!"); /* default message */ + lua_pushliteral(L, 'assertion failed!'); /* default message */ lua_settop(L, 1); /* leave only message (default if no other one) */ return luaB_error(L); /* call 'error' */ } }; -const luaB_select = function(L) { +const luaB_select = function (L) { let n = lua_gettop(L); if (lua_type(L, 1) === LUA_TSTRING && lua_tostring(L, 1)[0] === 35 /* '#'.charCodeAt(0) */) { lua_pushinteger(L, n - 1); @@ -338,7 +333,7 @@ const luaB_select = function(L) { let i = luaL_checkinteger(L, 1); if (i < 0) i = n + i; else if (i > n) i = n; - luaL_argcheck(L, 1 <= i, 1, "index out of range"); + luaL_argcheck(L, 1 <= i, 1, 'index out of range'); return n - i; } }; @@ -350,7 +345,7 @@ const luaB_select = function(L) { ** 'extra' values (where 'extra' is exactly the number of items to be ** ignored). */ -const finishpcall = function(L, status, extra) { +const finishpcall = function (L, status, extra) { if (status !== LUA_OK && status !== LUA_YIELD) { /* error? */ lua_pushboolean(L, 0); /* first result (false) */ lua_pushvalue(L, -2); /* error message */ @@ -359,7 +354,7 @@ const finishpcall = function(L, status, extra) { return lua_gettop(L) - extra; }; -const luaB_pcall = function(L) { +const luaB_pcall = function (L) { luaL_checkany(L, 1); lua_pushboolean(L, 1); /* first result if no errors */ lua_insert(L, 1); /* put it in place */ @@ -372,7 +367,7 @@ const luaB_pcall = function(L) { ** stack will have ; so, the function passes ** 2 to 'finishpcall' to skip the 2 first values when returning results. */ -const luaB_xpcall = function(L) { +const luaB_xpcall = function (L) { let n = lua_gettop(L); luaL_checktype(L, 2, LUA_TFUNCTION); /* check error function */ lua_pushboolean(L, 1); /* first result */ @@ -382,7 +377,7 @@ const luaB_xpcall = function(L) { return finishpcall(L, status, 2); }; -const load_aux = function(L, status, envidx) { +const load_aux = function (L, status, envidx) { if (status === LUA_OK) { if (envidx !== 0) { /* 'env' parameter? */ lua_pushvalue(L, envidx); /* environment for loaded function */ @@ -410,29 +405,29 @@ const RESERVEDSLOT = 5; ** stack top. Instead, it keeps its resulting string in a ** reserved slot inside the stack. */ -const generic_reader = function(L, ud) { - luaL_checkstack(L, 2, "too many nested functions"); +const generic_reader = function (L, ud) { + luaL_checkstack(L, 2, 'too many nested functions'); lua_pushvalue(L, 1); /* get function */ lua_call(L, 0, 1); /* call it */ if (lua_isnil(L, -1)) { lua_pop(L, 1); /* pop result */ return null; } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("reader function must return a string")); + luaL_error(L, to_luastring('reader function must return a string')); lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ return lua_tostring(L, RESERVEDSLOT); }; -const luaB_load = function(L) { +const luaB_load = function (L) { let s = lua_tostring(L, 1); - let mode = luaL_optstring(L, 3, "bt"); + let mode = luaL_optstring(L, 3, 'bt'); let env = !lua_isnone(L, 4) ? 4 : 0; /* 'env' index or 0 if no 'env' */ let status; if (s !== null) { /* loading a string? */ let chunkname = luaL_optstring(L, 2, s); status = luaL_loadbufferx(L, s, s.length, chunkname, mode); } else { /* loading from a reader function */ - let chunkname = luaL_optstring(L, 2, "=(load)"); + let chunkname = luaL_optstring(L, 2, '=(load)'); luaL_checktype(L, 1, LUA_TFUNCTION); lua_settop(L, RESERVEDSLOT); /* create reserved slot */ status = lua_load(L, generic_reader, null, chunkname, mode); @@ -440,7 +435,7 @@ const luaB_load = function(L) { return load_aux(L, status, env); }; -const luaB_loadfile = function(L) { +const luaB_loadfile = function (L) { let fname = luaL_optstring(L, 1, null); let mode = luaL_optstring(L, 2, null); let env = !lua_isnone(L, 3) ? 3 : 0; /* 'env' index or 0 if no 'env' */ @@ -448,11 +443,11 @@ const luaB_loadfile = function(L) { return load_aux(L, status, env); }; -const dofilecont = function(L, d1, d2) { +const dofilecont = function (L, d1, d2) { return lua_gettop(L) - 1; }; -const luaB_dofile = function(L) { +const luaB_dofile = function (L) { let fname = luaL_optstring(L, 1, null); lua_settop(L, 1); if (luaL_loadfile(L, fname) !== LUA_OK) @@ -462,41 +457,39 @@ const luaB_dofile = function(L) { }; const base_funcs = { - "assert": luaB_assert, - "collectgarbage": luaB_collectgarbage, - "dofile": luaB_dofile, - "error": luaB_error, - "getmetatable": luaB_getmetatable, - "ipairs": luaB_ipairs, - "load": luaB_load, - "loadfile": luaB_loadfile, - "next": luaB_next, - "pairs": luaB_pairs, - "pcall": luaB_pcall, - "print": luaB_print, - "rawequal": luaB_rawequal, - "rawget": luaB_rawget, - "rawlen": luaB_rawlen, - "rawset": luaB_rawset, - "select": luaB_select, - "setmetatable": luaB_setmetatable, - "tonumber": luaB_tonumber, - "tostring": luaB_tostring, - "type": luaB_type, - "xpcall": luaB_xpcall + 'assert': luaB_assert, + 'collectgarbage': luaB_collectgarbage, + 'dofile': luaB_dofile, + 'error': luaB_error, + 'getmetatable': luaB_getmetatable, + 'ipairs': luaB_ipairs, + 'load': luaB_load, + 'loadfile': luaB_loadfile, + 'next': luaB_next, + 'pairs': luaB_pairs, + 'pcall': luaB_pcall, + 'print': luaB_print, + 'rawequal': luaB_rawequal, + 'rawget': luaB_rawget, + 'rawlen': luaB_rawlen, + 'rawset': luaB_rawset, + 'select': luaB_select, + 'setmetatable': luaB_setmetatable, + 'tonumber': luaB_tonumber, + 'tostring': luaB_tostring, + 'type': luaB_type, + 'xpcall': luaB_xpcall }; -const luaopen_base = function(L) { +const luaopen_base = function (L) { /* open lib into global table */ lua_pushglobaltable(L); luaL_setfuncs(L, base_funcs, 0); /* set global _G */ lua_pushvalue(L, -1); - lua_setfield(L, -2, to_luastring("_G")); + lua_setfield(L, -2, to_luastring('_G')); /* set global _VERSION */ lua_pushliteral(L, LUA_VERSION); - lua_setfield(L, -2, to_luastring("_VERSION")); + lua_setfield(L, -2, to_luastring('_VERSION')); return 1; }; - -module.exports.luaopen_base = luaopen_base; diff --git a/src/lcode.js b/src/lcode.js index b6b9b16e..da177df8 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -1,6 +1,5 @@ -"use strict"; - -const { +import * as defs from './defs.js'; +import { LUA_MULTRET, LUA_OPADD, LUA_OPBAND, @@ -13,27 +12,60 @@ const { LUA_OPSHL, LUA_OPSHR, LUA_OPUNM, - constant_types: { - LUA_TBOOLEAN, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TTABLE - }, - to_luastring -} = require('./defs.js'); -const { lua_assert } = require("./llimits.js"); -const llex = require('./llex.js'); -const lobject = require('./lobject.js'); -const lopcodes = require('./lopcodes.js'); -const lparser = require('./lparser.js'); -const ltable = require('./ltable.js'); -const lvm = require('./lvm.js'); - -const OpCodesI = lopcodes.OpCodesI; -const TValue = lobject.TValue; + to_luastring, + LUA_TBOOLEAN, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TTABLE +} from './defs.js'; +import { lua_assert } from './llimits.js'; +import { luaX_syntaxerror } from './llex.js'; +import { TValue, luaO_arith } from './lobject.js'; +import { + OpCodesI, + SETARG_A, + SETARG_B, + MAXARG_sBx, + SETARG_sBx, + testTMode, + NO_REG, + CREATE_ABC, + getOpMode, + iABC, + getBMode, + OpArgN, + getCMode, + MAXARG_A, + MAXARG_B, + MAXARG_C, + iABx, + iAsBx, + MAXARG_Bx, + CREATE_ABx, + MAXARG_Ax, + CREATE_Ax, + ISK, + SETARG_C, + MAXINDEXRK, + RKASK, + LFIELDS_PER_FLUSH +} from './lopcodes.js'; +import { expkind, vkisinreg, expdesc } from './lparser.js'; +import { luaH_get, luaH_setfrom } from './ltable.js'; +import { tointeger } from './lvm.js'; + +const constant_types = { + LUA_TBOOLEAN, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TTABLE +} /* Maximum number of registers in a Lua function (must fit in 8 bits) */ const MAXREGS = 255; @@ -45,39 +77,39 @@ const MAXREGS = 255; const NO_JUMP = -1; const BinOpr = { - OPR_ADD: 0, - OPR_SUB: 1, - OPR_MUL: 2, - OPR_MOD: 3, - OPR_POW: 4, - OPR_DIV: 5, - OPR_IDIV: 6, - OPR_BAND: 7, - OPR_BOR: 8, - OPR_BXOR: 9, - OPR_SHL: 10, - OPR_SHR: 11, - OPR_CONCAT: 12, - OPR_EQ: 13, - OPR_LT: 14, - OPR_LE: 15, - OPR_NE: 16, - OPR_GT: 17, - OPR_GE: 18, - OPR_AND: 19, - OPR_OR: 20, + OPR_ADD: 0, + OPR_SUB: 1, + OPR_MUL: 2, + OPR_MOD: 3, + OPR_POW: 4, + OPR_DIV: 5, + OPR_IDIV: 6, + OPR_BAND: 7, + OPR_BOR: 8, + OPR_BXOR: 9, + OPR_SHL: 10, + OPR_SHR: 11, + OPR_CONCAT: 12, + OPR_EQ: 13, + OPR_LT: 14, + OPR_LE: 15, + OPR_NE: 16, + OPR_GT: 17, + OPR_GE: 18, + OPR_AND: 19, + OPR_OR: 20, OPR_NOBINOPR: 21 }; const UnOpr = { - OPR_MINUS: 0, - OPR_BNOT: 1, - OPR_NOT: 2, - OPR_LEN: 3, - OPR_NOUNOPR: 4 + OPR_MINUS: 0, + OPR_BNOT: 1, + OPR_NOT: 2, + OPR_LEN: 3, + OPR_NOUNOPR: 4 }; -const hasjumps = function(e) { +const hasjumps = function (e) { return e.t !== e.f; }; @@ -85,8 +117,8 @@ const hasjumps = function(e) { ** If expression is a numeric constant returns either true or a new TValue ** (depending on 'make_tvalue'). Otherwise, returns false. */ -const tonumeral = function(e, make_tvalue) { - let ek = lparser.expkind; +const tonumeral = function (e, make_tvalue) { + let ek = expkind; if (hasjumps(e)) return false; /* not a numeral */ switch (e.k) { @@ -110,20 +142,20 @@ const tonumeral = function(e, make_tvalue) { ** range of previous instruction instead of emitting a new one. (For ** instance, 'local a; local b' will generate a single opcode.) */ -const luaK_nil = function(fs, from, n) { +const luaK_nil = function (fs, from, n) { let previous; let l = from + n - 1; /* last register to set nil */ if (fs.pc > fs.lasttarget) { /* no jumps to current position? */ - previous = fs.f.code[fs.pc-1]; + previous = fs.f.code[fs.pc - 1]; if (previous.opcode === OpCodesI.OP_LOADNIL) { /* previous is LOADNIL? */ let pfrom = previous.A; /* get previous range */ let pl = pfrom + previous.B; if ((pfrom <= from && from <= pl + 1) || - (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ + (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ if (pl > l) l = pl; /* l = max(l, pl) */ - lopcodes.SETARG_A(previous, from); - lopcodes.SETARG_B(previous, l - from); + SETARG_A(previous, from); + SETARG_B(previous, l - from); return; } } /* else go through */ @@ -131,7 +163,7 @@ const luaK_nil = function(fs, from, n) { luaK_codeABC(fs, OpCodesI.OP_LOADNIL, from, n - 1, 0); /* else no optimization */ }; -const getinstruction = function(fs, e) { +const getinstruction = function (fs, e) { return fs.f.code[e.u.info]; }; @@ -139,7 +171,7 @@ const getinstruction = function(fs, e) { ** Gets the destination address of a jump instruction. Used to traverse ** a list of jumps. */ -const getjump = function(fs, pc) { +const getjump = function (fs, pc) { let offset = fs.f.code[pc].sBx; if (offset === NO_JUMP) /* point to itself represents end of list */ return NO_JUMP; /* end of list */ @@ -151,19 +183,19 @@ const getjump = function(fs, pc) { ** Fix jump instruction at position 'pc' to jump to 'dest'. ** (Jump addresses are relative in Lua) */ -const fixjump = function(fs, pc, dest) { +const fixjump = function (fs, pc, dest) { let jmp = fs.f.code[pc]; let offset = dest - (pc + 1); lua_assert(dest !== NO_JUMP); - if (Math.abs(offset) > lopcodes.MAXARG_sBx) - llex.luaX_syntaxerror(fs.ls, to_luastring("control structure too long", true)); - lopcodes.SETARG_sBx(jmp, offset); + if (Math.abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs.ls, to_luastring('control structure too long', true)); + SETARG_sBx(jmp, offset); }; /* ** Concatenate jump-list 'l2' into jump-list 'l1' */ -const luaK_concat = function(fs, l1, l2) { +const luaK_concat = function (fs, l1, l2) { if (l2 === NO_JUMP) return l1; /* nothing to concatenate? */ else if (l1 === NO_JUMP) /* no original list? */ l1 = l2; @@ -194,14 +226,14 @@ const luaK_jump = function (fs) { return j; }; -const luaK_jumpto = function(fs, t) { +const luaK_jumpto = function (fs, t) { return luaK_patchlist(fs, luaK_jump(fs), t); }; /* ** Code a 'return' instruction */ -const luaK_ret = function(fs, first, nret) { +const luaK_ret = function (fs, first, nret) { luaK_codeABC(fs, OpCodesI.OP_RETURN, first, nret + 1, 0); }; @@ -209,7 +241,7 @@ const luaK_ret = function(fs, first, nret) { ** Code a "conditional jump", that is, a test or comparison opcode ** followed by a jump. Return jump position. */ -const condjump = function(fs, op, A, B, C) { +const condjump = function (fs, op, A, B, C) { luaK_codeABC(fs, op, A, B, C); return luaK_jump(fs); }; @@ -218,7 +250,7 @@ const condjump = function(fs, op, A, B, C) { ** returns current 'pc' and marks it as a jump target (to avoid wrong ** optimizations with consecutive instructions not in the same basic block). */ -const luaK_getlabel = function(fs) { +const luaK_getlabel = function (fs) { fs.lasttarget = fs.pc; return fs.pc; }; @@ -228,13 +260,13 @@ const luaK_getlabel = function(fs) { ** jump (that is, its condition), or the jump itself if it is ** unconditional. */ -const getjumpcontroloffset = function(fs, pc) { - if (pc >= 1 && lopcodes.testTMode(fs.f.code[pc - 1].opcode)) +const getjumpcontroloffset = function (fs, pc) { + if (pc >= 1 && testTMode(fs.f.code[pc - 1].opcode)) return pc - 1; else return pc; }; -const getjumpcontrol = function(fs, pc) { +const getjumpcontrol = function (fs, pc) { return fs.f.code[getjumpcontroloffset(fs, pc)]; }; @@ -245,17 +277,17 @@ const getjumpcontrol = function(fs, pc) { ** register. Otherwise, change instruction to a simple 'TEST' (produces ** no register value) */ -const patchtestreg = function(fs, node, reg) { +const patchtestreg = function (fs, node, reg) { let pc = getjumpcontroloffset(fs, node); let i = fs.f.code[pc]; if (i.opcode !== OpCodesI.OP_TESTSET) return false; /* cannot patch other instructions */ - if (reg !== lopcodes.NO_REG && reg !== i.B) - lopcodes.SETARG_A(i, reg); + if (reg !== NO_REG && reg !== i.B) + SETARG_A(i, reg); else { /* no register to put value or register already has the value; change instruction to simple test */ - fs.f.code[pc] = lopcodes.CREATE_ABC(OpCodesI.OP_TEST, i.B, 0, i.C); + fs.f.code[pc] = CREATE_ABC(OpCodesI.OP_TEST, i.B, 0, i.C); } return true; }; @@ -263,9 +295,9 @@ const patchtestreg = function(fs, node, reg) { /* ** Traverse a list of tests ensuring no one produces a value */ -const removevalues = function(fs, list) { +const removevalues = function (fs, list) { for (; list !== NO_JUMP; list = getjump(fs, list)) - patchtestreg(fs, list, lopcodes.NO_REG); + patchtestreg(fs, list, NO_REG); }; /* @@ -273,7 +305,7 @@ const removevalues = function(fs, list) { ** registers: tests producing values jump to 'vtarget' (and put their ** values in 'reg'), other tests jump to 'dtarget'. */ -const patchlistaux = function(fs, list, vtarget, reg, dtarget) { +const patchlistaux = function (fs, list, vtarget, reg, dtarget) { while (list !== NO_JUMP) { let next = getjump(fs, list); if (patchtestreg(fs, list, reg)) @@ -289,8 +321,8 @@ const patchlistaux = function(fs, list, vtarget, reg, dtarget) { ** to current position with no values) and reset list of pending ** jumps */ -const dischargejpc = function(fs) { - patchlistaux(fs, fs.jpc, fs.pc, lopcodes.NO_REG, fs.pc); +const dischargejpc = function (fs) { + patchlistaux(fs, fs.jpc, fs.pc, NO_REG, fs.pc); fs.jpc = NO_JUMP; }; @@ -298,7 +330,7 @@ const dischargejpc = function(fs) { ** Add elements in 'list' to list of pending jumps to "here" ** (current position) */ -const luaK_patchtohere = function(fs, list) { +const luaK_patchtohere = function (fs, list) { luaK_getlabel(fs); /* mark "here" as a jump target */ fs.jpc = luaK_concat(fs, fs.jpc, list); }; @@ -308,12 +340,12 @@ const luaK_patchtohere = function(fs, list) { ** (The assert means that we cannot fix a jump to a forward address ** because we only know addresses once code is generated.) */ -const luaK_patchlist = function(fs, list, target) { +const luaK_patchlist = function (fs, list, target) { if (target === fs.pc) /* 'target' is current position? */ luaK_patchtohere(fs, list); /* add list to pending jumps */ else { lua_assert(target < fs.pc); - patchlistaux(fs, list, target, lopcodes.NO_REG, target); + patchlistaux(fs, list, target, NO_REG, target); } }; @@ -322,12 +354,12 @@ const luaK_patchlist = function(fs, list, target) { ** (The assertion checks that jumps either were closing nothing ** or were closing higher levels, from inner blocks.) */ -const luaK_patchclose = function(fs, list, level) { +const luaK_patchclose = function (fs, list, level) { level++; /* argument is +1 to reserve 0 as non-op */ for (; list !== NO_JUMP; list = getjump(fs, list)) { let ins = fs.f.code[list]; lua_assert(ins.opcode === OpCodesI.OP_JMP && (ins.A === 0 || ins.A >= level)); - lopcodes.SETARG_A(ins, level); + SETARG_A(ins, level); } }; @@ -335,7 +367,7 @@ const luaK_patchclose = function(fs, list, level) { ** Emit instruction 'i', checking for array sizes and saving also its ** line information. Return 'i' position. */ -const luaK_code = function(fs, i) { +const luaK_code = function (fs, i) { let f = fs.f; dischargejpc(fs); /* 'pc' will change */ /* put new instruction in code array */ @@ -348,34 +380,34 @@ const luaK_code = function(fs, i) { ** Format and emit an 'iABC' instruction. (Assertions check consistency ** of parameters versus opcode.) */ -const luaK_codeABC = function(fs, o, a, b, c) { - lua_assert(lopcodes.getOpMode(o) === lopcodes.iABC); - lua_assert(lopcodes.getBMode(o) !== lopcodes.OpArgN || b === 0); - lua_assert(lopcodes.getCMode(o) !== lopcodes.OpArgN || c === 0); - lua_assert(a <= lopcodes.MAXARG_A && b <= lopcodes.MAXARG_B && c <= lopcodes.MAXARG_C); - return luaK_code(fs, lopcodes.CREATE_ABC(o, a, b, c)); +const luaK_codeABC = function (fs, o, a, b, c) { + lua_assert(getOpMode(o) === iABC); + lua_assert(getBMode(o) !== OpArgN || b === 0); + lua_assert(getCMode(o) !== OpArgN || c === 0); + lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); + return luaK_code(fs, CREATE_ABC(o, a, b, c)); }; /* ** Format and emit an 'iABx' instruction. */ -const luaK_codeABx = function(fs, o, a, bc) { - lua_assert(lopcodes.getOpMode(o) === lopcodes.iABx || lopcodes.getOpMode(o) === lopcodes.iAsBx); - lua_assert(lopcodes.getCMode(o) === lopcodes.OpArgN); - lua_assert(a <= lopcodes.MAXARG_A && bc <= lopcodes.MAXARG_Bx); - return luaK_code(fs, lopcodes.CREATE_ABx(o, a, bc)); +const luaK_codeABx = function (fs, o, a, bc) { + lua_assert(getOpMode(o) === iABx || getOpMode(o) === iAsBx); + lua_assert(getCMode(o) === OpArgN); + lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); + return luaK_code(fs, CREATE_ABx(o, a, bc)); }; -const luaK_codeAsBx = function(fs,o,A,sBx) { - return luaK_codeABx(fs, o, A, (sBx) + lopcodes.MAXARG_sBx); +const luaK_codeAsBx = function (fs, o, A, sBx) { + return luaK_codeABx(fs, o, A, (sBx) + MAXARG_sBx); }; /* ** Emit an "extra argument" instruction (format 'iAx') */ -const codeextraarg = function(fs, a) { - lua_assert(a <= lopcodes.MAXARG_Ax); - return luaK_code(fs, lopcodes.CREATE_Ax(OpCodesI.OP_EXTRAARG, a)); +const codeextraarg = function (fs, a) { + lua_assert(a <= MAXARG_Ax); + return luaK_code(fs, CREATE_Ax(OpCodesI.OP_EXTRAARG, a)); }; /* @@ -383,8 +415,8 @@ const codeextraarg = function(fs, a) { ** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX' ** instruction with "extra argument". */ -const luaK_codek = function(fs, reg, k) { - if (k <= lopcodes.MAXARG_Bx) +const luaK_codek = function (fs, reg, k) { + if (k <= MAXARG_Bx) return luaK_codeABx(fs, OpCodesI.OP_LOADK, reg, k); else { let p = luaK_codeABx(fs, OpCodesI.OP_LOADKX, reg, 0); @@ -397,11 +429,11 @@ const luaK_codek = function(fs, reg, k) { ** Check register-stack level, keeping track of its maximum size ** in field 'maxstacksize' */ -const luaK_checkstack = function(fs, n) { +const luaK_checkstack = function (fs, n) { let newstack = fs.freereg + n; if (newstack > fs.f.maxstacksize) { if (newstack >= MAXREGS) - llex.luaX_syntaxerror(fs.ls, to_luastring("function or expression needs too many registers", true)); + luaX_syntaxerror(fs.ls, to_luastring('function or expression needs too many registers', true)); fs.f.maxstacksize = newstack; } }; @@ -409,7 +441,7 @@ const luaK_checkstack = function(fs, n) { /* ** Reserve 'n' registers in register stack */ -const luaK_reserveregs = function(fs, n) { +const luaK_reserveregs = function (fs, n) { luaK_checkstack(fs, n); fs.freereg += n; }; @@ -418,8 +450,8 @@ const luaK_reserveregs = function(fs, n) { ** Free register 'reg', if it is neither a constant index nor ** a local variable. */ -const freereg = function(fs, reg) { - if (!lopcodes.ISK(reg) && reg >= fs.nactvar) { +const freereg = function (fs, reg) { + if (!ISK(reg) && reg >= fs.nactvar) { fs.freereg--; lua_assert(reg === fs.freereg); } @@ -428,8 +460,8 @@ const freereg = function(fs, reg) { /* ** Free register used by expression 'e' (if any) */ -const freeexp = function(fs, e) { - if (e.k === lparser.expkind.VNONRELOC) +const freeexp = function (fs, e) { + if (e.k === expkind.VNONRELOC) freereg(fs, e.u.info); }; @@ -437,9 +469,9 @@ const freeexp = function(fs, e) { ** Free registers used by expressions 'e1' and 'e2' (if any) in proper ** order. */ -const freeexps = function(fs, e1, e2) { - let r1 = (e1.k === lparser.expkind.VNONRELOC) ? e1.u.info : -1; - let r2 = (e2.k === lparser.expkind.VNONRELOC) ? e2.u.info : -1; +const freeexps = function (fs, e1, e2) { + let r1 = (e1.k === expkind.VNONRELOC) ? e1.u.info : -1; + let r2 = (e2.k === expkind.VNONRELOC) ? e2.u.info : -1; if (r1 > r2) { freereg(fs, r1); freereg(fs, r2); @@ -458,9 +490,9 @@ const freeexps = function(fs, e1, e2) { ** as keys (nil cannot be a key, integer keys can collapse with float ** keys), the caller must provide a useful 'key' for indexing the cache. */ -const addk = function(fs, key, v) { +const addk = function (fs, key, v) { let f = fs.f; - let idx = ltable.luaH_get(fs.L, fs.ls.h, key); /* index scanner table */ + let idx = luaH_get(fs.L, fs.ls.h, key); /* index scanner table */ if (idx.ttisinteger()) { /* is there an index there? */ let k = idx.value; /* correct value? (warning: must distinguish floats from integers!) */ @@ -469,7 +501,7 @@ const addk = function(fs, key, v) { } /* constant not found; create a new entry */ let k = fs.nk; - ltable.luaH_setfrom(fs.L, fs.ls.h, key, new lobject.TValue(LUA_TNUMINT, k)); + luaH_setfrom(fs.L, fs.ls.h, key, new _TValue(LUA_TNUMINT, k)); f.k[k] = v; fs.nk++; return k; @@ -478,7 +510,7 @@ const addk = function(fs, key, v) { /* ** Add a string to list of constants and return its index. */ -const luaK_stringK = function(fs, s) { +const luaK_stringK = function (fs, s) { let o = new TValue(LUA_TLNGSTR, s); return addk(fs, o, o); /* use string itself as key */ }; @@ -489,7 +521,7 @@ const luaK_stringK = function(fs, s) { ** Integers use userdata as keys to avoid collision with floats with ** same value. */ -const luaK_intK = function(fs, n) { +const luaK_intK = function (fs, n) { let k = new TValue(LUA_TLIGHTUSERDATA, n); let o = new TValue(LUA_TNUMINT, n); return addk(fs, k, o); @@ -498,7 +530,7 @@ const luaK_intK = function(fs, n) { /* ** Add a float to list of constants and return its index. */ -const luaK_numberK = function(fs, r) { +const luaK_numberK = function (fs, r) { let o = new TValue(LUA_TNUMFLT, r); return addk(fs, o, o); /* use number itself as key */ }; @@ -507,7 +539,7 @@ const luaK_numberK = function(fs, r) { /* ** Add a boolean to list of constants and return its index. */ -const boolK = function(fs, b) { +const boolK = function (fs, b) { let o = new TValue(LUA_TBOOLEAN, b); return addk(fs, o, o); /* use boolean itself as key */ }; @@ -516,7 +548,7 @@ const boolK = function(fs, b) { /* ** Add nil to list of constants and return its index. */ -const nilK = function(fs) { +const nilK = function (fs) { let v = new TValue(LUA_TNIL, null); let k = new TValue(LUA_TTABLE, fs.ls.h); /* cannot use nil as key; instead use table itself to represent nil */ @@ -528,21 +560,21 @@ const nilK = function(fs) { ** Either 'e' is a multi-ret expression (function call or vararg) ** or 'nresults' is LUA_MULTRET (as any expression can satisfy that). */ -const luaK_setreturns = function(fs, e, nresults) { - let ek = lparser.expkind; +const luaK_setreturns = function (fs, e, nresults) { + let ek = expkind; if (e.k === ek.VCALL) { /* expression is an open function call? */ - lopcodes.SETARG_C(getinstruction(fs, e), nresults + 1); + SETARG_C(getinstruction(fs, e), nresults + 1); } else if (e.k === ek.VVARARG) { let pc = getinstruction(fs, e); - lopcodes.SETARG_B(pc, nresults + 1); - lopcodes.SETARG_A(pc, fs.freereg); + SETARG_B(pc, nresults + 1); + SETARG_A(pc, fs.freereg); luaK_reserveregs(fs, 1); } else lua_assert(nresults === LUA_MULTRET); }; -const luaK_setmultret = function(fs, e) { +const luaK_setmultret = function (fs, e) { luaK_setreturns(fs, e, LUA_MULTRET); }; @@ -556,15 +588,15 @@ const luaK_setmultret = function(fs, e) { ** (Calls are created returning one result, so that does not need ** to be fixed.) */ -const luaK_setoneret = function(fs, e) { - let ek = lparser.expkind; +const luaK_setoneret = function (fs, e) { + let ek = expkind; if (e.k === ek.VCALL) { /* expression is an open function call? */ /* already returns 1 value */ lua_assert(getinstruction(fs, e).C === 2); e.k = ek.VNONRELOC; /* result has fixed position */ e.u.info = getinstruction(fs, e).A; } else if (e.k === ek.VVARARG) { - lopcodes.SETARG_B(getinstruction(fs, e), 2); + SETARG_B(getinstruction(fs, e), 2); e.k = ek.VRELOCABLE; /* can relocate its simple result */ } }; @@ -572,12 +604,12 @@ const luaK_setoneret = function(fs, e) { /* ** Ensure that expression 'e' is not a variable. */ -const luaK_dischargevars = function(fs, e) { - let ek = lparser.expkind; +const luaK_dischargevars = function (fs, e) { + let ek = expkind; switch (e.k) { case ek.VLOCAL: { /* already in a register */ - e.k = ek.VNONRELOC; /* becomes a non-relocatable value */ + e.k = ek.VNONRELOC; /* becomes a non-relocatable value */ break; } case ek.VUPVAL: { /* move value to some (pending) register */ @@ -607,7 +639,7 @@ const luaK_dischargevars = function(fs, e) { } }; -const code_loadbool = function(fs, A, b, jump) { +const code_loadbool = function (fs, A, b, jump) { luaK_getlabel(fs); /* those instructions may be jump targets */ return luaK_codeABC(fs, OpCodesI.OP_LOADBOOL, A, b, jump); }; @@ -616,8 +648,8 @@ const code_loadbool = function(fs, A, b, jump) { ** Ensures expression value is in register 'reg' (and therefore ** 'e' will become a non-relocatable expression). */ -const discharge2reg = function(fs, e, reg) { - let ek = lparser.expkind; +const discharge2reg = function (fs, e, reg) { + let ek = expkind; luaK_dischargevars(fs, e); switch (e.k) { case ek.VNIL: { @@ -642,7 +674,7 @@ const discharge2reg = function(fs, e, reg) { } case ek.VRELOCABLE: { let pc = getinstruction(fs, e); - lopcodes.SETARG_A(pc, reg); /* instruction will put result in 'reg' */ + SETARG_A(pc, reg); /* instruction will put result in 'reg' */ break; } case ek.VNONRELOC: { @@ -662,10 +694,10 @@ const discharge2reg = function(fs, e, reg) { /* ** Ensures expression value is in any register. */ -const discharge2anyreg = function(fs, e) { - if (e.k !== lparser.expkind.VNONRELOC) { /* no fixed register yet? */ +const discharge2anyreg = function (fs, e) { + if (e.k !== expkind.VNONRELOC) { /* no fixed register yet? */ luaK_reserveregs(fs, 1); /* get a register */ - discharge2reg(fs, e, fs.freereg-1); /* put value there */ + discharge2reg(fs, e, fs.freereg - 1); /* put value there */ } }; @@ -673,7 +705,7 @@ const discharge2anyreg = function(fs, e) { ** check whether list has any jump that do not produce a value ** or produce an inverted value */ -const need_value = function(fs, list) { +const need_value = function (fs, list) { for (; list !== NO_JUMP; list = getjump(fs, list)) { let i = getjumpcontrol(fs, list); if (i.opcode !== OpCodesI.OP_TESTSET) return true; @@ -688,8 +720,8 @@ const need_value = function(fs, list) { ** its final position or to "load" instructions (for those tests ** that do not produce values). */ -const exp2reg = function(fs, e, reg) { - let ek = lparser.expkind; +const exp2reg = function (fs, e, reg) { + let ek = expkind; discharge2reg(fs, e, reg); if (e.k === ek.VJMP) /* expression itself is a test? */ e.t = luaK_concat(fs, e.t, e.u.info); /* put this jump in 't' list */ @@ -716,7 +748,7 @@ const exp2reg = function(fs, e, reg) { ** Ensures final expression result (including results from its jump ** lists) is in next available register. */ -const luaK_exp2nextreg = function(fs, e) { +const luaK_exp2nextreg = function (fs, e) { luaK_dischargevars(fs, e); freeexp(fs, e); luaK_reserveregs(fs, 1); @@ -728,9 +760,9 @@ const luaK_exp2nextreg = function(fs, e) { ** Ensures final expression result (including results from its jump ** lists) is in some (any) register and return that register. */ -const luaK_exp2anyreg = function(fs, e) { +const luaK_exp2anyreg = function (fs, e) { luaK_dischargevars(fs, e); - if (e.k === lparser.expkind.VNONRELOC) { /* expression already has a register? */ + if (e.k === expkind.VNONRELOC) { /* expression already has a register? */ if (!hasjumps(e)) /* no jumps? */ return e.u.info; /* result is already in a register */ if (e.u.info >= fs.nactvar) { /* reg. is not a local? */ @@ -746,8 +778,8 @@ const luaK_exp2anyreg = function(fs, e) { ** Ensures final expression result is either in a register or in an ** upvalue. */ -const luaK_exp2anyregup = function(fs, e) { - if (e.k !== lparser.expkind.VUPVAL || hasjumps(e)) +const luaK_exp2anyregup = function (fs, e) { + if (e.k !== expkind.VUPVAL || hasjumps(e)) luaK_exp2anyreg(fs, e); }; @@ -755,7 +787,7 @@ const luaK_exp2anyregup = function(fs, e) { ** Ensures final expression result is either in a register or it is ** a constant. */ -const luaK_exp2val = function(fs, e) { +const luaK_exp2val = function (fs, e) { if (hasjumps(e)) luaK_exp2anyreg(fs, e); else @@ -768,8 +800,8 @@ const luaK_exp2val = function(fs, e) { ** in the range of R/K indices). ** Returns R/K index. */ -const luaK_exp2RK = function(fs, e) { - let ek = lparser.expkind; +const luaK_exp2RK = function (fs, e) { + let ek = expkind; let vk = false; luaK_exp2val(fs, e); switch (e.k) { /* move constants to 'k' */ @@ -784,8 +816,8 @@ const luaK_exp2RK = function(fs, e) { if (vk) { e.k = ek.VK; - if (e.u.info <= lopcodes.MAXINDEXRK) /* constant fits in 'argC'? */ - return lopcodes.RKASK(e.u.info); + if (e.u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ + return RKASK(e.u.info); } /* not a constant in the right range: put it in a register */ @@ -795,8 +827,8 @@ const luaK_exp2RK = function(fs, e) { /* ** Generate code to store result of expression 'ex' into variable 'var'. */ -const luaK_storevar = function(fs, vr, ex) { - let ek = lparser.expkind; +const luaK_storevar = function (fs, vr, ex) { + let ek = expkind; switch (vr.k) { case ek.VLOCAL: { freeexp(fs, ex); @@ -822,12 +854,12 @@ const luaK_storevar = function(fs, vr, ex) { /* ** Emit SELF instruction (convert expression 'e' into 'e:key(e,'). */ -const luaK_self = function(fs, e, key) { +const luaK_self = function (fs, e, key) { luaK_exp2anyreg(fs, e); let ereg = e.u.info; /* register where 'e' was placed */ freeexp(fs, e); e.u.info = fs.freereg; /* base register for op_self */ - e.k = lparser.expkind.VNONRELOC; /* self expression has a fixed register */ + e.k = expkind.VNONRELOC; /* self expression has a fixed register */ luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ luaK_codeABC(fs, OpCodesI.OP_SELF, e.u.info, ereg, luaK_exp2RK(fs, key)); freeexp(fs, key); @@ -836,10 +868,10 @@ const luaK_self = function(fs, e, key) { /* ** Negate condition 'e' (where 'e' is a comparison). */ -const negatecondition = function(fs, e) { +const negatecondition = function (fs, e) { let pc = getjumpcontrol(fs, e.u.info); - lua_assert(lopcodes.testTMode(pc.opcode) && pc.opcode !== OpCodesI.OP_TESTSET && pc.opcode !== OpCodesI.OP_TEST); - lopcodes.SETARG_A(pc, !(pc.A)); + lua_assert(testTMode(pc.opcode) && pc.opcode !== OpCodesI.OP_TESTSET && pc.opcode !== OpCodesI.OP_TEST); + SETARG_A(pc, !(pc.A)); }; /* @@ -848,8 +880,8 @@ const negatecondition = function(fs, e) { ** Optimize when 'e' is 'not' something, inverting the condition ** and removing the 'not'. */ -const jumponcond = function(fs, e, cond) { - if (e.k === lparser.expkind.VRELOCABLE) { +const jumponcond = function (fs, e, cond) { + if (e.k === expkind.VRELOCABLE) { let ie = getinstruction(fs, e); if (ie.opcode === OpCodesI.OP_NOT) { fs.pc--; /* remove previous OP_NOT */ @@ -859,14 +891,14 @@ const jumponcond = function(fs, e, cond) { } discharge2anyreg(fs, e); freeexp(fs, e); - return condjump(fs, OpCodesI.OP_TESTSET, lopcodes.NO_REG, e.u.info, cond); + return condjump(fs, OpCodesI.OP_TESTSET, NO_REG, e.u.info, cond); }; /* ** Emit code to go through if 'e' is true, jump otherwise. */ -const luaK_goiftrue = function(fs, e) { - let ek = lparser.expkind; +const luaK_goiftrue = function (fs, e) { + let ek = expkind; let pc; /* pc of new jump */ luaK_dischargevars(fs, e); switch (e.k) { @@ -892,8 +924,8 @@ const luaK_goiftrue = function(fs, e) { /* ** Emit code to go through if 'e' is false, jump otherwise. */ -const luaK_goiffalse = function(fs, e) { - let ek = lparser.expkind; +const luaK_goiffalse = function (fs, e) { + let ek = expkind; let pc; /* pc of new jump */ luaK_dischargevars(fs, e); switch (e.k) { @@ -918,8 +950,8 @@ const luaK_goiffalse = function(fs, e) { /* ** Code 'not e', doing constant folding. */ -const codenot = function(fs, e) { - let ek = lparser.expkind; +const codenot = function (fs, e) { + let ek = expkind; luaK_dischargevars(fs, e); switch (e.k) { case ek.VNIL: case ek.VFALSE: { @@ -953,9 +985,9 @@ const codenot = function(fs, e) { ** Create expression 't[k]'. 't' must have its final result already in a ** register or upvalue. */ -const luaK_indexed = function(fs, t, k) { - let ek = lparser.expkind; - lua_assert(!hasjumps(t) && (lparser.vkisinreg(t.k) || t.k === ek.VUPVAL)); +const luaK_indexed = function (fs, t, k) { + let ek = expkind; + lua_assert(!hasjumps(t) && (vkisinreg(t.k) || t.k === ek.VUPVAL)); t.u.ind.t = t.u.info; /* register or upvalue index */ t.u.ind.idx = luaK_exp2RK(fs, k); /* R/K index for key */ t.u.ind.vt = (t.k === ek.VUPVAL) ? ek.VUPVAL : ek.VLOCAL; @@ -967,11 +999,11 @@ const luaK_indexed = function(fs, t, k) { ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */ -const validop = function(op, v1, v2) { +const validop = function (op, v1, v2) { switch (op) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ - return (lvm.tointeger(v1) !== false && lvm.tointeger(v2) !== false); + return (tointeger(v1) !== false && tointeger(v2) !== false); } case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ return (v2.value !== 0); @@ -983,13 +1015,13 @@ const validop = function(op, v1, v2) { ** Try to "constant-fold" an operation; return 1 iff successful. ** (In this case, 'e1' has the final result.) */ -const constfolding = function(op, e1, e2) { - let ek = lparser.expkind; +const constfolding = function (op, e1, e2) { + let ek = expkind; let v1, v2; if (!(v1 = tonumeral(e1, true)) || !(v2 = tonumeral(e2, true)) || !validop(op, v1, v2)) return 0; /* non-numeric operands or not safe to fold */ let res = new TValue(); /* FIXME */ - lobject.luaO_arith(null, op, v1, v2, res); /* does operation */ + luaO_arith(null, op, v1, v2, res); /* does operation */ if (res.ttisinteger()) { e1.k = ek.VKINT; e1.u.ival = res.value; @@ -1009,11 +1041,11 @@ const constfolding = function(op, e1, e2) { ** (everything but 'not'). ** Expression to produce final result will be encoded in 'e'. */ -const codeunexpval = function(fs, op, e, line) { +const codeunexpval = function (fs, op, e, line) { let r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ freeexp(fs, e); e.u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ - e.k = lparser.expkind.VRELOCABLE; /* all those operations are relocatable */ + e.k = expkind.VRELOCABLE; /* all those operations are relocatable */ luaK_fixline(fs, line); }; @@ -1026,12 +1058,12 @@ const codeunexpval = function(fs, op, e, line) { ** in "stack order" (that is, first on 'e2', which may have more ** recent registers to be released). */ -const codebinexpval = function(fs, op, e1, e2, line) { +const codebinexpval = function (fs, op, e1, e2, line) { let rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */ let rk1 = luaK_exp2RK(fs, e1); freeexps(fs, e1, e2); e1.u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */ - e1.k = lparser.expkind.VRELOCABLE; /* all those operations are relocatable */ + e1.k = expkind.VRELOCABLE; /* all those operations are relocatable */ luaK_fixline(fs, line); }; @@ -1040,12 +1072,12 @@ const codebinexpval = function(fs, op, e1, e2, line) { ** Emit code for comparisons. ** 'e1' was already put in R/K form by 'luaK_infix'. */ -const codecomp = function(fs, opr, e1, e2) { - let ek = lparser.expkind; +const codecomp = function (fs, opr, e1, e2) { + let ek = expkind; let rk1; if (e1.k === ek.VK) - rk1 = lopcodes.RKASK(e1.u.info); + rk1 = RKASK(e1.u.info); else { lua_assert(e1.k === ek.VNONRELOC); rk1 = e1.u.info; @@ -1076,9 +1108,9 @@ const codecomp = function(fs, opr, e1, e2) { /* ** Apply prefix operation 'op' to expression 'e'. */ -const luaK_prefix = function(fs, op, e, line) { - let ef = new lparser.expdesc(); - ef.k = lparser.expkind.VKINT; +const luaK_prefix = function (fs, op, e, line) { + let ef = new expdesc(); + ef.k = expkind.VKINT; ef.u.ival = ef.u.nval = ef.u.info = 0; ef.t = NO_JUMP; ef.f = NO_JUMP; @@ -1086,7 +1118,7 @@ const luaK_prefix = function(fs, op, e, line) { case UnOpr.OPR_MINUS: case UnOpr.OPR_BNOT: /* use 'ef' as fake 2nd operand */ if (constfolding(op + LUA_OPUNM, e, ef)) break; - /* FALLTHROUGH */ + /* FALLTHROUGH */ case UnOpr.OPR_LEN: codeunexpval(fs, op + OpCodesI.OP_UNM, e, line); break; @@ -1098,7 +1130,7 @@ const luaK_prefix = function(fs, op, e, line) { ** Process 1st operand 'v' of binary operation 'op' before reading ** 2nd operand. */ -const luaK_infix = function(fs, op, v) { +const luaK_infix = function (fs, op, v) { switch (op) { case BinOpr.OPR_AND: { luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ @@ -1135,8 +1167,8 @@ const luaK_infix = function(fs, op, v) { ** concatenation is right associative), merge second CONCAT into first ** one. */ -const luaK_posfix = function(fs, op, e1, e2, line) { - let ek = lparser.expkind; +const luaK_posfix = function (fs, op, e1, e2, line) { + let ek = expkind; switch (op) { case BinOpr.OPR_AND: { lua_assert(e1.t === NO_JUMP); /* list closed by 'luK_infix' */ @@ -1158,7 +1190,7 @@ const luaK_posfix = function(fs, op, e1, e2, line) { if (e2.k === ek.VRELOCABLE && ins.opcode === OpCodesI.OP_CONCAT) { lua_assert(e1.u.info === ins.B - 1); freeexp(fs, e1); - lopcodes.SETARG_B(ins, e1.u.info); + SETARG_B(ins, e1.u.info); e1.k = ek.VRELOCABLE; e1.u.info = e2.u.info; } else { @@ -1188,7 +1220,7 @@ const luaK_posfix = function(fs, op, e1, e2, line) { /* ** Change line information associated with current position. */ -const luaK_fixline = function(fs, line) { +const luaK_fixline = function (fs, line) { fs.f.lineinfo[fs.pc - 1] = line; }; @@ -1199,61 +1231,17 @@ const luaK_fixline = function(fs, line) { ** 'tostore' is number of values (in registers 'base + 1',...) to add to ** table (or LUA_MULTRET to add up to stack top). */ -const luaK_setlist = function(fs, base, nelems, tostore) { - let c = (nelems - 1)/lopcodes.LFIELDS_PER_FLUSH + 1; +const luaK_setlist = function (fs, base, nelems, tostore) { + let c = (nelems - 1) / LFIELDS_PER_FLUSH + 1; let b = (tostore === LUA_MULTRET) ? 0 : tostore; - lua_assert(tostore !== 0 && tostore <= lopcodes.LFIELDS_PER_FLUSH); - if (c <= lopcodes.MAXARG_C) + lua_assert(tostore !== 0 && tostore <= LFIELDS_PER_FLUSH); + if (c <= MAXARG_C) luaK_codeABC(fs, OpCodesI.OP_SETLIST, base, b, c); - else if (c <= lopcodes.MAXARG_Ax) { + else if (c <= MAXARG_Ax) { luaK_codeABC(fs, OpCodesI.OP_SETLIST, base, b, 0); codeextraarg(fs, c); } else - llex.luaX_syntaxerror(fs.ls, to_luastring("constructor too long", true)); + luaX_syntaxerror(fs.ls, to_luastring('constructor too long', true)); fs.freereg = base + 1; /* free registers with list values */ }; - - -module.exports.BinOpr = BinOpr; -module.exports.NO_JUMP = NO_JUMP; -module.exports.UnOpr = UnOpr; -module.exports.getinstruction = getinstruction; -module.exports.luaK_checkstack = luaK_checkstack; -module.exports.luaK_code = luaK_code; -module.exports.luaK_codeABC = luaK_codeABC; -module.exports.luaK_codeABx = luaK_codeABx; -module.exports.luaK_codeAsBx = luaK_codeAsBx; -module.exports.luaK_codek = luaK_codek; -module.exports.luaK_concat = luaK_concat; -module.exports.luaK_dischargevars = luaK_dischargevars; -module.exports.luaK_exp2RK = luaK_exp2RK; -module.exports.luaK_exp2anyreg = luaK_exp2anyreg; -module.exports.luaK_exp2anyregup = luaK_exp2anyregup; -module.exports.luaK_exp2nextreg = luaK_exp2nextreg; -module.exports.luaK_exp2val = luaK_exp2val; -module.exports.luaK_fixline = luaK_fixline; -module.exports.luaK_getlabel = luaK_getlabel; -module.exports.luaK_goiffalse = luaK_goiffalse; -module.exports.luaK_goiftrue = luaK_goiftrue; -module.exports.luaK_indexed = luaK_indexed; -module.exports.luaK_infix = luaK_infix; -module.exports.luaK_intK = luaK_intK; -module.exports.luaK_jump = luaK_jump; -module.exports.luaK_jumpto = luaK_jumpto; -module.exports.luaK_nil = luaK_nil; -module.exports.luaK_numberK = luaK_numberK; -module.exports.luaK_patchclose = luaK_patchclose; -module.exports.luaK_patchlist = luaK_patchlist; -module.exports.luaK_patchtohere = luaK_patchtohere; -module.exports.luaK_posfix = luaK_posfix; -module.exports.luaK_prefix = luaK_prefix; -module.exports.luaK_reserveregs = luaK_reserveregs; -module.exports.luaK_ret = luaK_ret; -module.exports.luaK_self = luaK_self; -module.exports.luaK_setlist = luaK_setlist; -module.exports.luaK_setmultret = luaK_setmultret; -module.exports.luaK_setoneret = luaK_setoneret; -module.exports.luaK_setreturns = luaK_setreturns; -module.exports.luaK_storevar = luaK_storevar; -module.exports.luaK_stringK = luaK_stringK; diff --git a/src/lcorolib.js b/src/lcorolib.js index d290f32b..8139dd9c 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -1,6 +1,4 @@ -"use strict"; - -const { +import { LUA_OK, LUA_TFUNCTION, LUA_TSTRING, @@ -27,28 +25,23 @@ const { lua_upvalueindex, lua_xmove, lua_yield -} = require('./lua.js'); -const { - luaL_argcheck, - luaL_checktype, - luaL_newlib, - luaL_where -} = require('./lauxlib.js'); - -const getco = function(L) { +} from './lua.js'; +import { luaL_argcheck, luaL_checktype, luaL_newlib, luaL_where } from './lauxlib.js'; + +const getco = function (L) { let co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "thread expected"); + luaL_argcheck(L, co, 1, 'thread expected'); return co; }; -const auxresume = function(L, co, narg) { +const auxresume = function (L, co, narg) { if (!lua_checkstack(co, narg)) { - lua_pushliteral(L, "too many arguments to resume"); + lua_pushliteral(L, 'too many arguments to resume'); return -1; /* error flag */ } if (lua_status(co) === LUA_OK && lua_gettop(co) === 0) { - lua_pushliteral(L, "cannot resume dead coroutine"); + lua_pushliteral(L, 'cannot resume dead coroutine'); return -1; /* error flag */ } @@ -58,11 +51,11 @@ const auxresume = function(L, co, narg) { let nres = lua_gettop(co); if (!lua_checkstack(L, nres + 1)) { lua_pop(co, nres); /* remove results anyway */ - lua_pushliteral(L, "too many results to resume"); + lua_pushliteral(L, 'too many results to resume'); return -1; /* error flag */ } - lua_xmove(co, L, nres); /* move yielded values */ + lua_xmove(co, L, nres); /* move yielded values */ return nres; } else { lua_xmove(co, L, 1); /* move error message */ @@ -70,7 +63,7 @@ const auxresume = function(L, co, narg) { } }; -const luaB_coresume = function(L) { +const luaB_coresume = function (L) { let co = getco(L); let r = auxresume(L, co, lua_gettop(L) - 1); if (r < 0) { @@ -84,7 +77,7 @@ const luaB_coresume = function(L) { } }; -const luaB_auxwrap = function(L) { +const luaB_auxwrap = function (L) { let co = lua_tothread(L, lua_upvalueindex(1)); let r = auxresume(L, co, lua_gettop(L)); if (r < 0) { @@ -100,7 +93,7 @@ const luaB_auxwrap = function(L) { return r; }; -const luaB_cocreate = function(L) { +const luaB_cocreate = function (L) { luaL_checktype(L, 1, LUA_TFUNCTION); let NL = lua_newthread(L); lua_pushvalue(L, 1); /* move function to top */ @@ -108,36 +101,36 @@ const luaB_cocreate = function(L) { return 1; }; -const luaB_cowrap = function(L) { +const luaB_cowrap = function (L) { luaB_cocreate(L); lua_pushcclosure(L, luaB_auxwrap, 1); return 1; }; -const luaB_yield = function(L) { +const luaB_yield = function (L) { return lua_yield(L, lua_gettop(L)); }; -const luaB_costatus = function(L) { +const luaB_costatus = function (L) { let co = getco(L); - if (L === co) lua_pushliteral(L, "running"); + if (L === co) lua_pushliteral(L, 'running'); else { switch (lua_status(co)) { case LUA_YIELD: - lua_pushliteral(L, "suspended"); + lua_pushliteral(L, 'suspended'); break; case LUA_OK: { let ar = new lua_Debug(); if (lua_getstack(co, 0, ar) > 0) /* does it have frames? */ - lua_pushliteral(L, "normal"); /* it is running */ + lua_pushliteral(L, 'normal'); /* it is running */ else if (lua_gettop(co) === 0) - lua_pushliteral(L, "dead"); + lua_pushliteral(L, 'dead'); else - lua_pushliteral(L, "suspended"); /* initial state */ + lua_pushliteral(L, 'suspended'); /* initial state */ break; } default: /* some error occurred */ - lua_pushliteral(L, "dead"); + lua_pushliteral(L, 'dead'); break; } } @@ -145,29 +138,27 @@ const luaB_costatus = function(L) { return 1; }; -const luaB_yieldable = function(L) { +const luaB_yieldable = function (L) { lua_pushboolean(L, lua_isyieldable(L)); return 1; }; -const luaB_corunning = function(L) { +const luaB_corunning = function (L) { lua_pushboolean(L, lua_pushthread(L)); return 2; }; const co_funcs = { - "create": luaB_cocreate, - "isyieldable": luaB_yieldable, - "resume": luaB_coresume, - "running": luaB_corunning, - "status": luaB_costatus, - "wrap": luaB_cowrap, - "yield": luaB_yield + 'create': luaB_cocreate, + 'isyieldable': luaB_yieldable, + 'resume': luaB_coresume, + 'running': luaB_corunning, + 'status': luaB_costatus, + 'wrap': luaB_cowrap, + 'yield': luaB_yield }; -const luaopen_coroutine = function(L) { +const luaopen_coroutine = function (L) { luaL_newlib(L, co_funcs); return 1; }; - -module.exports.luaopen_coroutine = luaopen_coroutine; diff --git a/src/ldblib.js b/src/ldblib.js index 03be3dfe..8d909705 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -1,6 +1,4 @@ -"use strict"; - -const { +import { LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, @@ -57,8 +55,8 @@ const { lua_upvalueid, lua_upvaluejoin, lua_xmove -} = require('./lua.js'); -const { +} from './lua.js'; +import { luaL_argcheck, luaL_argerror, luaL_checkany, @@ -72,29 +70,27 @@ const { luaL_optstring, luaL_traceback, lua_writestringerror -} = require('./lauxlib.js'); -const lualib = require('./lualib.js'); -const { - luastring_indexOf, - to_luastring -} = require("./fengaricore.js"); +} from './lauxlib.js'; +import { lua_assert } from './lualib.js'; +import { luastring_indexOf, to_luastring } from './fengaricore.js'; +import readlineSync from 'readline-sync'; /* ** If L1 != L, L1 can be in any state, and therefore there are no ** guarantees about its stack space; any push in L1 must be ** checked. */ -const checkstack = function(L, L1, n) { +const checkstack = function (L, L1, n) { if (L !== L1 && !lua_checkstack(L1, n)) - luaL_error(L, to_luastring("stack overflow", true)); + luaL_error(L, to_luastring('stack overflow', true)); }; -const db_getregistry = function(L) { +const db_getregistry = function (L) { lua_pushvalue(L, LUA_REGISTRYINDEX); return 1; }; -const db_getmetatable = function(L) { +const db_getmetatable = function (L) { luaL_checkany(L, 1); if (!lua_getmetatable(L, 1)) { lua_pushnil(L); /* no metatable */ @@ -102,15 +98,15 @@ const db_getmetatable = function(L) { return 1; }; -const db_setmetatable = function(L) { +const db_setmetatable = function (L) { const t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table expected"); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, 'nil or table expected'); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; /* return 1st argument */ }; -const db_getuservalue = function(L) { +const db_getuservalue = function (L) { if (lua_type(L, 1) !== LUA_TUSERDATA) lua_pushnil(L); else @@ -119,7 +115,7 @@ const db_getuservalue = function(L) { }; -const db_setuservalue = function(L) { +const db_setuservalue = function (L) { luaL_checktype(L, 1, LUA_TUSERDATA); luaL_checkany(L, 2); lua_settop(L, 2); @@ -133,7 +129,7 @@ const db_setuservalue = function(L) { ** 1 if this argument is present (so that functions can skip it to ** access their other arguments) */ -const getthread = function(L) { +const getthread = function (L) { if (lua_isthread(L, 1)) { return { arg: 1, @@ -152,17 +148,17 @@ const getthread = function(L) { ** from 'lua_getinfo' into result table. Key is always a string; ** value can be a string, an int, or a boolean. */ -const settabss = function(L, k, v) { +const settabss = function (L, k, v) { lua_pushstring(L, v); lua_setfield(L, -2, k); }; -const settabsi = function(L, k, v) { +const settabsi = function (L, k, v) { lua_pushinteger(L, v); lua_setfield(L, -2, k); }; -const settabsb = function(L, k, v) { +const settabsb = function (L, k, v) { lua_pushboolean(L, v); lua_setfield(L, -2, k); }; @@ -175,7 +171,7 @@ const settabsb = function(L, k, v) { ** 'lua_getinfo' on top of the result table so that it can call ** 'lua_setfield'. */ -const treatstackoption = function(L, L1, fname) { +const treatstackoption = function (L, L1, fname) { if (L == L1) lua_rotate(L, -2, 1); /* exchange object and table */ else @@ -189,15 +185,15 @@ const treatstackoption = function(L, L1, fname) { ** two optional outputs (function and line table) from function ** 'lua_getinfo'. */ -const db_getinfo = function(L) { +const db_getinfo = function (L) { let ar = new lua_Debug(); let thread = getthread(L); let arg = thread.arg; let L1 = thread.thread; - let options = luaL_optstring(L, arg + 2, "flnStu"); + let options = luaL_optstring(L, arg + 2, 'flnStu'); checkstack(L, L1, 3); if (lua_isfunction(L, arg + 1)) { /* info about a function? */ - options = lua_pushfstring(L, to_luastring(">%s"), options); /* add '>' to 'options' */ + options = lua_pushfstring(L, to_luastring('>%s'), options); /* add '>' to 'options' */ lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ lua_xmove(L, L1, 1); } else { /* stack level */ @@ -208,36 +204,36 @@ const db_getinfo = function(L) { } if (!lua_getinfo(L1, options, ar)) - luaL_argerror(L, arg + 2, "invalid option"); + luaL_argerror(L, arg + 2, 'invalid option'); lua_newtable(L); /* table to collect results */ if (luastring_indexOf(options, 83 /* 'S'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring("source", true), ar.source); - settabss(L, to_luastring("short_src", true), ar.short_src); - settabsi(L, to_luastring("linedefined", true), ar.linedefined); - settabsi(L, to_luastring("lastlinedefined", true), ar.lastlinedefined); - settabss(L, to_luastring("what", true), ar.what); + settabss(L, to_luastring('source', true), ar.source); + settabss(L, to_luastring('short_src', true), ar.short_src); + settabsi(L, to_luastring('linedefined', true), ar.linedefined); + settabsi(L, to_luastring('lastlinedefined', true), ar.lastlinedefined); + settabss(L, to_luastring('what', true), ar.what); } if (luastring_indexOf(options, 108 /* 'l'.charCodeAt(0) */) > -1) - settabsi(L, to_luastring("currentline", true), ar.currentline); + settabsi(L, to_luastring('currentline', true), ar.currentline); if (luastring_indexOf(options, 117 /* 'u'.charCodeAt(0) */) > -1) { - settabsi(L, to_luastring("nups", true), ar.nups); - settabsi(L, to_luastring("nparams", true), ar.nparams); - settabsb(L, to_luastring("isvararg", true), ar.isvararg); + settabsi(L, to_luastring('nups', true), ar.nups); + settabsi(L, to_luastring('nparams', true), ar.nparams); + settabsb(L, to_luastring('isvararg', true), ar.isvararg); } if (luastring_indexOf(options, 110 /* 'n'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring("name", true), ar.name); - settabss(L, to_luastring("namewhat", true), ar.namewhat); + settabss(L, to_luastring('name', true), ar.name); + settabss(L, to_luastring('namewhat', true), ar.namewhat); } if (luastring_indexOf(options, 116 /* 't'.charCodeAt(0) */) > -1) - settabsb(L, to_luastring("istailcall", true), ar.istailcall); + settabsb(L, to_luastring('istailcall', true), ar.istailcall); if (luastring_indexOf(options, 76 /* 'L'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring("activelines", true)); + treatstackoption(L, L1, to_luastring('activelines', true)); if (luastring_indexOf(options, 102 /* 'f'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring("func", true)); + treatstackoption(L, L1, to_luastring('func', true)); return 1; /* return table */ }; -const db_getlocal = function(L) { +const db_getlocal = function (L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; @@ -250,7 +246,7 @@ const db_getlocal = function(L) { } else { /* stack-level argument */ let level = luaL_checkinteger(L, arg + 1); if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); + return luaL_argerror(L, arg + 1, 'level out of range'); checkstack(L, L1, 1); let name = lua_getlocal(L1, ar, nvar); if (name) { @@ -266,7 +262,7 @@ const db_getlocal = function(L) { } }; -const db_setlocal = function(L) { +const db_setlocal = function (L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; @@ -274,7 +270,7 @@ const db_setlocal = function(L) { let level = luaL_checkinteger(L, arg + 1); let nvar = luaL_checkinteger(L, arg + 2); if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg + 1, "level out of range"); + return luaL_argerror(L, arg + 1, 'level out of range'); luaL_checkany(L, arg + 3); lua_settop(L, arg + 3); checkstack(L, L1, 1); @@ -289,22 +285,22 @@ const db_setlocal = function(L) { /* ** get (if 'get' is true) or set an upvalue from a closure */ -const auxupvalue = function(L, get) { +const auxupvalue = function (L, get) { let n = luaL_checkinteger(L, 2); /* upvalue index */ luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ let name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); if (name === null) return 0; lua_pushstring(L, name); - lua_insert(L, -(get+1)); /* no-op if get is false */ + lua_insert(L, -(get + 1)); /* no-op if get is false */ return get + 1; }; -const db_getupvalue = function(L) { +const db_getupvalue = function (L) { return auxupvalue(L, 1); }; -const db_setupvalue = function(L) { +const db_setupvalue = function (L) { luaL_checkany(L, 3); return auxupvalue(L, 0); }; @@ -313,24 +309,24 @@ const db_setupvalue = function(L) { ** Check whether a given upvalue from a given closure exists and ** returns its index */ -const checkupval = function(L, argf, argnup) { +const checkupval = function (L, argf, argnup) { let nup = luaL_checkinteger(L, argnup); /* upvalue index */ luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ - luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, "invalid upvalue index"); + luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, 'invalid upvalue index'); return nup; }; -const db_upvalueid = function(L) { +const db_upvalueid = function (L) { let n = checkupval(L, 1, 2); lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); return 1; }; -const db_upvaluejoin = function(L) { +const db_upvaluejoin = function (L) { let n1 = checkupval(L, 1, 2); let n2 = checkupval(L, 3, 4); - luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); - luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, 'Lua function expected'); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, 'Lua function expected'); lua_upvaluejoin(L, 1, n1, 3, n2); return 0; }; @@ -339,15 +335,15 @@ const db_upvaluejoin = function(L) { ** The hook table at registry[HOOKKEY] maps threads to their current ** hook function. (We only need the unique address of 'HOOKKEY'.) */ -const HOOKKEY = to_luastring("__hooks__", true); +const HOOKKEY = to_luastring('__hooks__', true); -const hooknames = ["call", "return", "line", "count", "tail call"].map(e => to_luastring(e)); +const hooknames = ['call', 'return', 'line', 'count', 'tail call'].map(e => to_luastring(e)); /* ** Call hook function registered at hook table for the current ** thread (if there is one) */ -const hookf = function(L, ar) { +const hookf = function (L, ar) { lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); let hooktable = lua_touserdata(L, -1); let proxy = hooktable.get(L); @@ -357,7 +353,7 @@ const hookf = function(L, ar) { if (ar.currentline >= 0) lua_pushinteger(L, ar.currentline); /* push current line */ else lua_pushnil(L); - lualib.lua_assert(lua_getinfo(L, to_luastring("lS"), ar)); + lua_assert(lua_getinfo(L, to_luastring('lS'), ar)); lua_call(L, 2, 0); /* call hook function */ } }; @@ -365,7 +361,7 @@ const hookf = function(L, ar) { /* ** Convert a string mask (for 'sethook') into a bit mask */ -const makemask = function(smask, count) { +const makemask = function (smask, count) { let mask = 0; if (luastring_indexOf(smask, 99 /* 'c'.charCodeAt(0) */) > -1) mask |= LUA_MASKCALL; if (luastring_indexOf(smask, 114 /* 'r'.charCodeAt(0) */) > -1) mask |= LUA_MASKRET; @@ -377,7 +373,7 @@ const makemask = function(smask, count) { /* ** Convert a bit mask (for 'gethook') into a string mask */ -const unmakemask = function(mask, smask) { +const unmakemask = function (mask, smask) { let i = 0; if (mask & LUA_MASKCALL) smask[i++] = 99 /* 'c'.charCodeAt(0) */; if (mask & LUA_MASKRET) smask[i++] = 114 /* 'r'.charCodeAt(0) */; @@ -385,18 +381,18 @@ const unmakemask = function(mask, smask) { return smask.subarray(0, i); }; -const db_sethook = function(L) { +const db_sethook = function (L) { let mask, count, func; let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; - if (lua_isnoneornil(L, arg+1)) { /* no hook? */ - lua_settop(L, arg+1); + if (lua_isnoneornil(L, arg + 1)) { /* no hook? */ + lua_settop(L, arg + 1); func = null; mask = 0; count = 0; /* turn off hooks */ } else { const smask = luaL_checkstring(L, arg + 2); - luaL_checktype(L, arg+1, LUA_TFUNCTION); + luaL_checktype(L, arg + 1, LUA_TFUNCTION); count = luaL_optinteger(L, arg + 3, 0); func = hookf; mask = makemask(smask, count); } @@ -415,7 +411,7 @@ const db_sethook = function(L) { return 0; }; -const db_gethook = function(L) { +const db_gethook = function (L) { let thread = getthread(L); let L1 = thread.thread; let buff = new Uint8Array(5); @@ -424,7 +420,7 @@ const db_gethook = function(L) { if (hook === null) /* no hook? */ lua_pushnil(L); else if (hook !== hookf) /* external hook? */ - lua_pushliteral(L, "external hook"); + lua_pushliteral(L, 'external hook'); else { /* hook table must exist */ lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); let hooktable = lua_touserdata(L, -1); @@ -436,7 +432,7 @@ const db_gethook = function(L) { return 3; }; -const db_traceback = function(L) { +const db_traceback = function (L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; @@ -451,65 +447,62 @@ const db_traceback = function(L) { }; const dblib = { - "gethook": db_gethook, - "getinfo": db_getinfo, - "getlocal": db_getlocal, - "getmetatable": db_getmetatable, - "getregistry": db_getregistry, - "getupvalue": db_getupvalue, - "getuservalue": db_getuservalue, - "sethook": db_sethook, - "setlocal": db_setlocal, - "setmetatable": db_setmetatable, - "setupvalue": db_setupvalue, - "setuservalue": db_setuservalue, - "traceback": db_traceback, - "upvalueid": db_upvalueid, - "upvaluejoin": db_upvaluejoin + 'gethook': db_gethook, + 'getinfo': db_getinfo, + 'getlocal': db_getlocal, + 'getmetatable': db_getmetatable, + 'getregistry': db_getregistry, + 'getupvalue': db_getupvalue, + 'getuservalue': db_getuservalue, + 'sethook': db_sethook, + 'setlocal': db_setlocal, + 'setmetatable': db_setmetatable, + 'setupvalue': db_setupvalue, + 'setuservalue': db_setuservalue, + 'traceback': db_traceback, + 'upvalueid': db_upvalueid, + 'upvaluejoin': db_upvaluejoin }; let getinput; -if (typeof process !== "undefined") { // Only with Node - const readlineSync = require('readline-sync'); +if (typeof process !== 'undefined') { // Only with Node readlineSync.setDefaultOptions({ prompt: 'lua_debug> ' }); - getinput = function() { + getinput = function () { return readlineSync.prompt(); }; -} else if (typeof window !== "undefined") { +} else if (typeof window !== 'undefined') { /* if in browser use window.prompt. Doesn't work from web workers. See https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt */ - getinput = function() { - let input = prompt("lua_debug>", ""); - return (input !== null) ? input : ""; + getinput = function () { + let input = prompt('lua_debug>', ''); + return (input !== null) ? input : ''; }; } if (getinput) { - dblib.debug = function(L) { - for (;;) { + dblib.debug = function (L) { + for (; ;) { let input = getinput(); - if (input === "cont") + if (input === 'cont') return 0; if (input.length === 0) continue; let buffer = to_luastring(input); - if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring("=(debug command)", true)) + if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring('=(debug command)', true)) || lua_pcall(L, 0, 0, 0)) { - lua_writestringerror(lua_tojsstring(L, -1), "\n"); + lua_writestringerror(lua_tojsstring(L, -1), '\n'); } lua_settop(L, 0); /* remove eventual returns */ } }; } -const luaopen_debug = function(L) { +const luaopen_debug = function (L) { luaL_newlib(L, dblib); return 1; }; - -module.exports.luaopen_debug = luaopen_debug; diff --git a/src/ldebug.js b/src/ldebug.js index a471c758..927da92e 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -1,46 +1,47 @@ -"use strict"; - -const { +import { LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_MASKCOUNT, LUA_MASKLINE, - constant_types: { - LUA_TBOOLEAN, - LUA_TNIL, - LUA_TTABLE - }, - thread_status: { - LUA_ERRRUN, - LUA_YIELD - }, + LUA_TBOOLEAN, + LUA_TNIL, + LUA_TTABLE, + LUA_ERRRUN, + LUA_YIELD, from_userstring, luastring_eq, luastring_indexOf, to_luastring -} = require('./defs.js'); -const { - api_check, - lua_assert -} = require('./llimits.js'); -const { LUA_IDSIZE } = require('./luaconf.js'); -const lapi = require('./lapi.js'); -const ldo = require('./ldo.js'); -const lfunc = require('./lfunc.js'); -const llex = require('./llex.js'); -const lobject = require('./lobject.js'); -const lopcodes = require('./lopcodes.js'); -const lstate = require('./lstate.js'); -const ltable = require('./ltable.js'); -const ltm = require('./ltm.js'); -const lvm = require('./lvm.js'); - -const currentpc = function(ci) { - lua_assert(ci.callstatus & lstate.CIST_LUA); +} from './defs.js'; +import { api_check, lua_assert } from './llimits.js'; +import { LUA_IDSIZE } from './luaconf.js'; +import { api_incr_top } from './lapi.js'; +import { luaD_callnoyield, luaD_throw, luaD_hook } from './ldo.js'; +import { luaF_getlocalname } from './lfunc.js'; +import { LUA_ENV } from './llex.js'; +import { pushobj2s, setobjs2s, CClosure, luaO_chunkid, TValue, luaO_pushfstring, luaO_pushvfstring } from './lobject.js'; +import { ISK, INDEXK, OpCodesI, testAMode } from './lopcodes.js'; +import { CIST_LUA, CIST_FIN, CIST_TAIL, CIST_HOOKED, CIST_HOOKYIELD } from './lstate.js'; +import { luaH_new, luaH_setint } from './ltable.js'; +import { TMS, luaT_objtypename } from './ltm.js'; +import { cvt2str, tonumber, tointeger } from './lvm.js'; + +const constant_types = { + LUA_TBOOLEAN, + LUA_TNIL, + LUA_TTABLE +}; +const thread_status = { + LUA_ERRRUN, + LUA_YIELD +}; + +const currentpc = function (ci) { + lua_assert(ci.callstatus & CIST_LUA); return ci.l_savedpc - 1; }; -const currentline = function(ci) { +const currentline = function (ci) { return ci.func.value.p.lineinfo.length !== 0 ? ci.func.value.p.lineinfo[currentpc(ci)] : -1; }; @@ -50,7 +51,7 @@ const currentline = function(ci) { ** purposes. (It exchanges 'func' and 'extra'; so, when called again, ** after debugging, it also "re-restores" ** 'func' to its altered value. */ -const swapextra = function(L) { +const swapextra = function (L) { if (L.status === LUA_YIELD) { let ci = L.ci; /* get function that yielded */ let temp = ci.funcOff; /* exchange its 'func' and 'extra' values */ @@ -60,12 +61,12 @@ const swapextra = function(L) { } }; -const lua_sethook = function(L, func, mask, count) { +const lua_sethook = function (L, func, mask, count) { if (func === null || mask === 0) { /* turn off hooks? */ mask = 0; func = null; } - if (L.ci.callstatus & lstate.CIST_LUA) + if (L.ci.callstatus & CIST_LUA) L.oldpc = L.ci.l_savedpc; L.hook = func; L.basehookcount = count; @@ -73,21 +74,21 @@ const lua_sethook = function(L, func, mask, count) { L.hookmask = mask; }; -const lua_gethook = function(L) { +const lua_gethook = function (L) { return L.hook; }; -const lua_gethookmask = function(L) { +const lua_gethookmask = function (L) { return L.hookmask; }; -const lua_gethookcount = function(L) { +const lua_gethookcount = function (L) { return L.basehookcount; }; -const lua_getstack = function(L, level, ar) { +const lua_getstack = function (L, level, ar) { let ci; let status; if (level < 0) return 0; /* invalid (negative) level */ @@ -101,34 +102,34 @@ const lua_getstack = function(L, level, ar) { return status; }; -const upvalname = function(p, uv) { +const upvalname = function (p, uv) { lua_assert(uv < p.upvalues.length); let s = p.upvalues[uv].name; - if (s === null) return to_luastring("?", true); + if (s === null) return to_luastring('?', true); return s.getstr(); }; -const findvararg = function(ci, n) { +const findvararg = function (ci, n) { let nparams = ci.func.value.p.numparams; if (n >= ci.l_base - ci.funcOff - nparams) return null; /* no such vararg */ else { return { pos: ci.funcOff + nparams + n, - name: to_luastring("(*vararg)", true) /* generic name for any vararg */ + name: to_luastring('(*vararg)', true) /* generic name for any vararg */ }; } }; -const findlocal = function(L, ci, n) { +const findlocal = function (L, ci, n) { let base, name = null; - if (ci.callstatus & lstate.CIST_LUA) { + if (ci.callstatus & CIST_LUA) { if (n < 0) /* access to vararg values? */ return findvararg(ci, -n); else { base = ci.l_base; - name = lfunc.luaF_getlocalname(ci.func.value.p, n, currentpc(ci)); + name = luaF_getlocalname(ci.func.value.p, n, currentpc(ci)); } } else base = ci.funcOff + 1; @@ -136,7 +137,7 @@ const findlocal = function(L, ci, n) { if (name === null) { /* no 'standard' name? */ let limit = ci === L.ci ? L.top : ci.next.funcOff; if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - name = to_luastring("(*temporary)", true); /* generic name for any valid slot */ + name = to_luastring('(*temporary)', true); /* generic name for any valid slot */ else return null; /* no name */ } @@ -146,20 +147,20 @@ const findlocal = function(L, ci, n) { }; }; -const lua_getlocal = function(L, ar, n) { +const lua_getlocal = function (L, ar, n) { let name; swapextra(L); if (ar === null) { /* information about non-active function? */ if (!L.stack[L.top - 1].ttisLclosure()) /* not a Lua function? */ name = null; else /* consider live variables at function start (parameters) */ - name = lfunc.luaF_getlocalname(L.stack[L.top - 1].value.p, n, 0); + name = luaF_getlocalname(L.stack[L.top - 1].value.p, n, 0); } else { /* active function; get information through 'ar' */ let local = findlocal(L, ar.i_ci, n); if (local) { name = local.name; - lobject.pushobj2s(L, L.stack[local.pos]); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushobj2s(L, L.stack[local.pos]); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { name = null; } @@ -168,13 +169,13 @@ const lua_getlocal = function(L, ar, n) { return name; }; -const lua_setlocal = function(L, ar, n) { +const lua_setlocal = function (L, ar, n) { let name; swapextra(L); let local = findlocal(L, ar.i_ci, n); if (local) { name = local.name; - lobject.setobjs2s(L, local.pos, L.top - 1); + setobjs2s(L, local.pos, L.top - 1); delete L.stack[--L.top]; /* pop value */ } else { name = null; @@ -183,57 +184,57 @@ const lua_setlocal = function(L, ar, n) { return name; }; -const funcinfo = function(ar, cl) { - if (cl === null || cl instanceof lobject.CClosure) { - ar.source = to_luastring("=[JS]", true); +const funcinfo = function (ar, cl) { + if (cl === null || cl instanceof CClosure) { + ar.source = to_luastring('=[JS]', true); ar.linedefined = -1; ar.lastlinedefined = -1; - ar.what = to_luastring("J", true); + ar.what = to_luastring('J', true); } else { let p = cl.p; - ar.source = p.source ? p.source.getstr() : to_luastring("=?", true); + ar.source = p.source ? p.source.getstr() : to_luastring('=?', true); ar.linedefined = p.linedefined; ar.lastlinedefined = p.lastlinedefined; - ar.what = ar.linedefined === 0 ? to_luastring("main", true) : to_luastring("Lua", true); + ar.what = ar.linedefined === 0 ? to_luastring('main', true) : to_luastring('Lua', true); } - ar.short_src = lobject.luaO_chunkid(ar.source, LUA_IDSIZE); + ar.short_src = luaO_chunkid(ar.source, LUA_IDSIZE); }; -const collectvalidlines = function(L, f) { - if (f === null || f instanceof lobject.CClosure) { - L.stack[L.top] = new lobject.TValue(LUA_TNIL, null); - lapi.api_incr_top(L); +const collectvalidlines = function (L, f) { + if (f === null || f instanceof CClosure) { + L.stack[L.top] = new TValue(LUA_TNIL, null); + api_incr_top(L); } else { let lineinfo = f.p.lineinfo; - let t = ltable.luaH_new(L); - L.stack[L.top] = new lobject.TValue(LUA_TTABLE, t); - lapi.api_incr_top(L); - let v = new lobject.TValue(LUA_TBOOLEAN, true); + let t = luaH_new(L); + L.stack[L.top] = new TValue(LUA_TTABLE, t); + api_incr_top(L); + let v = new TValue(LUA_TBOOLEAN, true); for (let i = 0; i < lineinfo.length; i++) - ltable.luaH_setint(t, lineinfo[i], v); + luaH_setint(t, lineinfo[i], v); } }; -const getfuncname = function(L, ci) { +const getfuncname = function (L, ci) { let r = { name: null, funcname: null }; if (ci === null) return null; - else if (ci.callstatus & lstate.CIST_FIN) { /* is this a finalizer? */ - r.name = to_luastring("__gc", true); - r.funcname = to_luastring("metamethod", true); /* report it as such */ + else if (ci.callstatus & CIST_FIN) { /* is this a finalizer? */ + r.name = to_luastring('__gc', true); + r.funcname = to_luastring('metamethod', true); /* report it as such */ return r; } /* calling function is a known Lua function? */ - else if (!(ci.callstatus & lstate.CIST_TAIL) && ci.previous.callstatus & lstate.CIST_LUA) + else if (!(ci.callstatus & CIST_TAIL) && ci.previous.callstatus & CIST_LUA) return funcnamefromcode(L, ci.previous); else return null; /* no way to find a name */ }; -const auxgetinfo = function(L, what, ar, f, ci) { +const auxgetinfo = function (L, what, ar, f, ci) { let status = 1; for (; what.length > 0; what = what.subarray(1)) { switch (what[0]) { @@ -242,12 +243,12 @@ const auxgetinfo = function(L, what, ar, f, ci) { break; } case 108 /* ('l').charCodeAt(0) */: { - ar.currentline = ci && ci.callstatus & lstate.CIST_LUA ? currentline(ci) : -1; + ar.currentline = ci && ci.callstatus & CIST_LUA ? currentline(ci) : -1; break; } case 117 /* ('u').charCodeAt(0) */: { ar.nups = f === null ? 0 : f.nupvalues; - if (f === null || f instanceof lobject.CClosure) { + if (f === null || f instanceof CClosure) { ar.isvararg = true; ar.nparams = 0; } else { @@ -257,13 +258,13 @@ const auxgetinfo = function(L, what, ar, f, ci) { break; } case 116 /* ('t').charCodeAt(0) */: { - ar.istailcall = ci ? ci.callstatus & lstate.CIST_TAIL : 0; + ar.istailcall = ci ? ci.callstatus & CIST_TAIL : 0; break; } case 110 /* ('n').charCodeAt(0) */: { let r = getfuncname(L, ci); if (r === null) { - ar.namewhat = to_luastring("", true); + ar.namewhat = to_luastring('', true); ar.name = null; } else { ar.namewhat = r.funcname; @@ -281,14 +282,14 @@ const auxgetinfo = function(L, what, ar, f, ci) { return status; }; -const lua_getinfo = function(L, what, ar) { +const lua_getinfo = function (L, what, ar) { what = from_userstring(what); let status, cl, ci, func; swapextra(L); if (what[0] === 62 /* ('>').charCodeAt(0) */) { ci = null; func = L.stack[L.top - 1]; - api_check(L, func.ttisfunction(), "function expected"); + api_check(L, func.ttisfunction(), 'function expected'); what = what.subarray(1); /* skip the '>' */ L.top--; /* pop function */ } else { @@ -300,8 +301,8 @@ const lua_getinfo = function(L, what, ar) { cl = func.ttisclosure() ? func.value : null; status = auxgetinfo(L, what, ar, cl, ci); if (luastring_indexOf(what, 102 /* ('f').charCodeAt(0) */) >= 0) { - lobject.pushobj2s(L, func); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushobj2s(L, func); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } swapextra(L); @@ -311,14 +312,14 @@ const lua_getinfo = function(L, what, ar) { return status; }; -const kname = function(p, pc, c) { +const kname = function (p, pc, c) { let r = { name: null, funcname: null }; - if (lopcodes.ISK(c)) { /* is 'c' a constant? */ - let kvalue = p.k[lopcodes.INDEXK(c)]; + if (ISK(c)) { /* is 'c' a constant? */ + let kvalue = p.k[INDEXK(c)]; if (kvalue.ttisstring()) { /* literal constant? */ r.name = kvalue.svalue(); /* it is its own name */ return r; @@ -331,11 +332,11 @@ const kname = function(p, pc, c) { } /* else no reasonable name found */ } - r.name = to_luastring("?", true); + r.name = to_luastring('?', true); return r; /* no reasonable name found */ }; -const filterpc = function(pc, jmptarget) { +const filterpc = function (pc, jmptarget) { if (pc < jmptarget) /* is code conditional (inside a jump)? */ return -1; /* cannot know who sets that register */ else return pc; /* current position sets that register */ @@ -344,10 +345,10 @@ const filterpc = function(pc, jmptarget) { /* ** try to find last instruction before 'lastpc' that modified register 'reg' */ -const findsetreg = function(p, lastpc, reg) { +const findsetreg = function (p, lastpc, reg) { let setreg = -1; /* keep last instruction that changed 'reg' */ let jmptarget = 0; /* any code before this address is conditional */ - let OCi = lopcodes.OpCodesI; + let OCi = OpCodesI; for (let pc = 0; pc < lastpc; pc++) { let i = p.code[pc]; let a = i.A; @@ -380,7 +381,7 @@ const findsetreg = function(p, lastpc, reg) { break; } default: - if (lopcodes.testAMode(i.opcode) && reg === a) + if (testAMode(i.opcode) && reg === a) setreg = filterpc(pc, jmptarget); break; } @@ -390,20 +391,20 @@ const findsetreg = function(p, lastpc, reg) { }; -const getobjname = function(p, lastpc, reg) { +const getobjname = function (p, lastpc, reg) { let r = { - name: lfunc.luaF_getlocalname(p, reg + 1, lastpc), + name: luaF_getlocalname(p, reg + 1, lastpc), funcname: null }; if (r.name) { /* is a local? */ - r.funcname = to_luastring("local", true); + r.funcname = to_luastring('local', true); return r; } /* else try symbolic execution */ let pc = findsetreg(p, lastpc, reg); - let OCi = lopcodes.OpCodesI; + let OCi = OpCodesI; if (pc !== -1) { /* could find instruction? */ let i = p.code[pc]; switch (i.opcode) { @@ -417,14 +418,14 @@ const getobjname = function(p, lastpc, reg) { case OCi.OP_GETTABLE: { let k = i.C; /* key index */ let t = i.B; /* table index */ - let vn = i.opcode === OCi.OP_GETTABLE ? lfunc.luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); + let vn = i.opcode === OCi.OP_GETTABLE ? luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); r.name = kname(p, pc, k).name; - r.funcname = (vn && luastring_eq(vn, llex.LUA_ENV)) ? to_luastring("global", true) : to_luastring("field", true); + r.funcname = (vn && luastring_eq(vn, LUA_ENV)) ? to_luastring('global', true) : to_luastring('field', true); return r; } case OCi.OP_GETUPVAL: { r.name = upvalname(p, i.B); - r.funcname = to_luastring("upvalue", true); + r.funcname = to_luastring('upvalue', true); return r; } case OCi.OP_LOADK: @@ -432,7 +433,7 @@ const getobjname = function(p, lastpc, reg) { let b = i.opcode === OCi.OP_LOADK ? i.Bx : p.code[pc + 1].Ax; if (p.k[b].ttisstring()) { r.name = p.k[b].svalue(); - r.funcname = to_luastring("constant", true); + r.funcname = to_luastring('constant', true); return r; } break; @@ -440,7 +441,7 @@ const getobjname = function(p, lastpc, reg) { case OCi.OP_SELF: { let k = i.C; r.name = kname(p, pc, k).name; - r.funcname = to_luastring("method", true); + r.funcname = to_luastring('method', true); return r; } default: break; @@ -456,7 +457,7 @@ const getobjname = function(p, lastpc, reg) { ** Returns what the name is (e.g., "for iterator", "method", ** "metamethod") and sets '*name' to point to the name. */ -const funcnamefromcode = function(L, ci) { +const funcnamefromcode = function (L, ci) { let r = { name: null, funcname: null @@ -466,11 +467,11 @@ const funcnamefromcode = function(L, ci) { let p = ci.func.value.p; /* calling function */ let pc = currentpc(ci); /* calling instruction index */ let i = p.code[pc]; /* calling instruction */ - let OCi = lopcodes.OpCodesI; + let OCi = OpCodesI; - if (ci.callstatus & lstate.CIST_HOOKED) { - r.name = to_luastring("?", true); - r.funcname = to_luastring("hook", true); + if (ci.callstatus & CIST_HOOKED) { + r.name = to_luastring('?', true); + r.funcname = to_luastring('hook', true); return r; } @@ -479,48 +480,48 @@ const funcnamefromcode = function(L, ci) { case OCi.OP_TAILCALL: return getobjname(p, pc, i.A); /* get function name */ case OCi.OP_TFORCALL: - r.name = to_luastring("for iterator", true); - r.funcname = to_luastring("for iterator", true); + r.name = to_luastring('for iterator', true); + r.funcname = to_luastring('for iterator', true); return r; /* other instructions can do calls through metamethods */ case OCi.OP_SELF: case OCi.OP_GETTABUP: case OCi.OP_GETTABLE: - tm = ltm.TMS.TM_INDEX; + tm = TMS.TM_INDEX; break; case OCi.OP_SETTABUP: case OCi.OP_SETTABLE: - tm = ltm.TMS.TM_NEWINDEX; + tm = TMS.TM_NEWINDEX; break; - case OCi.OP_ADD: tm = ltm.TMS.TM_ADD; break; - case OCi.OP_SUB: tm = ltm.TMS.TM_SUB; break; - case OCi.OP_MUL: tm = ltm.TMS.TM_MUL; break; - case OCi.OP_MOD: tm = ltm.TMS.TM_MOD; break; - case OCi.OP_POW: tm = ltm.TMS.TM_POW; break; - case OCi.OP_DIV: tm = ltm.TMS.TM_DIV; break; - case OCi.OP_IDIV: tm = ltm.TMS.TM_IDIV; break; - case OCi.OP_BAND: tm = ltm.TMS.TM_BAND; break; - case OCi.OP_BOR: tm = ltm.TMS.TM_BOR; break; - case OCi.OP_BXOR: tm = ltm.TMS.TM_BXOR; break; - case OCi.OP_SHL: tm = ltm.TMS.TM_SHL; break; - case OCi.OP_SHR: tm = ltm.TMS.TM_SHR; break; - case OCi.OP_UNM: tm = ltm.TMS.TM_UNM; break; - case OCi.OP_BNOT: tm = ltm.TMS.TM_BNOT; break; - case OCi.OP_LEN: tm = ltm.TMS.TM_LEN; break; - case OCi.OP_CONCAT: tm = ltm.TMS.TM_CONCAT; break; - case OCi.OP_EQ: tm = ltm.TMS.TM_EQ; break; - case OCi.OP_LT: tm = ltm.TMS.TM_LT; break; - case OCi.OP_LE: tm = ltm.TMS.TM_LE; break; + case OCi.OP_ADD: tm = TMS.TM_ADD; break; + case OCi.OP_SUB: tm = TMS.TM_SUB; break; + case OCi.OP_MUL: tm = TMS.TM_MUL; break; + case OCi.OP_MOD: tm = TMS.TM_MOD; break; + case OCi.OP_POW: tm = TMS.TM_POW; break; + case OCi.OP_DIV: tm = TMS.TM_DIV; break; + case OCi.OP_IDIV: tm = TMS.TM_IDIV; break; + case OCi.OP_BAND: tm = TMS.TM_BAND; break; + case OCi.OP_BOR: tm = TMS.TM_BOR; break; + case OCi.OP_BXOR: tm = TMS.TM_BXOR; break; + case OCi.OP_SHL: tm = TMS.TM_SHL; break; + case OCi.OP_SHR: tm = TMS.TM_SHR; break; + case OCi.OP_UNM: tm = TMS.TM_UNM; break; + case OCi.OP_BNOT: tm = TMS.TM_BNOT; break; + case OCi.OP_LEN: tm = TMS.TM_LEN; break; + case OCi.OP_CONCAT: tm = TMS.TM_CONCAT; break; + case OCi.OP_EQ: tm = TMS.TM_EQ; break; + case OCi.OP_LT: tm = TMS.TM_LT; break; + case OCi.OP_LE: tm = TMS.TM_LE; break; default: return null; /* cannot find a reasonable name */ } r.name = L.l_G.tmname[tm].getstr(); - r.funcname = to_luastring("metamethod", true); + r.funcname = to_luastring('metamethod', true); return r; }; -const isinstack = function(L, ci, o) { +const isinstack = function (L, ci, o) { for (let i = ci.l_base; i < ci.top; i++) { if (L.stack[i] === o) return i; @@ -534,7 +535,7 @@ const isinstack = function(L, ci, o) { ** with instructions OP_GETTABUP/OP_SETTABUP, which operate directly on ** upvalues.) */ -const getupvalname = function(L, ci, o) { +const getupvalname = function (L, ci, o) { let c = ci.func.value; for (let i = 0; i < c.nupvalues; i++) { if (c.upvals[i] === o) { @@ -548,88 +549,88 @@ const getupvalname = function(L, ci, o) { return null; }; -const varinfo = function(L, o) { +const varinfo = function (L, o) { let ci = L.ci; let kind = null; - if (ci.callstatus & lstate.CIST_LUA) { + if (ci.callstatus & CIST_LUA) { kind = getupvalname(L, ci, o); /* check whether 'o' is an upvalue */ let stkid = isinstack(L, ci, o); if (!kind && stkid) /* no? try a register */ kind = getobjname(ci.func.value.p, currentpc(ci), stkid - ci.l_base); } - return kind ? lobject.luaO_pushfstring(L, to_luastring(" (%s '%s')", true), kind.funcname, kind.name) : to_luastring("", true); + return kind ? luaO_pushfstring(L, to_luastring(' (%s \'%s\')', true), kind.funcname, kind.name) : to_luastring('', true); }; -const luaG_typeerror = function(L, o, op) { - let t = ltm.luaT_objtypename(L, o); - luaG_runerror(L, to_luastring("attempt to %s a %s value%s", true), op, t, varinfo(L, o)); +const luaG_typeerror = function (L, o, op) { + let t = luaT_objtypename(L, o); + luaG_runerror(L, to_luastring('attempt to %s a %s value%s', true), op, t, varinfo(L, o)); }; -const luaG_concaterror = function(L, p1, p2) { - if (p1.ttisstring() || lvm.cvt2str(p1)) p1 = p2; +const luaG_concaterror = function (L, p1, p2) { + if (p1.ttisstring() || cvt2str(p1)) p1 = p2; luaG_typeerror(L, p1, to_luastring('concatenate', true)); }; /* ** Error when both values are convertible to numbers, but not to integers */ -const luaG_opinterror = function(L, p1, p2, msg) { - if (lvm.tonumber(p1) === false) +const luaG_opinterror = function (L, p1, p2, msg) { + if (tonumber(p1) === false) p2 = p1; luaG_typeerror(L, p2, msg); }; -const luaG_ordererror = function(L, p1, p2) { - let t1 = ltm.luaT_objtypename(L, p1); - let t2 = ltm.luaT_objtypename(L, p2); +const luaG_ordererror = function (L, p1, p2) { + let t1 = luaT_objtypename(L, p1); + let t2 = luaT_objtypename(L, p2); if (luastring_eq(t1, t2)) - luaG_runerror(L, to_luastring("attempt to compare two %s values", true), t1); + luaG_runerror(L, to_luastring('attempt to compare two %s values', true), t1); else - luaG_runerror(L, to_luastring("attempt to compare %s with %s", true), t1, t2); + luaG_runerror(L, to_luastring('attempt to compare %s with %s', true), t1, t2); }; /* add src:line information to 'msg' */ -const luaG_addinfo = function(L, msg, src, line) { +const luaG_addinfo = function (L, msg, src, line) { let buff; if (src) - buff = lobject.luaO_chunkid(src.getstr(), LUA_IDSIZE); + buff = luaO_chunkid(src.getstr(), LUA_IDSIZE); else - buff = to_luastring("?", true); + buff = to_luastring('?', true); - return lobject.luaO_pushfstring(L, to_luastring("%s:%d: %s", true), buff, line, msg); + return luaO_pushfstring(L, to_luastring('%s:%d: %s', true), buff, line, msg); }; -const luaG_runerror = function(L, fmt, ...argp) { +const luaG_runerror = function (L, fmt, ...argp) { let ci = L.ci; - let msg = lobject.luaO_pushvfstring(L, fmt, argp); - if (ci.callstatus & lstate.CIST_LUA) /* if Lua function, add source:line information */ + let msg = luaO_pushvfstring(L, fmt, argp); + if (ci.callstatus & CIST_LUA) /* if Lua function, add source:line information */ luaG_addinfo(L, msg, ci.func.value.p.source, currentline(ci)); luaG_errormsg(L); }; -const luaG_errormsg = function(L) { +export const luaG_errormsg = function (L) { if (L.errfunc !== 0) { /* is there an error handling function? */ let errfunc = L.errfunc; - lobject.pushobj2s(L, L.stack[L.top - 1]); /* move argument */ - lobject.setobjs2s(L, L.top - 2, errfunc); /* push function */ - ldo.luaD_callnoyield(L, L.top - 2, 1); + pushobj2s(L, L.stack[L.top - 1]); /* move argument */ + setobjs2s(L, L.top - 2, errfunc); /* push function */ + luaD_callnoyield(L, L.top - 2, 1); } - ldo.luaD_throw(L, LUA_ERRRUN); + luaD_throw(L, LUA_ERRRUN); }; /* ** Error when both values are convertible to numbers, but not to integers */ -const luaG_tointerror = function(L, p1, p2) { - let temp = lvm.tointeger(p1); +const luaG_tointerror = function (L, p1, p2) { + let temp = tointeger(p1); if (temp === false) p2 = p1; - luaG_runerror(L, to_luastring("number%s has no integer representation", true), varinfo(L, p2)); + luaG_runerror(L, to_luastring('number%s has no integer representation', true), varinfo(L, p2)); }; -const luaG_traceexec = function(L) { +const luaG_traceexec = function (L) { let ci = L.ci; let mask = L.hookmask; let counthook = (--L.hookcount === 0 && (mask & LUA_MASKCOUNT)); @@ -637,12 +638,12 @@ const luaG_traceexec = function(L) { L.hookcount = L.basehookcount; /* reset count */ else if (!(mask & LUA_MASKLINE)) return; /* no line hook and count != 0; nothing to be done */ - if (ci.callstatus & lstate.CIST_HOOKYIELD) { /* called hook last time? */ - ci.callstatus &= ~lstate.CIST_HOOKYIELD; /* erase mark */ + if (ci.callstatus & CIST_HOOKYIELD) { /* called hook last time? */ + ci.callstatus &= ~CIST_HOOKYIELD; /* erase mark */ return; /* do not call hook again (VM yielded, so it did not move) */ } if (counthook) - ldo.luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ + luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ if (mask & LUA_MASKLINE) { let p = ci.func.value.p; let npc = ci.l_savedpc - 1; // pcRel(ci.u.l.savedpc, p); @@ -650,34 +651,16 @@ const luaG_traceexec = function(L) { if (npc === 0 || /* call linehook when enter a new function, */ ci.l_savedpc <= L.oldpc || /* when jump back (loop), or when */ newline !== (p.lineinfo.length !== 0 ? p.lineinfo[L.oldpc - 1] : -1)) /* enter a new line */ - ldo.luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ + luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ } L.oldpc = ci.l_savedpc; if (L.status === LUA_YIELD) { /* did hook yield? */ if (counthook) L.hookcount = 1; /* undo decrement to zero */ ci.l_savedpc--; /* undo increment (resume will increment it again) */ - ci.callstatus |= lstate.CIST_HOOKYIELD; /* mark that it yielded */ + ci.callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ ci.funcOff = L.top - 1; /* protect stack below results */ ci.func = L.stack[ci.funcOff]; - ldo.luaD_throw(L, LUA_YIELD); + luaD_throw(L, LUA_YIELD); } }; - -module.exports.luaG_addinfo = luaG_addinfo; -module.exports.luaG_concaterror = luaG_concaterror; -module.exports.luaG_errormsg = luaG_errormsg; -module.exports.luaG_opinterror = luaG_opinterror; -module.exports.luaG_ordererror = luaG_ordererror; -module.exports.luaG_runerror = luaG_runerror; -module.exports.luaG_tointerror = luaG_tointerror; -module.exports.luaG_traceexec = luaG_traceexec; -module.exports.luaG_typeerror = luaG_typeerror; -module.exports.lua_gethook = lua_gethook; -module.exports.lua_gethookcount = lua_gethookcount; -module.exports.lua_gethookmask = lua_gethookmask; -module.exports.lua_getinfo = lua_getinfo; -module.exports.lua_getlocal = lua_getlocal; -module.exports.lua_getstack = lua_getstack; -module.exports.lua_sethook = lua_sethook; -module.exports.lua_setlocal = lua_setlocal; diff --git a/src/ldo.js b/src/ldo.js index 9c89ff75..1ffd15c9 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -1,6 +1,4 @@ -"use strict"; - -const { +import { LUA_HOOKCALL, LUA_HOOKRET, LUA_HOOKTAILCALL, @@ -10,67 +8,77 @@ const { LUA_MINSTACK, LUA_MULTRET, LUA_SIGNATURE, - constant_types: { - LUA_TCCL, - LUA_TLCF, - LUA_TLCL, - LUA_TNIL - }, - thread_status: { - LUA_ERRMEM, - LUA_ERRERR, - LUA_ERRRUN, - LUA_ERRSYNTAX, - LUA_OK, - LUA_YIELD - }, + LUA_TCCL, + LUA_TLCF, + LUA_TLCL, + LUA_TNIL, + LUA_ERRMEM, + LUA_ERRERR, + LUA_ERRRUN, + LUA_ERRSYNTAX, + LUA_OK, + LUA_YIELD, lua_Debug, luastring_indexOf, to_luastring -} = require('./defs.js'); -const lapi = require('./lapi.js'); -const ldebug = require('./ldebug.js'); -const lfunc = require('./lfunc.js'); -const { - api_check, - lua_assert, - LUAI_MAXCCALLS -} = require('./llimits.js'); -const lobject = require('./lobject.js'); -const lopcodes = require('./lopcodes.js'); -const lparser = require('./lparser.js'); -const lstate = require('./lstate.js'); -const { luaS_newliteral } = require('./lstring.js'); -const ltm = require('./ltm.js'); -const { LUAI_MAXSTACK } = require('./luaconf.js'); -const lundump = require('./lundump.js'); -const lvm = require('./lvm.js'); -const { MBuffer } = require('./lzio.js'); - -const adjust_top = function(L, newtop) { +} from './defs.js'; + +import * as lapi from "./lapi.js"; + +import * as ldebug from "./ldebug.js"; + +import * as lfunc from "./lfunc.js"; + +import {api_check, lua_assert, LUAI_MAXCCALLS} from "./llimits.js"; + +import * as lobject from "./lobject.js"; + +import * as lopcodes from "./lopcodes.js"; + +import * as lparser from "./lparser.js"; + +import * as lstate from "./lstate.js"; + +import {luaS_newliteral} from "./lstring.js"; + +import * as ltm from "./ltm.js"; + +import {LUAI_MAXSTACK} from "./luaconf.js"; + +import * as lundump from "./lundump.js"; + +import * as lvm from "./lvm.js"; + +import {MBuffer} from "./lzio.js"; + +const constant_types = { + LUA_TCCL, LUA_TLCF, LUA_TLCL, LUA_TNIL +}; +const thread_status = { + LUA_ERRMEM, LUA_ERRERR, LUA_ERRRUN, LUA_ERRSYNTAX, LUA_OK, LUA_YIELD +}; + +export const adjust_top = function (L, newtop) { if (L.top < newtop) { - while (L.top < newtop) - L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + while (L.top < newtop) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); } else { - while (L.top > newtop) - delete L.stack[--L.top]; + while (L.top > newtop) delete L.stack[--L.top]; } }; -const seterrorobj = function(L, errcode, oldtop) { +const seterrorobj = function (L, errcode, oldtop) { let current_top = L.top; /* extend stack so that L.stack[oldtop] is sure to exist */ - while (L.top < oldtop + 1) - L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + while (L.top < oldtop + 1) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); switch (errcode) { case LUA_ERRMEM: { - lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, "not enough memory")); + lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, 'not enough memory')); break; } case LUA_ERRERR: { - lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, 'error in error handling')); break; } default: { @@ -78,43 +86,37 @@ const seterrorobj = function(L, errcode, oldtop) { } } - while (L.top > oldtop + 1) - delete L.stack[--L.top]; + while (L.top > oldtop + 1) delete L.stack[--L.top]; }; const ERRORSTACKSIZE = LUAI_MAXSTACK + 200; -const luaD_reallocstack = function(L, newsize) { +const luaD_reallocstack = function (L, newsize) { lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); lua_assert(L.stack_last == L.stack.length - lstate.EXTRA_STACK); L.stack.length = newsize; L.stack_last = newsize - lstate.EXTRA_STACK; }; -const luaD_growstack = function(L, n) { +export const luaD_growstack = function (L, n) { let size = L.stack.length; - if (size > LUAI_MAXSTACK) - luaD_throw(L, LUA_ERRERR); - else { + if (size > LUAI_MAXSTACK) luaD_throw(L, LUA_ERRERR); else { let needed = L.top + n + lstate.EXTRA_STACK; let newsize = 2 * size; if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; if (newsize < needed) newsize = needed; if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ luaD_reallocstack(L, ERRORSTACKSIZE); - ldebug.luaG_runerror(L, to_luastring("stack overflow", true)); - } - else - luaD_reallocstack(L, newsize); + ldebug.luaG_runerror(L, to_luastring('stack overflow', true)); + } else luaD_reallocstack(L, newsize); } }; -const luaD_checkstack = function(L, n) { - if (L.stack_last - L.top <= n) - luaD_growstack(L, n); +const luaD_checkstack = function (L, n) { + if (L.stack_last - L.top <= n) luaD_growstack(L, n); }; -const stackinuse = function(L) { +const stackinuse = function (L) { let lim = L.top; for (let ci = L.ci; ci !== null; ci = ci.previous) { if (lim < ci.top) lim = ci.top; @@ -123,20 +125,18 @@ const stackinuse = function(L) { return lim + 1; /* part of stack in use */ }; -const luaD_shrinkstack = function(L) { +const luaD_shrinkstack = function (L) { let inuse = stackinuse(L); - let goodsize = inuse + Math.floor(inuse / 8) + 2*lstate.EXTRA_STACK; - if (goodsize > LUAI_MAXSTACK) - goodsize = LUAI_MAXSTACK; /* respect stack limit */ + let goodsize = inuse + Math.floor(inuse / 8) + 2 * lstate.EXTRA_STACK; + if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK; /* respect stack limit */ if (L.stack.length > LUAI_MAXSTACK) /* had been handling stack overflow? */ lstate.luaE_freeCI(L); /* free all CIs (list grew because of an error) */ /* if thread is currently not handling a stack overflow and its good size is smaller than current size, shrink its stack */ - if (inuse <= (LUAI_MAXSTACK - lstate.EXTRA_STACK) && goodsize < L.stack.length) - luaD_reallocstack(L, goodsize); + if (inuse <= (LUAI_MAXSTACK - lstate.EXTRA_STACK) && goodsize < L.stack.length) luaD_reallocstack(L, goodsize); }; -const luaD_inctop = function(L) { +const luaD_inctop = function (L) { luaD_checkstack(L, 1); L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); }; @@ -148,10 +148,10 @@ const luaD_inctop = function(L) { ** the execution ('luaV_execute') to the caller, to allow stackless ** calls.) Returns true iff function has been executed (JS function). */ -const luaD_precall = function(L, off, nresults) { +const luaD_precall = function (L, off, nresults) { let func = L.stack[off]; - switch(func.type) { + switch (func.type) { case LUA_TCCL: case LUA_TLCF: { let f = func.type === LUA_TCCL ? func.value.f : func.value; @@ -164,11 +164,9 @@ const luaD_precall = function(L, off, nresults) { ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); ci.callstatus = 0; - if (L.hookmask & LUA_MASKCALL) - luaD_hook(L, LUA_HOOKCALL, -1); + if (L.hookmask & LUA_MASKCALL) luaD_hook(L, LUA_HOOKCALL, -1); let n = f(L); /* do the actual call */ - if (typeof n !== "number" || n < 0 || (n|0) !== n) - throw Error("invalid return value from JS function (expected integer)"); + if (typeof n !== 'number' || n < 0 || (n | 0) !== n) throw Error('invalid return value from JS function (expected integer)'); lapi.api_checknelems(L, n); luaD_poscall(L, ci, L.top - n, n); @@ -184,8 +182,7 @@ const luaD_precall = function(L, off, nresults) { if (p.is_vararg) { base = adjust_varargs(L, p, n); } else { - for (; n < p.numparams; n++) - L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); // complete missing arguments + for (; n < p.numparams; n++) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); // complete missing arguments base = off + 1; } @@ -199,8 +196,7 @@ const luaD_precall = function(L, off, nresults) { ci.l_code = p.code; ci.l_savedpc = 0; ci.callstatus = lstate.CIST_LUA; - if (L.hookmask & LUA_MASKCALL) - callhook(L, ci); + if (L.hookmask & LUA_MASKCALL) callhook(L, ci); return false; } default: @@ -210,12 +206,11 @@ const luaD_precall = function(L, off, nresults) { } }; -const luaD_poscall = function(L, ci, firstResult, nres) { +const luaD_poscall = function (L, ci, firstResult, nres) { let wanted = ci.nresults; if (L.hookmask & (LUA_MASKRET | LUA_MASKLINE)) { - if (L.hookmask & LUA_MASKRET) - luaD_hook(L, LUA_HOOKRET, -1); + if (L.hookmask & LUA_MASKRET) luaD_hook(L, LUA_HOOKRET, -1); L.oldpc = ci.previous.l_savedpc; /* 'oldpc' for caller function */ } @@ -225,47 +220,37 @@ const luaD_poscall = function(L, ci, firstResult, nres) { return moveresults(L, firstResult, res, nres, wanted); }; -const moveresults = function(L, firstResult, res, nres, wanted) { +const moveresults = function (L, firstResult, res, nres, wanted) { switch (wanted) { case 0: break; case 1: { - if (nres === 0) - L.stack[res].setnilvalue(); - else { + if (nres === 0) L.stack[res].setnilvalue(); else { lobject.setobjs2s(L, res, firstResult); /* move it to proper place */ } break; } case LUA_MULTRET: { - for (let i = 0; i < nres; i++) - lobject.setobjs2s(L, res + i, firstResult + i); - for (let i=L.top; i>=(res + nres); i--) - delete L.stack[i]; + for (let i = 0; i < nres; i++) lobject.setobjs2s(L, res + i, firstResult + i); + for (let i = L.top; i >= (res + nres); i--) delete L.stack[i]; L.top = res + nres; return false; } default: { let i; if (wanted <= nres) { - for (i = 0; i < wanted; i++) - lobject.setobjs2s(L, res + i, firstResult + i); + for (i = 0; i < wanted; i++) lobject.setobjs2s(L, res + i, firstResult + i); } else { - for (i = 0; i < nres; i++) - lobject.setobjs2s(L, res + i, firstResult + i); + for (i = 0; i < nres; i++) lobject.setobjs2s(L, res + i, firstResult + i); for (; i < wanted; i++) { - if (res+i >= L.top) - L.stack[res + i] = new lobject.TValue(LUA_TNIL, null); - else - L.stack[res + i].setnilvalue(); + if (res + i >= L.top) L.stack[res + i] = new lobject.TValue(LUA_TNIL, null); else L.stack[res + i].setnilvalue(); } } break; } } let newtop = res + wanted; /* top points after the last result */ - for (let i=L.top; i>=newtop; i--) - delete L.stack[i]; + for (let i = L.top; i >= newtop; i--) delete L.stack[i]; L.top = newtop; return true; }; @@ -275,7 +260,7 @@ const moveresults = function(L, firstResult, res, nres, wanted) { ** called. (Both 'L->hook' and 'L->hookmask', which triggers this ** function, can be changed asynchronously by signals.) */ -const luaD_hook = function(L, event, line) { +const luaD_hook = function (L, event, line) { let hook = L.hook; if (hook && L.allowhook) { /* make sure there is a hook */ let ci = L.ci; @@ -299,11 +284,10 @@ const luaD_hook = function(L, event, line) { } }; -const callhook = function(L, ci) { +const callhook = function (L, ci) { let hook = LUA_HOOKCALL; ci.l_savedpc++; /* hooks assume 'pc' is already incremented */ - if ((ci.previous.callstatus & lstate.CIST_LUA) && - ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == lopcodes.OpCodesI.OP_TAILCALL) { + if ((ci.previous.callstatus & lstate.CIST_LUA) && ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == lopcodes.OpCodesI.OP_TAILCALL) { ci.callstatus |= lstate.CIST_TAIL; hook = LUA_HOOKTAILCALL; } @@ -311,7 +295,7 @@ const callhook = function(L, ci) { ci.l_savedpc--; /* correct 'pc' */ }; -const adjust_varargs = function(L, p, actual) { +const adjust_varargs = function (L, p, actual) { let nfixargs = p.numparams; /* move fixed parameters to final position */ let fixed = L.top - actual; /* first fixed argument */ @@ -323,20 +307,17 @@ const adjust_varargs = function(L, p, actual) { L.stack[fixed + i].setnilvalue(); } - for (; i < nfixargs; i++) - L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + for (; i < nfixargs; i++) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); return base; }; -const tryfuncTM = function(L, off, func) { +const tryfuncTM = function (L, off, func) { let tm = ltm.luaT_gettmbyobj(L, func, ltm.TMS.TM_CALL); - if (!tm.ttisfunction(tm)) - ldebug.luaG_typeerror(L, func, to_luastring("call", true)); + if (!tm.ttisfunction(tm)) ldebug.luaG_typeerror(L, func, to_luastring('call', true)); /* Open a hole inside the stack at 'func' */ - lobject.pushobj2s(L, L.stack[L.top-1]); /* push top of stack again */ - for (let p = L.top-2; p > off; p--) - lobject.setobjs2s(L, p, p-1); /* move other items up one */ + lobject.pushobj2s(L, L.stack[L.top - 1]); /* push top of stack again */ + for (let p = L.top - 2; p > off; p--) lobject.setobjs2s(L, p, p - 1); /* move other items up one */ lobject.setobj2s(L, off, tm); /* tag method is the new function to be called */ }; @@ -347,11 +328,8 @@ const tryfuncTM = function(L, off, func) { ** smaller than 9/8 of LUAI_MAXCCALLS, does not report an error (to ** allow overflow handling to work) */ -const stackerror = function(L) { - if (L.nCcalls === LUAI_MAXCCALLS) - ldebug.luaG_runerror(L, to_luastring("JS stack overflow", true)); - else if (L.nCcalls >= LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)) - luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ +const stackerror = function (L) { + if (L.nCcalls === LUAI_MAXCCALLS) ldebug.luaG_runerror(L, to_luastring('JS stack overflow', true)); else if (L.nCcalls >= LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)) luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ }; /* @@ -360,15 +338,13 @@ const stackerror = function(L) { ** When returns, all the results are on the stack, starting at the original ** function position. */ -const luaD_call = function(L, off, nResults) { - if (++L.nCcalls >= LUAI_MAXCCALLS) - stackerror(L); - if (!luaD_precall(L, off, nResults)) - lvm.luaV_execute(L); +export const luaD_call = function (L, off, nResults) { + if (++L.nCcalls >= LUAI_MAXCCALLS) stackerror(L); + if (!luaD_precall(L, off, nResults)) lvm.luaV_execute(L); L.nCcalls--; }; -const luaD_throw = function(L, errcode) { +const luaD_throw = function (L, errcode) { if (L.errorJmp) { /* thread has an error handler? */ L.errorJmp.status = errcode; /* set status */ throw L.errorJmp; @@ -382,8 +358,7 @@ const luaD_throw = function(L, errcode) { let panic = g.panic; if (panic) { /* panic function? */ seterrorobj(L, errcode, L.top); /* assume EXTRA_STACK */ - if (L.ci.top < L.top) - L.ci.top = L.top; /* pushing msg. can break this invariant */ + if (L.ci.top < L.top) L.ci.top = L.top; /* pushing msg. can break this invariant */ panic(L); /* call panic function (last chance to jump out) */ } throw new Error(`Aborted ${errcode}`); @@ -391,11 +366,10 @@ const luaD_throw = function(L, errcode) { } }; -const luaD_rawrunprotected = function(L, f, ud) { +const luaD_rawrunprotected = function (L, f, ud) { let oldnCcalls = L.nCcalls; let lj = { - status: LUA_OK, - previous: L.errorJmp /* chain new error handler */ + status: LUA_OK, previous: L.errorJmp /* chain new error handler */ }; L.errorJmp = lj; @@ -447,7 +421,7 @@ const luaD_rawrunprotected = function(L, f, ud) { ** Completes the execution of an interrupted C function, calling its ** continuation function. */ -const finishCcall = function(L, status) { +const finishCcall = function (L, status) { let ci = L.ci; /* must have a continuation and must be able to call it */ @@ -477,14 +451,13 @@ const finishCcall = function(L, status) { ** be passed to the first continuation function (otherwise the default ** status is LUA_YIELD). */ -const unroll = function(L, ud) { +const unroll = function (L, ud) { if (ud !== null) /* error status? */ finishCcall(L, ud); /* finish 'lua_pcallk' callee */ while (L.ci !== L.base_ci) { /* something in the stack */ if (!(L.ci.callstatus & lstate.CIST_LUA)) /* C function? */ - finishCcall(L, LUA_YIELD); /* complete its execution */ - else { /* Lua function */ + finishCcall(L, LUA_YIELD); /* complete its execution */ else { /* Lua function */ lvm.luaV_finishOp(L); /* finish interrupted instruction */ lvm.luaV_execute(L); /* execute down to higher C 'boundary' */ } @@ -495,10 +468,9 @@ const unroll = function(L, ud) { ** Try to find a suspended protected call (a "recover point") for the ** given thread. */ -const findpcall = function(L) { +const findpcall = function (L) { for (let ci = L.ci; ci !== null; ci = ci.previous) { /* search for a pcall */ - if (ci.callstatus & lstate.CIST_YPCALL) - return ci; + if (ci.callstatus & lstate.CIST_YPCALL) return ci; } return null; /* no pending pcall */ @@ -509,7 +481,7 @@ const findpcall = function(L) { ** there is one) and completes the execution of the interrupted ** 'luaD_pcall'. If there is no recover point, returns zero. */ -const recover = function(L, status) { +const recover = function (L, status) { let ci = findpcall(L); if (ci === null) return 0; /* no recovery point */ /* "finish" luaD_pcall */ @@ -529,16 +501,15 @@ const recover = function(L, status) { ** of the coroutine itself. (Such errors should not be handled by any ** coroutine error handler and should not kill the coroutine.) */ -const resume_error = function(L, msg, narg) { +const resume_error = function (L, msg, narg) { let ts = luaS_newliteral(L, msg); if (narg === 0) { lobject.pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { /* remove args from the stack */ - for (let i=1; i= LUAI_MAXCCALLS) - return resume_error(L, "JS stack overflow", nargs); + if (L.nCcalls >= LUAI_MAXCCALLS) return resume_error(L, 'JS stack overflow', nargs); L.nny = 0; /* allow yields */ - lapi.api_checknelems(L, L.status === LUA_OK ? nargs + 1: nargs); + lapi.api_checknelems(L, L.status === LUA_OK ? nargs + 1 : nargs); let status = luaD_rawrunprotected(L, resume, nargs); if (status === -1) /* error calling 'lua_resume'? */ - status = LUA_ERRRUN; - else { /* continue running after recoverable errors */ + status = LUA_ERRRUN; else { /* continue running after recoverable errors */ while (status > LUA_YIELD && recover(L, status)) { /* unroll continuation */ status = luaD_rawrunprotected(L, unroll, status); @@ -608,8 +575,7 @@ const lua_resume = function(L, from, nargs) { L.status = status; /* mark thread as 'dead' */ seterrorobj(L, status, L.top); /* push error message */ L.ci.top = L.top; - } else - lua_assert(status === L.status); /* normal end or yield */ + } else lua_assert(status === L.status); /* normal end or yield */ } L.nny = oldnny; /* restore 'nny' */ @@ -618,26 +584,22 @@ const lua_resume = function(L, from, nargs) { return status; }; -const lua_isyieldable = function(L) { +const lua_isyieldable = function (L) { return L.nny === 0; }; -const lua_yieldk = function(L, nresults, ctx, k) { +const lua_yieldk = function (L, nresults, ctx, k) { let ci = L.ci; lapi.api_checknelems(L, nresults); if (L.nny > 0) { - if (L !== L.l_G.mainthread) - ldebug.luaG_runerror(L, to_luastring("attempt to yield across a JS-call boundary", true)); - else - ldebug.luaG_runerror(L, to_luastring("attempt to yield from outside a coroutine", true)); + if (L !== L.l_G.mainthread) ldebug.luaG_runerror(L, to_luastring('attempt to yield across a JS-call boundary', true)); else ldebug.luaG_runerror(L, to_luastring('attempt to yield from outside a coroutine', true)); } L.status = LUA_YIELD; ci.extra = ci.funcOff; /* save current 'func' */ if (ci.callstatus & lstate.CIST_LUA) /* inside a hook? */ - api_check(L, k === null, "hooks cannot continue after yielding"); - else { + api_check(L, k === null, 'hooks cannot continue after yielding'); else { ci.c_k = k; if (k !== null) /* is there a continuation? */ ci.c_ctx = ctx; /* save context */ @@ -650,11 +612,11 @@ const lua_yieldk = function(L, nresults, ctx, k) { return 0; /* return to 'luaD_hook' */ }; -const lua_yield = function(L, n) { +const lua_yield = function (L, n) { lua_yieldk(L, n, 0, null); }; -const luaD_pcall = function(L, func, u, old_top, ef) { +export const luaD_pcall = function (L, func, u, old_top, ef) { let old_ci = L.ci; let old_allowhooks = L.allowhook; let old_nny = L.nny; @@ -680,7 +642,7 @@ const luaD_pcall = function(L, func, u, old_top, ef) { /* ** Similar to 'luaD_call', but does not allow yields during the call */ -const luaD_callnoyield = function(L, off, nResults) { +export const luaD_callnoyield = function (L, off, nResults) { L.nny++; luaD_call(L, off, nResults); L.nny--; @@ -699,22 +661,21 @@ class SParser { } } -const checkmode = function(L, mode, x) { +const checkmode = function (L, mode, x) { if (mode && luastring_indexOf(mode, x[0]) === -1) { - lobject.luaO_pushfstring(L, - to_luastring("attempt to load a %s chunk (mode is '%s')"), x, mode); + lobject.luaO_pushfstring(L, to_luastring('attempt to load a %s chunk (mode is \'%s\')'), x, mode); luaD_throw(L, LUA_ERRSYNTAX); } }; -const f_parser = function(L, p) { +const f_parser = function (L, p) { let cl; let c = p.z.zgetc(); /* read first character */ if (c === LUA_SIGNATURE[0]) { - checkmode(L, p.mode, to_luastring("binary", true)); + checkmode(L, p.mode, to_luastring('binary', true)); cl = lundump.luaU_undump(L, p.z, p.name); } else { - checkmode(L, p.mode, to_luastring("text", true)); + checkmode(L, p.mode, to_luastring('text', true)); cl = lparser.luaY_parser(L, p.z, p.buff, p.dyd, p.name, c); } @@ -722,29 +683,10 @@ const f_parser = function(L, p) { lfunc.luaF_initupvals(L, cl); }; -const luaD_protectedparser = function(L, z, name, mode) { +export const luaD_protectedparser = function (L, z, name, mode) { let p = new SParser(z, name, mode); L.nny++; /* cannot yield during parsing */ let status = luaD_pcall(L, f_parser, p, L.top, L.errfunc); L.nny--; return status; }; - -module.exports.adjust_top = adjust_top; -module.exports.luaD_call = luaD_call; -module.exports.luaD_callnoyield = luaD_callnoyield; -module.exports.luaD_checkstack = luaD_checkstack; -module.exports.luaD_growstack = luaD_growstack; -module.exports.luaD_hook = luaD_hook; -module.exports.luaD_inctop = luaD_inctop; -module.exports.luaD_pcall = luaD_pcall; -module.exports.luaD_poscall = luaD_poscall; -module.exports.luaD_precall = luaD_precall; -module.exports.luaD_protectedparser = luaD_protectedparser; -module.exports.luaD_rawrunprotected = luaD_rawrunprotected; -module.exports.luaD_reallocstack = luaD_reallocstack; -module.exports.luaD_throw = luaD_throw; -module.exports.lua_isyieldable = lua_isyieldable; -module.exports.lua_resume = lua_resume; -module.exports.lua_yield = lua_yield; -module.exports.lua_yieldk = lua_yieldk; diff --git a/src/ldump.js b/src/ldump.js index 6a30f0b1..05cb58fd 100644 --- a/src/ldump.js +++ b/src/ldump.js @@ -1,19 +1,21 @@ -"use strict"; - -const { +import { LUA_SIGNATURE, + LUA_TBOOLEAN, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR, LUA_VERSION_MAJOR, - LUA_VERSION_MINOR, - constant_types: { - LUA_TBOOLEAN, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR - }, - luastring_of -} = require('./defs.js'); + LUA_VERSION_MINOR, luastring_of +} from "./defs.js"; + +const constant_types = { + LUA_TBOOLEAN, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR +} const LUAC_DATA = luastring_of(25, 147, 13, 10, 26, 10); const LUAC_INT = 0x5678; @@ -182,7 +184,7 @@ const DumpHeader = function(D) { /* ** dump Lua function as precompiled chunk */ -const luaU_dump = function(L, f, w, data, strip) { +export const luaU_dump = function(L, f, w, data, strip) { let D = new DumpState(); D.L = L; D.writer = w; @@ -194,5 +196,3 @@ const luaU_dump = function(L, f, w, data, strip) { DumpFunction(f, null, D); return D.status; }; - -module.exports.luaU_dump = luaU_dump; diff --git a/src/lfunc.js b/src/lfunc.js index 9290f4b2..f2e1b98a 100644 --- a/src/lfunc.js +++ b/src/lfunc.js @@ -1,7 +1,8 @@ -"use strict"; +import {LUA_TNIL} from "./defs.js"; -const { constant_types: { LUA_TNIL } } = require('./defs.js'); -const lobject = require('./lobject.js'); +import * as lobject from "./lobject.js"; + +const constant_types = { LUA_TNIL } class Proto { constructor(L) { @@ -63,10 +64,4 @@ const luaF_getlocalname = function(f, local_number, pc) { return null; /* not found */ }; -module.exports.MAXUPVAL = 255; -module.exports.Proto = Proto; -module.exports.luaF_findupval = luaF_findupval; -module.exports.luaF_close = luaF_close; -module.exports.luaF_getlocalname = luaF_getlocalname; -module.exports.luaF_initupvals = luaF_initupvals; -module.exports.luaF_newLclosure = luaF_newLclosure; +export const MAXUPVAL= 255; diff --git a/src/linit.js b/src/linit.js index 8f461a49..32e7692a 100644 --- a/src/linit.js +++ b/src/linit.js @@ -1,8 +1,18 @@ -"use strict"; - -const { lua_pop } = require('./lua.js'); -const { luaL_requiref } = require('./lauxlib.js'); -const { to_luastring } = require("./fengaricore.js"); +import {lua_pop} from "./lua.js"; +import {luaL_requiref} from "./lauxlib.js"; +import {to_luastring} from "./fengaricore.js"; +import * as lualib from "./lualib.js"; +import {luaopen_base} from "./lbaselib.js"; +import {luaopen_coroutine} from "./lcorolib.js"; +import {luaopen_debug} from "./ldblib.js"; +import {luaopen_math} from "./lmathlib.js"; +import {luaopen_package} from "./loadlib.js"; +import {luaopen_os} from "./loslib.js"; +import {luaopen_string} from "./lstrlib.js"; +import {luaopen_table} from "./ltablib.js"; +import {luaopen_utf8} from "./lutf8lib.js"; +import {luaopen_io} from "./liolib.js"; +import {luaopen_fengari} from "./fengarilib.js"; const loadedlibs = {}; @@ -14,20 +24,8 @@ const luaL_openlibs = function(L) { lua_pop(L, 1); /* remove lib */ } }; -module.exports.luaL_openlibs = luaL_openlibs; - -const lualib = require('./lualib.js'); -const { luaopen_base } = require('./lbaselib.js'); -const { luaopen_coroutine } = require('./lcorolib.js'); -const { luaopen_debug } = require('./ldblib.js'); -const { luaopen_math } = require('./lmathlib.js'); -const { luaopen_package } = require('./loadlib.js'); -const { luaopen_os } = require('./loslib.js'); -const { luaopen_string } = require('./lstrlib.js'); -const { luaopen_table } = require('./ltablib.js'); -const { luaopen_utf8 } = require('./lutf8lib.js'); -loadedlibs["_G"] = luaopen_base, +loadedlibs['_G'] = luaopen_base; loadedlibs[lualib.LUA_LOADLIBNAME] = luaopen_package; loadedlibs[lualib.LUA_COLIBNAME] = luaopen_coroutine; loadedlibs[lualib.LUA_TABLIBNAME] = luaopen_table; @@ -36,9 +34,6 @@ loadedlibs[lualib.LUA_STRLIBNAME] = luaopen_string; loadedlibs[lualib.LUA_MATHLIBNAME] = luaopen_math; loadedlibs[lualib.LUA_UTF8LIBNAME] = luaopen_utf8; loadedlibs[lualib.LUA_DBLIBNAME] = luaopen_debug; -if (typeof process !== "undefined") - loadedlibs[lualib.LUA_IOLIBNAME] = require('./liolib.js').luaopen_io; - -/* Extension: fengari library */ -const { luaopen_fengari } = require('./fengarilib.js'); +if (typeof process !== 'undefined') + loadedlibs[lualib.LUA_IOLIBNAME] = luaopen_io.luaopen_io; loadedlibs[lualib.LUA_FENGARILIBNAME] = luaopen_fengari; diff --git a/src/liolib.js b/src/liolib.js index 92dda580..f2c58925 100644 --- a/src/liolib.js +++ b/src/liolib.js @@ -1,43 +1,28 @@ -"use strict"; - -const fs = require('fs'); - -const { - LUA_REGISTRYINDEX, +import fs from "fs"; +import { lua_getfield, lua_gettop, lua_isnone, lua_isnoneornil, lua_newuserdata, - lua_pop, - lua_pushliteral, - lua_pushnil, - lua_pushstring, - lua_pushvalue, - lua_setfield, - lua_tostring, - lua_touserdata -} = require('./lua.js'); -const { + lua_pop, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, + LUA_REGISTRYINDEX, lua_setfield, lua_tostring, lua_touserdata +} from "./lua.js"; +import { LUA_FILEHANDLE, luaL_checkany, luaL_checklstring, luaL_checkudata, luaL_error, - luaL_fileresult, - luaL_newlib, - luaL_newmetatable, - luaL_setfuncs, - luaL_setmetatable, - luaL_testudata -} = require('./lauxlib.js'); -const lualib = require('./lualib.js'); -const { to_luastring } = require("./fengaricore.js"); - -const IO_PREFIX = "_IO_"; + luaL_fileresult, luaL_newlib, luaL_newmetatable, luaL_setfuncs, luaL_setmetatable, luaL_testudata +} from "./lauxlib.js"; +import * as lualib from "./lualib.js"; +import {to_luastring} from "./fengaricore.js"; + +const IO_PREFIX = '_IO_'; const IOPREF_LEN = IO_PREFIX.length; -const IO_INPUT = to_luastring(IO_PREFIX + "input"); -const IO_OUTPUT = to_luastring(IO_PREFIX + "output"); +const IO_INPUT = to_luastring(IO_PREFIX + 'input'); +const IO_OUTPUT = to_luastring(IO_PREFIX + 'output'); const tolstream = function(L) { return luaL_checkudata(L, 1, LUA_FILEHANDLE); @@ -53,16 +38,16 @@ const io_type = function(L) { if (p === null) lua_pushnil(L); /* not a file */ else if (isclosed(p)) - lua_pushliteral(L, "closed file"); + lua_pushliteral(L, 'closed file'); else - lua_pushliteral(L, "file"); + lua_pushliteral(L, 'file'); return 1; }; const f_tostring = function(L) { let p = tolstream(L); if (isclosed(p)) - lua_pushliteral(L, "file (closed)"); + lua_pushliteral(L, 'file (closed)'); else lua_pushstring(L, to_luastring(`file (${p.f.toString()})`)); return 1; @@ -71,7 +56,7 @@ const f_tostring = function(L) { const tofile = function(L) { let p = tolstream(L); if (isclosed(p)) - luaL_error(L, to_luastring("attempt to use a closed file")); + luaL_error(L, to_luastring('attempt to use a closed file')); lualib.lua_assert(p.f); return p.f; }; @@ -102,7 +87,7 @@ const getiofile = function(L, findex) { lua_getfield(L, LUA_REGISTRYINDEX, findex); let p = lua_touserdata(L, -1); if (isclosed(p)) - luaL_error(L, to_luastring("standard %s file is closed"), findex.subarray(IOPREF_LEN)); + luaL_error(L, to_luastring('standard %s file is closed'), findex.subarray(IOPREF_LEN)); return p.f; }; @@ -110,7 +95,7 @@ const g_iofile = function(L, f, mode) { if (!lua_isnoneornil(L, 1)) { let filename = lua_tostring(L, 1); if (filename) - luaL_error(L, to_luastring("opening files not yet implemented")); + luaL_error(L, to_luastring('opening files not yet implemented')); else { tofile(L); /* check that it's a valid file handle */ lua_pushvalue(L, 1); @@ -123,11 +108,11 @@ const g_iofile = function(L, f, mode) { }; const io_input = function(L) { - return g_iofile(L, IO_INPUT, "r"); + return g_iofile(L, IO_INPUT, 'r'); }; const io_output = function(L) { - return g_iofile(L, IO_OUTPUT, "w"); + return g_iofile(L, IO_OUTPUT, 'w'); }; /* node <= 6 doesn't support passing a Uint8Array to fs.writeSync */ @@ -175,25 +160,25 @@ const f_flush = function (L) { }; const iolib = { - "close": io_close, - "flush": io_flush, - "input": io_input, - "output": io_output, - "type": io_type, - "write": io_write + 'close': io_close, + 'flush': io_flush, + 'input': io_input, + 'output': io_output, + 'type': io_type, + 'write': io_write }; const flib = { - "close": io_close, - "flush": f_flush, - "write": f_write, - "__tostring": f_tostring + 'close': io_close, + 'flush': f_flush, + 'write': f_write, + '__tostring': f_tostring }; const createmeta = function(L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, to_luastring("__index", true)); /* metatable.__index = metatable */ + lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = metatable */ luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ lua_pop(L, 1); /* pop new metatable */ }; @@ -202,7 +187,7 @@ const io_noclose = function(L) { let p = tolstream(L); p.closef = io_noclose; lua_pushnil(L); - lua_pushliteral(L, "cannot close standard file"); + lua_pushliteral(L, 'cannot close standard file'); return 2; }; @@ -221,10 +206,8 @@ const luaopen_io = function(L) { luaL_newlib(L, iolib); createmeta(L); /* create (and set) default files */ - createstdfile(L, process.stdin, IO_INPUT, to_luastring("stdin")); - createstdfile(L, process.stdout, IO_OUTPUT, to_luastring("stdout")); - createstdfile(L, process.stderr, null, to_luastring("stderr")); + createstdfile(L, process.stdin, IO_INPUT, to_luastring('stdin')); + createstdfile(L, process.stdout, IO_OUTPUT, to_luastring('stdout')); + createstdfile(L, process.stderr, null, to_luastring('stderr')); return 1; }; - -module.exports.luaopen_io = luaopen_io; diff --git a/src/ljstype.js b/src/ljstype.js index eb24ac51..90009de7 100644 --- a/src/ljstype.js +++ b/src/ljstype.js @@ -1,6 +1,4 @@ -"use strict"; - -const { luastring_of } = require('./defs.js'); +import {luastring_of} from "./defs.js"; const luai_ctype_ = luastring_of( 0x00, /* EOZ */ @@ -67,10 +65,3 @@ const lislalpha = function(c) { const lislalnum = function(c) { return (luai_ctype_[c+1] & ((1<=", "<=", "~=", - "<<", ">>", "::", "", - "", "", "", "" + 'and', 'break', 'do', 'else', 'elseif', + 'end', 'false', 'for', 'function', 'goto', 'if', + 'in', 'local', 'nil', 'not', 'or', 'repeat', + 'return', 'then', 'true', 'until', 'while', + '//', '..', '...', '==', '>=', '<=', '~=', + '<<', '>>', '::', '', + '', '', '', '' ].map((e, i)=>to_luastring(e)); class SemInfo { @@ -168,7 +152,7 @@ const save = function(ls, c) { let b = ls.buff; if (b.n + 1 > b.buffer.length) { if (b.buffer.length >= MAX_INT/2) - lexerror(ls, to_luastring("lexical element too long", true), 0); + lexerror(ls, to_luastring('lexical element too long', true), 0); let newsize = b.buffer.length*2; luaZ_resizebuffer(ls.L, b, newsize); } @@ -177,11 +161,11 @@ const save = function(ls, c) { const luaX_token2str = function(ls, token) { if (token < FIRST_RESERVED) { /* single-byte symbols? */ - return lobject.luaO_pushfstring(ls.L, to_luastring("'%c'", true), token); + return lobject.luaO_pushfstring(ls.L, to_luastring('\'%c\'', true), token); } else { let s = luaX_tokens[token - FIRST_RESERVED]; if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ - return lobject.luaO_pushfstring(ls.L, to_luastring("'%s'", true), s); + return lobject.luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), s); else /* names, strings, and numerals */ return s; } @@ -231,7 +215,7 @@ const inclinenumber = function(ls) { if (currIsNewline(ls) && ls.current !== old) next(ls); /* skip '\n\r' or '\r\n' */ if (++ls.linenumber >= MAX_INT) - lexerror(ls, to_luastring("chunk has too many lines", true), 0); + lexerror(ls, to_luastring('chunk has too many lines', true), 0); }; const luaX_setinput = function(L, ls, z, source, firstchar) { @@ -277,16 +261,16 @@ const check_next2 = function(ls, set) { }; const read_numeral = function(ls, seminfo) { - let expo = "Ee"; + let expo = 'Ee'; let first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); - if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, "xX")) /* hexadecimal? */ - expo = "Pp"; + if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, 'xX')) /* hexadecimal? */ + expo = 'Pp'; for (;;) { if (check_next2(ls, expo)) /* exponent part? */ - check_next2(ls, "-+"); /* optional exponent sign */ + check_next2(ls, '-+'); /* optional exponent sign */ if (lisxdigit(ls.current)) save_and_next(ls); else if (ls.current === 46 /* ('.').charCodeAt(0) */) @@ -298,7 +282,7 @@ const read_numeral = function(ls, seminfo) { let obj = new lobject.TValue(); if (lobject.luaO_str2num(luaZ_buffer(ls.buff), obj) === 0) /* format error? */ - lexerror(ls, to_luastring("malformed number", true), TK_FLT); + lexerror(ls, to_luastring('malformed number', true), TK_FLT); if (obj.ttisinteger()) { seminfo.i = obj.value; return TK_INT; @@ -314,7 +298,7 @@ const txtToken = function(ls, token) { case TK_NAME: case TK_STRING: case TK_FLT: case TK_INT: // save(ls, 0); - return lobject.luaO_pushfstring(ls.L, to_luastring("'%s'", true), luaZ_buffer(ls.buff)); + return lobject.luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), luaZ_buffer(ls.buff)); default: return luaX_token2str(ls, token); } @@ -323,7 +307,7 @@ const txtToken = function(ls, token) { const lexerror = function(ls, msg, token) { msg = ldebug.luaG_addinfo(ls.L, msg, ls.source, ls.linenumber); if (token) - lobject.luaO_pushfstring(ls.L, to_luastring("%s near %s"), msg, txtToken(ls, token)); + lobject.luaO_pushfstring(ls.L, to_luastring('%s near %s'), msg, txtToken(ls, token)); ldo.luaD_throw(ls.L, LUA_ERRSYNTAX); }; @@ -359,7 +343,7 @@ const read_long_string = function(ls, seminfo, sep) { for (; !skip ;) { switch (ls.current) { case EOZ: { /* error */ - let what = seminfo ? "string" : "comment"; + let what = seminfo ? 'string' : 'comment'; let msg = `unfinished long ${what} (starting at line ${line})`; lexerror(ls, to_luastring(msg), TK_EOS); break; @@ -399,7 +383,7 @@ const esccheck = function(ls, c, msg) { const gethexa = function(ls) { save_and_next(ls); - esccheck(ls, lisxdigit(ls.current), to_luastring("hexadecimal digit expected", true)); + esccheck(ls, lisxdigit(ls.current), to_luastring('hexadecimal digit expected', true)); return lobject.luaO_hexavalue(ls.current); }; @@ -413,17 +397,17 @@ const readhexaesc = function(ls) { const readutf8desc = function(ls) { let i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ save_and_next(ls); /* skip 'u' */ - esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring("missing '{'", true)); + esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring('missing \'{\'', true)); let r = gethexa(ls); /* must have at least one digit */ save_and_next(ls); while (lisxdigit(ls.current)) { i++; r = (r << 4) + lobject.luaO_hexavalue(ls.current); - esccheck(ls, r <= 0x10FFFF, to_luastring("UTF-8 value too large", true)); + esccheck(ls, r <= 0x10FFFF, to_luastring('UTF-8 value too large', true)); save_and_next(ls); } - esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring("missing '}'", true)); + esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring('missing \'}\'', true)); next(ls); /* skip '}' */ luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */ return r; @@ -443,7 +427,7 @@ const readdecesc = function(ls) { r = 10 * r + ls.current - 48 /* ('0').charCodeAt(0) */; save_and_next(ls); } - esccheck(ls, r <= 255, to_luastring("decimal escape too large", true)); + esccheck(ls, r <= 255, to_luastring('decimal escape too large', true)); luaZ_buffremove(ls.buff, i); /* remove read digits from buffer */ return r; }; @@ -454,11 +438,11 @@ const read_string = function(ls, del, seminfo) { while (ls.current !== del) { switch (ls.current) { case EOZ: - lexerror(ls, to_luastring("unfinished string", true), TK_EOS); + lexerror(ls, to_luastring('unfinished string', true), TK_EOS); break; case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: - lexerror(ls, to_luastring("unfinished string", true), TK_STRING); + lexerror(ls, to_luastring('unfinished string', true), TK_STRING); break; case 92 /* ('\\').charCodeAt(0) */: { /* escape sequences */ save_and_next(ls); /* keep '\\' for error messages */ @@ -492,7 +476,7 @@ const read_string = function(ls, del, seminfo) { will = 'no_save'; break; } default: { - esccheck(ls, lisdigit(ls.current), to_luastring("invalid escape sequence", true)); + esccheck(ls, lisdigit(ls.current), to_luastring('invalid escape sequence', true)); c = readdecesc(ls); /* digital escape '\ddd' */ will = 'only_save'; break; } @@ -528,7 +512,7 @@ const isreserved = function(w) { const llex = function(ls, seminfo) { luaZ_resetbuffer(ls.buff); for (;;) { - lua_assert(typeof ls.current == "number"); /* fengari addition */ + lua_assert(typeof ls.current == 'number'); /* fengari addition */ switch (ls.current) { case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: { /* line breaks */ @@ -568,7 +552,7 @@ const llex = function(ls, seminfo) { read_long_string(ls, seminfo, sep); return TK_STRING; } else if (sep !== -1) /* '[=...' missing second bracket */ - lexerror(ls, to_luastring("invalid long string delimiter", true), TK_STRING); + lexerror(ls, to_luastring('invalid long string delimiter', true), TK_STRING); return 91 /* ('[').charCodeAt(0) */; } case 61 /* ('=').charCodeAt(0) */: { @@ -664,16 +648,3 @@ const luaX_lookahead = function(ls) { ls.lookahead.token = llex(ls, ls.lookahead.seminfo); return ls.lookahead.token; }; - -module.exports.FIRST_RESERVED = FIRST_RESERVED; -module.exports.LUA_ENV = LUA_ENV; -module.exports.LexState = LexState; -module.exports.RESERVED = RESERVED; -module.exports.isreserved = isreserved; -module.exports.luaX_lookahead = luaX_lookahead; -module.exports.luaX_newstring = luaX_newstring; -module.exports.luaX_next = luaX_next; -module.exports.luaX_setinput = luaX_setinput; -module.exports.luaX_syntaxerror = luaX_syntaxerror; -module.exports.luaX_token2str = luaX_token2str; -module.exports.luaX_tokens = luaX_tokens; diff --git a/src/llimits.js b/src/llimits.js index 4f2b3f33..fc1270f1 100644 --- a/src/llimits.js +++ b/src/llimits.js @@ -1,32 +1,23 @@ -"use strict"; - -const lua_assert = function(c) { - if (!c) throw Error("assertion failed"); +export const lua_assert = function(c) { + if (!c) throw Error('assertion failed'); }; -module.exports.lua_assert = lua_assert; -const api_check = function(l, e, msg) { +export const api_check = function(l, e, msg) { if (!e) throw Error(msg); }; -module.exports.api_check = api_check; const LUAI_MAXCCALLS = 200; -module.exports.LUAI_MAXCCALLS = LUAI_MAXCCALLS; /* minimum size for string buffer */ const LUA_MINBUFFER = 32; -module.exports.LUA_MINBUFFER = LUA_MINBUFFER; -const luai_nummod = function(L, a, b) { +export const luai_nummod = function(L, a, b) { let m = a % b; if ((m*b) < 0) m += b; return m; }; -module.exports.luai_nummod = luai_nummod; // If later integers are more than 32bit, LUA_MAXINTEGER will then be != MAX_INT const MAX_INT = 2147483647; -module.exports.MAX_INT = MAX_INT; const MIN_INT = -2147483648; -module.exports.MIN_INT = MIN_INT; diff --git a/src/lmathlib.js b/src/lmathlib.js index 8313e934..be66e73c 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,40 +1,30 @@ -"use strict"; - -const { - LUA_OPLT, - LUA_TNUMBER, +import { lua_compare, lua_gettop, lua_isinteger, lua_isnoneornil, - lua_pushboolean, - lua_pushinteger, - lua_pushliteral, - lua_pushnil, - lua_pushnumber, - lua_pushvalue, - lua_setfield, + LUA_OPLT, + lua_pushboolean, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushvalue, lua_setfield, lua_settop, - lua_tointeger, - lua_tointegerx, - lua_type -} = require('./lua.js'); -const { + LUA_TNUMBER, lua_tointeger, lua_tointegerx, lua_type +} from "./lua.js"; + + +import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checknumber, - luaL_error, - luaL_newlib, - luaL_optnumber -} = require('./lauxlib.js'); -const { - LUA_MAXINTEGER, - LUA_MININTEGER, - lua_numbertointeger -} = require('./luaconf.js'); -const { to_luastring } = require("./fengaricore.js"); + luaL_error, luaL_newlib, luaL_optnumber +} from "./lauxlib.js"; + + +import {LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger} from "./luaconf.js"; + + +import {to_luastring} from "./fengaricore.js"; + let rand_state; /* use same parameters as glibc LCG */ @@ -66,13 +56,13 @@ const math_random = function(L) { up = luaL_checkinteger(L, 2); break; } - default: return luaL_error(L, "wrong number of arguments"); + default: return luaL_error(L, 'wrong number of arguments'); } /* random integer in the interval [low, up] */ - luaL_argcheck(L, low <= up, 1, "interval is empty"); + luaL_argcheck(L, low <= up, 1, 'interval is empty'); luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, - "interval too large"); + 'interval too large'); r *= (up - low) + 1; lua_pushinteger(L, Math.floor(r) + low); @@ -213,7 +203,7 @@ const math_rad = function(L) { const math_min = function(L) { let n = lua_gettop(L); /* number of arguments */ let imin = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, "value expected"); + luaL_argcheck(L, n >= 1, 1, 'value expected'); for (let i = 2; i <= n; i++){ if (lua_compare(L, i, imin, LUA_OPLT)) imin = i; @@ -225,7 +215,7 @@ const math_min = function(L) { const math_max = function(L) { let n = lua_gettop(L); /* number of arguments */ let imax = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, "value expected"); + luaL_argcheck(L, n >= 1, 1, 'value expected'); for (let i = 2; i <= n; i++){ if (lua_compare(L, imax, i, LUA_OPLT)) imax = i; @@ -237,9 +227,9 @@ const math_max = function(L) { const math_type = function(L) { if (lua_type(L, 1) === LUA_TNUMBER) { if (lua_isinteger(L, 1)) - lua_pushliteral(L, "integer"); + lua_pushliteral(L, 'integer'); else - lua_pushliteral(L, "float"); + lua_pushliteral(L, 'float'); } else { luaL_checkany(L, 1); lua_pushnil(L); @@ -252,7 +242,7 @@ const math_fmod = function(L) { let d = lua_tointeger(L, 2); /* no special case needed for -1 in javascript */ if (d === 0) { - luaL_argerror(L, 2, "zero"); + luaL_argerror(L, 2, 'zero'); } else lua_pushinteger(L, (lua_tointeger(L, 1) % d)|0); } else { @@ -277,41 +267,41 @@ const math_modf = function(L) { }; const mathlib = { - "abs": math_abs, - "acos": math_acos, - "asin": math_asin, - "atan": math_atan, - "ceil": math_ceil, - "cos": math_cos, - "deg": math_deg, - "exp": math_exp, - "floor": math_floor, - "fmod": math_fmod, - "log": math_log, - "max": math_max, - "min": math_min, - "modf": math_modf, - "rad": math_rad, - "random": math_random, - "randomseed": math_randomseed, - "sin": math_sin, - "sqrt": math_sqrt, - "tan": math_tan, - "tointeger": math_toint, - "type": math_type, - "ult": math_ult + 'abs': math_abs, + 'acos': math_acos, + 'asin': math_asin, + 'atan': math_atan, + 'ceil': math_ceil, + 'cos': math_cos, + 'deg': math_deg, + 'exp': math_exp, + 'floor': math_floor, + 'fmod': math_fmod, + 'log': math_log, + 'max': math_max, + 'min': math_min, + 'modf': math_modf, + 'rad': math_rad, + 'random': math_random, + 'randomseed': math_randomseed, + 'sin': math_sin, + 'sqrt': math_sqrt, + 'tan': math_tan, + 'tointeger': math_toint, + 'type': math_type, + 'ult': math_ult }; const luaopen_math = function(L) { luaL_newlib(L, mathlib); lua_pushnumber(L, Math.PI); - lua_setfield(L, -2, to_luastring("pi", true)); + lua_setfield(L, -2, to_luastring('pi', true)); lua_pushnumber(L, Infinity); - lua_setfield(L, -2, to_luastring("huge", true)); + lua_setfield(L, -2, to_luastring('huge', true)); lua_pushinteger(L, LUA_MAXINTEGER); - lua_setfield(L, -2, to_luastring("maxinteger", true)); + lua_setfield(L, -2, to_luastring('maxinteger', true)); lua_pushinteger(L, LUA_MININTEGER); - lua_setfield(L, -2, to_luastring("mininteger", true)); + lua_setfield(L, -2, to_luastring('mininteger', true)); return 1; }; diff --git a/src/loadlib.js b/src/loadlib.js index 92bf677e..2a3fc698 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -1,82 +1,52 @@ -"use strict"; - -const { +import fs from "fs"; +import pathlib from "path"; +import { LUA_DIRSEP, LUA_EXEC_DIR, LUA_JSPATH_DEFAULT, LUA_PATH_DEFAULT, LUA_PATH_MARK, LUA_PATH_SEP -} = require('./luaconf.js'); -const { - LUA_OK, - LUA_REGISTRYINDEX, - LUA_TNIL, - LUA_TTABLE, +} from "./luaconf.js"; + + +import { lua_callk, lua_createtable, lua_getfield, - lua_insert, - lua_isfunction, - lua_isnil, - lua_isstring, - lua_newtable, - lua_pop, - lua_pushboolean, - lua_pushcclosure, - lua_pushcfunction, - lua_pushfstring, - lua_pushglobaltable, - lua_pushlightuserdata, - lua_pushliteral, - lua_pushlstring, - lua_pushnil, - lua_pushstring, - lua_pushvalue, - lua_rawgeti, - lua_rawgetp, - lua_rawseti, - lua_rawsetp, - lua_remove, - lua_setfield, - lua_setmetatable, - lua_settop, - lua_toboolean, - lua_tostring, - lua_touserdata, - lua_upvalueindex -} = require('./lua.js'); -const { + lua_insert, lua_isfunction, lua_isnil, lua_isstring, lua_newtable, + LUA_OK, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, + lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgeti, + lua_rawgetp, lua_rawseti, lua_rawsetp, + LUA_REGISTRYINDEX, lua_remove, lua_setfield, lua_setmetatable, lua_settop, + LUA_TNIL, lua_toboolean, lua_tostring, lua_touserdata, + LUA_TTABLE, lua_upvalueindex +} from "./lua.js"; + + +import { LUA_LOADED_TABLE, LUA_PRELOAD_TABLE, - luaL_Buffer, luaL_addvalue, + luaL_Buffer, luaL_buffinit, - luaL_checkstring, - luaL_error, - luaL_getsubtable, - luaL_gsub, - luaL_len, - luaL_loadfile, - luaL_newlib, - luaL_optstring, - luaL_pushresult, - luaL_setfuncs -} = require('./lauxlib.js'); -const lualib = require('./lualib.js'); -const { - luastring_indexOf, - to_jsstring, - to_luastring, - to_uristring -} = require("./fengaricore.js"); -const fengari = require('./fengari.js'); + luaL_checkstring, luaL_error, luaL_getsubtable, luaL_gsub, luaL_len, luaL_loadfile, luaL_newlib, luaL_optstring, + luaL_pushresult, luaL_setfuncs +} from "./lauxlib.js"; + + +import * as lualib from "./lualib.js"; + +import {luastring_indexOf, to_jsstring, to_luastring, to_uristring} from "./fengaricore.js"; + + +import * as fengari from "./fengari.js"; const global_env = (function() { - if (typeof process !== "undefined") { + if (typeof process !== 'undefined') { /* node */ return global; - } else if (typeof window !== "undefined") { + } else if (typeof window !== 'undefined') { /* browser window */ return window; } else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { @@ -88,11 +58,11 @@ const global_env = (function() { } })(); -const JSLIBS = to_luastring("__JSLIBS__"); -const LUA_PATH_VAR = "LUA_PATH"; -const LUA_JSPATH_VAR = "LUA_JSPATH"; +const JSLIBS = to_luastring('__JSLIBS__'); +const LUA_PATH_VAR = 'LUA_PATH'; +const LUA_JSPATH_VAR = 'LUA_JSPATH'; -const LUA_IGMARK = "-"; +const LUA_IGMARK = '-'; /* ** LUA_CSUBSEP is the character that replaces dots in submodule names @@ -104,13 +74,13 @@ const LUA_CSUBSEP = LUA_DIRSEP; const LUA_LSUBSEP = LUA_DIRSEP; /* prefix for open functions in JS libraries */ -const LUA_POF = to_luastring("luaopen_"); +const LUA_POF = to_luastring('luaopen_'); /* separator for open functions in JS libraries */ -const LUA_OFSEP = to_luastring("_"); -const LIB_FAIL = "open"; +const LUA_OFSEP = to_luastring('_'); +const LIB_FAIL = 'open'; -const AUXMARK = to_luastring("\x01"); +const AUXMARK = to_luastring('\x01'); /* @@ -120,11 +90,11 @@ const AUXMARK = to_luastring("\x01"); ** error string in the stack. */ let lsys_load; -if (typeof process === "undefined") { +if (typeof process === 'undefined') { lsys_load = function(L, path, seeglb) { path = to_uristring(path); let xhr = new XMLHttpRequest(); - xhr.open("GET", path, false); + xhr.open('GET', path, false); xhr.send(); if (xhr.status < 200 || xhr.status >= 300) { @@ -135,16 +105,16 @@ if (typeof process === "undefined") { let code = xhr.response; /* Add sourceURL comment to get path in debugger+tracebacks */ if (!/\/\/[#@] sourceURL=/.test(code)) - code += " //# sourceURL=" + path; + code += ' //# sourceURL=' + path; let func; try { - func = Function("fengari", code); + func = Function('fengari', code); } catch (e) { lua_pushstring(L, to_luastring(`${e.name}: ${e.message}`)); return null; } let res = func(fengari); - if (typeof res === "function" || (typeof res === "object" && res !== null)) { + if (typeof res === 'function' || (typeof res === 'object' && res !== null)) { return res; } else if (res === void 0) { /* assume library added symbols to global environment */ return global_env; @@ -154,13 +124,12 @@ if (typeof process === "undefined") { } }; } else { - const pathlib = require('path'); lsys_load = function(L, path, seeglb) { path = to_jsstring(path); /* relative paths should be relative to cwd, not this js file */ path = pathlib.resolve(process.cwd(), path); try { - return require(path); + return require(path); // TODO: This cannot happen - need to convert this call to ES } catch (e) { lua_pushstring(L, to_luastring(e.message)); return null; @@ -179,7 +148,7 @@ const lsys_sym = function(L, lib, sym) { if (f && typeof f === 'function') return f; else { - lua_pushfstring(L, to_luastring("undefined symbol: %s"), sym); + lua_pushfstring(L, to_luastring('undefined symbol: %s'), sym); return null; } }; @@ -188,15 +157,14 @@ const lsys_sym = function(L, lib, sym) { ** return registry.LUA_NOENV as a boolean */ const noenv = function(L) { - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("LUA_NOENV")); + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('LUA_NOENV')); let b = lua_toboolean(L, -1); lua_pop(L, 1); /* remove value */ return b; }; let readable; -if (typeof process !== "undefined") { // Only with Node - const fs = require('fs'); +if (typeof process !== 'undefined') { // Only with Node readable = function(filename) { try { @@ -212,7 +180,7 @@ if (typeof process !== "undefined") { // Only with Node path = to_uristring(path); let xhr = new XMLHttpRequest(); /* Following GET request done by searcher_Web will be cached */ - xhr.open("GET", path, false); + xhr.open('GET', path, false); xhr.send(); return xhr.status >= 200 && xhr.status <= 299; @@ -264,13 +232,13 @@ const ll_loadlib = function(L) { else { /* error; error message is on stack top */ lua_pushnil(L); lua_insert(L, -2); - lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : "init"); + lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : 'init'); return 3; /* return nil, error message, and where */ } }; const env = (function() { - if (typeof process !== "undefined") { + if (typeof process !== 'undefined') { /* node */ return process.env; } else { @@ -347,7 +315,7 @@ const searchpath = function(L, name, path, sep, dirsep) { lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pushfstring(L, to_luastring("\n\tno file '%s'"), filename); + lua_pushfstring(L, to_luastring('\n\tno file \'%s\''), filename); lua_remove(L, -2); /* remove file name */ luaL_addvalue(msg); } @@ -360,7 +328,7 @@ const ll_searchpath = function(L) { L, luaL_checkstring(L, 1), luaL_checkstring(L, 2), - luaL_optstring(L, 3, "."), + luaL_optstring(L, 3, '.'), luaL_optstring(L, 4, LUA_DIRSEP) ); if (f !== null) return 1; @@ -375,8 +343,8 @@ const findfile = function(L, name, pname, dirsep) { lua_getfield(L, lua_upvalueindex(1), pname); let path = lua_tostring(L, -1); if (path === null) - luaL_error(L, to_luastring("'package.%s' must be a string"), pname); - return searchpath(L, name, path, to_luastring("."), dirsep); + luaL_error(L, to_luastring('\'package.%s\' must be a string'), pname); + return searchpath(L, name, path, to_luastring('.'), dirsep); }; const checkload = function(L, stat, filename) { @@ -384,13 +352,13 @@ const checkload = function(L, stat, filename) { lua_pushstring(L, filename); /* will be 2nd argument to module */ return 2; /* return open function and file name */ } else - return luaL_error(L, to_luastring("error loading module '%s' from file '%s':\n\t%s"), + return luaL_error(L, to_luastring('error loading module \'%s\' from file \'%s\':\n\t%s'), lua_tostring(L, 1), filename, lua_tostring(L, -1)); }; const searcher_Lua = function(L) { let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring("path", true), to_luastring(LUA_LSUBSEP, true)); + let filename = findfile(L, name, to_luastring('path', true), to_luastring(LUA_LSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, luaL_loadfile(L, filename) === LUA_OK, filename); }; @@ -405,22 +373,22 @@ const searcher_Lua = function(L) { */ const loadfunc = function(L, filename, modname) { let openfunc; - modname = luaL_gsub(L, modname, to_luastring("."), LUA_OFSEP); + modname = luaL_gsub(L, modname, to_luastring('.'), LUA_OFSEP); let mark = luastring_indexOf(modname, LUA_IGMARK.charCodeAt(0)); if (mark >= 0) { openfunc = lua_pushlstring(L, modname, mark); - openfunc = lua_pushfstring(L, to_luastring("%s%s"), LUA_POF, openfunc); + openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, openfunc); let stat = lookforfunc(L, filename, openfunc); if (stat !== ERRFUNC) return stat; modname = mark + 1; /* else go ahead and try old-style name */ } - openfunc = lua_pushfstring(L, to_luastring("%s%s"), LUA_POF, modname); + openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, modname); return lookforfunc(L, filename, openfunc); }; const searcher_C = function(L) { let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring("jspath", true), to_luastring(LUA_CSUBSEP, true)); + let filename = findfile(L, name, to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, (loadfunc(L, filename, name) === 0), filename); }; @@ -431,13 +399,13 @@ const searcher_Croot = function(L) { let stat; if (p < 0) return 0; /* is root */ lua_pushlstring(L, name, p); - let filename = findfile(L, lua_tostring(L, -1), to_luastring("jspath", true), to_luastring(LUA_CSUBSEP, true)); + let filename = findfile(L, lua_tostring(L, -1), to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* root not found */ if ((stat = loadfunc(L, filename, name)) !== 0) { if (stat != ERRFUNC) return checkload(L, 0, filename); /* real error */ else { /* open function not found */ - lua_pushfstring(L, to_luastring("\n\tno module '%s' in file '%s'"), name, filename); + lua_pushfstring(L, to_luastring('\n\tno module \'%s\' in file \'%s\''), name, filename); return 1; } } @@ -449,7 +417,7 @@ const searcher_preload = function(L) { let name = luaL_checkstring(L, 1); lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); if (lua_getfield(L, -1, name) === LUA_TNIL) /* not found? */ - lua_pushfstring(L, to_luastring("\n\tno field package.preload['%s']"), name); + lua_pushfstring(L, to_luastring('\n\tno field package.preload[\'%s\']'), name); return 1; }; @@ -457,8 +425,8 @@ const findloader = function(L, name, ctx, k) { let msg = new luaL_Buffer(); /* to build error message */ luaL_buffinit(L, msg); /* push 'package.searchers' to index 3 in the stack */ - if (lua_getfield(L, lua_upvalueindex(1), to_luastring("searchers", true)) !== LUA_TTABLE) - luaL_error(L, to_luastring("'package.searchers' must be a table")); + if (lua_getfield(L, lua_upvalueindex(1), to_luastring('searchers', true)) !== LUA_TTABLE) + luaL_error(L, to_luastring('\'package.searchers\' must be a table')); let ctx2 = {name: name, i: 1, msg: msg, ctx: ctx, k: k}; return findloader_cont(L, LUA_OK, ctx2); }; @@ -470,7 +438,7 @@ const findloader_cont = function(L, status, ctx) { if (lua_rawgeti(L, 3, ctx.i) === LUA_TNIL) { /* no more searchers? */ lua_pop(L, 1); /* remove nil */ luaL_pushresult(ctx.msg); /* create error message */ - luaL_error(L, to_luastring("module '%s' not found:%s"), ctx.name, lua_tostring(L, -1)); + luaL_error(L, to_luastring('module \'%s\' not found:%s'), ctx.name, lua_tostring(L, -1)); } lua_pushstring(L, ctx.name); lua_callk(L, 1, 2, ctx, findloader_cont); /* call it */ @@ -523,12 +491,12 @@ const ll_require_cont2 = function(L, status, ctx) { }; const pk_funcs = { - "loadlib": ll_loadlib, - "searchpath": ll_searchpath + 'loadlib': ll_loadlib, + 'searchpath': ll_searchpath }; const ll_funcs = { - "require": ll_require + 'require': ll_require }; const createsearcherstable = function(L) { @@ -541,7 +509,7 @@ const createsearcherstable = function(L) { lua_pushcclosure(L, searchers[i], 1); lua_rawseti(L, -2, i+1); } - lua_setfield(L, -2, to_luastring("searchers", true)); /* put it in field 'searchers' */ + lua_setfield(L, -2, to_luastring('searchers', true)); /* put it in field 'searchers' */ }; /* @@ -560,23 +528,21 @@ const luaopen_package = function(L) { luaL_newlib(L, pk_funcs); /* create 'package' table */ createsearcherstable(L); /* set paths */ - setpath(L, to_luastring("path", true), LUA_PATH_VAR, LUA_PATH_DEFAULT); - setpath(L, to_luastring("jspath", true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); + setpath(L, to_luastring('path', true), LUA_PATH_VAR, LUA_PATH_DEFAULT); + setpath(L, to_luastring('jspath', true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); /* store config information */ - lua_pushliteral(L, LUA_DIRSEP + "\n" + LUA_PATH_SEP + "\n" + LUA_PATH_MARK + "\n" + - LUA_EXEC_DIR + "\n" + LUA_IGMARK + "\n"); - lua_setfield(L, -2, to_luastring("config", true)); + lua_pushliteral(L, LUA_DIRSEP + '\n' + LUA_PATH_SEP + '\n' + LUA_PATH_MARK + '\n' + + LUA_EXEC_DIR + '\n' + LUA_IGMARK + '\n'); + lua_setfield(L, -2, to_luastring('config', true)); /* set field 'loaded' */ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - lua_setfield(L, -2, to_luastring("loaded", true)); + lua_setfield(L, -2, to_luastring('loaded', true)); /* set field 'preload' */ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - lua_setfield(L, -2, to_luastring("preload", true)); + lua_setfield(L, -2, to_luastring('preload', true)); lua_pushglobaltable(L); lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ lua_pop(L, 1); /* pop global table */ return 1; /* return 'package' table */ }; - -module.exports.luaopen_package = luaopen_package; diff --git a/src/lobject.js b/src/lobject.js index c83439c7..ae2478ab 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -1,6 +1,6 @@ -"use strict"; - -const { +import { + from_userstring, + LUA_NUMTAGS, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, @@ -15,8 +15,34 @@ const { LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, - constant_types: { - LUA_NUMTAGS, + LUA_TBOOLEAN, + LUA_TCCL, + LUA_TFUNCTION, + LUA_TLCF, + LUA_TLCL, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMBER, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, + LUA_TSTRING, + LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, luastring_indexOf, luastring_of, to_jsstring, to_luastring +} from "./defs.js"; +import * as ltm from "./ltm.js"; +import {lua_assert, luai_nummod, MAX_INT} from "./llimits.js"; +import * as lvm from "./lvm.js"; +import {ldexp, LUA_COMPAT_FLOATSTRING, lua_integer2str, lua_number2str} from "./luaconf.js"; +import * as ltable from "./ltable.js"; +import {luaS_bless, luaS_new} from "./lstring.js"; +import * as lstate from "./lstate.js"; +import * as ldo from "./ldo.js"; +import * as ldebug from "./ldebug.js"; +import {lisdigit, lisprint, lisspace, lisxdigit} from "./ljstype.js"; + +const constant_types = { + LUA_NUMTAGS, LUA_TBOOLEAN, LUA_TCCL, LUA_TFUNCTION, @@ -33,45 +59,12 @@ const { LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA - }, - from_userstring, - luastring_indexOf, - luastring_of, - to_jsstring, - to_luastring -} = require('./defs.js'); -const { - lisdigit, - lisprint, - lisspace, - lisxdigit -} = require('./ljstype.js'); -const ldebug = require('./ldebug.js'); -const ldo = require('./ldo.js'); -const lstate = require('./lstate.js'); -const { - luaS_bless, - luaS_new -} = require('./lstring.js'); -const ltable = require('./ltable.js'); -const { - LUA_COMPAT_FLOATSTRING, - ldexp, - lua_integer2str, - lua_number2str -} = require('./luaconf.js'); -const lvm = require('./lvm.js'); -const { - MAX_INT, - luai_nummod, - lua_assert -} = require("./llimits.js"); -const ltm = require('./ltm.js'); +} const LUA_TPROTO = LUA_NUMTAGS; const LUA_TDEADKEY = LUA_NUMTAGS+1; -class TValue { +export class TValue { constructor(type, value) { this.type = type; @@ -270,27 +263,26 @@ class TValue { } } -const pushobj2s = function(L, tv) { +export const pushobj2s = function(L, tv) { L.stack[L.top++] = new TValue(tv.type, tv.value); }; -const pushsvalue2s = function(L, ts) { +export const pushsvalue2s = function(L, ts) { L.stack[L.top++] = new TValue(LUA_TLNGSTR, ts); }; /* from stack to (same) stack */ -const setobjs2s = function(L, newidx, oldidx) { +export const setobjs2s = function(L, newidx, oldidx) { L.stack[newidx].setfrom(L.stack[oldidx]); }; /* to stack (not from same stack) */ -const setobj2s = function(L, newidx, oldtv) { +export const setobj2s = function(L, newidx, oldtv) { L.stack[newidx].setfrom(oldtv); }; const setsvalue2s = function(L, newidx, ts) { L.stack[newidx].setsvalue(ts); }; -const luaO_nilobject = new TValue(LUA_TNIL, null); +export const luaO_nilobject = new TValue(LUA_TNIL, null); Object.freeze(luaO_nilobject); -module.exports.luaO_nilobject = luaO_nilobject; class LClosure { @@ -304,7 +296,7 @@ class LClosure { } -class CClosure { +export class CClosure { constructor(L, f, n) { this.id = L.l_G.id_counter++; @@ -319,7 +311,7 @@ class CClosure { } -class Udata { +export class Udata { constructor(L, size) { this.id = L.l_G.id_counter++; @@ -344,9 +336,9 @@ class LocVar { } } -const RETS = to_luastring("..."); -const PRE = to_luastring("[string \""); -const POS = to_luastring("\"]"); +const RETS = to_luastring('...'); +const PRE = to_luastring('[string "'); +const POS = to_luastring('"]'); const luaO_chunkid = function(source, bufflen) { let l = source.length; @@ -505,11 +497,11 @@ const SIGILS = [ 78 /* ("N").charCodeAt(0) */ ]; const modes = { - [ 46]: ".", - [120]: "x", - [ 88]: "x", - [110]: "n", - [ 78]: "n" + [ 46]: '.', + [120]: 'x', + [ 88]: 'x', + [110]: 'n', + [ 78]: 'n' }; const l_str2d = function(s) { let l = s.length; @@ -568,7 +560,7 @@ const l_str2int = function(s) { } }; -const luaO_str2num = function(s, o) { +export const luaO_str2num = function(s, o) { let s2i = l_str2int(s); if (s2i !== null) { /* try as an integer */ o.setivalue(s2i.n); @@ -583,7 +575,7 @@ const luaO_str2num = function(s, o) { } }; -const luaO_tostring = function(L, obj) { +export const luaO_tostring = function(L, obj) { let buff; if (obj.ttisinteger()) buff = to_luastring(lua_integer2str(obj.value)); @@ -602,7 +594,7 @@ const pushstr = function(L, str) { setsvalue2s(L, L.top-1, luaS_new(L, str)); }; -const luaO_pushvfstring = function(L, fmt, argp) { +export const luaO_pushvfstring = function(L, fmt, argp) { let n = 0; let i = 0; let a = 0; @@ -614,7 +606,7 @@ const luaO_pushvfstring = function(L, fmt, argp) { switch(fmt[e+1]) { case 115 /* ('s').charCodeAt(0) */: { let s = argp[a++]; - if (s === null) s = to_luastring("(null)", true); + if (s === null) s = to_luastring('(null)', true); else { s = from_userstring(s); /* respect null terminator */ @@ -630,7 +622,7 @@ const luaO_pushvfstring = function(L, fmt, argp) { if (lisprint(buff)) pushstr(L, luastring_of(buff)); else - luaO_pushfstring(L, to_luastring("<\\%d>", true), buff); + luaO_pushfstring(L, to_luastring('<\\%d>', true), buff); break; } case 100 /* ('d').charCodeAt(0) */: @@ -651,39 +643,39 @@ const luaO_pushvfstring = function(L, fmt, argp) { v instanceof Udata || v instanceof LClosure || v instanceof CClosure) { - pushstr(L, to_luastring("0x"+v.id.toString(16))); + pushstr(L, to_luastring('0x'+v.id.toString(16))); } else { switch(typeof v) { - case "undefined": - pushstr(L, to_luastring("undefined")); + case 'undefined': + pushstr(L, to_luastring('undefined')); break; - case "number": /* before check object as null is an object */ - pushstr(L, to_luastring("Number("+v+")")); + case 'number': /* before check object as null is an object */ + pushstr(L, to_luastring('Number('+v+')')); break; - case "string": /* before check object as null is an object */ - pushstr(L, to_luastring("String("+JSON.stringify(v)+")")); + case 'string': /* before check object as null is an object */ + pushstr(L, to_luastring('String('+JSON.stringify(v)+')')); break; - case "boolean": /* before check object as null is an object */ - pushstr(L, to_luastring(v?"Boolean(true)":"Boolean(false)")); + case 'boolean': /* before check object as null is an object */ + pushstr(L, to_luastring(v?'Boolean(true)':'Boolean(false)')); break; - case "object": + case 'object': if (v === null) { /* null is special */ - pushstr(L, to_luastring("null")); + pushstr(L, to_luastring('null')); break; } /* fall through */ - case "function": { + case 'function': { let id = L.l_G.ids.get(v); if (!id) { id = L.l_G.id_counter++; L.l_G.ids.set(v, id); } - pushstr(L, to_luastring("0x"+id.toString(16))); + pushstr(L, to_luastring('0x'+id.toString(16))); break; } default: /* user provided object. no id available */ - pushstr(L, to_luastring("")); + pushstr(L, to_luastring('')); } } break; @@ -695,10 +687,10 @@ const luaO_pushvfstring = function(L, fmt, argp) { break; } case 37 /* ('%').charCodeAt(0) */: - pushstr(L, to_luastring("%", true)); + pushstr(L, to_luastring('%', true)); break; default: - ldebug.luaG_runerror(L, to_luastring("invalid option '%%%c' to 'lua_pushfstring'"), fmt[e + 1]); + ldebug.luaG_runerror(L, to_luastring('invalid option \'%%%c\' to \'lua_pushfstring\''), fmt[e + 1]); } n += 2; i = e + 2; @@ -766,8 +758,8 @@ const numarith = function(L, op, v1, v2) { } }; -const luaO_arith = function(L, op, p1, p2, p3) { - let res = (typeof p3 === "number") ? L.stack[p3] : p3; /* FIXME */ +export const luaO_arith = function(L, op, p1, p2, p3) { + let res = (typeof p3 === 'number') ? L.stack[p3] : p3; /* FIXME */ switch (op) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: @@ -805,28 +797,3 @@ const luaO_arith = function(L, op, p1, p2, p3) { lua_assert(L !== null); /* should not fail when folding (compile time) */ ltm.luaT_trybinTM(L, p1, p2, p3, (op - LUA_OPADD) + ltm.TMS.TM_ADD); }; - - -module.exports.CClosure = CClosure; -module.exports.LClosure = LClosure; -module.exports.LUA_TDEADKEY = LUA_TDEADKEY; -module.exports.LUA_TPROTO = LUA_TPROTO; -module.exports.LocVar = LocVar; -module.exports.TValue = TValue; -module.exports.Udata = Udata; -module.exports.UTF8BUFFSZ = UTF8BUFFSZ; -module.exports.luaO_arith = luaO_arith; -module.exports.luaO_chunkid = luaO_chunkid; -module.exports.luaO_hexavalue = luaO_hexavalue; -module.exports.luaO_int2fb = luaO_int2fb; -module.exports.luaO_pushfstring = luaO_pushfstring; -module.exports.luaO_pushvfstring = luaO_pushvfstring; -module.exports.luaO_str2num = luaO_str2num; -module.exports.luaO_tostring = luaO_tostring; -module.exports.luaO_utf8esc = luaO_utf8esc; -module.exports.numarith = numarith; -module.exports.pushobj2s = pushobj2s; -module.exports.pushsvalue2s = pushsvalue2s; -module.exports.setobjs2s = setobjs2s; -module.exports.setobj2s = setobj2s; -module.exports.setsvalue2s = setsvalue2s; diff --git a/src/lopcodes.js b/src/lopcodes.js index ae4dbb1f..099e5b3a 100644 --- a/src/lopcodes.js +++ b/src/lopcodes.js @@ -1,56 +1,54 @@ -"use strict"; - const OpCodes = [ - "MOVE", - "LOADK", - "LOADKX", - "LOADBOOL", - "LOADNIL", - "GETUPVAL", - "GETTABUP", - "GETTABLE", - "SETTABUP", - "SETUPVAL", - "SETTABLE", - "NEWTABLE", - "SELF", - "ADD", - "SUB", - "MUL", - "MOD", - "POW", - "DIV", - "IDIV", - "BAND", - "BOR", - "BXOR", - "SHL", - "SHR", - "UNM", - "BNOT", - "NOT", - "LEN", - "CONCAT", - "JMP", - "EQ", - "LT", - "LE", - "TEST", - "TESTSET", - "CALL", - "TAILCALL", - "RETURN", - "FORLOOP", - "FORPREP", - "TFORCALL", - "TFORLOOP", - "SETLIST", - "CLOSURE", - "VARARG", - "EXTRAARG" + 'MOVE', + 'LOADK', + 'LOADKX', + 'LOADBOOL', + 'LOADNIL', + 'GETUPVAL', + 'GETTABUP', + 'GETTABLE', + 'SETTABUP', + 'SETUPVAL', + 'SETTABLE', + 'NEWTABLE', + 'SELF', + 'ADD', + 'SUB', + 'MUL', + 'MOD', + 'POW', + 'DIV', + 'IDIV', + 'BAND', + 'BOR', + 'BXOR', + 'SHL', + 'SHR', + 'UNM', + 'BNOT', + 'NOT', + 'LEN', + 'CONCAT', + 'JMP', + 'EQ', + 'LT', + 'LE', + 'TEST', + 'TESTSET', + 'CALL', + 'TAILCALL', + 'RETURN', + 'FORLOOP', + 'FORPREP', + 'TFORCALL', + 'TFORLOOP', + 'SETLIST', + 'CLOSURE', + 'VARARG', + 'EXTRAARG' ]; -const OpCodesI = { +export const OpCodesI = { OP_MOVE: 0, OP_LOADK: 1, OP_LOADKX: 2, @@ -219,12 +217,12 @@ const MAXINDEXRK = (BITRK - 1); const NO_REG = MAXARG_A; /* test whether value is a constant */ -const ISK = function (x) { +export const ISK = function (x) { return x & BITRK; }; /* gets the index of the constant */ -const INDEXK = function (r) { +export const INDEXK = function (r) { return r & ~BITRK; }; @@ -310,7 +308,7 @@ const SETARG_sBx = function(i, b) { ** Pre-calculate all possible part of the instruction */ const fullins = function(ins) { - if (typeof ins === "number") { + if (typeof ins === 'number') { return { code: ins, opcode: (ins >> POS_OP) & MASK1(SIZE_OP, 0), @@ -347,63 +345,4 @@ const CREATE_Ax = function(o, a) { }; /* number of list items to accumulate before a SETLIST instruction */ -const LFIELDS_PER_FLUSH = 50; - -module.exports.BITRK = BITRK; -module.exports.CREATE_ABC = CREATE_ABC; -module.exports.CREATE_ABx = CREATE_ABx; -module.exports.CREATE_Ax = CREATE_Ax; -module.exports.GET_OPCODE = GET_OPCODE; -module.exports.GETARG_A = GETARG_A; -module.exports.GETARG_B = GETARG_B; -module.exports.GETARG_C = GETARG_C; -module.exports.GETARG_Bx = GETARG_Bx; -module.exports.GETARG_Ax = GETARG_Ax; -module.exports.GETARG_sBx = GETARG_sBx; -module.exports.INDEXK = INDEXK; -module.exports.ISK = ISK; -module.exports.LFIELDS_PER_FLUSH = LFIELDS_PER_FLUSH; -module.exports.MAXARG_A = MAXARG_A; -module.exports.MAXARG_Ax = MAXARG_Ax; -module.exports.MAXARG_B = MAXARG_B; -module.exports.MAXARG_Bx = MAXARG_Bx; -module.exports.MAXARG_C = MAXARG_C; -module.exports.MAXARG_sBx = MAXARG_sBx; -module.exports.MAXINDEXRK = MAXINDEXRK; -module.exports.NO_REG = NO_REG; -module.exports.OpArgK = OpArgK; -module.exports.OpArgN = OpArgN; -module.exports.OpArgR = OpArgR; -module.exports.OpArgU = OpArgU; -module.exports.OpCodes = OpCodes; -module.exports.OpCodesI = OpCodesI; -module.exports.POS_A = POS_A; -module.exports.POS_Ax = POS_Ax; -module.exports.POS_B = POS_B; -module.exports.POS_Bx = POS_Bx; -module.exports.POS_C = POS_C; -module.exports.POS_OP = POS_OP; -module.exports.RKASK = RKASK; -module.exports.SETARG_A = SETARG_A; -module.exports.SETARG_Ax = SETARG_Ax; -module.exports.SETARG_B = SETARG_B; -module.exports.SETARG_Bx = SETARG_Bx; -module.exports.SETARG_C = SETARG_C; -module.exports.SETARG_sBx = SETARG_sBx; -module.exports.SET_OPCODE = SET_OPCODE; -module.exports.SIZE_A = SIZE_A; -module.exports.SIZE_Ax = SIZE_Ax; -module.exports.SIZE_B = SIZE_B; -module.exports.SIZE_Bx = SIZE_Bx; -module.exports.SIZE_C = SIZE_C; -module.exports.SIZE_OP = SIZE_OP; -module.exports.fullins = fullins; -module.exports.getBMode = getBMode; -module.exports.getCMode = getCMode; -module.exports.getOpMode = getOpMode; -module.exports.iABC = iABC; -module.exports.iABx = iABx; -module.exports.iAsBx = iAsBx; -module.exports.iAx = iAx; -module.exports.testAMode = testAMode; -module.exports.testTMode = testTMode; +export const LFIELDS_PER_FLUSH = 50; diff --git a/src/loslib.js b/src/loslib.js index 2e7b90ef..f8b8260e 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -1,51 +1,26 @@ -"use strict"; - -const { - LUA_TNIL, - LUA_TTABLE, +import { lua_close, lua_createtable, lua_getfield, lua_isboolean, lua_isnoneornil, - lua_pop, - lua_pushboolean, - lua_pushfstring, - lua_pushinteger, - lua_pushliteral, - lua_pushnil, - lua_pushnumber, - lua_pushstring, - lua_setfield, - lua_settop, - lua_toboolean, - lua_tointegerx -} = require('./lua.js'); -const { - luaL_Buffer, + lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, + lua_pushstring, lua_setfield, lua_settop, + LUA_TNIL, lua_toboolean, lua_tointegerx, + LUA_TTABLE +} from "./lua.js"; +import { luaL_addchar, luaL_addstring, - // luaL_argcheck, luaL_argerror, + luaL_Buffer, luaL_buffinit, luaL_checkinteger, - luaL_checkoption, - luaL_checkstring, - luaL_checktype, - luaL_error, - luaL_execresult, - luaL_fileresult, - luaL_newlib, - luaL_optinteger, - luaL_optlstring, - luaL_optstring, - luaL_pushresult -} = require('./lauxlib.js'); -const { - luastring_eq, - to_jsstring, - to_luastring -} = require("./fengaricore.js"); + luaL_checkoption, luaL_checkstring, luaL_checktype, luaL_error, luaL_execresult, luaL_fileresult, luaL_newlib, + luaL_optinteger, luaL_optlstring, luaL_optstring, luaL_pushresult +} from "./lauxlib.js"; +import {luastring_eq, to_jsstring, to_luastring} from "./fengaricore.js"; + /* options for ANSI C 89 (only 1-char options) */ // const L_STRFTIMEC89 = to_luastring("aAbBcdHIjmMpSUwWxXyYZ%"); @@ -69,7 +44,7 @@ const { - %l: TZ extension: space-padded 12-hour - %P: GNU extension: lower-case am/pm */ -const LUA_STRFTIMEOPTIONS = to_luastring("aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%"); +const LUA_STRFTIMEOPTIONS = to_luastring('aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%'); const setfield = function(L, key, value) { @@ -78,14 +53,14 @@ const setfield = function(L, key, value) { }; const setallfields = function(L, time, utc) { - setfield(L, "sec", utc ? time.getUTCSeconds() : time.getSeconds()); - setfield(L, "min", utc ? time.getUTCMinutes() : time.getMinutes()); - setfield(L, "hour", utc ? time.getUTCHours() : time.getHours()); - setfield(L, "day", utc ? time.getUTCDate() : time.getDate()); - setfield(L, "month", (utc ? time.getUTCMonth() : time.getMonth()) + 1); - setfield(L, "year", utc ? time.getUTCFullYear() : time.getFullYear()); - setfield(L, "wday", (utc ? time.getUTCDay() : time.getDay()) + 1); - setfield(L, "yday", Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); + setfield(L, 'sec', utc ? time.getUTCSeconds() : time.getSeconds()); + setfield(L, 'min', utc ? time.getUTCMinutes() : time.getMinutes()); + setfield(L, 'hour', utc ? time.getUTCHours() : time.getHours()); + setfield(L, 'day', utc ? time.getUTCDate() : time.getDate()); + setfield(L, 'month', (utc ? time.getUTCMonth() : time.getMonth()) + 1); + setfield(L, 'year', utc ? time.getUTCFullYear() : time.getFullYear()); + setfield(L, 'wday', (utc ? time.getUTCDay() : time.getDay()) + 1); + setfield(L, 'yday', Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); // setboolfield(L, "isdst", time.get); }; @@ -96,14 +71,14 @@ const getfield = function(L, key, d, delta) { let res = lua_tointegerx(L, -1); if (res === false) { /* field is not an integer? */ if (t !== LUA_TNIL) /* some other value? */ - return luaL_error(L, to_luastring("field '%s' is not an integer"), key); + return luaL_error(L, to_luastring('field \'%s\' is not an integer'), key); else if (d < 0) /* absent field; no default? */ - return luaL_error(L, to_luastring("field '%s' missing in date table"), key); + return luaL_error(L, to_luastring('field \'%s\' missing in date table'), key); res = d; } else { if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) - return luaL_error(L, to_luastring("field '%s' is out-of-bound"), key); + return luaL_error(L, to_luastring('field \'%s\' is out-of-bound'), key); res -= delta; } lua_pop(L, 1); @@ -112,23 +87,23 @@ const getfield = function(L, key, d, delta) { const locale = { - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ].map((s) => to_luastring(s)), - shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].map((s) => to_luastring(s)), - months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"].map((s) => to_luastring(s)), - shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map((s) => to_luastring(s)), - AM: to_luastring("AM"), - PM: to_luastring("PM"), - am: to_luastring("am"), - pm: to_luastring("pm"), + days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ].map((s) => to_luastring(s)), + shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((s) => to_luastring(s)), + months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].map((s) => to_luastring(s)), + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'].map((s) => to_luastring(s)), + AM: to_luastring('AM'), + PM: to_luastring('PM'), + am: to_luastring('am'), + pm: to_luastring('pm'), formats: { - c: to_luastring("%a %b %e %H:%M:%S %Y"), - D: to_luastring("%m/%d/%y"), - F: to_luastring("%Y-%m-%d"), - R: to_luastring("%H:%M"), - r: to_luastring("%I:%M:%S %p"), - T: to_luastring("%H:%M:%S"), - X: to_luastring("%T"), - x: to_luastring("%D") + c: to_luastring('%a %b %e %H:%M:%S %Y'), + D: to_luastring('%m/%d/%y'), + F: to_luastring('%Y-%m-%d'), + R: to_luastring('%H:%M'), + r: to_luastring('%I:%M:%S %p'), + T: to_luastring('%H:%M:%S'), + X: to_luastring('%T'), + x: to_luastring('%D') } }; @@ -229,12 +204,12 @@ const strftime = function(L, b, s, date) { // '00' case 85 /* U */: - push_pad_2(b, week_number(date, "sunday"), 48 /* 0 */); + push_pad_2(b, week_number(date, 'sunday'), 48 /* 0 */); break; // '00' case 87 /* W */: - push_pad_2(b, week_number(date, "monday"), 48 /* 0 */); + push_pad_2(b, week_number(date, 'monday'), 48 /* 0 */); break; // '16:00:00' @@ -387,7 +362,7 @@ const checkoption = function(L, conv, i) { } } luaL_argerror(L, 1, - lua_pushfstring(L, to_luastring("invalid conversion specifier '%%%s'"), conv)); + lua_pushfstring(L, to_luastring('invalid conversion specifier \'%%%s\''), conv)); }; /* maximum size for an individual 'strftime' item */ @@ -395,7 +370,7 @@ const checkoption = function(L, conv, i) { const os_date = function(L) { - let s = luaL_optlstring(L, 1, "%c"); + let s = luaL_optlstring(L, 1, '%c'); let stm = lua_isnoneornil(L, 2) ? new Date() : new Date(l_checktime(L, 2) * 1000); let utc = false; let i = 0; @@ -403,12 +378,12 @@ const os_date = function(L) { utc = true; i++; /* skip '!' */ } - if (s[i] === "*".charCodeAt(0) && s[i+1] === "t".charCodeAt(0)) { + if (s[i] === '*'.charCodeAt(0) && s[i+1] === 't'.charCodeAt(0)) { lua_createtable(L, 0, 9); /* 9 = number of fields */ setallfields(L, stm, utc); } else { let cc = new Uint8Array(4); - cc[0] = "%".charCodeAt(0); + cc[0] = '%'.charCodeAt(0); let b = new luaL_Buffer(); luaL_buffinit(L, b); strftime(L, b, s, stm); @@ -425,12 +400,12 @@ const os_time = function(L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ t = new Date( - getfield(L, "year", -1, 0), - getfield(L, "month", -1, 1), - getfield(L, "day", -1, 0), - getfield(L, "hour", 12, 0), - getfield(L, "min", 0, 0), - getfield(L, "sec", 0, 0) + getfield(L, 'year', -1, 0), + getfield(L, 'month', -1, 1), + getfield(L, 'day', -1, 0), + getfield(L, 'hour', 12, 0), + getfield(L, 'min', 0, 0), + getfield(L, 'sec', 0, 0) ); setallfields(L, t); } @@ -452,12 +427,12 @@ const os_difftime = function(L) { return 1; }; -const catnames = ["all", "collate", "ctype", "monetary", "numeric", "time"].map((lc) => to_luastring(lc)); -const C = to_luastring("C"); -const POSIX = to_luastring("POSIX"); +const catnames = ['all', 'collate', 'ctype', 'monetary', 'numeric', 'time'].map((lc) => to_luastring(lc)); +const C = to_luastring('C'); +const POSIX = to_luastring('POSIX'); const os_setlocale = function(L) { const l = luaL_optstring(L, 1, null); - luaL_checkoption(L, 2, "all", catnames); + luaL_checkoption(L, 2, 'all', catnames); /* It is not possible to set the JS-VM wide locale, so we say that we only know the C locale. The "POSIX" locale is defined in IEEE Std 1003.1-2017 Section 7.2 as equivalent to "C" */ @@ -471,13 +446,13 @@ const os_setlocale = function(L) { }; const syslib = { - "date": os_date, - "difftime": os_difftime, - "setlocale": os_setlocale, - "time": os_time + 'date': os_date, + 'difftime': os_difftime, + 'setlocale': os_setlocale, + 'time': os_time }; -if (typeof process === "undefined") { +if (typeof process === 'undefined') { syslib.clock = function(L) { lua_pushnumber(L, performance.now()/1000); return 1; @@ -552,7 +527,7 @@ if (typeof process === "undefined") { syslib.tmpname = function(L) { let name = lua_tmpname(); if (!name) - return luaL_error(L, to_luastring("unable to generate a unique filename")); + return luaL_error(L, to_luastring('unable to generate a unique filename')); lua_pushstring(L, to_luastring(name)); return 1; }; diff --git a/src/lparser.js b/src/lparser.js index 7c67709c..4951e470 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1,12 +1,46 @@ -"use strict"; - -const { - LUA_MULTRET, - to_luastring -} = require('./defs.js'); -const { - BinOpr: { - OPR_ADD, +import {LUA_MULTRET, to_luastring} from "./defs.js"; +import * as ltable from "./ltable.js"; +import {luaS_eqlngstr, luaS_new, luaS_newliteral} from "./lstring.js"; +import { + LFIELDS_PER_FLUSH, + OP_CALL, + OP_CLOSURE, + OP_FORLOOP, + OP_FORPREP, + OP_GETUPVAL, + OP_MOVE, + OP_NEWTABLE, + OP_SETTABLE, OP_TAILCALL, OP_TFORCALL, OP_TFORLOOP, OP_VARARG, SET_OPCODE, SETARG_B, SETARG_C +} from "./lopcodes.js"; +import * as lobject from "./lobject.js"; +import {lua_assert, LUAI_MAXCCALLS, MAX_INT} from "./llimits.js"; +import * as llex from "./llex.js"; +import * as lfunc from "./lfunc.js"; +import * as ldo from "./ldo.js"; +import { + getinstruction, luaK_checkstack, luaK_codeABC, luaK_codeABx, luaK_codeAsBx, luaK_codek, luaK_concat, + luaK_dischargevars, luaK_exp2anyreg, luaK_exp2anyregup, luaK_exp2nextreg, luaK_exp2RK, luaK_exp2val, luaK_fixline, + luaK_getlabel, luaK_goiffalse, luaK_goiftrue, luaK_indexed, luaK_infix, luaK_intK, luaK_jump, luaK_jumpto, luaK_nil, + luaK_patchclose, luaK_patchlist, luaK_patchtohere, luaK_posfix, luaK_prefix, luaK_reserveregs, luaK_ret, luaK_self, + luaK_setlist, luaK_setmultret, luaK_setoneret, luaK_setreturns, luaK_storevar, luaK_stringK, + NO_JUMP, + OPR_ADD, + OPR_AND, + OPR_BAND, OPR_BNOT, + OPR_BOR, + OPR_BXOR, + OPR_CONCAT, + OPR_DIV, + OPR_EQ, + OPR_GE, + OPR_GT, + OPR_IDIV, OPR_LE, + OPR_LEN, OPR_LT, OPR_MINUS, OPR_MOD, OPR_MUL, OPR_NE, OPR_NOBINOPR, + OPR_NOT, OPR_NOUNOPR, OPR_OR, OPR_POW, OPR_SHL, OPR_SHR, OPR_SUB +} from "./lcode.js"; + +const BinOpr = { + OPR_ADD, OPR_AND, OPR_BAND, OPR_BOR, @@ -28,65 +62,18 @@ const { OPR_SHL, OPR_SHR, OPR_SUB - }, - UnOpr: { - OPR_BNOT, - OPR_LEN, - OPR_MINUS, - OPR_NOT, - OPR_NOUNOPR - }, - NO_JUMP, - getinstruction, - luaK_checkstack, - luaK_codeABC, - luaK_codeABx, - luaK_codeAsBx, - luaK_codek, - luaK_concat, - luaK_dischargevars, - luaK_exp2RK, - luaK_exp2anyreg, - luaK_exp2anyregup, - luaK_exp2nextreg, - luaK_exp2val, - luaK_fixline, - luaK_getlabel, - luaK_goiffalse, - luaK_goiftrue, - luaK_indexed, - luaK_infix, - luaK_intK, - luaK_jump, - luaK_jumpto, - luaK_nil, - luaK_patchclose, - luaK_patchlist, - luaK_patchtohere, - luaK_posfix, - luaK_prefix, - luaK_reserveregs, - luaK_ret, - luaK_self, - luaK_setlist, - luaK_setmultret, - luaK_setoneret, - luaK_setreturns, - luaK_storevar, - luaK_stringK -} = require('./lcode.js'); -const ldo = require('./ldo.js'); -const lfunc = require('./lfunc.js'); -const llex = require('./llex.js'); -const { - LUAI_MAXCCALLS, - MAX_INT, - lua_assert -} = require('./llimits.js'); -const lobject = require('./lobject.js'); -const { - OpCodesI: { - OP_CALL, +} + +const UnOpr = { + OPR_BNOT, + OPR_LEN, + OPR_MINUS, + OPR_NOT, + OPR_NOUNOPR +}; + +const OpCodesI = { + OP_CALL, OP_CLOSURE, OP_FORLOOP, OP_FORPREP, @@ -98,18 +85,8 @@ const { OP_TFORCALL, OP_TFORLOOP, OP_VARARG - }, - LFIELDS_PER_FLUSH, - SETARG_B, - SETARG_C, - SET_OPCODE -} = require('./lopcodes.js'); -const { - luaS_eqlngstr, - luaS_new, - luaS_newliteral -} = require('./lstring.js'); -const ltable = require('./ltable.js'); +}; + const Proto = lfunc.Proto; const R = llex.RESERVED; @@ -259,16 +236,16 @@ const semerror = function(ls, msg) { }; const error_expected = function(ls, token) { - llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, to_luastring("%s expected", true), llex.luaX_token2str(ls, token))); + llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, to_luastring('%s expected', true), llex.luaX_token2str(ls, token))); }; const errorlimit = function(fs, limit, what) { let L = fs.ls.L; let line = fs.f.linedefined; let where = (line === 0) - ? to_luastring("main function", true) - : lobject.luaO_pushfstring(L, to_luastring("function at line %d", true), line); - let msg = lobject.luaO_pushfstring(L, to_luastring("too many %s (limit is %d) in %s", true), + ? to_luastring('main function', true) + : lobject.luaO_pushfstring(L, to_luastring('function at line %d', true), line); + let msg = lobject.luaO_pushfstring(L, to_luastring('too many %s (limit is %d) in %s', true), what, limit, where); llex.luaX_syntaxerror(fs.ls, msg); }; @@ -307,7 +284,7 @@ const check_match = function(ls, what, who, where) { error_expected(ls, what); else llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, - to_luastring("%s expected (to close %s at line %d)"), + to_luastring('%s expected (to close %s at line %d)'), llex.luaX_token2str(ls, what), llex.luaX_token2str(ls, who), where)); } }; @@ -345,7 +322,7 @@ const new_localvar = function(ls, name) { let fs = ls.fs; let dyd = ls.dyd; let reg = registerlocalvar(ls, name); - checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring("local variables", true)); + checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring('local variables', true)); dyd.actvar.arr[dyd.actvar.n] = new Vardesc(); dyd.actvar.arr[dyd.actvar.n].idx = reg; dyd.actvar.n++; @@ -385,7 +362,7 @@ const searchupvalue = function(fs, name) { const newupvalue = function(fs, name, v) { let f = fs.f; - checklimit(fs, fs.nups + 1, lfunc.MAXUPVAL, to_luastring("upvalues", true)); + checklimit(fs, fs.nups + 1, lfunc.MAXUPVAL, to_luastring('upvalues', true)); f.upvalues[fs.nups] = { instack: v.k === expkind.VLOCAL, idx: v.u.info, @@ -477,7 +454,7 @@ const adjust_assign = function(ls, nvars, nexps, e) { const enterlevel = function(ls) { let L = ls.L; ++L.nCcalls; - checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true)); + checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); }; const leavelevel = function(ls) { @@ -492,7 +469,7 @@ const closegoto = function(ls, g, label) { if (gt.nactvar < label.nactvar) { let vname = getlocvar(fs, gt.nactvar).varname; let msg = lobject.luaO_pushfstring(ls.L, - to_luastring(" at line %d jumps into the scope of local '%s'"), + to_luastring(' at line %d jumps into the scope of local \'%s\''), gt.name.getstr(), gt.line, vname.getstr()); semerror(ls, msg); } @@ -587,7 +564,7 @@ const enterblock = function(fs, bl, isloop) { ** create a label named 'break' to resolve break statements */ const breaklabel = function(ls) { - let n = luaS_newliteral(ls.L, "break"); + let n = luaS_newliteral(ls.L, 'break'); let l = newlabelentry(ls, ls.dyd.label, n, 0, ls.fs.pc); findgotos(ls, ls.dyd.label.arr[l]); }; @@ -598,8 +575,8 @@ const breaklabel = function(ls) { */ const undefgoto = function(ls, gt) { let msg = llex.isreserved(gt.name) - ? "<%s> at line %d not inside a loop" - : "no visible label '%s' for at line %d"; + ? '<%s> at line %d not inside a loop' + : 'no visible label \'%s\' for at line %d'; msg = lobject.luaO_pushfstring(ls.L, to_luastring(msg), gt.name.getstr(), gt.line); semerror(ls, msg); }; @@ -745,7 +722,7 @@ const recfield = function(ls, cc) { let val = new expdesc(); if (ls.t.token === R.TK_NAME) { - checklimit(fs, cc.nh, MAX_INT, to_luastring("items in a constructor", true)); + checklimit(fs, cc.nh, MAX_INT, to_luastring('items in a constructor', true)); checkname(ls, key); } else /* ls->t.token === '[' */ yindex(ls, key); @@ -783,7 +760,7 @@ const lastlistfield = function(fs, cc) { const listfield = function(ls, cc) { /* listfield -> exp */ expr(ls, cc.v); - checklimit(ls.fs, cc.na, MAX_INT, to_luastring("items in a constructor", true)); + checklimit(ls.fs, cc.na, MAX_INT, to_luastring('items in a constructor', true)); cc.na++; cc.tostore++; }; @@ -855,7 +832,7 @@ const parlist = function(ls) { f.is_vararg = true; /* declared vararg */ break; } - default: llex.luaX_syntaxerror(ls, to_luastring(" or '...' expected", true)); + default: llex.luaX_syntaxerror(ls, to_luastring(' or \'...\' expected', true)); } } while(!f.is_vararg && testnext(ls, 44 /* (',').charCodeAt(0) */)); } @@ -873,7 +850,7 @@ const body = function(ls, e, ismethod, line) { open_func(ls, new_fs, bl); checknext(ls, 40 /* ('(').charCodeAt(0) */); if (ismethod) { - new_localvarliteral(ls, "self"); /* create 'self' parameter */ + new_localvarliteral(ls, 'self'); /* create 'self' parameter */ adjustlocalvars(ls, 1); } parlist(ls); @@ -922,7 +899,7 @@ const funcargs = function(ls, f, line) { break; } default: { - llex.luaX_syntaxerror(ls, to_luastring("function arguments expected", true)); + llex.luaX_syntaxerror(ls, to_luastring('function arguments expected', true)); } } lua_assert(f.k === expkind.VNONRELOC); @@ -962,7 +939,7 @@ const primaryexp = function(ls, v) { return; } default: { - llex.luaX_syntaxerror(ls, to_luastring("unexpected symbol", true)); + llex.luaX_syntaxerror(ls, to_luastring('unexpected symbol', true)); } } }; @@ -1036,7 +1013,7 @@ const simpleexp = function(ls, v) { } case R.TK_DOTS: { /* vararg */ let fs = ls.fs; - check_condition(ls, fs.f.is_vararg, to_luastring("cannot use '...' outside a vararg function", true)); + check_condition(ls, fs.f.is_vararg, to_luastring('cannot use \'...\' outside a vararg function', true)); init_exp(v, expkind.VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } @@ -1208,14 +1185,14 @@ const check_conflict = function(ls, lh, v) { const assignment = function(ls, lh, nvars) { let e = new expdesc(); - check_condition(ls, vkisvar(lh.v.k), to_luastring("syntax error", true)); + check_condition(ls, vkisvar(lh.v.k), to_luastring('syntax error', true)); if (testnext(ls, 44 /* (',').charCodeAt(0) */)) { /* assignment -> ',' suffixedexp assignment */ let nv = new LHS_assign(); nv.prev = lh; suffixedexp(ls, nv.v); if (nv.v.k !== expkind.VINDEXED) check_conflict(ls, lh, nv.v); - checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true)); + checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); assignment(ls, nv, nvars + 1); } else { /* assignment -> '=' explist */ checknext(ls, 61 /* ('=').charCodeAt(0) */); @@ -1248,7 +1225,7 @@ const gotostat = function(ls, pc) { label = str_checkname(ls); else { llex.luaX_next(ls); /* skip break */ - label = luaS_newliteral(ls.L, "break"); + label = luaS_newliteral(ls.L, 'break'); } let g = newlabelentry(ls, ls.dyd.gt, label, line, pc); findlabel(ls, g); /* close it if label already defined */ @@ -1259,7 +1236,7 @@ const checkrepeated = function(fs, ll, label) { for (let i = fs.bl.firstlabel; i < ll.n; i++) { if (eqstr(label, ll.arr[i].name)) { let msg = lobject.luaO_pushfstring(fs.ls.L, - to_luastring("label '%s' already defined on line %d", true), + to_luastring('label \'%s\' already defined on line %d', true), label.getstr(), ll.arr[i].line); semerror(fs.ls, msg); } @@ -1362,9 +1339,9 @@ const fornum = function(ls, varname, line) { /* fornum -> NAME = exp1,exp1[,exp1] forbody */ let fs = ls.fs; let base = fs.freereg; - new_localvarliteral(ls, "(for index)"); - new_localvarliteral(ls, "(for limit)"); - new_localvarliteral(ls, "(for step)"); + new_localvarliteral(ls, '(for index)'); + new_localvarliteral(ls, '(for limit)'); + new_localvarliteral(ls, '(for step)'); new_localvar(ls, varname); checknext(ls, 61 /* ('=').charCodeAt(0) */); exp1(ls); /* initial value */ @@ -1386,9 +1363,9 @@ const forlist = function(ls, indexname) { let nvars = 4; /* gen, state, control, plus at least one declared var */ let base = fs.freereg; /* create control variables */ - new_localvarliteral(ls, "(for generator)"); - new_localvarliteral(ls, "(for state)"); - new_localvarliteral(ls, "(for control)"); + new_localvarliteral(ls, '(for generator)'); + new_localvarliteral(ls, '(for state)'); + new_localvarliteral(ls, '(for control)'); /* create declared variables */ new_localvar(ls, indexname); while (testnext(ls, 44 /* (',').charCodeAt(0) */)) { @@ -1412,7 +1389,7 @@ const forstat = function(ls, line) { switch (ls.t.token) { case 61 /* ('=').charCodeAt(0) */: fornum(ls, varname, line); break; case 44 /* (',').charCodeAt(0) */: case R.TK_IN: forlist(ls, varname); break; - default: llex.luaX_syntaxerror(ls, to_luastring("'=' or 'in' expected", true)); + default: llex.luaX_syntaxerror(ls, to_luastring('\'=\' or \'in\' expected', true)); } check_match(ls, R.TK_END, R.TK_FOR, line); leaveblock(fs); /* loop scope ('break' jumps to this point) */ @@ -1530,7 +1507,7 @@ const exprstat= function(ls) { assignment(ls, v, 1); } else { /* stat -> func */ - check_condition(ls, v.v.k === expkind.VCALL, to_luastring("syntax error", true)); + check_condition(ls, v.v.k === expkind.VCALL, to_luastring('syntax error', true)); SETARG_C(getinstruction(fs, v.v), 1); /* call statement uses no results */ } }; @@ -1672,10 +1649,3 @@ const luaY_parser = function(L, z, buff, dyd, name, firstchar) { delete L.stack[--L.top]; /* remove scanner's table */ return cl; /* closure is on the stack, too */ }; - - -module.exports.Dyndata = Dyndata; -module.exports.expkind = expkind; -module.exports.expdesc = expdesc; -module.exports.luaY_parser = luaY_parser; -module.exports.vkisinreg = vkisinreg; diff --git a/src/lstate.js b/src/lstate.js index 6e623b9b..79295d01 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -1,26 +1,32 @@ -"use strict"; - -const { +import { LUA_MINSTACK, + constant_types, + thread_status, + LUA_NUMTAGS, LUA_OK, LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD, - constant_types: { - LUA_NUMTAGS, - LUA_TNIL, - LUA_TTABLE, - LUA_TTHREAD - }, - thread_status: { - LUA_OK - } -} = require('./defs.js'); -const lobject = require('./lobject.js'); -const ldo = require('./ldo.js'); -const lapi = require('./lapi.js'); -const ltable = require('./ltable.js'); -const ltm = require('./ltm.js'); + LUA_TNIL, + LUA_TTABLE, + LUA_TTHREAD +} from "./defs.js"; + +import * as lobject from "./lobject.js"; +import * as ldo from "./ldo.js"; +import * as lapi from "./lapi.js"; +import * as ltable from "./ltable.js"; +import * as ltm from "./ltm.js"; -const EXTRA_STACK = 5; +const { + LUA_NUMTAGS, + LUA_TNIL, + LUA_TTABLE, + LUA_TTHREAD +} = constant_types; +const { + LUA_OK +} =thread_status; + +export const EXTRA_STACK = 5; const BASIC_STACK_SIZE = 2 * LUA_MINSTACK; @@ -48,7 +54,7 @@ class CallInfo { } -class lua_State { +export class lua_State { constructor(g) { this.id = g.id_counter++; @@ -93,7 +99,7 @@ class global_State { } -const luaE_extendCI = function(L) { +const luaE_extendCI = function (L) { let ci = new CallInfo(); L.ci.next = ci; ci.previous = L.ci; @@ -102,12 +108,12 @@ const luaE_extendCI = function(L) { return ci; }; -const luaE_freeCI = function(L) { +const luaE_freeCI = function (L) { let ci = L.ci; ci.next = null; }; -const stack_init = function(L1, L) { +const stack_init = function (L1, L) { L1.stack = new Array(BASIC_STACK_SIZE); L1.top = 0; L1.stack_last = BASIC_STACK_SIZE - EXTRA_STACK; @@ -122,7 +128,7 @@ const stack_init = function(L1, L) { L1.ci = ci; }; -const freestack = function(L) { +const freestack = function (L) { L.ci = L.base_ci; luaE_freeCI(L); L.stack = null; @@ -131,7 +137,7 @@ const freestack = function(L) { /* ** Create registry table and its predefined values */ -const init_registry = function(L, g) { +const init_registry = function (L, g) { let registry = ltable.luaH_new(L); g.l_registry.sethvalue(registry); ltable.luaH_setint(registry, LUA_RIDX_MAINTHREAD, new lobject.TValue(LUA_TTHREAD, L)); @@ -142,7 +148,7 @@ const init_registry = function(L, g) { ** open parts of the state that may cause memory-allocation errors. ** ('g->version' !== NULL flags that the state was completely build) */ -const f_luaopen = function(L) { +const f_luaopen = function (L) { let g = L.l_G; stack_init(L, L); init_registry(L, g); @@ -150,7 +156,7 @@ const f_luaopen = function(L) { g.version = lapi.lua_version(null); }; -const lua_newthread = function(L) { +const lua_newthread = function (L) { let g = L.l_G; let L1 = new lua_State(g); L.stack[L.top] = new lobject.TValue(LUA_TTHREAD, L1); @@ -163,11 +169,11 @@ const lua_newthread = function(L) { return L1; }; -const luaE_freethread = function(L, L1) { +const luaE_freethread = function (L, L1) { freestack(L1); }; -const lua_newstate = function() { +const lua_newstate = function () { let g = new global_State(); let L = new lua_State(g); g.mainthread = L; @@ -179,30 +185,11 @@ const lua_newstate = function() { return L; }; -const close_state = function(L) { +const close_state = function (L) { freestack(L); }; -const lua_close = function(L) { +const lua_close = function (L) { L = L.l_G.mainthread; /* only the main thread can be closed */ close_state(L); }; - -module.exports.lua_State = lua_State; -module.exports.CallInfo = CallInfo; -module.exports.CIST_OAH = (1<<0); /* original value of 'allowhook' */ -module.exports.CIST_LUA = (1<<1); /* call is running a Lua function */ -module.exports.CIST_HOOKED = (1<<2); /* call is running a debug hook */ -module.exports.CIST_FRESH = (1<<3); /* call is running on a fresh invocation of luaV_execute */ -module.exports.CIST_YPCALL = (1<<4); /* call is a yieldable protected call */ -module.exports.CIST_TAIL = (1<<5); /* call was tail called */ -module.exports.CIST_HOOKYIELD = (1<<6); /* last hook called yielded */ -module.exports.CIST_LEQ = (1<<7); /* using __lt for __le */ -module.exports.CIST_FIN = (1<<8); /* call is running a finalizer */ -module.exports.EXTRA_STACK = EXTRA_STACK; -module.exports.lua_close = lua_close; -module.exports.lua_newstate = lua_newstate; -module.exports.lua_newthread = lua_newthread; -module.exports.luaE_extendCI = luaE_extendCI; -module.exports.luaE_freeCI = luaE_freeCI; -module.exports.luaE_freethread = luaE_freethread; diff --git a/src/lstring.js b/src/lstring.js index 4769866c..bddc6f3d 100644 --- a/src/lstring.js +++ b/src/lstring.js @@ -1,12 +1,5 @@ -"use strict"; - -const { - is_luastring, - luastring_eq, - luastring_from, - to_luastring -} = require('./defs.js'); -const { lua_assert } = require("./llimits.js"); +import {is_luastring, luastring_eq, luastring_from, to_luastring} from "./defs.js"; +import {lua_assert} from "./llimits.js"; class TString { @@ -25,7 +18,7 @@ class TString { } -const luaS_eqlngstr = function(a, b) { +export const luaS_eqlngstr = function(a, b) { lua_assert(a instanceof TString); lua_assert(b instanceof TString); return a == b || luastring_eq(a.realstring, b.realstring); @@ -36,13 +29,13 @@ const luaS_eqlngstr = function(a, b) { const luaS_hash = function(str) { lua_assert(is_luastring(str)); let len = str.length; - let s = "|"; + let s = '|'; for (let i=0; i l) end = l; if (start <= end) lua_pushstring(L, s.subarray(start - 1, (start - 1) + (end - start + 1))); - else lua_pushliteral(L, ""); + else lua_pushliteral(L, ''); return 1; }; @@ -131,7 +84,7 @@ const str_char = function(L) { let p = luaL_buffinitsize(L, b, n); for (let i = 1; i <= n; i++) { let c = luaL_checkinteger(L, i); - luaL_argcheck(L, c >= 0 && c <= 255, "value out of range"); // Strings are 8-bit clean + luaL_argcheck(L, c >= 0 && c <= 255, 'value out of range'); // Strings are 8-bit clean p[i-1] = c; } luaL_pushresultsize(b, n); @@ -150,7 +103,7 @@ const str_dump = function(L) { lua_settop(L, 1); luaL_buffinit(L, b); if (lua_dump(L, writer, b, strip) !== 0) - return luaL_error(L, to_luastring("unable to dump given function")); + return luaL_error(L, to_luastring('unable to dump given function')); luaL_pushresult(b); return 1; }; @@ -169,12 +122,12 @@ const num2straux = function(x) { return to_luastring('nan'); else if (x === 0) { /* can be -0... */ /* create "0" or "-0" followed by exponent */ - let zero = sprintf(LUA_NUMBER_FMT + "x0p+0", x); + let zero = sprintf(LUA_NUMBER_FMT + 'x0p+0', x); if (Object.is(x, -0)) - zero = "-" + zero; + zero = '-' + zero; return to_luastring(zero); } else { - let buff = ""; + let buff = ''; let fe = frexp(x); /* 'x' fraction and exponent */ let m = fe[0]; let e = fe[1]; @@ -182,10 +135,10 @@ const num2straux = function(x) { buff += '-'; /* add signal */ m = -m; /* make it positive */ } - buff += "0x"; /* add "0x" */ + buff += '0x'; /* add "0x" */ buff += (m * (1<= 0) p++; /* skip flags */ if (p - i >= FLAGS.length) - luaL_error(L, to_luastring("invalid format (repeated flags)")); + luaL_error(L, to_luastring('invalid format (repeated flags)')); if (isdigit(strfrmt[p])) p++; /* skip width */ if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ if (strfrmt[p] === 46 /* '.'.charCodeAt(0) */) { @@ -311,7 +264,7 @@ const scanformat = function(L, strfrmt, i, form) { if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ } if (isdigit(strfrmt[p])) - luaL_error(L, to_luastring("invalid format (width or precision too long)")); + luaL_error(L, to_luastring('invalid format (width or precision too long)')); form[0] = 37 /* "%".charCodeAt(0) */; for (let j = 0; j < p - i + 1; j++) form[j+1] = strfrmt[i+j]; @@ -346,7 +299,7 @@ const str_format = function(L) { } else { /* format item */ let form = []; /* to store the format ('%...') */ if (++arg > top) - luaL_argerror(L, arg, to_luastring("no value")); + luaL_argerror(L, arg, to_luastring('no value')); i = scanformat(L, strfrmt, i, form); switch (String.fromCharCode(strfrmt[i++])) { case 'c': { @@ -382,7 +335,7 @@ const str_format = function(L) { if (form.length <= 2 || form[2] === 0) { /* no modifiers? */ luaL_addvalue(b); /* keep entire string */ } else { - luaL_argcheck(L, s.length === strlen(s), arg, "string contains zeros"); + luaL_argcheck(L, s.length === strlen(s), arg, 'string contains zeros'); if (luastring_indexOf(form, 46 /* '.'.charCodeAt(0) */) < 0 && s.length >= 100) { /* no precision and string is too long to be formatted */ luaL_addvalue(b); /* keep entire string */ @@ -395,7 +348,7 @@ const str_format = function(L) { break; } default: { /* also treat cases 'pnLlh' */ - return luaL_error(L, to_luastring("invalid option '%%%c' to 'format'"), strfrmt[i-1]); + return luaL_error(L, to_luastring('invalid option \'%%%c\' to \'format\''), strfrmt[i-1]); } } } @@ -465,7 +418,7 @@ const getnum = function(fmt, df) { const getnumlimit = function(h, fmt, df) { let sz = getnum(fmt, df); if (sz > MAXINTSIZE || sz <= 0) - luaL_error(h.L, to_luastring("integral size (%d) out of limits [1,%d]"), sz, MAXINTSIZE); + luaL_error(h.L, to_luastring('integral size (%d) out of limits [1,%d]'), sz, MAXINTSIZE); return sz; }; @@ -496,7 +449,7 @@ const getoption = function(h, fmt) { case 99 /*'c'*/: { r.size = getnum(fmt, -1); if (r.size === -1) - luaL_error(h.L, to_luastring("missing size for format option 'c'")); + luaL_error(h.L, to_luastring('missing size for format option \'c\'')); r.opt = Kchar; return r; } @@ -508,7 +461,7 @@ const getoption = function(h, fmt) { case 62 /*'>'*/: h.islittle = false; break; case 61 /*'='*/: h.islittle = true; break; case 33 /*'!'*/: h.maxalign = getnumlimit(h, fmt, MAXALIGN); break; - default: luaL_error(h.L, to_luastring("invalid format option '%c'"), r.opt); + default: luaL_error(h.L, to_luastring('invalid format option \'%c\''), r.opt); } r.opt = Knop; return r; @@ -536,13 +489,13 @@ const getdetails = function(h, totalsize, fmt) { let align = r.size; /* usually, alignment follows size */ if (r.opt === Kpaddalign) { /* 'X' gets alignment from following option */ if (fmt.off >= fmt.s.length || fmt.s[fmt.off] === 0) - luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'")); + luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); else { let o = getoption(h, fmt); align = o.size; o = o.opt; if (o === Kchar || align === 0) - luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'")); + luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); } } if (align <= 1 || r.opt === Kchar) /* need no alignment? */ @@ -551,7 +504,7 @@ const getdetails = function(h, totalsize, fmt) { if (align > h.maxalign) /* enforce maximum alignment */ align = h.maxalign; if ((align & (align -1)) !== 0) /* is 'align' not a power of 2? */ - luaL_argerror(h.L, 1, to_luastring("format asks for alignment not power of 2")); + luaL_argerror(h.L, 1, to_luastring('format asks for alignment not power of 2')); r.ntoalign = (align - (totalsize & (align - 1))) & (align - 1); } return r; @@ -602,7 +555,7 @@ const str_pack = function(L) { let n = luaL_checkinteger(L, arg); if (size < SZINT) { /* need overflow check? */ let lim = 1 << (size * 8) - 1; - luaL_argcheck(L, -lim <= n && n < lim, arg, "integer overflow"); + luaL_argcheck(L, -lim <= n && n < lim, arg, 'integer overflow'); } packint(b, n, h.islittle, size, n < 0); break; @@ -610,7 +563,7 @@ const str_pack = function(L) { case Kuint: { /* unsigned integers */ let n = luaL_checkinteger(L, arg); if (size < SZINT) - luaL_argcheck(L, (n>>>0) < (1 << (size * NB)), arg, "unsigned overflow"); + luaL_argcheck(L, (n>>>0) < (1 << (size * NB)), arg, 'unsigned overflow'); packint(b, n>>>0, h.islittle, size, false); break; } @@ -626,7 +579,7 @@ const str_pack = function(L) { case Kchar: { /* fixed-size string */ let s = luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, len <= size, arg, "string longer than given size"); + luaL_argcheck(L, len <= size, arg, 'string longer than given size'); luaL_addlstring(b, s, len); /* add string */ while (len++ < size) /* pad extra space */ luaL_addchar(b, LUAL_PACKPADBYTE); @@ -637,7 +590,7 @@ const str_pack = function(L) { let len = s.length; luaL_argcheck(L, size >= 4 /* sizeof(size_t) */ || len < (1 << (size * NB)), - arg, "string length does not fit in given size"); + arg, 'string length does not fit in given size'); packint(b, len, h.islittle, size, 0); /* pack length */ luaL_addlstring(b, s, len); totalsize += len; @@ -646,7 +599,7 @@ const str_pack = function(L) { case Kzstr: { /* zero-terminated string */ let s = luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, "strings contains zeros"); + luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, 'strings contains zeros'); luaL_addlstring(b, s, len); luaL_addchar(b, 0); /* add zero at the end */ totalsize += len + 1; @@ -704,11 +657,11 @@ const str_rep = function(L) { let s = luaL_checkstring(L, 1); let l = s.length; let n = luaL_checkinteger(L, 2); - let sep = luaL_optstring(L, 3, ""); + let sep = luaL_optstring(L, 3, ''); let lsep = sep.length; - if (n <= 0) lua_pushliteral(L, ""); + if (n <= 0) lua_pushliteral(L, ''); else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */ - return luaL_error(L, to_luastring("resulting string too large")); + return luaL_error(L, to_luastring('resulting string too large')); else { let totallen = n * l + (n - 1) * lsep; let b = new luaL_Buffer(); @@ -738,10 +691,10 @@ const str_byte = function(L) { if (pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) /* arithmetic overflow? */ - return luaL_error(L, "string slice too long"); + return luaL_error(L, 'string slice too long'); let n = (pose - posi) + 1; - luaL_checkstack(L, n, "string slice too long"); + luaL_checkstack(L, n, 'string slice too long'); for (let i = 0; i < n; i++) lua_pushinteger(L, s[posi + i - 1]); return n; @@ -760,12 +713,12 @@ const str_packsize = function(L) { let size = details.size; let ntoalign = details.ntoalign; size += ntoalign; /* total space used by option */ - luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, "format result too large"); + luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, 'format result too large'); totalsize += size; switch (opt) { case Kstring: /* strings with length count */ case Kzstr: /* zero-terminated string */ - luaL_argerror(L, 1, "variable-length format"); + luaL_argerror(L, 1, 'variable-length format'); /* call never return, but to avoid warnings: *//* fall through */ default: break; } @@ -798,7 +751,7 @@ const unpackint = function(L, str, islittle, size, issigned) { let mask = !issigned || res >= 0 ? 0 : MC; for (let i = limit; i < size; i++) { if (str[islittle ? i : size - 1 - i] !== mask) - luaL_error(L, to_luastring("%d-byte integer does not fit into Lua Integer"), size); + luaL_error(L, to_luastring('%d-byte integer does not fit into Lua Integer'), size); } } return res; @@ -825,17 +778,17 @@ const str_unpack = function(L) { let ld = data.length; let pos = posrelat(luaL_optinteger(L, 3, 1), ld) - 1; let n = 0; /* number of results */ - luaL_argcheck(L, pos <= ld && pos >= 0, 3, "initial position out of string"); + luaL_argcheck(L, pos <= ld && pos >= 0, 3, 'initial position out of string'); while (fmt.off < fmt.s.length) { let details = getdetails(h, pos, fmt); let opt = details.opt; let size = details.size; let ntoalign = details.ntoalign; if (/*ntoalign + size > ~pos ||*/ pos + ntoalign + size > ld) - luaL_argerror(L, 2, to_luastring("data string too short")); + luaL_argerror(L, 2, to_luastring('data string too short')); pos += ntoalign; /* skip alignment */ /* stack space for item + next position */ - luaL_checkstack(L, 2, "too many results"); + luaL_checkstack(L, 2, 'too many results'); n++; switch (opt) { case Kint: @@ -855,7 +808,7 @@ const str_unpack = function(L) { } case Kstring: { let len = unpackint(L, data.subarray(pos), h.islittle, size, 0); - luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short"); + luaL_argcheck(L, pos + len + size <= ld, 2, 'data string too short'); lua_pushstring(L, data.subarray(pos + size, pos + size + len)); pos += len; /* skip string */ break; @@ -880,7 +833,7 @@ const str_unpack = function(L) { const CAP_UNFINISHED = -1; const CAP_POSITION = -2; const MAXCCALLS = 200; -const SPECIALS = to_luastring("^$*+?.([%-"); +const SPECIALS = to_luastring('^$*+?.([%-'); class MatchState { constructor(L) { @@ -899,7 +852,7 @@ class MatchState { const check_capture = function(ms, l) { l = l - 49 /* '1'.charCodeAt(0) */; if (l < 0 || l >= ms.level || ms.capture[l].len === CAP_UNFINISHED) - return luaL_error(ms.L, to_luastring("invalid capture index %%%d"), l + 1); + return luaL_error(ms.L, to_luastring('invalid capture index %%%d'), l + 1); return l; }; @@ -907,21 +860,21 @@ const capture_to_close = function(ms) { let level = ms.level; for (level--; level >= 0; level--) if (ms.capture[level].len === CAP_UNFINISHED) return level; - return luaL_error(ms.L, to_luastring("invalid pattern capture")); + return luaL_error(ms.L, to_luastring('invalid pattern capture')); }; const classend = function(ms, p) { switch(ms.p[p++]) { case L_ESC: { if (p === ms.p_end) - luaL_error(ms.L, to_luastring("malformed pattern (ends with '%%')")); + luaL_error(ms.L, to_luastring('malformed pattern (ends with \'%%\')')); return p + 1; } case 91 /* '['.charCodeAt(0) */: { if (ms.p[p] === 94 /* '^'.charCodeAt(0) */) p++; do { /* look for a ']' */ if (p === ms.p_end) - luaL_error(ms.L, to_luastring("malformed pattern (missing ']')")); + luaL_error(ms.L, to_luastring('malformed pattern (missing \']\')')); if (ms.p[p++] === L_ESC && p < ms.p_end) p++; /* skip escapes (e.g. '%]') */ } while (ms.p[p] !== 93 /* ']'.charCodeAt(0) */); @@ -997,7 +950,7 @@ const singlematch = function(ms, s, p, ep) { const matchbalance = function(ms, s, p) { if (p >= ms.p_end - 1) - luaL_error(ms.L, to_luastring("malformed pattern (missing arguments to '%%b'")); + luaL_error(ms.L, to_luastring('malformed pattern (missing arguments to \'%%b\'')); if (ms.src[s] !== ms.p[p]) return null; else { @@ -1040,7 +993,7 @@ const min_expand = function(ms, s, p, ep) { const start_capture = function(ms, s, p, what) { let level = ms.level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring("too many captures")); + if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring('too many captures')); ms.capture[level] = ms.capture[level] ? ms.capture[level] : {}; ms.capture[level].init = s; ms.capture[level].len = what; @@ -1078,7 +1031,7 @@ const match = function(ms, s, p) { let gotoinit = true; if (ms.matchdepth-- === 0) - luaL_error(ms.L, to_luastring("pattern too complex")); + luaL_error(ms.L, to_luastring('pattern too complex')); while (gotoinit || gotodefault) { gotoinit = false; @@ -1116,7 +1069,7 @@ const match = function(ms, s, p) { case 102 /* 'f'.charCodeAt(0) */: { /* frontier? */ p += 2; if (ms.p[p] !== 91 /* '['.charCodeAt(0) */) - luaL_error(ms.L, to_luastring("missing '[' after '%%f' in pattern")); + luaL_error(ms.L, to_luastring('missing \'[\' after \'%%f\' in pattern')); let ep = classend(ms, p); /* points to what is next */ let previous = s === ms.src_init ? 0 : ms.src[s-1]; if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, (s===ms.src_end)?0:ms.src[s], p, ep - 1)) { @@ -1187,10 +1140,10 @@ const push_onecapture = function(ms, i, s, e) { if (i === 0) lua_pushlstring(ms.L, ms.src.subarray(s, e), e - s); /* add whole match */ else - luaL_error(ms.L, to_luastring("invalid capture index %%%d"), i + 1); + luaL_error(ms.L, to_luastring('invalid capture index %%%d'), i + 1); } else { let l = ms.capture[i].len; - if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring("unfinished capture")); + if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring('unfinished capture')); if (l === CAP_POSITION) lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1); else @@ -1200,7 +1153,7 @@ const push_onecapture = function(ms, i, s, e) { const push_captures = function(ms, s, e) { let nlevels = (ms.level === 0 && s != null) ? 1 : ms.level; - luaL_checkstack(ms.L, nlevels, "too many captures"); + luaL_checkstack(ms.L, nlevels, 'too many captures'); for (let i = 0; i < nlevels; i++) push_onecapture(ms, i, s, e); return nlevels; /* number of strings pushed */ @@ -1348,7 +1301,7 @@ const add_s = function(ms, b, s, e) { i++; /* skip ESC */ if (!isdigit(news[i])) { if (news[i] !== L_ESC) - luaL_error(L, to_luastring("invalid use of '%c' in replacement string"), L_ESC); + luaL_error(L, to_luastring('invalid use of \'%c\' in replacement string'), L_ESC); luaL_addchar(b, news[i]); } else if (news[i] === 48 /* '0'.charCodeAt(0) */) luaL_addlstring(b, ms.src.subarray(s, e), e - s); @@ -1385,7 +1338,7 @@ const add_value = function(ms, b, s, e, tr) { lua_pop(L, 1); lua_pushlstring(L, ms.src.subarray(s, e), e - s); /* keep original text */ } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("invalid replacement value (a %s)"), luaL_typename(L, -1)); + luaL_error(L, to_luastring('invalid replacement value (a %s)'), luaL_typename(L, -1)); luaL_addvalue(b); /* add result to accumulator */ }; @@ -1402,7 +1355,7 @@ const str_gsub = function(L) { let ms = new MatchState(L); let b = new luaL_Buffer(); luaL_argcheck(L, tr === LUA_TNUMBER || tr === LUA_TSTRING || tr === LUA_TFUNCTION || tr === LUA_TTABLE, 3, - "string/function/table expected"); + 'string/function/table expected'); luaL_buffinit(L, b); if (anchor) { p = p.subarray(1); lp--; /* skip anchor character */ @@ -1428,33 +1381,33 @@ const str_gsub = function(L) { }; const strlib = { - "byte": str_byte, - "char": str_char, - "dump": str_dump, - "find": str_find, - "format": str_format, - "gmatch": str_gmatch, - "gsub": str_gsub, - "len": str_len, - "lower": str_lower, - "match": str_match, - "pack": str_pack, - "packsize": str_packsize, - "rep": str_rep, - "reverse": str_reverse, - "sub": str_sub, - "unpack": str_unpack, - "upper": str_upper + 'byte': str_byte, + 'char': str_char, + 'dump': str_dump, + 'find': str_find, + 'format': str_format, + 'gmatch': str_gmatch, + 'gsub': str_gsub, + 'len': str_len, + 'lower': str_lower, + 'match': str_match, + 'pack': str_pack, + 'packsize': str_packsize, + 'rep': str_rep, + 'reverse': str_reverse, + 'sub': str_sub, + 'unpack': str_unpack, + 'upper': str_upper }; const createmetatable = function(L) { lua_createtable(L, 0, 1); /* table to be metatable for strings */ - lua_pushliteral(L, ""); /* dummy string */ + lua_pushliteral(L, ''); /* dummy string */ lua_pushvalue(L, -2); /* copy table */ lua_setmetatable(L, -2); /* set table as metatable for strings */ lua_pop(L, 1); /* pop dummy string */ lua_pushvalue(L, -2); /* get string library */ - lua_setfield(L, -2, to_luastring("__index", true)); /* metatable.__index = string */ + lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = string */ lua_pop(L, 1); /* pop metatable */ }; @@ -1463,5 +1416,3 @@ const luaopen_string = function(L) { createmetatable(L); return 1; }; - -module.exports.luaopen_string = luaopen_string; diff --git a/src/ltable.js b/src/ltable.js index fdc34bf2..3ef98c5c 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -1,8 +1,22 @@ -"use strict"; +import { + LUA_TBOOLEAN, + LUA_TCCL, + LUA_TLCF, + LUA_TLCL, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR, LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, to_luastring +} from "./defs.js"; +import {LUA_MAXINTEGER} from "./luaconf.js"; +import {lua_assert} from "./llimits.js"; +import * as ldebug from "./ldebug.js"; +import * as lobject from "./lobject.js"; +import {luaS_hashlongstr, TString} from "./lstring.js"; +import * as lstate from "./lstate.js"; -const { - constant_types: { - LUA_TBOOLEAN, +const constant_types = { + LUA_TBOOLEAN, LUA_TCCL, LUA_TLCF, LUA_TLCL, @@ -15,20 +29,7 @@ const { LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA - }, - to_luastring -} = require('./defs.js'); -const { - LUA_MAXINTEGER -} = require('./luaconf.js'); -const { lua_assert } = require('./llimits.js'); -const ldebug = require('./ldebug.js'); -const lobject = require('./lobject.js'); -const { - luaS_hashlongstr, - TString -} = require('./lstring.js'); -const lstate = require('./lstate.js'); +} /* used to prevent conflicts with lightuserdata keys */ let lightuserdata_hashes = new WeakMap(); @@ -46,10 +47,10 @@ const get_lightuserdata_hash = function(v) { const table_hash = function(L, key) { switch(key.type) { case LUA_TNIL: - return ldebug.luaG_runerror(L, to_luastring("table index is nil", true)); + return ldebug.luaG_runerror(L, to_luastring('table index is nil', true)); case LUA_TNUMFLT: if (isNaN(key.value)) - return ldebug.luaG_runerror(L, to_luastring("table index is NaN", true)); + return ldebug.luaG_runerror(L, to_luastring('table index is NaN', true)); /* fall through */ case LUA_TNUMINT: /* takes advantage of floats and integers being same in JS */ case LUA_TBOOLEAN: @@ -66,22 +67,22 @@ const table_hash = function(L, key) { case LUA_TLIGHTUSERDATA: { let v = key.value; switch(typeof v) { - case "string": + case 'string': /* possible conflict with LUA_TSTRING. prefix this string with "*" so they don't clash */ - return "*" + v; - case "number": + return '*' + v; + case 'number': /* possible conflict with LUA_TNUMBER. turn into string and prefix with "#" to avoid clash with other strings */ - return "#" + v; - case "boolean": + return '#' + v; + case 'boolean': /* possible conflict with LUA_TBOOLEAN. use strings ?true and ?false instead */ - return v?"?true":"?false"; - case "function": + return v?'?true':'?false'; + case 'function': /* possible conflict with LUA_TLCF. indirect via a weakmap */ return get_lightuserdata_hash(v); - case "object": + case 'object': /* v could be a lua_State, CClosure, LClosure, Table or Userdata from this state as returned by lua_topointer */ if ((v instanceof lstate.lua_State && v.l_G === L.l_G) || v instanceof Table || @@ -97,7 +98,7 @@ const table_hash = function(L, key) { } } default: - throw new Error("unknown key type: " + key.type); + throw new Error('unknown key type: ' + key.type); } }; @@ -114,7 +115,7 @@ class Table { } } -const invalidateTMcache = function(t) { +export const invalidateTMcache = function(t) { t.flags = 0; }; @@ -162,7 +163,7 @@ const mark_dead = function(t, hash) { } }; -const luaH_new = function(L) { +export const luaH_new = function(L) { return new Table(L); }; @@ -171,8 +172,8 @@ const getgeneric = function(t, hash) { return v ? v.value : lobject.luaO_nilobject; }; -const luaH_getint = function(t, key) { - lua_assert(typeof key == "number" && (key|0) === key); +export const luaH_getint = function(t, key) { + lua_assert(typeof key == 'number' && (key|0) === key); return getgeneric(t, key); }; @@ -181,15 +182,15 @@ const luaH_getstr = function(t, key) { return getgeneric(t, luaS_hashlongstr(key)); }; -const luaH_get = function(L, t, key) { +export const luaH_get = function(L, t, key) { lua_assert(key instanceof lobject.TValue); if (key.ttisnil() || (key.ttisfloat() && isNaN(key.value))) return lobject.luaO_nilobject; return getgeneric(t, table_hash(L, key)); }; -const luaH_setint = function(t, key, value) { - lua_assert(typeof key == "number" && (key|0) === key && value instanceof lobject.TValue); +export const luaH_setint = function(t, key, value) { + lua_assert(typeof key == 'number' && (key|0) === key && value instanceof lobject.TValue); let hash = key; /* table_hash known result */ if (value.ttisnil()) { mark_dead(t, hash); @@ -206,7 +207,7 @@ const luaH_setint = function(t, key, value) { } }; -const luaH_setfrom = function(L, t, key, value) { +export const luaH_setfrom = function(L, t, key, value) { lua_assert(key instanceof lobject.TValue); let hash = table_hash(L, key); if (value.ttisnil()) { /* delete */ @@ -235,7 +236,7 @@ const luaH_setfrom = function(L, t, key, value) { ** Try to find a boundary in table 't'. A 'boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). */ -const luaH_getn = function(t) { +export const luaH_getn = function(t) { let i = 0; let j = t.strong.size + 1; /* use known size of Map to kick start search */ /* find 'i' and 'j' such that i is present and j is not */ @@ -258,7 +259,7 @@ const luaH_getn = function(t) { return i; }; -const luaH_next = function(L, table, keyI) { +export const luaH_next = function(L, table, keyI) { let keyO = L.stack[keyI]; let entry; @@ -280,7 +281,7 @@ const luaH_next = function(L, table, keyI) { entry = (table.dead_weak && table.dead_weak.get(hash)) || table.dead_strong.get(hash); if (!entry) /* item not in table */ - return ldebug.luaG_runerror(L, to_luastring("invalid key to 'next'")); + return ldebug.luaG_runerror(L, to_luastring('invalid key to \'next\'')); /* Iterate until either out of keys, or until finding a non-dead key */ do { entry = entry.n; @@ -293,14 +294,3 @@ const luaH_next = function(L, table, keyI) { lobject.setobj2s(L, keyI+1, entry.value); return true; }; - -module.exports.invalidateTMcache = invalidateTMcache; -module.exports.luaH_get = luaH_get; -module.exports.luaH_getint = luaH_getint; -module.exports.luaH_getn = luaH_getn; -module.exports.luaH_getstr = luaH_getstr; -module.exports.luaH_setfrom = luaH_setfrom; -module.exports.luaH_setint = luaH_setint; -module.exports.luaH_new = luaH_new; -module.exports.luaH_next = luaH_next; -module.exports.Table = Table; diff --git a/src/ltablib.js b/src/ltablib.js index 0a1d9510..422a26e4 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -1,54 +1,33 @@ -"use strict"; +import {LUA_MAXINTEGER} from "./luaconf.js"; -const { LUA_MAXINTEGER } = require('./luaconf.js'); -const { - LUA_OPEQ, - LUA_OPLT, - LUA_TFUNCTION, - LUA_TNIL, - LUA_TTABLE, +import { lua_call, lua_checkstack, lua_compare, - lua_createtable, - lua_geti, - lua_getmetatable, - lua_gettop, - lua_insert, - lua_isnil, - lua_isnoneornil, - lua_isstring, - lua_pop, - lua_pushinteger, - lua_pushnil, - lua_pushstring, - lua_pushvalue, - lua_rawget, - lua_setfield, - lua_seti, + lua_createtable, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnoneornil, lua_isstring, + LUA_OPEQ, + LUA_OPLT, lua_pop, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawget, lua_setfield, lua_seti, lua_settop, - lua_toboolean, - lua_type -} = require('./lua.js'); -const { - luaL_Buffer, + LUA_TFUNCTION, + LUA_TNIL, lua_toboolean, + LUA_TTABLE, lua_type +} from "./lua.js"; + + +import { luaL_addlstring, luaL_addvalue, luaL_argcheck, + luaL_Buffer, luaL_buffinit, - luaL_checkinteger, - luaL_checktype, - luaL_error, - luaL_len, - luaL_newlib, - luaL_opt, - luaL_optinteger, - luaL_optlstring, - luaL_pushresult, - luaL_typename -} = require('./lauxlib.js'); -const lualib = require('./lualib.js'); -const { to_luastring } = require("./fengaricore.js"); + luaL_checkinteger, luaL_checktype, luaL_error, luaL_len, luaL_newlib, luaL_opt, luaL_optinteger, luaL_optlstring, + luaL_pushresult, luaL_typename +} from "./lauxlib.js"; + + +import lualib from "./lualib.js"; +import {to_luastring} from "./fengaricore.js"; + /* ** Operations that an object must define to mimic a table @@ -72,9 +51,9 @@ const checktab = function(L, arg, what) { if (lua_type(L, arg) !== LUA_TTABLE) { /* is it not a table? */ let n = 1; if (lua_getmetatable(L, arg) && /* must have metatable */ - (!(what & TAB_R) || checkfield(L, to_luastring("__index", true), ++n)) && - (!(what & TAB_W) || checkfield(L, to_luastring("__newindex", true), ++n)) && - (!(what & TAB_L) || checkfield(L, to_luastring("__len", true), ++n))) { + (!(what & TAB_R) || checkfield(L, to_luastring('__index', true), ++n)) && + (!(what & TAB_W) || checkfield(L, to_luastring('__newindex', true), ++n)) && + (!(what & TAB_L) || checkfield(L, to_luastring('__len', true), ++n))) { lua_pop(L, n); /* pop metatable and tested metamethods */ } else @@ -90,7 +69,7 @@ const aux_getn = function(L, n, w) { const addfield = function(L, b, i) { lua_geti(L, 1, i); if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("invalid value (%s) at index %d in table for 'concat'"), + luaL_error(L, to_luastring('invalid value (%s) at index %d in table for \'concat\''), luaL_typename(L, -1), i); luaL_addvalue(b); @@ -105,7 +84,7 @@ const tinsert = function(L) { break; case 3: { pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ - luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); + luaL_argcheck(L, 1 <= pos && pos <= e, 2, 'position out of bounds'); for (let i = e; i > pos; i--) { /* move up elements */ lua_geti(L, 1, i - 1); lua_seti(L, 1, i); /* t[i] = t[i - 1] */ @@ -113,7 +92,7 @@ const tinsert = function(L) { break; } default: { - return luaL_error(L, "wrong number of arguments to 'insert'"); + return luaL_error(L, 'wrong number of arguments to \'insert\''); } } @@ -125,7 +104,7 @@ const tremove = function(L) { let size = aux_getn(L, 1, TAB_RW); let pos = luaL_optinteger(L, 2, size); if (pos !== size) /* validate 'pos' if given */ - luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); + luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, 'position out of bounds'); lua_geti(L, 1, pos); /* result = t[pos] */ for (; pos < size; pos++) { lua_geti(L, 1, pos + 1); @@ -150,9 +129,9 @@ const tmove = function(L) { checktab(L, 1, TAB_R); checktab(L, tt, TAB_W); if (e >= f) { /* otherwise, nothing to move */ - luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, "too many elements to move"); + luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, 'too many elements to move'); let n = e - f + 1; /* number of elements to move */ - luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, "destination wrap around"); + luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, 'destination wrap around'); if (t > e || t <= f || (tt !== 1 && lua_compare(L, 1, tt, LUA_OPEQ) !== 1)) { for (let i = 0; i < n; i++) { @@ -173,7 +152,7 @@ const tmove = function(L) { const tconcat = function(L) { let last = aux_getn(L, 1, TAB_R); - let sep = luaL_optlstring(L, 2, ""); + let sep = luaL_optlstring(L, 2, ''); let lsep = sep.length; let i = luaL_optinteger(L, 3, 1); last = luaL_optinteger(L, 4, last); @@ -201,7 +180,7 @@ const pack = function(L) { for (let i = n; i >= 1; i--) /* assign elements */ lua_seti(L, 1, i); lua_pushinteger(L, n); - lua_setfield(L, 1, to_luastring("n")); /* t.n = number of elements */ + lua_setfield(L, 1, to_luastring('n')); /* t.n = number of elements */ return 1; /* return table */ }; @@ -211,7 +190,7 @@ const unpack = function(L) { if (i > e) return 0; /* empty range */ let n = e - i; /* number of elements minus 1 (avoid overflows) */ if (n >= Number.MAX_SAFE_INTEGER || !lua_checkstack(L, ++n)) - return luaL_error(L, to_luastring("too many results to unpack")); + return luaL_error(L, to_luastring('too many results to unpack')); for (; i < e; i++) /* push arg[i..e - 1] (to avoid overflows) */ lua_geti(L, 1, i); lua_geti(L, 1, e); /* push last element */ @@ -251,14 +230,14 @@ const partition = function(L, lo, up) { /* next loop: repeat ++i while a[i] < P */ while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ - luaL_error(L, to_luastring("invalid order function for sorting")); + luaL_error(L, to_luastring('invalid order function for sorting')); lua_pop(L, 1); /* remove a[i] */ } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) /* j < i but a[j] > P ?? */ - luaL_error(L, to_luastring("invalid order function for sorting")); + luaL_error(L, to_luastring('invalid order function for sorting')); lua_pop(L, 1); /* remove a[j] */ } /* after the loop, a[j] <= P and a[j + 1 .. up] >= P */ @@ -335,7 +314,7 @@ const auxsort = function(L, lo, up, rnd) { const sort = function(L) { let n = aux_getn(L, 1, TAB_RW); if (n > 1) { /* non-trivial interval? */ - luaL_argcheck(L, n < LUA_MAXINTEGER, 1, "array too big"); + luaL_argcheck(L, n < LUA_MAXINTEGER, 1, 'array too big'); if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ luaL_checktype(L, 2, LUA_TFUNCTION); /* must be a function */ lua_settop(L, 2); /* make sure there are two arguments */ @@ -345,18 +324,16 @@ const sort = function(L) { }; const tab_funcs = { - "concat": tconcat, - "insert": tinsert, - "move": tmove, - "pack": pack, - "remove": tremove, - "sort": sort, - "unpack": unpack + 'concat': tconcat, + 'insert': tinsert, + 'move': tmove, + 'pack': pack, + 'remove': tremove, + 'sort': sort, + 'unpack': unpack }; const luaopen_table = function(L) { luaL_newlib(L, tab_funcs); return 1; }; - -module.exports.luaopen_table = luaopen_table; diff --git a/src/ltm.js b/src/ltm.js index a1aa8e37..1db56e0c 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -1,39 +1,36 @@ -"use strict"; +import {LUA_TTABLE, LUA_TUSERDATA, to_luastring} from "./defs.js"; -const { - constant_types: { - LUA_TTABLE, + +import {lua_assert} from "./llimits.js"; + +import * as lobject from "./lobject.js"; +import * as ldo from "./ldo.js"; +import * as lstate from "./lstate.js"; +import {luaS_bless, luaS_new} from "./lstring.js"; +import * as lvm from "./lvm.js"; +import * as ldebug from "./ldebug.js"; +import * as ltable from "./ltable.js"; + +const constant_types = { + LUA_TTABLE, LUA_TUSERDATA - }, - to_luastring -} = require('./defs.js'); -const { lua_assert } = require('./llimits.js'); -const lobject = require('./lobject.js'); -const ldo = require('./ldo.js'); -const lstate = require('./lstate.js'); -const { - luaS_bless, - luaS_new -} = require('./lstring.js'); -const ltable = require('./ltable.js'); -const ldebug = require('./ldebug.js'); -const lvm = require('./lvm.js'); +} const luaT_typenames_ = [ - "no value", - "nil", - "boolean", - "userdata", - "number", - "string", - "table", - "function", - "userdata", - "thread", - "proto" /* this last case is used for tests only */ + 'no value', + 'nil', + 'boolean', + 'userdata', + 'number', + 'string', + 'table', + 'function', + 'userdata', + 'thread', + 'proto' /* this last case is used for tests only */ ].map(e => to_luastring(e)); -const ttypename = function(t) { +export const ttypename = function(t) { return luaT_typenames_[t + 1]; }; @@ -71,30 +68,30 @@ const TMS = { }; const luaT_init = function(L) { - L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring("__index", true)); - L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring("__newindex", true)); - L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring("__gc", true)); - L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring("__mode", true)); - L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring("__len", true)); - L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring("__eq", true)); - L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring("__add", true)); - L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring("__sub", true)); - L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring("__mul", true)); - L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring("__mod", true)); - L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring("__pow", true)); - L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring("__div", true)); - L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring("__idiv", true)); - L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring("__band", true)); - L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring("__bor", true)); - L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring("__bxor", true)); - L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring("__shl", true)); - L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring("__shr", true)); - L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring("__unm", true)); - L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring("__bnot", true)); - L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring("__lt", true)); - L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring("__le", true)); - L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring("__concat", true)); - L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring("__call", true)); + L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring('__index', true)); + L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring('__newindex', true)); + L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring('__gc', true)); + L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring('__mode', true)); + L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring('__len', true)); + L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring('__eq', true)); + L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring('__add', true)); + L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring('__sub', true)); + L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring('__mul', true)); + L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring('__mod', true)); + L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring('__pow', true)); + L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring('__div', true)); + L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring('__idiv', true)); + L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring('__band', true)); + L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring('__bor', true)); + L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring('__bxor', true)); + L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring('__shl', true)); + L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring('__shr', true)); + L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring('__unm', true)); + L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring('__bnot', true)); + L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring('__lt', true)); + L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring('__le', true)); + L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring('__concat', true)); + L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring('__call', true)); }; /* @@ -156,10 +153,10 @@ const luaT_trybinTM = function(L, p1, p2, res, event) { if (n1 !== false && n2 !== false) return ldebug.luaG_tointerror(L, p1, p2); else - return ldebug.luaG_opinterror(L, p1, p2, to_luastring("perform bitwise operation on", true)); + return ldebug.luaG_opinterror(L, p1, p2, to_luastring('perform bitwise operation on', true)); } default: - return ldebug.luaG_opinterror(L, p1, p2, to_luastring("perform arithmetic on", true)); + return ldebug.luaG_opinterror(L, p1, p2, to_luastring('perform arithmetic on', true)); } } }; @@ -200,15 +197,3 @@ const luaT_gettmbyobj = function(L, o, event) { return mt ? ltable.luaH_getstr(mt, L.l_G.tmname[event]) : lobject.luaO_nilobject; }; - -module.exports.fasttm = fasttm; -module.exports.TMS = TMS; -module.exports.luaT_callTM = luaT_callTM; -module.exports.luaT_callbinTM = luaT_callbinTM; -module.exports.luaT_trybinTM = luaT_trybinTM; -module.exports.luaT_callorderTM = luaT_callorderTM; -module.exports.luaT_gettm = luaT_gettm; -module.exports.luaT_gettmbyobj = luaT_gettmbyobj; -module.exports.luaT_init = luaT_init; -module.exports.luaT_objtypename = luaT_objtypename; -module.exports.ttypename = ttypename; diff --git a/src/lua.js b/src/lua.js index 154cfa87..a2b412dd 100644 --- a/src/lua.js +++ b/src/lua.js @@ -1,191 +1,9 @@ -"use strict"; +import * as defs from "./defs.js"; +import * as lapi from "./lapi.js"; +import * as ldebug from "./ldebug.js"; +import * as ldo from "./ldo.js"; +import * as lstate from "./lstate.js"; -const defs = require("./defs.js"); -const lapi = require("./lapi.js"); -const ldebug = require("./ldebug.js"); -const ldo = require("./ldo.js"); -const lstate = require("./lstate.js"); - -module.exports.LUA_AUTHORS = defs.LUA_AUTHORS; -module.exports.LUA_COPYRIGHT = defs.LUA_COPYRIGHT; -module.exports.LUA_ERRERR = defs.thread_status.LUA_ERRERR; -module.exports.LUA_ERRGCMM = defs.thread_status.LUA_ERRGCMM; -module.exports.LUA_ERRMEM = defs.thread_status.LUA_ERRMEM; -module.exports.LUA_ERRRUN = defs.thread_status.LUA_ERRRUN; -module.exports.LUA_ERRSYNTAX = defs.thread_status.LUA_ERRSYNTAX; -module.exports.LUA_HOOKCALL = defs.LUA_HOOKCALL; -module.exports.LUA_HOOKCOUNT = defs.LUA_HOOKCOUNT; -module.exports.LUA_HOOKLINE = defs.LUA_HOOKLINE; -module.exports.LUA_HOOKRET = defs.LUA_HOOKRET; -module.exports.LUA_HOOKTAILCALL = defs.LUA_HOOKTAILCALL; -module.exports.LUA_MASKCALL = defs.LUA_MASKCALL; -module.exports.LUA_MASKCOUNT = defs.LUA_MASKCOUNT; -module.exports.LUA_MASKLINE = defs.LUA_MASKLINE; -module.exports.LUA_MASKRET = defs.LUA_MASKRET; -module.exports.LUA_MINSTACK = defs.LUA_MINSTACK; -module.exports.LUA_MULTRET = defs.LUA_MULTRET; -module.exports.LUA_NUMTAGS = defs.constant_types.LUA_NUMTAGS; -module.exports.LUA_OK = defs.thread_status.LUA_OK; -module.exports.LUA_OPADD = defs.LUA_OPADD; -module.exports.LUA_OPBAND = defs.LUA_OPBAND; -module.exports.LUA_OPBNOT = defs.LUA_OPBNOT; -module.exports.LUA_OPBOR = defs.LUA_OPBOR; -module.exports.LUA_OPBXOR = defs.LUA_OPBXOR; -module.exports.LUA_OPDIV = defs.LUA_OPDIV; -module.exports.LUA_OPEQ = defs.LUA_OPEQ; -module.exports.LUA_OPIDIV = defs.LUA_OPIDIV; -module.exports.LUA_OPLE = defs.LUA_OPLE; -module.exports.LUA_OPLT = defs.LUA_OPLT; -module.exports.LUA_OPMOD = defs.LUA_OPMOD; -module.exports.LUA_OPMUL = defs.LUA_OPMUL; -module.exports.LUA_OPPOW = defs.LUA_OPPOW; -module.exports.LUA_OPSHL = defs.LUA_OPSHL; -module.exports.LUA_OPSHR = defs.LUA_OPSHR; -module.exports.LUA_OPSUB = defs.LUA_OPSUB; -module.exports.LUA_OPUNM = defs.LUA_OPUNM; -module.exports.LUA_REGISTRYINDEX = defs.LUA_REGISTRYINDEX; -module.exports.LUA_RELEASE = defs.LUA_RELEASE; -module.exports.LUA_RIDX_GLOBALS = defs.LUA_RIDX_GLOBALS; -module.exports.LUA_RIDX_LAST = defs.LUA_RIDX_LAST; -module.exports.LUA_RIDX_MAINTHREAD = defs.LUA_RIDX_MAINTHREAD; -module.exports.LUA_SIGNATURE = defs.LUA_SIGNATURE; -module.exports.LUA_TNONE = defs.constant_types.LUA_TNONE; -module.exports.LUA_TNIL = defs.constant_types.LUA_TNIL; -module.exports.LUA_TBOOLEAN = defs.constant_types.LUA_TBOOLEAN; -module.exports.LUA_TLIGHTUSERDATA = defs.constant_types.LUA_TLIGHTUSERDATA; -module.exports.LUA_TNUMBER = defs.constant_types.LUA_TNUMBER; -module.exports.LUA_TSTRING = defs.constant_types.LUA_TSTRING; -module.exports.LUA_TTABLE = defs.constant_types.LUA_TTABLE; -module.exports.LUA_TFUNCTION = defs.constant_types.LUA_TFUNCTION; -module.exports.LUA_TUSERDATA = defs.constant_types.LUA_TUSERDATA; -module.exports.LUA_TTHREAD = defs.constant_types.LUA_TTHREAD; -module.exports.LUA_VERSION = defs.LUA_VERSION; -module.exports.LUA_VERSION_MAJOR = defs.LUA_VERSION_MAJOR; -module.exports.LUA_VERSION_MINOR = defs.LUA_VERSION_MINOR; -module.exports.LUA_VERSION_NUM = defs.LUA_VERSION_NUM; -module.exports.LUA_VERSION_RELEASE = defs.LUA_VERSION_RELEASE; -module.exports.LUA_YIELD = defs.thread_status.LUA_YIELD; -module.exports.lua_Debug = defs.lua_Debug; -module.exports.lua_upvalueindex = defs.lua_upvalueindex; -module.exports.lua_absindex = lapi.lua_absindex; -module.exports.lua_arith = lapi.lua_arith; -module.exports.lua_atpanic = lapi.lua_atpanic; -module.exports.lua_atnativeerror = lapi.lua_atnativeerror; -module.exports.lua_call = lapi.lua_call; -module.exports.lua_callk = lapi.lua_callk; -module.exports.lua_checkstack = lapi.lua_checkstack; -module.exports.lua_close = lstate.lua_close; -module.exports.lua_compare = lapi.lua_compare; -module.exports.lua_concat = lapi.lua_concat; -module.exports.lua_copy = lapi.lua_copy; -module.exports.lua_createtable = lapi.lua_createtable; -module.exports.lua_dump = lapi.lua_dump; -module.exports.lua_error = lapi.lua_error; -module.exports.lua_gc = lapi.lua_gc; -module.exports.lua_getallocf = lapi.lua_getallocf; -module.exports.lua_getextraspace = lapi.lua_getextraspace; -module.exports.lua_getfield = lapi.lua_getfield; -module.exports.lua_getglobal = lapi.lua_getglobal; -module.exports.lua_gethook = ldebug.lua_gethook; -module.exports.lua_gethookcount = ldebug.lua_gethookcount; -module.exports.lua_gethookmask = ldebug.lua_gethookmask; -module.exports.lua_geti = lapi.lua_geti; -module.exports.lua_getinfo = ldebug.lua_getinfo; -module.exports.lua_getlocal = ldebug.lua_getlocal; -module.exports.lua_getmetatable = lapi.lua_getmetatable; -module.exports.lua_getstack = ldebug.lua_getstack; -module.exports.lua_gettable = lapi.lua_gettable; -module.exports.lua_gettop = lapi.lua_gettop; -module.exports.lua_getupvalue = lapi.lua_getupvalue; -module.exports.lua_getuservalue = lapi.lua_getuservalue; -module.exports.lua_insert = lapi.lua_insert; -module.exports.lua_isboolean = lapi.lua_isboolean; -module.exports.lua_iscfunction = lapi.lua_iscfunction; -module.exports.lua_isfunction = lapi.lua_isfunction; -module.exports.lua_isinteger = lapi.lua_isinteger; -module.exports.lua_islightuserdata = lapi.lua_islightuserdata; -module.exports.lua_isnil = lapi.lua_isnil; -module.exports.lua_isnone = lapi.lua_isnone; -module.exports.lua_isnoneornil = lapi.lua_isnoneornil; -module.exports.lua_isnumber = lapi.lua_isnumber; -module.exports.lua_isproxy = lapi.lua_isproxy; -module.exports.lua_isstring = lapi.lua_isstring; -module.exports.lua_istable = lapi.lua_istable; -module.exports.lua_isthread = lapi.lua_isthread; -module.exports.lua_isuserdata = lapi.lua_isuserdata; -module.exports.lua_isyieldable = ldo.lua_isyieldable; -module.exports.lua_len = lapi.lua_len; -module.exports.lua_load = lapi.lua_load; -module.exports.lua_newstate = lstate.lua_newstate; -module.exports.lua_newtable = lapi.lua_newtable; -module.exports.lua_newthread = lstate.lua_newthread; -module.exports.lua_newuserdata = lapi.lua_newuserdata; -module.exports.lua_next = lapi.lua_next; -module.exports.lua_pcall = lapi.lua_pcall; -module.exports.lua_pcallk = lapi.lua_pcallk; -module.exports.lua_pop = lapi.lua_pop; -module.exports.lua_pushboolean = lapi.lua_pushboolean; -module.exports.lua_pushcclosure = lapi.lua_pushcclosure; -module.exports.lua_pushcfunction = lapi.lua_pushcfunction; -module.exports.lua_pushfstring = lapi.lua_pushfstring; -module.exports.lua_pushglobaltable = lapi.lua_pushglobaltable; -module.exports.lua_pushinteger = lapi.lua_pushinteger; -module.exports.lua_pushjsclosure = lapi.lua_pushjsclosure; -module.exports.lua_pushjsfunction = lapi.lua_pushjsfunction; -module.exports.lua_pushlightuserdata = lapi.lua_pushlightuserdata; -module.exports.lua_pushliteral = lapi.lua_pushliteral; -module.exports.lua_pushlstring = lapi.lua_pushlstring; -module.exports.lua_pushnil = lapi.lua_pushnil; -module.exports.lua_pushnumber = lapi.lua_pushnumber; -module.exports.lua_pushstring = lapi.lua_pushstring; -module.exports.lua_pushthread = lapi.lua_pushthread; -module.exports.lua_pushvalue = lapi.lua_pushvalue; -module.exports.lua_pushvfstring = lapi.lua_pushvfstring; -module.exports.lua_rawequal = lapi.lua_rawequal; -module.exports.lua_rawget = lapi.lua_rawget; -module.exports.lua_rawgeti = lapi.lua_rawgeti; -module.exports.lua_rawgetp = lapi.lua_rawgetp; -module.exports.lua_rawlen = lapi.lua_rawlen; -module.exports.lua_rawset = lapi.lua_rawset; -module.exports.lua_rawseti = lapi.lua_rawseti; -module.exports.lua_rawsetp = lapi.lua_rawsetp; -module.exports.lua_register = lapi.lua_register; -module.exports.lua_remove = lapi.lua_remove; -module.exports.lua_replace = lapi.lua_replace; -module.exports.lua_resume = ldo.lua_resume; -module.exports.lua_rotate = lapi.lua_rotate; -module.exports.lua_setallocf = lapi.lua_setallocf; -module.exports.lua_setfield = lapi.lua_setfield; -module.exports.lua_setglobal = lapi.lua_setglobal; -module.exports.lua_sethook = ldebug.lua_sethook; -module.exports.lua_seti = lapi.lua_seti; -module.exports.lua_setlocal = ldebug.lua_setlocal; -module.exports.lua_setmetatable = lapi.lua_setmetatable; -module.exports.lua_settable = lapi.lua_settable; -module.exports.lua_settop = lapi.lua_settop; -module.exports.lua_setupvalue = lapi.lua_setupvalue; -module.exports.lua_setuservalue = lapi.lua_setuservalue; -module.exports.lua_status = lapi.lua_status; -module.exports.lua_stringtonumber = lapi.lua_stringtonumber; -module.exports.lua_toboolean = lapi.lua_toboolean; -module.exports.lua_todataview = lapi.lua_todataview; -module.exports.lua_tointeger = lapi.lua_tointeger; -module.exports.lua_tointegerx = lapi.lua_tointegerx; -module.exports.lua_tojsstring = lapi.lua_tojsstring; -module.exports.lua_tolstring = lapi.lua_tolstring; -module.exports.lua_tonumber = lapi.lua_tonumber; -module.exports.lua_tonumberx = lapi.lua_tonumberx; -module.exports.lua_topointer = lapi.lua_topointer; -module.exports.lua_toproxy = lapi.lua_toproxy; -module.exports.lua_tostring = lapi.lua_tostring; -module.exports.lua_tothread = lapi.lua_tothread; -module.exports.lua_touserdata = lapi.lua_touserdata; -module.exports.lua_type = lapi.lua_type; -module.exports.lua_typename = lapi.lua_typename; -module.exports.lua_upvalueid = lapi.lua_upvalueid; -module.exports.lua_upvaluejoin = lapi.lua_upvaluejoin; -module.exports.lua_version = lapi.lua_version; -module.exports.lua_xmove = lapi.lua_xmove; -module.exports.lua_yield = ldo.lua_yield; -module.exports.lua_yieldk = ldo.lua_yieldk; -module.exports.lua_tocfunction = lapi.lua_tocfunction; +export const lua_pushinteger = lapi.lua_pushinteger; +export const lua_pushliteral = lapi.lua_pushliteral; +export const lua_setfield = lapi.lua_setfield; diff --git a/src/luaconf.js b/src/luaconf.js index 5fb91cd7..5a2c4a6d 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -1,13 +1,8 @@ -"use strict"; +import { platform } from "os"; +import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR, to_luastring } from './defs.js'; const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); -const { - LUA_VERSION_MAJOR, - LUA_VERSION_MINOR, - to_luastring -} = require('./defs.js'); - /* ** LUA_PATH_SEP is the character that separates templates in a path. ** LUA_PATH_MARK is the string that marks the substitution points in a @@ -15,14 +10,11 @@ const { ** LUA_EXEC_DIR in a Windows path is replaced by the executable's ** directory. */ -const LUA_PATH_SEP = ";"; -module.exports.LUA_PATH_SEP = LUA_PATH_SEP; +const LUA_PATH_SEP = ";"; const LUA_PATH_MARK = "?"; -module.exports.LUA_PATH_MARK = LUA_PATH_MARK; -const LUA_EXEC_DIR = "!"; -module.exports.LUA_EXEC_DIR = LUA_EXEC_DIR; +const LUA_EXEC_DIR = "!"; /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @@ -34,92 +26,64 @@ module.exports.LUA_EXEC_DIR = LUA_EXEC_DIR; ** non-conventional directories. */ const LUA_VDIR = LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; -module.exports.LUA_VDIR = LUA_VDIR; - -if (typeof process === "undefined") { - const LUA_DIRSEP = "/"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; - const LUA_LDIR = "./lua/" + LUA_VDIR + "/"; - module.exports.LUA_LDIR = LUA_LDIR; - const LUA_JSDIR = LUA_LDIR; - module.exports.LUA_JSDIR = LUA_JSDIR; +// Platform-dependent config as ES module exports +let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_ROOT, LUA_ROOT2, LUA_LDIR2, LUA_JSDIR2; +let LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT; - const LUA_PATH_DEFAULT = to_luastring( +if (typeof process === "undefined") { + LUA_DIRSEP = "/"; + LUA_LDIR = "./lua/" + LUA_VDIR + "/"; + LUA_JSDIR = LUA_LDIR; + LUA_PATH_DEFAULT = to_luastring( LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + - /* LUA_JSDIR excluded as it is equal to LUA_LDIR */ "./?.lua;./?/init.lua" ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - - const LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = to_luastring( LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;./?.js" ); - module.exports.LUA_JSPATH_DEFAULT = LUA_JSPATH_DEFAULT; -} else if (require('os').platform() === 'win32') { - const LUA_DIRSEP = "\\"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; - - /* - ** In Windows, any exclamation mark ('!') in the path is replaced by the - ** path of the directory of the executable file of the current process. - */ - const LUA_LDIR = "!\\lua\\"; - module.exports.LUA_LDIR = LUA_LDIR; - - const LUA_JSDIR = "!\\"; - module.exports.LUA_JSDIR = LUA_JSDIR; - - const LUA_SHRDIR = "!\\..\\share\\lua\\" + LUA_VDIR + "\\"; - module.exports.LUA_SHRDIR = LUA_SHRDIR; - - const LUA_PATH_DEFAULT = to_luastring( + // No SHRDIR, ROOT, etc. in browser +} else if (platform() === "win32") { + LUA_DIRSEP = "\\"; + LUA_LDIR = "!\\lua\\"; + LUA_JSDIR = "!\\"; + LUA_SHRDIR = "!\\..\\share\\lua\\" + LUA_VDIR + "\\"; + LUA_PATH_DEFAULT = to_luastring( LUA_LDIR + "?.lua;" + LUA_LDIR + "?\\init.lua;" + LUA_JSDIR + "?.lua;" + LUA_JSDIR + "?\\init.lua;" + LUA_SHRDIR + "?.lua;" + LUA_SHRDIR + "?\\init.lua;" + ".\\?.lua;.\\?\\init.lua" ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - - const LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = to_luastring( LUA_JSDIR + "?.js;" + LUA_JSDIR + "..\\share\\lua\\" + LUA_VDIR + "\\?.js;" + LUA_JSDIR + "loadall.js;.\\?.js" ); - module.exports.LUA_JSPATH_DEFAULT = LUA_JSPATH_DEFAULT; } else { - const LUA_DIRSEP = "/"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; - - const LUA_ROOT = "/usr/local/"; - module.exports.LUA_ROOT = LUA_ROOT; - const LUA_ROOT2 = "/usr/"; - - const LUA_LDIR = LUA_ROOT + "share/lua/" + LUA_VDIR + "/"; - const LUA_LDIR2 = LUA_ROOT2 + "share/lua/" + LUA_VDIR + "/"; - module.exports.LUA_LDIR = LUA_LDIR; - - const LUA_JSDIR = LUA_LDIR; - module.exports.LUA_JSDIR = LUA_JSDIR; - const LUA_JSDIR2 = LUA_LDIR2; - - const LUA_PATH_DEFAULT = to_luastring( + LUA_DIRSEP = "/"; + LUA_ROOT = "/usr/local/"; + LUA_ROOT2 = "/usr/"; + LUA_LDIR = LUA_ROOT + "share/lua/" + LUA_VDIR + "/"; + LUA_LDIR2 = LUA_ROOT2 + "share/lua/" + LUA_VDIR + "/"; + LUA_JSDIR = LUA_LDIR; + LUA_JSDIR2 = LUA_LDIR2; + LUA_PATH_DEFAULT = to_luastring( LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + LUA_LDIR2 + "?.lua;" + LUA_LDIR2 + "?/init.lua;" + - /* LUA_JSDIR(2) excluded as it is equal to LUA_LDIR(2) */ "./?.lua;./?/init.lua" ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - - const LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = to_luastring( LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;" + LUA_JSDIR2 + "?.js;" + LUA_JSDIR2 + "loadall.js;" + "./?.js" ); - module.exports.LUA_JSPATH_DEFAULT = LUA_JSPATH_DEFAULT; } +{ LUA_DIRSEP, LUA_LDIR, LUA_JSDIR }; +// Optionally these if defined for the platform +{ LUA_SHRDIR, LUA_ROOT, LUA_ROOT2, LUA_LDIR2, LUA_JSDIR2 }; + /* @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a @@ a float mark ('.0'). @@ -128,8 +92,8 @@ if (typeof process === "undefined") { */ const LUA_COMPAT_FLOATSTRING = conf.LUA_COMPAT_FLOATSTRING || false; -const LUA_MAXINTEGER = 2147483647; -const LUA_MININTEGER = -2147483648; +export const LUA_MAXINTEGER = 2147483647; +export const LUA_MININTEGER = -2147483648; /* @@ LUAI_MAXSTACK limits the size of the Lua stack. @@ -137,24 +101,24 @@ const LUA_MININTEGER = -2147483648; ** its only purpose is to stop Lua from consuming unlimited stack ** space (and to reserve some numbers for pseudo-indices). */ -const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; +export const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; /* @@ LUA_IDSIZE gives the maximum size for the description of the source @@ of a function in debug information. ** CHANGE it if you want a different size. */ -const LUA_IDSIZE = conf.LUA_IDSIZE || (60-1); /* fengari uses 1 less than lua as we don't embed the null byte */ +const LUA_IDSIZE = conf.LUA_IDSIZE || (60 - 1); /* fengari uses 1 less than lua as we don't embed the null byte */ -const lua_integer2str = function(n) { +const lua_integer2str = function (n) { return String(n); /* should match behaviour of LUA_INTEGER_FMT */ }; -const lua_number2str = function(n) { +const lua_number2str = function (n) { return String(Number(n.toPrecision(14))); /* should match behaviour of LUA_NUMBER_FMT */ }; -const lua_numbertointeger = function(n) { +export const lua_numbertointeger = function (n) { return n >= LUA_MININTEGER && n < -LUA_MININTEGER ? n : false; }; @@ -162,9 +126,9 @@ const LUA_INTEGER_FRMLEN = ""; const LUA_NUMBER_FRMLEN = ""; const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; -const LUA_NUMBER_FMT = "%.14g"; +const LUA_NUMBER_FMT = "%.14g"; -const lua_getlocaledecpoint = function() { +const lua_getlocaledecpoint = function () { /* we hard-code the decimal point to '.' as a user cannot change the locale in most JS environments, and in that you can, a multi-byte locale is common. @@ -178,7 +142,7 @@ const lua_getlocaledecpoint = function() { const LUAL_BUFFERSIZE = conf.LUAL_BUFFERSIZE || 8192; // See: http://croquetweak.blogspot.fr/2014/08/deconstructing-floats-frexp-and-ldexp.html -const frexp = function(value) { +const frexp = function (value) { if (value === 0) return [value, 0]; var data = new DataView(new ArrayBuffer(8)); data.setFloat64(0, value); @@ -192,7 +156,7 @@ const frexp = function(value) { return [mantissa, exponent]; }; -const ldexp = function(mantissa, exponent) { +const ldexp = function (mantissa, exponent) { var steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023)); var result = mantissa; for (var i = 0; i < steps; i++) @@ -200,19 +164,21 @@ const ldexp = function(mantissa, exponent) { return result; }; -module.exports.LUAI_MAXSTACK = LUAI_MAXSTACK; -module.exports.LUA_COMPAT_FLOATSTRING = LUA_COMPAT_FLOATSTRING; -module.exports.LUA_IDSIZE = LUA_IDSIZE; -module.exports.LUA_INTEGER_FMT = LUA_INTEGER_FMT; -module.exports.LUA_INTEGER_FRMLEN = LUA_INTEGER_FRMLEN; -module.exports.LUA_MAXINTEGER = LUA_MAXINTEGER; -module.exports.LUA_MININTEGER = LUA_MININTEGER; -module.exports.LUA_NUMBER_FMT = LUA_NUMBER_FMT; -module.exports.LUA_NUMBER_FRMLEN = LUA_NUMBER_FRMLEN; -module.exports.LUAL_BUFFERSIZE = LUAL_BUFFERSIZE; -module.exports.frexp = frexp; -module.exports.ldexp = ldexp; -module.exports.lua_getlocaledecpoint = lua_getlocaledecpoint; -module.exports.lua_integer2str = lua_integer2str; -module.exports.lua_number2str = lua_number2str; -module.exports.lua_numbertointeger = lua_numbertointeger; +{ + LUAI_MAXSTACK, + LUA_COMPAT_FLOATSTRING, + LUA_IDSIZE, + LUA_INTEGER_FMT, + LUA_INTEGER_FRMLEN, + LUA_MAXINTEGER, + LUA_MININTEGER, + LUA_NUMBER_FMT, + LUA_NUMBER_FRMLEN, + LUAL_BUFFERSIZE, + frexp, + ldexp, + lua_getlocaledecpoint, + lua_integer2str, + lua_number2str, + lua_numbertointeger +}; diff --git a/src/lualib.js b/src/lualib.js index fa302684..33928abd 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,62 +1,30 @@ -"use strict"; - -const { - LUA_VERSION_MAJOR, - LUA_VERSION_MINOR -} = require("./lua.js"); - -const LUA_VERSUFFIX = "_" + LUA_VERSION_MAJOR + "_" + LUA_VERSION_MINOR; -module.exports.LUA_VERSUFFIX = LUA_VERSUFFIX; - -module.exports.lua_assert = function(c) {}; - -module.exports.luaopen_base = require("./lbaselib.js").luaopen_base; - -const LUA_COLIBNAME = "coroutine"; -module.exports.LUA_COLIBNAME = LUA_COLIBNAME; -module.exports.luaopen_coroutine = require("./lcorolib.js").luaopen_coroutine; - -const LUA_TABLIBNAME = "table"; -module.exports.LUA_TABLIBNAME = LUA_TABLIBNAME; -module.exports.luaopen_table = require("./ltablib.js").luaopen_table; - -if (typeof process !== "undefined") { - const LUA_IOLIBNAME = "io"; - module.exports.LUA_IOLIBNAME = LUA_IOLIBNAME; - module.exports.luaopen_io = require("./liolib.js").luaopen_io; -} - -const LUA_OSLIBNAME = "os"; -module.exports.LUA_OSLIBNAME = LUA_OSLIBNAME; -module.exports.luaopen_os = require("./loslib.js").luaopen_os; - -const LUA_STRLIBNAME = "string"; -module.exports.LUA_STRLIBNAME = LUA_STRLIBNAME; -module.exports.luaopen_string = require("./lstrlib.js").luaopen_string; - -const LUA_UTF8LIBNAME = "utf8"; -module.exports.LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; -module.exports.luaopen_utf8 = require("./lutf8lib.js").luaopen_utf8; - -const LUA_BITLIBNAME = "bit32"; -module.exports.LUA_BITLIBNAME = LUA_BITLIBNAME; +import {LUA_VERSION_MAJOR, LUA_VERSION_MINOR} from "./lua.js"; + +import linit from "./linit.js"; +import {luaopen_fengari} from "./fengarilib.js"; +import {luaopen_package} from "./loadlib.js"; +import {luaopen_debug} from "./ldblib.js"; +import {luaopen_math} from "./lmathlib.js"; +import {luaopen_utf8} from "./lutf8lib.js"; +import {luaopen_string} from "./lstrlib.js"; +import {luaopen_os} from "./loslib.js"; +import {luaopen_io} from "./liolib.js"; +import {luaopen_table} from "./ltablib.js"; +import {luaopen_coroutine} from "./lcorolib.js"; +import {luaopen_base} from "./lbaselib.js"; + +const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; +const LUA_COLIBNAME = 'coroutine'; +const LUA_TABLIBNAME = 'table'; +const LUA_IOLIBNAME = 'io'; +const LUA_OSLIBNAME = 'os'; +const LUA_STRLIBNAME = 'string'; +const LUA_UTF8LIBNAME = 'utf8'; +const LUA_BITLIBNAME = 'bit32'; // module.exports.luaopen_bit32 = require("./lbitlib.js").luaopen_bit32; -const LUA_MATHLIBNAME = "math"; -module.exports.LUA_MATHLIBNAME = LUA_MATHLIBNAME; -module.exports.luaopen_math = require("./lmathlib.js").luaopen_math; - -const LUA_DBLIBNAME = "debug"; -module.exports.LUA_DBLIBNAME = LUA_DBLIBNAME; -module.exports.luaopen_debug = require("./ldblib.js").luaopen_debug; - -const LUA_LOADLIBNAME = "package"; -module.exports.LUA_LOADLIBNAME = LUA_LOADLIBNAME; -module.exports.luaopen_package = require("./loadlib.js").luaopen_package; - -const LUA_FENGARILIBNAME = "fengari"; -module.exports.LUA_FENGARILIBNAME = LUA_FENGARILIBNAME; -module.exports.luaopen_fengari = require("./fengarilib.js").luaopen_fengari; - -const linit = require('./linit.js'); -module.exports.luaL_openlibs = linit.luaL_openlibs; +const LUA_MATHLIBNAME = 'math'; +const LUA_DBLIBNAME = 'debug'; +const LUA_LOADLIBNAME = 'package'; +const LUA_FENGARILIBNAME = 'fengari'; +const luaL_openlibs = linit.luaL_openlibs; diff --git a/src/lundump.js b/src/lundump.js index 807d8be4..cb1c57b8 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -1,24 +1,18 @@ -"use strict"; - -const { - LUA_SIGNATURE, - constant_types: { - LUA_TBOOLEAN, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR - }, - thread_status: { LUA_ERRSYNTAX }, +import { is_luastring, - luastring_eq, - to_luastring -} = require('./defs.js'); -const ldo = require('./ldo.js'); -const lfunc = require('./lfunc.js'); -const lobject = require('./lobject.js'); -const { + LUA_ERRSYNTAX, + LUA_SIGNATURE, + LUA_TBOOLEAN, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, luastring_eq, to_luastring +} from "./defs.js"; +import * as ldo from "./ldo.js"; +import * as lfunc from "./lfunc.js"; +import * as lobject from "./lobject.js"; +import { MAXARG_sBx, POS_A, POS_Ax, @@ -30,15 +24,24 @@ const { SIZE_Ax, SIZE_B, SIZE_Bx, - SIZE_C, - SIZE_OP -} = require('./lopcodes.js'); -const { lua_assert } = require("./llimits.js"); -const { luaS_bless } = require('./lstring.js'); -const { - luaZ_read, - ZIO -} = require('./lzio.js'); + SIZE_C, SIZE_OP +} from "./lopcodes.js"; + +import {ZIO} from "./lzio.js"; +import {luaZ_read, ZIO} from "./lzio.js"; +import {luaS_bless} from "./lstring.js"; +import {lua_assert} from "./llimits.js"; + + +const constant_types = { + LUA_TBOOLEAN, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR +}; +const thread_status = {LUA_ERRSYNTAX}; let LUAC_DATA = [0x19, 0x93, 13, 10, 0x1a, 10]; @@ -51,13 +54,13 @@ class BytecodeParser { this.integerSize = 4; this.numberSize = 8; - lua_assert(Z instanceof ZIO, "BytecodeParser only operates on a ZIO"); + lua_assert(Z instanceof ZIO, 'BytecodeParser only operates on a ZIO'); lua_assert(is_luastring(name)); if (name[0] === 64 /* ('@').charCodeAt(0) */ || name[0] === 61 /* ('=').charCodeAt(0) */) this.name = name.subarray(1); else if (name[0] == LUA_SIGNATURE[0]) - this.name = to_luastring("binary string", true); + this.name = to_luastring('binary string', true); else this.name = name; @@ -74,32 +77,32 @@ class BytecodeParser { read(size) { let u8 = new Uint8Array(size); - if(luaZ_read(this.Z, u8, 0, size) !== 0) - this.error("truncated"); + if (luaZ_read(this.Z, u8, 0, size) !== 0) + this.error('truncated'); return u8; } LoadByte() { if (luaZ_read(this.Z, this.u8, 0, 1) !== 0) - this.error("truncated"); + this.error('truncated'); return this.u8[0]; } LoadInt() { if (luaZ_read(this.Z, this.u8, 0, this.intSize) !== 0) - this.error("truncated"); + this.error('truncated'); return this.dv.getInt32(0, true); } LoadNumber() { if (luaZ_read(this.Z, this.u8, 0, this.numberSize) !== 0) - this.error("truncated"); + this.error('truncated'); return this.dv.getFloat64(0, true); } LoadInteger() { if (luaZ_read(this.Z, this.u8, 0, this.integerSize) !== 0) - this.error("truncated"); + this.error('truncated'); return this.dv.getInt32(0, true); } @@ -113,12 +116,12 @@ class BytecodeParser { size = this.LoadSize_t(); if (size === 0) return null; - return luaS_bless(this.L, this.read(size-1)); + return luaS_bless(this.L, this.read(size - 1)); } /* creates a mask with 'n' 1 bits at position 'p' */ static MASK1(n, p) { - return ((~((~0)<<(n)))<<(p)); + return ((~((~0) << (n))) << (p)); } LoadCode(f) { @@ -127,17 +130,17 @@ class BytecodeParser { for (let i = 0; i < n; i++) { if (luaZ_read(this.Z, this.u8, 0, this.instructionSize) !== 0) - this.error("truncated"); + this.error('truncated'); let ins = this.dv.getUint32(0, true); f.code[i] = { - code: ins, + code: ins, opcode: (ins >> POS_OP) & p.MASK1(SIZE_OP, 0), - A: (ins >> POS_A) & p.MASK1(SIZE_A, 0), - B: (ins >> POS_B) & p.MASK1(SIZE_B, 0), - C: (ins >> POS_C) & p.MASK1(SIZE_C, 0), - Bx: (ins >> POS_Bx) & p.MASK1(SIZE_Bx, 0), - Ax: (ins >> POS_Ax) & p.MASK1(SIZE_Ax, 0), - sBx: ((ins >> POS_Bx) & p.MASK1(SIZE_Bx, 0)) - MAXARG_sBx + A: (ins >> POS_A) & p.MASK1(SIZE_A, 0), + B: (ins >> POS_B) & p.MASK1(SIZE_B, 0), + C: (ins >> POS_C) & p.MASK1(SIZE_C, 0), + Bx: (ins >> POS_Bx) & p.MASK1(SIZE_Bx, 0), + Ax: (ins >> POS_Ax) & p.MASK1(SIZE_Ax, 0), + sBx: ((ins >> POS_Bx) & p.MASK1(SIZE_Bx, 0)) - MAXARG_sBx }; } } @@ -185,9 +188,9 @@ class BytecodeParser { for (let i = 0; i < n; i++) { f.upvalues[i] = { - name: null, + name: null, instack: this.LoadByte(), - idx: this.LoadByte() + idx: this.LoadByte() }; } } @@ -202,7 +205,7 @@ class BytecodeParser { f.locvars[i] = { varname: this.LoadString(), startpc: this.LoadInt(), - endpc: this.LoadInt() + endpc: this.LoadInt() }; } @@ -235,38 +238,38 @@ class BytecodeParser { } checkHeader() { - this.checkliteral(LUA_SIGNATURE.subarray(1), "not a"); /* 1st char already checked */ + this.checkliteral(LUA_SIGNATURE.subarray(1), 'not a'); /* 1st char already checked */ if (this.LoadByte() !== 0x53) - this.error("version mismatch in"); + this.error('version mismatch in'); if (this.LoadByte() !== 0) - this.error("format mismatch in"); + this.error('format mismatch in'); - this.checkliteral(LUAC_DATA, "corrupted"); + this.checkliteral(LUAC_DATA, 'corrupted'); - this.intSize = this.LoadByte(); - this.size_tSize = this.LoadByte(); + this.intSize = this.LoadByte(); + this.size_tSize = this.LoadByte(); this.instructionSize = this.LoadByte(); - this.integerSize = this.LoadByte(); - this.numberSize = this.LoadByte(); + this.integerSize = this.LoadByte(); + this.numberSize = this.LoadByte(); - this.checksize(this.intSize, 4, "int"); - this.checksize(this.size_tSize, 4, "size_t"); - this.checksize(this.instructionSize, 4, "instruction"); - this.checksize(this.integerSize, 4, "integer"); - this.checksize(this.numberSize, 8, "number"); + this.checksize(this.intSize, 4, 'int'); + this.checksize(this.size_tSize, 4, 'size_t'); + this.checksize(this.instructionSize, 4, 'instruction'); + this.checksize(this.integerSize, 4, 'integer'); + this.checksize(this.numberSize, 8, 'number'); if (this.LoadInteger() !== 0x5678) - this.error("endianness mismatch in"); + this.error('endianness mismatch in'); if (this.LoadNumber() !== 370.5) - this.error("float format mismatch in"); + this.error('float format mismatch in'); } error(why) { - lobject.luaO_pushfstring(this.L, to_luastring("%s: %s precompiled chunk"), this.name, to_luastring(why)); + lobject.luaO_pushfstring(this.L, to_luastring('%s: %s precompiled chunk'), this.name, to_luastring(why)); ldo.luaD_throw(this.L, LUA_ERRSYNTAX); } @@ -276,17 +279,15 @@ class BytecodeParser { } } -const luaU_undump = function(L, Z, name) { +const luaU_undump = function (L, Z, name) { let S = new BytecodeParser(L, Z, name); S.checkHeader(); let cl = lfunc.luaF_newLclosure(L, S.LoadByte()); ldo.luaD_inctop(L); - L.stack[L.top-1].setclLvalue(cl); + L.stack[L.top - 1].setclLvalue(cl); cl.p = new lfunc.Proto(L); S.LoadFunction(cl.p, null); lua_assert(cl.nupvalues === cl.p.upvalues.length); /* luai_verifycode */ return cl; }; - -module.exports.luaU_undump = luaU_undump; diff --git a/src/lutf8lib.js b/src/lutf8lib.js index d3dc3a25..79f4ec00 100644 --- a/src/lutf8lib.js +++ b/src/lutf8lib.js @@ -1,33 +1,23 @@ -"use strict"; - -const { +import { lua_gettop, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushnil, lua_pushstring, - lua_pushvalue, - lua_setfield, - lua_tointeger -} = require('./lua.js'); -const { - luaL_Buffer, + lua_pushvalue, lua_setfield, lua_tointeger +} from "./lua.js"; + +import { luaL_addvalue, luaL_argcheck, + luaL_Buffer, luaL_buffinit, luaL_checkinteger, - luaL_checkstack, - luaL_checkstring, - luaL_error, - luaL_newlib, - luaL_optinteger, - luaL_pushresult -} = require('./lauxlib.js'); -const { - luastring_of, - to_luastring -} = require("./fengaricore.js"); + luaL_checkstack, luaL_checkstring, luaL_error, luaL_newlib, luaL_optinteger, luaL_pushresult +} from "./lauxlib.js"; + +import {luastring_of, to_luastring} from "./fengaricore.js"; const MAXUNICODE = 0x10FFFF; @@ -85,8 +75,8 @@ const utflen = function(L) { let posi = u_posrelat(luaL_optinteger(L, 2, 1), len); let posj = u_posrelat(luaL_optinteger(L, 3, -1), len); - luaL_argcheck(L, 1 <= posi && --posi <= len, 2, "initial position out of string"); - luaL_argcheck(L, --posj < len, 3, "final position out of string"); + luaL_argcheck(L, 1 <= posi && --posi <= len, 2, 'initial position out of string'); + luaL_argcheck(L, --posj < len, 3, 'final position out of string'); while (posi <= posj) { let dec = utf8_decode(s, posi); @@ -102,10 +92,10 @@ const utflen = function(L) { return 1; }; -const p_U = to_luastring("%U"); +const p_U = to_luastring('%U'); const pushutfchar = function(L, arg) { let code = luaL_checkinteger(L, arg); - luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); + luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, 'value out of range'); lua_pushfstring(L, p_U, code); }; @@ -138,14 +128,14 @@ const byteoffset = function(L) { let posi = n >= 0 ? 1 : s.length + 1; posi = u_posrelat(luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, "position out of range"); + luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, 'position out of range'); if (n === 0) { /* find beginning of current byte sequence */ while (posi > 0 && iscont(s[posi])) posi--; } else { if (iscont(s[posi])) - luaL_error(L, "initial position is a continuation byte"); + luaL_error(L, 'initial position is a continuation byte'); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ @@ -182,19 +172,19 @@ const codepoint = function(L) { let posi = u_posrelat(luaL_optinteger(L, 2, 1), s.length); let pose = u_posrelat(luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, posi >= 1, 2, "out of range"); - luaL_argcheck(L, pose <= s.length, 3, "out of range"); + luaL_argcheck(L, posi >= 1, 2, 'out of range'); + luaL_argcheck(L, pose <= s.length, 3, 'out of range'); if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) - return luaL_error(L, "string slice too long"); + return luaL_error(L, 'string slice too long'); let n = (pose - posi) + 1; - luaL_checkstack(L, n, "string slice too long"); + luaL_checkstack(L, n, 'string slice too long'); n = 0; for (posi -= 1; posi < pose;) { let dec = utf8_decode(s, posi); if (dec === null) - return luaL_error(L, "invalid UTF-8 code"); + return luaL_error(L, 'invalid UTF-8 code'); lua_pushinteger(L, dec.code); posi = dec.pos; n++; @@ -219,7 +209,7 @@ const iter_aux = function(L) { else { let dec = utf8_decode(s, n); if (dec === null || iscont(s[dec.pos])) - return luaL_error(L, to_luastring("invalid UTF-8 code")); + return luaL_error(L, to_luastring('invalid UTF-8 code')); lua_pushinteger(L, n + 1); lua_pushinteger(L, dec.code); return 2; @@ -235,11 +225,11 @@ const iter_codes = function(L) { }; const funcs = { - "char": utfchar, - "codepoint": codepoint, - "codes": iter_codes, - "len": utflen, - "offset": byteoffset + 'char': utfchar, + 'codepoint': codepoint, + 'codes': iter_codes, + 'len': utflen, + 'offset': byteoffset }; /* pattern to match a single UTF-8 character */ @@ -248,8 +238,6 @@ const UTF8PATT = luastring_of(91, 0, 45, 127, 194, 45, 244, 93, 91, 128, 45, 191 const luaopen_utf8 = function(L) { luaL_newlib(L, funcs); lua_pushstring(L, UTF8PATT); - lua_setfield(L, -2, to_luastring("charpattern", true)); + lua_setfield(L, -2, to_luastring('charpattern', true)); return 1; }; - -module.exports.luaopen_utf8 = luaopen_utf8; diff --git a/src/lvm.js b/src/lvm.js index 423d2a73..f5cba0ee 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -1,120 +1,131 @@ -"use strict"; - -const { - LUA_MASKLINE, +import { LUA_MASKCOUNT, + LUA_MASKLINE, LUA_MULTRET, - constant_types: { - LUA_TBOOLEAN, - LUA_TLCF, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMBER, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR, - LUA_TTABLE, - LUA_TUSERDATA - }, + constant_types, to_luastring -} = require('./defs.js'); -const { +} from "./defs.js"; + +import { INDEXK, ISK, LFIELDS_PER_FLUSH, - OpCodesI: { - OP_ADD, - OP_BAND, - OP_BNOT, - OP_BOR, - OP_BXOR, - OP_CALL, - OP_CLOSURE, - OP_CONCAT, - OP_DIV, - OP_EQ, - OP_EXTRAARG, - OP_FORLOOP, - OP_FORPREP, - OP_GETTABLE, - OP_GETTABUP, - OP_GETUPVAL, - OP_IDIV, - OP_JMP, - OP_LE, - OP_LEN, - OP_LOADBOOL, - OP_LOADK, - OP_LOADKX, - OP_LOADNIL, - OP_LT, - OP_MOD, - OP_MOVE, - OP_MUL, - OP_NEWTABLE, - OP_NOT, - OP_POW, - OP_RETURN, - OP_SELF, - OP_SETLIST, - OP_SETTABLE, - OP_SETTABUP, - OP_SETUPVAL, - OP_SHL, - OP_SHR, - OP_SUB, - OP_TAILCALL, - OP_TEST, - OP_TESTSET, - OP_TFORCALL, - OP_TFORLOOP, - OP_UNM, - OP_VARARG - } -} = require('./lopcodes.js'); -const { - LUA_MAXINTEGER, - LUA_MININTEGER, - lua_numbertointeger -} = require('./luaconf.js'); + OpCodesI +} from "./lopcodes.js"; + +import {LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger} from "./luaconf.js"; + +import {lua_assert, luai_nummod} from "./llimits.js"; + +import * as lobject from "./lobject.js"; +import * as lfunc from "./lfunc.js"; +import * as lstate from "./lstate.js"; +import {luaS_bless, luaS_eqlngstr, luaS_hashlongstr} from "./lstring.js"; + +import * as ldebug from "./ldebug.js"; +import * as ltable from "./ltable.js"; +import * as ltm from "./ltm.js"; +import * as ldo from "./ldo.js"; + const { - lua_assert, - luai_nummod -} = require('./llimits.js'); -const lobject = require('./lobject.js'); -const lfunc = require('./lfunc.js'); -const lstate = require('./lstate.js'); + OP_ADD, + OP_BAND, + OP_BNOT, + OP_BOR, + OP_BXOR, + OP_CALL, + OP_CLOSURE, + OP_CONCAT, + OP_DIV, + OP_EQ, + OP_EXTRAARG, + OP_FORLOOP, + OP_FORPREP, + OP_GETTABLE, + OP_GETTABUP, + OP_GETUPVAL, + OP_IDIV, + OP_JMP, + OP_LE, + OP_LEN, + OP_LOADBOOL, + OP_LOADK, + OP_LOADKX, + OP_LOADNIL, + OP_LT, + OP_MOD, + OP_MOVE, + OP_MUL, + OP_NEWTABLE, + OP_NOT, + OP_POW, + OP_RETURN, + OP_SELF, + OP_SETLIST, + OP_SETTABLE, + OP_SETTABUP, + OP_SETUPVAL, + OP_SHL, + OP_SHR, + OP_SUB, + OP_TAILCALL, + OP_TEST, + OP_TESTSET, + OP_TFORCALL, + OP_TFORLOOP, + OP_UNM, + OP_VARARG +} = OpCodesI; + const { - luaS_bless, - luaS_eqlngstr, - luaS_hashlongstr -} = require('./lstring.js'); -const ldo = require('./ldo.js'); -const ltm = require('./ltm.js'); -const ltable = require('./ltable.js'); -const ldebug = require('./ldebug.js'); + LUA_TBOOLEAN, + LUA_TLCF, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMBER, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, + LUA_TTABLE, + LUA_TUSERDATA +} = constant_types; /* ** finish execution of an opcode interrupted by an yield */ -const luaV_finishOp = function(L) { +const luaV_finishOp = function (L) { let ci = L.ci; let base = ci.l_base; let inst = ci.l_code[ci.l_savedpc - 1]; /* interrupted instruction */ let op = inst.opcode; switch (op) { /* finish its execution */ - case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_IDIV: - case OP_BAND: case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: - case OP_MOD: case OP_POW: - case OP_UNM: case OP_BNOT: case OP_LEN: - case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { - lobject.setobjs2s(L, base + inst.A, L.top-1); + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_IDIV: + case OP_BAND: + case OP_BOR: + case OP_BXOR: + case OP_SHL: + case OP_SHR: + case OP_MOD: + case OP_POW: + case OP_UNM: + case OP_BNOT: + case OP_LEN: + case OP_GETTABUP: + case OP_GETTABLE: + case OP_SELF: { + lobject.setobjs2s(L, base + inst.A, L.top - 1); delete L.stack[--L.top]; break; } - case OP_LE: case OP_LT: case OP_EQ: { + case OP_LE: + case OP_LT: + case OP_EQ: { let res = !L.stack[L.top - 1].l_isfalse(); delete L.stack[--L.top]; if (ci.callstatus & lstate.CIST_LEQ) { /* "<=" using "<" instead? */ @@ -154,11 +165,11 @@ const luaV_finishOp = function(L) { } }; -const RA = function(L, base, i) { +const RA = function (L, base, i) { return base + i.A; }; -const RB = function(L, base, i) { +const RB = function (L, base, i) { return base + i.B; }; @@ -166,548 +177,548 @@ const RB = function(L, base, i) { // return base + i.C; // }; -const RKB = function(L, base, k, i) { +const RKB = function (L, base, k, i) { return ISK(i.B) ? k[INDEXK(i.B)] : L.stack[base + i.B]; }; -const RKC = function(L, base, k, i) { +const RKC = function (L, base, k, i) { return ISK(i.C) ? k[INDEXK(i.C)] : L.stack[base + i.C]; }; -const luaV_execute = function(L) { +const luaV_execute = function (L) { let ci = L.ci; ci.callstatus |= lstate.CIST_FRESH; newframe: - for (;;) { - lua_assert(ci === L.ci); - let cl = ci.func.value; - let k = cl.p.k; - let base = ci.l_base; + for (; ;) { + lua_assert(ci === L.ci); + let cl = ci.func.value; + let k = cl.p.k; + let base = ci.l_base; - let i = ci.l_code[ci.l_savedpc++]; + let i = ci.l_code[ci.l_savedpc++]; - if (L.hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) { - ldebug.luaG_traceexec(L); - } + if (L.hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) { + ldebug.luaG_traceexec(L); + } - let ra = RA(L, base, i); - let opcode = i.opcode; + let ra = RA(L, base, i); + let opcode = i.opcode; - switch (opcode) { - case OP_MOVE: { - lobject.setobjs2s(L, ra, RB(L, base, i)); - break; - } - case OP_LOADK: { - let konst = k[i.Bx]; - lobject.setobj2s(L, ra, konst); - break; - } - case OP_LOADKX: { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); - let konst = k[ci.l_code[ci.l_savedpc++].Ax]; - lobject.setobj2s(L, ra, konst); - break; - } - case OP_LOADBOOL: { - L.stack[ra].setbvalue(i.B !== 0); + switch (opcode) { + case OP_MOVE: { + lobject.setobjs2s(L, ra, RB(L, base, i)); + break; + } + case OP_LOADK: { + let konst = k[i.Bx]; + lobject.setobj2s(L, ra, konst); + break; + } + case OP_LOADKX: { + lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); + let konst = k[ci.l_code[ci.l_savedpc++].Ax]; + lobject.setobj2s(L, ra, konst); + break; + } + case OP_LOADBOOL: { + L.stack[ra].setbvalue(i.B !== 0); - if (i.C !== 0) - ci.l_savedpc++; /* skip next instruction (if C) */ + if (i.C !== 0) + ci.l_savedpc++; /* skip next instruction (if C) */ - break; - } - case OP_LOADNIL: { - for (let j = 0; j <= i.B; j++) - L.stack[ra + j].setnilvalue(); - break; - } - case OP_GETUPVAL: { - let b = i.B; - lobject.setobj2s(L, ra, cl.upvals[b]); - break; - } - case OP_GETTABUP: { - let upval = cl.upvals[i.B]; - let rc = RKC(L, base, k, i); - luaV_gettable(L, upval, rc, ra); - break; - } - case OP_GETTABLE: { - let rb = L.stack[RB(L, base, i)]; - let rc = RKC(L, base, k, i); - luaV_gettable(L, rb, rc, ra); - break; - } - case OP_SETTABUP: { - let upval = cl.upvals[i.A]; - let rb = RKB(L, base, k, i); - let rc = RKC(L, base, k, i); - settable(L, upval, rb, rc); - break; - } - case OP_SETUPVAL: { - let uv = cl.upvals[i.B]; - uv.setfrom(L.stack[ra]); - break; - } - case OP_SETTABLE: { - let table = L.stack[ra]; - let key = RKB(L, base, k, i); - let v = RKC(L, base, k, i); + break; + } + case OP_LOADNIL: { + for (let j = 0; j <= i.B; j++) + L.stack[ra + j].setnilvalue(); + break; + } + case OP_GETUPVAL: { + let b = i.B; + lobject.setobj2s(L, ra, cl.upvals[b]); + break; + } + case OP_GETTABUP: { + let upval = cl.upvals[i.B]; + let rc = RKC(L, base, k, i); + luaV_gettable(L, upval, rc, ra); + break; + } + case OP_GETTABLE: { + let rb = L.stack[RB(L, base, i)]; + let rc = RKC(L, base, k, i); + luaV_gettable(L, rb, rc, ra); + break; + } + case OP_SETTABUP: { + let upval = cl.upvals[i.A]; + let rb = RKB(L, base, k, i); + let rc = RKC(L, base, k, i); + settable(L, upval, rb, rc); + break; + } + case OP_SETUPVAL: { + let uv = cl.upvals[i.B]; + uv.setfrom(L.stack[ra]); + break; + } + case OP_SETTABLE: { + let table = L.stack[ra]; + let key = RKB(L, base, k, i); + let v = RKC(L, base, k, i); - settable(L, table, key, v); - break; - } - case OP_NEWTABLE: { - L.stack[ra].sethvalue(ltable.luaH_new(L)); - break; - } - case OP_SELF: { - let rb = RB(L, base, i); - let rc = RKC(L, base, k, i); - lobject.setobjs2s(L, ra + 1, rb); - luaV_gettable(L, L.stack[rb], rc, ra); - break; - } - case OP_ADD: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue((op1.value + op2.value)|0); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 + numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_ADD); + settable(L, table, key, v); + break; } - break; - } - case OP_SUB: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue((op1.value - op2.value)|0); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 - numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SUB); + case OP_NEWTABLE: { + L.stack[ra].sethvalue(ltable.luaH_new(L)); + break; } - break; - } - case OP_MUL: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue(luaV_imul(op1.value, op2.value)); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 * numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MUL); + case OP_SELF: { + let rb = RB(L, base, i); + let rc = RKC(L, base, k, i); + lobject.setobjs2s(L, ra + 1, rb); + luaV_gettable(L, L.stack[rb], rc, ra); + break; } - break; - } - case OP_MOD: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue(luaV_mod(L, op1.value, op2.value)); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(luai_nummod(L, numberop1, numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MOD); + case OP_ADD: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue((op1.value + op2.value) | 0); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 + numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_ADD); + } + break; } - break; - } - case OP_POW: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(Math.pow(numberop1, numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_POW); + case OP_SUB: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue((op1.value - op2.value) | 0); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 - numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SUB); + } + break; } - break; - } - case OP_DIV: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 / numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_DIV); + case OP_MUL: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue(luaV_imul(op1.value, op2.value)); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 * numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MUL); + } + break; } - break; - } - case OP_IDIV: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue(luaV_div(L, op1.value, op2.value)); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(Math.floor(numberop1 / numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_IDIV); + case OP_MOD: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue(luaV_mod(L, op1.value, op2.value)); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(luai_nummod(L, numberop1, numberop2)); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MOD); + } + break; } - break; - } - case OP_BAND: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(numberop1 & numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BAND); + case OP_POW: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(Math.pow(numberop1, numberop2)); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_POW); + } + break; } - break; - } - case OP_BOR: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(numberop1 | numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BOR); + case OP_DIV: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 / numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_DIV); + } + break; } - break; - } - case OP_BXOR: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(numberop1 ^ numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BXOR); + case OP_IDIV: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue(luaV_div(L, op1.value, op2.value)); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(Math.floor(numberop1 / numberop2)); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_IDIV); + } + break; } - break; - } - case OP_SHL: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(luaV_shiftl(numberop1, numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHL); + case OP_BAND: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(numberop1 & numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BAND); + } + break; } - break; - } - case OP_SHR: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(luaV_shiftl(numberop1, -numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHR); + case OP_BOR: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(numberop1 | numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BOR); + } + break; } - break; - } - case OP_UNM: { - let op = L.stack[RB(L, base, i)]; - let numberop; - - if (op.ttisinteger()) { - L.stack[ra].setivalue((-op.value)|0); - } else if ((numberop = tonumber(op)) !== false) { - L.stack[ra].setfltvalue(-numberop); - } else { - ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_UNM); + case OP_BXOR: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(numberop1 ^ numberop2); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BXOR); + } + break; } - break; - } - case OP_BNOT: { - let op = L.stack[RB(L, base, i)]; + case OP_SHL: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(luaV_shiftl(numberop1, numberop2)); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHL); + } + break; + } + case OP_SHR: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(luaV_shiftl(numberop1, -numberop2)); + } else { + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHR); + } + break; + } + case OP_UNM: { + let op = L.stack[RB(L, base, i)]; + let numberop; + + if (op.ttisinteger()) { + L.stack[ra].setivalue((-op.value) | 0); + } else if ((numberop = tonumber(op)) !== false) { + L.stack[ra].setfltvalue(-numberop); + } else { + ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_UNM); + } + break; + } + case OP_BNOT: { + let op = L.stack[RB(L, base, i)]; - if (op.ttisinteger()) { - L.stack[ra].setivalue(~op.value); - } else { - ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_BNOT); + if (op.ttisinteger()) { + L.stack[ra].setivalue(~op.value); + } else { + ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_BNOT); + } + break; } - break; - } - case OP_NOT: { - let op = L.stack[RB(L, base, i)]; - L.stack[ra].setbvalue(op.l_isfalse()); - break; - } - case OP_LEN: { - luaV_objlen(L, L.stack[ra], L.stack[RB(L, base, i)]); - break; - } - case OP_CONCAT: { - let b = i.B; - let c = i.C; - L.top = base + c + 1; /* mark the end of concat operands */ - luaV_concat(L, c - b + 1); - let rb = base + b; - lobject.setobjs2s(L, ra, rb); - ldo.adjust_top(L, ci.top); /* restore top */ - break; - } - case OP_JMP: { - dojump(L, ci, i, 0); - break; - } - case OP_EQ: { - if (luaV_equalobj(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_LT: { - if (luaV_lessthan(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_LE: { - if (luaV_lessequal(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_TEST: { - if (i.C ? L.stack[ra].l_isfalse() : !L.stack[ra].l_isfalse()) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_TESTSET: { - let rbIdx = RB(L, base, i); - let rb = L.stack[rbIdx]; - if (i.C ? rb.l_isfalse() : !rb.l_isfalse()) - ci.l_savedpc++; - else { - lobject.setobjs2s(L, ra, rbIdx); - donextjump(L, ci); + case OP_NOT: { + let op = L.stack[RB(L, base, i)]; + L.stack[ra].setbvalue(op.l_isfalse()); + break; } - break; - } - case OP_CALL: { - let b = i.B; - let nresults = i.C - 1; - if (b !== 0) ldo.adjust_top(L, ra+b); /* else previous instruction set top */ - if (ldo.luaD_precall(L, ra, nresults)) { - if (nresults >= 0) - ldo.adjust_top(L, ci.top); /* adjust results */ - } else { - ci = L.ci; - continue newframe; + case OP_LEN: { + luaV_objlen(L, L.stack[ra], L.stack[RB(L, base, i)]); + break; + } + case OP_CONCAT: { + let b = i.B; + let c = i.C; + L.top = base + c + 1; /* mark the end of concat operands */ + luaV_concat(L, c - b + 1); + let rb = base + b; + lobject.setobjs2s(L, ra, rb); + ldo.adjust_top(L, ci.top); /* restore top */ + break; + } + case OP_JMP: { + dojump(L, ci, i, 0); + break; + } + case OP_EQ: { + if (luaV_equalobj(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_LT: { + if (luaV_lessthan(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_LE: { + if (luaV_lessequal(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_TEST: { + if (i.C ? L.stack[ra].l_isfalse() : !L.stack[ra].l_isfalse()) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_TESTSET: { + let rbIdx = RB(L, base, i); + let rb = L.stack[rbIdx]; + if (i.C ? rb.l_isfalse() : !rb.l_isfalse()) + ci.l_savedpc++; + else { + lobject.setobjs2s(L, ra, rbIdx); + donextjump(L, ci); + } + break; } + case OP_CALL: { + let b = i.B; + let nresults = i.C - 1; + if (b !== 0) ldo.adjust_top(L, ra + b); /* else previous instruction set top */ + if (ldo.luaD_precall(L, ra, nresults)) { + if (nresults >= 0) + ldo.adjust_top(L, ci.top); /* adjust results */ + } else { + ci = L.ci; + continue newframe; + } - break; - } - case OP_TAILCALL: { - let b = i.B; - if (b !== 0) ldo.adjust_top(L, ra+b); /* else previous instruction set top */ - if (ldo.luaD_precall(L, ra, LUA_MULTRET)) { // JS function - } else { - /* tail call: put called frame (n) in place of caller one (o) */ - let nci = L.ci; - let oci = nci.previous; - let nfunc = nci.func; - let nfuncOff = nci.funcOff; - let ofuncOff = oci.funcOff; - let lim = nci.l_base + nfunc.value.p.numparams; - if (cl.p.p.length > 0) lfunc.luaF_close(L, oci.l_base); - for (let aux = 0; nfuncOff + aux < lim; aux++) - lobject.setobjs2s(L, ofuncOff + aux, nfuncOff + aux); - oci.l_base = ofuncOff + (nci.l_base - nfuncOff); - oci.top = ofuncOff + (L.top - nfuncOff); - ldo.adjust_top(L, oci.top); /* correct top */ - oci.l_code = nci.l_code; - oci.l_savedpc = nci.l_savedpc; - oci.callstatus |= lstate.CIST_TAIL; - oci.next = null; - ci = L.ci = oci; - - lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); + break; + } + case OP_TAILCALL: { + let b = i.B; + if (b !== 0) ldo.adjust_top(L, ra + b); /* else previous instruction set top */ + if (ldo.luaD_precall(L, ra, LUA_MULTRET)) { // JS function + } else { + /* tail call: put called frame (n) in place of caller one (o) */ + let nci = L.ci; + let oci = nci.previous; + let nfunc = nci.func; + let nfuncOff = nci.funcOff; + let ofuncOff = oci.funcOff; + let lim = nci.l_base + nfunc.value.p.numparams; + if (cl.p.p.length > 0) lfunc.luaF_close(L, oci.l_base); + for (let aux = 0; nfuncOff + aux < lim; aux++) + lobject.setobjs2s(L, ofuncOff + aux, nfuncOff + aux); + oci.l_base = ofuncOff + (nci.l_base - nfuncOff); + oci.top = ofuncOff + (L.top - nfuncOff); + ldo.adjust_top(L, oci.top); /* correct top */ + oci.l_code = nci.l_code; + oci.l_savedpc = nci.l_savedpc; + oci.callstatus |= lstate.CIST_TAIL; + oci.next = null; + ci = L.ci = oci; + + lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); + + continue newframe; + } + break; + } + case OP_RETURN: { + if (cl.p.p.length > 0) lfunc.luaF_close(L, base); + let b = ldo.luaD_poscall(L, ci, ra, (i.B !== 0 ? i.B - 1 : L.top - ra)); + if (ci.callstatus & lstate.CIST_FRESH) + return; /* external invocation: return */ + /* invocation via reentry: continue execution */ + ci = L.ci; + if (b) ldo.adjust_top(L, ci.top); + lua_assert(ci.callstatus & lstate.CIST_LUA); + lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); continue newframe; } - break; - } - case OP_RETURN: { - if (cl.p.p.length > 0) lfunc.luaF_close(L, base); - let b = ldo.luaD_poscall(L, ci, ra, (i.B !== 0 ? i.B - 1 : L.top - ra)); - - if (ci.callstatus & lstate.CIST_FRESH) - return; /* external invocation: return */ - /* invocation via reentry: continue execution */ - ci = L.ci; - if (b) ldo.adjust_top(L, ci.top); - lua_assert(ci.callstatus & lstate.CIST_LUA); - lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); - continue newframe; - } - case OP_FORLOOP: { - if (L.stack[ra].ttisinteger()) { /* integer loop? */ - let step = L.stack[ra + 2].value; - let idx = (L.stack[ra].value + step)|0; - let limit = L.stack[ra + 1].value; - - if (0 < step ? idx <= limit : limit <= idx) { - ci.l_savedpc += i.sBx; - L.stack[ra].chgivalue(idx); /* update internal index... */ - L.stack[ra + 3].setivalue(idx); + case OP_FORLOOP: { + if (L.stack[ra].ttisinteger()) { /* integer loop? */ + let step = L.stack[ra + 2].value; + let idx = (L.stack[ra].value + step) | 0; + let limit = L.stack[ra + 1].value; + + if (0 < step ? idx <= limit : limit <= idx) { + ci.l_savedpc += i.sBx; + L.stack[ra].chgivalue(idx); /* update internal index... */ + L.stack[ra + 3].setivalue(idx); + } + } else { /* floating loop */ + let step = L.stack[ra + 2].value; + let idx = L.stack[ra].value + step; + let limit = L.stack[ra + 1].value; + + if (0 < step ? idx <= limit : limit <= idx) { + ci.l_savedpc += i.sBx; + L.stack[ra].chgfltvalue(idx); /* update internal index... */ + L.stack[ra + 3].setfltvalue(idx); + } } - } else { /* floating loop */ - let step = L.stack[ra + 2].value; - let idx = L.stack[ra].value + step; - let limit = L.stack[ra + 1].value; - - if (0 < step ? idx <= limit : limit <= idx) { - ci.l_savedpc += i.sBx; - L.stack[ra].chgfltvalue(idx); /* update internal index... */ - L.stack[ra + 3].setfltvalue(idx); + break; + } + case OP_FORPREP: { + let init = L.stack[ra]; + let plimit = L.stack[ra + 1]; + let pstep = L.stack[ra + 2]; + let forlim; + + if (init.ttisinteger() && pstep.ttisinteger() && (forlim = forlimit(plimit, pstep.value))) { + /* all values are integer */ + let initv = forlim.stopnow ? 0 : init.value; + plimit.value = forlim.ilimit; + init.value = (initv - pstep.value) | 0; + } else { /* try making all values floats */ + let nlimit, nstep, ninit; + if ((nlimit = tonumber(plimit)) === false) + ldebug.luaG_runerror(L, to_luastring('\'for\' limit must be a number', true)); + L.stack[ra + 1].setfltvalue(nlimit); + if ((nstep = tonumber(pstep)) === false) + ldebug.luaG_runerror(L, to_luastring('\'for\' step must be a number', true)); + L.stack[ra + 2].setfltvalue(nstep); + if ((ninit = tonumber(init)) === false) + ldebug.luaG_runerror(L, to_luastring('\'for\' initial value must be a number', true)); + L.stack[ra].setfltvalue(ninit - nstep); } + + ci.l_savedpc += i.sBx; + break; } - break; - } - case OP_FORPREP: { - let init = L.stack[ra]; - let plimit = L.stack[ra + 1]; - let pstep = L.stack[ra + 2]; - let forlim; - - if (init.ttisinteger() && pstep.ttisinteger() && (forlim = forlimit(plimit, pstep.value))) { - /* all values are integer */ - let initv = forlim.stopnow ? 0 : init.value; - plimit.value = forlim.ilimit; - init.value = (initv - pstep.value)|0; - } else { /* try making all values floats */ - let nlimit, nstep, ninit; - if ((nlimit = tonumber(plimit)) === false) - ldebug.luaG_runerror(L, to_luastring("'for' limit must be a number", true)); - L.stack[ra + 1].setfltvalue(nlimit); - if ((nstep = tonumber(pstep)) === false) - ldebug.luaG_runerror(L, to_luastring("'for' step must be a number", true)); - L.stack[ra + 2].setfltvalue(nstep); - if ((ninit = tonumber(init)) === false) - ldebug.luaG_runerror(L, to_luastring("'for' initial value must be a number", true)); - L.stack[ra].setfltvalue(ninit - nstep); + case OP_TFORCALL: { + let cb = ra + 3; /* call base */ + lobject.setobjs2s(L, cb + 2, ra + 2); + lobject.setobjs2s(L, cb + 1, ra + 1); + lobject.setobjs2s(L, cb, ra); + ldo.adjust_top(L, cb + 3); /* func. + 2 args (state and index) */ + ldo.luaD_call(L, cb, i.C); + ldo.adjust_top(L, ci.top); + /* go straight to OP_TFORLOOP */ + i = ci.l_code[ci.l_savedpc++]; + ra = RA(L, base, i); + lua_assert(i.opcode === OP_TFORLOOP); } - - ci.l_savedpc += i.sBx; - break; - } - case OP_TFORCALL: { - let cb = ra + 3; /* call base */ - lobject.setobjs2s(L, cb+2, ra+2); - lobject.setobjs2s(L, cb+1, ra+1); - lobject.setobjs2s(L, cb, ra); - ldo.adjust_top(L, cb+3); /* func. + 2 args (state and index) */ - ldo.luaD_call(L, cb, i.C); - ldo.adjust_top(L, ci.top); - /* go straight to OP_TFORLOOP */ - i = ci.l_code[ci.l_savedpc++]; - ra = RA(L, base, i); - lua_assert(i.opcode === OP_TFORLOOP); - } - /* fall through */ - case OP_TFORLOOP: { - if (!L.stack[ra + 1].ttisnil()) { /* continue loop? */ - lobject.setobjs2s(L, ra, ra + 1); /* save control variable */ - ci.l_savedpc += i.sBx; /* jump back */ + /* fall through */ + case OP_TFORLOOP: { + if (!L.stack[ra + 1].ttisnil()) { /* continue loop? */ + lobject.setobjs2s(L, ra, ra + 1); /* save control variable */ + ci.l_savedpc += i.sBx; /* jump back */ + } + break; } - break; - } - case OP_SETLIST: { - let n = i.B; - let c = i.C; + case OP_SETLIST: { + let n = i.B; + let c = i.C; - if (n === 0) n = L.top - ra - 1; + if (n === 0) n = L.top - ra - 1; - if (c === 0) { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); - c = ci.l_code[ci.l_savedpc++].Ax; - } + if (c === 0) { + lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); + c = ci.l_code[ci.l_savedpc++].Ax; + } - let h = L.stack[ra].value; - let last = ((c - 1) * LFIELDS_PER_FLUSH) + n; + let h = L.stack[ra].value; + let last = ((c - 1) * LFIELDS_PER_FLUSH) + n; - for (; n > 0; n--) { - ltable.luaH_setint(h, last--, L.stack[ra + n]); + for (; n > 0; n--) { + ltable.luaH_setint(h, last--, L.stack[ra + n]); + } + ldo.adjust_top(L, ci.top); /* correct top (in case of previous open call) */ + break; } - ldo.adjust_top(L, ci.top); /* correct top (in case of previous open call) */ - break; - } - case OP_CLOSURE: { - let p = cl.p.p[i.Bx]; - let ncl = getcached(p, cl.upvals, L.stack, base); /* cached closure */ - if (ncl === null) /* no match? */ - pushclosure(L, p, cl.upvals, base, ra); /* create a new one */ - else - L.stack[ra].setclLvalue(ncl); - break; - } - case OP_VARARG: { - let b = i.B - 1; - let n = base - ci.funcOff - cl.p.numparams - 1; - let j; - - if (n < 0) /* less arguments than parameters? */ - n = 0; /* no vararg arguments */ - - if (b < 0) { - b = n; /* get all var. arguments */ - ldo.luaD_checkstack(L, n); - ldo.adjust_top(L, ra + n); + case OP_CLOSURE: { + let p = cl.p.p[i.Bx]; + let ncl = getcached(p, cl.upvals, L.stack, base); /* cached closure */ + if (ncl === null) /* no match? */ + pushclosure(L, p, cl.upvals, base, ra); /* create a new one */ + else + L.stack[ra].setclLvalue(ncl); + break; } + case OP_VARARG: { + let b = i.B - 1; + let n = base - ci.funcOff - cl.p.numparams - 1; + let j; + + if (n < 0) /* less arguments than parameters? */ + n = 0; /* no vararg arguments */ + + if (b < 0) { + b = n; /* get all var. arguments */ + ldo.luaD_checkstack(L, n); + ldo.adjust_top(L, ra + n); + } - for (j = 0; j < b && j < n; j++) - lobject.setobjs2s(L, ra + j, base - n + j); + for (j = 0; j < b && j < n; j++) + lobject.setobjs2s(L, ra + j, base - n + j); - for (; j < b; j++) /* complete required results with nil */ - L.stack[ra + j].setnilvalue(); - break; - } - case OP_EXTRAARG: { - throw Error("invalid opcode"); + for (; j < b; j++) /* complete required results with nil */ + L.stack[ra + j].setnilvalue(); + break; + } + case OP_EXTRAARG: { + throw Error('invalid opcode'); + } } } - } }; -const dojump = function(L, ci, i, e) { +const dojump = function (L, ci, i, e) { let a = i.A; if (a !== 0) lfunc.luaF_close(L, ci.l_base + a - 1); ci.l_savedpc += i.sBx + e; }; -const donextjump = function(L, ci) { +const donextjump = function (L, ci) { dojump(L, ci, ci.l_code[ci.l_savedpc], 1); }; -const luaV_lessthan = function(L, l, r) { +export const luaV_lessthan = function (L, l, r) { if (l.ttisnumber() && r.ttisnumber()) return LTnum(l, r) ? 1 : 0; else if (l.ttisstring() && r.ttisstring()) @@ -720,7 +731,7 @@ const luaV_lessthan = function(L, l, r) { } }; -const luaV_lessequal = function(L, l, r) { +export const luaV_lessequal = function (L, l, r) { let res; if (l.ttisnumber() && r.ttisnumber()) @@ -741,7 +752,7 @@ const luaV_lessequal = function(L, l, r) { return res ? 0 : 1; /* result is negated */ }; -const luaV_equalobj = function(L, t1, t2) { +export const luaV_equalobj = function (L, t1, t2) { if (t1.ttype() !== t2.ttype()) { /* not the same variant? */ if (t1.ttnov() !== t2.ttnov() || t1.ttnov() !== LUA_TNUMBER) return 0; /* only numbers can be equal with different variants */ @@ -754,7 +765,7 @@ const luaV_equalobj = function(L, t1, t2) { let tm; /* values have same type and same variant */ - switch(t1.ttype()) { + switch (t1.ttype()) { case LUA_TNIL: return 1; case LUA_TBOOLEAN: @@ -789,11 +800,11 @@ const luaV_equalobj = function(L, t1, t2) { return tv.l_isfalse() ? 0 : 1; }; -const luaV_rawequalobj = function(t1, t2) { +const luaV_rawequalobj = function (t1, t2) { return luaV_equalobj(null, t1, t2); }; -const forlimit = function(obj, step) { +const forlimit = function (obj, step) { let stopnow = false; let ilimit = luaV_tointeger(obj, step < 0 ? 2 : 1); if (ilimit === false) { @@ -822,7 +833,7 @@ const forlimit = function(obj, step) { ** mode === 1: takes the floor of the number ** mode === 2: takes the ceil of the number */ -const luaV_tointeger = function(obj, mode) { +const luaV_tointeger = function (obj, mode) { if (obj.ttisfloat()) { let n = obj.value; let f = Math.floor(n); @@ -846,11 +857,11 @@ const luaV_tointeger = function(obj, mode) { return false; }; -const tointeger = function(o) { +export const tointeger = function (o) { return o.ttisinteger() ? o.value : luaV_tointeger(o, 0); }; -const tonumber = function(o) { +export const tonumber = function (o) { if (o.ttnov() === LUA_TNUMBER) return o.value; @@ -868,14 +879,14 @@ const tonumber = function(o) { ** As fengari uses javascript numbers for both floats and integers and has ** correct semantics, we can just compare values. */ -const LTnum = function(l, r) { +const LTnum = function (l, r) { return l.value < r.value; }; /* ** Return 'l <= r', for numbers. */ -const LEnum = function(l, r) { +const LEnum = function (l, r) { return l.value <= r.value; }; @@ -883,7 +894,7 @@ const LEnum = function(l, r) { ** Compare two strings 'ls' x 'rs', returning an integer smaller-equal- ** -larger than zero if 'ls' is smaller-equal-larger than 'rs'. */ -const l_strcmp = function(ls, rs) { +const l_strcmp = function (ls, rs) { let l = luaS_hashlongstr(ls); let r = luaS_hashlongstr(rs); /* In fengari we assume string hash has same collation as byte values */ @@ -898,9 +909,9 @@ const l_strcmp = function(ls, rs) { /* ** Main operation 'ra' = #rb'. */ -const luaV_objlen = function(L, ra, rb) { +export const luaV_objlen = function (L, ra, rb) { let tm; - switch(rb.ttype()) { + switch (rb.ttype()) { case LUA_TTABLE: { let h = rb.value; tm = ltm.fasttm(L, h.metatable, ltm.TMS.TM_LEN); @@ -915,7 +926,7 @@ const luaV_objlen = function(L, ra, rb) { default: { tm = ltm.luaT_gettmbyobj(L, rb, ltm.TMS.TM_LEN); if (tm.ttisnil()) - ldebug.luaG_typeerror(L, rb, to_luastring("get length of", true)); + ldebug.luaG_typeerror(L, rb, to_luastring('get length of', true)); break; } } @@ -924,7 +935,7 @@ const luaV_objlen = function(L, ra, rb) { }; /* Shim taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul */ -const luaV_imul = Math.imul || function(a, b) { +const luaV_imul = Math.imul || function (a, b) { let aHi = (a >>> 16) & 0xffff; let aLo = a & 0xffff; let bHi = (b >>> 16) & 0xffff; @@ -936,27 +947,26 @@ const luaV_imul = Math.imul || function(a, b) { return ((aLo * bLo) + (((aHi * bLo + aLo * bHi) << 16) >>> 0) | 0); }; -const luaV_div = function(L, m, n) { +const luaV_div = function (L, m, n) { if (n === 0) - ldebug.luaG_runerror(L, to_luastring("attempt to divide by zero")); - return Math.floor(m / n)|0; + ldebug.luaG_runerror(L, to_luastring('attempt to divide by zero')); + return Math.floor(m / n) | 0; }; // % semantic on negative numbers is different in js -const luaV_mod = function(L, m, n) { +const luaV_mod = function (L, m, n) { if (n === 0) - ldebug.luaG_runerror(L, to_luastring("attempt to perform 'n%%0'")); - return (m - Math.floor(m / n) * n)|0; + ldebug.luaG_runerror(L, to_luastring('attempt to perform \'n%%0\'')); + return (m - Math.floor(m / n) * n) | 0; }; const NBITS = 32; -const luaV_shiftl = function(x, y) { +const luaV_shiftl = function (x, y) { if (y < 0) { /* shift right? */ if (y <= -NBITS) return 0; else return x >>> -y; - } - else { /* shift left */ + } else { /* shift left */ if (y >= NBITS) return 0; else return x << y; } @@ -967,7 +977,7 @@ const luaV_shiftl = function(x, y) { ** whether there is a cached closure with the same upvalues needed by ** new closure to be created. */ -const getcached = function(p, encup, stack, base) { +const getcached = function (p, encup, stack, base) { let c = p.cache; if (c !== null) { /* is there a cached closure? */ let uv = p.upvalues; @@ -985,7 +995,7 @@ const getcached = function(p, encup, stack, base) { ** create a new Lua closure, push it in the stack, and initialize ** its upvalues. */ -const pushclosure = function(L, p, encup, base, ra) { +const pushclosure = function (L, p, encup, base, ra) { let nup = p.upvalues.length; let uv = p.upvalues; let ncl = new lobject.LClosure(L, nup); @@ -1000,15 +1010,15 @@ const pushclosure = function(L, p, encup, base, ra) { p.cache = ncl; /* save it on cache for reuse */ }; -const cvt2str = function(o) { +export const cvt2str = function (o) { return o.ttisnumber(); }; -const cvt2num = function(o) { +const cvt2num = function (o) { return o.ttisstring(); }; -const tostring = function(L, i) { +const tostring = function (L, i) { let o = L.stack[i]; if (o.ttisstring()) return true; @@ -1021,15 +1031,15 @@ const tostring = function(L, i) { return false; }; -const isemptystr = function(o) { +const isemptystr = function (o) { return o.ttisstring() && o.vslen() === 0; }; /* copy strings in stack from top - n up to top - 1 to buffer */ -const copy2buff = function(L, top, n, buff) { +const copy2buff = function (L, top, n, buff) { let tl = 0; /* size already copied */ do { - let tv = L.stack[top-n]; + let tv = L.stack[top - n]; let l = tv.vslen(); /* length of string being copied */ let s = tv.svalue(); buff.set(s, tl); @@ -1041,21 +1051,21 @@ const copy2buff = function(L, top, n, buff) { ** Main operation for concatenation: concat 'total' values in the stack, ** from 'L->top - total' up to 'L->top - 1'. */ -const luaV_concat = function(L, total) { +export const luaV_concat = function (L, total) { lua_assert(total >= 2); do { let top = L.top; let n = 2; /* number of elements handled in this pass (at least 2) */ - if (!(L.stack[top-2].ttisstring() || cvt2str(L.stack[top-2])) || !tostring(L, top - 1)) { - ltm.luaT_trybinTM(L, L.stack[top-2], L.stack[top-1], L.stack[top-2], ltm.TMS.TM_CONCAT); - } else if (isemptystr(L.stack[top-1])) { + if (!(L.stack[top - 2].ttisstring() || cvt2str(L.stack[top - 2])) || !tostring(L, top - 1)) { + ltm.luaT_trybinTM(L, L.stack[top - 2], L.stack[top - 1], L.stack[top - 2], ltm.TMS.TM_CONCAT); + } else if (isemptystr(L.stack[top - 1])) { tostring(L, top - 2); - } else if (isemptystr(L.stack[top-2])) { + } else if (isemptystr(L.stack[top - 2])) { lobject.setobjs2s(L, top - 2, top - 1); } else { /* at least two non-empty string values; get as many as possible */ - let tl = L.stack[top-1].vslen(); + let tl = L.stack[top - 1].vslen(); /* collect total length and number of strings */ for (n = 1; n < total && tostring(L, top - n - 1); n++) { let l = L.stack[top - n - 1].vslen(); @@ -1068,14 +1078,14 @@ const luaV_concat = function(L, total) { } total -= n - 1; /* got 'n' strings to create 1 new */ /* popped 'n' strings and pushed one */ - for (; L.top > top-(n-1);) + for (; L.top > top - (n - 1);) delete L.stack[--L.top]; } while (total > 1); /* repeat until only 1 result left */ }; const MAXTAGLOOP = 2000; -const luaV_gettable = function(L, t, key, ra) { +export const luaV_gettable = function (L, t, key, ra) { for (let loop = 0; loop < MAXTAGLOOP; loop++) { let tm; @@ -1105,10 +1115,10 @@ const luaV_gettable = function(L, t, key, ra) { t = tm; /* else try to access 'tm[key]' */ } - ldebug.luaG_runerror(L, to_luastring("'__index' chain too long; possible loop", true)); + ldebug.luaG_runerror(L, to_luastring('\'__index\' chain too long; possible loop', true)); }; -const settable = function(L, t, key, val) { +export const settable = function (L, t, key, val) { for (let loop = 0; loop < MAXTAGLOOP; loop++) { let tm; if (t.ttistable()) { @@ -1132,26 +1142,5 @@ const settable = function(L, t, key, val) { t = tm; /* else repeat assignment over 'tm' */ } - ldebug.luaG_runerror(L, to_luastring("'__newindex' chain too long; possible loop", true)); + ldebug.luaG_runerror(L, to_luastring('\'__newindex\' chain too long; possible loop', true)); }; - - -module.exports.cvt2str = cvt2str; -module.exports.cvt2num = cvt2num; -module.exports.luaV_gettable = luaV_gettable; -module.exports.luaV_concat = luaV_concat; -module.exports.luaV_div = luaV_div; -module.exports.luaV_equalobj = luaV_equalobj; -module.exports.luaV_execute = luaV_execute; -module.exports.luaV_finishOp = luaV_finishOp; -module.exports.luaV_imul = luaV_imul; -module.exports.luaV_lessequal = luaV_lessequal; -module.exports.luaV_lessthan = luaV_lessthan; -module.exports.luaV_mod = luaV_mod; -module.exports.luaV_objlen = luaV_objlen; -module.exports.luaV_rawequalobj = luaV_rawequalobj; -module.exports.luaV_shiftl = luaV_shiftl; -module.exports.luaV_tointeger = luaV_tointeger; -module.exports.settable = settable; -module.exports.tointeger = tointeger; -module.exports.tonumber = tonumber; diff --git a/src/lzio.js b/src/lzio.js index b9081a7a..306a8475 100644 --- a/src/lzio.js +++ b/src/lzio.js @@ -1,6 +1,4 @@ -"use strict"; - -const { lua_assert } = require("./llimits.js"); +import {lua_assert} from "./llimits.js"; class MBuffer { constructor() { @@ -28,10 +26,10 @@ const luaZ_resizebuffer = function(L, buff, size) { buff.buffer = newbuff; }; -class ZIO { +export class ZIO { constructor(L, reader, data) { this.L = L; /* Lua state (for reader) */ - lua_assert(typeof reader == "function", "ZIO requires a reader"); + lua_assert(typeof reader == 'function', 'ZIO requires a reader'); this.reader = reader; /* reader function */ this.data = data; /* additional data */ this.n = 0; /* bytes still unread */ @@ -50,7 +48,7 @@ const luaZ_fill = function(z) { let buff = z.reader(z.L, z.data); if (buff === null) return EOZ; - lua_assert(buff instanceof Uint8Array, "Should only load binary of array of bytes"); + lua_assert(buff instanceof Uint8Array, 'Should only load binary of array of bytes'); let size = buff.length; if (size === 0) return EOZ; @@ -84,13 +82,3 @@ const luaZ_read = function(z, b, b_offset, n) { return 0; }; - -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; -module.exports.luaZ_resetbuffer = luaZ_resetbuffer; -module.exports.luaZ_resizebuffer = luaZ_resizebuffer; -module.exports.MBuffer = MBuffer; -module.exports.ZIO = ZIO; diff --git a/test/defs.test.js b/test/defs.test.js index ead9a7b4..5ed17f5f 100644 --- a/test/defs.test.js +++ b/test/defs.test.js @@ -1,48 +1,47 @@ -const defs = require('../src/defs.js'); - +import { luastring_of, to_luastring, to_jsstring } from '../src/defs.js'; const unicode_tests = [ { - description: "Convert normal ascii string", - literal: "foo", - byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)) + description: 'Convert normal ascii string', + literal: 'foo', + byte_array: luastring_of('f'.charCodeAt(0), 'o'.charCodeAt(0), 'o'.charCodeAt(0)) }, { - description: "Convert ascii string containing null byte", - literal: "fo\0o", - byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)) + description: 'Convert ascii string containing null byte', + literal: 'fo\0o', + byte_array: luastring_of('f'.charCodeAt(0), 'o'.charCodeAt(0), 0, 'o'.charCodeAt(0)) }, { - description: "Convert string with BMP unicode chars", - literal: "Café", - byte_array: defs.luastring_of(67, 97, 102, 195, 169) + description: 'Convert string with BMP unicode chars', + literal: 'Café', + byte_array: luastring_of(67, 97, 102, 195, 169) }, { - description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)", - literal: "", - byte_array: defs.luastring_of(239, 163, 191) + description: 'Convert string with codepoint in PUA (U+E000 to U+F8FF)', + literal: '', + byte_array: luastring_of(239, 163, 191) }, { - description: "Convert string with surrogate pair", - literal: "❤️🍾", - byte_array: defs.luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) + description: 'Convert string with surrogate pair', + literal: '❤️🍾', + byte_array: luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) }, { - description: "Convert string with broken surrogate pair", - literal: "\uD800a", - byte_array: defs.luastring_of(237, 160, 128, 97) + description: 'Convert string with broken surrogate pair', + literal: '\uD800a', + byte_array: luastring_of(237, 160, 128, 97) }, { - description: "Convert string with broken surrogate pair at end of string", - literal: "\uD823", - byte_array: defs.luastring_of(237, 160, 163) + description: 'Convert string with broken surrogate pair at end of string', + literal: '\uD823', + byte_array: luastring_of(237, 160, 163) } ]; describe('to_luastring', () => { unicode_tests.forEach((v) => { test(v.description, () => { - expect(defs.to_luastring(v.literal)).toEqual(v.byte_array); + expect(to_luastring(v.literal)).toEqual(v.byte_array); }); }); }); @@ -50,45 +49,45 @@ describe('to_luastring', () => { describe('to_jsstring', () => { unicode_tests.forEach((v) => { test(v.description, () => { - expect(defs.to_jsstring(v.byte_array)).toEqual(v.literal); + expect(to_jsstring(v.byte_array)).toEqual(v.literal); }); }); }); describe('to_jsstring fails on invalid unicode', () => { - test("non-utf8 char", () => { - expect(() => defs.to_jsstring(defs.luastring_of(165))) - .toThrow(RangeError); + test('non-utf8 char', () => { + expect(() => to_jsstring(luastring_of(165))) + .toThrowError(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(208, 60))) - .toThrow(RangeError); + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(208, 60))) + .toThrowError(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(225, 60, 145))) - .toThrow(RangeError); + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(225, 60, 145))) + .toThrowError(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(225, 145, 60))) - .toThrow(RangeError); + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(225, 145, 60))) + .toThrowError(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(242, 60, 145, 145))) - .toThrow(RangeError); + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(242, 60, 145, 145))) + .toThrowError(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 60, 145))) - .toThrow(RangeError); + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(242, 145, 60, 145))) + .toThrowError(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 145, 60))) - .toThrow(RangeError); + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(242, 145, 145, 60))) + .toThrowError(RangeError); }); }); diff --git a/test/lapi.test.js b/test/lapi.test.js index 399155a8..209623d0 100644 --- a/test/lapi.test.js +++ b/test/lapi.test.js @@ -1,35 +1,35 @@ -"use strict"; +'use strict'; -const {toByteCode} = require("./tests.js"); +const {toByteCode} = require('./tests.js'); const lua = require('../src/lua.js'); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +const lauxlib = require('../src/lauxlib.js'); +const {to_luastring} = require('../src/fengaricore.js'); test('luaL_newstate, lua_pushnil, luaL_typename', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_pushnil(L); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("nil")); + .toEqual(to_luastring('nil')); }); test('lua_pushnumber', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_pushnumber(L, 10.5); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("number")); + .toEqual(to_luastring('number')); expect(lua.lua_tonumber(L, -1)) .toBe(10.5); @@ -38,14 +38,14 @@ test('lua_pushnumber', () => { test('lua_pushinteger', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_pushinteger(L, 10); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("number")); + .toEqual(to_luastring('number')); expect(lua.lua_tointeger(L, -1)) .toBe(10); @@ -54,30 +54,30 @@ test('lua_pushinteger', () => { test('lua_pushliteral', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua.lua_pushliteral(L, "hello"); + lua.lua_pushliteral(L, 'hello'); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("string")); + .toEqual(to_luastring('string')); expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_pushboolean', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_pushboolean(L, true); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("boolean")); + .toEqual(to_luastring('boolean')); expect(lua.lua_toboolean(L, -1)) .toBe(true); @@ -86,47 +86,47 @@ test('lua_pushboolean', () => { test('lua_pushvalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua.lua_pushliteral(L, "hello"); + lua.lua_pushliteral(L, 'hello'); lua.lua_pushvalue(L, -1); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("string")); + .toEqual(to_luastring('string')); expect(lauxlib.luaL_typename(L, -2)) - .toEqual(to_luastring("string")); + .toEqual(to_luastring('string')); expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); expect(lua.lua_tojsstring(L, -2)) - .toBe("hello"); + .toBe('hello'); }); test('lua_pushjsclosure', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { return 0; }; - lua.lua_pushliteral(L, "a value associated to the C closure"); + lua.lua_pushliteral(L, 'a value associated to the C closure'); lua.lua_pushjsclosure(L, fn, 1); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("function")); + .toEqual(to_luastring('function')); }); test('lua_pushjsfunction', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { @@ -136,17 +136,17 @@ test('lua_pushjsfunction', () => { } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("function")); + .toEqual(to_luastring('function')); }); test('lua_call (calling a light JS function)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { - lua.lua_pushliteral(L, "hello"); + lua.lua_pushliteral(L, 'hello'); return 1; }; lua.lua_pushjsfunction(L, fn); @@ -154,36 +154,36 @@ test('lua_call (calling a light JS function)', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_call (calling a JS closure)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { lua.lua_pushstring(L, lua.lua_tostring(L, lua.lua_upvalueindex(1))); return 1; }; - lua.lua_pushliteral(L, "upvalue hello!"); + lua.lua_pushliteral(L, 'upvalue hello!'); lua.lua_pushjsclosure(L, fn, 1); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("upvalue hello!"); + .toBe('upvalue hello!'); }); test('lua_pcall (calling a light JS function)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { - lua.lua_pushliteral(L, "hello"); + lua.lua_pushliteral(L, 'hello'); return 1; }; lua.lua_pushjsfunction(L, fn); @@ -191,17 +191,17 @@ test('lua_pcall (calling a light JS function)', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_pcall that breaks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { - return "undefined_value"; + return 'undefined_value'; }; lua.lua_pushjsfunction(L, fn); expect(lua.lua_pcall(L, 0, 1, 0)).not.toBe(lua.LUA_OK); @@ -211,22 +211,22 @@ test('lua_pcall that breaks', () => { test('lua_pop', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua.lua_pushliteral(L, "hello"); - lua.lua_pushliteral(L, "world"); + lua.lua_pushliteral(L, 'hello'); + lua.lua_pushliteral(L, 'world'); lua.lua_pop(L, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_load with no chunkname', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_load(L, function(L, s) { @@ -234,18 +234,18 @@ test('lua_load with no chunkname', () => { s.code = null; return r; }, { - code: to_luastring("return 'hello'") + code: to_luastring('return \'hello\'') }, null, null); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_load and lua_call it', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let luaCode = ` @@ -257,37 +257,37 @@ test('lua_load and lua_call it', () => { let r = s.bc; s.bc = null; return r; - }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary")); + }, {bc: bc}, to_luastring('test-lua_load'), to_luastring('binary')); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("JS > Lua > JS \\o/"); + .toBe('JS > Lua > JS \\o/'); }); test('lua script reads js upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let luaCode = ` return js .. " world" `; expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pushliteral(L, "hello"); - lua.lua_setglobal(L, to_luastring("js")); + lua.lua_pushliteral(L, 'hello'); + lua.lua_setglobal(L, to_luastring('js')); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('lua_createtable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_createtable(L, 3, 3); @@ -299,7 +299,7 @@ test('lua_createtable', () => { test('lua_newtable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_newtable(L); @@ -311,28 +311,28 @@ test('lua_newtable', () => { test('lua_settable, lua_gettable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_newtable(L); - lua.lua_pushliteral(L, "key"); - lua.lua_pushliteral(L, "value"); + lua.lua_pushliteral(L, 'key'); + lua.lua_pushliteral(L, 'value'); lua.lua_settable(L, -3); - lua.lua_pushliteral(L, "key"); + lua.lua_pushliteral(L, 'key'); lua.lua_gettable(L, -2); } expect(lua.lua_tojsstring(L, -1)) - .toBe("value"); + .toBe('value'); }); describe('lua_atnativeerror', () => { test('no native error handler', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let errob = {}; @@ -345,39 +345,39 @@ describe('lua_atnativeerror', () => { test('native error handler returns string', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let errob = {}; lua.lua_atnativeerror(L, function(L) { let e = lua.lua_touserdata(L, 1); expect(e).toBe(errob); - lua.lua_pushstring(L, to_luastring("runtime error!")); + lua.lua_pushstring(L, to_luastring('runtime error!')); return 1; }); lua.lua_pushcfunction(L, function(L) { throw errob; }); expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN); - expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!"); + expect(lua.lua_tojsstring(L, -1)).toBe('runtime error!'); }); test('native error handler rethrows lua error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let errob = {}; lua.lua_atnativeerror(L, function(L) { let e = lua.lua_touserdata(L, 1); expect(e).toBe(errob); - lauxlib.luaL_error(L, to_luastring("runtime error!")); + lauxlib.luaL_error(L, to_luastring('runtime error!')); }); lua.lua_pushcfunction(L, function(L) { throw errob; }); expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN); - expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!"); + expect(lua.lua_tojsstring(L, -1)).toBe('runtime error!'); }); }); @@ -385,7 +385,7 @@ describe('lua_atnativeerror', () => { describe('lua_len', () => { test('table with two potential boundaries', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_createtable(L); @@ -403,7 +403,7 @@ describe('lua_len', () => { test('pathological case', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua.lua_createtable(L); diff --git a/test/lauxlib.test.js b/test/lauxlib.test.js index 62198ac4..dbf8c9ca 100644 --- a/test/lauxlib.test.js +++ b/test/lauxlib.test.js @@ -1,16 +1,16 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +const lauxlib = require('../src/lauxlib.js'); +const {to_luastring} = require('../src/fengaricore.js'); test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua.lua_pushstring(L, to_luastring("hello references!")); + lua.lua_pushstring(L, to_luastring('hello references!')); let r = lauxlib.luaL_ref(L, lua.LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, r); // pushes a value associated with the reference @@ -18,5 +18,5 @@ test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello references!"); + .toBe('hello references!'); }); diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js index dc30a984..43ab869a 100644 --- a/test/lbaselib.test.js +++ b/test/lbaselib.test.js @@ -1,14 +1,14 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('print', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` print("hello", "world", 123) @@ -23,7 +23,7 @@ test('print', () => { test('setmetatable, getmetatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -45,7 +45,7 @@ test('setmetatable, getmetatable', () => { } expect(lua.lua_tojsstring(L, -2)) - .toBe("hello"); + .toBe('hello'); expect(lua.lua_istable(L, -1)).toBe(true); }); @@ -53,7 +53,7 @@ test('setmetatable, getmetatable', () => { test('rawequal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -83,7 +83,7 @@ test('rawequal', () => { test('rawset, rawget', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -108,22 +108,22 @@ test('rawset, rawget', () => { } expect(lua.lua_tojsstring(L, -4)) - .toBe("hello"); + .toBe('hello'); expect(lua.lua_tojsstring(L, -3)) - .toBe("hello"); + .toBe('hello'); expect(lua.lua_tojsstring(L, -2)) - .toBe("bye"); + .toBe('bye'); expect(lua.lua_tojsstring(L, -1)) - .toBe("bye"); + .toBe('bye'); }); test('type', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return type(1), type(true), type("hello"), type({}), type(nil) @@ -135,25 +135,25 @@ test('type', () => { } expect(lua.lua_tojsstring(L, -5)) - .toBe("number"); + .toBe('number'); expect(lua.lua_tojsstring(L, -4)) - .toBe("boolean"); + .toBe('boolean'); expect(lua.lua_tojsstring(L, -3)) - .toBe("string"); + .toBe('string'); expect(lua.lua_tojsstring(L, -2)) - .toBe("table"); + .toBe('table'); expect(lua.lua_tojsstring(L, -1)) - .toBe("nil"); + .toBe('nil'); }); test('error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` error("you fucked up") @@ -170,7 +170,7 @@ test('error', () => { test('error, protected', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` error("you fucked up") @@ -187,7 +187,7 @@ test('error, protected', () => { test('pcall', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local willFail = function () @@ -208,7 +208,7 @@ test('pcall', () => { test('xpcall', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local willFail = function () @@ -233,7 +233,7 @@ test('xpcall', () => { test('ipairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, ['yo'] = 'lo'} @@ -257,7 +257,7 @@ test('ipairs', () => { test('select', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return {select('#', 1, 2, 3)}, {select(2, 1, 2, 3)}, {select(-2, 1, 2, 3)} @@ -281,7 +281,7 @@ test('select', () => { test('tonumber', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return tonumber('foo'), @@ -306,7 +306,7 @@ test('tonumber', () => { test('assert', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(1 < 0, "this doesn't makes sense") @@ -323,7 +323,7 @@ test('assert', () => { test('rawlen', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return rawlen({1, 2, 3}), rawlen('hello') @@ -341,7 +341,7 @@ test('rawlen', () => { test('next', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -370,7 +370,7 @@ test('next', () => { test('pairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -399,7 +399,7 @@ test('pairs', () => { test('pairs with __pairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 diff --git a/test/lcorolib.test.js b/test/lcorolib.test.js index e9ad8ed4..15a36ada 100644 --- a/test/lcorolib.test.js +++ b/test/lcorolib.test.js @@ -1,14 +1,14 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); const lstate = require('../src/lstate.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('coroutine.create, coroutine.yield, coroutine.resume', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function (start) @@ -34,7 +34,7 @@ test('coroutine.create, coroutine.yield, coroutine.resume', () => { test('coroutine.status', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function (start) @@ -60,16 +60,16 @@ test('coroutine.status', () => { } expect(lua.lua_tojsstring(L, -2)) - .toBe("suspended"); + .toBe('suspended'); expect(lua.lua_tojsstring(L, -1)) - .toBe("dead"); + .toBe('dead'); }); test('coroutine.isyieldable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function () @@ -93,7 +93,7 @@ test('coroutine.isyieldable', () => { test('coroutine.running', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local running, ismain @@ -119,7 +119,7 @@ test('coroutine.running', () => { test('coroutine.wrap', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.wrap(function (start) diff --git a/test/ldblib.test.js b/test/ldblib.test.js index ba68853a..82158143 100644 --- a/test/ldblib.test.js +++ b/test/ldblib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('debug.sethook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local result = "" @@ -31,13 +31,13 @@ test('debug.sethook', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("return count line count line count line call count line return count line count line call count line return count line count line call count line return count line "); + .toBe('return count line count line count line call count line return count line count line call count line return count line count line call count line return count line '); }); test('debug.gethook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local result = "" @@ -61,15 +61,15 @@ test('debug.gethook', () => { } expect(lua.lua_typename(L, lua.lua_type(L, -3))) - .toEqual(to_luastring("function")); - expect(lua.lua_tojsstring(L, -2)).toBe("crl"); + .toEqual(to_luastring('function')); + expect(lua.lua_tojsstring(L, -2)).toBe('crl'); expect(lua.lua_tointeger(L, -1)).toBe(1); }); test('debug.getlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local alocal = "alocal" @@ -97,12 +97,12 @@ test('debug.getlocal', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("alocal alocalanother anotherinfunction infunctionanotherin anotherin"); + .toBe('alocal alocalanother anotherinfunction infunctionanotherin anotherin'); }); test('debug.setlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local alocal = "alocal" @@ -138,7 +138,7 @@ test('debug.setlocal', () => { test('debug.upvalueid', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local upvalue = "upvalue" @@ -161,7 +161,7 @@ test('debug.upvalueid', () => { test('debug.upvaluejoin', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local upvalue1 = "upvalue1" @@ -186,13 +186,13 @@ test('debug.upvaluejoin', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("upvalue2"); + .toBe('upvalue2'); }); test('debug.traceback (with a global)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local trace @@ -213,7 +213,7 @@ test('debug.traceback (with a global)', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test")); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('traceback-test')); lua.lua_call(L, 0, -1); } @@ -236,7 +236,7 @@ test('debug.traceback (with a global)', () => { test('debug.traceback (with a upvalue)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local trace @@ -258,7 +258,7 @@ test('debug.traceback (with a upvalue)', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test")); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('traceback-test')); lua.lua_call(L, 0, -1); } @@ -280,7 +280,7 @@ test('debug.traceback (with a upvalue)', () => { test('debug.getinfo', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local alocal = function(p1, p2) end @@ -295,16 +295,16 @@ test('debug.getinfo', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("getinfo-test")); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('getinfo-test')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -8)).toBe(`[string "getinfo-test"]`); + expect(lua.lua_tojsstring(L, -8)).toBe('[string "getinfo-test"]'); expect(lua.lua_tointeger(L, -7)).toBe(0); - expect(lua.lua_tojsstring(L, -6)).toBe(`Lua`); + expect(lua.lua_tojsstring(L, -6)).toBe('Lua'); expect(lua.lua_tointeger(L, -5)).toBe(2); - expect(lua.lua_tojsstring(L, -4)).toBe(`[string "getinfo-test"]`); + expect(lua.lua_tojsstring(L, -4)).toBe('[string "getinfo-test"]'); expect(lua.lua_tointeger(L, -3)).toBe(1); - expect(lua.lua_tojsstring(L, -2)).toBe(`Lua`); + expect(lua.lua_tojsstring(L, -2)).toBe('Lua'); expect(lua.lua_tointeger(L, -1)).toBe(0); }); diff --git a/test/ldebug.test.js b/test/ldebug.test.js index d52cfcba..57d24d6e 100644 --- a/test/ldebug.test.js +++ b/test/ldebug.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -20,13 +20,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("attempt to get length of a boolean value (local 'a')"); + .toMatch('attempt to get length of a boolean value (local \'a\')'); }); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -39,13 +39,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("attempt to index a boolean value (local 'a')"); + .toMatch('attempt to index a boolean value (local \'a\')'); }); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -58,13 +58,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("attempt to index a boolean value (local 'a')"); + .toMatch('attempt to index a boolean value (local \'a\')'); }); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -77,13 +77,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("attempt to index a boolean value (local 'a')"); + .toMatch('attempt to index a boolean value (local \'a\')'); }); test('luaG_concaterror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return {} .. 'hello' @@ -95,13 +95,13 @@ test('luaG_concaterror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("attempt to concatenate a table value"); + .toMatch('attempt to concatenate a table value'); }); test('luaG_opinterror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return {} + 'hello' @@ -113,13 +113,13 @@ test('luaG_opinterror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("attempt to perform arithmetic on a table value"); + .toMatch('attempt to perform arithmetic on a table value'); }); test('luaG_tointerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return 123.5 & 12 @@ -131,5 +131,5 @@ test('luaG_tointerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch("number has no integer representation"); + .toMatch('number has no integer representation'); }); diff --git a/test/lexparse.test.js b/test/lexparse.test.js index a9407ed9..71176986 100644 --- a/test/lexparse.test.js +++ b/test/lexparse.test.js @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const lstring = require("../src/lstring.js"); -const {to_luastring} = require("../src/fengaricore.js"); +const lstring = require('../src/lstring.js'); +const {to_luastring} = require('../src/fengaricore.js'); // Roughly the same tests as test/lvm.js to cover all opcodes test('LOADK, RETURN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -22,18 +22,18 @@ test('LOADK, RETURN', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); }); test('MOVE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -47,18 +47,18 @@ test('MOVE', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); }); test('Binary op', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -72,7 +72,7 @@ test('Binary op', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -84,7 +84,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -98,7 +98,7 @@ test('Unary op, LOADBOOL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -110,7 +110,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -123,7 +123,7 @@ test('NEWTABLE', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -134,7 +134,7 @@ test('NEWTABLE', () => { test('CALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -152,7 +152,7 @@ test('CALL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -162,7 +162,7 @@ test('CALL', () => { test('Multiple return', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -184,7 +184,7 @@ test('Multiple return', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -196,7 +196,7 @@ test('Multiple return', () => { test('TAILCALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -212,7 +212,7 @@ test('TAILCALL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -223,7 +223,7 @@ test('TAILCALL', () => { test('VARARG', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (...) @@ -239,7 +239,7 @@ test('VARARG', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -251,7 +251,7 @@ test('VARARG', () => { test('LE, JMP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -265,7 +265,7 @@ test('LE, JMP', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -276,7 +276,7 @@ test('LE, JMP', () => { test('LT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -290,7 +290,7 @@ test('LT', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -301,7 +301,7 @@ test('LT', () => { test('EQ', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -315,7 +315,7 @@ test('EQ', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -326,7 +326,7 @@ test('EQ', () => { test('TESTSET (and)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -341,18 +341,18 @@ test('TESTSET (and)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('TESTSET (or)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -367,18 +367,18 @@ test('TESTSET (or)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('TEST (false)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -397,18 +397,18 @@ test('TEST (false)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("goodbye"); + expect(lua.lua_tojsstring(L, -1)).toBe('goodbye'); }); test('FORPREP, FORLOOP (int)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -426,7 +426,7 @@ test('FORPREP, FORLOOP (int)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -437,7 +437,7 @@ test('FORPREP, FORLOOP (int)', () => { test('FORPREP, FORLOOP (float)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -455,7 +455,7 @@ test('FORPREP, FORLOOP (float)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -466,7 +466,7 @@ test('FORPREP, FORLOOP (float)', () => { test('SETTABLE, GETTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -483,21 +483,21 @@ test('SETTABLE, GETTABLE', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SETUPVAL, GETUPVAL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = "hello" @@ -517,18 +517,18 @@ test('SETUPVAL, GETUPVAL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); + expect(lua.lua_tojsstring(L, -1)).toBe('world'); }); test('SETTABUP, GETTABUP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -545,21 +545,21 @@ test('SETTABUP, GETTABUP', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SELF', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -578,18 +578,18 @@ test('SELF', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -603,7 +603,7 @@ test('SETLIST', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -615,7 +615,7 @@ test('SETLIST', () => { test('Variable SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = function () @@ -633,7 +633,7 @@ test('Variable SETLIST', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -644,7 +644,7 @@ test('Variable SETLIST', () => { test('Long SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} @@ -658,7 +658,7 @@ test('Long SETLIST', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -670,7 +670,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local iterator = function (t, i) @@ -700,7 +700,7 @@ test('TFORCALL, TFORLOOP', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -711,7 +711,7 @@ test('TFORCALL, TFORLOOP', () => { test('LEN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[10000] = "foo"} @@ -727,7 +727,7 @@ test('LEN', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } @@ -740,7 +740,7 @@ test('LEN', () => { test('CONCAT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return "hello " .. 2 .. " you" @@ -752,10 +752,10 @@ test('CONCAT', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello 2 you'); }); diff --git a/test/lmathlib.test.js b/test/lmathlib.test.js index 0ee0b1c8..3e616f57 100644 --- a/test/lmathlib.test.js +++ b/test/lmathlib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.abs(-10), math.abs(-10.5), math.cos(10), math.tan(10), @@ -31,7 +31,7 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', test('math.ceil, math.floor', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.ceil(10.5), math.floor(10.5) @@ -49,7 +49,7 @@ test('math.ceil, math.floor', () => { test('math.deg, math.rad', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.deg(10), math.rad(10) @@ -67,7 +67,7 @@ test('math.deg, math.rad', () => { test('math.log', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.log(10), math.log(10, 2), math.log(10, 10) @@ -87,7 +87,7 @@ test('math.log', () => { /* Node.js 6 has incorrect results for Math.exp */ (parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.exp(10) @@ -104,7 +104,7 @@ test('math.log', () => { test('math.min, math.max', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.max(10, 5, 23), math.min(10, 5, 23) @@ -122,7 +122,7 @@ test('math.min, math.max', () => { test('math.random', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.random(), math.random(10, 15) @@ -148,7 +148,7 @@ test('math.random', () => { test('math.sqrt', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.sqrt(10) @@ -165,7 +165,7 @@ test('math.sqrt', () => { test('math.tointeger', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.tointeger('10') @@ -182,7 +182,7 @@ test('math.tointeger', () => { test('math.type', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.type(10), math.type(10.5), math.type('hello') @@ -193,15 +193,15 @@ test('math.type', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -3)).toBe("integer"); - expect(lua.lua_tojsstring(L, -2)).toBe("float"); + expect(lua.lua_tojsstring(L, -3)).toBe('integer'); + expect(lua.lua_tojsstring(L, -2)).toBe('float'); expect(lua.lua_tojsstring(L, -1)).toBe(null); }); test('math.ult', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.ult(5, 200) @@ -218,7 +218,7 @@ test('math.ult', () => { test('math.fmod', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.fmod(2,5) @@ -235,7 +235,7 @@ test('math.fmod', () => { test('math.modf', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.modf(3.4, 0.6) diff --git a/test/load.test.js b/test/load.test.js index e8f39ea4..af440ec9 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; -const {toByteCode} = require("./tests.js"); +const {toByteCode} = require('./tests.js'); const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('luaL_loadstring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -21,13 +21,13 @@ test('luaL_loadstring', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('load', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = load("return 'js running lua running lua'") @@ -39,13 +39,13 @@ test('load', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("js running lua running lua"); + .toBe('js running lua running lua'); }); test('undump empty string', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(load(string.dump(function() @@ -63,7 +63,7 @@ test('undump empty string', () => { test('luaL_loadbuffer', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -72,17 +72,17 @@ test('luaL_loadbuffer', () => { { lualib.luaL_openlibs(L); let bc = toByteCode(luaCode); - lauxlib.luaL_loadbuffer(L, bc, null, to_luastring("test")); + lauxlib.luaL_loadbuffer(L, bc, null, to_luastring('test')); lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); // TODO: test stdin test('loadfile', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = assert(loadfile("test/loadfile-test.lua")) @@ -94,13 +94,13 @@ test('loadfile', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('loadfile (binary)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = assert(loadfile("test/loadfile-test.bc")) @@ -112,13 +112,13 @@ test('loadfile (binary)', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('dofile', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return dofile("test/loadfile-test.lua") @@ -129,5 +129,5 @@ test('dofile', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); diff --git a/test/loadlib.test.js b/test/loadlib.test.js index c0125c08..a3be494c 100644 --- a/test/loadlib.test.js +++ b/test/loadlib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('require an existing module', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return require('os') @@ -24,7 +24,7 @@ test('require an existing module', () => { test('require a file', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return require('test.module-hello')() @@ -35,13 +35,13 @@ test('require a file', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello from module"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello from module'); }); test('package.loadlib', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return package.loadlib('./test/lib-hello.js.mod', 'hello')() @@ -52,13 +52,13 @@ test('package.loadlib', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello from js lib"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello from js lib'); }); test('package.searchpath', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return package.searchpath('module-hello', './?.lua;./test/?.lua') @@ -69,5 +69,5 @@ test('package.searchpath', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("./test/module-hello.lua"); + expect(lua.lua_tojsstring(L, -1)).toBe('./test/module-hello.lua'); }); diff --git a/test/loslib.test.js b/test/loslib.test.js index af7de92a..9c3d68d6 100644 --- a/test/loslib.test.js +++ b/test/loslib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('os.time', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.time() @@ -24,7 +24,7 @@ test('os.time', () => { test('os.time (with format)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.time({ @@ -46,7 +46,7 @@ test('os.time (with format)', () => { test('os.difftime', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1 = os.time() @@ -65,7 +65,7 @@ test('os.difftime', () => { test('os.date', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -80,13 +80,13 @@ test('os.date', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("2015-02-08"); + expect(lua.lua_tojsstring(L, -1)).toBe('2015-02-08'); }); test('os.date normalisation', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -101,13 +101,13 @@ test('os.date normalisation', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("2013-11-30"); + expect(lua.lua_tojsstring(L, -1)).toBe('2013-11-30'); }); test('os.time normalisation of table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = { @@ -130,7 +130,7 @@ test('os.time normalisation of table', () => { test('os.setlocale', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("C" == os.setlocale()) @@ -147,7 +147,7 @@ test('os.setlocale', () => { test('os.getenv', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.getenv('PATH') diff --git a/test/lstrlib.test.js b/test/lstrlib.test.js index 3ae2ec3f..53383430 100644 --- a/test/lstrlib.test.js +++ b/test/lstrlib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('string.len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "world" @@ -26,7 +26,7 @@ test('string.len', () => { test('string.char', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.char(104, 101, 108, 108, 111) @@ -37,13 +37,13 @@ test('string.char', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('string.upper, string.lower', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.upper("hello"), string.lower("HELLO") @@ -54,14 +54,14 @@ test('string.upper, string.lower', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("HELLO"); - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -2)).toBe('HELLO'); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('string.rep', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.rep("hello", 3, ", ") @@ -72,13 +72,13 @@ test('string.rep', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello, hello, hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello, hello, hello'); }); test('string.reverse', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.reverse("olleh") @@ -89,13 +89,13 @@ test('string.reverse', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('string.byte', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.byte("hello", 2, 4) @@ -114,7 +114,7 @@ test('string.byte', () => { test('string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.format("%%%d %010d", 10, 23) @@ -125,13 +125,13 @@ test('string.format', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("%10 0000000023"); + expect(lua.lua_tojsstring(L, -1)).toBe('%10 0000000023'); }); test('string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.format("%07X", 0xFFFFFFF) @@ -142,13 +142,13 @@ test('string.format', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("FFFFFFF"); + expect(lua.lua_tojsstring(L, -1)).toBe('FFFFFFF'); }); test('string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.format("%q", 'a string with "quotes" and \\n new line') @@ -160,14 +160,14 @@ test('string.format', () => { } expect(lua.lua_tojsstring(L, -1)).toBe('"a string with \\"quotes\\" and \\\n new line"', - "Correct element(s) on the stack" + 'Correct element(s) on the stack' ); }); test('string.sub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.sub("123456789",2,4), -- "234" @@ -188,23 +188,23 @@ test('string.sub', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -11)).toBe("234"); - expect(lua.lua_tojsstring(L, -10)).toBe("789"); - expect(lua.lua_tojsstring(L, -9)).toBe(""); - expect(lua.lua_tojsstring(L, -8)).toBe("7"); - expect(lua.lua_tojsstring(L, -7)).toBe(""); - expect(lua.lua_tojsstring(L, -6)).toBe("123456789"); - expect(lua.lua_tojsstring(L, -5)).toBe("123456789"); - expect(lua.lua_tojsstring(L, -4)).toBe(""); - expect(lua.lua_tojsstring(L, -3)).toBe("9"); - expect(lua.lua_tojsstring(L, -2)).toBe("6789"); - expect(lua.lua_tojsstring(L, -1)).toBe("456"); + expect(lua.lua_tojsstring(L, -11)).toBe('234'); + expect(lua.lua_tojsstring(L, -10)).toBe('789'); + expect(lua.lua_tojsstring(L, -9)).toBe(''); + expect(lua.lua_tojsstring(L, -8)).toBe('7'); + expect(lua.lua_tojsstring(L, -7)).toBe(''); + expect(lua.lua_tojsstring(L, -6)).toBe('123456789'); + expect(lua.lua_tojsstring(L, -5)).toBe('123456789'); + expect(lua.lua_tojsstring(L, -4)).toBe(''); + expect(lua.lua_tojsstring(L, -3)).toBe('9'); + expect(lua.lua_tojsstring(L, -2)).toBe('6789'); + expect(lua.lua_tojsstring(L, -1)).toBe('456'); }); test('string.dump', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local todump = function() @@ -227,17 +227,17 @@ test('string.dump', () => { let r = s.str; s.str = null; return r; - }, {str: str}, to_luastring("test"), to_luastring("binary")); + }, {str: str}, to_luastring('test'), to_luastring('binary')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello1212.5"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello1212.5'); }); test('string.pack/unpack/packsize', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s1, n, s2 = "hello", 2, "you" @@ -258,7 +258,7 @@ test('string.pack/unpack/packsize', () => { test('string.find without pattern', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.find("hello to you", " to ") @@ -276,7 +276,7 @@ test('string.find without pattern', () => { test('string.find with special pattern (issue #185)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.find("-", "-") @@ -295,7 +295,7 @@ test('string.find with special pattern (issue #185)', () => { test('string.match', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)") @@ -306,14 +306,14 @@ test('string.match', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("foo"); - expect(lua.lua_tojsstring(L, -1)).toBe("123"); + expect(lua.lua_tojsstring(L, -2)).toBe('foo'); + expect(lua.lua_tojsstring(L, -1)).toBe('123'); }); test('string.find', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)") @@ -326,14 +326,14 @@ test('string.find', () => { expect(lua.lua_tointeger(L, -4)).toBe(1); expect(lua.lua_tointeger(L, -3)).toBe(8); - expect(lua.lua_tojsstring(L, -2)).toBe("foo"); - expect(lua.lua_tojsstring(L, -1)).toBe("123"); + expect(lua.lua_tojsstring(L, -2)).toBe('foo'); + expect(lua.lua_tojsstring(L, -1)).toBe('123'); }); test('string.gmatch', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "hello world from Lua" @@ -351,16 +351,16 @@ test('string.gmatch', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -4)).toBe("hello"); - expect(lua.lua_tojsstring(L, -3)).toBe("world"); - expect(lua.lua_tojsstring(L, -2)).toBe("from"); - expect(lua.lua_tojsstring(L, -1)).toBe("Lua"); + expect(lua.lua_tojsstring(L, -4)).toBe('hello'); + expect(lua.lua_tojsstring(L, -3)).toBe('world'); + expect(lua.lua_tojsstring(L, -2)).toBe('from'); + expect(lua.lua_tojsstring(L, -1)).toBe('Lua'); }); test('string.gsub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("hello world", "(%w+)", "%1 %1") @@ -371,14 +371,14 @@ test('string.gsub', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world world"); + expect(lua.lua_tojsstring(L, -2)).toBe('hello hello world world'); expect(lua.lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (number)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("hello world", "%w+", "%0 %0", 1) @@ -389,14 +389,14 @@ test('string.gsub (number)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world"); + expect(lua.lua_tojsstring(L, -2)).toBe('hello hello world'); expect(lua.lua_tointeger(L, -1)).toBe(1); }); test('string.gsub (pattern)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1") @@ -407,14 +407,14 @@ test('string.gsub (pattern)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("world hello Lua from"); + expect(lua.lua_tojsstring(L, -2)).toBe('world hello Lua from'); expect(lua.lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (function)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) @@ -427,7 +427,7 @@ test('string.gsub (function)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("4+5 = 9"); + expect(lua.lua_tojsstring(L, -2)).toBe('4+5 = 9'); expect(lua.lua_tointeger(L, -1)).toBe(1); }); @@ -435,7 +435,7 @@ test('string.gsub (function)', () => { test('string.gsub (table)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {name="lua", version="5.3"} @@ -447,6 +447,6 @@ test('string.gsub (table)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("lua-5.3.tar.gz"); + expect(lua.lua_tojsstring(L, -2)).toBe('lua-5.3.tar.gz'); expect(lua.lua_tointeger(L, -1)).toBe(2); }); diff --git a/test/ltablib.test.js b/test/ltablib.test.js index 2cce1189..91b1c3ad 100644 --- a/test/ltablib.test.js +++ b/test/ltablib.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); const inttable2array = function(t) { let a = []; @@ -16,7 +16,7 @@ const inttable2array = function(t) { test('table.concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return table.concat({1, 2, 3, 4, 5, 6, 7}, ",", 3, 5) @@ -27,13 +27,13 @@ test('table.concat', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("3,4,5"); + expect(lua.lua_tojsstring(L, -1)).toBe('3,4,5'); }); test('table.pack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return table.pack(1, 2, 3) @@ -53,7 +53,7 @@ test('table.pack', () => { test('table.unpack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return table.unpack({1, 2, 3, 4, 5}, 2, 4) @@ -72,7 +72,7 @@ test('table.unpack', () => { test('table.insert', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 3, 4} @@ -96,7 +96,7 @@ test('table.insert', () => { test('table.remove', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 3, 4, 4} @@ -120,7 +120,7 @@ test('table.remove', () => { test('table.move', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1 = {3, 4, 5} @@ -143,7 +143,7 @@ test('table.move', () => { test('table.sort (<)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} @@ -163,7 +163,7 @@ test('table.sort (<)', () => { test('table.sort with cmp function', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} diff --git a/test/ltm.test.js b/test/ltm.test.js index c4e03da8..ba56539d 100644 --- a/test/ltm.test.js +++ b/test/ltm.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('__index, __newindex: with actual table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {yo=1} @@ -26,7 +26,7 @@ test('__index, __newindex: with actual table', () => { test('__newindex: with non table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = "a string" @@ -45,7 +45,7 @@ test('__newindex: with non table', () => { test('__index function in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -66,13 +66,13 @@ test('__index function in metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("__index"); + expect(lua.lua_tojsstring(L, -1)).toBe('__index'); }); test('__newindex function in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -101,7 +101,7 @@ test('__newindex function in metatable', () => { test('__index table in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmt = { @@ -124,13 +124,13 @@ test('__index table in metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('__newindex table in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmt = { @@ -155,14 +155,14 @@ test('__newindex table in metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); + expect(lua.lua_tojsstring(L, -1)).toBe('world'); expect(lua.lua_isnil(L, -2)).toBe(true); }); test('__index table with own metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmmt = { @@ -193,13 +193,13 @@ test('__index table with own metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('__newindex table with own metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = nil @@ -234,14 +234,14 @@ test('__newindex table with own metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); expect(lua.lua_isnil(L, -2)).toBe(true); }); test('binary __xxx functions in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -321,25 +321,25 @@ test('binary __xxx functions in metatable', () => { expect(L.stack.slice(L.top - 12, L.top).map(e => e.jsstring())) .toEqual([ - "{} + 1", - "{} - 1", - "{} * 1", - "{} % 1", - "{} ^ 1", - "{} / 1", - "{} // 1", - "{} & 1", - "{} | 1", - "{} ~ 1", - "{} << 1", - "{} >> 1" + '{} + 1', + '{} - 1', + '{} * 1', + '{} % 1', + '{} ^ 1', + '{} / 1', + '{} // 1', + '{} & 1', + '{} | 1', + '{} ~ 1', + '{} << 1', + '{} >> 1' ]); }); test('__eq', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -366,7 +366,7 @@ test('__eq', () => { test('__lt', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -393,7 +393,7 @@ test('__lt', () => { test('__le', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -420,7 +420,7 @@ test('__le', () => { test('__le that uses __lt', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -447,7 +447,7 @@ test('__le that uses __lt', () => { test('__unm, __bnot', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -472,14 +472,14 @@ test('__unm, __bnot', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); - expect(lua.lua_tojsstring(L, -2)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('world'); + expect(lua.lua_tojsstring(L, -2)).toBe('hello'); }); test('__len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -500,13 +500,13 @@ test('__len', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('__concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -527,13 +527,13 @@ test('__concat', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('__call', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -555,5 +555,5 @@ test('__call', () => { } expect(L.stack.slice(L.top - 3, L.top).map(e => e.jsstring())) - .toEqual(["hello", "world", "wow"]); + .toEqual(['hello', 'world', 'wow']); }); diff --git a/test/lua.test.js b/test/lua.test.js index 0f12238b..f4a060cb 100644 --- a/test/lua.test.js +++ b/test/lua.test.js @@ -1,14 +1,14 @@ -"use strict"; +'use strict'; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); // TODO: remove test.skip('locals.lua', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -25,7 +25,7 @@ test.skip('locals.lua', () => { test.skip('constructs.lua', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -42,7 +42,7 @@ test.skip('constructs.lua', () => { test.skip('strings.lua', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return dofile("tests/lua-tests/strings.lua") @@ -57,7 +57,7 @@ test.skip('strings.lua', () => { test('__newindex leaves nils', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = setmetatable({}, { diff --git a/test/lutf8lib.test.js b/test/lutf8lib.test.js index d2d51b31..4bb04fa7 100644 --- a/test/lutf8lib.test.js +++ b/test/lutf8lib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const lualib = require("../src/lualib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +const lua = require('../src/lua.js'); +const lauxlib = require('../src/lauxlib.js'); +const lualib = require('../src/lualib.js'); +const {to_luastring} = require('../src/fengaricore.js'); test('utf8.offset', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.offset("( ͡° ͜ʖ ͡° )", 5) @@ -24,7 +24,7 @@ test('utf8.offset', () => { test('utf8.codepoint', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8) @@ -43,7 +43,7 @@ test('utf8.codepoint', () => { test('utf8.char', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.char(40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 32, 41) @@ -54,13 +54,13 @@ test('utf8.char', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("( ͡° ͜ʖ ͡° )"); + expect(lua.lua_tojsstring(L, -1)).toBe('( ͡° ͜ʖ ͡° )'); }); test('utf8.len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.len("( ͡° ͜ʖ ͡° )") @@ -77,7 +77,7 @@ test('utf8.len', () => { test('utf8.codes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "( ͡° ͜ʖ ͡° )" @@ -93,5 +93,5 @@ test('utf8.codes', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] "); + expect(lua.lua_tojsstring(L, -1)).toBe('[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] '); }); diff --git a/test/lvm.test.js b/test/lvm.test.js index daa4539f..5630c4c4 100644 --- a/test/lvm.test.js +++ b/test/lvm.test.js @@ -1,14 +1,14 @@ -"use strict"; +'use strict'; -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const lstring = require("../src/lstring.js"); -const {to_luastring} = require("../src/fengaricore.js"); +const lua = require('../src/lua.js'); +const lauxlib = require('../src/lauxlib.js'); +const lstring = require('../src/lstring.js'); +const {to_luastring} = require('../src/fengaricore.js'); test('LOADK, RETURN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -19,13 +19,13 @@ test('LOADK, RETURN', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); }); test('MOVE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -37,12 +37,12 @@ test('MOVE', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); }); test('Binary op', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -61,7 +61,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -80,7 +80,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -97,7 +97,7 @@ test('NEWTABLE', () => { test('CALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -119,7 +119,7 @@ test('CALL', () => { test('Multiple return', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -146,7 +146,7 @@ test('Multiple return', () => { test('TAILCALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -166,7 +166,7 @@ test('TAILCALL', () => { test('VARARG', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (...) @@ -187,7 +187,7 @@ test('VARARG', () => { test('LE, JMP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -205,7 +205,7 @@ test('LE, JMP', () => { test('LT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -223,7 +223,7 @@ test('LT', () => { test('EQ', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -241,7 +241,7 @@ test('EQ', () => { test('TESTSET (and)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -254,13 +254,13 @@ test('TESTSET (and)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('TESTSET (or)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -273,13 +273,13 @@ test('TESTSET (or)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('TEST (true)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -296,13 +296,13 @@ test('TEST (true)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('TEST (false)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -319,13 +319,13 @@ test('TEST (false)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("goodbye"); + expect(lua.lua_tojsstring(L, -1)).toBe('goodbye'); }); test('FORPREP, FORLOOP (int)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -347,7 +347,7 @@ test('FORPREP, FORLOOP (int)', () => { test('FORPREP, FORLOOP (float)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -369,7 +369,7 @@ test('FORPREP, FORLOOP (float)', () => { test('SETTABLE, GETTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -385,15 +385,15 @@ test('SETTABLE, GETTABLE', () => { } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SETUPVAL, GETUPVAL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = "hello" @@ -411,13 +411,13 @@ test('SETUPVAL, GETUPVAL', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); + expect(lua.lua_tojsstring(L, -1)).toBe('world'); }); test('SETTABUP, GETTABUP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -433,15 +433,15 @@ test('SETTABUP, GETTABUP', () => { } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SELF', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -458,13 +458,13 @@ test('SELF', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello'); }); test('SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -483,7 +483,7 @@ test('SETLIST', () => { test('Variable SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = function () @@ -506,7 +506,7 @@ test('Variable SETLIST', () => { test('Long SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} @@ -549,7 +549,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local iterator = function (t, i) @@ -583,7 +583,7 @@ test('TFORCALL, TFORLOOP', () => { test('LEN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[10000] = "foo"} @@ -605,7 +605,7 @@ test('LEN', () => { test('CONCAT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return "hello " .. 2 .. " you" @@ -615,5 +615,5 @@ test('CONCAT', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you"); + expect(lua.lua_tojsstring(L, -1)).toBe('hello 2 you'); }); diff --git a/test/manual-tests/debug-cli.js b/test/manual-tests/debug-cli.js index dc49a0e0..f4ce8e9a 100755 --- a/test/manual-tests/debug-cli.js +++ b/test/manual-tests/debug-cli.js @@ -1,10 +1,10 @@ #!/usr/bin/env node -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); let luaCode = ` a = "debug me" diff --git a/test/test-suite/api.test.js b/test/test-suite/api.test.js index 5a5e10ea..eb101174 100644 --- a/test/test-suite/api.test.js +++ b/test/test-suite/api.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const ltests = require('./ltests.js'); @@ -26,9 +26,9 @@ const prefix = ` end `; -test("[test-suite] api: registry", () => { +test('[test-suite] api: registry', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = T.testC("pushvalue R; return 1") @@ -42,9 +42,9 @@ test("[test-suite] api: registry", () => { }); -test("[test-suite] api: absindex", () => { +test('[test-suite] api: absindex', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("settop 10; absindex -1; return 1") == 10) @@ -60,9 +60,9 @@ test("[test-suite] api: absindex", () => { }); -test("[test-suite] api: testing alignment", () => { +test('[test-suite] api: testing alignment', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- Useless tests in fengari since we do the same thing in d2s than in string.pack @@ -85,9 +85,9 @@ test("[test-suite] api: testing alignment", () => { }); -test("[test-suite] api: test that all trues are equal", () => { +test('[test-suite] api: test that all trues are equal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a,b,c = T.testC("pushbool 1; pushbool 2; pushbool 0; return 3") @@ -138,9 +138,9 @@ test("[test-suite] api: test that all trues are equal", () => { }); -test("[test-suite] api: testing 'rotate'", () => { +test('[test-suite] api: testing \'rotate\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing 'rotate' @@ -174,9 +174,9 @@ test("[test-suite] api: testing 'rotate'", () => { }); -test("[test-suite] api: testing non-function message handlers", () => { +test('[test-suite] api: testing non-function message handlers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -215,9 +215,9 @@ test("[test-suite] api: testing non-function message handlers", () => { }); -test("[test-suite] api: testing MULTRET", () => { +test('[test-suite] api: testing MULTRET', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = pack(T.testC("call 2,-1; return *", @@ -232,9 +232,9 @@ test("[test-suite] api: testing MULTRET", () => { }); -test("[test-suite] api: test returning more results than fit in the caller stack", () => { +test('[test-suite] api: test returning more results than fit in the caller stack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test returning more results than fit in the caller stack @@ -253,9 +253,9 @@ test("[test-suite] api: test returning more results than fit in the caller stack }); -test("[test-suite] api: testing globals", () => { +test('[test-suite] api: testing globals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.a = 14; _G.b = "a31" @@ -276,9 +276,9 @@ test("[test-suite] api: testing globals", () => { }); -test("[test-suite] api: testing arith", () => { +test('[test-suite] api: testing arith', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5) @@ -322,9 +322,9 @@ test("[test-suite] api: testing arith", () => { }); -test("[test-suite] api: errors in arithmetic", () => { +test('[test-suite] api: errors in arithmetic', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerr("divide by zero", T.testC, "arith \\\\", 10, 0) @@ -338,9 +338,9 @@ test("[test-suite] api: errors in arithmetic", () => { }); -test("[test-suite] api: testing lessthan and lessequal", () => { +test('[test-suite] api: testing lessthan and lessequal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("compare LT 2 5, return 1", 3, 2, 2, 4, 2, 2)) @@ -359,9 +359,9 @@ test("[test-suite] api: testing lessthan and lessequal", () => { }); -test("[test-suite] api: non-valid indices produce false", () => { +test('[test-suite] api: non-valid indices produce false', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not T.testC("compare LT 1 4, return 1")) @@ -390,9 +390,9 @@ test("[test-suite] api: non-valid indices produce false", () => { }); -test("[test-suite] api: testing length", () => { +test('[test-suite] api: testing length', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = setmetatable({x = 20}, {__len = function (t) return t.x end}) @@ -429,9 +429,9 @@ test("[test-suite] api: testing length", () => { }); -test("[test-suite] api: testing __concat", () => { +test('[test-suite] api: testing __concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = setmetatable({x="u"}, {__concat = function (a,b) return a.x..'.'..b.x end}) @@ -459,9 +459,9 @@ test("[test-suite] api: testing __concat", () => { }); -test("[test-suite] api: testing lua_is", () => { +test('[test-suite] api: testing lua_is', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function B(x) return x and 1 or 0 end @@ -502,9 +502,9 @@ test("[test-suite] api: testing lua_is", () => { }); -test("[test-suite] api: testing lua_to...", () => { +test('[test-suite] api: testing lua_to...', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function to (s, x, n) @@ -550,9 +550,9 @@ test("[test-suite] api: testing lua_to...", () => { lua.lua_call(L, 0, 0); }); -test("[test-suite] api: testing panic function", () => { +test('[test-suite] api: testing panic function', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -598,9 +598,9 @@ test("[test-suite] api: testing panic function", () => { }); -test.skip("[test-suite] api: testing deep JS stack", () => { +test.skip('[test-suite] api: testing deep JS stack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -642,9 +642,9 @@ test.skip("[test-suite] api: testing deep JS stack", () => { }); -test("[test-suite] api: testing errors", () => { +test('[test-suite] api: testing errors', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = T.testC([[ @@ -673,9 +673,9 @@ test("[test-suite] api: testing errors", () => { }); -test("[test-suite] api: test errors in non protected threads", () => { +test('[test-suite] api: test errors in non protected threads', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function checkerrnopro (code, msg) @@ -699,9 +699,9 @@ test("[test-suite] api: test errors in non protected threads", () => { }); -test("[test-suite] api: testing table access", () => { +test('[test-suite] api: testing table access', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- getp/setp @@ -750,9 +750,9 @@ test("[test-suite] api: testing table access", () => { }); -test("[test-suite] api: testing getfield/setfield with long keys", () => { +test('[test-suite] api: testing getfield/setfield with long keys', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing getfield/setfield with long keys @@ -778,9 +778,9 @@ test("[test-suite] api: testing getfield/setfield with long keys", () => { }); -test("[test-suite] api: testing next", () => { +test('[test-suite] api: testing next', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -800,9 +800,9 @@ test("[test-suite] api: testing next", () => { }); -test("[test-suite] api: testing upvalues", () => { +test('[test-suite] api: testing upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -828,9 +828,9 @@ test("[test-suite] api: testing upvalues", () => { }); -test("[test-suite] api: testing absent upvalues from JS-function pointers", () => { +test('[test-suite] api: testing absent upvalues from JS-function pointers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC[[isnull U1; return 1]] == true) @@ -852,9 +852,9 @@ test("[test-suite] api: testing absent upvalues from JS-function pointers", () = }); -test("[test-suite] api: large closures", () => { +test('[test-suite] api: large closures', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -877,9 +877,9 @@ test("[test-suite] api: large closures", () => { }); -test("[test-suite] api: testing get/setuservalue", () => { +test('[test-suite] api: testing get/setuservalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- bug in 5.1.2 @@ -912,9 +912,9 @@ test("[test-suite] api: testing get/setuservalue", () => { }); -test.skip("[test-suite] api: testing get/setuservalue", () => { +test.skip('[test-suite] api: testing get/setuservalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T.gcstate("atomic") @@ -931,9 +931,9 @@ test.skip("[test-suite] api: testing get/setuservalue", () => { }); -test.skip("[test-suite] api: long chain of userdata", () => { +test.skip('[test-suite] api: long chain of userdata', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, 1000 do @@ -956,9 +956,9 @@ test.skip("[test-suite] api: long chain of userdata", () => { }); -test.skip("[test-suite] api: reuse of references", () => { +test.skip('[test-suite] api: reuse of references', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local i = T.ref{} @@ -1016,9 +1016,9 @@ test.skip("[test-suite] api: reuse of references", () => { }); -test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", () => { +test.skip('[test-suite] api: collect in cl the `val\' of all collected userdata', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` tt = {} @@ -1132,9 +1132,9 @@ test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", }); -test.skip("[test-suite] api: test whether udate collection frees memory in the right time", () => { +test.skip('[test-suite] api: test whether udate collection frees memory in the right time', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1176,9 +1176,9 @@ test.skip("[test-suite] api: test whether udate collection frees memory in the r }); -test("[test-suite] api: testing lua_equal", () => { +test('[test-suite] api: testing lua_equal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("compare EQ 2 4; return 1", print, 1, print, 20)) @@ -1196,9 +1196,9 @@ test("[test-suite] api: testing lua_equal", () => { }); -test("[test-suite] api: testing lua_equal with fallbacks", () => { +test('[test-suite] api: testing lua_equal with fallbacks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1226,9 +1226,9 @@ test("[test-suite] api: testing lua_equal with fallbacks", () => { }); -test("[test-suite] api: testing changing hooks during hooks", () => { +test('[test-suite] api: testing changing hooks during hooks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.t = {} @@ -1260,9 +1260,9 @@ test("[test-suite] api: testing changing hooks during hooks", () => { }); -test.skip("[test-suite] api: testing errors during GC", () => { +test.skip('[test-suite] api: testing errors during GC', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing errors during GC @@ -1300,9 +1300,9 @@ test.skip("[test-suite] api: testing errors during GC", () => { }); -test("[test-suite] api: test for userdata vals", () => { +test('[test-suite] api: test for userdata vals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1323,9 +1323,9 @@ test("[test-suite] api: test for userdata vals", () => { }); -test("[test-suite] api: testing multiple states", () => { +test('[test-suite] api: testing multiple states', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T.closestate(T.newstate()); @@ -1382,9 +1382,9 @@ test("[test-suite] api: testing multiple states", () => { }); -test.skip("[test-suite] api: testing memory limits", () => { +test.skip('[test-suite] api: testing memory limits', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerr("block too big", T.newuserdata, math.maxinteger) @@ -1428,9 +1428,9 @@ const memprefix = ` `; -test.skip("[test-suite] api: testing memory errors when creating a new state", () => { +test.skip('[test-suite] api: testing memory errors when creating a new state', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` b = testamem("state creation", T.newstate) @@ -1443,9 +1443,9 @@ test.skip("[test-suite] api: testing memory errors when creating a new state", ( lua.lua_call(L, 0, 0); }); -test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", () => { +test('[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` mt = T.testC("rawgeti R 1; return 1") @@ -1458,9 +1458,9 @@ test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHR lua.lua_call(L, 0, 0); }); -test.skip("[test-suite] api: test thread creation after stressing GC", () => { +test.skip('[test-suite] api: test thread creation after stressing GC', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function expand (n,s) @@ -1486,9 +1486,9 @@ test.skip("[test-suite] api: test thread creation after stressing GC", () => { }); -test.skip("[test-suite] api: testing memory x compiler", () => { +test.skip('[test-suite] api: testing memory x compiler', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` testamem("loadstring", function () @@ -1503,9 +1503,9 @@ test.skip("[test-suite] api: testing memory x compiler", () => { }); -test.skip("[test-suite] api: testing memory x dofile", () => { +test.skip('[test-suite] api: testing memory x dofile', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local testprog = [[ @@ -1537,9 +1537,9 @@ test.skip("[test-suite] api: testing memory x dofile", () => { }); -test.skip("[test-suite] api: other generic tests", () => { +test.skip('[test-suite] api: other generic tests', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` testamem("string creation", function () @@ -1608,9 +1608,9 @@ test.skip("[test-suite] api: other generic tests", () => { }); -test("[test-suite] api: testing some auxlib functions", () => { +test('[test-suite] api: testing some auxlib functions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function gsub (a, b, c) @@ -1633,9 +1633,9 @@ test("[test-suite] api: testing some auxlib functions", () => { }); -test("[test-suite] api: testing luaL_newmetatable", () => { +test('[test-suite] api: testing luaL_newmetatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt_xuxu, res, top = T.testC("newmetatable xuxu; gettop; return 3") diff --git a/test/test-suite/attrib.test.js b/test/test-suite/attrib.test.js index bb07e628..3b419bc1 100644 --- a/test/test-suite/attrib.test.js +++ b/test/test-suite/attrib.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); -test("[test-suite] attrib: testing require", () => { +test('[test-suite] attrib: testing require', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(require"string" == string) @@ -62,15 +62,15 @@ test("[test-suite] attrib: testing require", () => { // TODO: when io.write etc. -test.skip("[test-suite] attrib: system specific tests for 'require'", () => { +test.skip('[test-suite] attrib: system specific tests for \'require\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); }); -test("[test-suite] attrib: testing assignments, logical operators, and constructors", () => { +test('[test-suite] attrib: testing assignments, logical operators, and constructors', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local res, res2 = 27 @@ -168,9 +168,9 @@ test("[test-suite] attrib: testing assignments, logical operators, and construct }); -test("[test-suite] attrib: test of large float/integer indices ", () => { +test('[test-suite] attrib: test of large float/integer indices ', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -232,9 +232,9 @@ test("[test-suite] attrib: test of large float/integer indices ", () => { }); -test("[test-suite] attrib: test conflicts in multiple assignment", () => { +test('[test-suite] attrib: test conflicts in multiple assignment', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -252,9 +252,9 @@ test("[test-suite] attrib: test conflicts in multiple assignment", () => { }); -test("[test-suite] attrib: repeat test with upvalues", () => { +test('[test-suite] attrib: repeat test with upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -278,9 +278,9 @@ test("[test-suite] attrib: repeat test with upvalues", () => { }); -test("[test-suite] attrib: bug in 5.2 beta", () => { +test('[test-suite] attrib: bug in 5.2 beta', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () diff --git a/test/test-suite/bitwise.test.js b/test/test-suite/bitwise.test.js index bf8de5c5..a5e3722c 100644 --- a/test/test-suite/bitwise.test.js +++ b/test/test-suite/bitwise.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` package.preload.bit32 = function () --{ @@ -114,9 +114,9 @@ const prefix = ` local bit32 = require'bit32' `; -test("[test-suite] bitwise: testing bitwise operations", () => { +test('[test-suite] bitwise: testing bitwise operations', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local numbits = string.packsize('j') * 8 @@ -184,9 +184,9 @@ test("[test-suite] bitwise: testing bitwise operations", () => { }); -test("[test-suite] bitwise: testing bitwise library", () => { +test('[test-suite] bitwise: testing bitwise library', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.band() == bit32.bnot(0)) @@ -204,9 +204,9 @@ test("[test-suite] bitwise: testing bitwise library", () => { }); -test("[test-suite] bitwise: out-of-range numbers", () => { +test('[test-suite] bitwise: out-of-range numbers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.band(-1) == 0xffffffff) @@ -269,9 +269,9 @@ test("[test-suite] bitwise: out-of-range numbers", () => { }); -test("[test-suite] bitwise: some special cases", () => { +test('[test-suite] bitwise: some special cases', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555, @@ -312,9 +312,9 @@ test("[test-suite] bitwise: some special cases", () => { }); -test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)", () => { +test('[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` c = {0, 1, 2, 3, 10, 0x800000, 0xaaaaaa, 0x555555, 0xffffff, 0x7fffff} @@ -339,9 +339,9 @@ test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si }); -test("[test-suite] bitwise: testing extract/replace", () => { +test('[test-suite] bitwise: testing extract/replace', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.extract(0x12345678, 0, 4) == 8) @@ -370,9 +370,9 @@ test("[test-suite] bitwise: testing extract/replace", () => { }); -test("[test-suite] bitwise: testing conversion of floats", () => { +test('[test-suite] bitwise: testing conversion of floats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.bor(3.0) == 3) @@ -385,9 +385,9 @@ test("[test-suite] bitwise: testing conversion of floats", () => { }); -test("[test-suite] bitwise: large floats and large-enough integers?", () => { +test('[test-suite] bitwise: large floats and large-enough integers?', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if 2.0^50 < 2.0^50 + 1.0 and 2.0^50 < (-1 >> 1) then diff --git a/test/test-suite/calls.test.js b/test/test-suite/calls.test.js index 16043376..34b926b1 100644 --- a/test/test-suite/calls.test.js +++ b/test/test-suite/calls.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); -test("[test-suite] calls: test 'type'", () => { +test('[test-suite] calls: test \'type\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(1<2) == 'boolean') @@ -30,9 +30,9 @@ test("[test-suite] calls: test 'type'", () => { }); -test("[test-suite] calls: test error in 'print'", () => { +test('[test-suite] calls: test error in \'print\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test error in 'print' too... @@ -56,9 +56,9 @@ test("[test-suite] calls: test error in 'print'", () => { }); -test("[test-suite] calls: testing local-function recursion", () => { +test('[test-suite] calls: testing local-function recursion', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` fact = false @@ -80,9 +80,9 @@ test("[test-suite] calls: testing local-function recursion", () => { }); -test("[test-suite] calls: testing declarations", () => { +test('[test-suite] calls: testing declarations', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {i = 10} @@ -175,9 +175,9 @@ test("[test-suite] calls: testing declarations", () => { }); -test("[test-suite] calls: testing closures", () => { +test('[test-suite] calls: testing closures', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- fixed-point operator @@ -221,9 +221,9 @@ test("[test-suite] calls: testing closures", () => { }); -test("[test-suite] calls: testing multiple returns", () => { +test('[test-suite] calls: testing multiple returns', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function unlpack (t, i) @@ -267,9 +267,9 @@ test("[test-suite] calls: testing multiple returns", () => { }); -test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { +test('[test-suite] calls: testing calls with \'incorrect\' arguments', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` rawget({}, "x", 1) @@ -284,9 +284,9 @@ test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { }); -test("[test-suite] calls: test for generic load", () => { +test('[test-suite] calls: test for generic load', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = "-- a comment\\0\\0\\0\\n x = 10 + \\n23; \\ @@ -344,9 +344,9 @@ test("[test-suite] calls: test for generic load", () => { }); -test("[test-suite] calls: any value is valid for _ENV", () => { +test('[test-suite] calls: any value is valid for _ENV', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(load("return _ENV", nil, nil, 123)() == 123) @@ -358,9 +358,9 @@ test("[test-suite] calls: any value is valid for _ENV", () => { }); -test("[test-suite] calls: load when _ENV is not first upvalue", () => { +test('[test-suite] calls: load when _ENV is not first upvalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x; XX = 123 @@ -383,9 +383,9 @@ test("[test-suite] calls: load when _ENV is not first upvalue", () => { }); -test("[test-suite] calls: test generic load with nested functions", () => { +test('[test-suite] calls: test generic load with nested functions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function read1 (x) @@ -416,9 +416,9 @@ test("[test-suite] calls: test generic load with nested functions", () => { }); -test("[test-suite] calls: test for dump/undump with upvalues", () => { +test('[test-suite] calls: test for dump/undump with upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 20, 30 @@ -444,9 +444,9 @@ test("[test-suite] calls: test for dump/undump with upvalues", () => { }); -test("[test-suite] calls: test for dump/undump with many upvalues", () => { +test('[test-suite] calls: test for dump/undump with many upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -479,9 +479,9 @@ test("[test-suite] calls: test for dump/undump with many upvalues", () => { }); -test("[test-suite] calls: test for long method names", () => { +test('[test-suite] calls: test for long method names', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -499,9 +499,9 @@ test("[test-suite] calls: test for long method names", () => { }); -test("[test-suite] calls: test for bug in parameter adjustment", () => { +test('[test-suite] calls: test for bug in parameter adjustment', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert((function () return nil end)(4) == nil) @@ -515,9 +515,9 @@ test("[test-suite] calls: test for bug in parameter adjustment", () => { }); -test("[test-suite] calls: testing binary chunks", () => { +test('[test-suite] calls: testing binary chunks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/closure.test.js b/test/test-suite/closure.test.js index d44d908f..0ee21b99 100644 --- a/test/test-suite/closure.test.js +++ b/test/test-suite/closure.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); -test("[test-suite] closure: testing equality", () => { +test('[test-suite] closure: testing equality', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -29,9 +29,9 @@ test("[test-suite] closure: testing equality", () => { }); -test("[test-suite] closure: testing closures with 'for' control variable", () => { +test('[test-suite] closure: testing closures with \'for\' control variable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -70,9 +70,9 @@ test("[test-suite] closure: testing closures with 'for' control variable", () => }); -test("[test-suite] closure: testing closures with 'for' control variable x break", () => { +test('[test-suite] closure: testing closures with \'for\' control variable x break', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {"a", "b"} @@ -98,9 +98,9 @@ test("[test-suite] closure: testing closures with 'for' control variable x break }); -test("[test-suite] closure: testing closure x break x return x errors", () => { +test('[test-suite] closure: testing closure x break x return x errors', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local b @@ -142,9 +142,9 @@ test("[test-suite] closure: testing closure x break x return x errors", () => { }); -test("[test-suite] closure: testing multi-level closure", () => { +test('[test-suite] closure: testing multi-level closure', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local w @@ -165,9 +165,9 @@ test("[test-suite] closure: testing multi-level closure", () => { }); -test("[test-suite] closure: testing closures x repeat-until", () => { +test('[test-suite] closure: testing closures x repeat-until', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -185,9 +185,9 @@ test("[test-suite] closure: testing closures x repeat-until", () => { }); -test("[test-suite] closure: testing closures created in 'then' and 'else' parts of 'if's", () => { +test('[test-suite] closure: testing closures created in \'then\' and \'else\' parts of \'if\'s', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -226,9 +226,9 @@ test("[test-suite] closure: testing closures created in 'then' and 'else' parts }); -test("[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions", () => { +test('[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function t () diff --git a/test/test-suite/code.test.js b/test/test-suite/code.test.js index 377dd630..3fdfeb02 100644 --- a/test/test-suite/code.test.js +++ b/test/test-suite/code.test.js @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const ltests = require('./ltests.js'); -test("[test-suite] code: testing reuse in constant table", () => { +test('[test-suite] code: testing reuse in constant table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkKlist (func, list) @@ -64,9 +64,9 @@ const prefix = ` `; -test("[test-suite] code: some basic instructions", () => { +test('[test-suite] code: some basic instructions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -81,9 +81,9 @@ test("[test-suite] code: some basic instructions", () => { }); -test("[test-suite] code: sequence of LOADNILs", () => { +test('[test-suite] code: sequence of LOADNILs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -112,9 +112,9 @@ test("[test-suite] code: sequence of LOADNILs", () => { }); -test("[test-suite] code: single return", () => { +test('[test-suite] code: single return', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check (function (a,b,c) return a end, 'RETURN') @@ -127,9 +127,9 @@ test("[test-suite] code: single return", () => { }); -test("[test-suite] code: infinite loops", () => { +test('[test-suite] code: infinite loops', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () while true do local a = -1 end end, @@ -149,9 +149,9 @@ test("[test-suite] code: infinite loops", () => { }); -test("[test-suite] code: concat optimization", () => { +test('[test-suite] code: concat optimization', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function (a,b,c,d) return a..b..c..d end, @@ -165,9 +165,9 @@ test("[test-suite] code: concat optimization", () => { }); -test("[test-suite] code: not", () => { +test('[test-suite] code: not', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return not not nil end, 'LOADBOOL', 'RETURN') @@ -183,9 +183,9 @@ test("[test-suite] code: not", () => { }); -test("[test-suite] code: direct access to locals", () => { +test('[test-suite] code: direct access to locals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -206,9 +206,9 @@ test("[test-suite] code: direct access to locals", () => { }); -test("[test-suite] code: direct access to constants", () => { +test('[test-suite] code: direct access to constants', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -241,9 +241,9 @@ test("[test-suite] code: direct access to constants", () => { }); -test("[test-suite] code: constant folding", () => { +test('[test-suite] code: constant folding', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkK (func, val) @@ -275,9 +275,9 @@ test("[test-suite] code: constant folding", () => { }); -test("[test-suite] code: no folding", () => { +test('[test-suite] code: no folding', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return -0.0 end, 'LOADK', 'UNM', 'RETURN') @@ -293,9 +293,9 @@ test("[test-suite] code: no folding", () => { }); -test("[test-suite] code: bug in constant folding for 5.1", () => { +test('[test-suite] code: bug in constant folding for 5.1', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN') @@ -323,9 +323,9 @@ test("[test-suite] code: bug in constant folding for 5.1", () => { }); -test("[test-suite] code: x == nil , x ~= nil", () => { +test('[test-suite] code: x == nil , x ~= nil', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkequal(function () if (a==nil) then a=1 end; if a~=nil then a=1 end end, @@ -348,9 +348,9 @@ test("[test-suite] code: x == nil , x ~= nil", () => { }); -test("[test-suite] code: if-goto optimizations", () => { +test('[test-suite] code: if-goto optimizations', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function (a, b, c, d, e) diff --git a/test/test-suite/constructs.test.js b/test/test-suite/constructs.test.js index e79778ae..180e99e6 100644 --- a/test/test-suite/constructs.test.js +++ b/test/test-suite/constructs.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const checkload = ` local function checkload (s, msg) @@ -13,7 +13,7 @@ const checkload = ` test('[test-suite] constructs: testing semicolons', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do ;;; end @@ -29,7 +29,7 @@ test('[test-suite] constructs: testing semicolons', () => { test('[test-suite] constructs: invalid operations should not raise errors when not executed', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if false then a = 3 // 0; a = 0 % 0 end @@ -43,7 +43,7 @@ test('[test-suite] constructs: invalid operations should not raise errors when n test('[test-suite] constructs: testing priorities', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(2^3^2 == 2^(3^2)); @@ -96,7 +96,7 @@ test('[test-suite] constructs: testing priorities', () => { test('[test-suite] constructs: silly loops', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` repeat until 1; repeat until true; @@ -269,7 +269,7 @@ test('[test-suite] constructs: silly loops', () => { test.skip('[test-suite] constructs: huge loops, upvalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- sometimes will be 0, sometimes will not... @@ -343,9 +343,9 @@ test.skip('[test-suite] constructs: huge loops, upvalue', () => { }); -test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", () => { +test('[test-suite] constructs: testing some syntax errors (chosen through \'gcov\')', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true diff --git a/test/test-suite/coroutine.test.js b/test/test-suite/coroutine.test.js index de92317f..c967c639 100644 --- a/test/test-suite/coroutine.test.js +++ b/test/test-suite/coroutine.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const ltests = require('./ltests.js'); @@ -55,9 +55,9 @@ const prefix = ` end `; -test("[test-suite] coroutine: is main thread", () => { +test('[test-suite] coroutine: is main thread', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local main, ismain = coroutine.running() @@ -73,9 +73,9 @@ test("[test-suite] coroutine: is main thread", () => { }); -test("[test-suite] coroutine: trivial errors", () => { +test('[test-suite] coroutine: trivial errors', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(coroutine.resume, 0)) @@ -88,9 +88,9 @@ test("[test-suite] coroutine: trivial errors", () => { }); -test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => { +test('[test-suite] coroutine: tests for multiple yield/resume arguments', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function eqtab (t1, t2) @@ -143,9 +143,9 @@ test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => }); -test("[test-suite] coroutine: yields in tail calls", () => { +test('[test-suite] coroutine: yields in tail calls', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (i) return coroutine.yield(i) end @@ -165,9 +165,9 @@ test("[test-suite] coroutine: yields in tail calls", () => { }); -test("[test-suite] coroutine: recursive", () => { +test('[test-suite] coroutine: recursive', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function pf (n, i) @@ -189,9 +189,9 @@ test("[test-suite] coroutine: recursive", () => { }); -test("[test-suite] coroutine: sieve", () => { +test('[test-suite] coroutine: sieve', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function gen (n) @@ -230,9 +230,9 @@ test("[test-suite] coroutine: sieve", () => { }); -test("[test-suite] coroutine: yielding across JS boundaries", () => { +test('[test-suite] coroutine: yielding across JS boundaries', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (s, i) return coroutine.yield(i) end @@ -270,9 +270,9 @@ test("[test-suite] coroutine: yielding across JS boundaries", () => { }); -test("[test-suite] coroutine: unyieldable JS call", () => { +test('[test-suite] coroutine: unyieldable JS call', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -296,9 +296,9 @@ test("[test-suite] coroutine: unyieldable JS call", () => { }); -test("[test-suite] coroutine: errors in coroutines", () => { +test('[test-suite] coroutine: errors in coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function foo () @@ -329,9 +329,9 @@ test("[test-suite] coroutine: errors in coroutines", () => { }); -test("[test-suite] coroutine: co-routines x for loop", () => { +test('[test-suite] coroutine: co-routines x for loop', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function all (a, n, k) @@ -357,9 +357,9 @@ test("[test-suite] coroutine: co-routines x for loop", () => { }); -test("[test-suite] coroutine: old bug: attempt to resume itself", () => { +test('[test-suite] coroutine: old bug: attempt to resume itself', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function co_func (current_co) @@ -388,9 +388,9 @@ test("[test-suite] coroutine: old bug: attempt to resume itself", () => { }); -test("[test-suite] coroutine: old bug: other old bug when attempting to resume itself", () => { +test('[test-suite] coroutine: old bug: other old bug when attempting to resume itself', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -411,9 +411,9 @@ test("[test-suite] coroutine: old bug: other old bug when attempting to resume i }); -test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { +test('[test-suite] coroutine: attempt to resume \'normal\' coroutine', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co1, co2 @@ -435,9 +435,9 @@ test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { }); -test("[test-suite] coroutine: infinite recursion of coroutines", () => { +test('[test-suite] coroutine: infinite recursion of coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = function(a) coroutine.wrap(a)(a) end @@ -451,9 +451,9 @@ test("[test-suite] coroutine: infinite recursion of coroutines", () => { }); -test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { +test('[test-suite] coroutine: access to locals of erroneous coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = coroutine.create (function () @@ -474,9 +474,9 @@ test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { lua.lua_call(L, 0, 0); }); -test("[test-suite] coroutine: leaving a pending coroutine open", () => { +test('[test-suite] coroutine: leaving a pending coroutine open', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _X = coroutine.wrap(function () @@ -494,9 +494,9 @@ test("[test-suite] coroutine: leaving a pending coroutine open", () => { }); -test("[test-suite] coroutine: stack overflow", () => { +test('[test-suite] coroutine: stack overflow', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- bug (stack overflow) @@ -522,9 +522,9 @@ test("[test-suite] coroutine: stack overflow", () => { }); -test("[test-suite] coroutine: testing yields inside metamethods", () => { +test('[test-suite] coroutine: testing yields inside metamethods', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = new(10) @@ -570,9 +570,9 @@ test("[test-suite] coroutine: testing yields inside metamethods", () => { }); -test("[test-suite] coroutine: tests for comparsion operators", () => { +test('[test-suite] coroutine: tests for comparsion operators', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -622,9 +622,9 @@ test("[test-suite] coroutine: tests for comparsion operators", () => { }); -test("[test-suite] coroutine: getuptable & setuptable", () => { +test('[test-suite] coroutine: getuptable & setuptable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do local _ENV = _ENV @@ -642,9 +642,9 @@ test("[test-suite] coroutine: getuptable & setuptable", () => { }); -test("[test-suite] coroutine: testing yields inside 'for' iterators", () => { +test('[test-suite] coroutine: testing yields inside \'for\' iterators', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (s, i) @@ -676,9 +676,9 @@ const jsprefix = ` end `; -test("[test-suite] coroutine: testing yields inside hooks", () => { +test('[test-suite] coroutine: testing yields inside hooks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local A, B = 0, 0 @@ -708,9 +708,9 @@ test("[test-suite] coroutine: testing yields inside hooks", () => { }); -test("[test-suite] coroutine: testing yields inside line hook", () => { +test('[test-suite] coroutine: testing yields inside line hook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -739,9 +739,9 @@ test("[test-suite] coroutine: testing yields inside line hook", () => { }); -test("[test-suite] coroutine: testing yields in count hook", () => { +test('[test-suite] coroutine: testing yields in count hook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -768,9 +768,9 @@ test("[test-suite] coroutine: testing yields in count hook", () => { }); -test("[test-suite] coroutine: testing yields inside line hook", () => { +test('[test-suite] coroutine: testing yields inside line hook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -806,9 +806,9 @@ test("[test-suite] coroutine: testing yields inside line hook", () => { }); -test("[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook", () => { +test('[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -846,9 +846,9 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins }); -test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", () => { +test('[test-suite] coroutine: testing debug library on last function in a suspended coroutine', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -870,9 +870,9 @@ test("[test-suite] coroutine: testing debug library on last function in a suspen }); -test("[test-suite] coroutine: reusing a thread", () => { +test('[test-suite] coroutine: reusing a thread', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC([[ @@ -904,9 +904,9 @@ test("[test-suite] coroutine: reusing a thread", () => { }); -test("[test-suite] coroutine: resuming running coroutine", () => { +test('[test-suite] coroutine: resuming running coroutine', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = coroutine.create(function () @@ -940,9 +940,9 @@ test("[test-suite] coroutine: resuming running coroutine", () => { lua.lua_call(L, 0, 0); }); -test("[test-suite] coroutine: using a main thread as a coroutine", () => { +test('[test-suite] coroutine: using a main thread as a coroutine', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local state = T.newstate() @@ -984,9 +984,9 @@ test("[test-suite] coroutine: using a main thread as a coroutine", () => { }); -test("[test-suite] coroutine: tests for coroutine API", () => { +test('[test-suite] coroutine: tests for coroutine API', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function apico (...) @@ -1036,9 +1036,9 @@ test("[test-suite] coroutine: tests for coroutine API", () => { }); -test("[test-suite] coroutine: tests for coroutine API", () => { +test('[test-suite] coroutine: tests for coroutine API', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` f = T.makeCfunc("pushnum 3; pushnum 5; yield 1;") @@ -1057,9 +1057,9 @@ test("[test-suite] coroutine: tests for coroutine API", () => { }); -test("[test-suite] coroutine: testing coroutines with C bodies", () => { +test('[test-suite] coroutine: testing coroutines with C bodies', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function eqtab (t1, t2) @@ -1102,9 +1102,9 @@ test("[test-suite] coroutine: testing coroutines with C bodies", () => { }); -test("[test-suite] coroutine: testing chain of suspendable C calls", () => { +test('[test-suite] coroutine: testing chain of suspendable C calls', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local count = 3 -- number of levels @@ -1145,9 +1145,9 @@ test("[test-suite] coroutine: testing chain of suspendable C calls", () => { }); -test("[test-suite] coroutine: testing yields with continuations", () => { +test('[test-suite] coroutine: testing yields with continuations', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = coroutine.wrap(function (...) return @@ -1210,9 +1210,9 @@ test("[test-suite] coroutine: testing yields with continuations", () => { }); -test("[test-suite] coroutine: bug in nCcalls", () => { +test('[test-suite] coroutine: bug in nCcalls', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.wrap(function () diff --git a/test/test-suite/db.test.js b/test/test-suite/db.test.js index 89ec66da..9fce2154 100644 --- a/test/test-suite/db.test.js +++ b/test/test-suite/db.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` local function dostring(s) return assert(load(s))() end @@ -22,9 +22,9 @@ const prefix = ` end `; -test("[test-suite] db: getinfo, ...line...", () => { +test('[test-suite] db: getinfo, ...line...', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(debug.getinfo, print, "X")) -- invalid option @@ -50,9 +50,9 @@ test("[test-suite] db: getinfo, ...line...", () => { }); -test("[test-suite] db: test file and string names truncation", () => { +test('[test-suite] db: test file and string names truncation', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = "function f () end" @@ -85,9 +85,9 @@ test("[test-suite] db: test file and string names truncation", () => { lua.lua_call(L, 0, 0); }); -test("[test-suite] db: local", () => { +test('[test-suite] db: local', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` repeat @@ -133,9 +133,9 @@ test("[test-suite] db: local", () => { }); -test("[test-suite] db: line hook", () => { +test('[test-suite] db: line hook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` test([[if @@ -199,9 +199,9 @@ test("[test-suite] db: line hook", () => { }); -test("[test-suite] db: invalid levels in [gs]etlocal", () => { +test('[test-suite] db: invalid levels in [gs]etlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(debug.getlocal, 20, 1)) @@ -214,9 +214,9 @@ test("[test-suite] db: invalid levels in [gs]etlocal", () => { }); -test("[test-suite] db: parameter names", () => { +test('[test-suite] db: parameter names', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (a,b,...) local d, e end @@ -238,9 +238,9 @@ test("[test-suite] db: parameter names", () => { }); -test("[test-suite] db: vararg", () => { +test('[test-suite] db: vararg', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (a, ...) @@ -275,9 +275,9 @@ test("[test-suite] db: vararg", () => { }); -test("[test-suite] db: access to vararg in non-vararg function", () => { +test('[test-suite] db: access to vararg in non-vararg function', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () return debug.getlocal(1, -1) end @@ -290,9 +290,9 @@ test("[test-suite] db: access to vararg in non-vararg function", () => { }); -test("[test-suite] db: test hook presence in debug info", () => { +test('[test-suite] db: test hook presence in debug info', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test hook presence in debug info @@ -386,9 +386,9 @@ test("[test-suite] db: test hook presence in debug info", () => { }); -test("[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)", () => { +test('[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local n, v = debug.getlocal(0, 1) @@ -420,9 +420,9 @@ test("[test-suite] db: tests for manipulating non-registered locals (C and Lua t }); -test("[test-suite] db: testing access to function arguments", () => { +test('[test-suite] db: testing access to function arguments', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function collectlocals (level) @@ -469,9 +469,9 @@ test("[test-suite] db: testing access to function arguments", () => { }); -test("[test-suite] db: testing access to local variables in return hook (bug in 5.2)", () => { +test('[test-suite] db: testing access to local variables in return hook (bug in 5.2)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function collectlocals (level) @@ -516,9 +516,9 @@ test("[test-suite] db: testing access to local variables in return hook (bug in }); -test("[test-suite] db: testing upvalue access", () => { +test('[test-suite] db: testing upvalue access', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function getupvalues (f) @@ -556,9 +556,9 @@ test("[test-suite] db: testing upvalue access", () => { }); -test("[test-suite] db: testing count hooks", () => { +test('[test-suite] db: testing count hooks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a=0 @@ -586,9 +586,9 @@ test("[test-suite] db: testing count hooks", () => { }); -test("[test-suite] db: tests for tail calls", () => { +test('[test-suite] db: tests for tail calls', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (x) @@ -652,9 +652,9 @@ test("[test-suite] db: tests for tail calls", () => { }); -test("[test-suite] db: testing local function information", () => { +test('[test-suite] db: testing local function information', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = load[[ @@ -682,9 +682,9 @@ test("[test-suite] db: testing local function information", () => { }); -test("[test-suite] db: testing traceback", () => { +test('[test-suite] db: testing traceback', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(debug.traceback(print) == print) @@ -707,9 +707,9 @@ test("[test-suite] db: testing traceback", () => { }); -test("[test-suite] db: testing nparams, nups e isvararg", () => { +test('[test-suite] db: testing nparams, nups e isvararg', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = debug.getinfo(print, "u") @@ -732,9 +732,9 @@ test("[test-suite] db: testing nparams, nups e isvararg", () => { }); -test("[test-suite] db: testing debugging of coroutines", () => { +test('[test-suite] db: testing debugging of coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checktraceback (co, p, level) @@ -805,15 +805,15 @@ test("[test-suite] db: testing debugging of coroutines", () => { `; lualib.luaL_openlibs(L); let b = to_luastring(luaCode); - if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring('@db.lua')) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test("[test-suite] db: check get/setlocal in coroutines", () => { +test('[test-suite] db: check get/setlocal in coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = coroutine.create(function (x) @@ -838,9 +838,9 @@ test("[test-suite] db: check get/setlocal in coroutines", () => { }); -test("[test-suite] db: check traceback of suspended (or dead with error) coroutines", () => { +test('[test-suite] db: check traceback of suspended (or dead with error) coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checktraceback (co, p, level) @@ -873,9 +873,9 @@ test("[test-suite] db: check traceback of suspended (or dead with error) corouti }); -test("[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function", () => { +test('[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function g(x) @@ -904,9 +904,9 @@ test("[test-suite] db: check test acessing line numbers of a coroutine from a re }); -test("[test-suite] db: test tagmethod information", () => { +test('[test-suite] db: test tagmethod information', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -944,9 +944,9 @@ test("[test-suite] db: test tagmethod information", () => { }); -test("[test-suite] db: testing for-iterator name", () => { +test('[test-suite] db: testing for-iterator name', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -964,9 +964,9 @@ test("[test-suite] db: testing for-iterator name", () => { }); -test("[test-suite] db: testing traceback sizes", () => { +test('[test-suite] db: testing traceback sizes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function countlines (s) @@ -1006,15 +1006,15 @@ test("[test-suite] db: testing traceback sizes", () => { `; lualib.luaL_openlibs(L); let b = to_luastring(luaCode); - if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring('@db.lua')) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test("[test-suite] db: testing debug functions on chunk without debug info", () => { +test('[test-suite] db: testing debug functions on chunk without debug info', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` prog = [[-- program to be loaded without debug information @@ -1067,9 +1067,9 @@ test("[test-suite] db: testing debug functions on chunk without debug info", () }); -test("[test-suite] db: tests for 'source' in binary dumps", () => { +test('[test-suite] db: tests for \'source\' in binary dumps', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/errors.test.js b/test/test-suite/errors.test.js index 83c7a909..8c514056 100644 --- a/test/test-suite/errors.test.js +++ b/test/test-suite/errors.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` -- avoid problems with 'strict' module (which may generate other error messages) @@ -42,9 +42,9 @@ const prefix = ` end `; -test("[test-suite] errors: test error message with no extra info", () => { +test('[test-suite] errors: test error message with no extra info', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(doit("error('hi', 0)") == 'hi') @@ -56,9 +56,9 @@ test("[test-suite] errors: test error message with no extra info", () => { }); -test("[test-suite] errors: test error message with no info", () => { +test('[test-suite] errors: test error message with no info', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(doit("error()") == nil) @@ -70,9 +70,9 @@ test("[test-suite] errors: test error message with no info", () => { }); -test("[test-suite] errors: test common errors/errors that crashed in the past", () => { +test('[test-suite] errors: test common errors/errors that crashed in the past', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(doit("table.unpack({}, 1, n=2^30)")) @@ -99,9 +99,9 @@ test("[test-suite] errors: test common errors/errors that crashed in the past", }); -test("[test-suite] errors: tests for better error messages", () => { +test('[test-suite] errors: tests for better error messages', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("a = {} + 1", "arithmetic") @@ -133,9 +133,9 @@ test("[test-suite] errors: tests for better error messages", () => { }); -test("[test-suite] errors: upvalues being indexed do not go to the stack", () => { +test('[test-suite] errors: upvalues being indexed do not go to the stack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("local a,b,cc; (function () a = cc[1] end)()", "upvalue 'cc'") @@ -155,9 +155,9 @@ test("[test-suite] errors: upvalues being indexed do not go to the stack", () => }); -test("[test-suite] errors: short circuit", () => { +test('[test-suite] errors: short circuit', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("a=1; local a,bbbb=2,3; a = math.sin(1) and bbbb(3)", @@ -180,9 +180,9 @@ test("[test-suite] errors: short circuit", () => { }); -test("[test-suite] errors: float->integer conversions", () => { +test('[test-suite] errors: float->integer conversions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("local a = 2.0^100; x = a << 2", "local a") @@ -210,9 +210,9 @@ test("[test-suite] errors: float->integer conversions", () => { }); -test("[test-suite] errors: passing light userdata instead of full userdata", () => { +test('[test-suite] errors: passing light userdata instead of full userdata', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.D = debug @@ -230,9 +230,9 @@ test("[test-suite] errors: passing light userdata instead of full userdata", () }); -test("[test-suite] errors: named objects (field '__name')", () => { +test('[test-suite] errors: named objects (field \'__name\')', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -255,9 +255,9 @@ test("[test-suite] errors: named objects (field '__name')", () => { }); -test("[test-suite] errors: global functions", () => { +test('[test-suite] errors: global functions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("(io.write or print){}", "io.write") @@ -270,9 +270,9 @@ test("[test-suite] errors: global functions", () => { }); -test("[test-suite] errors: errors in functions without debug info", () => { +test('[test-suite] errors: errors in functions without debug info', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -296,9 +296,9 @@ test("[test-suite] errors: errors in functions without debug info", () => { }); -test("[test-suite] errors: tests for field accesses after RK limit", () => { +test('[test-suite] errors: tests for field accesses after RK limit', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -319,9 +319,9 @@ test("[test-suite] errors: tests for field accesses after RK limit", () => { }); -test("[test-suite] errors: global", () => { +test('[test-suite] errors: global', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[aaa=9 @@ -342,9 +342,9 @@ test("[test-suite] errors: global", () => { }); -test("[test-suite] errors: field", () => { +test('[test-suite] errors: field', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -359,9 +359,9 @@ test("[test-suite] errors: field", () => { }); -test("[test-suite] errors: global insert", () => { +test('[test-suite] errors: global insert', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -380,9 +380,9 @@ test("[test-suite] errors: global insert", () => { }); -test("[test-suite] errors: sin", () => { +test('[test-suite] errors: sin', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ -- tail call @@ -396,9 +396,9 @@ test("[test-suite] errors: sin", () => { }); -test("[test-suite] errors: concatenate", () => { +test('[test-suite] errors: concatenate', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[x = print .. "a"]], "concatenate") @@ -412,9 +412,9 @@ test("[test-suite] errors: concatenate", () => { }); -test("[test-suite] errors: unknown global", () => { +test('[test-suite] errors: unknown global', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -432,9 +432,9 @@ test("[test-suite] errors: unknown global", () => { }); -test("[test-suite] errors: __index", () => { +test('[test-suite] errors: __index', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {}; setmetatable(a, {__index = string}) @@ -452,9 +452,9 @@ test("[test-suite] errors: __index", () => { }); -test("[test-suite] errors: tests for errors in coroutines", () => { +test('[test-suite] errors: tests for errors in coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (n) @@ -476,9 +476,9 @@ test("[test-suite] errors: tests for errors in coroutines", () => { }); -test("[test-suite] errors: testing size of 'source' info", () => { +test('[test-suite] errors: testing size of \'source\' info', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` idsize = 60 - 1 @@ -503,9 +503,9 @@ test("[test-suite] errors: testing size of 'source' info", () => { }); -test("[test-suite] errors: testing line error", () => { +test('[test-suite] errors: testing line error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function lineerror (s, l) @@ -568,9 +568,9 @@ test("[test-suite] errors: testing line error", () => { }); -test("[test-suite] errors: several tests that exhaust the Lua stack", () => { +test('[test-suite] errors: several tests that exhaust the Lua stack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = 0 @@ -591,9 +591,9 @@ test("[test-suite] errors: several tests that exhaust the Lua stack", () => { }); -test("[test-suite] errors: error lines in stack overflow", () => { +test('[test-suite] errors: error lines in stack overflow', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = 0 @@ -622,9 +622,9 @@ test("[test-suite] errors: error lines in stack overflow", () => { }); -test("[test-suite] errors: error in error handling", () => { +test('[test-suite] errors: error in error handling', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local res, msg = xpcall(error, error) @@ -647,9 +647,9 @@ test("[test-suite] errors: error in error handling", () => { }); -test("[test-suite] errors: too many results", () => { +test('[test-suite] errors: too many results', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function loop (x,y,z) return 1 + loop(x, y, z) end @@ -674,9 +674,9 @@ test("[test-suite] errors: too many results", () => { }); -test("[test-suite] errors: non string messages", () => { +test('[test-suite] errors: non string messages', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -714,15 +714,15 @@ test("[test-suite] errors: non string messages", () => { end `; lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua")) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring('@errors.lua')) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test("[test-suite] errors: xpcall with arguments", () => { +test('[test-suite] errors: xpcall with arguments', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a, b, c = xpcall(string.find, error, "alo", "al") @@ -737,9 +737,9 @@ test("[test-suite] errors: xpcall with arguments", () => { }); -test("[test-suite] errors: testing tokens in error messages", () => { +test('[test-suite] errors: testing tokens in error messages', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("syntax error", "", "error", 1) @@ -756,9 +756,9 @@ test("[test-suite] errors: testing tokens in error messages", () => { }); -test("[test-suite] errors: test invalid non-printable char in a chunk", () => { +test('[test-suite] errors: test invalid non-printable char in a chunk', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("a\\1a = 1", "", "<\\\\1>", 1) @@ -770,9 +770,9 @@ test("[test-suite] errors: test invalid non-printable char in a chunk", () => { }); -test("[test-suite] errors: test 255 as first char in a chunk", () => { +test('[test-suite] errors: test 255 as first char in a chunk', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("\\255a = 1", "", "<\\\\255>", 1) @@ -787,9 +787,9 @@ test("[test-suite] errors: test 255 as first char in a chunk", () => { }); -test("[test-suite] errors: lots of errors", () => { +test('[test-suite] errors: lots of errors', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` lim = 1000 @@ -806,9 +806,9 @@ test("[test-suite] errors: lots of errors", () => { }); -test("[test-suite] errors: testing syntax limits", () => { +test('[test-suite] errors: testing syntax limits', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local maxClevel = 200 -- LUAI_MAXCCALLS (in llimits.h) @@ -841,9 +841,9 @@ test("[test-suite] errors: testing syntax limits", () => { }); -test("[test-suite] errors: upvalues limit", () => { +test('[test-suite] errors: upvalues limit', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local lim = 127 @@ -875,9 +875,9 @@ test("[test-suite] errors: upvalues limit", () => { }); -test("[test-suite] errors: local variables limit", () => { +test('[test-suite] errors: local variables limit', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` s = "\\nfunction foo ()\\n local " diff --git a/test/test-suite/events.test.js b/test/test-suite/events.test.js index 67faad64..085a2461 100644 --- a/test/test-suite/events.test.js +++ b/test/test-suite/events.test.js @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const ltests = require('./ltests.js'); -test("[test-suite] events: testing metatable", () => { +test('[test-suite] events: testing metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` X = 20; B = 30 @@ -190,9 +190,9 @@ test("[test-suite] events: testing metatable", () => { }); -test("[test-suite] events: test for rawlen", () => { +test('[test-suite] events: test for rawlen', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = setmetatable({1,2,3}, {__len = function () return 10 end}) @@ -212,9 +212,9 @@ test("[test-suite] events: test for rawlen", () => { }); -test("[test-suite] events: test comparison", () => { +test('[test-suite] events: test comparison', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -261,9 +261,9 @@ test("[test-suite] events: test comparison", () => { }); -test("[test-suite] events: test 'partial order'", () => { +test('[test-suite] events: test \'partial order\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -332,9 +332,9 @@ test("[test-suite] events: test 'partial order'", () => { }); -test("[test-suite] events: __eq between userdata", () => { +test('[test-suite] events: __eq between userdata', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T = require('T') @@ -364,9 +364,9 @@ test("[test-suite] events: __eq between userdata", () => { }); -test("[test-suite] events: concat", () => { +test('[test-suite] events: concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -403,9 +403,9 @@ test("[test-suite] events: concat", () => { }); -test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { +test('[test-suite] events: concat metamethod x numbers (bug in 5.1.1)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` c = {} @@ -425,9 +425,9 @@ test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { }); -test("[test-suite] events: test comparison compatibilities", () => { +test('[test-suite] events: test comparison compatibilities', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1, t2, c, d @@ -451,9 +451,9 @@ test("[test-suite] events: test comparison compatibilities", () => { }); -test("[test-suite] events: test for several levels of callstest for several levels of calls", () => { +test('[test-suite] events: test for several levels of callstest for several levels of calls', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local i @@ -482,9 +482,9 @@ test("[test-suite] events: test for several levels of callstest for several leve }); -test("[test-suite] events: __index on _ENV", () => { +test('[test-suite] events: __index on _ENV', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local _g = _G @@ -502,9 +502,9 @@ test("[test-suite] events: __index on _ENV", () => { }); -test("[test-suite] events: testing metatables for basic types", () => { +test('[test-suite] events: testing metatables for basic types', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` mt = {__index = function (a,b) return a+b end, @@ -544,9 +544,9 @@ test("[test-suite] events: testing metatables for basic types", () => { }); -test("[test-suite] events: loops in delegation", () => { +test('[test-suite] events: loops in delegation', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {}; setmetatable(a, a); a.__index = a; a.__newindex = a @@ -561,9 +561,9 @@ test("[test-suite] events: loops in delegation", () => { }); -test("[test-suite] events: bug in 5.1", () => { +test('[test-suite] events: bug in 5.1', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T, K, V = nil diff --git a/test/test-suite/goto.test.js b/test/test-suite/goto.test.js index 17e0397d..95b5903b 100644 --- a/test/test-suite/goto.test.js +++ b/test/test-suite/goto.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); -test("[test-suite] goto: error messages", () => { +test('[test-suite] goto: error messages', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function errmsg (code, m) @@ -53,9 +53,9 @@ test("[test-suite] goto: error messages", () => { }); -test("[test-suite] goto", () => { +test('[test-suite] goto', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- simple gotos @@ -120,9 +120,9 @@ test("[test-suite] goto", () => { }); -test("[test-suite] goto: to repeat a label in a different function is OK", () => { +test('[test-suite] goto: to repeat a label in a different function is OK', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () @@ -148,9 +148,9 @@ test("[test-suite] goto: to repeat a label in a different function is OK", () => }); -test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { +test('[test-suite] goto: bug in 5.2 -> 5.3.2', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- bug in 5.2 -> 5.3.2 @@ -175,9 +175,9 @@ test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { }); -test("[test-suite] goto: testing closing of upvalues", () => { +test('[test-suite] goto: testing closing of upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () @@ -248,9 +248,9 @@ test("[test-suite] goto: testing closing of upvalues", () => { }); -test("[test-suite] goto: testing if x goto optimizations", () => { +test('[test-suite] goto: testing if x goto optimizations', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function testG (a) diff --git a/test/test-suite/literals.test.js b/test/test-suite/literals.test.js index 3e9307bf..ecddad5e 100644 --- a/test/test-suite/literals.test.js +++ b/test/test-suite/literals.test.js @@ -1,17 +1,17 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const dostring = ` local function dostring (x) return assert(load(x), "")() end `; -test("[test-suite] literals: dostring", () => { +test('[test-suite] literals: dostring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` dostring("x \\v\\f = \\t\\r 'a\\0a' \\v\\f\\f") @@ -25,9 +25,9 @@ test("[test-suite] literals: dostring", () => { // TODO: bell character '\a' in JS is parsed as 'a' -test("[test-suite] literals: escape sequences", () => { +test('[test-suite] literals: escape sequences', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('\\n\\"\\'\\\\' == [[ @@ -42,9 +42,9 @@ test("[test-suite] literals: escape sequences", () => { }); -test("[test-suite] literals: assume ASCII just for tests", () => { +test('[test-suite] literals: assume ASCII just for tests', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\09912" == 'c12') @@ -62,9 +62,9 @@ test("[test-suite] literals: assume ASCII just for tests", () => { }); -test("[test-suite] literals: hexadecimal escapes", () => { +test('[test-suite] literals: hexadecimal escapes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\x00\\x05\\x10\\x1f\\x3C\\xfF\\xe8" == "\\0\\5\\16\\31\\60\\255\\232") @@ -97,9 +97,9 @@ assert("abc\\z }); -test("[test-suite] literals: UTF-8 sequences", () => { +test('[test-suite] literals: UTF-8 sequences', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\u{0}\\u{00000000}\\x00\\0" == string.char(0, 0, 0, 0)) @@ -123,9 +123,9 @@ test("[test-suite] literals: UTF-8 sequences", () => { }); -test("[test-suite] literals: Error in escape sequences", () => { +test('[test-suite] literals: Error in escape sequences', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function lexerror (s, err) @@ -177,9 +177,9 @@ test("[test-suite] literals: Error in escape sequences", () => { }); -test("[test-suite] literals: valid characters in variable names", () => { +test('[test-suite] literals: valid characters in variable names', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 0, 255 do @@ -196,9 +196,9 @@ test("[test-suite] literals: valid characters in variable names", () => { }); -test("[test-suite] literals: long variable names", () => { +test('[test-suite] literals: long variable names', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` var1 = string.rep('a', 15000) .. '1' @@ -219,9 +219,9 @@ test("[test-suite] literals: long variable names", () => { }); -test("[test-suite] literals: escapes", () => { +test('[test-suite] literals: escapes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `assert("\\n\\t" == [[\n\n\t]]) assert([[\n\n $debug]] == "\\n $debug") @@ -233,9 +233,9 @@ assert([[ [ ]] ~= [[ ] ]])`; }); -test("[test-suite] literals: long strings", () => { +test('[test-suite] literals: long strings', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789" assert(string.len(b) == 960) @@ -296,9 +296,9 @@ b = nil`; }); -test("[test-suite] literals: testing line ends", () => { +test('[test-suite] literals: testing line ends', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `prog = [[ a = 1 -- a comment @@ -326,9 +326,9 @@ end`; }); -test("[test-suite] literals: testing comments and strings with long brackets", () => { +test('[test-suite] literals: testing comments and strings with long brackets', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `a = [==[]=]==] assert(a == "]=") @@ -356,9 +356,9 @@ error error]=]===]`; }); -test("[test-suite] literals: generate all strings of four of these chars", () => { +test('[test-suite] literals: generate all strings of four of these chars', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `local x = {"=", "[", "]", "\\n"} local len = 4 @@ -381,9 +381,9 @@ end`; }); -test("[test-suite] literals: testing %q x line ends", () => { +test('[test-suite] literals: testing %q x line ends', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "a string with \\r and \\n and \\r\\n and \\n\\r" @@ -397,9 +397,9 @@ test("[test-suite] literals: testing %q x line ends", () => { }); -test("[test-suite] literals: testing errors", () => { +test('[test-suite] literals: testing errors', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not load"a = 'non-ending string") diff --git a/test/test-suite/locals.test.js b/test/test-suite/locals.test.js index 27015194..821d0e03 100644 --- a/test/test-suite/locals.test.js +++ b/test/test-suite/locals.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); test('[test-suite] locals: bug in 5.1', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f(x) x = nil; return x end @@ -28,7 +28,7 @@ test('[test-suite] locals: bug in 5.1', () => { test('[test-suite] locals: local scope', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -97,7 +97,7 @@ const getenv = ` test('[test-suite] locals: test for global table of loaded chunks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(getenv(load"a=3") == _G) @@ -116,7 +116,7 @@ test('[test-suite] locals: test for global table of loaded chunks', () => { test('[test-suite] locals: old test for limits for special instructions (now just a generic test)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -147,7 +147,7 @@ test('[test-suite] locals: old test for limits for special instructions (now jus test('[test-suite] locals: testing lexical environments', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(_ENV == _G) diff --git a/test/test-suite/ltests.js b/test/test-suite/ltests.js index 6fc086c9..948a7b86 100644 --- a/test/test-suite/ltests.js +++ b/test/test-suite/ltests.js @@ -1,6 +1,6 @@ -"use strict"; +'use strict'; -const assert = require("assert"); +const assert = require('assert'); const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); @@ -9,13 +9,13 @@ const { luastring_indexOf, to_jsstring, to_luastring -} = require("../../src/fengaricore.js"); +} = require('../../src/fengaricore.js'); const ljstype = require('../../src/ljstype.js'); const lopcodes = require('../../src/lopcodes.js'); const { pushobj2s } = require('../../src/lobject.js'); const sprintf = require('sprintf-js').sprintf; -const delimits = [" ", "\t", "\n", ",", ";"].map(e => e.charCodeAt(0)); +const delimits = [' ', '\t', '\n', ',', ';'].map(e => e.charCodeAt(0)); const skip = function(pc) { for (;;) { @@ -47,7 +47,7 @@ const getnum = function(L, L1, pc) { pc.offset++; } if (!ljstype.lisdigit(pc.script[pc.offset])) - lauxlib.luaL_error(L, to_luastring("number expected (%s)"), pc.script); + lauxlib.luaL_error(L, to_luastring('number expected (%s)'), pc.script); while (ljstype.lisdigit(pc.script[pc.offset])) res = res*10 + pc.script[pc.offset++] - '0'.charCodeAt(0); return sig*res; }; @@ -59,7 +59,7 @@ const getstring = function(L, buff, pc) { let quote = pc.script[pc.offset++]; while (pc.script[pc.offset] !== quote) { if (pc.script[pc.offset] === 0 || pc.offset >= pc.script.length) - lauxlib.luaL_error(L, to_luastring("unfinished string in JS script", true)); + lauxlib.luaL_error(L, to_luastring('unfinished string in JS script', true)); buff[i++] = pc.script[pc.offset++]; } pc.offset++; @@ -74,13 +74,13 @@ const getindex = function(L, L1, pc) { skip(pc); switch (pc.script[pc.offset++]) { case 'R'.charCodeAt(0): return lua.LUA_REGISTRYINDEX; - case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, to_luastring("deprecated index 'G'", true)); + case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, to_luastring('deprecated index \'G\'', true)); case 'U'.charCodeAt(0): return lua.lua_upvalueindex(getnum(L, L1, pc)); default: pc.offset--; return getnum(L, L1, pc); } }; -const codes = ["OK", "YIELD", "ERRRUN", "ERRSYNTAX", "ERRMEM", "ERRGCMM", "ERRERR"].map(e => to_luastring(e)); +const codes = ['OK', 'YIELD', 'ERRRUN', 'ERRSYNTAX', 'ERRMEM', 'ERRGCMM', 'ERRERR'].map(e => to_luastring(e)); const pushcode = function(L, code) { lua.lua_pushstring(L, codes[code]); @@ -89,10 +89,10 @@ const pushcode = function(L, code) { const printstack = function(L) { let n = lua.lua_gettop(L); for (let i = 1; i <= n; i++) { - console.log("${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n"); + console.log('${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n'); lua.lua_pop(L, 1); } - console.log(""); + console.log(''); }; /* @@ -103,47 +103,47 @@ const printstack = function(L) { ** LUA_OPUNM -> _ ** LUA_OPBNOT -> ! */ -const ops = "+-*%^/\\&|~<>_!".split('').map(e => e.charCodeAt(0)); +const ops = '+-*%^/\\&|~<>_!'.split('').map(e => e.charCodeAt(0)); const runJS = function(L, L1, pc) { let buff = new Uint8Array(300); let status = 0; - if (!pc || !pc.script) return lauxlib.luaL_error(L, to_luastring("attempt to runJS null script")); + if (!pc || !pc.script) return lauxlib.luaL_error(L, to_luastring('attempt to runJS null script')); for (;;) { let inst = to_jsstring(getstring(L, buff, pc)); if (inst.length === 0) return 0; switch (inst) { - case "absindex": { + case 'absindex': { lua.lua_pushnumber(L1, lua.lua_absindex(L1, getindex(L, L1, pc))); break; } - case "append": { + case 'append': { let t = getindex(L, L1, pc); let i = lua.lua_rawlen(L1, t); lua.lua_rawseti(L1, t, i + 1); break; } - case "arith": { + case 'arith': { let op; skip(pc); op = ops.indexOf(pc.script[pc.offset++]); lua.lua_arith(L1, op); break; } - case "call": { + case 'call': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); lua.lua_call(L1, narg, nres); break; } - case "callk": { + case 'callk': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); lua.lua_callk(L1, narg, nres, i, Cfunck); break; } - case "checkstack": { + case 'checkstack': { let sz = getnum(L, L1, pc); let msg = getstring(L, buff, pc); if (msg.length === 0) @@ -151,7 +151,7 @@ const runJS = function(L, L1, pc) { lauxlib.luaL_checkstack(L1, sz, msg); break; } - case "compare": { + case 'compare': { let opt = getstring(L, buff, pc); /* EQ, LT, or LE */ let op = (opt[0] === 'E'.charCodeAt(0)) ? lua.LUA_OPEQ @@ -161,150 +161,150 @@ const runJS = function(L, L1, pc) { lua.lua_pushboolean(L1, lua.lua_compare(L1, a, b, op)); break; } - case "concat": { + case 'concat': { lua.lua_concat(L1, getnum(L, L1, pc)); break; } - case "copy": { + case 'copy': { let f = getindex(L, L1, pc); lua.lua_copy(L1, f, getindex(L, L1, pc)); break; } - case "func2num": { + case 'func2num': { let func = lua.lua_tocfunction(L1, getindex(L, L1, pc)); if (func === null) func = 0; else if (func.id) func = func.id; lua.lua_pushnumber(L1, func); break; } - case "getfield": { + case 'getfield': { let t = getindex(L, L1, pc); lua.lua_getfield(L1, t, getstring(L, buff, pc)); break; } - case "getglobal": { + case 'getglobal': { lua.lua_getglobal(L1, getstring(L, buff, pc)); break; } - case "getmetatable": { + case 'getmetatable': { if (lua.lua_getmetatable(L1, getindex(L, L1, pc)) === 0) lua.lua_pushnil(L1); break; } - case "gettable": { + case 'gettable': { lua.lua_gettable(L1, getindex(L, L1, pc)); break; } - case "gettop": { + case 'gettop': { lua.lua_pushinteger(L1, lua.lua_gettop(L1)); break; } - case "gsub": { + case 'gsub': { let a = getnum(L, L1, pc); let b = getnum(L, L1, pc); let c = getnum(L, L1, pc); lauxlib.luaL_gsub(L1, lua.lua_tostring(L1, a), lua.lua_tostring(L1, b), lua.lua_tostring(L1, c)); break; } - case "insert": { + case 'insert': { lua.lua_insert(L1, getnum(L, L1, pc)); break; } - case "iscfunction": { + case 'iscfunction': { lua.lua_pushboolean(L1, lua.lua_iscfunction(L1, getindex(L, L1, pc))); break; } - case "isfunction": { + case 'isfunction': { lua.lua_pushboolean(L1, lua.lua_isfunction(L1, getindex(L, L1, pc))); break; } - case "isnil": { + case 'isnil': { lua.lua_pushboolean(L1, lua.lua_isnil(L1, getindex(L, L1, pc))); break; } - case "isnull": { + case 'isnull': { lua.lua_pushboolean(L1, lua.lua_isnone(L1, getindex(L, L1, pc))); break; } - case "isnumber": { + case 'isnumber': { lua.lua_pushboolean(L1, lua.lua_isnumber(L1, getindex(L, L1, pc))); break; } - case "isstring": { + case 'isstring': { lua.lua_pushboolean(L1, lua.lua_isstring(L1, getindex(L, L1, pc))); break; } - case "istable": { + case 'istable': { lua.lua_pushboolean(L1, lua.lua_istable(L1, getindex(L, L1, pc))); break; } - case "isudataval": { + case 'isudataval': { lua.lua_pushboolean(L1, lua.lua_islightuserdata(L1, getindex(L, L1, pc))); break; } - case "isuserdata": { + case 'isuserdata': { lua.lua_pushboolean(L1, lua.lua_isuserdata(L1, getindex(L, L1, pc))); break; } - case "len": { + case 'len': { lua.lua_len(L1, getindex(L, L1, pc)); break; } - case "Llen": { + case 'Llen': { lua.lua_pushinteger(L1, lauxlib.luaL_len(L1, getindex(L, L1, pc))); break; } - case "loadfile": { + case 'loadfile': { lauxlib.luaL_loadfile(L1, lauxlib.luaL_checkstring(L1, getnum(L, L1, pc))); break; } - case "loadstring": { + case 'loadstring': { let s = lauxlib.luaL_checkstring(L1, getnum(L, L1, pc)); lauxlib.luaL_loadstring(L1, s); break; } - case "newmetatable": { + case 'newmetatable': { lua.lua_pushboolean(L1, lauxlib.luaL_newmetatable(L1, getstring(L, buff, pc))); break; } - case "newtable": { + case 'newtable': { lua.lua_newtable(L1); break; } - case "newthread": { + case 'newthread': { lua.lua_newthread(L1); break; } - case "newuserdata": { + case 'newuserdata': { lua.lua_newuserdata(L1, getnum(L, L1, pc)); break; } - case "next": { + case 'next': { lua.lua_next(L1, -2); break; } - case "objsize": { + case 'objsize': { lua.lua_pushinteger(L1, lua.lua_rawlen(L1, getindex(L, L1, pc))); break; } - case "pcall": { + case 'pcall': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); status = lua.lua_pcall(L1, narg, nres, getnum(L, L1, pc)); break; } - case "pcallk": { + case 'pcallk': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); status = lua.lua_pcallk(L1, narg, nres, 0, i, Cfunck); break; } - case "pop": { + case 'pop': { lua.lua_pop(L1, getnum(L, L1, pc)); break; } - case "print": { + case 'print': { let n = getnum(L, L1, pc); if (n !== 0) { console.log(`${lauxlib.luaL_tojsstring(L1, n, null)}\n`); @@ -313,71 +313,71 @@ const runJS = function(L, L1, pc) { else printstack(L1); break; } - case "pushbool": { + case 'pushbool': { lua.lua_pushboolean(L1, getnum(L, L1, pc)); break; } - case "pushcclosure": { + case 'pushcclosure': { lua.lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); break; } - case "pushint": { + case 'pushint': { lua.lua_pushinteger(L1, getnum(L, L1, pc)); break; } - case "pushnil": { + case 'pushnil': { lua.lua_pushnil(L1); break; } - case "pushnum": { + case 'pushnum': { lua.lua_pushnumber(L1, getnum(L, L1, pc)); break; } - case "pushstatus": { + case 'pushstatus': { pushcode(L1, status); break; } - case "pushstring": { + case 'pushstring': { lua.lua_pushstring(L1, getstring(L, buff, pc)); break; } - case "pushupvalueindex": { + case 'pushupvalueindex': { lua.lua_pushinteger(L1, lua.lua_upvalueindex(getnum(L, L1, pc))); break; } - case "pushvalue": { + case 'pushvalue': { lua.lua_pushvalue(L1, getindex(L, L1, pc)); break; } - case "rawgeti": { + case 'rawgeti': { let t = getindex(L, L1, pc); lua.lua_rawgeti(L1, t, getnum(L, L1, pc)); break; } - case "rawgetp": { + case 'rawgetp': { let t = getindex(L, L1, pc); lua.lua_rawgetp(L1, t, getnum(L, L1, pc)); break; } - case "rawsetp": { + case 'rawsetp': { let t = getindex(L, L1, pc); lua.lua_rawsetp(L1, t, getnum(L, L1, pc)); break; } - case "remove": { + case 'remove': { lua.lua_remove(L1, getnum(L, L1, pc)); break; } - case "replace": { + case 'replace': { lua.lua_replace(L1, getindex(L, L1, pc)); break; } - case "resume": { + case 'resume': { let i = getindex(L, L1, pc); status = lua.lua_resume(lua.lua_tothread(L1, i), L, getnum(L, L1, pc)); break; } - case "return": { + case 'return': { let n = getnum(L, L1, pc); if (L1 != L) { let i; @@ -386,84 +386,84 @@ const runJS = function(L, L1, pc) { } return n; } - case "rotate": { + case 'rotate': { let i = getindex(L, L1, pc); lua.lua_rotate(L1, i, getnum(L, L1, pc)); break; } - case "setfield": { + case 'setfield': { let t = getindex(L, L1, pc); lua.lua_setfield(L1, t, getstring(L, buff, pc)); break; } - case "setglobal": { + case 'setglobal': { lua.lua_setglobal(L1, getstring(L, buff, pc)); break; } - case "sethook": { + case 'sethook': { let mask = getnum(L, L1, pc); let count = getnum(L, L1, pc); sethookaux(L1, mask, count, getstring(L, buff, pc)); break; } - case "setmetatable": { + case 'setmetatable': { lua.lua_setmetatable(L1, getindex(L, L1, pc)); break; } - case "settable": { + case 'settable': { lua.lua_settable(L1, getindex(L, L1, pc)); break; } - case "settop": { + case 'settop': { lua.lua_settop(L1, getnum(L, L1, pc)); break; } - case "testudata": { + case 'testudata': { let i = getindex(L, L1, pc); lua.lua_pushboolean(L1, lauxlib.luaL_testudata(L1, i, getstring(L, buff, pc)) !== null); break; } - case "error": { + case 'error': { lua.lua_error(L1); break; } - case "throw": { + case 'throw': { throw new Error(); } - case "tobool": { + case 'tobool': { lua.lua_pushboolean(L1, lua.lua_toboolean(L1, getindex(L, L1, pc))); break; } - case "tocfunction": { + case 'tocfunction': { lua.lua_pushcfunction(L1, lua.lua_tocfunction(L1, getindex(L, L1, pc))); break; } - case "tointeger": { + case 'tointeger': { lua.lua_pushinteger(L1, lua.lua_tointeger(L1, getindex(L, L1, pc))); break; } - case "tonumber": { + case 'tonumber': { lua.lua_pushnumber(L1, lua.lua_tonumber(L1, getindex(L, L1, pc))); break; } - case "topointer": { + case 'topointer': { let p = lua.lua_topointer(L1, getindex(L, L1, pc)); if (p === null) p = 0; else if (p.id) p = p.id; lua.lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */ break; } - case "tostring": { + case 'tostring': { let s = lua.lua_tostring(L1, getindex(L, L1, pc)); let s1 = lua.lua_pushstring(L1, s); assert(luastring_eq(s, s1)); break; } - case "type": { + case 'type': { lua.lua_pushstring(L1, lauxlib.luaL_typename(L1, getnum(L, L1, pc))); break; } - case "xmove": { + case 'xmove': { let f = getindex(L, L1, pc); let t = getindex(L, L1, pc); let fs = (f === 0) ? L1 : lua.lua_tothread(L1, f); @@ -473,16 +473,16 @@ const runJS = function(L, L1, pc) { lua.lua_xmove(fs, ts, n); break; } - case "yield": { + case 'yield': { return lua.lua_yield(L1, getnum(L, L1, pc)); } - case "yieldk": { + case 'yieldk': { let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); return lua.lua_yieldk(L1, nres, i, Cfunck); } default: - lauxlib.luaL_error(L, to_luastring("unknown instruction %s"), buff); + lauxlib.luaL_error(L, to_luastring('unknown instruction %s'), buff); } } }; @@ -559,36 +559,36 @@ const newstate = function(L) { const getstate = function(L) { let L1 = lua.lua_touserdata(L, 1); - lauxlib.luaL_argcheck(L, L1 !== null, 1, "state expected"); + lauxlib.luaL_argcheck(L, L1 !== null, 1, 'state expected'); return L1; }; -const luaopen_base = require("../../src/lbaselib.js").luaopen_base; -const luaopen_coroutine = require("../../src/lcorolib.js").luaopen_coroutine; -const luaopen_debug = require("../../src/ldblib.js").luaopen_debug; -const luaopen_io = require("../../src/liolib.js").luaopen_io; -const luaopen_os = require("../../src/loslib.js").luaopen_os; -const luaopen_math = require("../../src/lmathlib.js").luaopen_math; -const luaopen_string = require("../../src/lstrlib.js").luaopen_string; -const luaopen_table = require("../../src/ltablib.js").luaopen_table; -const luaopen_package = require("../../src/loadlib.js").luaopen_package; +const luaopen_base = require('../../src/lbaselib.js').luaopen_base; +const luaopen_coroutine = require('../../src/lcorolib.js').luaopen_coroutine; +const luaopen_debug = require('../../src/ldblib.js').luaopen_debug; +const luaopen_io = require('../../src/liolib.js').luaopen_io; +const luaopen_os = require('../../src/loslib.js').luaopen_os; +const luaopen_math = require('../../src/lmathlib.js').luaopen_math; +const luaopen_string = require('../../src/lstrlib.js').luaopen_string; +const luaopen_table = require('../../src/ltablib.js').luaopen_table; +const luaopen_package = require('../../src/loadlib.js').luaopen_package; const loadlib = function(L) { let libs = { - "_G": luaopen_base, - "coroutine": luaopen_coroutine, - "debug": luaopen_debug, - "io": luaopen_io, - "os": luaopen_os, - "math": luaopen_math, - "string": luaopen_string, - "table": luaopen_table + '_G': luaopen_base, + 'coroutine': luaopen_coroutine, + 'debug': luaopen_debug, + 'io': luaopen_io, + 'os': luaopen_os, + 'math': luaopen_math, + 'string': luaopen_string, + 'table': luaopen_table }; let L1 = getstate(L); - lauxlib.luaL_requiref(L1, to_luastring("package", true), luaopen_package, 0); + lauxlib.luaL_requiref(L1, to_luastring('package', true), luaopen_package, 0); assert(lua.lua_type(L1, -1) == lua.LUA_TTABLE); /* 'requiref' should not reload module already loaded... */ - lauxlib.luaL_requiref(L1, to_luastring("package", true), null, 1); /* seg. fault if it reloads */ + lauxlib.luaL_requiref(L1, to_luastring('package', true), null, 1); /* seg. fault if it reloads */ /* ...but should return the same module */ assert(lua.lua_compare(L1, -1, -2, lua.LUA_OPEQ)); lauxlib.luaL_getsubtable(L1, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE); @@ -644,8 +644,8 @@ const newuserdata = function(L) { */ const Chook = function(L, ar) { let scpt; - let events = ["call", "ret", "line", "count", "tailcall"].map(e => to_luastring(e)); - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); + let events = ['call', 'ret', 'line', 'count', 'tailcall'].map(e => to_luastring(e)); + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); lua.lua_pushlightuserdata(L, L); lua.lua_gettable(L, -2); /* get C_HOOK[L] (script saved by sethookaux) */ scpt = lua.lua_tostring(L, -1); /* not very religious (string will be popped) */ @@ -668,7 +668,7 @@ class Aux { const panicback = function(L) { let b = new Aux(); lua.lua_checkstack(L, 1); /* open space for 'Aux' struct */ - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* get 'Aux' struct */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring('_jmpbuf', true)); /* get 'Aux' struct */ b = lua.lua_touserdata(L, -1); lua.lua_pop(L, 1); /* remove 'Aux' struct */ runJS(b.L, L, { script: b.paniccode, offset: 0 }); /* run optional panic code */ @@ -678,7 +678,7 @@ const panicback = function(L) { const checkpanic = function(L) { let b = new Aux(); let code = lauxlib.luaL_checkstring(L, 1); - b.paniccode = lauxlib.luaL_optstring(L, 2, ""); + b.paniccode = lauxlib.luaL_optstring(L, 2, ''); b.L = L; let L1 = lua.lua_newstate(); /* create new state */ if (L1 === null) { /* error? */ @@ -687,10 +687,10 @@ const checkpanic = function(L) { } lua.lua_atpanic(L1, panicback); /* set its panic function */ lua.lua_pushlightuserdata(L1, b); - lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* store 'Aux' struct */ + lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, to_luastring('_jmpbuf', true)); /* store 'Aux' struct */ try { /* set jump buffer */ runJS(L, L1, { script: code, offset: 0 }); /* run code unprotected */ - lua.lua_pushliteral(L, "no errors"); + lua.lua_pushliteral(L, 'no errors'); } catch (e) { /* error handling */ /* move error message to original state */ lua.lua_pushstring(L, lua.lua_tostring(L1, -1)); @@ -707,12 +707,12 @@ const sethookaux = function(L, mask, count, scpt) { lua.lua_sethook(L, null, 0, 0); /* turn off hooks */ return; } - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* get C_HOOK table */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); /* get C_HOOK table */ if (!lua.lua_istable(L, -1)) { /* no hook table? */ lua.lua_pop(L, 1); /* remove previous value */ lua.lua_newtable(L); /* create new C_HOOK table */ lua.lua_pushvalue(L, -1); - lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* register it */ + lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); /* register it */ } lua.lua_pushlightuserdata(L, L); lua.lua_pushstring(L, scpt); @@ -743,9 +743,9 @@ const Cfunc = function(L) { const Cfunck = function(L, status, ctx) { pushcode(L, status); - lua.lua_setglobal(L, to_luastring("status", true)); + lua.lua_setglobal(L, to_luastring('status', true)); lua.lua_pushinteger(L, ctx); - lua.lua_setglobal(L, to_luastring("ctx", true)); + lua.lua_setglobal(L, to_luastring('ctx', true)); return runJS(L, L, { script: lua.lua_tostring(L, ctx), offset: 0 }); }; @@ -758,7 +758,7 @@ const makeCfunc = function(L) { const coresume = function(L) { let status; let co = lua.lua_tothread(L, 1); - lauxlib.luaL_argcheck(L, co, 1, "coroutine expected"); + lauxlib.luaL_argcheck(L, co, 1, 'coroutine expected'); status = lua.lua_resume(co, L, 0); if (status != lua.LUA_OK && status !== lua.LUA_YIELD) { lua.lua_pushboolean(L, 0); @@ -783,7 +783,7 @@ const setnameval = function(L, name, val) { const pushobject = function(L, o){ pushobj2s(L, o); - assert(L.top <= L.ci.top, "stack overflow"); + assert(L.top <= L.ci.top, 'stack overflow'); }; const buildop = function(p, pc) { @@ -791,19 +791,19 @@ const buildop = function(p, pc) { let o = lopcodes.GET_OPCODE(i); let name = lopcodes.OpCodes[o]; let line = p.lineinfo.length !== 0 ? p.lineinfo[pc] : -1; - let result = sprintf("(%4d) %4d - ", line, pc); //`(${line}) ${pc} - `; + let result = sprintf('(%4d) %4d - ', line, pc); //`(${line}) ${pc} - `; switch (lopcodes.getOpMode(o)) { case lopcodes.iABC: - result += sprintf("%-12s%4d %4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_B(i), lopcodes.GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; + result += sprintf('%-12s%4d %4d %4d', name, lopcodes.GETARG_A(i), lopcodes.GETARG_B(i), lopcodes.GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; break; case lopcodes.iABx: - result += sprintf("%-12s%4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; + result += sprintf('%-12s%4d %4d', name, lopcodes.GETARG_A(i), lopcodes.GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; break; case lopcodes.iAsBx: - result += sprintf("%-12s%4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; + result += sprintf('%-12s%4d %4d', name, lopcodes.GETARG_A(i), lopcodes.GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; break; case lopcodes.iAx: - result += sprintf("%-12s%4d", name, lopcodes.GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; + result += sprintf('%-12s%4d', name, lopcodes.GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; break; } @@ -812,11 +812,11 @@ const buildop = function(p, pc) { const listcode = function(L) { lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1), - 1, "Lua function expected"); + 1, 'Lua function expected'); let p = obj_at(L, 1); lua.lua_newtable(L); - setnameval(L, to_luastring("maxstack", true), p.maxstacksize); - setnameval(L, to_luastring("numparams", true), p.numparams); + setnameval(L, to_luastring('maxstack', true), p.maxstacksize); + setnameval(L, to_luastring('numparams', true), p.numparams); for (let pc = 0; pc < p.code.length; pc++) { lua.lua_pushinteger(L, pc+1); lua.lua_pushstring(L, buildop(p, pc)); @@ -828,7 +828,7 @@ const listcode = function(L) { const listk = function(L) { lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1), - 1, "Lua function expected"); + 1, 'Lua function expected'); let p = obj_at(L, 1); lua.lua_createtable(L, p.k.length, 0); for (let i = 0; i < p.k.length; i++) { @@ -839,24 +839,24 @@ const listk = function(L) { }; const tests_funcs = { - "checkpanic": checkpanic, - "closestate": closestate, - "d2s": d2s, - "doremote": doremote, - "listcode": listcode, - "listk": listk, - "loadlib": loadlib, - "makeCfunc": makeCfunc, - "newstate": newstate, - "newuserdata": newuserdata, - "pushuserdata": pushuserdata, - "resume": coresume, - "s2d": s2d, - "sethook": sethook, - "testC": testJS, - "testJS": testJS, - "udataval": udataval, - "upvalue": upvalue + 'checkpanic': checkpanic, + 'closestate': closestate, + 'd2s': d2s, + 'doremote': doremote, + 'listcode': listcode, + 'listk': listk, + 'loadlib': loadlib, + 'makeCfunc': makeCfunc, + 'newstate': newstate, + 'newuserdata': newuserdata, + 'pushuserdata': pushuserdata, + 'resume': coresume, + 's2d': s2d, + 'sethook': sethook, + 'testC': testJS, + 'testJS': testJS, + 'udataval': udataval, + 'upvalue': upvalue }; const luaB_opentests = function(L) { @@ -866,7 +866,7 @@ const luaB_opentests = function(L) { }; const luaopen_tests = function(L) { - lauxlib.luaL_requiref(L, to_luastring("T"), luaB_opentests, 1); + lauxlib.luaL_requiref(L, to_luastring('T'), luaB_opentests, 1); lua.lua_pop(L, 1); /* remove lib */ }; diff --git a/test/test-suite/math.test.js b/test/test-suite/math.test.js index 9cf4e21a..dacc038c 100644 --- a/test/test-suite/math.test.js +++ b/test/test-suite/math.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` local minint = math.mininteger @@ -52,9 +52,9 @@ const prefix = ` end `; -test("[test-suite] math: int bits", () => { +test('[test-suite] math: int bits', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -67,9 +67,9 @@ test("[test-suite] math: int bits", () => { }); -test("[test-suite] math: number of bits in the mantissa of a floating-point number", () => { +test('[test-suite] math: number of bits in the mantissa of a floating-point number', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(isNaN(0/0)) @@ -94,9 +94,9 @@ test("[test-suite] math: number of bits in the mantissa of a floating-point numb }); -test("[test-suite] math: basic float notation", () => { +test('[test-suite] math: basic float notation', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(0e12 == 0 and .0 == 0 and 0. == 0 and .2e2 == 20 and 2.E-1 == 0.2) @@ -146,9 +146,9 @@ test("[test-suite] math: basic float notation", () => { }); -test("[test-suite] math: math.huge", () => { +test('[test-suite] math: math.huge', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(math.huge > 10e30) @@ -161,9 +161,9 @@ test("[test-suite] math: math.huge", () => { }); -test("[test-suite] math: integer arithmetic", () => { +test('[test-suite] math: integer arithmetic', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint < minint + 1) @@ -179,9 +179,9 @@ test("[test-suite] math: integer arithmetic", () => { }); -test("[test-suite] math: testing floor division and conversions", () => { +test('[test-suite] math: testing floor division and conversions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for _, i in pairs{-16, -15, -3, -2, -1, 0, 1, 2, 3, 15} do @@ -222,9 +222,9 @@ test("[test-suite] math: testing floor division and conversions", () => { }); -test("[test-suite] math: negative exponents", () => { +test('[test-suite] math: negative exponents', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -247,9 +247,9 @@ test("[test-suite] math: negative exponents", () => { }); -test("[test-suite] math: comparison between floats and integers (border cases)", () => { +test('[test-suite] math: comparison between floats and integers (border cases)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if floatbits < intbits then @@ -275,9 +275,9 @@ test("[test-suite] math: comparison between floats and integers (border cases)", }); -test("[test-suite] math: order between floats and integers", () => { +test('[test-suite] math: order between floats and integers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -312,9 +312,9 @@ test("[test-suite] math: order between floats and integers", () => { }); -test("[test-suite] math: testing order (floats can represent all integers)", () => { +test('[test-suite] math: testing order (floats can represent all integers)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(floatbits >= intbits) @@ -354,9 +354,9 @@ test("[test-suite] math: testing order (floats can represent all integers)", () }); -test("[test-suite] math: NaN order", () => { +test('[test-suite] math: NaN order', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local NaN = 0/0 @@ -375,9 +375,9 @@ test("[test-suite] math: NaN order", () => { }); -test("[test-suite] math: avoiding errors at compile time", () => { +test('[test-suite] math: avoiding errors at compile time', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkcompt("divide by zero", "return 2 // 0") @@ -393,9 +393,9 @@ test("[test-suite] math: avoiding errors at compile time", () => { lua.lua_call(L, 0, 0); }); -test("[test-suite] math: testing overflow errors when converting from float to integer (runtime)", () => { +test('[test-suite] math: testing overflow errors when converting from float to integer (runtime)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f2i (x) return x | x end @@ -435,9 +435,9 @@ test("[test-suite] math: testing overflow errors when converting from float to i }); -test("[test-suite] math: testing numeric strings", () => { +test('[test-suite] math: testing numeric strings', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("2" + 1 == 3) @@ -452,9 +452,9 @@ test("[test-suite] math: testing numeric strings", () => { }); -test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () => { +test('[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -498,9 +498,9 @@ test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () }); -test("[test-suite] math: 'tonumber' with numbers", () => { +test('[test-suite] math: \'tonumber\' with numbers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber(3.4) == 3.4) @@ -515,9 +515,9 @@ test("[test-suite] math: 'tonumber' with numbers", () => { }); -test("[test-suite] math: 'tonumber' with strings", () => { +test('[test-suite] math: \'tonumber\' with strings', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber("0") == 0) @@ -565,9 +565,9 @@ test("[test-suite] math: 'tonumber' with strings", () => { }); -test("[test-suite] math: tests with very long numerals", () => { +test('[test-suite] math: tests with very long numerals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber("0x"..string.rep("f", 13)..".0") == 2.0^(4*13) - 1) @@ -591,9 +591,9 @@ test("[test-suite] math: tests with very long numerals", () => { }); -test("[test-suite] math: testing 'tonumber' for invalid formats", () => { +test('[test-suite] math: testing \'tonumber\' for invalid formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (...) @@ -635,9 +635,9 @@ test("[test-suite] math: testing 'tonumber' for invalid formats", () => { }); -test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () => { +test('[test-suite] math: testing \'tonumber\' for invalid hexadecimal formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber('0x') == nil) @@ -660,9 +660,9 @@ test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () }); -test("[test-suite] math: testing hexadecimal numerals", () => { +test('[test-suite] math: testing hexadecimal numerals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(0x10 == 16 and 0xfff == 2^12 - 1 and 0XFB == 251) @@ -682,9 +682,9 @@ test("[test-suite] math: testing hexadecimal numerals", () => { }); -test("[test-suite] math: floating hexas", () => { +test('[test-suite] math: floating hexas', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber(' 0x2.5 ') == 0x25/16) @@ -718,9 +718,9 @@ test("[test-suite] math: floating hexas", () => { }); -test("[test-suite] math: testing order operators", () => { +test('[test-suite] math: testing order operators', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not(1<1) and (1<2) and not(2<1)) @@ -740,9 +740,9 @@ test("[test-suite] math: testing order operators", () => { }); -test("[test-suite] math: testing mod operator", () => { +test('[test-suite] math: testing mod operator', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(eqT(-4 % 3, 2)) @@ -769,9 +769,9 @@ test("[test-suite] math: testing mod operator", () => { }); -test("[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly", () => { +test('[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function anan (x) assert(isNaN(x)) end -- assert Not a Number @@ -794,9 +794,9 @@ test("[test-suite] math: non-portable tests because Windows C library cannot com }); -test("[test-suite] math: testing unsigned comparisons", () => { +test('[test-suite] math: testing unsigned comparisons', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(math.ult(3, 4)) @@ -838,9 +838,9 @@ test("[test-suite] math: testing unsigned comparisons", () => { }); -test("[test-suite] math: testing constant limits", () => { +test('[test-suite] math: testing constant limits', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(8388609 + -8388609 == 0) @@ -854,9 +854,9 @@ test("[test-suite] math: testing constant limits", () => { }); -test("[test-suite] math: testing floor & ceil", () => { +test('[test-suite] math: testing floor & ceil', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -909,9 +909,9 @@ test("[test-suite] math: testing floor & ceil", () => { }); -test("[test-suite] math: testing fmod for integers", () => { +test('[test-suite] math: testing fmod for integers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = -6, 6 do @@ -941,9 +941,9 @@ test("[test-suite] math: testing fmod for integers", () => { }); -test("[test-suite] math: testing max/min", () => { +test('[test-suite] math: testing max/min', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -969,9 +969,9 @@ test("[test-suite] math: testing max/min", () => { }); -test("[test-suite] math: testing implicit convertions", () => { +test('[test-suite] math: testing implicit convertions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a,b = '10', '20' @@ -985,9 +985,9 @@ test("[test-suite] math: testing implicit convertions", () => { }); -test("[test-suite] math: testing -0 and NaN", () => { +test('[test-suite] math: testing -0 and NaN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1031,9 +1031,9 @@ test("[test-suite] math: testing -0 and NaN", () => { }); -test("[test-suite] math: test random for floats", () => { +test('[test-suite] math: test random for floats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` math.randomseed(0) @@ -1062,9 +1062,9 @@ test("[test-suite] math: test random for floats", () => { }); -test("[test-suite] math: test random for small intervals", () => { +test('[test-suite] math: test random for small intervals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1106,9 +1106,9 @@ test("[test-suite] math: test random for small intervals", () => { }); -test("[test-suite] math: test random for large intervals", () => { +test('[test-suite] math: test random for large intervals', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1152,9 +1152,9 @@ test("[test-suite] math: test random for large intervals", () => { }); -test("[test-suite] math: test random for empty interval", () => { +test('[test-suite] math: test random for empty interval', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(math.random, minint + 1, minint)) @@ -1168,9 +1168,9 @@ test("[test-suite] math: test random for empty interval", () => { }); -test("[test-suite] math: interval too large", () => { +test('[test-suite] math: interval too large', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(math.random, minint, 0)) diff --git a/test/test-suite/nextvar.test.js b/test/test-suite/nextvar.test.js index 1c4f3319..940082b3 100644 --- a/test/test-suite/nextvar.test.js +++ b/test/test-suite/nextvar.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` local function checkerror (msg, f, ...) @@ -12,9 +12,9 @@ const prefix = ` end `; -test("[test-suite] nextvar: testing size operator", () => { +test('[test-suite] nextvar: testing size operator', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -35,9 +35,9 @@ test("[test-suite] nextvar: testing size operator", () => { }); -test("[test-suite] nextvar: testing ipairs", () => { +test('[test-suite] nextvar: testing ipairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = 0 @@ -55,9 +55,9 @@ test("[test-suite] nextvar: testing ipairs", () => { }); -test("[test-suite] nextvar: test for 'false' x ipair", () => { +test('[test-suite] nextvar: test for \'false\' x ipair', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` x = false @@ -76,9 +76,9 @@ test("[test-suite] nextvar: test for 'false' x ipair", () => { }); -test("[test-suite] nextvar: iterator function is always the same", () => { +test('[test-suite] nextvar: iterator function is always the same', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{}) @@ -90,9 +90,9 @@ test("[test-suite] nextvar: iterator function is always the same", () => { }); -test.skip("[test-suite] nextvar: JS tests", () => { +test.skip('[test-suite] nextvar: JS tests', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- testing table sizes @@ -232,9 +232,9 @@ test.skip("[test-suite] nextvar: JS tests", () => { }); -test("[test-suite] nextvar: test size operation on empty tables", () => { +test('[test-suite] nextvar: test size operation on empty tables', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -250,9 +250,9 @@ test("[test-suite] nextvar: test size operation on empty tables", () => { }); -test("[test-suite] nextvar: test size operation on empty tables", () => { +test('[test-suite] nextvar: test size operation on empty tables', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -268,9 +268,9 @@ test("[test-suite] nextvar: test size operation on empty tables", () => { }); -test("[test-suite] nextvar: next uses always the same iteration function", () => { +test('[test-suite] nextvar: next uses always the same iteration function', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local nofind = {} @@ -317,9 +317,9 @@ test("[test-suite] nextvar: next uses always the same iteration function", () => }); -test("[test-suite] nextvar: invalid key to 'next'", () => { +test('[test-suite] nextvar: invalid key to \'next\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("invalid key", next, {10,20}, 3) @@ -331,9 +331,9 @@ test("[test-suite] nextvar: invalid key to 'next'", () => { }); -test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => { +test('[test-suite] nextvar: both \'pairs\' and \'ipairs\' need an argument', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("bad argument", pairs) @@ -346,9 +346,9 @@ test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => { }); -test("[test-suite] nextvar: fmod table", () => { +test('[test-suite] nextvar: fmod table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -373,9 +373,9 @@ test("[test-suite] nextvar: fmod table", () => { }); -test("[test-suite] nextvar: check next", () => { +test('[test-suite] nextvar: check next', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checknext (a) @@ -398,9 +398,9 @@ test("[test-suite] nextvar: check next", () => { }); -test("[test-suite] nextvar: # operator", () => { +test('[test-suite] nextvar: # operator', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -419,9 +419,9 @@ test("[test-suite] nextvar: # operator", () => { }); -test("[test-suite] nextvar: maxn", () => { +test('[test-suite] nextvar: maxn', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- 'maxn' is now deprecated, but it is easily defined in Lua @@ -448,9 +448,9 @@ test("[test-suite] nextvar: maxn", () => { }); -test("[test-suite] nextvar: int overflow", () => { +test('[test-suite] nextvar: int overflow', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -464,9 +464,9 @@ test("[test-suite] nextvar: int overflow", () => { }); -test("[test-suite] nextvar: erasing values", () => { +test('[test-suite] nextvar: erasing values', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[{1}] = 1, [{2}] = 2, [string.rep("x ", 4)] = 3, @@ -549,9 +549,9 @@ test("[test-suite] nextvar: erasing values", () => { }); -test("[test-suite] nextvar: testing table library with metamethods", () => { +test('[test-suite] nextvar: testing table library with metamethods', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -607,9 +607,9 @@ test("[test-suite] nextvar: testing table library with metamethods", () => { }); -test.skip("[test-suite] nextvar: JS tests", () => { +test.skip('[test-suite] nextvar: JS tests', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local tab = {10, 20, 30} @@ -648,9 +648,9 @@ test.skip("[test-suite] nextvar: JS tests", () => { }); -test("[test-suite] nextvar: next", () => { +test('[test-suite] nextvar: next', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -675,9 +675,9 @@ test("[test-suite] nextvar: next", () => { }); -test("[test-suite] nextvar: testing floats in numeric for", () => { +test('[test-suite] nextvar: testing floats in numeric for', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -706,9 +706,9 @@ test("[test-suite] nextvar: testing floats in numeric for", () => { }); -test("[test-suite] nextvar: conversion", () => { +test('[test-suite] nextvar: conversion', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5) @@ -720,9 +720,9 @@ test("[test-suite] nextvar: conversion", () => { }); -test("[test-suite] nextvar: checking types", () => { +test('[test-suite] nextvar: checking types', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -786,9 +786,9 @@ test("[test-suite] nextvar: checking types", () => { }); -test("[test-suite] nextvar: testing generic 'for'", () => { +test('[test-suite] nextvar: testing generic \'for\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (n, p) @@ -815,9 +815,9 @@ test("[test-suite] nextvar: testing generic 'for'", () => { }); -test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { +test('[test-suite] nextvar: testing __pairs and __ipairs metamethod', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -855,9 +855,9 @@ test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { }); -test("[test-suite] nextvar: testing ipairs with metamethods", () => { +test('[test-suite] nextvar: testing ipairs with metamethods', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {n=10} diff --git a/test/test-suite/pm.test.js b/test/test-suite/pm.test.js index c2d0de5c..062f377a 100644 --- a/test/test-suite/pm.test.js +++ b/test/test-suite/pm.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); -test("[test-suite] pm: pattern matching", () => { +test('[test-suite] pm: pattern matching', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(s, p) @@ -94,9 +94,9 @@ test("[test-suite] pm: pattern matching", () => { }); -test("[test-suite] pm: tonumber", () => { +test('[test-suite] pm: tonumber', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f1(s, p) @@ -121,9 +121,9 @@ test("[test-suite] pm: tonumber", () => { }); -test("[test-suite] pm: range", () => { +test('[test-suite] pm: range', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function range (i, j) @@ -162,32 +162,32 @@ test("[test-suite] pm: range", () => { // Can't be represented by JS string, testing from actual lua file -test("[test-suite] pm: classes", () => { +test('[test-suite] pm: classes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-classes.lua")) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadfile(L, to_luastring('test/test-suite/pm-classes.lua')) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); // Can't be represented by JS string, testing from actual lua file -test("[test-suite] pm: gsub", () => { +test('[test-suite] pm: gsub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-gsub.lua")) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadfile(L, to_luastring('test/test-suite/pm-gsub.lua')) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test("[test-suite] pm: empty matches", () => { +test('[test-suite] pm: empty matches', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- new (5.3.3) semantics for empty matches @@ -210,9 +210,9 @@ test("[test-suite] pm: empty matches", () => { }); -test("[test-suite] pm: gsub", () => { +test('[test-suite] pm: gsub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("um (dois) tres (quatro)", "(%(%w+%))", string.upper) == @@ -252,9 +252,9 @@ test("[test-suite] pm: gsub", () => { }); -test("[test-suite] pm: gsub isbalanced", () => { +test('[test-suite] pm: gsub isbalanced', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function isbalanced (s) @@ -272,9 +272,9 @@ test("[test-suite] pm: gsub isbalanced", () => { }); -test("[test-suite] pm: capture", () => { +test('[test-suite] pm: capture', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkerror (msg, f, ...) @@ -309,9 +309,9 @@ test("[test-suite] pm: capture", () => { }); -test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { +test('[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -334,9 +334,9 @@ test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { }); -test("[test-suite] pm: big strings (TODO: _soft)", () => { +test('[test-suite] pm: big strings (TODO: _soft)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true -- TODO @@ -359,9 +359,9 @@ test("[test-suite] pm: big strings (TODO: _soft)", () => { }); -test("[test-suite] pm: recursive nest of gsubs", () => { +test('[test-suite] pm: recursive nest of gsubs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function rev (s) @@ -378,9 +378,9 @@ test("[test-suite] pm: recursive nest of gsubs", () => { }); -test("[test-suite] pm: gsub with tables", () => { +test('[test-suite] pm: gsub with tables', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("alo alo", ".", {}) == "alo alo") @@ -400,9 +400,9 @@ test("[test-suite] pm: gsub with tables", () => { }); -test("[test-suite] pm: gmatch", () => { +test('[test-suite] pm: gmatch', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 0 @@ -436,9 +436,9 @@ test("[test-suite] pm: gmatch", () => { }); -test("[test-suite] pm: tests for '%f' ('frontiers')", () => { +test('[test-suite] pm: tests for \'%f\' (\'frontiers\')', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") @@ -474,9 +474,9 @@ test("[test-suite] pm: tests for '%f' ('frontiers')", () => { }); -test("[test-suite] pm: malformed patterns", () => { +test('[test-suite] pm: malformed patterns', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function malform (p, m) @@ -504,9 +504,9 @@ test("[test-suite] pm: malformed patterns", () => { }); -test("[test-suite] pm: \\0 in patterns", () => { +test('[test-suite] pm: \\0 in patterns', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.match("ab\\0\\1\\2c", "[\\0-\\2]+") == "\\0\\1\\2") @@ -524,9 +524,9 @@ test("[test-suite] pm: \\0 in patterns", () => { }); -test("[test-suite] pm: magic char after \\0", () => { +test('[test-suite] pm: magic char after \\0', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.find("abc\\0\\0","\\0.") == 4) diff --git a/test/test-suite/sort.test.js b/test/test-suite/sort.test.js index cc33c0ca..82059067 100644 --- a/test/test-suite/sort.test.js +++ b/test/test-suite/sort.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` local unpack = table.unpack @@ -30,9 +30,9 @@ const prefix = ` if _soft then limit = 5000 end `; -test("[test-suite] sort: testing unpack", () => { +test('[test-suite] sort: testing unpack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("wrong number of arguments", table.insert, {}, 2, 3, 4) @@ -67,9 +67,9 @@ test("[test-suite] sort: testing unpack", () => { }); -test("[test-suite] sort: testing unpack", () => { +test('[test-suite] sort: testing unpack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -107,9 +107,9 @@ test("[test-suite] sort: testing unpack", () => { }); -test("[test-suite] sort: testing unpack", () => { +test('[test-suite] sort: testing unpack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- length is not an integer @@ -125,9 +125,9 @@ test("[test-suite] sort: testing unpack", () => { }); -test("[test-suite] sort: testing pack", () => { +test('[test-suite] sort: testing pack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = table.pack() @@ -146,9 +146,9 @@ test("[test-suite] sort: testing pack", () => { }); -test("[test-suite] sort: testing move", () => { +test('[test-suite] sort: testing move', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -229,9 +229,9 @@ test("[test-suite] sort: testing move", () => { }); -test("[test-suite] sort: testing long move", () => { +test('[test-suite] sort: testing long move', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -268,9 +268,9 @@ test("[test-suite] sort: testing long move", () => { }); -test("[test-suite] sort: testing sort, strange lengths", () => { +test('[test-suite] sort: testing sort, strange lengths', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = setmetatable({}, {__len = function () return -1 end}) @@ -286,9 +286,9 @@ test("[test-suite] sort: testing sort, strange lengths", () => { }); -test("[test-suite] sort: test checks for invalid order functions", () => { +test('[test-suite] sort: test checks for invalid order functions', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function check (t) @@ -307,9 +307,9 @@ test("[test-suite] sort: test checks for invalid order functions", () => { }); -test("[test-suite] sort: sort alpha", () => { +test('[test-suite] sort: sort alpha', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -332,9 +332,9 @@ test("[test-suite] sort: sort alpha", () => { }); -test("[test-suite] sort: sort perm", () => { +test('[test-suite] sort: sort perm', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -377,9 +377,9 @@ test("[test-suite] sort: sort perm", () => { }); -test("[test-suite] sort: Invert-sorting", () => { +test('[test-suite] sort: Invert-sorting', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -415,9 +415,9 @@ test("[test-suite] sort: Invert-sorting", () => { }); -test("[test-suite] sort: sorting", () => { +test('[test-suite] sort: sorting', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) diff --git a/test/test-suite/strings.test.js b/test/test-suite/strings.test.js index 0e37674b..eaf8e3ff 100644 --- a/test/test-suite/strings.test.js +++ b/test/test-suite/strings.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const checkerror = ` local maxi, mini = math.maxinteger, math.mininteger @@ -16,7 +16,7 @@ const checkerror = ` test('[test-suite] strings: string comparisons', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('alo' < 'alo1') @@ -46,7 +46,7 @@ test('[test-suite] strings: string comparisons', () => { test('[test-suite] strings: string.sub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('alo' < 'alo1') @@ -76,7 +76,7 @@ test('[test-suite] strings: string.sub', () => { test('[test-suite] strings: string.find', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.find("123456789", "345") == 3) @@ -102,7 +102,7 @@ test('[test-suite] strings: string.find', () => { test('[test-suite] strings: string.len and #', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.len("") == 0) @@ -122,7 +122,7 @@ test('[test-suite] strings: string.len and #', () => { test('[test-suite] strings: string.byte/string.char', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.byte("a") == 97) @@ -167,7 +167,7 @@ test('[test-suite] strings: string.byte/string.char', () => { test('[test-suite] strings: repetitions with separator', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.rep('teste', 0, 'xuxu') == '') @@ -192,7 +192,7 @@ test('[test-suite] strings: repetitions with separator', () => { test('[test-suite] strings: tostring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(tostring(nil)) == 'string') @@ -232,7 +232,7 @@ test('[test-suite] strings: tostring', () => { test('[test-suite] strings: string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` x = '"ílo"\\n\\\\' @@ -267,7 +267,7 @@ test('[test-suite] strings: string.format', () => { test('[test-suite] strings: %q', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -296,7 +296,7 @@ test('[test-suite] strings: %q', () => { test('[test-suite] strings: embedded zeros error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.format("\\0%s\\0", "\\0\\0\\1") == "\\0\\0\\0\\1\\0") @@ -311,7 +311,7 @@ test('[test-suite] strings: embedded zeros error', () => { test('[test-suite] strings: format x tostring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.format("%s %s", nil, true) == "nil true") @@ -342,7 +342,7 @@ test('[test-suite] strings: format x tostring', () => { test('[test-suite] strings: longest number that can be formatted', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -367,7 +367,7 @@ test('[test-suite] strings: longest number that can be formatted', () => { test('[test-suite] strings: large numbers for format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- assume at least 32 bits @@ -402,9 +402,9 @@ test('[test-suite] strings: large numbers for format', () => { }); -test("[test-suite] strings: 'format %a %A'", () => { +test('[test-suite] strings: \'format %a %A\'', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -447,9 +447,9 @@ test("[test-suite] strings: 'format %a %A'", () => { }); -test("[test-suite] strings: errors in format", () => { +test('[test-suite] strings: errors in format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function check (fmt, msg) @@ -475,9 +475,9 @@ test("[test-suite] strings: errors in format", () => { }); -test("[test-suite] strings: table.concat", () => { +test('[test-suite] strings: table.concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("table expected", table.concat, 3) @@ -515,9 +515,9 @@ test("[test-suite] strings: table.concat", () => { // TODO: os.setlocale NYI -test.skip("[test-suite] strings: locale", () => { +test.skip('[test-suite] strings: locale', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if not _port then @@ -558,9 +558,9 @@ test.skip("[test-suite] strings: locale", () => { }); -test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", () => { +test('[test-suite] strings: bug in Lua 5.3.2: \'gmatch\' iterator does not work across coroutines', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/tpack.test.js b/test/test-suite/tpack.test.js index 3b97d3a5..25950a7c 100644 --- a/test/test-suite/tpack.test.js +++ b/test/test-suite/tpack.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` local pack = string.pack @@ -30,9 +30,9 @@ const prefix = ` local align = packsize("!xXi16") `; -test("[test-suite] tpack: maximum size for integers", () => { +test('[test-suite] tpack: maximum size for integers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and @@ -54,9 +54,9 @@ test("[test-suite] tpack: maximum size for integers", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(unpack("B", pack("B", 0xff)) == 0xff) @@ -78,9 +78,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, NB do @@ -105,9 +105,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -138,9 +138,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, sizeLI do @@ -160,9 +160,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: sign extension", () => { +test('[test-suite] tpack: sign extension', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -181,9 +181,9 @@ test("[test-suite] tpack: sign extension", () => { }); -test("[test-suite] tpack: mixed endianness", () => { +test('[test-suite] tpack: mixed endianness', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -200,9 +200,9 @@ test("[test-suite] tpack: mixed endianness", () => { }); -test("[test-suite] tpack: testing invalid formats", () => { +test('[test-suite] tpack: testing invalid formats', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("out of limits", pack, "i0", 0) @@ -223,9 +223,9 @@ test("[test-suite] tpack: testing invalid formats", () => { }); -test("[test-suite] tpack: overflow in option size (error will be in digit after limit)", () => { +test('[test-suite] tpack: overflow in option size (error will be in digit after limit)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("invalid format", packsize, "c1" .. string.rep("0", 40)) @@ -246,9 +246,9 @@ test("[test-suite] tpack: overflow in option size (error will be in digit after }); -test("[test-suite] tpack: overflow in packing", () => { +test('[test-suite] tpack: overflow in packing', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, sizeLI - 1 do @@ -275,9 +275,9 @@ test("[test-suite] tpack: overflow in packing", () => { }); -test("[test-suite] tpack: Lua integer size", () => { +test('[test-suite] tpack: Lua integer size', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(unpack(">j", pack(">j", math.maxinteger)) == math.maxinteger) @@ -297,9 +297,9 @@ test("[test-suite] tpack: Lua integer size", () => { }); -test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => { +test('[test-suite] tpack: testing pack/unpack of floating-point numbers', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do @@ -325,9 +325,9 @@ test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => }); -test("[test-suite] tpack: testing pack/unpack of strings", () => { +test('[test-suite] tpack: testing pack/unpack of strings', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -379,9 +379,9 @@ test("[test-suite] tpack: testing pack/unpack of strings", () => { }); -test("[test-suite] tpack: testing multiple types and sequence", () => { +test('[test-suite] tpack: testing multiple types and sequence', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -399,9 +399,9 @@ test("[test-suite] tpack: testing multiple types and sequence", () => { }); -test("[test-suite] tpack: testing alignment", () => { +test('[test-suite] tpack: testing alignment', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -453,9 +453,9 @@ test("[test-suite] tpack: testing alignment", () => { }); -test("[test-suite] tpack: testing initial position", () => { +test('[test-suite] tpack: testing initial position', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/utf8.test.js b/test/test-suite/utf8.test.js index 7e809da2..dd7116e9 100644 --- a/test/test-suite/utf8.test.js +++ b/test/test-suite/utf8.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); const prefix = ` local function checkerror (msg, f, ...) @@ -94,9 +94,9 @@ const prefix = ` end `; -test("[test-suite] utf8: offset", () => { +test('[test-suite] utf8: offset', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` assert(utf8.offset("alo", 5) == nil) @@ -109,9 +109,9 @@ test("[test-suite] utf8: offset", () => { }); -test("[test-suite] utf8: error indication in utf8.len", () => { +test('[test-suite] utf8: error indication in utf8.len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` do @@ -132,9 +132,9 @@ test("[test-suite] utf8: error indication in utf8.len", () => { }); -test("[test-suite] utf8: error in initial position for offset", () => { +test('[test-suite] utf8: error in initial position for offset', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` checkerror("position out of range", utf8.offset, "abc", 1, 5) @@ -152,9 +152,9 @@ test("[test-suite] utf8: error in initial position for offset", () => { }); -test("[test-suite] utf8: codepoints", () => { +test('[test-suite] utf8: codepoints', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` local s = "hello World" @@ -190,9 +190,9 @@ test("[test-suite] utf8: codepoints", () => { }); -test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", () => { +test('[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\xF4\\x9F\\xBF\\xBF") @@ -204,9 +204,9 @@ test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid r }); -test("[test-suite] utf8: overlong sequences", () => { +test('[test-suite] utf8: overlong sequences', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\xC0\\x80") -- zero @@ -221,9 +221,9 @@ test("[test-suite] utf8: overlong sequences", () => { }); -test("[test-suite] utf8: invalid bytes", () => { +test('[test-suite] utf8: invalid bytes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\x80") -- continuation byte @@ -238,9 +238,9 @@ test("[test-suite] utf8: invalid bytes", () => { }); -test("[test-suite] utf8: empty strings", () => { +test('[test-suite] utf8: empty strings', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` check("", {}) @@ -252,9 +252,9 @@ test("[test-suite] utf8: empty strings", () => { }); -test("[test-suite] utf8: minimum and maximum values for each sequence size", () => { +test('[test-suite] utf8: minimum and maximum values for each sequence size', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` s = "\\0 \\x7F\\z diff --git a/test/test-suite/vararg.test.js b/test/test-suite/vararg.test.js index 05385411..d4f3eb96 100644 --- a/test/test-suite/vararg.test.js +++ b/test/test-suite/vararg.test.js @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +const {to_luastring} = require('../../src/fengaricore.js'); -test("[test-suite] vararg: testing vararg", () => { +test('[test-suite] vararg: testing vararg', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(a, ...) @@ -81,9 +81,9 @@ test("[test-suite] vararg: testing vararg", () => { }); -test("[test-suite] vararg: new-style varargs", () => { +test('[test-suite] vararg: new-style varargs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function oneless (a, ...) return ... end @@ -114,9 +114,9 @@ test("[test-suite] vararg: new-style varargs", () => { }); -test("[test-suite] vararg: varargs for main chunks", () => { +test('[test-suite] vararg: varargs for main chunks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` f = load[[ return {...} ]] @@ -152,9 +152,9 @@ test("[test-suite] vararg: varargs for main chunks", () => { }); -test("[test-suite] vararg: bug in 5.2.2", () => { +test('[test-suite] vararg: bug in 5.2.2', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, diff --git a/test/tests.js b/test/tests.js index 631594b1..5609fce0 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,12 +1,12 @@ -"use strict"; +'use strict'; -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +const lua = require('../src/lua.js'); +const lauxlib = require('../src/lauxlib.js'); +const {to_luastring} = require('../src/fengaricore.js'); const toByteCode = function(luaCode) { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) !== lua.LUA_OK) throw Error(lua.lua_tojsstring(L, -1)); @@ -16,7 +16,7 @@ const toByteCode = function(luaCode) { B.push(...b.slice(0, size)); return 0; }, b, false) !== 0) - throw Error("unable to dump given function"); + throw Error('unable to dump given function'); return Uint8Array.from(b); }; From 260f693e3fa4aa62836548e841a2e7e7e5d6ce3c Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Mon, 1 Jun 2026 13:55:38 +0000 Subject: [PATCH 02/11] Stage 1 - VSCode refactoring --- package.json | 3 +- src/defs.js | 139 ++-- src/fengari.js | 38 +- src/fengaricore.js | 55 +- src/fengarilib.js | 21 +- src/lapi.js | 455 +++++++---- src/lauxlib.js | 539 +++++++------ src/lbaselib.js | 264 +++--- src/lcode.js | 159 ++-- src/lcorolib.js | 92 +-- src/ldblib.js | 252 +++--- src/ldebug.js | 124 +-- src/ldo.js | 361 +++++---- src/ldump.js | 57 +- src/lfunc.js | 27 +- src/linit.js | 58 +- src/liolib.js | 86 +- src/ljstype.js | 15 +- src/llex.js | 359 +++++---- src/llimits.js | 24 +- src/lmathlib.js | 176 ++-- src/loadlib.js | 224 +++--- src/lobject.js | 327 ++++---- src/lopcodes.js | 417 ++++++---- src/loslib.js | 129 ++- src/lparser.js | 530 ++++++------ src/lstate.js | 80 +- src/lstring.js | 37 +- src/lstrlib.js | 445 +++++----- src/ltable.js | 170 ++-- src/ltablib.js | 84 +- src/ltm.js | 230 +++--- src/lua.js | 196 ++++- src/luaconf.js | 176 ++-- src/lualib.js | 94 ++- src/lundump.js | 114 ++- src/lutf8lib.js | 62 +- src/lvm.js | 1208 ++++++++++++++-------------- src/lzio.js | 27 +- test/defs.test.js | 91 +-- test/lapi.test.js | 136 ++-- test/lauxlib.test.js | 12 +- test/lbaselib.test.js | 58 +- test/lcorolib.test.js | 18 +- test/ldblib.test.js | 46 +- test/ldebug.test.js | 32 +- test/lexparse.test.js | 142 ++-- test/lmathlib.test.js | 34 +- test/load.test.js | 34 +- test/loadlib.test.js | 18 +- test/loslib.test.js | 24 +- test/lstrlib.test.js | 116 +-- test/ltablib.test.js | 22 +- test/ltm.test.js | 82 +- test/lua.test.js | 12 +- test/lutf8lib.test.js | 24 +- test/lvm.test.js | 96 +-- test/manual-tests/debug-cli.js | 4 +- test/test-suite/api.test.js | 196 ++--- test/test-suite/attrib.test.js | 32 +- test/test-suite/bitwise.test.js | 36 +- test/test-suite/calls.test.js | 68 +- test/test-suite/closure.test.js | 36 +- test/test-suite/code.test.js | 60 +- test/test-suite/constructs.test.js | 18 +- test/test-suite/coroutine.test.js | 148 ++-- test/test-suite/db.test.js | 116 +-- test/test-suite/errors.test.js | 146 ++-- test/test-suite/events.test.js | 56 +- test/test-suite/goto.test.js | 28 +- test/test-suite/literals.test.js | 64 +- test/test-suite/locals.test.js | 14 +- test/test-suite/ltests.js | 298 +++---- test/test-suite/math.test.js | 152 ++-- test/test-suite/nextvar.test.js | 104 +-- test/test-suite/pm.test.js | 80 +- test/test-suite/sort.test.js | 52 +- test/test-suite/strings.test.js | 50 +- test/test-suite/tpack.test.js | 68 +- test/test-suite/utf8.test.js | 40 +- test/test-suite/vararg.test.js | 20 +- test/tests.js | 12 +- 82 files changed, 5680 insertions(+), 5069 deletions(-) diff --git a/package.json b/package.json index 9a5c8f59..85db196f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "fengari", - "version": "0.1.5", + "version": "0.1.6", "description": "A Lua VM written in JS ES6 targeting the browser", "main": "src/fengari.js", + "type": "module", "directories": { "lib": "src", "test": "test" diff --git a/src/defs.js b/src/defs.js index b7c3f1c4..cbd76083 100644 --- a/src/defs.js +++ b/src/defs.js @@ -2,7 +2,9 @@ * Fengari specific string conversion functions */ -export const luastring_from = typeof Uint8Array.from === 'function' ? +export { LUAI_MAXSTACK } from './luaconf.js'; + +export const luastring_from = (typeof Uint8Array.from === "function") ? Uint8Array.from.bind(Uint8Array) : function (a) { let i = 0; @@ -12,28 +14,30 @@ export const luastring_from = typeof Uint8Array.from === 'function' ? return r; }; -export const luastring_indexOf = typeof (new Uint8Array().indexOf) === 'function' ? +export const luastring_indexOf = (typeof (new Uint8Array().indexOf) === "function") ? function (s, v, i) { return s.indexOf(v, i); } : + /* Browsers that don't support Uint8Array.indexOf seem to allow using Array.indexOf on Uint8Array objects e.g. IE11 */ function (s, v, i) { let array_indexOf = [].indexOf; - if (array_indexOf.call(new Uint8Array(1), 0) !== 0) throw Error('missing .indexOf'); + if (array_indexOf.call(new Uint8Array(1), 0) !== 0) throw Error("missing .indexOf"); return array_indexOf.call(s, v, i); }; -export const luastring_of = typeof Uint8Array.of === 'function' ? + +export const luastring_of = (typeof Uint8Array.of === "function") ? Uint8Array.of.bind(Uint8Array) : function () { return luastring_from(arguments); }; -export const is_luastring = function (s) { +export function is_luastring(s) { return s instanceof Uint8Array; }; /* test two lua strings for equality */ -export const luastring_eq = function (a, b) { +export function luastring_eq(a, b) { if (a !== b) { let len = a.length; if (len !== b.length) return false; @@ -44,9 +48,9 @@ export const luastring_eq = function (a, b) { return true; }; -const unicode_error_message = 'cannot convert invalid utf8 to javascript string'; -export const to_jsstring = function (value, from, to, replacement_char) { - if (!is_luastring(value)) throw new TypeError('to_jsstring expects a Uint8Array'); +const unicode_error_message = "cannot convert invalid utf8 to javascript string"; +export function to_jsstring(value, from, to, replacement_char) { + if (!is_luastring(value)) throw new TypeError("to_jsstring expects a Uint8Array"); if (to === void 0) { to = value.length; @@ -54,7 +58,7 @@ export const to_jsstring = function (value, from, to, replacement_char) { to = Math.min(value.length, to); } - let str = ''; + let str = ""; for (let i = (from !== void 0 ? from : 0); i < to;) { let u0 = value[i++]; if (u0 < 0x80) { @@ -62,18 +66,18 @@ export const to_jsstring = function (value, from, to, replacement_char) { str += String.fromCharCode(u0); } else if (u0 < 0xC2 || u0 > 0xF4) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; } else if (u0 <= 0xDF) { /* two byte sequence */ if (i >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u1 = value[i++]; if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } str += String.fromCharCode(((u0 & 0x1F) << 6) + (u1 & 0x3F)); @@ -81,19 +85,19 @@ export const to_jsstring = function (value, from, to, replacement_char) { /* three byte sequence */ if (i + 1 >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u1 = value[i++]; if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u2 = value[i++]; if ((u2 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u = ((u0 & 0x0F) << 12) + ((u1 & 0x3F) << 6) + (u2 & 0x3F); @@ -109,25 +113,25 @@ export const to_jsstring = function (value, from, to, replacement_char) { /* four byte sequence */ if (i + 2 >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u1 = value[i++]; if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u2 = value[i++]; if ((u2 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } let u3 = value[i++]; if ((u3 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += '�'; + str += "�"; continue; } /* Has to be astral codepoint */ @@ -142,21 +146,21 @@ export const to_jsstring = function (value, from, to, replacement_char) { }; /* bytes allowed unescaped in a uri */ -const uri_allowed = (';,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*\'()#').split('').reduce(function (uri_allowed, c) { +const uri_allowed = (";,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*'()#").split('').reduce(function (uri_allowed, c) { uri_allowed[c.charCodeAt(0)] = true; return uri_allowed; }, {}); /* utility function to convert a lua string to a js string with uri escaping */ -export const to_uristring = function (a) { - if (!is_luastring(a)) throw new TypeError('to_uristring expects a Uint8Array'); - let s = ''; +export function to_uristring(a) { + if (!is_luastring(a)) throw new TypeError("to_uristring expects a Uint8Array"); + let s = ""; for (let i = 0; i < a.length; i++) { let v = a[i]; if (uri_allowed[v]) { s += String.fromCharCode(v); } else { - s += '%' + (v < 0x10 ? '0' : '') + v.toString(16); + s += "%" + (v < 0x10 ? "0" : "") + v.toString(16); } } return s; @@ -164,8 +168,8 @@ export const to_uristring = function (a) { const to_luastring_cache = {}; -export const to_luastring = function (str, cache) { - if (typeof str !== 'string') throw new TypeError('to_luastring expects a javascript string'); +export function to_luastring(str, cache) { + if (typeof str !== "string") throw new TypeError("to_luastring expects a javascript string"); if (cache) { let cached = to_luastring_cache[str]; @@ -212,30 +216,29 @@ export const to_luastring = function (str, cache) { return outU8Array; }; -export const from_userstring = function (str) { +export function from_userstring(str) { if (!is_luastring(str)) { - if (typeof str === 'string') { + if (typeof str === "string") { str = to_luastring(str); } else { - throw new TypeError('expects an array of bytes or javascript string'); + throw new TypeError("expects an array of bytes or javascript string"); } } return str; }; /* mark for precompiled code ('Lua') */ -const LUA_SIGNATURE = to_luastring('\x1bLua'); +export const LUA_SIGNATURE = to_luastring("\x1bLua"); -const LUA_VERSION_MAJOR = '5'; -const LUA_VERSION_MINOR = '3'; +export const LUA_VERSION_MAJOR = "5"; +export const LUA_VERSION_MINOR = "3"; export const LUA_VERSION_NUM = 503; -const LUA_VERSION_RELEASE = '4'; - -const LUA_VERSION = 'Lua ' + LUA_VERSION_MAJOR + '.' + LUA_VERSION_MINOR; -const LUA_RELEASE = LUA_VERSION + '.' + LUA_VERSION_RELEASE; -export const LUA_COPYRIGHT = LUA_RELEASE + ' Copyright (C) 1994-2017 Lua.org, PUC-Rio'; -const LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo, W. Celes'; +export const LUA_VERSION_RELEASE = "4"; +export const LUA_VERSION = "Lua " + LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; +export const LUA_RELEASE = LUA_VERSION + "." + LUA_VERSION_RELEASE; +export const LUA_COPYRIGHT = LUA_RELEASE + " Copyright (C) 1994-2017 Lua.org, PUC-Rio"; +export const LUA_AUTHORS = "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"; export const thread_status = { LUA_OK: 0, @@ -247,7 +250,7 @@ export const thread_status = { LUA_ERRERR: 6 }; -export const constant_types = { +const constant_types = { LUA_TNONE: -1, LUA_TNIL: 0, LUA_TBOOLEAN: 1, @@ -271,22 +274,24 @@ 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 */ +export { constant_types }; + /* ** 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; +export const LUA_OPADD = 0; /* ORDER TM, ORDER OP */ +export const LUA_OPSUB = 1; +export const LUA_OPMUL = 2; +export const LUA_OPMOD = 3; +export const LUA_OPPOW = 4; +export const LUA_OPDIV = 5; +export const LUA_OPIDIV = 6; +export const LUA_OPBAND = 7; +export const LUA_OPBOR = 8; +export const LUA_OPBXOR = 9; +export const LUA_OPSHL = 10; +export const LUA_OPSHR = 11; export const LUA_OPUNM = 12; export const LUA_OPBNOT = 13; @@ -294,22 +299,20 @@ export const LUA_OPEQ = 0; export const LUA_OPLT = 1; export const LUA_OPLE = 2; -const LUA_MINSTACK = 20; +export const LUA_MINSTACK = 20; -const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); -const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; export const LUA_REGISTRYINDEX = -LUAI_MAXSTACK - 1000; -const lua_upvalueindex = function (i) { +export function lua_upvalueindex(i) { return LUA_REGISTRYINDEX - i; }; /* predefined values in the registry */ -const LUA_RIDX_MAINTHREAD = 1; +export const LUA_RIDX_MAINTHREAD = 1; export const LUA_RIDX_GLOBALS = 2; -const LUA_RIDX_LAST = LUA_RIDX_GLOBALS; +export const LUA_RIDX_LAST = LUA_RIDX_GLOBALS; -class lua_Debug { +export class lua_Debug { constructor() { this.event = NaN; this.name = null; /* (n) */ @@ -332,17 +335,19 @@ class lua_Debug { /* ** Event codes */ -const LUA_HOOKCALL = 0; -const LUA_HOOKRET = 1; -const LUA_HOOKLINE = 2; -const LUA_HOOKCOUNT = 3; -const LUA_HOOKTAILCALL = 4; -export const LUA_MULTRET = -1; +export const LUA_HOOKCALL = 0; +export const LUA_HOOKRET = 1; +export const LUA_HOOKLINE = 2; +export const LUA_HOOKCOUNT = 3; +export const LUA_HOOKTAILCALL = 4; + /* ** Event masks */ -const LUA_MASKCALL = (1 << LUA_HOOKCALL); -const LUA_MASKRET = (1 << LUA_HOOKRET); +export const LUA_MASKCALL = (1 << LUA_HOOKCALL); +export const LUA_MASKRET = (1 << LUA_HOOKRET); export const LUA_MASKLINE = (1 << LUA_HOOKLINE); export const LUA_MASKCOUNT = (1 << LUA_HOOKCOUNT); + +export const LUA_MULTRET = -1; diff --git a/src/fengari.js b/src/fengari.js index fca3ee92..3d1ca73c 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -6,8 +6,36 @@ Copyright © 2017-2019 Daurnimator Copyright © 1994–2017 Lua.org, PUC-Rio. */ -export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from './fengaricore.js'; -export * as luaconf from './luaconf.js'; -export * as lua from './lua.js'; -export * as lauxlib from './lauxlib.js'; -export * as lualib from './lualib.js'; +"use strict"; + +import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; + +export const FENGARI_AUTHORS = FENGARI_AUTHORS; +export const FENGARI_COPYRIGHT = FENGARI_COPYRIGHT; +export const FENGARI_RELEASE = FENGARI_RELEASE; +export const FENGARI_VERSION = FENGARI_VERSION; +export const FENGARI_VERSION_MAJOR = FENGARI_VERSION_MAJOR; +export const FENGARI_VERSION_MINOR = FENGARI_VERSION_MINOR; +export const FENGARI_VERSION_NUM = FENGARI_VERSION_NUM; +export const FENGARI_VERSION_RELEASE = FENGARI_VERSION_RELEASE; + +export const luastring_eq = luastring_eq; +export const luastring_indexOf = luastring_indexOf; +export const luastring_of = luastring_of; +export const to_jsstring = to_jsstring; +export const to_luastring = to_luastring; +export const to_uristring = to_uristring; + +import luaconf from './luaconf.js'; +import lua from './lua.js'; +import lauxlib from './lauxlib.js'; +import lualib from './lualib.js'; + +const _luaconf = luaconf; +export { _luaconf as luaconf }; +const _lua = lua; +export { _lua as lua }; +const _lauxlib = lauxlib; +export { _lauxlib as lauxlib }; +const _lualib = lualib; +export { _lualib as lualib }; diff --git a/src/fengaricore.js b/src/fengaricore.js index 26235b1f..e56fe399 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,24 +6,39 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ -export { - LUA_COPYRIGHT, - is_luastring, - luastring_eq, - luastring_from, - luastring_indexOf, - luastring_of, - to_jsstring, - to_luastring, - to_uristring, - from_userstring -} from './defs.js'; +import { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from "./defs.js"; -export const FENGARI_VERSION_MAJOR = '0'; -export const FENGARI_VERSION_MINOR = '1'; -export const FENGARI_VERSION_NUM = 1; -export const FENGARI_VERSION_RELEASE = '4'; -export const FENGARI_VERSION = 'Fengari ' + FENGARI_VERSION_MAJOR + '.' + FENGARI_VERSION_MINOR; -export const FENGARI_RELEASE = FENGARI_VERSION + '.' + FENGARI_VERSION_RELEASE; -export const FENGARI_AUTHORS = 'B. Giannangeli, Daurnimator'; -export const FENGARI_COPYRIGHT = FENGARI_RELEASE + ' Copyright (C) 2017-2019 ' + FENGARI_AUTHORS + '\nBased on: ' + LUA_COPYRIGHT; +const FENGARI_VERSION_MAJOR = "0"; +const FENGARI_VERSION_MINOR = "1"; +const FENGARI_VERSION_NUM = 1; +const FENGARI_VERSION_RELEASE = "5"; +const FENGARI_VERSION = "Fengari " + FENGARI_VERSION_MAJOR + "." + FENGARI_VERSION_MINOR; +const FENGARI_RELEASE = FENGARI_VERSION + "." + FENGARI_VERSION_RELEASE; +const FENGARI_AUTHORS = "B. Giannangeli, Daurnimator"; +const FENGARI_COPYRIGHT = FENGARI_RELEASE + " Copyright (C) 2017-2019 " + FENGARI_AUTHORS + "\nBased on: " + LUA_COPYRIGHT; + +const _FENGARI_AUTHORS = FENGARI_AUTHORS; +export { _FENGARI_AUTHORS as FENGARI_AUTHORS }; +const _FENGARI_COPYRIGHT = FENGARI_COPYRIGHT; +export { _FENGARI_COPYRIGHT as FENGARI_COPYRIGHT }; +const _FENGARI_RELEASE = FENGARI_RELEASE; +export { _FENGARI_RELEASE as FENGARI_RELEASE }; +const _FENGARI_VERSION = FENGARI_VERSION; +export { _FENGARI_VERSION as FENGARI_VERSION }; +const _FENGARI_VERSION_MAJOR = FENGARI_VERSION_MAJOR; +export { _FENGARI_VERSION_MAJOR as FENGARI_VERSION_MAJOR }; +const _FENGARI_VERSION_MINOR = FENGARI_VERSION_MINOR; +export { _FENGARI_VERSION_MINOR as FENGARI_VERSION_MINOR }; +const _FENGARI_VERSION_NUM = FENGARI_VERSION_NUM; +export { _FENGARI_VERSION_NUM as FENGARI_VERSION_NUM }; +const _FENGARI_VERSION_RELEASE = FENGARI_VERSION_RELEASE; +export { _FENGARI_VERSION_RELEASE as FENGARI_VERSION_RELEASE }; +export const is_luastring = is_luastring; +export const luastring_eq = luastring_eq; +export const luastring_from = luastring_from; +export const luastring_indexOf = luastring_indexOf; +export const luastring_of = luastring_of; +export const to_jsstring = to_jsstring; +export const to_luastring = to_luastring; +export const to_uristring = to_uristring; +export const from_userstring = from_userstring; diff --git a/src/fengarilib.js b/src/fengarilib.js index 09a852fd..75d21440 100644 --- a/src/fengarilib.js +++ b/src/fengarilib.js @@ -1,24 +1,27 @@ import { lua_pushinteger, lua_pushliteral, lua_setfield } from './lua.js'; import { luaL_newlib } from './lauxlib.js'; -import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, to_luastring } from './fengaricore.js'; +import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, to_luastring } from "./fengaricore.js"; const luaopen_fengari = function(L) { luaL_newlib(L, {}); lua_pushliteral(L, FENGARI_AUTHORS); - lua_setfield(L, -2, to_luastring('AUTHORS')); + lua_setfield(L, -2, to_luastring("AUTHORS")); lua_pushliteral(L, FENGARI_COPYRIGHT); - lua_setfield(L, -2, to_luastring('COPYRIGHT')); + lua_setfield(L, -2, to_luastring("COPYRIGHT")); lua_pushliteral(L, FENGARI_RELEASE); - lua_setfield(L, -2, to_luastring('RELEASE')); + lua_setfield(L, -2, to_luastring("RELEASE")); lua_pushliteral(L, FENGARI_VERSION); - lua_setfield(L, -2, to_luastring('VERSION')); + lua_setfield(L, -2, to_luastring("VERSION")); lua_pushliteral(L, FENGARI_VERSION_MAJOR); - lua_setfield(L, -2, to_luastring('VERSION_MAJOR')); + lua_setfield(L, -2, to_luastring("VERSION_MAJOR")); lua_pushliteral(L, FENGARI_VERSION_MINOR); - lua_setfield(L, -2, to_luastring('VERSION_MINOR')); + lua_setfield(L, -2, to_luastring("VERSION_MINOR")); lua_pushinteger(L, FENGARI_VERSION_NUM); - lua_setfield(L, -2, to_luastring('VERSION_NUM')); + lua_setfield(L, -2, to_luastring("VERSION_NUM")); lua_pushliteral(L, FENGARI_VERSION_RELEASE); - lua_setfield(L, -2, to_luastring('VERSION_RELEASE')); + lua_setfield(L, -2, to_luastring("VERSION_RELEASE")); return 1; }; + +const _luaopen_fengari = luaopen_fengari; +export { _luaopen_fengari as luaopen_fengari }; diff --git a/src/lapi.js b/src/lapi.js index 4aa297d4..7c1df733 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1,70 +1,20 @@ -import * as defs from './defs.js'; -import { - LUA_MULTRET, - LUA_OPBNOT, - LUA_OPEQ, - LUA_OPLE, - LUA_OPLT, - LUA_OPUNM, - LUA_REGISTRYINDEX, - LUA_RIDX_GLOBALS, - LUA_VERSION_NUM, - constant_types, - thread_status, - from_userstring, - to_luastring -} from './defs.js'; -import {api_check} from './llimits.js'; -import {luaG_errormsg} from './ldebug.js'; -import {luaD_growstack, adjust_top, luaD_callnoyield, luaD_protectedparser, luaD_call, luaD_pcall} from './ldo.js'; -import {luaU_dump} from './ldump.js'; -import {MAXUPVAL} from './lfunc.js'; -import { - TValue as _TValue, - CClosure as _CClosure, - luaO_nilobject, - setobj2s, - pushobj2s, - setobjs2s, - pushsvalue2s, - luaO_pushvfstring, - Udata, - luaO_tostring, - luaO_str2num, - luaO_arith -} from './lobject.js'; -import {EXTRA_STACK, lua_State, CIST_LUA, CIST_OAH, CIST_YPCALL} from './lstate.js'; -import {luaS_bless, luaS_new, luaS_newliteral} from './lstring.js'; -import {ttypename} from './ltm.js'; -import {LUAI_MAXSTACK} from './luaconf.js'; -import { - settable, - luaV_gettable, - cvt2str, - tointeger, - tonumber, - luaV_equalobj, - luaV_lessthan, - luaV_lessequal, - luaV_concat, - luaV_objlen -} from './lvm.js'; -import { - luaH_getint, - luaH_setfrom, - invalidateTMcache, - luaH_setint, - luaH_get, - luaH_new, - luaH_getn, - luaH_next -} from './ltable.js'; -import {ZIO} from './lzio.js'; - +import { LUA_MULTRET, LUA_OPBNOT, LUA_OPEQ, LUA_OPLE, LUA_OPLT, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS, LUA_VERSION_NUM, constant_types, thread_status, from_userstring, to_luastring } from './defs.js'; +import { api_check } from './llimits.js'; +import { luaG_errormsg } from './ldebug.js'; +import { luaD_growstack, adjust_top, luaD_callnoyield, luaD_protectedparser, luaD_call, luaD_pcall } from './ldo.js'; +import { luaU_dump } from './ldump.js'; +import { MAXUPVAL } from './lfunc.js'; +import { TValue as _TValue, CClosure as _CClosure, luaO_nilobject, setobj2s, pushobj2s, setobjs2s, pushsvalue2s, luaO_pushvfstring, Udata, luaO_tostring, luaO_str2num, luaO_arith } from './lobject.js'; +import { EXTRA_STACK, lua_State, CIST_LUA, CIST_OAH, CIST_YPCALL } from './lstate.js'; +import { luaS_bless, luaS_new, luaS_newliteral } from './lstring.js'; +import { ttypename } from './ltm.js'; +import { LUAI_MAXSTACK } from './luaconf.js'; +import { settable, luaV_gettable, cvt2str, tointeger, tonumber, luaV_equalobj, luaV_lessthan, luaV_lessequal, luaV_concat, luaV_objlen } from './lvm.js'; +import { luaH_getint, luaH_setfrom, invalidateTMcache, luaH_setint, luaH_get, luaH_new, luaH_getn, luaH_next } from './ltable.js'; +import { ZIO } from './lzio.js'; const TValue = _TValue; const CClosure = _CClosure; -const {LUA_OK} = thread_status; const { LUA_NUMTAGS, LUA_TBOOLEAN, @@ -84,21 +34,23 @@ const { LUA_TUSERDATA } = constant_types; -export const api_incr_top = function (L) { +const {LUA_OK} = thread_status; + +const api_incr_top = function (L) { L.top++; - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); }; const api_checknelems = function (L, n) { - api_check(L, n < (L.top - L.ci.funcOff), 'not enough elements in the stack'); + api_check(L, n < (L.top - L.ci.funcOff), "not enough elements in the stack"); }; const fengari_argcheck = function (c) { - if (!c) throw TypeError('invalid argument'); + if (!c) throw TypeError("invalid argument"); }; const fengari_argcheckinteger = function (n) { - fengari_argcheck(typeof n === 'number' && (n | 0) === n); + fengari_argcheck(typeof n === "number" && (n | 0) === n); }; const isvalid = function (o) { @@ -127,17 +79,17 @@ const index2addr = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); + api_check(L, idx <= ci.top - (ci.funcOff + 1), "unacceptable index"); if (o >= L.top) return luaO_nilobject; else return L.stack[o]; } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); + api_check(L, idx !== 0 && -idx <= L.top, "invalid index"); return L.stack[L.top + idx]; } else if (idx === LUA_REGISTRYINDEX) { return L.l_G.l_registry; } else { /* upvalues */ idx = LUA_REGISTRYINDEX - idx; - api_check(L, idx <= MAXUPVAL + 1, 'upvalue index too large'); + api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); if (ci.func.ttislcf()) /* light C function? */ return luaO_nilobject; /* it has no upvalues */ else { @@ -151,21 +103,21 @@ const index2addr_ = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); + api_check(L, idx <= ci.top - (ci.funcOff + 1), "unacceptable index"); if (o >= L.top) return null; else return o; } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); + api_check(L, idx !== 0 && -idx <= L.top, "invalid index"); return L.top + idx; } else { /* registry or upvalue */ - throw Error('attempt to use pseudo-index'); + throw Error("attempt to use pseudo-index"); } }; const lua_checkstack = function (L, n) { let res; let ci = L.ci; - api_check(L, n >= 0, 'negative \'n\''); + api_check(L, n >= 0, "negative 'n'"); if (L.stack_last - L.top > n) /* stack large enough? */ res = true; else { /* no; need to grow stack */ @@ -187,8 +139,8 @@ const lua_checkstack = function (L, n) { const lua_xmove = function (from, to, n) { if (from === to) return; api_checknelems(from, n); - api_check(from, from.l_G === to.l_G, 'moving among independent states'); - api_check(from, to.ci.top - to.top >= n, 'stack overflow'); + api_check(from, from.l_G === to.l_G, "moving among independent states"); + api_check(from, to.ci.top - to.top >= n, "stack overflow"); from.top -= n; for (let i = 0; i < n; i++) { to.stack[to.top] = new _TValue(); @@ -217,17 +169,17 @@ const lua_gettop = function (L) { const lua_pushvalue = function (L, idx) { pushobj2s(L, index2addr(L, idx)); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); }; const lua_settop = function (L, idx) { let func = L.ci.funcOff; let newtop; if (idx >= 0) { - api_check(L, idx <= L.stack_last - (func + 1), 'new top too large'); + api_check(L, idx <= L.stack_last - (func + 1), "new top too large"); newtop = func + 1 + idx; } else { - api_check(L, -(idx + 1) <= L.top - (func + 1), 'invalid new top'); + api_check(L, -(idx + 1) <= L.top - (func + 1), "invalid new top"); newtop = L.top + idx + 1; /* 'subtract' index (index is negative) */ } adjust_top(L, newtop); @@ -254,8 +206,8 @@ const lua_rotate = function (L, idx, n) { let t = L.top - 1; let pIdx = index2addr_(L, idx); let p = L.stack[pIdx]; - api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, 'index not in the stack'); - api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), 'invalid \'n\''); + api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, "index not in the stack"); + api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), "invalid 'n'"); let m = n >= 0 ? t - n : pIdx - n - 1; /* end of prefix */ reverse(L, pIdx, m); reverse(L, m + 1, L.top - 1); @@ -291,12 +243,12 @@ const lua_pushnil = function (L) { }; const lua_pushnumber = function (L, n) { - fengari_argcheck(typeof n === 'number'); + fengari_argcheck(typeof n === "number"); L.stack[L.top] = new TValue(LUA_TNUMFLT, n); api_incr_top(L); }; -export const lua_pushinteger = function (L, n) { +const lua_pushinteger = function (L, n) { fengari_argcheckinteger(n); L.stack[L.top] = new TValue(LUA_TNUMINT, n); api_incr_top(L); @@ -306,15 +258,15 @@ const lua_pushlstring = function (L, s, len) { fengari_argcheckinteger(len); let ts; if (len === 0) { - s = to_luastring('', true); + s = to_luastring("", true); ts = luaS_bless(L, s); } else { s = from_userstring(s); - api_check(L, s.length >= len, 'invalid length to lua_pushlstring'); + api_check(L, s.length >= len, "invalid length to lua_pushlstring"); ts = luaS_new(L, s.subarray(0, len)); } pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); return ts.value; }; @@ -327,7 +279,7 @@ const lua_pushstring = function (L, s) { pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); return s; }; @@ -342,29 +294,29 @@ const lua_pushfstring = function (L, fmt, ...argp) { }; /* Similar to lua_pushstring, but takes a JS string */ -export const lua_pushliteral = function (L, s) { +const lua_pushliteral = function (L, s) { if (s === undefined || s === null) { L.stack[L.top] = new TValue(LUA_TNIL, null); L.top++; } else { - fengari_argcheck(typeof s === 'string'); + fengari_argcheck(typeof s === "string"); let ts = luaS_newliteral(L, s); pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); return s; }; const lua_pushcclosure = function (L, fn, n) { - fengari_argcheck(typeof fn === 'function'); + fengari_argcheck(typeof fn === "function"); fengari_argcheckinteger(n); if (n === 0) L.stack[L.top] = new TValue(LUA_TLCF, fn); else { api_checknelems(L, n); - api_check(L, n <= MAXUPVAL, 'upvalue index too large'); + api_check(L, n <= MAXUPVAL, "upvalue index too large"); let cl = new CClosure(L, fn, n); for (let i = 0; i < n; i++) cl.upvalue[i].setfrom(L.stack[L.top - n + i]); @@ -416,7 +368,7 @@ const auxsetstr = function (L, t, k) { let str = luaS_new(L, from_userstring(k)); api_checknelems(L, 1); pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ delete L.stack[--L.top]; @@ -434,7 +386,7 @@ const lua_setmetatable = function (L, objindex) { if (L.stack[L.top - 1].ttisnil()) mt = null; else { - api_check(L, L.stack[L.top - 1].ttistable(), 'table expected'); + api_check(L, L.stack[L.top - 1].ttistable(), "table expected"); mt = L.stack[L.top - 1].value; } @@ -462,7 +414,7 @@ const lua_settable = function (L, idx) { delete L.stack[--L.top]; }; -export const lua_setfield = function (L, idx, k) { +const lua_setfield = function (L, idx, k) { auxsetstr(L, index2addr(L, idx), k); }; @@ -481,7 +433,7 @@ const lua_seti = function (L, idx, n) { const lua_rawset = function (L, idx) { api_checknelems(L, 2); let o = index2addr(L, idx); - api_check(L, o.ttistable(), 'table expected'); + api_check(L, o.ttistable(), "table expected"); let k = L.stack[L.top - 2]; let v = L.stack[L.top - 1]; luaH_setfrom(L, o.value, k, v); @@ -494,7 +446,7 @@ const lua_rawseti = function (L, idx, n) { fengari_argcheckinteger(n); api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), 'table expected'); + api_check(L, o.ttistable(), "table expected"); luaH_setint(o.value, n, L.stack[L.top - 1]); delete L.stack[--L.top]; }; @@ -502,7 +454,7 @@ const lua_rawseti = function (L, idx, n) { const lua_rawsetp = function (L, idx, p) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), 'table expected'); + api_check(L, o.ttistable(), "table expected"); let k = new TValue(LUA_TLIGHTUSERDATA, p); let v = L.stack[L.top - 1]; luaH_setfrom(L, o.value, k, v); @@ -516,7 +468,7 @@ const lua_rawsetp = function (L, idx, p) { const auxgetstr = function (L, t, k) { let str = luaS_new(L, from_userstring(k)); pushsvalue2s(L, str); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; @@ -524,24 +476,24 @@ const auxgetstr = function (L, t, k) { const lua_rawgeti = function (L, idx, n) { let t = index2addr(L, idx); fengari_argcheckinteger(n); - api_check(L, t.ttistable(), 'table expected'); + api_check(L, t.ttistable(), "table expected"); pushobj2s(L, luaH_getint(t.value, n)); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); return L.stack[L.top - 1].ttnov(); }; const lua_rawgetp = function (L, idx, p) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), 'table expected'); + api_check(L, t.ttistable(), "table expected"); let k = new TValue(LUA_TLIGHTUSERDATA, p); pushobj2s(L, luaH_get(L, t.value, k)); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); return L.stack[L.top - 1].ttnov(); }; const lua_rawget = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(t), 'table expected'); + api_check(L, t.ttistable(t), "table expected"); setobj2s(L, L.top - 1, luaH_get(L, t.value, L.stack[L.top - 1])); return L.stack[L.top - 1].ttnov(); }; @@ -571,7 +523,7 @@ const aux_upvalue = function (L, fi, n) { let f = fi.value; if (!(1 <= n && n <= f.nupvalues)) return null; return { - name: to_luastring('', true), + name: to_luastring("", true), val: f.upvalue[n - 1] }; } @@ -581,12 +533,11 @@ const aux_upvalue = function (L, fi, n) { if (!(1 <= n && n <= p.upvalues.length)) return null; let name = p.upvalues[n - 1].name; return { - name: name ? name.getstr() : to_luastring('(*no name)', true), + name: name ? name.getstr() : to_luastring("(*no name)", true), val: f.upvals[n - 1] }; } - default: - return null; /* not a closure */ + default: return null; /* not a closure */ } }; @@ -596,7 +547,7 @@ const lua_getupvalue = function (L, funcindex, n) { let name = up.name; let val = up.val; pushobj2s(L, val); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); return name; } return null; @@ -650,7 +601,7 @@ const lua_getmetatable = function (L, objindex) { const lua_getuservalue = function (L, idx) { let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), 'full userdata expected'); + api_check(L, o.ttisfulluserdata(), "full userdata expected"); let uv = o.value.uservalue; L.stack[L.top] = new TValue(uv.type, uv.value); api_incr_top(L); @@ -766,8 +717,7 @@ const lua_touserdata = function (L, idx) { return o.value.data; case LUA_TLIGHTUSERDATA: return o.value; - default: - return null; + default: return null; } }; @@ -809,7 +759,7 @@ const lua_isproxy = function (p, L) { /* Use 'create_proxy' helper function so that 'L' is not in scope */ const create_proxy = function (G, type, value) { let proxy = function (L) { - api_check(L, L instanceof lua_State && G === L.l_G, 'must be from same global state'); + api_check(L, L instanceof lua_State && G === L.l_G, "must be from same global state"); L.stack[L.top] = new TValue(type, value); api_incr_top(L); }; @@ -832,17 +782,10 @@ const lua_compare = function (L, index1, index2, op) { if (isvalid(o1) && isvalid(o2)) { switch (op) { - case LUA_OPEQ: - i = luaV_equalobj(L, o1, o2); - break; - case LUA_OPLT: - i = luaV_lessthan(L, o1, o2); - break; - case LUA_OPLE: - i = luaV_lessequal(L, o1, o2); - break; - default: - api_check(L, false, 'invalid option'); + case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; + case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; + case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; + default: api_check(L, false, "invalid option"); } } @@ -869,7 +812,7 @@ const lua_type = function (L, idx) { }; const lua_typename = function (L, t) { - api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, 'invalid tag'); + api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); return ttypename(t); }; @@ -940,7 +883,7 @@ const lua_arith = function (L, op) { else { /* for unary operations, add fake 2nd operand */ api_checknelems(L, 1); pushobj2s(L, L.stack[L.top - 1]); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); } /* first operand at top - 2, second at top - 1; result go to top - 2 */ luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); @@ -951,7 +894,7 @@ const lua_arith = function (L, op) { ** 'load' and 'call' functions (run Lua code) */ -const default_chunkname = to_luastring('?'); +const default_chunkname = to_luastring("?"); const lua_load = function (L, reader, data, chunkname, mode) { if (!chunkname) chunkname = default_chunkname; else chunkname = from_userstring(chunkname); @@ -985,20 +928,20 @@ const lua_status = function (L) { const lua_setuservalue = function (L, idx) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), 'full userdata expected'); + api_check(L, o.ttisfulluserdata(), "full userdata expected"); o.value.uservalue.setfrom(L.stack[L.top - 1]); delete L.stack[--L.top]; }; const checkresults = function (L, na, nr) { api_check(L, nr === LUA_MULTRET || (L.ci.top - L.top >= (nr) - (na)), - 'results from function overflow current stack size'); + "results from function overflow current stack size"); }; const lua_callk = function (L, nargs, nresults, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); + api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), "cannot use continuations inside hooks"); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); + api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread"); checkresults(L, nargs, nresults); let func = L.top - (nargs + 1); if (k !== null && L.nny === 0) { /* need to prepare continuation? */ @@ -1018,9 +961,9 @@ const lua_call = function (L, n, r) { }; const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); + api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), "cannot use continuations inside hooks"); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); + api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread"); checkresults(L, nargs, nresults); let status; let func; @@ -1073,7 +1016,7 @@ const lua_error = function (L) { const lua_next = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), 'table expected'); + api_check(L, t.ttistable(), "table expected"); L.stack[L.top] = new TValue(); let more = luaH_next(L, t.value, L.top - 1); if (more) { @@ -1091,8 +1034,8 @@ const lua_concat = function (L, n) { if (n >= 2) luaV_concat(L, n); else if (n === 0) { - pushsvalue2s(L, luaS_bless(L, to_luastring('', true))); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + pushsvalue2s(L, luaS_bless(L, to_luastring("", true))); + api_check(L, L.top <= L.ci.top, "stack overflow"); } }; @@ -1106,10 +1049,10 @@ const lua_len = function (L, idx) { const getupvalref = function (L, fidx, n) { let fi = index2addr(L, fidx); - api_check(L, fi.ttisLclosure(), 'Lua function expected'); + api_check(L, fi.ttisLclosure(), "Lua function expected"); let f = fi.value; fengari_argcheckinteger(n); - api_check(L, 1 <= n && n <= f.p.upvalues.length, 'invalid upvalue index'); + api_check(L, 1 <= n && n <= f.p.upvalues.length, "invalid upvalue index"); return { f: f, i: n - 1 @@ -1125,11 +1068,11 @@ const lua_upvalueid = function (L, fidx, n) { } case LUA_TCCL: { /* C closure */ let f = fi.value; - api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, 'invalid upvalue index'); + api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, "invalid upvalue index"); return f.upvalue[n - 1]; } default: { - api_check(L, false, 'closure expected'); + api_check(L, false, "closure expected"); return null; } } @@ -1143,20 +1086,238 @@ const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { }; // This functions are only there for compatibility purposes -const lua_gc = function () { -}; +const lua_gc = function () { }; const lua_getallocf = function () { - console.warn('lua_getallocf is not available'); + console.warn("lua_getallocf is not available"); return 0; }; const lua_setallocf = function () { - console.warn('lua_setallocf is not available'); + console.warn("lua_setallocf is not available"); return 0; }; const lua_getextraspace = function () { - console.warn('lua_getextraspace is not available'); + console.warn("lua_getextraspace is not available"); return 0; }; + +const _api_incr_top = api_incr_top; +export { _api_incr_top as api_incr_top }; +const _api_checknelems = api_checknelems; +export { _api_checknelems as api_checknelems }; +const _lua_absindex = lua_absindex; +export { _lua_absindex as lua_absindex }; +const _lua_arith = lua_arith; +export { _lua_arith as lua_arith }; +const _lua_atpanic = lua_atpanic; +export { _lua_atpanic as lua_atpanic }; +const _lua_atnativeerror = lua_atnativeerror; +export { _lua_atnativeerror as lua_atnativeerror }; +const _lua_call = lua_call; +export { _lua_call as lua_call }; +const _lua_callk = lua_callk; +export { _lua_callk as lua_callk }; +const _lua_checkstack = lua_checkstack; +export { _lua_checkstack as lua_checkstack }; +const _lua_compare = lua_compare; +export { _lua_compare as lua_compare }; +const _lua_concat = lua_concat; +export { _lua_concat as lua_concat }; +const _lua_copy = lua_copy; +export { _lua_copy as lua_copy }; +const _lua_createtable = lua_createtable; +export { _lua_createtable as lua_createtable }; +const _lua_dump = lua_dump; +export { _lua_dump as lua_dump }; +const _lua_error = lua_error; +export { _lua_error as lua_error }; +const _lua_gc = lua_gc; +export { _lua_gc as lua_gc }; +const _lua_getallocf = lua_getallocf; +export { _lua_getallocf as lua_getallocf }; +const _lua_getextraspace = lua_getextraspace; +export { _lua_getextraspace as lua_getextraspace }; +const _lua_getfield = lua_getfield; +export { _lua_getfield as lua_getfield }; +const _lua_getglobal = lua_getglobal; +export { _lua_getglobal as lua_getglobal }; +const _lua_geti = lua_geti; +export { _lua_geti as lua_geti }; +const _lua_getmetatable = lua_getmetatable; +export { _lua_getmetatable as lua_getmetatable }; +const _lua_gettable = lua_gettable; +export { _lua_gettable as lua_gettable }; +const _lua_gettop = lua_gettop; +export { _lua_gettop as lua_gettop }; +const _lua_getupvalue = lua_getupvalue; +export { _lua_getupvalue as lua_getupvalue }; +const _lua_getuservalue = lua_getuservalue; +export { _lua_getuservalue as lua_getuservalue }; +const _lua_insert = lua_insert; +export { _lua_insert as lua_insert }; +const _lua_isboolean = lua_isboolean; +export { _lua_isboolean as lua_isboolean }; +const _lua_iscfunction = lua_iscfunction; +export { _lua_iscfunction as lua_iscfunction }; +const _lua_isfunction = lua_isfunction; +export { _lua_isfunction as lua_isfunction }; +const _lua_isinteger = lua_isinteger; +export { _lua_isinteger as lua_isinteger }; +const _lua_islightuserdata = lua_islightuserdata; +export { _lua_islightuserdata as lua_islightuserdata }; +const _lua_isnil = lua_isnil; +export { _lua_isnil as lua_isnil }; +const _lua_isnone = lua_isnone; +export { _lua_isnone as lua_isnone }; +const _lua_isnoneornil = lua_isnoneornil; +export { _lua_isnoneornil as lua_isnoneornil }; +const _lua_isnumber = lua_isnumber; +export { _lua_isnumber as lua_isnumber }; +const _lua_isproxy = lua_isproxy; +export { _lua_isproxy as lua_isproxy }; +const _lua_isstring = lua_isstring; +export { _lua_isstring as lua_isstring }; +const _lua_istable = lua_istable; +export { _lua_istable as lua_istable }; +const _lua_isthread = lua_isthread; +export { _lua_isthread as lua_isthread }; +const _lua_isuserdata = lua_isuserdata; +export { _lua_isuserdata as lua_isuserdata }; +const _lua_len = lua_len; +export { _lua_len as lua_len }; +const _lua_load = lua_load; +export { _lua_load as lua_load }; +const _lua_newtable = lua_newtable; +export { _lua_newtable as lua_newtable }; +const _lua_newuserdata = lua_newuserdata; +export { _lua_newuserdata as lua_newuserdata }; +const _lua_next = lua_next; +export { _lua_next as lua_next }; +const _lua_pcall = lua_pcall; +export { _lua_pcall as lua_pcall }; +const _lua_pcallk = lua_pcallk; +export { _lua_pcallk as lua_pcallk }; +const _lua_pop = lua_pop; +export { _lua_pop as lua_pop }; +const _lua_pushboolean = lua_pushboolean; +export { _lua_pushboolean as lua_pushboolean }; +const _lua_pushcclosure = lua_pushcclosure; +export { _lua_pushcclosure as lua_pushcclosure }; +const _lua_pushcfunction = lua_pushcfunction; +export { _lua_pushcfunction as lua_pushcfunction }; +const _lua_pushfstring = lua_pushfstring; +export { _lua_pushfstring as lua_pushfstring }; +const _lua_pushglobaltable = lua_pushglobaltable; +export { _lua_pushglobaltable as lua_pushglobaltable }; +const _lua_pushinteger = lua_pushinteger; +export { _lua_pushinteger as lua_pushinteger }; +const _lua_pushjsclosure = lua_pushjsclosure; +export { _lua_pushjsclosure as lua_pushjsclosure }; +const _lua_pushjsfunction = lua_pushjsfunction; +export { _lua_pushjsfunction as lua_pushjsfunction }; +const _lua_pushlightuserdata = lua_pushlightuserdata; +export { _lua_pushlightuserdata as lua_pushlightuserdata }; +const _lua_pushliteral = lua_pushliteral; +export { _lua_pushliteral as lua_pushliteral }; +const _lua_pushlstring = lua_pushlstring; +export { _lua_pushlstring as lua_pushlstring }; +const _lua_pushnil = lua_pushnil; +export { _lua_pushnil as lua_pushnil }; +const _lua_pushnumber = lua_pushnumber; +export { _lua_pushnumber as lua_pushnumber }; +const _lua_pushstring = lua_pushstring; +export { _lua_pushstring as lua_pushstring }; +const _lua_pushthread = lua_pushthread; +export { _lua_pushthread as lua_pushthread }; +const _lua_pushvalue = lua_pushvalue; +export { _lua_pushvalue as lua_pushvalue }; +const _lua_pushvfstring = lua_pushvfstring; +export { _lua_pushvfstring as lua_pushvfstring }; +const _lua_rawequal = lua_rawequal; +export { _lua_rawequal as lua_rawequal }; +const _lua_rawget = lua_rawget; +export { _lua_rawget as lua_rawget }; +const _lua_rawgeti = lua_rawgeti; +export { _lua_rawgeti as lua_rawgeti }; +const _lua_rawgetp = lua_rawgetp; +export { _lua_rawgetp as lua_rawgetp }; +const _lua_rawlen = lua_rawlen; +export { _lua_rawlen as lua_rawlen }; +const _lua_rawset = lua_rawset; +export { _lua_rawset as lua_rawset }; +const _lua_rawseti = lua_rawseti; +export { _lua_rawseti as lua_rawseti }; +const _lua_rawsetp = lua_rawsetp; +export { _lua_rawsetp as lua_rawsetp }; +const _lua_register = lua_register; +export { _lua_register as lua_register }; +const _lua_remove = lua_remove; +export { _lua_remove as lua_remove }; +const _lua_replace = lua_replace; +export { _lua_replace as lua_replace }; +const _lua_rotate = lua_rotate; +export { _lua_rotate as lua_rotate }; +const _lua_setallocf = lua_setallocf; +export { _lua_setallocf as lua_setallocf }; +const _lua_setfield = lua_setfield; +export { _lua_setfield as lua_setfield }; +const _lua_setglobal = lua_setglobal; +export { _lua_setglobal as lua_setglobal }; +const _lua_seti = lua_seti; +export { _lua_seti as lua_seti }; +const _lua_setmetatable = lua_setmetatable; +export { _lua_setmetatable as lua_setmetatable }; +const _lua_settable = lua_settable; +export { _lua_settable as lua_settable }; +const _lua_settop = lua_settop; +export { _lua_settop as lua_settop }; +const _lua_setupvalue = lua_setupvalue; +export { _lua_setupvalue as lua_setupvalue }; +const _lua_setuservalue = lua_setuservalue; +export { _lua_setuservalue as lua_setuservalue }; +const _lua_status = lua_status; +export { _lua_status as lua_status }; +const _lua_stringtonumber = lua_stringtonumber; +export { _lua_stringtonumber as lua_stringtonumber }; +const _lua_toboolean = lua_toboolean; +export { _lua_toboolean as lua_toboolean }; +const _lua_tocfunction = lua_tocfunction; +export { _lua_tocfunction as lua_tocfunction }; +const _lua_todataview = lua_todataview; +export { _lua_todataview as lua_todataview }; +const _lua_tointeger = lua_tointeger; +export { _lua_tointeger as lua_tointeger }; +const _lua_tointegerx = lua_tointegerx; +export { _lua_tointegerx as lua_tointegerx }; +const _lua_tojsstring = lua_tojsstring; +export { _lua_tojsstring as lua_tojsstring }; +const _lua_tolstring = lua_tolstring; +export { _lua_tolstring as lua_tolstring }; +const _lua_tonumber = lua_tonumber; +export { _lua_tonumber as lua_tonumber }; +const _lua_tonumberx = lua_tonumberx; +export { _lua_tonumberx as lua_tonumberx }; +const _lua_topointer = lua_topointer; +export { _lua_topointer as lua_topointer }; +const _lua_toproxy = lua_toproxy; +export { _lua_toproxy as lua_toproxy }; +const _lua_tostring = lua_tostring; +export { _lua_tostring as lua_tostring }; +const _lua_tothread = lua_tothread; +export { _lua_tothread as lua_tothread }; +const _lua_touserdata = lua_touserdata; +export { _lua_touserdata as lua_touserdata }; +const _lua_type = lua_type; +export { _lua_type as lua_type }; +const _lua_typename = lua_typename; +export { _lua_typename as lua_typename }; +const _lua_upvalueid = lua_upvalueid; +export { _lua_upvalueid as lua_upvalueid }; +const _lua_upvaluejoin = lua_upvaluejoin; +export { _lua_upvaluejoin as lua_upvaluejoin }; +const _lua_version = lua_version; +export { _lua_version as lua_version }; +const _lua_xmove = lua_xmove; +export { _lua_xmove as lua_xmove }; diff --git a/src/lauxlib.js b/src/lauxlib.js index 95620269..042b8b23 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -1,102 +1,24 @@ -import fs from 'fs'; +"use strict"; + import { LUAL_BUFFERSIZE } from './luaconf.js'; -import { - LUA_ERRERR, - LUA_MULTRET, - LUA_REGISTRYINDEX, - LUA_SIGNATURE, - LUA_TBOOLEAN, - LUA_TLIGHTUSERDATA, - LUA_TNIL, - LUA_TNONE, - LUA_TNUMBER, - LUA_TSTRING, - LUA_TTABLE, - LUA_VERSION_NUM, - lua_Debug, - lua_absindex, - lua_atpanic, - lua_call, - lua_checkstack, - lua_concat, - lua_copy, - lua_createtable, - lua_error, - lua_getfield, - lua_getinfo, - lua_getmetatable, - lua_getstack, - lua_gettop, - lua_insert, - lua_isinteger, - lua_isnil, - lua_isnumber, - lua_isstring, - lua_istable, - lua_len, - lua_load, - lua_newstate, - lua_newtable, - lua_next, - lua_pcall, - lua_pop, - lua_pushboolean, - lua_pushcclosure, - lua_pushcfunction, - lua_pushfstring, - lua_pushinteger, - lua_pushliteral, - lua_pushlstring, - lua_pushnil, - lua_pushstring, - lua_pushvalue, - lua_pushvfstring, - lua_rawequal, - lua_rawget, - lua_rawgeti, - lua_rawlen, - lua_rawseti, - lua_remove, - lua_setfield, - lua_setglobal, - lua_setmetatable, - lua_settop, - lua_toboolean, - lua_tointeger, - lua_tointegerx, - lua_tojsstring, - lua_tolstring, - lua_tonumber, - lua_tonumberx, - lua_topointer, - lua_tostring, - lua_touserdata, - lua_type, - lua_typename, - lua_version -} from './lua.js'; -import { - from_userstring, - luastring_eq, - to_luastring, - to_uristring -} from './fengaricore.js'; +import { LUA_ERRERR, LUA_MULTRET, LUA_REGISTRYINDEX, LUA_SIGNATURE, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_VERSION_NUM, lua_Debug, lua_absindex, lua_atpanic, lua_call, lua_checkstack, lua_concat, lua_copy, lua_createtable, lua_error, lua_getfield, lua_getinfo, lua_getmetatable, lua_getstack, lua_gettop, lua_insert, lua_isinteger, lua_isnil, lua_isnumber, lua_isstring, lua_istable, lua_len, lua_load, lua_newstate, lua_newtable, lua_next, lua_pcall, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawlen, lua_rawseti, lua_remove, lua_setfield, lua_setglobal, lua_setmetatable, lua_settop, lua_toboolean, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_tostring, lua_touserdata, lua_type, lua_typename, lua_version } from './lua.js'; +import { from_userstring, luastring_eq, to_luastring, to_uristring } from "./fengaricore.js"; /* extra error code for 'luaL_loadfilex' */ -const LUA_ERRFILE = LUA_ERRERR + 1; +const LUA_ERRFILE = LUA_ERRERR+1; /* key, in the registry, for table of loaded modules */ -const LUA_LOADED_TABLE = to_luastring('_LOADED'); +const LUA_LOADED_TABLE = to_luastring("_LOADED"); /* key, in the registry, for table of preloaded loaders */ -const LUA_PRELOAD_TABLE = to_luastring('_PRELOAD'); +const LUA_PRELOAD_TABLE = to_luastring("_PRELOAD"); -const LUA_FILEHANDLE = to_luastring('FILE*'); +const LUA_FILEHANDLE = to_luastring("FILE*"); -const LUAL_NUMSIZES = 4 * 16 + 8; +const LUAL_NUMSIZES = 4*16 + 8; -const __name = to_luastring('__name'); -const __tostring = to_luastring('__tostring'); +const __name = to_luastring("__name"); +const __tostring = to_luastring("__tostring"); const empty = new Uint8Array(0); @@ -115,7 +37,7 @@ const LEVELS2 = 11; /* size of the second part of the stack */ ** search for 'objidx' in table at index -1. ** return 1 + string at top if find a good name. */ -const findfield = function (L, objidx, level) { +const findfield = function(L, objidx, level) { if (level === 0 || !lua_istable(L, -1)) return 0; /* not found */ @@ -128,7 +50,7 @@ const findfield = function (L, objidx, level) { return 1; } else if (findfield(L, objidx, level - 1)) { /* try recursively */ lua_remove(L, -2); /* remove table (but keep name) */ - lua_pushliteral(L, '.'); + lua_pushliteral(L, "."); lua_insert(L, -2); /* place '.' between the two names */ lua_concat(L, 3); return 1; @@ -143,9 +65,9 @@ const findfield = function (L, objidx, level) { /* ** Search for a name for a function in all loaded modules */ -const pushglobalfuncname = function (L, ar) { +const pushglobalfuncname = function(L, ar) { let top = lua_gettop(L); - lua_getinfo(L, to_luastring('f'), ar); /* push function */ + lua_getinfo(L, to_luastring("f"), ar); /* push function */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); if (findfield(L, top + 1, 2)) { let name = lua_tostring(L, -1); @@ -165,22 +87,22 @@ const pushglobalfuncname = function (L, ar) { } }; -const pushfuncname = function (L, ar) { +const pushfuncname = function(L, ar) { if (pushglobalfuncname(L, ar)) { /* try first a global name */ - lua_pushfstring(L, to_luastring('function \'%s\''), lua_tostring(L, -1)); + lua_pushfstring(L, to_luastring("function '%s'"), lua_tostring(L, -1)); lua_remove(L, -2); /* remove name */ } else if (ar.namewhat.length !== 0) /* is there a name from code? */ - lua_pushfstring(L, to_luastring('%s \'%s\''), ar.namewhat, ar.name); /* use it */ + lua_pushfstring(L, to_luastring("%s '%s'"), ar.namewhat, ar.name); /* use it */ else if (ar.what && ar.what[0] === 109 /* 'm'.charCodeAt(0) */) /* main? */ - lua_pushliteral(L, 'main chunk'); + lua_pushliteral(L, "main chunk"); else if (ar.what && ar.what[0] === 76 /* 'L'.charCodeAt(0) */) /* for Lua functions, use */ - lua_pushfstring(L, to_luastring('function <%s:%d>'), ar.short_src, ar.linedefined); + lua_pushfstring(L, to_luastring("function <%s:%d>"), ar.short_src, ar.linedefined); else /* nothing left... */ - lua_pushliteral(L, '?'); + lua_pushliteral(L, "?"); }; -const lastlevel = function (L) { +const lastlevel = function(L) { let ar = new lua_Debug(); let li = 1; let le = 1; @@ -188,92 +110,92 @@ const lastlevel = function (L) { while (lua_getstack(L, le, ar)) { li = le; le *= 2; } /* do a binary search */ while (li < le) { - let m = Math.floor((li + le) / 2); + let m = Math.floor((li + le)/2); if (lua_getstack(L, m, ar)) li = m + 1; else le = m; } return le - 1; }; -export const luaL_traceback = function (L, L1, msg, level) { +const luaL_traceback = function(L, L1, msg, level) { let ar = new lua_Debug(); let top = lua_gettop(L); let last = lastlevel(L1); let n1 = last - level > LEVELS1 + LEVELS2 ? LEVELS1 : -1; if (msg) - lua_pushfstring(L, to_luastring('%s\n'), msg); + lua_pushfstring(L, to_luastring("%s\n"), msg); luaL_checkstack(L, 10, null); - lua_pushliteral(L, 'stack traceback:'); + lua_pushliteral(L, "stack traceback:"); while (lua_getstack(L1, level++, ar)) { if (n1-- === 0) { /* too many levels? */ - lua_pushliteral(L, '\n\t...'); /* add a '...' */ + lua_pushliteral(L, "\n\t..."); /* add a '...' */ level = last - LEVELS2 + 1; /* and skip to last ones */ } else { - lua_getinfo(L1, to_luastring('Slnt', true), ar); - lua_pushfstring(L, to_luastring('\n\t%s:'), ar.short_src); + lua_getinfo(L1, to_luastring("Slnt", true), ar); + lua_pushfstring(L, to_luastring("\n\t%s:"), ar.short_src); if (ar.currentline > 0) lua_pushliteral(L, `${ar.currentline}:`); - lua_pushliteral(L, ' in '); + lua_pushliteral(L, " in "); pushfuncname(L, ar); if (ar.istailcall) - lua_pushliteral(L, '\n\t(...tail calls..)'); + lua_pushliteral(L, "\n\t(...tail calls..)"); lua_concat(L, lua_gettop(L) - top); } } lua_concat(L, lua_gettop(L) - top); }; -const panic = function (L) { - let msg = 'PANIC: unprotected error in call to Lua API (' + lua_tojsstring(L, -1) + ')'; +const panic = function(L) { + let msg = "PANIC: unprotected error in call to Lua API (" + lua_tojsstring(L, -1) + ")"; throw new Error(msg); }; -export const luaL_argerror = function (L, arg, extramsg) { +const luaL_argerror = function(L, arg, extramsg) { let ar = new lua_Debug(); if (!lua_getstack(L, 0, ar)) /* no stack frame? */ - return luaL_error(L, to_luastring('bad argument #%d (%s)'), arg, extramsg); + return luaL_error(L, to_luastring("bad argument #%d (%s)"), arg, extramsg); - lua_getinfo(L, to_luastring('n'), ar); + lua_getinfo(L, to_luastring("n"), ar); - if (luastring_eq(ar.namewhat, to_luastring('method'))) { + if (luastring_eq(ar.namewhat, to_luastring("method"))) { arg--; /* do not count 'self' */ if (arg === 0) /* error is in the self argument itself? */ - return luaL_error(L, to_luastring('calling \'%s\' on bad self (%s)'), ar.name, extramsg); + return luaL_error(L, to_luastring("calling '%s' on bad self (%s)"), ar.name, extramsg); } if (ar.name === null) - ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring('?'); + ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring("?"); - return luaL_error(L, to_luastring('bad argument #%d to \'%s\' (%s)'), arg, ar.name, extramsg); + return luaL_error(L, to_luastring("bad argument #%d to '%s' (%s)"), arg, ar.name, extramsg); }; -const typeerror = function (L, arg, tname) { +const typeerror = function(L, arg, tname) { let typearg; if (luaL_getmetafield(L, arg, __name) === LUA_TSTRING) typearg = lua_tostring(L, -1); else if (lua_type(L, arg) === LUA_TLIGHTUSERDATA) - typearg = to_luastring('light userdata', true); + typearg = to_luastring("light userdata", true); else typearg = luaL_typename(L, arg); - let msg = lua_pushfstring(L, to_luastring('%s expected, got %s'), tname, typearg); + let msg = lua_pushfstring(L, to_luastring("%s expected, got %s"), tname, typearg); return luaL_argerror(L, arg, msg); }; -export const luaL_where = function (L, level) { +const luaL_where = function(L, level) { let ar = new lua_Debug(); if (lua_getstack(L, level, ar)) { - lua_getinfo(L, to_luastring('Sl', true), ar); + lua_getinfo(L, to_luastring("Sl", true), ar); if (ar.currentline > 0) { - lua_pushfstring(L, to_luastring('%s:%d: '), ar.short_src, ar.currentline); + lua_pushfstring(L, to_luastring("%s:%d: "), ar.short_src, ar.currentline); return; } } - lua_pushstring(L, to_luastring('')); + lua_pushstring(L, to_luastring("")); }; -export const luaL_error = function (L, fmt, ...argp) { +const luaL_error = function(L, fmt, ...argp) { luaL_where(L, 1); lua_pushvfstring(L, fmt, argp); lua_concat(L, 2); @@ -281,7 +203,7 @@ export const luaL_error = function (L, fmt, ...argp) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_fileresult = function (L, stat, fname, e) { +const luaL_fileresult = function(L, stat, fname, e) { if (stat) { lua_pushboolean(L, 1); return 1; @@ -292,11 +214,11 @@ const luaL_fileresult = function (L, stat, fname, e) { message = e.message; errno = -e.errno; } else { - message = 'Success'; /* what strerror(0) returns */ + message = "Success"; /* what strerror(0) returns */ errno = 0; } if (fname) - lua_pushfstring(L, to_luastring('%s: %s'), fname, to_luastring(message)); + lua_pushfstring(L, to_luastring("%s: %s"), fname, to_luastring(message)); else lua_pushstring(L, to_luastring(message)); lua_pushinteger(L, errno); @@ -305,18 +227,18 @@ const luaL_fileresult = function (L, stat, fname, e) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_execresult = function (L, e) { +const luaL_execresult = function(L, e) { let what, stat; if (e === null) { lua_pushboolean(L, 1); - lua_pushliteral(L, 'exit'); + lua_pushliteral(L, "exit"); lua_pushinteger(L, 0); return 3; } else if (e.status) { - what = 'exit'; + what = "exit"; stat = e.status; } else if (e.signal) { - what = 'signal'; + what = "signal"; stat = e.signal; } else { /* XXX: node seems to have e.errno as a string instead of a number */ @@ -328,11 +250,11 @@ const luaL_execresult = function (L, e) { return 3; }; -const luaL_getmetatable = function (L, n) { +const luaL_getmetatable = function(L, n) { return lua_getfield(L, LUA_REGISTRYINDEX, n); }; -const luaL_newmetatable = function (L, tname) { +const luaL_newmetatable = function(L, tname) { if (luaL_getmetatable(L, tname) !== LUA_TNIL) /* name already in use? */ return 0; /* leave previous value on top, but return 0 */ lua_pop(L, 1); @@ -345,12 +267,12 @@ const luaL_newmetatable = function (L, tname) { }; -const luaL_setmetatable = function (L, tname) { +const luaL_setmetatable = function(L, tname) { luaL_getmetatable(L, tname); lua_setmetatable(L, -2); }; -const luaL_testudata = function (L, ud, tname) { +const luaL_testudata = function(L, ud, tname) { let p = lua_touserdata(L, ud); if (p !== null) { /* value is a userdata? */ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ @@ -364,95 +286,95 @@ const luaL_testudata = function (L, ud, tname) { return null; /* value is not a userdata with a metatable */ }; -const luaL_checkudata = function (L, ud, tname) { +const luaL_checkudata = function(L, ud, tname) { let p = luaL_testudata(L, ud, tname); if (p === null) typeerror(L, ud, tname); return p; }; -export const luaL_checkoption = function (L, arg, def, lst) { +const luaL_checkoption = function(L, arg, def, lst) { let name = def !== null ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); for (let i = 0; lst[i]; i++) if (luastring_eq(lst[i], name)) return i; - return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring('invalid option \'%s\''), name)); + return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring("invalid option '%s'"), name)); }; -const tag_error = function (L, arg, tag) { +const tag_error = function(L, arg, tag) { typeerror(L, arg, lua_typename(L, tag)); }; -const luaL_newstate = function () { +const luaL_newstate = function() { let L = lua_newstate(); if (L) lua_atpanic(L, panic); return L; }; -const luaL_typename = function (L, i) { +const luaL_typename = function(L, i) { return lua_typename(L, lua_type(L, i)); }; -export const luaL_argcheck = function (L, cond, arg, extramsg) { +const luaL_argcheck = function(L, cond, arg, extramsg) { if (!cond) luaL_argerror(L, arg, extramsg); }; -export const luaL_checkany = function (L, arg) { +const luaL_checkany = function(L, arg) { if (lua_type(L, arg) === LUA_TNONE) - luaL_argerror(L, arg, to_luastring('value expected', true)); + luaL_argerror(L, arg, to_luastring("value expected", true)); }; -export const luaL_checktype = function (L, arg, t) { +const luaL_checktype = function(L, arg, t) { if (lua_type(L, arg) !== t) tag_error(L, arg, t); }; -const luaL_checklstring = function (L, arg) { +const luaL_checklstring = function(L, arg) { let s = lua_tolstring(L, arg); if (s === null || s === undefined) tag_error(L, arg, LUA_TSTRING); return s; }; -export const luaL_checkstring = luaL_checklstring; +const luaL_checkstring = luaL_checklstring; -const luaL_optlstring = function (L, arg, def) { +const luaL_optlstring = function(L, arg, def) { if (lua_type(L, arg) <= 0) { return def === null ? null : from_userstring(def); } else return luaL_checklstring(L, arg); }; -export const luaL_optstring = luaL_optlstring; +const luaL_optstring = luaL_optlstring; -const interror = function (L, arg) { +const interror = function(L, arg) { if (lua_isnumber(L, arg)) - luaL_argerror(L, arg, to_luastring('number has no integer representation', true)); + luaL_argerror(L, arg, to_luastring("number has no integer representation", true)); else tag_error(L, arg, LUA_TNUMBER); }; -const luaL_checknumber = function (L, arg) { +const luaL_checknumber = function(L, arg) { let d = lua_tonumberx(L, arg); if (d === false) tag_error(L, arg, LUA_TNUMBER); return d; }; -const luaL_optnumber = function (L, arg, def) { +const luaL_optnumber = function(L, arg, def) { return luaL_opt(L, luaL_checknumber, arg, def); }; -export const luaL_checkinteger = function (L, arg) { +const luaL_checkinteger = function(L, arg) { let d = lua_tointegerx(L, arg); if (d === false) interror(L, arg); return d; }; -export const luaL_optinteger = function (L, arg, def) { +const luaL_optinteger = function(L, arg, def) { return luaL_opt(L, luaL_checkinteger, arg, def); }; -const luaL_prepbuffsize = function (B, sz) { +const luaL_prepbuffsize = function(B, sz) { let newend = B.n + sz; if (B.b.length < newend) { let newsize = Math.max(B.b.length * 2, newend); /* double buffer size */ @@ -463,21 +385,21 @@ const luaL_prepbuffsize = function (B, sz) { return B.b.subarray(B.n, newend); }; -const luaL_buffinit = function (L, B) { +const luaL_buffinit = function(L, B) { B.L = L; B.b = empty; }; -const luaL_buffinitsize = function (L, B, sz) { +const luaL_buffinitsize = function(L, B, sz) { luaL_buffinit(L, B); return luaL_prepbuffsize(B, sz); }; -const luaL_prepbuffer = function (B) { +const luaL_prepbuffer = function(B) { return luaL_prepbuffsize(B, LUAL_BUFFERSIZE); }; -const luaL_addlstring = function (B, s, l) { +const luaL_addlstring = function(B, s, l) { if (l > 0) { s = from_userstring(s); let b = luaL_prepbuffsize(B, l); @@ -486,66 +408,66 @@ const luaL_addlstring = function (B, s, l) { } }; -const luaL_addstring = function (B, s) { +const luaL_addstring = function(B, s) { s = from_userstring(s); luaL_addlstring(B, s, s.length); }; -const luaL_pushresult = function (B) { +const luaL_pushresult = function(B) { lua_pushlstring(B.L, B.b, B.n); /* delete old buffer */ B.n = 0; B.b = empty; }; -const luaL_addchar = function (B, c) { +const luaL_addchar = function(B, c) { luaL_prepbuffsize(B, 1); B.b[B.n++] = c; }; -const luaL_addsize = function (B, s) { +const luaL_addsize = function(B, s) { B.n += s; }; -const luaL_pushresultsize = function (B, sz) { +const luaL_pushresultsize = function(B, sz) { luaL_addsize(B, sz); luaL_pushresult(B); }; -const luaL_addvalue = function (B) { +const luaL_addvalue = function(B) { let L = B.L; let s = lua_tostring(L, -1); luaL_addlstring(B, s, s.length); lua_pop(L, 1); /* remove value */ }; -const luaL_opt = function (L, f, n, d) { +const luaL_opt = function(L, f, n, d) { return lua_type(L, n) <= 0 ? d : f(L, n); }; -const getS = function (L, ud) { +const getS = function(L, ud) { let s = ud.string; ud.string = null; return s; }; -export const luaL_loadbufferx = function (L, buff, size, name, mode) { - return lua_load(L, getS, { string: buff }, name, mode); +const luaL_loadbufferx = function(L, buff, size, name, mode) { + return lua_load(L, getS, {string: buff}, name, mode); }; -export const luaL_loadbuffer = function (L, s, sz, n) { +const luaL_loadbuffer = function(L, s, sz, n) { return luaL_loadbufferx(L, s, sz, n, null); }; -const luaL_loadstring = function (L, s) { +const luaL_loadstring = function(L, s) { return luaL_loadbuffer(L, s, s.length, s); }; -const luaL_dostring = function (L, s) { +const luaL_dostring = function(L, s) { return (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)); }; -export const luaL_getmetafield = function (L, obj, event) { +const luaL_getmetafield = function(L, obj, event) { if (!lua_getmetatable(L, obj)) /* no metatable? */ return LUA_TNIL; else { @@ -559,7 +481,7 @@ export const luaL_getmetafield = function (L, obj, event) { } }; -const luaL_callmeta = function (L, obj, event) { +const luaL_callmeta = function(L, obj, event) { obj = lua_absindex(L, obj); if (luaL_getmetafield(L, obj, event) === LUA_TNIL) return false; @@ -570,24 +492,24 @@ const luaL_callmeta = function (L, obj, event) { return true; }; -const luaL_len = function (L, idx) { +const luaL_len = function(L, idx) { lua_len(L, idx); let l = lua_tointegerx(L, -1); if (l === false) - luaL_error(L, to_luastring('object length is not an integer', true)); + luaL_error(L, to_luastring("object length is not an integer", true)); lua_pop(L, 1); /* remove object */ return l; }; -const p_I = to_luastring('%I'); -const p_f = to_luastring('%f'); -export const luaL_tolstring = function (L, idx) { +const p_I = to_luastring("%I"); +const p_f = to_luastring("%f"); +const luaL_tolstring = function(L, idx) { if (luaL_callmeta(L, idx, __tostring)) { if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('\'__tostring\' must return a string')); + luaL_error(L, to_luastring("'__tostring' must return a string")); } else { let t = lua_type(L, idx); - switch (t) { + switch(t) { case LUA_TNUMBER: { if (lua_isinteger(L, idx)) lua_pushfstring(L, p_I, lua_tointeger(L, idx)); @@ -599,15 +521,15 @@ export const luaL_tolstring = function (L, idx) { lua_pushvalue(L, idx); break; case LUA_TBOOLEAN: - lua_pushliteral(L, (lua_toboolean(L, idx) ? 'true' : 'false')); + lua_pushliteral(L, (lua_toboolean(L, idx) ? "true" : "false")); break; case LUA_TNIL: - lua_pushliteral(L, 'nil'); + lua_pushliteral(L, "nil"); break; default: { let tt = luaL_getmetafield(L, idx, __name); let kind = tt === LUA_TSTRING ? lua_tostring(L, -1) : luaL_typename(L, idx); - lua_pushfstring(L, to_luastring('%s: %p'), kind, lua_topointer(L, idx)); + lua_pushfstring(L, to_luastring("%s: %p"), kind, lua_topointer(L, idx)); if (tt !== LUA_TNIL) lua_remove(L, -2); break; @@ -624,7 +546,7 @@ export const luaL_tolstring = function (L, idx) { ** if 'glb' is true, also registers the result in the global table. ** Leaves resulting module on the top. */ -const luaL_requiref = function (L, modname, openf, glb) { +const luaL_requiref = function(L, modname, openf, glb) { luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); lua_getfield(L, -1, modname); /* LOADED[modname] */ if (!lua_toboolean(L, -1)) { /* package not already loaded? */ @@ -642,21 +564,21 @@ const luaL_requiref = function (L, modname, openf, glb) { } }; -const find_subarray = function (arr, subarr, from_index) { +const find_subarray = function(arr, subarr, from_index) { var i = from_index >>> 0, sl = subarr.length, l = arr.length + 1 - sl; loop: for (; i < l; i++) { for (let j = 0; j < sl; j++) - if (arr[i + j] !== subarr[j]) + if (arr[i+j] !== subarr[j]) continue loop; return i; } return -1; }; -const luaL_gsub = function (L, s, p, r) { +const luaL_gsub = function(L, s, p, r) { let wild; let b = new luaL_Buffer(); luaL_buffinit(L, b); @@ -674,7 +596,7 @@ const luaL_gsub = function (L, s, p, r) { ** ensure that stack[idx][fname] has a table and push that table ** into the stack */ -const luaL_getsubtable = function (L, idx, fname) { +const luaL_getsubtable = function(L, idx, fname) { if (lua_getfield(L, idx, fname) === LUA_TTABLE) return true; /* table already there */ else { @@ -692,8 +614,8 @@ const luaL_getsubtable = function (L, idx, fname) { ** function gets the 'nup' elements at the top as upvalues. ** Returns with only the table at the stack. */ -export const luaL_setfuncs = function (L, l, nup) { - luaL_checkstack(L, nup, to_luastring('too many upvalues', true)); +const luaL_setfuncs = function(L, l, nup) { + luaL_checkstack(L, nup, to_luastring("too many upvalues", true)); for (let lib in l) { /* fill the table with given functions */ for (let i = 0; i < nup; i++) /* copy upvalues to the top */ lua_pushvalue(L, -nup); @@ -710,29 +632,29 @@ export const luaL_setfuncs = function (L, l, nup) { ** this extra space, Lua will generate the same 'stack overflow' error, ** but without 'msg'.) */ -export const luaL_checkstack = function (L, space, msg) { +const luaL_checkstack = function(L, space, msg) { if (!lua_checkstack(L, space)) { if (msg) - luaL_error(L, to_luastring('stack overflow (%s)'), msg); + luaL_error(L, to_luastring("stack overflow (%s)"), msg); else luaL_error(L, to_luastring('stack overflow', true)); } }; -const luaL_newlibtable = function (L) { +const luaL_newlibtable = function(L) { lua_createtable(L); }; -export const luaL_newlib = function (L, l) { +const luaL_newlib = function(L, l) { lua_createtable(L); luaL_setfuncs(L, l, 0); }; /* predefined references */ -const LUA_NOREF = -2; +const LUA_NOREF = -2; const LUA_REFNIL = -1; -const luaL_ref = function (L, t) { +const luaL_ref = function(L, t) { let ref; if (lua_isnil(L, -1)) { lua_pop(L, 1); /* remove from stack */ @@ -753,7 +675,7 @@ const luaL_ref = function (L, t) { }; -const luaL_unref = function (L, t, ref) { +const luaL_unref = function(L, t, ref) { if (ref >= 0) { t = lua_absindex(L, t); lua_rawgeti(L, t, 0); @@ -764,10 +686,10 @@ const luaL_unref = function (L, t, ref) { }; -const errfile = function (L, what, fnameindex, error) { +const errfile = function(L, what, fnameindex, error) { let serr = error.message; let filename = lua_tostring(L, fnameindex).subarray(1); - lua_pushfstring(L, to_luastring('cannot %s %s: %s'), to_luastring(what), filename, to_luastring(serr)); + lua_pushfstring(L, to_luastring("cannot %s %s: %s"), to_luastring(what), filename, to_luastring(serr)); lua_remove(L, fnameindex); return LUA_ERRFILE; }; @@ -775,7 +697,7 @@ const errfile = function (L, what, fnameindex, error) { let getc; const utf8_bom = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ -const skipBOM = function (lf) { +const skipBOM = function(lf) { lf.n = 0; let c; let p = 0; @@ -796,7 +718,7 @@ const skipBOM = function (lf) { ** first "valid" character of the file (after the optional BOM and ** a first-line comment). */ -const skipcomment = function (lf) { +const skipcomment = function(lf) { let c = skipBOM(lf); if (c === 35 /* '#'.charCodeAt(0) */) { /* first line is a comment (Unix exec. file)? */ do { /* skip first line */ @@ -815,9 +737,9 @@ const skipcomment = function (lf) { } }; -export let luaL_loadfilex; +let luaL_loadfilex; -if (typeof process === 'undefined') { +if (typeof process === "undefined") { class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -828,7 +750,7 @@ if (typeof process === 'undefined') { } } - const getF = function (L, ud) { + const getF = function(L, ud) { let lf = ud; if (lf.f !== null && lf.n > 0) { /* are there pre-read characters to be read? */ @@ -843,37 +765,37 @@ if (typeof process === 'undefined') { return f; }; - getc = function (lf) { + getc = function(lf) { return lf.pos < lf.f.length ? lf.f[lf.pos++] : null; }; - luaL_loadfilex = function (L, filename, mode) { + luaL_loadfilex = function(L, filename, mode) { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - throw new Error('Can\'t read stdin in the browser'); + throw new Error("Can't read stdin in the browser"); } else { - lua_pushfstring(L, to_luastring('@%s'), filename); + lua_pushfstring(L, to_luastring("@%s"), filename); let path = to_uristring(filename); let xhr = new XMLHttpRequest(); - xhr.open('GET', path, false); + xhr.open("GET", path, false); /* Synchronous xhr in main thread always returns a js string. Some browsers make console noise if you even attempt to set responseType */ - if (typeof window === 'undefined') { - xhr.responseType = 'arraybuffer'; + if (typeof window === "undefined") { + xhr.responseType = "arraybuffer"; } xhr.send(); if (xhr.status >= 200 && xhr.status <= 299) { - if (typeof xhr.response === 'string') { + if (typeof xhr.response === "string") { lf.f = to_luastring(xhr.response); } else { lf.f = new Uint8Array(xhr.response); } } else { lf.err = xhr.status; - return errfile(L, 'open', fnameindex, { message: `${xhr.status}: ${xhr.statusText}` }); + return errfile(L, "open", fnameindex, { message: `${xhr.status}: ${xhr.statusText}` }); } } let com = skipcomment(lf); @@ -889,12 +811,14 @@ if (typeof process === 'undefined') { let readstatus = lf.err; if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, 'read', fnameindex, readstatus); + return errfile(L, "read", fnameindex, readstatus); } lua_remove(L, fnameindex); return status; }; } else { + const fs = require('fs'); + class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -905,7 +829,7 @@ if (typeof process === 'undefined') { } } - const getF = function (L, ud) { + const getF = function(L, ud) { let lf = ud; let bytes = 0; if (lf.n > 0) { /* are there pre-read characters to be read? */ @@ -914,7 +838,7 @@ if (typeof process === 'undefined') { } else { /* read a block from file */ try { bytes = fs.readSync(lf.f, lf.buff, 0, lf.buff.length, lf.pos); /* read block */ - } catch (e) { + } catch(e) { lf.err = e; bytes = 0; } @@ -925,12 +849,12 @@ if (typeof process === 'undefined') { else return null; }; - getc = function (lf) { + getc = function(lf) { let b = Buffer.alloc(1); let bytes; try { bytes = fs.readSync(lf.f, b, 0, 1, lf.pos); - } catch (e) { + } catch(e) { lf.err = e; return null; } @@ -938,18 +862,18 @@ if (typeof process === 'undefined') { return bytes > 0 ? b.readUInt8() : null; }; - luaL_loadfilex = function (L, filename, mode) { + luaL_loadfilex = function(L, filename, mode) { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - lua_pushliteral(L, '=stdin'); + lua_pushliteral(L, "=stdin"); lf.f = process.stdin.fd; } else { - lua_pushfstring(L, to_luastring('@%s'), filename); + lua_pushfstring(L, to_luastring("@%s"), filename); try { - lf.f = fs.openSync(filename, 'r'); + lf.f = fs.openSync(filename, "r"); } catch (e) { - return errfile(L, 'open', fnameindex, e); + return errfile(L, "open", fnameindex, e); } } let com = skipcomment(lf); @@ -963,28 +887,28 @@ if (typeof process === 'undefined') { lf.buff[lf.n++] = com.c; /* 'c' is the first character of the stream */ let status = lua_load(L, getF, lf, lua_tostring(L, -1), mode); let readstatus = lf.err; - if (filename) try { fs.closeSync(lf.f); } catch (e) { } /* close file (even in case of errors) */ + if (filename) try { fs.closeSync(lf.f); } catch (e) {} /* close file (even in case of errors) */ if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, 'read', fnameindex, readstatus); + return errfile(L, "read", fnameindex, readstatus); } lua_remove(L, fnameindex); return status; }; } -export const luaL_loadfile = function (L, filename) { +const luaL_loadfile = function(L, filename) { return luaL_loadfilex(L, filename, null); }; -const luaL_dofile = function (L, filename) { +const luaL_dofile = function(L, filename) { return (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0)); }; -export const lua_writestringerror = function () { - for (let i = 0; i < arguments.length; i++) { +const lua_writestringerror = function() { + for (let i=0; i 1) lua_writestring(to_luastring('\t')); + return luaL_error(L, to_luastring("'tostring' must return a string to 'print'")); + if (i > 1) lua_writestring(to_luastring("\t")); lua_writestring(s); lua_pop(L, 1); } @@ -131,49 +64,49 @@ const luaB_print = function (L) { return 0; }; -const luaB_tostring = function (L) { +const luaB_tostring = function(L) { luaL_checkany(L, 1); luaL_tolstring(L, 1); return 1; }; -const luaB_getmetatable = function (L) { +const luaB_getmetatable = function(L) { luaL_checkany(L, 1); if (!lua_getmetatable(L, 1)) { lua_pushnil(L); return 1; /* no metatable */ } - luaL_getmetafield(L, 1, to_luastring('__metatable', true)); + luaL_getmetafield(L, 1, to_luastring("__metatable", true)); return 1; /* returns either __metatable field (if present) or metatable */ }; -const luaB_setmetatable = function (L) { +const luaB_setmetatable = function(L) { let t = lua_type(L, 2); luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, 'nil or table expected'); - if (luaL_getmetafield(L, 1, to_luastring('__metatable', true)) !== LUA_TNIL) - return luaL_error(L, to_luastring('cannot change a protected metatable')); + luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, "nil or table expected"); + if (luaL_getmetafield(L, 1, to_luastring("__metatable", true)) !== LUA_TNIL) + return luaL_error(L, to_luastring("cannot change a protected metatable")); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; }; -const luaB_rawequal = function (L) { +const luaB_rawequal = function(L) { luaL_checkany(L, 1); luaL_checkany(L, 2); lua_pushboolean(L, lua_rawequal(L, 1, 2)); return 1; }; -const luaB_rawlen = function (L) { +const luaB_rawlen = function(L) { let t = lua_type(L, 1); - luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, 'table or string expected'); + luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, "table or string expected"); lua_pushinteger(L, lua_rawlen(L, 1)); return 1; }; -const luaB_rawget = function (L) { +const luaB_rawget = function(L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_checkany(L, 2); lua_settop(L, 2); @@ -181,7 +114,7 @@ const luaB_rawget = function (L) { return 1; }; -const luaB_rawset = function (L) { +const luaB_rawset = function(L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_checkany(L, 2); luaL_checkany(L, 3); @@ -191,24 +124,24 @@ const luaB_rawset = function (L) { }; const opts = [ - 'stop', 'restart', 'collect', - 'count', 'step', 'setpause', 'setstepmul', - 'isrunning' + "stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", + "isrunning" ].map((e) => to_luastring(e)); -const luaB_collectgarbage = function (L) { - luaL_checkoption(L, 1, 'collect', opts); +const luaB_collectgarbage = function(L) { + luaL_checkoption(L, 1, "collect", opts); luaL_optinteger(L, 2, 0); - luaL_error(L, to_luastring('lua_gc not implemented')); + luaL_error(L, to_luastring("lua_gc not implemented")); }; -const luaB_type = function (L) { +const luaB_type = function(L) { let t = lua_type(L, 1); - luaL_argcheck(L, t !== LUA_TNONE, 1, 'value expected'); + luaL_argcheck(L, t !== LUA_TNONE, 1, "value expected"); lua_pushstring(L, lua_typename(L, t)); return 1; }; -const pairsmeta = function (L, method, iszero, iter) { +const pairsmeta = function(L, method, iszero, iter) { luaL_checkany(L, 1); if (luaL_getmetafield(L, 1, method) === LUA_TNIL) { /* no metamethod? */ lua_pushcfunction(L, iter); /* will return generator, */ @@ -222,7 +155,7 @@ const pairsmeta = function (L, method, iszero, iter) { return 3; }; -const luaB_next = function (L) { +const luaB_next = function(L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 2); /* create a 2nd argument if there isn't one */ if (lua_next(L, 1)) @@ -233,14 +166,14 @@ const luaB_next = function (L) { } }; -const luaB_pairs = function (L) { - return pairsmeta(L, to_luastring('__pairs', true), 0, luaB_next); +const luaB_pairs = function(L) { + return pairsmeta(L, to_luastring("__pairs", true), 0, luaB_next); }; /* ** Traversal function for 'ipairs' */ -const ipairsaux = function (L) { +const ipairsaux = function(L) { let i = luaL_checkinteger(L, 2) + 1; lua_pushinteger(L, i); return lua_geti(L, 1, i) === LUA_TNIL ? 1 : 2; @@ -250,7 +183,7 @@ const ipairsaux = function (L) { ** 'ipairs' function. Returns 'ipairsaux', given "table", 0. ** (The given "table" may not be a table.) */ -const luaB_ipairs = function (L) { +const luaB_ipairs = function(L) { // Lua 5.2 // return pairsmeta(L, "__ipairs", 1, ipairsaux); @@ -261,7 +194,7 @@ const luaB_ipairs = function (L) { return 3; }; -const b_str2int = function (s, base) { +const b_str2int = function(s, base) { try { s = to_jsstring(s); } catch (e) { @@ -269,12 +202,12 @@ const b_str2int = function (s, base) { } let r = /^[\t\v\f \n\r]*([+-]?)0*([0-9A-Za-z]+)[\t\v\f \n\r]*$/.exec(s); if (!r) return null; - let v = parseInt(r[1] + r[2], base); + let v = parseInt(r[1]+r[2], base); if (isNaN(v)) return null; - return v | 0; + return v|0; }; -const luaB_tonumber = function (L) { +const luaB_tonumber = function(L) { if (lua_type(L, 2) <= 0) { /* standard conversion? */ luaL_checkany(L, 1); if (lua_type(L, 1) === LUA_TNUMBER) { /* already a number? */ @@ -282,14 +215,14 @@ const luaB_tonumber = function (L) { return 1; } else { let s = lua_tostring(L, 1); - if (s !== null && lua_stringtonumber(L, s) === s.length + 1) + if (s !== null && lua_stringtonumber(L, s) === s.length+1) return 1; /* successful conversion to number */ } } else { let base = luaL_checkinteger(L, 2); luaL_checktype(L, 1, LUA_TSTRING); /* no numbers as strings */ let s = lua_tostring(L, 1); - luaL_argcheck(L, 2 <= base && base <= 36, 2, 'base out of range'); + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); let n = b_str2int(s, base); if (n !== null) { lua_pushinteger(L, n); @@ -301,7 +234,7 @@ const luaB_tonumber = function (L) { return 1; }; -const luaB_error = function (L) { +const luaB_error = function(L) { let level = luaL_optinteger(L, 2, 1); lua_settop(L, 1); if (lua_type(L, 1) === LUA_TSTRING && level > 0) { @@ -312,19 +245,19 @@ const luaB_error = function (L) { return lua_error(L); }; -const luaB_assert = function (L) { +const luaB_assert = function(L) { if (lua_toboolean(L, 1)) /* condition is true? */ return lua_gettop(L); /* return all arguments */ else { luaL_checkany(L, 1); /* there must be a condition */ lua_remove(L, 1); /* remove it */ - lua_pushliteral(L, 'assertion failed!'); /* default message */ + lua_pushliteral(L, "assertion failed!"); /* default message */ lua_settop(L, 1); /* leave only message (default if no other one) */ return luaB_error(L); /* call 'error' */ } }; -const luaB_select = function (L) { +const luaB_select = function(L) { let n = lua_gettop(L); if (lua_type(L, 1) === LUA_TSTRING && lua_tostring(L, 1)[0] === 35 /* '#'.charCodeAt(0) */) { lua_pushinteger(L, n - 1); @@ -333,7 +266,7 @@ const luaB_select = function (L) { let i = luaL_checkinteger(L, 1); if (i < 0) i = n + i; else if (i > n) i = n; - luaL_argcheck(L, 1 <= i, 1, 'index out of range'); + luaL_argcheck(L, 1 <= i, 1, "index out of range"); return n - i; } }; @@ -345,7 +278,7 @@ const luaB_select = function (L) { ** 'extra' values (where 'extra' is exactly the number of items to be ** ignored). */ -const finishpcall = function (L, status, extra) { +const finishpcall = function(L, status, extra) { if (status !== LUA_OK && status !== LUA_YIELD) { /* error? */ lua_pushboolean(L, 0); /* first result (false) */ lua_pushvalue(L, -2); /* error message */ @@ -354,7 +287,7 @@ const finishpcall = function (L, status, extra) { return lua_gettop(L) - extra; }; -const luaB_pcall = function (L) { +const luaB_pcall = function(L) { luaL_checkany(L, 1); lua_pushboolean(L, 1); /* first result if no errors */ lua_insert(L, 1); /* put it in place */ @@ -367,7 +300,7 @@ const luaB_pcall = function (L) { ** stack will have ; so, the function passes ** 2 to 'finishpcall' to skip the 2 first values when returning results. */ -const luaB_xpcall = function (L) { +const luaB_xpcall = function(L) { let n = lua_gettop(L); luaL_checktype(L, 2, LUA_TFUNCTION); /* check error function */ lua_pushboolean(L, 1); /* first result */ @@ -377,7 +310,7 @@ const luaB_xpcall = function (L) { return finishpcall(L, status, 2); }; -const load_aux = function (L, status, envidx) { +const load_aux = function(L, status, envidx) { if (status === LUA_OK) { if (envidx !== 0) { /* 'env' parameter? */ lua_pushvalue(L, envidx); /* environment for loaded function */ @@ -405,29 +338,29 @@ const RESERVEDSLOT = 5; ** stack top. Instead, it keeps its resulting string in a ** reserved slot inside the stack. */ -const generic_reader = function (L, ud) { - luaL_checkstack(L, 2, 'too many nested functions'); +const generic_reader = function(L, ud) { + luaL_checkstack(L, 2, "too many nested functions"); lua_pushvalue(L, 1); /* get function */ lua_call(L, 0, 1); /* call it */ if (lua_isnil(L, -1)) { lua_pop(L, 1); /* pop result */ return null; } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('reader function must return a string')); + luaL_error(L, to_luastring("reader function must return a string")); lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ return lua_tostring(L, RESERVEDSLOT); }; -const luaB_load = function (L) { +const luaB_load = function(L) { let s = lua_tostring(L, 1); - let mode = luaL_optstring(L, 3, 'bt'); + let mode = luaL_optstring(L, 3, "bt"); let env = !lua_isnone(L, 4) ? 4 : 0; /* 'env' index or 0 if no 'env' */ let status; if (s !== null) { /* loading a string? */ let chunkname = luaL_optstring(L, 2, s); status = luaL_loadbufferx(L, s, s.length, chunkname, mode); } else { /* loading from a reader function */ - let chunkname = luaL_optstring(L, 2, '=(load)'); + let chunkname = luaL_optstring(L, 2, "=(load)"); luaL_checktype(L, 1, LUA_TFUNCTION); lua_settop(L, RESERVEDSLOT); /* create reserved slot */ status = lua_load(L, generic_reader, null, chunkname, mode); @@ -435,7 +368,7 @@ const luaB_load = function (L) { return load_aux(L, status, env); }; -const luaB_loadfile = function (L) { +const luaB_loadfile = function(L) { let fname = luaL_optstring(L, 1, null); let mode = luaL_optstring(L, 2, null); let env = !lua_isnone(L, 3) ? 3 : 0; /* 'env' index or 0 if no 'env' */ @@ -443,11 +376,11 @@ const luaB_loadfile = function (L) { return load_aux(L, status, env); }; -const dofilecont = function (L, d1, d2) { +const dofilecont = function(L, d1, d2) { return lua_gettop(L) - 1; }; -const luaB_dofile = function (L) { +const luaB_dofile = function(L) { let fname = luaL_optstring(L, 1, null); lua_settop(L, 1); if (luaL_loadfile(L, fname) !== LUA_OK) @@ -457,39 +390,42 @@ const luaB_dofile = function (L) { }; const base_funcs = { - 'assert': luaB_assert, - 'collectgarbage': luaB_collectgarbage, - 'dofile': luaB_dofile, - 'error': luaB_error, - 'getmetatable': luaB_getmetatable, - 'ipairs': luaB_ipairs, - 'load': luaB_load, - 'loadfile': luaB_loadfile, - 'next': luaB_next, - 'pairs': luaB_pairs, - 'pcall': luaB_pcall, - 'print': luaB_print, - 'rawequal': luaB_rawequal, - 'rawget': luaB_rawget, - 'rawlen': luaB_rawlen, - 'rawset': luaB_rawset, - 'select': luaB_select, - 'setmetatable': luaB_setmetatable, - 'tonumber': luaB_tonumber, - 'tostring': luaB_tostring, - 'type': luaB_type, - 'xpcall': luaB_xpcall + "assert": luaB_assert, + "collectgarbage": luaB_collectgarbage, + "dofile": luaB_dofile, + "error": luaB_error, + "getmetatable": luaB_getmetatable, + "ipairs": luaB_ipairs, + "load": luaB_load, + "loadfile": luaB_loadfile, + "next": luaB_next, + "pairs": luaB_pairs, + "pcall": luaB_pcall, + "print": luaB_print, + "rawequal": luaB_rawequal, + "rawget": luaB_rawget, + "rawlen": luaB_rawlen, + "rawset": luaB_rawset, + "select": luaB_select, + "setmetatable": luaB_setmetatable, + "tonumber": luaB_tonumber, + "tostring": luaB_tostring, + "type": luaB_type, + "xpcall": luaB_xpcall }; -const luaopen_base = function (L) { +const luaopen_base = function(L) { /* open lib into global table */ lua_pushglobaltable(L); luaL_setfuncs(L, base_funcs, 0); /* set global _G */ lua_pushvalue(L, -1); - lua_setfield(L, -2, to_luastring('_G')); + lua_setfield(L, -2, to_luastring("_G")); /* set global _VERSION */ lua_pushliteral(L, LUA_VERSION); - lua_setfield(L, -2, to_luastring('_VERSION')); + lua_setfield(L, -2, to_luastring("_VERSION")); return 1; }; + +const _luaopen_base = luaopen_base; +export { _luaopen_base as luaopen_base }; diff --git a/src/lcode.js b/src/lcode.js index da177df8..c9802728 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -1,63 +1,18 @@ -import * as defs from './defs.js'; -import { - LUA_MULTRET, - LUA_OPADD, - LUA_OPBAND, - LUA_OPBNOT, - LUA_OPBOR, - LUA_OPBXOR, - LUA_OPDIV, - LUA_OPIDIV, - LUA_OPMOD, - LUA_OPSHL, - LUA_OPSHR, - LUA_OPUNM, - to_luastring, - LUA_TBOOLEAN, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TTABLE -} from './defs.js'; -import { lua_assert } from './llimits.js'; +"use strict"; + +import { LUA_MULTRET, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPIDIV, LUA_OPMOD, LUA_OPSHL, LUA_OPSHR, LUA_OPUNM, constant_types, to_luastring } from './defs.js'; +import { lua_assert } from "./llimits.js"; import { luaX_syntaxerror } from './llex.js'; -import { TValue, luaO_arith } from './lobject.js'; -import { - OpCodesI, - SETARG_A, - SETARG_B, - MAXARG_sBx, - SETARG_sBx, - testTMode, - NO_REG, - CREATE_ABC, - getOpMode, - iABC, - getBMode, - OpArgN, - getCMode, - MAXARG_A, - MAXARG_B, - MAXARG_C, - iABx, - iAsBx, - MAXARG_Bx, - CREATE_ABx, - MAXARG_Ax, - CREATE_Ax, - ISK, - SETARG_C, - MAXINDEXRK, - RKASK, - LFIELDS_PER_FLUSH -} from './lopcodes.js'; +import { TValue as _TValue, luaO_arith } from './lobject.js'; +import { OpCodesI as _OpCodesI, SETARG_A, SETARG_B, MAXARG_sBx, SETARG_sBx, testTMode, NO_REG, CREATE_ABC, getOpMode, iABC, getBMode, OpArgN, getCMode, MAXARG_A, MAXARG_B, MAXARG_C, iABx, iAsBx, MAXARG_Bx, CREATE_ABx, MAXARG_Ax, CREATE_Ax, ISK, SETARG_C, MAXINDEXRK, RKASK, LFIELDS_PER_FLUSH } from './lopcodes.js'; import { expkind, vkisinreg, expdesc } from './lparser.js'; import { luaH_get, luaH_setfrom } from './ltable.js'; import { tointeger } from './lvm.js'; -const constant_types = { +const OpCodesI = _OpCodesI; +const TValue = _TValue; + +const { LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TLNGSTR, @@ -65,7 +20,7 @@ const constant_types = { LUA_TNUMFLT, LUA_TNUMINT, LUA_TTABLE -} +} = constant_types; /* Maximum number of registers in a Lua function (must fit in 8 bits) */ const MAXREGS = 255; @@ -188,7 +143,7 @@ const fixjump = function (fs, pc, dest) { let offset = dest - (pc + 1); lua_assert(dest !== NO_JUMP); if (Math.abs(offset) > MAXARG_sBx) - luaX_syntaxerror(fs.ls, to_luastring('control structure too long', true)); + luaX_syntaxerror(fs.ls, to_luastring("control structure too long", true)); SETARG_sBx(jmp, offset); }; @@ -433,7 +388,7 @@ const luaK_checkstack = function (fs, n) { let newstack = fs.freereg + n; if (newstack > fs.f.maxstacksize) { if (newstack >= MAXREGS) - luaX_syntaxerror(fs.ls, to_luastring('function or expression needs too many registers', true)); + luaX_syntaxerror(fs.ls, to_luastring("function or expression needs too many registers", true)); fs.f.maxstacksize = newstack; } }; @@ -1242,6 +1197,92 @@ const luaK_setlist = function (fs, base, nelems, tostore) { codeextraarg(fs, c); } else - luaX_syntaxerror(fs.ls, to_luastring('constructor too long', true)); + luaX_syntaxerror(fs.ls, to_luastring("constructor too long", true)); fs.freereg = base + 1; /* free registers with list values */ }; + + +const _BinOpr = BinOpr; +export { _BinOpr as BinOpr }; +const _NO_JUMP = NO_JUMP; +export { _NO_JUMP as NO_JUMP }; +const _UnOpr = UnOpr; +export { _UnOpr as UnOpr }; +const _getinstruction = getinstruction; +export { _getinstruction as getinstruction }; +const _luaK_checkstack = luaK_checkstack; +export { _luaK_checkstack as luaK_checkstack }; +const _luaK_code = luaK_code; +export { _luaK_code as luaK_code }; +const _luaK_codeABC = luaK_codeABC; +export { _luaK_codeABC as luaK_codeABC }; +const _luaK_codeABx = luaK_codeABx; +export { _luaK_codeABx as luaK_codeABx }; +const _luaK_codeAsBx = luaK_codeAsBx; +export { _luaK_codeAsBx as luaK_codeAsBx }; +const _luaK_codek = luaK_codek; +export { _luaK_codek as luaK_codek }; +const _luaK_concat = luaK_concat; +export { _luaK_concat as luaK_concat }; +const _luaK_dischargevars = luaK_dischargevars; +export { _luaK_dischargevars as luaK_dischargevars }; +const _luaK_exp2RK = luaK_exp2RK; +export { _luaK_exp2RK as luaK_exp2RK }; +const _luaK_exp2anyreg = luaK_exp2anyreg; +export { _luaK_exp2anyreg as luaK_exp2anyreg }; +const _luaK_exp2anyregup = luaK_exp2anyregup; +export { _luaK_exp2anyregup as luaK_exp2anyregup }; +const _luaK_exp2nextreg = luaK_exp2nextreg; +export { _luaK_exp2nextreg as luaK_exp2nextreg }; +const _luaK_exp2val = luaK_exp2val; +export { _luaK_exp2val as luaK_exp2val }; +const _luaK_fixline = luaK_fixline; +export { _luaK_fixline as luaK_fixline }; +const _luaK_getlabel = luaK_getlabel; +export { _luaK_getlabel as luaK_getlabel }; +const _luaK_goiffalse = luaK_goiffalse; +export { _luaK_goiffalse as luaK_goiffalse }; +const _luaK_goiftrue = luaK_goiftrue; +export { _luaK_goiftrue as luaK_goiftrue }; +const _luaK_indexed = luaK_indexed; +export { _luaK_indexed as luaK_indexed }; +const _luaK_infix = luaK_infix; +export { _luaK_infix as luaK_infix }; +const _luaK_intK = luaK_intK; +export { _luaK_intK as luaK_intK }; +const _luaK_jump = luaK_jump; +export { _luaK_jump as luaK_jump }; +const _luaK_jumpto = luaK_jumpto; +export { _luaK_jumpto as luaK_jumpto }; +const _luaK_nil = luaK_nil; +export { _luaK_nil as luaK_nil }; +const _luaK_numberK = luaK_numberK; +export { _luaK_numberK as luaK_numberK }; +const _luaK_patchclose = luaK_patchclose; +export { _luaK_patchclose as luaK_patchclose }; +const _luaK_patchlist = luaK_patchlist; +export { _luaK_patchlist as luaK_patchlist }; +const _luaK_patchtohere = luaK_patchtohere; +export { _luaK_patchtohere as luaK_patchtohere }; +const _luaK_posfix = luaK_posfix; +export { _luaK_posfix as luaK_posfix }; +const _luaK_prefix = luaK_prefix; +export { _luaK_prefix as luaK_prefix }; +const _luaK_reserveregs = luaK_reserveregs; +export { _luaK_reserveregs as luaK_reserveregs }; +const _luaK_ret = luaK_ret; +export { _luaK_ret as luaK_ret }; +const _luaK_self = luaK_self; +export { _luaK_self as luaK_self }; +const _luaK_setlist = luaK_setlist; +export { _luaK_setlist as luaK_setlist }; +const _luaK_setmultret = luaK_setmultret; +export { _luaK_setmultret as luaK_setmultret }; +const _luaK_setoneret = luaK_setoneret; +export { _luaK_setoneret as luaK_setoneret }; +const _luaK_setreturns = luaK_setreturns; +export { _luaK_setreturns as luaK_setreturns }; +const _luaK_storevar = luaK_storevar; +export { _luaK_storevar as luaK_storevar }; +const _luaK_stringK = luaK_stringK; +export { _luaK_stringK as luaK_stringK }; diff --git a/src/lcorolib.js b/src/lcorolib.js index 8139dd9c..a44dc071 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -1,47 +1,22 @@ -import { - LUA_OK, - LUA_TFUNCTION, - LUA_TSTRING, - LUA_YIELD, - lua_Debug, - lua_checkstack, - lua_concat, - lua_error, - lua_getstack, - lua_gettop, - lua_insert, - lua_isyieldable, - lua_newthread, - lua_pop, - lua_pushboolean, - lua_pushcclosure, - lua_pushliteral, - lua_pushthread, - lua_pushvalue, - lua_resume, - lua_status, - lua_tothread, - lua_type, - lua_upvalueindex, - lua_xmove, - lua_yield -} from './lua.js'; +"use strict"; + +import { LUA_OK, LUA_TFUNCTION, LUA_TSTRING, LUA_YIELD, lua_Debug, lua_checkstack, lua_concat, lua_error, lua_getstack, lua_gettop, lua_insert, lua_isyieldable, lua_newthread, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushliteral, lua_pushthread, lua_pushvalue, lua_resume, lua_status, lua_tothread, lua_type, lua_upvalueindex, lua_xmove, lua_yield } from './lua.js'; import { luaL_argcheck, luaL_checktype, luaL_newlib, luaL_where } from './lauxlib.js'; -const getco = function (L) { +const getco = function(L) { let co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, 'thread expected'); + luaL_argcheck(L, co, 1, "thread expected"); return co; }; -const auxresume = function (L, co, narg) { +const auxresume = function(L, co, narg) { if (!lua_checkstack(co, narg)) { - lua_pushliteral(L, 'too many arguments to resume'); + lua_pushliteral(L, "too many arguments to resume"); return -1; /* error flag */ } if (lua_status(co) === LUA_OK && lua_gettop(co) === 0) { - lua_pushliteral(L, 'cannot resume dead coroutine'); + lua_pushliteral(L, "cannot resume dead coroutine"); return -1; /* error flag */ } @@ -51,11 +26,11 @@ const auxresume = function (L, co, narg) { let nres = lua_gettop(co); if (!lua_checkstack(L, nres + 1)) { lua_pop(co, nres); /* remove results anyway */ - lua_pushliteral(L, 'too many results to resume'); + lua_pushliteral(L, "too many results to resume"); return -1; /* error flag */ } - lua_xmove(co, L, nres); /* move yielded values */ + lua_xmove(co, L, nres); /* move yielded values */ return nres; } else { lua_xmove(co, L, 1); /* move error message */ @@ -63,7 +38,7 @@ const auxresume = function (L, co, narg) { } }; -const luaB_coresume = function (L) { +const luaB_coresume = function(L) { let co = getco(L); let r = auxresume(L, co, lua_gettop(L) - 1); if (r < 0) { @@ -77,7 +52,7 @@ const luaB_coresume = function (L) { } }; -const luaB_auxwrap = function (L) { +const luaB_auxwrap = function(L) { let co = lua_tothread(L, lua_upvalueindex(1)); let r = auxresume(L, co, lua_gettop(L)); if (r < 0) { @@ -93,7 +68,7 @@ const luaB_auxwrap = function (L) { return r; }; -const luaB_cocreate = function (L) { +const luaB_cocreate = function(L) { luaL_checktype(L, 1, LUA_TFUNCTION); let NL = lua_newthread(L); lua_pushvalue(L, 1); /* move function to top */ @@ -101,36 +76,36 @@ const luaB_cocreate = function (L) { return 1; }; -const luaB_cowrap = function (L) { +const luaB_cowrap = function(L) { luaB_cocreate(L); lua_pushcclosure(L, luaB_auxwrap, 1); return 1; }; -const luaB_yield = function (L) { +const luaB_yield = function(L) { return lua_yield(L, lua_gettop(L)); }; -const luaB_costatus = function (L) { +const luaB_costatus = function(L) { let co = getco(L); - if (L === co) lua_pushliteral(L, 'running'); + if (L === co) lua_pushliteral(L, "running"); else { switch (lua_status(co)) { case LUA_YIELD: - lua_pushliteral(L, 'suspended'); + lua_pushliteral(L, "suspended"); break; case LUA_OK: { let ar = new lua_Debug(); if (lua_getstack(co, 0, ar) > 0) /* does it have frames? */ - lua_pushliteral(L, 'normal'); /* it is running */ + lua_pushliteral(L, "normal"); /* it is running */ else if (lua_gettop(co) === 0) - lua_pushliteral(L, 'dead'); + lua_pushliteral(L, "dead"); else - lua_pushliteral(L, 'suspended'); /* initial state */ + lua_pushliteral(L, "suspended"); /* initial state */ break; } default: /* some error occurred */ - lua_pushliteral(L, 'dead'); + lua_pushliteral(L, "dead"); break; } } @@ -138,27 +113,30 @@ const luaB_costatus = function (L) { return 1; }; -const luaB_yieldable = function (L) { +const luaB_yieldable = function(L) { lua_pushboolean(L, lua_isyieldable(L)); return 1; }; -const luaB_corunning = function (L) { +const luaB_corunning = function(L) { lua_pushboolean(L, lua_pushthread(L)); return 2; }; const co_funcs = { - 'create': luaB_cocreate, - 'isyieldable': luaB_yieldable, - 'resume': luaB_coresume, - 'running': luaB_corunning, - 'status': luaB_costatus, - 'wrap': luaB_cowrap, - 'yield': luaB_yield + "create": luaB_cocreate, + "isyieldable": luaB_yieldable, + "resume": luaB_coresume, + "running": luaB_corunning, + "status": luaB_costatus, + "wrap": luaB_cowrap, + "yield": luaB_yield }; -const luaopen_coroutine = function (L) { +const luaopen_coroutine = function(L) { luaL_newlib(L, co_funcs); return 1; }; + +const _luaopen_coroutine = luaopen_coroutine; +export { _luaopen_coroutine as luaopen_coroutine }; diff --git a/src/ldblib.js b/src/ldblib.js index 8d909705..1ea461e5 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -1,96 +1,24 @@ -import { - LUA_MASKCALL, - LUA_MASKCOUNT, - LUA_MASKLINE, - LUA_MASKRET, - LUA_REGISTRYINDEX, - LUA_TFUNCTION, - LUA_TNIL, - LUA_TTABLE, - LUA_TUSERDATA, - lua_Debug, - lua_call, - lua_checkstack, - lua_gethook, - lua_gethookcount, - lua_gethookmask, - lua_getinfo, - lua_getlocal, - lua_getmetatable, - lua_getstack, - lua_getupvalue, - lua_getuservalue, - lua_insert, - lua_iscfunction, - lua_isfunction, - lua_isnoneornil, - lua_isthread, - lua_newtable, - lua_pcall, - lua_pop, - lua_pushboolean, - lua_pushfstring, - lua_pushinteger, - lua_pushlightuserdata, - lua_pushliteral, - lua_pushnil, - lua_pushstring, - lua_pushvalue, - lua_rawgetp, - lua_rawsetp, - lua_rotate, - lua_setfield, - lua_sethook, - lua_setlocal, - lua_setmetatable, - lua_settop, - lua_setupvalue, - lua_setuservalue, - lua_tojsstring, - lua_toproxy, - lua_tostring, - lua_tothread, - lua_touserdata, - lua_type, - lua_upvalueid, - lua_upvaluejoin, - lua_xmove -} from './lua.js'; -import { - luaL_argcheck, - luaL_argerror, - luaL_checkany, - luaL_checkinteger, - luaL_checkstring, - luaL_checktype, - luaL_error, - luaL_loadbuffer, - luaL_newlib, - luaL_optinteger, - luaL_optstring, - luaL_traceback, - lua_writestringerror -} from './lauxlib.js'; +import { LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_REGISTRYINDEX, LUA_TFUNCTION, LUA_TNIL, LUA_TTABLE, LUA_TUSERDATA, lua_Debug, lua_call, lua_checkstack, lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getmetatable, lua_getstack, lua_getupvalue, lua_getuservalue, lua_insert, lua_iscfunction, lua_isfunction, lua_isnoneornil, lua_isthread, lua_newtable, lua_pcall, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushlightuserdata, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgetp, lua_rawsetp, lua_rotate, lua_setfield, lua_sethook, lua_setlocal, lua_setmetatable, lua_settop, lua_setupvalue, lua_setuservalue, lua_tojsstring, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_upvalueid, lua_upvaluejoin, lua_xmove } from './lua.js'; +import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checkstring, luaL_checktype, luaL_error, luaL_loadbuffer, luaL_newlib, luaL_optinteger, luaL_optstring, luaL_traceback, lua_writestringerror } from './lauxlib.js'; import { lua_assert } from './lualib.js'; -import { luastring_indexOf, to_luastring } from './fengaricore.js'; -import readlineSync from 'readline-sync'; +import { luastring_indexOf, to_luastring } from "./fengaricore.js"; /* ** If L1 != L, L1 can be in any state, and therefore there are no ** guarantees about its stack space; any push in L1 must be ** checked. */ -const checkstack = function (L, L1, n) { +const checkstack = function(L, L1, n) { if (L !== L1 && !lua_checkstack(L1, n)) - luaL_error(L, to_luastring('stack overflow', true)); + luaL_error(L, to_luastring("stack overflow", true)); }; -const db_getregistry = function (L) { +const db_getregistry = function(L) { lua_pushvalue(L, LUA_REGISTRYINDEX); return 1; }; -const db_getmetatable = function (L) { +const db_getmetatable = function(L) { luaL_checkany(L, 1); if (!lua_getmetatable(L, 1)) { lua_pushnil(L); /* no metatable */ @@ -98,15 +26,15 @@ const db_getmetatable = function (L) { return 1; }; -const db_setmetatable = function (L) { +const db_setmetatable = function(L) { const t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, 'nil or table expected'); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table expected"); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; /* return 1st argument */ }; -const db_getuservalue = function (L) { +const db_getuservalue = function(L) { if (lua_type(L, 1) !== LUA_TUSERDATA) lua_pushnil(L); else @@ -115,7 +43,7 @@ const db_getuservalue = function (L) { }; -const db_setuservalue = function (L) { +const db_setuservalue = function(L) { luaL_checktype(L, 1, LUA_TUSERDATA); luaL_checkany(L, 2); lua_settop(L, 2); @@ -129,7 +57,7 @@ const db_setuservalue = function (L) { ** 1 if this argument is present (so that functions can skip it to ** access their other arguments) */ -const getthread = function (L) { +const getthread = function(L) { if (lua_isthread(L, 1)) { return { arg: 1, @@ -148,17 +76,17 @@ const getthread = function (L) { ** from 'lua_getinfo' into result table. Key is always a string; ** value can be a string, an int, or a boolean. */ -const settabss = function (L, k, v) { +const settabss = function(L, k, v) { lua_pushstring(L, v); lua_setfield(L, -2, k); }; -const settabsi = function (L, k, v) { +const settabsi = function(L, k, v) { lua_pushinteger(L, v); lua_setfield(L, -2, k); }; -const settabsb = function (L, k, v) { +const settabsb = function(L, k, v) { lua_pushboolean(L, v); lua_setfield(L, -2, k); }; @@ -171,7 +99,7 @@ const settabsb = function (L, k, v) { ** 'lua_getinfo' on top of the result table so that it can call ** 'lua_setfield'. */ -const treatstackoption = function (L, L1, fname) { +const treatstackoption = function(L, L1, fname) { if (L == L1) lua_rotate(L, -2, 1); /* exchange object and table */ else @@ -185,15 +113,15 @@ const treatstackoption = function (L, L1, fname) { ** two optional outputs (function and line table) from function ** 'lua_getinfo'. */ -const db_getinfo = function (L) { +const db_getinfo = function(L) { let ar = new lua_Debug(); let thread = getthread(L); let arg = thread.arg; let L1 = thread.thread; - let options = luaL_optstring(L, arg + 2, 'flnStu'); + let options = luaL_optstring(L, arg + 2, "flnStu"); checkstack(L, L1, 3); if (lua_isfunction(L, arg + 1)) { /* info about a function? */ - options = lua_pushfstring(L, to_luastring('>%s'), options); /* add '>' to 'options' */ + options = lua_pushfstring(L, to_luastring(">%s"), options); /* add '>' to 'options' */ lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ lua_xmove(L, L1, 1); } else { /* stack level */ @@ -204,36 +132,36 @@ const db_getinfo = function (L) { } if (!lua_getinfo(L1, options, ar)) - luaL_argerror(L, arg + 2, 'invalid option'); + luaL_argerror(L, arg + 2, "invalid option"); lua_newtable(L); /* table to collect results */ if (luastring_indexOf(options, 83 /* 'S'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring('source', true), ar.source); - settabss(L, to_luastring('short_src', true), ar.short_src); - settabsi(L, to_luastring('linedefined', true), ar.linedefined); - settabsi(L, to_luastring('lastlinedefined', true), ar.lastlinedefined); - settabss(L, to_luastring('what', true), ar.what); + settabss(L, to_luastring("source", true), ar.source); + settabss(L, to_luastring("short_src", true), ar.short_src); + settabsi(L, to_luastring("linedefined", true), ar.linedefined); + settabsi(L, to_luastring("lastlinedefined", true), ar.lastlinedefined); + settabss(L, to_luastring("what", true), ar.what); } if (luastring_indexOf(options, 108 /* 'l'.charCodeAt(0) */) > -1) - settabsi(L, to_luastring('currentline', true), ar.currentline); + settabsi(L, to_luastring("currentline", true), ar.currentline); if (luastring_indexOf(options, 117 /* 'u'.charCodeAt(0) */) > -1) { - settabsi(L, to_luastring('nups', true), ar.nups); - settabsi(L, to_luastring('nparams', true), ar.nparams); - settabsb(L, to_luastring('isvararg', true), ar.isvararg); + settabsi(L, to_luastring("nups", true), ar.nups); + settabsi(L, to_luastring("nparams", true), ar.nparams); + settabsb(L, to_luastring("isvararg", true), ar.isvararg); } if (luastring_indexOf(options, 110 /* 'n'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring('name', true), ar.name); - settabss(L, to_luastring('namewhat', true), ar.namewhat); + settabss(L, to_luastring("name", true), ar.name); + settabss(L, to_luastring("namewhat", true), ar.namewhat); } if (luastring_indexOf(options, 116 /* 't'.charCodeAt(0) */) > -1) - settabsb(L, to_luastring('istailcall', true), ar.istailcall); + settabsb(L, to_luastring("istailcall", true), ar.istailcall); if (luastring_indexOf(options, 76 /* 'L'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring('activelines', true)); + treatstackoption(L, L1, to_luastring("activelines", true)); if (luastring_indexOf(options, 102 /* 'f'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring('func', true)); + treatstackoption(L, L1, to_luastring("func", true)); return 1; /* return table */ }; -const db_getlocal = function (L) { +const db_getlocal = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; @@ -246,7 +174,7 @@ const db_getlocal = function (L) { } else { /* stack-level argument */ let level = luaL_checkinteger(L, arg + 1); if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg + 1, 'level out of range'); + return luaL_argerror(L, arg+1, "level out of range"); checkstack(L, L1, 1); let name = lua_getlocal(L1, ar, nvar); if (name) { @@ -262,7 +190,7 @@ const db_getlocal = function (L) { } }; -const db_setlocal = function (L) { +const db_setlocal = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; @@ -270,7 +198,7 @@ const db_setlocal = function (L) { let level = luaL_checkinteger(L, arg + 1); let nvar = luaL_checkinteger(L, arg + 2); if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg + 1, 'level out of range'); + return luaL_argerror(L, arg + 1, "level out of range"); luaL_checkany(L, arg + 3); lua_settop(L, arg + 3); checkstack(L, L1, 1); @@ -285,22 +213,22 @@ const db_setlocal = function (L) { /* ** get (if 'get' is true) or set an upvalue from a closure */ -const auxupvalue = function (L, get) { +const auxupvalue = function(L, get) { let n = luaL_checkinteger(L, 2); /* upvalue index */ luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ let name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); if (name === null) return 0; lua_pushstring(L, name); - lua_insert(L, -(get + 1)); /* no-op if get is false */ + lua_insert(L, -(get+1)); /* no-op if get is false */ return get + 1; }; -const db_getupvalue = function (L) { +const db_getupvalue = function(L) { return auxupvalue(L, 1); }; -const db_setupvalue = function (L) { +const db_setupvalue = function(L) { luaL_checkany(L, 3); return auxupvalue(L, 0); }; @@ -309,24 +237,24 @@ const db_setupvalue = function (L) { ** Check whether a given upvalue from a given closure exists and ** returns its index */ -const checkupval = function (L, argf, argnup) { +const checkupval = function(L, argf, argnup) { let nup = luaL_checkinteger(L, argnup); /* upvalue index */ luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ - luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, 'invalid upvalue index'); + luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, "invalid upvalue index"); return nup; }; -const db_upvalueid = function (L) { +const db_upvalueid = function(L) { let n = checkupval(L, 1, 2); lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); return 1; }; -const db_upvaluejoin = function (L) { +const db_upvaluejoin = function(L) { let n1 = checkupval(L, 1, 2); let n2 = checkupval(L, 3, 4); - luaL_argcheck(L, !lua_iscfunction(L, 1), 1, 'Lua function expected'); - luaL_argcheck(L, !lua_iscfunction(L, 3), 3, 'Lua function expected'); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); lua_upvaluejoin(L, 1, n1, 3, n2); return 0; }; @@ -335,15 +263,15 @@ const db_upvaluejoin = function (L) { ** The hook table at registry[HOOKKEY] maps threads to their current ** hook function. (We only need the unique address of 'HOOKKEY'.) */ -const HOOKKEY = to_luastring('__hooks__', true); +const HOOKKEY = to_luastring("__hooks__", true); -const hooknames = ['call', 'return', 'line', 'count', 'tail call'].map(e => to_luastring(e)); +const hooknames = ["call", "return", "line", "count", "tail call"].map(e => to_luastring(e)); /* ** Call hook function registered at hook table for the current ** thread (if there is one) */ -const hookf = function (L, ar) { +const hookf = function(L, ar) { lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); let hooktable = lua_touserdata(L, -1); let proxy = hooktable.get(L); @@ -353,7 +281,7 @@ const hookf = function (L, ar) { if (ar.currentline >= 0) lua_pushinteger(L, ar.currentline); /* push current line */ else lua_pushnil(L); - lua_assert(lua_getinfo(L, to_luastring('lS'), ar)); + lua_assert(lua_getinfo(L, to_luastring("lS"), ar)); lua_call(L, 2, 0); /* call hook function */ } }; @@ -361,7 +289,7 @@ const hookf = function (L, ar) { /* ** Convert a string mask (for 'sethook') into a bit mask */ -const makemask = function (smask, count) { +const makemask = function(smask, count) { let mask = 0; if (luastring_indexOf(smask, 99 /* 'c'.charCodeAt(0) */) > -1) mask |= LUA_MASKCALL; if (luastring_indexOf(smask, 114 /* 'r'.charCodeAt(0) */) > -1) mask |= LUA_MASKRET; @@ -373,7 +301,7 @@ const makemask = function (smask, count) { /* ** Convert a bit mask (for 'gethook') into a string mask */ -const unmakemask = function (mask, smask) { +const unmakemask = function(mask, smask) { let i = 0; if (mask & LUA_MASKCALL) smask[i++] = 99 /* 'c'.charCodeAt(0) */; if (mask & LUA_MASKRET) smask[i++] = 114 /* 'r'.charCodeAt(0) */; @@ -381,18 +309,18 @@ const unmakemask = function (mask, smask) { return smask.subarray(0, i); }; -const db_sethook = function (L) { +const db_sethook = function(L) { let mask, count, func; let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; - if (lua_isnoneornil(L, arg + 1)) { /* no hook? */ - lua_settop(L, arg + 1); + if (lua_isnoneornil(L, arg+1)) { /* no hook? */ + lua_settop(L, arg+1); func = null; mask = 0; count = 0; /* turn off hooks */ } else { const smask = luaL_checkstring(L, arg + 2); - luaL_checktype(L, arg + 1, LUA_TFUNCTION); + luaL_checktype(L, arg+1, LUA_TFUNCTION); count = luaL_optinteger(L, arg + 3, 0); func = hookf; mask = makemask(smask, count); } @@ -411,7 +339,7 @@ const db_sethook = function (L) { return 0; }; -const db_gethook = function (L) { +const db_gethook = function(L) { let thread = getthread(L); let L1 = thread.thread; let buff = new Uint8Array(5); @@ -420,7 +348,7 @@ const db_gethook = function (L) { if (hook === null) /* no hook? */ lua_pushnil(L); else if (hook !== hookf) /* external hook? */ - lua_pushliteral(L, 'external hook'); + lua_pushliteral(L, "external hook"); else { /* hook table must exist */ lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); let hooktable = lua_touserdata(L, -1); @@ -432,7 +360,7 @@ const db_gethook = function (L) { return 3; }; -const db_traceback = function (L) { +const db_traceback = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; @@ -447,62 +375,66 @@ const db_traceback = function (L) { }; const dblib = { - 'gethook': db_gethook, - 'getinfo': db_getinfo, - 'getlocal': db_getlocal, - 'getmetatable': db_getmetatable, - 'getregistry': db_getregistry, - 'getupvalue': db_getupvalue, - 'getuservalue': db_getuservalue, - 'sethook': db_sethook, - 'setlocal': db_setlocal, - 'setmetatable': db_setmetatable, - 'setupvalue': db_setupvalue, - 'setuservalue': db_setuservalue, - 'traceback': db_traceback, - 'upvalueid': db_upvalueid, - 'upvaluejoin': db_upvaluejoin + "gethook": db_gethook, + "getinfo": db_getinfo, + "getlocal": db_getlocal, + "getmetatable": db_getmetatable, + "getregistry": db_getregistry, + "getupvalue": db_getupvalue, + "getuservalue": db_getuservalue, + "sethook": db_sethook, + "setlocal": db_setlocal, + "setmetatable": db_setmetatable, + "setupvalue": db_setupvalue, + "setuservalue": db_setuservalue, + "traceback": db_traceback, + "upvalueid": db_upvalueid, + "upvaluejoin": db_upvaluejoin }; let getinput; -if (typeof process !== 'undefined') { // Only with Node +if (typeof process !== "undefined") { // Only with Node + const readlineSync = require('readline-sync'); readlineSync.setDefaultOptions({ prompt: 'lua_debug> ' }); - getinput = function () { + getinput = function() { return readlineSync.prompt(); }; -} else if (typeof window !== 'undefined') { +} else if (typeof window !== "undefined") { /* if in browser use window.prompt. Doesn't work from web workers. See https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt */ - getinput = function () { - let input = prompt('lua_debug>', ''); - return (input !== null) ? input : ''; + getinput = function() { + let input = prompt("lua_debug>", ""); + return (input !== null) ? input : ""; }; } if (getinput) { - dblib.debug = function (L) { - for (; ;) { + dblib.debug = function(L) { + for (;;) { let input = getinput(); - if (input === 'cont') + if (input === "cont") return 0; if (input.length === 0) continue; let buffer = to_luastring(input); - if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring('=(debug command)', true)) + if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring("=(debug command)", true)) || lua_pcall(L, 0, 0, 0)) { - lua_writestringerror(lua_tojsstring(L, -1), '\n'); + lua_writestringerror(lua_tojsstring(L, -1), "\n"); } lua_settop(L, 0); /* remove eventual returns */ } }; } -const luaopen_debug = function (L) { +const luaopen_debug = function(L) { luaL_newlib(L, dblib); return 1; }; + +const _luaopen_debug = luaopen_debug; +export { _luaopen_debug as luaopen_debug }; diff --git a/src/ldebug.js b/src/ldebug.js index 927da92e..bcd01de2 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -1,18 +1,4 @@ -import { - LUA_HOOKCOUNT, - LUA_HOOKLINE, - LUA_MASKCOUNT, - LUA_MASKLINE, - LUA_TBOOLEAN, - LUA_TNIL, - LUA_TTABLE, - LUA_ERRRUN, - LUA_YIELD, - from_userstring, - luastring_eq, - luastring_indexOf, - to_luastring -} from './defs.js'; +import { LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_MASKCOUNT, LUA_MASKLINE, constant_types, thread_status, from_userstring, luastring_eq, luastring_indexOf, to_luastring } from './defs.js'; import { api_check, lua_assert } from './llimits.js'; import { LUA_IDSIZE } from './luaconf.js'; import { api_incr_top } from './lapi.js'; @@ -26,15 +12,16 @@ import { luaH_new, luaH_setint } from './ltable.js'; import { TMS, luaT_objtypename } from './ltm.js'; import { cvt2str, tonumber, tointeger } from './lvm.js'; -const constant_types = { +const { LUA_TBOOLEAN, LUA_TNIL, LUA_TTABLE -}; -const thread_status = { +} = constant_types; + +const { LUA_ERRRUN, LUA_YIELD -}; +} = thread_status; const currentpc = function (ci) { lua_assert(ci.callstatus & CIST_LUA); @@ -105,7 +92,7 @@ const lua_getstack = function (L, level, ar) { const upvalname = function (p, uv) { lua_assert(uv < p.upvalues.length); let s = p.upvalues[uv].name; - if (s === null) return to_luastring('?', true); + if (s === null) return to_luastring("?", true); return s.getstr(); }; @@ -116,7 +103,7 @@ const findvararg = function (ci, n) { else { return { pos: ci.funcOff + nparams + n, - name: to_luastring('(*vararg)', true) /* generic name for any vararg */ + name: to_luastring("(*vararg)", true) /* generic name for any vararg */ }; } }; @@ -137,7 +124,7 @@ const findlocal = function (L, ci, n) { if (name === null) { /* no 'standard' name? */ let limit = ci === L.ci ? L.top : ci.next.funcOff; if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - name = to_luastring('(*temporary)', true); /* generic name for any valid slot */ + name = to_luastring("(*temporary)", true); /* generic name for any valid slot */ else return null; /* no name */ } @@ -160,7 +147,7 @@ const lua_getlocal = function (L, ar, n) { if (local) { name = local.name; pushobj2s(L, L.stack[local.pos]); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); } else { name = null; } @@ -186,16 +173,16 @@ const lua_setlocal = function (L, ar, n) { const funcinfo = function (ar, cl) { if (cl === null || cl instanceof CClosure) { - ar.source = to_luastring('=[JS]', true); + ar.source = to_luastring("=[JS]", true); ar.linedefined = -1; ar.lastlinedefined = -1; - ar.what = to_luastring('J', true); + ar.what = to_luastring("J", true); } else { let p = cl.p; - ar.source = p.source ? p.source.getstr() : to_luastring('=?', true); + ar.source = p.source ? p.source.getstr() : to_luastring("=?", true); ar.linedefined = p.linedefined; ar.lastlinedefined = p.lastlinedefined; - ar.what = ar.linedefined === 0 ? to_luastring('main', true) : to_luastring('Lua', true); + ar.what = ar.linedefined === 0 ? to_luastring("main", true) : to_luastring("Lua", true); } ar.short_src = luaO_chunkid(ar.source, LUA_IDSIZE); @@ -224,8 +211,8 @@ const getfuncname = function (L, ci) { if (ci === null) return null; else if (ci.callstatus & CIST_FIN) { /* is this a finalizer? */ - r.name = to_luastring('__gc', true); - r.funcname = to_luastring('metamethod', true); /* report it as such */ + r.name = to_luastring("__gc", true); + r.funcname = to_luastring("metamethod", true); /* report it as such */ return r; } /* calling function is a known Lua function? */ @@ -264,7 +251,7 @@ const auxgetinfo = function (L, what, ar, f, ci) { case 110 /* ('n').charCodeAt(0) */: { let r = getfuncname(L, ci); if (r === null) { - ar.namewhat = to_luastring('', true); + ar.namewhat = to_luastring("", true); ar.name = null; } else { ar.namewhat = r.funcname; @@ -289,7 +276,7 @@ const lua_getinfo = function (L, what, ar) { if (what[0] === 62 /* ('>').charCodeAt(0) */) { ci = null; func = L.stack[L.top - 1]; - api_check(L, func.ttisfunction(), 'function expected'); + api_check(L, func.ttisfunction(), "function expected"); what = what.subarray(1); /* skip the '>' */ L.top--; /* pop function */ } else { @@ -302,7 +289,7 @@ const lua_getinfo = function (L, what, ar) { status = auxgetinfo(L, what, ar, cl, ci); if (luastring_indexOf(what, 102 /* ('f').charCodeAt(0) */) >= 0) { pushobj2s(L, func); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + api_check(L, L.top <= L.ci.top, "stack overflow"); } swapextra(L); @@ -332,7 +319,7 @@ const kname = function (p, pc, c) { } /* else no reasonable name found */ } - r.name = to_luastring('?', true); + r.name = to_luastring("?", true); return r; /* no reasonable name found */ }; @@ -398,7 +385,7 @@ const getobjname = function (p, lastpc, reg) { }; if (r.name) { /* is a local? */ - r.funcname = to_luastring('local', true); + r.funcname = to_luastring("local", true); return r; } @@ -420,12 +407,12 @@ const getobjname = function (p, lastpc, reg) { let t = i.B; /* table index */ let vn = i.opcode === OCi.OP_GETTABLE ? luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); r.name = kname(p, pc, k).name; - r.funcname = (vn && luastring_eq(vn, LUA_ENV)) ? to_luastring('global', true) : to_luastring('field', true); + r.funcname = (vn && luastring_eq(vn, LUA_ENV)) ? to_luastring("global", true) : to_luastring("field", true); return r; } case OCi.OP_GETUPVAL: { r.name = upvalname(p, i.B); - r.funcname = to_luastring('upvalue', true); + r.funcname = to_luastring("upvalue", true); return r; } case OCi.OP_LOADK: @@ -433,7 +420,7 @@ const getobjname = function (p, lastpc, reg) { let b = i.opcode === OCi.OP_LOADK ? i.Bx : p.code[pc + 1].Ax; if (p.k[b].ttisstring()) { r.name = p.k[b].svalue(); - r.funcname = to_luastring('constant', true); + r.funcname = to_luastring("constant", true); return r; } break; @@ -441,7 +428,7 @@ const getobjname = function (p, lastpc, reg) { case OCi.OP_SELF: { let k = i.C; r.name = kname(p, pc, k).name; - r.funcname = to_luastring('method', true); + r.funcname = to_luastring("method", true); return r; } default: break; @@ -470,8 +457,8 @@ const funcnamefromcode = function (L, ci) { let OCi = OpCodesI; if (ci.callstatus & CIST_HOOKED) { - r.name = to_luastring('?', true); - r.funcname = to_luastring('hook', true); + r.name = to_luastring("?", true); + r.funcname = to_luastring("hook", true); return r; } @@ -480,8 +467,8 @@ const funcnamefromcode = function (L, ci) { case OCi.OP_TAILCALL: return getobjname(p, pc, i.A); /* get function name */ case OCi.OP_TFORCALL: - r.name = to_luastring('for iterator', true); - r.funcname = to_luastring('for iterator', true); + r.name = to_luastring("for iterator", true); + r.funcname = to_luastring("for iterator", true); return r; /* other instructions can do calls through metamethods */ case OCi.OP_SELF: @@ -517,7 +504,7 @@ const funcnamefromcode = function (L, ci) { } r.name = L.l_G.tmname[tm].getstr(); - r.funcname = to_luastring('metamethod', true); + r.funcname = to_luastring("metamethod", true); return r; }; @@ -559,12 +546,12 @@ const varinfo = function (L, o) { kind = getobjname(ci.func.value.p, currentpc(ci), stkid - ci.l_base); } - return kind ? luaO_pushfstring(L, to_luastring(' (%s \'%s\')', true), kind.funcname, kind.name) : to_luastring('', true); + return kind ? luaO_pushfstring(L, to_luastring(" (%s '%s')", true), kind.funcname, kind.name) : to_luastring("", true); }; const luaG_typeerror = function (L, o, op) { let t = luaT_objtypename(L, o); - luaG_runerror(L, to_luastring('attempt to %s a %s value%s', true), op, t, varinfo(L, o)); + luaG_runerror(L, to_luastring("attempt to %s a %s value%s", true), op, t, varinfo(L, o)); }; const luaG_concaterror = function (L, p1, p2) { @@ -585,9 +572,9 @@ const luaG_ordererror = function (L, p1, p2) { let t1 = luaT_objtypename(L, p1); let t2 = luaT_objtypename(L, p2); if (luastring_eq(t1, t2)) - luaG_runerror(L, to_luastring('attempt to compare two %s values', true), t1); + luaG_runerror(L, to_luastring("attempt to compare two %s values", true), t1); else - luaG_runerror(L, to_luastring('attempt to compare %s with %s', true), t1, t2); + luaG_runerror(L, to_luastring("attempt to compare %s with %s", true), t1, t2); }; /* add src:line information to 'msg' */ @@ -596,9 +583,9 @@ const luaG_addinfo = function (L, msg, src, line) { if (src) buff = luaO_chunkid(src.getstr(), LUA_IDSIZE); else - buff = to_luastring('?', true); + buff = to_luastring("?", true); - return luaO_pushfstring(L, to_luastring('%s:%d: %s', true), buff, line, msg); + return luaO_pushfstring(L, to_luastring("%s:%d: %s", true), buff, line, msg); }; const luaG_runerror = function (L, fmt, ...argp) { @@ -609,7 +596,7 @@ const luaG_runerror = function (L, fmt, ...argp) { luaG_errormsg(L); }; -export const luaG_errormsg = function (L) { +const luaG_errormsg = function (L) { if (L.errfunc !== 0) { /* is there an error handling function? */ let errfunc = L.errfunc; pushobj2s(L, L.stack[L.top - 1]); /* move argument */ @@ -627,7 +614,7 @@ const luaG_tointerror = function (L, p1, p2) { let temp = tointeger(p1); if (temp === false) p2 = p1; - luaG_runerror(L, to_luastring('number%s has no integer representation', true), varinfo(L, p2)); + luaG_runerror(L, to_luastring("number%s has no integer representation", true), varinfo(L, p2)); }; const luaG_traceexec = function (L) { @@ -664,3 +651,38 @@ const luaG_traceexec = function (L) { luaD_throw(L, LUA_YIELD); } }; + +const _luaG_addinfo = luaG_addinfo; +export { _luaG_addinfo as luaG_addinfo }; +const _luaG_concaterror = luaG_concaterror; +export { _luaG_concaterror as luaG_concaterror }; +const _luaG_errormsg = luaG_errormsg; +export { _luaG_errormsg as luaG_errormsg }; +const _luaG_opinterror = luaG_opinterror; +export { _luaG_opinterror as luaG_opinterror }; +const _luaG_ordererror = luaG_ordererror; +export { _luaG_ordererror as luaG_ordererror }; +const _luaG_runerror = luaG_runerror; +export { _luaG_runerror as luaG_runerror }; +const _luaG_tointerror = luaG_tointerror; +export { _luaG_tointerror as luaG_tointerror }; +const _luaG_traceexec = luaG_traceexec; +export { _luaG_traceexec as luaG_traceexec }; +const _luaG_typeerror = luaG_typeerror; +export { _luaG_typeerror as luaG_typeerror }; +const _lua_gethook = lua_gethook; +export { _lua_gethook as lua_gethook }; +const _lua_gethookcount = lua_gethookcount; +export { _lua_gethookcount as lua_gethookcount }; +const _lua_gethookmask = lua_gethookmask; +export { _lua_gethookmask as lua_gethookmask }; +const _lua_getinfo = lua_getinfo; +export { _lua_getinfo as lua_getinfo }; +const _lua_getlocal = lua_getlocal; +export { _lua_getlocal as lua_getlocal }; +const _lua_getstack = lua_getstack; +export { _lua_getstack as lua_getstack }; +const _lua_sethook = lua_sethook; +export { _lua_sethook as lua_sethook }; +const _lua_setlocal = lua_setlocal; +export { _lua_setlocal as lua_setlocal }; diff --git a/src/ldo.js b/src/ldo.js index 1ffd15c9..38613316 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -1,68 +1,42 @@ -import { - LUA_HOOKCALL, - LUA_HOOKRET, - LUA_HOOKTAILCALL, - LUA_MASKCALL, - LUA_MASKLINE, - LUA_MASKRET, - LUA_MINSTACK, - LUA_MULTRET, - LUA_SIGNATURE, +import { LUA_HOOKCALL, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, LUA_SIGNATURE, constant_types, thread_status, lua_Debug, luastring_indexOf, to_luastring } from './defs.js'; +import { api_checknelems, lua_pushcfunction, lua_pushlightuserdata } from './lapi.js'; +import { luaG_runerror, luaG_typeerror } from './ldebug.js'; +import { luaF_close, luaF_initupvals } from './lfunc.js'; +import { api_check, lua_assert, LUAI_MAXCCALLS } from './llimits.js'; +import { TValue, setsvalue2s, setobjs2s, pushobj2s, setobj2s, pushsvalue2s, luaO_pushfstring } from './lobject.js'; +import { OpCodesI } from './lopcodes.js'; +import { Dyndata, luaY_parser } from './lparser.js'; +import { EXTRA_STACK, luaE_freeCI, luaE_extendCI, CIST_LUA, CIST_HOOKED, CIST_TAIL, CIST_YPCALL, CIST_OAH } from './lstate.js'; +import { luaS_newliteral } from './lstring.js'; +import { luaT_gettmbyobj, TMS } from './ltm.js'; +import { LUAI_MAXSTACK } from './luaconf.js'; +import { luaU_undump } from './lundump.js'; +import { luaV_execute, luaV_finishOp } from './lvm.js'; +import { MBuffer } from './lzio.js'; + +const { LUA_TCCL, LUA_TLCF, LUA_TLCL, - LUA_TNIL, + LUA_TNIL +} = constant_types; + +const { LUA_ERRMEM, LUA_ERRERR, LUA_ERRRUN, LUA_ERRSYNTAX, LUA_OK, - LUA_YIELD, - lua_Debug, - luastring_indexOf, - to_luastring -} from './defs.js'; - -import * as lapi from "./lapi.js"; - -import * as ldebug from "./ldebug.js"; - -import * as lfunc from "./lfunc.js"; - -import {api_check, lua_assert, LUAI_MAXCCALLS} from "./llimits.js"; - -import * as lobject from "./lobject.js"; - -import * as lopcodes from "./lopcodes.js"; - -import * as lparser from "./lparser.js"; - -import * as lstate from "./lstate.js"; - -import {luaS_newliteral} from "./lstring.js"; + LUA_YIELD +} = thread_status; -import * as ltm from "./ltm.js"; - -import {LUAI_MAXSTACK} from "./luaconf.js"; - -import * as lundump from "./lundump.js"; - -import * as lvm from "./lvm.js"; - -import {MBuffer} from "./lzio.js"; - -const constant_types = { - LUA_TCCL, LUA_TLCF, LUA_TLCL, LUA_TNIL -}; -const thread_status = { - LUA_ERRMEM, LUA_ERRERR, LUA_ERRRUN, LUA_ERRSYNTAX, LUA_OK, LUA_YIELD -}; - -export const adjust_top = function (L, newtop) { +const adjust_top = function (L, newtop) { if (L.top < newtop) { - while (L.top < newtop) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + while (L.top < newtop) + L.stack[L.top++] = new TValue(LUA_TNIL, null); } else { - while (L.top > newtop) delete L.stack[--L.top]; + while (L.top > newtop) + delete L.stack[--L.top]; } }; @@ -70,50 +44,57 @@ const seterrorobj = function (L, errcode, oldtop) { let current_top = L.top; /* extend stack so that L.stack[oldtop] is sure to exist */ - while (L.top < oldtop + 1) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + while (L.top < oldtop + 1) + L.stack[L.top++] = new TValue(LUA_TNIL, null); switch (errcode) { case LUA_ERRMEM: { - lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, 'not enough memory')); + setsvalue2s(L, oldtop, luaS_newliteral(L, "not enough memory")); break; } case LUA_ERRERR: { - lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, 'error in error handling')); + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); break; } default: { - lobject.setobjs2s(L, oldtop, current_top - 1); + setobjs2s(L, oldtop, current_top - 1); } } - while (L.top > oldtop + 1) delete L.stack[--L.top]; + while (L.top > oldtop + 1) + delete L.stack[--L.top]; }; const ERRORSTACKSIZE = LUAI_MAXSTACK + 200; const luaD_reallocstack = function (L, newsize) { lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); - lua_assert(L.stack_last == L.stack.length - lstate.EXTRA_STACK); + lua_assert(L.stack_last == L.stack.length - EXTRA_STACK); L.stack.length = newsize; - L.stack_last = newsize - lstate.EXTRA_STACK; + L.stack_last = newsize - EXTRA_STACK; }; -export const luaD_growstack = function (L, n) { +const luaD_growstack = function (L, n) { let size = L.stack.length; - if (size > LUAI_MAXSTACK) luaD_throw(L, LUA_ERRERR); else { - let needed = L.top + n + lstate.EXTRA_STACK; + if (size > LUAI_MAXSTACK) + luaD_throw(L, LUA_ERRERR); + else { + let needed = L.top + n + EXTRA_STACK; let newsize = 2 * size; if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; if (newsize < needed) newsize = needed; if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ luaD_reallocstack(L, ERRORSTACKSIZE); - ldebug.luaG_runerror(L, to_luastring('stack overflow', true)); - } else luaD_reallocstack(L, newsize); + luaG_runerror(L, to_luastring("stack overflow", true)); + } + else + luaD_reallocstack(L, newsize); } }; const luaD_checkstack = function (L, n) { - if (L.stack_last - L.top <= n) luaD_growstack(L, n); + if (L.stack_last - L.top <= n) + luaD_growstack(L, n); }; const stackinuse = function (L) { @@ -127,18 +108,20 @@ const stackinuse = function (L) { const luaD_shrinkstack = function (L) { let inuse = stackinuse(L); - let goodsize = inuse + Math.floor(inuse / 8) + 2 * lstate.EXTRA_STACK; - if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK; /* respect stack limit */ + let goodsize = inuse + Math.floor(inuse / 8) + 2 * EXTRA_STACK; + if (goodsize > LUAI_MAXSTACK) + goodsize = LUAI_MAXSTACK; /* respect stack limit */ if (L.stack.length > LUAI_MAXSTACK) /* had been handling stack overflow? */ - lstate.luaE_freeCI(L); /* free all CIs (list grew because of an error) */ + luaE_freeCI(L); /* free all CIs (list grew because of an error) */ /* if thread is currently not handling a stack overflow and its good size is smaller than current size, shrink its stack */ - if (inuse <= (LUAI_MAXSTACK - lstate.EXTRA_STACK) && goodsize < L.stack.length) luaD_reallocstack(L, goodsize); + if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && goodsize < L.stack.length) + luaD_reallocstack(L, goodsize); }; const luaD_inctop = function (L) { luaD_checkstack(L, 1); - L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + L.stack[L.top++] = new TValue(LUA_TNIL, null); }; /* @@ -157,17 +140,19 @@ const luaD_precall = function (L, off, nresults) { let f = func.type === LUA_TCCL ? func.value.f : func.value; luaD_checkstack(L, LUA_MINSTACK); - let ci = lstate.luaE_extendCI(L); + let ci = luaE_extendCI(L); ci.funcOff = off; ci.nresults = nresults; ci.func = func; ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); ci.callstatus = 0; - if (L.hookmask & LUA_MASKCALL) luaD_hook(L, LUA_HOOKCALL, -1); + if (L.hookmask & LUA_MASKCALL) + luaD_hook(L, LUA_HOOKCALL, -1); let n = f(L); /* do the actual call */ - if (typeof n !== 'number' || n < 0 || (n | 0) !== n) throw Error('invalid return value from JS function (expected integer)'); - lapi.api_checknelems(L, n); + if (typeof n !== "number" || n < 0 || (n | 0) !== n) + throw Error("invalid return value from JS function (expected integer)"); + api_checknelems(L, n); luaD_poscall(L, ci, L.top - n, n); @@ -182,11 +167,12 @@ const luaD_precall = function (L, off, nresults) { if (p.is_vararg) { base = adjust_varargs(L, p, n); } else { - for (; n < p.numparams; n++) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); // complete missing arguments + for (; n < p.numparams; n++) + L.stack[L.top++] = new TValue(LUA_TNIL, null); // complete missing arguments base = off + 1; } - let ci = lstate.luaE_extendCI(L); + let ci = luaE_extendCI(L); ci.funcOff = off; ci.nresults = nresults; ci.func = func; @@ -195,8 +181,9 @@ const luaD_precall = function (L, off, nresults) { adjust_top(L, ci.top); ci.l_code = p.code; ci.l_savedpc = 0; - ci.callstatus = lstate.CIST_LUA; - if (L.hookmask & LUA_MASKCALL) callhook(L, ci); + ci.callstatus = CIST_LUA; + if (L.hookmask & LUA_MASKCALL) + callhook(L, ci); return false; } default: @@ -210,7 +197,8 @@ const luaD_poscall = function (L, ci, firstResult, nres) { let wanted = ci.nresults; if (L.hookmask & (LUA_MASKRET | LUA_MASKLINE)) { - if (L.hookmask & LUA_MASKRET) luaD_hook(L, LUA_HOOKRET, -1); + if (L.hookmask & LUA_MASKRET) + luaD_hook(L, LUA_HOOKRET, -1); L.oldpc = ci.previous.l_savedpc; /* 'oldpc' for caller function */ } @@ -225,32 +213,42 @@ const moveresults = function (L, firstResult, res, nres, wanted) { case 0: break; case 1: { - if (nres === 0) L.stack[res].setnilvalue(); else { - lobject.setobjs2s(L, res, firstResult); /* move it to proper place */ + if (nres === 0) + L.stack[res].setnilvalue(); + else { + setobjs2s(L, res, firstResult); /* move it to proper place */ } break; } case LUA_MULTRET: { - for (let i = 0; i < nres; i++) lobject.setobjs2s(L, res + i, firstResult + i); - for (let i = L.top; i >= (res + nres); i--) delete L.stack[i]; + for (let i = 0; i < nres; i++) + setobjs2s(L, res + i, firstResult + i); + for (let i = L.top; i >= (res + nres); i--) + delete L.stack[i]; L.top = res + nres; return false; } default: { let i; if (wanted <= nres) { - for (i = 0; i < wanted; i++) lobject.setobjs2s(L, res + i, firstResult + i); + for (i = 0; i < wanted; i++) + setobjs2s(L, res + i, firstResult + i); } else { - for (i = 0; i < nres; i++) lobject.setobjs2s(L, res + i, firstResult + i); + for (i = 0; i < nres; i++) + setobjs2s(L, res + i, firstResult + i); for (; i < wanted; i++) { - if (res + i >= L.top) L.stack[res + i] = new lobject.TValue(LUA_TNIL, null); else L.stack[res + i].setnilvalue(); + if (res + i >= L.top) + L.stack[res + i] = new TValue(LUA_TNIL, null); + else + L.stack[res + i].setnilvalue(); } } break; } } let newtop = res + wanted; /* top points after the last result */ - for (let i = L.top; i >= newtop; i--) delete L.stack[i]; + for (let i = L.top; i >= newtop; i--) + delete L.stack[i]; L.top = newtop; return true; }; @@ -274,21 +272,22 @@ const luaD_hook = function (L, event, line) { ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); L.allowhook = 0; /* cannot call hooks inside a hook */ - ci.callstatus |= lstate.CIST_HOOKED; + ci.callstatus |= CIST_HOOKED; hook(L, ar); lua_assert(!L.allowhook); L.allowhook = 1; ci.top = ci_top; adjust_top(L, top); - ci.callstatus &= ~lstate.CIST_HOOKED; + ci.callstatus &= ~CIST_HOOKED; } }; const callhook = function (L, ci) { let hook = LUA_HOOKCALL; ci.l_savedpc++; /* hooks assume 'pc' is already incremented */ - if ((ci.previous.callstatus & lstate.CIST_LUA) && ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == lopcodes.OpCodesI.OP_TAILCALL) { - ci.callstatus |= lstate.CIST_TAIL; + if ((ci.previous.callstatus & CIST_LUA) && + ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == OpCodesI.OP_TAILCALL) { + ci.callstatus |= CIST_TAIL; hook = LUA_HOOKTAILCALL; } luaD_hook(L, hook, -1); @@ -303,22 +302,25 @@ const adjust_varargs = function (L, p, actual) { let i; for (i = 0; i < nfixargs && i < actual; i++) { - lobject.pushobj2s(L, L.stack[fixed + i]); + pushobj2s(L, L.stack[fixed + i]); L.stack[fixed + i].setnilvalue(); } - for (; i < nfixargs; i++) L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); + for (; i < nfixargs; i++) + L.stack[L.top++] = new TValue(LUA_TNIL, null); return base; }; const tryfuncTM = function (L, off, func) { - let tm = ltm.luaT_gettmbyobj(L, func, ltm.TMS.TM_CALL); - if (!tm.ttisfunction(tm)) ldebug.luaG_typeerror(L, func, to_luastring('call', true)); + let tm = luaT_gettmbyobj(L, func, TMS.TM_CALL); + if (!tm.ttisfunction(tm)) + luaG_typeerror(L, func, to_luastring("call", true)); /* Open a hole inside the stack at 'func' */ - lobject.pushobj2s(L, L.stack[L.top - 1]); /* push top of stack again */ - for (let p = L.top - 2; p > off; p--) lobject.setobjs2s(L, p, p - 1); /* move other items up one */ - lobject.setobj2s(L, off, tm); /* tag method is the new function to be called */ + pushobj2s(L, L.stack[L.top - 1]); /* push top of stack again */ + for (let p = L.top - 2; p > off; p--) + setobjs2s(L, p, p - 1); /* move other items up one */ + setobj2s(L, off, tm); /* tag method is the new function to be called */ }; /* @@ -329,7 +331,10 @@ const tryfuncTM = function (L, off, func) { ** allow overflow handling to work) */ const stackerror = function (L) { - if (L.nCcalls === LUAI_MAXCCALLS) ldebug.luaG_runerror(L, to_luastring('JS stack overflow', true)); else if (L.nCcalls >= LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)) luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + if (L.nCcalls === LUAI_MAXCCALLS) + luaG_runerror(L, to_luastring("JS stack overflow", true)); + else if (L.nCcalls >= LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ }; /* @@ -338,9 +343,11 @@ const stackerror = function (L) { ** When returns, all the results are on the stack, starting at the original ** function position. */ -export const luaD_call = function (L, off, nResults) { - if (++L.nCcalls >= LUAI_MAXCCALLS) stackerror(L); - if (!luaD_precall(L, off, nResults)) lvm.luaV_execute(L); +const luaD_call = function (L, off, nResults) { + if (++L.nCcalls >= LUAI_MAXCCALLS) + stackerror(L); + if (!luaD_precall(L, off, nResults)) + luaV_execute(L); L.nCcalls--; }; @@ -358,7 +365,8 @@ const luaD_throw = function (L, errcode) { let panic = g.panic; if (panic) { /* panic function? */ seterrorobj(L, errcode, L.top); /* assume EXTRA_STACK */ - if (L.ci.top < L.top) L.ci.top = L.top; /* pushing msg. can break this invariant */ + if (L.ci.top < L.top) + L.ci.top = L.top; /* pushing msg. can break this invariant */ panic(L); /* call panic function (last chance to jump out) */ } throw new Error(`Aborted ${errcode}`); @@ -369,7 +377,8 @@ const luaD_throw = function (L, errcode) { const luaD_rawrunprotected = function (L, f, ud) { let oldnCcalls = L.nCcalls; let lj = { - status: LUA_OK, previous: L.errorJmp /* chain new error handler */ + status: LUA_OK, + previous: L.errorJmp /* chain new error handler */ }; L.errorJmp = lj; @@ -384,16 +393,16 @@ const luaD_rawrunprotected = function (L, f, ud) { try { lj.status = LUA_OK; - lapi.lua_pushcfunction(L, atnativeerror); - lapi.lua_pushlightuserdata(L, e); + lua_pushcfunction(L, atnativeerror); + lua_pushlightuserdata(L, e); luaD_callnoyield(L, L.top - 2, 1); /* Now run the message handler (if it exists) */ /* copy of luaG_errormsg without the throw */ if (L.errfunc !== 0) { /* is there an error handling function? */ let errfunc = L.errfunc; - lobject.pushobj2s(L, L.stack[L.top - 1]); /* move argument */ - lobject.setobjs2s(L, L.top - 2, errfunc); /* push function */ + pushobj2s(L, L.stack[L.top - 1]); /* move argument */ + setobjs2s(L, L.top - 2, errfunc); /* push function */ luaD_callnoyield(L, L.top - 2, 1); } @@ -427,10 +436,10 @@ const finishCcall = function (L, status) { /* must have a continuation and must be able to call it */ lua_assert(ci.c_k !== null && L.nny === 0); /* error status can only happen in a protected call */ - lua_assert(ci.callstatus & lstate.CIST_YPCALL || status === LUA_YIELD); + lua_assert(ci.callstatus & CIST_YPCALL || status === LUA_YIELD); - if (ci.callstatus & lstate.CIST_YPCALL) { /* was inside a pcall? */ - ci.callstatus &= ~lstate.CIST_YPCALL; /* continuation is also inside it */ + if (ci.callstatus & CIST_YPCALL) { /* was inside a pcall? */ + ci.callstatus &= ~CIST_YPCALL; /* continuation is also inside it */ L.errfunc = ci.c_old_errfunc; /* with the same error function */ } @@ -439,7 +448,7 @@ const finishCcall = function (L, status) { if (ci.nresults === LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top; let c_k = ci.c_k; /* don't want to call as method */ let n = c_k(L, status, ci.c_ctx); /* call continuation function */ - lapi.api_checknelems(L, n); + api_checknelems(L, n); luaD_poscall(L, ci, L.top - n, n); /* finish 'luaD_precall' */ }; @@ -456,10 +465,11 @@ const unroll = function (L, ud) { finishCcall(L, ud); /* finish 'lua_pcallk' callee */ while (L.ci !== L.base_ci) { /* something in the stack */ - if (!(L.ci.callstatus & lstate.CIST_LUA)) /* C function? */ - finishCcall(L, LUA_YIELD); /* complete its execution */ else { /* Lua function */ - lvm.luaV_finishOp(L); /* finish interrupted instruction */ - lvm.luaV_execute(L); /* execute down to higher C 'boundary' */ + if (!(L.ci.callstatus & CIST_LUA)) /* C function? */ + finishCcall(L, LUA_YIELD); /* complete its execution */ + else { /* Lua function */ + luaV_finishOp(L); /* finish interrupted instruction */ + luaV_execute(L); /* execute down to higher C 'boundary' */ } } }; @@ -470,7 +480,8 @@ const unroll = function (L, ud) { */ const findpcall = function (L) { for (let ci = L.ci; ci !== null; ci = ci.previous) { /* search for a pcall */ - if (ci.callstatus & lstate.CIST_YPCALL) return ci; + if (ci.callstatus & CIST_YPCALL) + return ci; } return null; /* no pending pcall */ @@ -486,10 +497,10 @@ const recover = function (L, status) { if (ci === null) return 0; /* no recovery point */ /* "finish" luaD_pcall */ let oldtop = ci.extra; - lfunc.luaF_close(L, oldtop); + luaF_close(L, oldtop); seterrorobj(L, status, oldtop); L.ci = ci; - L.allowhook = ci.callstatus & lstate.CIST_OAH; /* restore original 'allowhook' */ + L.allowhook = ci.callstatus & CIST_OAH; /* restore original 'allowhook' */ L.nny = 0; /* should be zero to be yieldable */ luaD_shrinkstack(L); L.errfunc = ci.c_old_errfunc; @@ -504,12 +515,13 @@ const recover = function (L, status) { const resume_error = function (L, msg, narg) { let ts = luaS_newliteral(L, msg); if (narg === 0) { - lobject.pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + pushsvalue2s(L, ts); + api_check(L, L.top <= L.ci.top, "stack overflow"); } else { /* remove args from the stack */ - for (let i = 1; i < narg; i++) delete L.stack[--L.top]; - lobject.setsvalue2s(L, L.top - 1, ts); /* push error message */ + for (let i = 1; i < narg; i++) + delete L.stack[--L.top]; + setsvalue2s(L, L.top - 1, ts); /* push error message */ } return LUA_ERRRUN; }; @@ -526,18 +538,19 @@ const resume = function (L, n) { let ci = L.ci; if (L.status === LUA_OK) { /* starting a coroutine? */ if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ - lvm.luaV_execute(L); /* call it */ + luaV_execute(L); /* call it */ } else { /* resuming from previous yield */ lua_assert(L.status === LUA_YIELD); L.status = LUA_OK; /* mark that it is running (again) */ ci.funcOff = ci.extra; ci.func = L.stack[ci.funcOff]; - if (ci.callstatus & lstate.CIST_LUA) /* yielded inside a hook? */ - lvm.luaV_execute(L); /* just continue running Lua code */ else { /* 'common' yield */ + if (ci.callstatus & CIST_LUA) /* yielded inside a hook? */ + luaV_execute(L); /* just continue running Lua code */ + else { /* 'common' yield */ if (ci.c_k !== null) { /* does it have a continuation function? */ n = ci.c_k(L, LUA_YIELD, ci.c_ctx); /* call continuation */ - lapi.api_checknelems(L, n); + api_checknelems(L, n); firstArg = L.top - n; /* yield results come from continuation */ } @@ -553,19 +566,22 @@ const lua_resume = function (L, from, nargs) { if (L.status === LUA_OK) { /* may be starting a coroutine */ if (L.ci !== L.base_ci) /* not in base level? */ - return resume_error(L, 'cannot resume non-suspended coroutine', nargs); - } else if (L.status !== LUA_YIELD) return resume_error(L, 'cannot resume dead coroutine', nargs); + return resume_error(L, "cannot resume non-suspended coroutine", nargs); + } else if (L.status !== LUA_YIELD) + return resume_error(L, "cannot resume dead coroutine", nargs); L.nCcalls = from ? from.nCcalls + 1 : 1; - if (L.nCcalls >= LUAI_MAXCCALLS) return resume_error(L, 'JS stack overflow', nargs); + if (L.nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "JS stack overflow", nargs); L.nny = 0; /* allow yields */ - lapi.api_checknelems(L, L.status === LUA_OK ? nargs + 1 : nargs); + api_checknelems(L, L.status === LUA_OK ? nargs + 1 : nargs); let status = luaD_rawrunprotected(L, resume, nargs); if (status === -1) /* error calling 'lua_resume'? */ - status = LUA_ERRRUN; else { /* continue running after recoverable errors */ + status = LUA_ERRRUN; + else { /* continue running after recoverable errors */ while (status > LUA_YIELD && recover(L, status)) { /* unroll continuation */ status = luaD_rawrunprotected(L, unroll, status); @@ -575,7 +591,8 @@ const lua_resume = function (L, from, nargs) { L.status = status; /* mark thread as 'dead' */ seterrorobj(L, status, L.top); /* push error message */ L.ci.top = L.top; - } else lua_assert(status === L.status); /* normal end or yield */ + } else + lua_assert(status === L.status); /* normal end or yield */ } L.nny = oldnny; /* restore 'nny' */ @@ -590,16 +607,20 @@ const lua_isyieldable = function (L) { const lua_yieldk = function (L, nresults, ctx, k) { let ci = L.ci; - lapi.api_checknelems(L, nresults); + api_checknelems(L, nresults); if (L.nny > 0) { - if (L !== L.l_G.mainthread) ldebug.luaG_runerror(L, to_luastring('attempt to yield across a JS-call boundary', true)); else ldebug.luaG_runerror(L, to_luastring('attempt to yield from outside a coroutine', true)); + if (L !== L.l_G.mainthread) + luaG_runerror(L, to_luastring("attempt to yield across a JS-call boundary", true)); + else + luaG_runerror(L, to_luastring("attempt to yield from outside a coroutine", true)); } L.status = LUA_YIELD; ci.extra = ci.funcOff; /* save current 'func' */ - if (ci.callstatus & lstate.CIST_LUA) /* inside a hook? */ - api_check(L, k === null, 'hooks cannot continue after yielding'); else { + if (ci.callstatus & CIST_LUA) /* inside a hook? */ + api_check(L, k === null, "hooks cannot continue after yielding"); + else { ci.c_k = k; if (k !== null) /* is there a continuation? */ ci.c_ctx = ctx; /* save context */ @@ -608,7 +629,7 @@ const lua_yieldk = function (L, nresults, ctx, k) { luaD_throw(L, LUA_YIELD); } - lua_assert(ci.callstatus & lstate.CIST_HOOKED); /* must be inside a hook */ + lua_assert(ci.callstatus & CIST_HOOKED); /* must be inside a hook */ return 0; /* return to 'luaD_hook' */ }; @@ -616,7 +637,7 @@ const lua_yield = function (L, n) { lua_yieldk(L, n, 0, null); }; -export const luaD_pcall = function (L, func, u, old_top, ef) { +const luaD_pcall = function (L, func, u, old_top, ef) { let old_ci = L.ci; let old_allowhooks = L.allowhook; let old_nny = L.nny; @@ -626,7 +647,7 @@ export const luaD_pcall = function (L, func, u, old_top, ef) { let status = luaD_rawrunprotected(L, func, u); if (status !== LUA_OK) { - lfunc.luaF_close(L, old_top); + luaF_close(L, old_top); seterrorobj(L, status, old_top); L.ci = old_ci; L.allowhook = old_allowhooks; @@ -642,7 +663,7 @@ export const luaD_pcall = function (L, func, u, old_top, ef) { /* ** Similar to 'luaD_call', but does not allow yields during the call */ -export const luaD_callnoyield = function (L, off, nResults) { +const luaD_callnoyield = function (L, off, nResults) { L.nny++; luaD_call(L, off, nResults); L.nny--; @@ -655,7 +676,7 @@ class SParser { constructor(z, name, mode) { /* data to 'f_parser' */ this.z = z; this.buff = new MBuffer(); /* dynamic structure used by the scanner */ - this.dyd = new lparser.Dyndata(); /* dynamic structures used by the parser */ + this.dyd = new Dyndata(); /* dynamic structures used by the parser */ this.mode = mode; this.name = name; } @@ -663,7 +684,8 @@ class SParser { const checkmode = function (L, mode, x) { if (mode && luastring_indexOf(mode, x[0]) === -1) { - lobject.luaO_pushfstring(L, to_luastring('attempt to load a %s chunk (mode is \'%s\')'), x, mode); + luaO_pushfstring(L, + to_luastring("attempt to load a %s chunk (mode is '%s')"), x, mode); luaD_throw(L, LUA_ERRSYNTAX); } }; @@ -672,21 +694,58 @@ const f_parser = function (L, p) { let cl; let c = p.z.zgetc(); /* read first character */ if (c === LUA_SIGNATURE[0]) { - checkmode(L, p.mode, to_luastring('binary', true)); - cl = lundump.luaU_undump(L, p.z, p.name); + checkmode(L, p.mode, to_luastring("binary", true)); + cl = luaU_undump(L, p.z, p.name); } else { - checkmode(L, p.mode, to_luastring('text', true)); - cl = lparser.luaY_parser(L, p.z, p.buff, p.dyd, p.name, c); + checkmode(L, p.mode, to_luastring("text", true)); + cl = luaY_parser(L, p.z, p.buff, p.dyd, p.name, c); } lua_assert(cl.nupvalues === cl.p.upvalues.length); - lfunc.luaF_initupvals(L, cl); + luaF_initupvals(L, cl); }; -export const luaD_protectedparser = function (L, z, name, mode) { +const luaD_protectedparser = function (L, z, name, mode) { let p = new SParser(z, name, mode); L.nny++; /* cannot yield during parsing */ let status = luaD_pcall(L, f_parser, p, L.top, L.errfunc); L.nny--; return status; }; + +const _adjust_top = adjust_top; +export { _adjust_top as adjust_top }; +const _luaD_call = luaD_call; +export { _luaD_call as luaD_call }; +const _luaD_callnoyield = luaD_callnoyield; +export { _luaD_callnoyield as luaD_callnoyield }; +const _luaD_checkstack = luaD_checkstack; +export { _luaD_checkstack as luaD_checkstack }; +const _luaD_growstack = luaD_growstack; +export { _luaD_growstack as luaD_growstack }; +const _luaD_hook = luaD_hook; +export { _luaD_hook as luaD_hook }; +const _luaD_inctop = luaD_inctop; +export { _luaD_inctop as luaD_inctop }; +const _luaD_pcall = luaD_pcall; +export { _luaD_pcall as luaD_pcall }; +const _luaD_poscall = luaD_poscall; +export { _luaD_poscall as luaD_poscall }; +const _luaD_precall = luaD_precall; +export { _luaD_precall as luaD_precall }; +const _luaD_protectedparser = luaD_protectedparser; +export { _luaD_protectedparser as luaD_protectedparser }; +const _luaD_rawrunprotected = luaD_rawrunprotected; +export { _luaD_rawrunprotected as luaD_rawrunprotected }; +const _luaD_reallocstack = luaD_reallocstack; +export { _luaD_reallocstack as luaD_reallocstack }; +const _luaD_throw = luaD_throw; +export { _luaD_throw as luaD_throw }; +const _lua_isyieldable = lua_isyieldable; +export { _lua_isyieldable as lua_isyieldable }; +const _lua_resume = lua_resume; +export { _lua_resume as lua_resume }; +const _lua_yield = lua_yield; +export { _lua_yield as lua_yield }; +const _lua_yieldk = lua_yieldk; +export { _lua_yieldk as lua_yieldk }; diff --git a/src/ldump.js b/src/ldump.js index 05cb58fd..bfa1ae10 100644 --- a/src/ldump.js +++ b/src/ldump.js @@ -1,27 +1,21 @@ -import { - LUA_SIGNATURE, - LUA_TBOOLEAN, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR, - LUA_VERSION_MAJOR, - LUA_VERSION_MINOR, luastring_of -} from "./defs.js"; +"use strict"; -const constant_types = { +import { LUA_SIGNATURE, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, constant_types, luastring_of } from './defs.js'; + +const { LUA_TBOOLEAN, LUA_TLNGSTR, LUA_TNIL, LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR -} +} = constant_types; -const LUAC_DATA = luastring_of(25, 147, 13, 10, 26, 10); -const LUAC_INT = 0x5678; -const LUAC_NUM = 370.5; +const LUAC_DATA = luastring_of(25, 147, 13, 10, 26, 10); +const LUAC_INT = 0x5678; +const LUAC_NUM = 370.5; const LUAC_VERSION = Number(LUA_VERSION_MAJOR) * 16 + Number(LUA_VERSION_MINOR); -const LUAC_FORMAT = 0; /* this is the official format */ +const LUAC_FORMAT = 0; /* this is the official format */ class DumpState { constructor() { @@ -33,16 +27,16 @@ class DumpState { } } -const DumpBlock = function(b, size, D) { +const DumpBlock = function (b, size, D) { if (D.status === 0 && size > 0) D.status = D.writer(D.L, b, size, D.data); }; -const DumpByte = function(y, D) { +const DumpByte = function (y, D) { DumpBlock(luastring_of(y), 1, D); }; -const DumpInt = function(x, D) { +const DumpInt = function (x, D) { let ab = new ArrayBuffer(4); let dv = new DataView(ab); dv.setInt32(0, x, true); @@ -50,7 +44,7 @@ const DumpInt = function(x, D) { DumpBlock(t, 4, D); }; -const DumpInteger = function(x, D) { +const DumpInteger = function (x, D) { let ab = new ArrayBuffer(4); let dv = new DataView(ab); dv.setInt32(0, x, true); @@ -58,7 +52,7 @@ const DumpInteger = function(x, D) { DumpBlock(t, 4, D); }; -const DumpNumber = function(x, D) { +const DumpNumber = function (x, D) { let ab = new ArrayBuffer(8); let dv = new DataView(ab); dv.setFloat64(0, x, true); @@ -66,7 +60,7 @@ const DumpNumber = function(x, D) { DumpBlock(t, 8, D); }; -const DumpString = function(s, D) { +const DumpString = function (s, D) { if (s === null) DumpByte(0, D); else { @@ -82,7 +76,7 @@ const DumpString = function(s, D) { } }; -const DumpCode = function(f, D) { +const DumpCode = function (f, D) { let s = f.code.map(e => e.code); DumpInt(s.length, D); @@ -90,7 +84,7 @@ const DumpCode = function(f, D) { DumpInt(s[i], D); }; -const DumpConstants = function(f, D) { +const DumpConstants = function (f, D) { let n = f.k.length; DumpInt(n, D); for (let i = 0; i < n; i++) { @@ -116,14 +110,14 @@ const DumpConstants = function(f, D) { } }; -const DumpProtos = function(f, D) { +const DumpProtos = function (f, D) { let n = f.p.length; DumpInt(n, D); for (let i = 0; i < n; i++) DumpFunction(f.p[i], f.source, D); }; -const DumpUpvalues = function(f, D) { +const DumpUpvalues = function (f, D) { let n = f.upvalues.length; DumpInt(n, D); for (let i = 0; i < n; i++) { @@ -132,7 +126,7 @@ const DumpUpvalues = function(f, D) { } }; -const DumpDebug = function(f, D) { +const DumpDebug = function (f, D) { let n = D.strip ? 0 : f.lineinfo.length; DumpInt(n, D); for (let i = 0; i < n; i++) @@ -150,7 +144,7 @@ const DumpDebug = function(f, D) { DumpString(f.upvalues[i].name, D); }; -const DumpFunction = function(f, psource, D) { +const DumpFunction = function (f, psource, D) { if (D.strip || f.source === psource) DumpString(null, D); /* no debug info or same source as its parent */ else @@ -158,7 +152,7 @@ const DumpFunction = function(f, psource, D) { DumpInt(f.linedefined, D); DumpInt(f.lastlinedefined, D); DumpByte(f.numparams, D); - DumpByte(f.is_vararg?1:0, D); + DumpByte(f.is_vararg ? 1 : 0, D); DumpByte(f.maxstacksize, D); DumpCode(f, D); DumpConstants(f, D); @@ -167,7 +161,7 @@ const DumpFunction = function(f, psource, D) { DumpDebug(f, D); }; -const DumpHeader = function(D) { +const DumpHeader = function (D) { DumpBlock(LUA_SIGNATURE, LUA_SIGNATURE.length, D); DumpByte(LUAC_VERSION, D); DumpByte(LUAC_FORMAT, D); @@ -184,7 +178,7 @@ const DumpHeader = function(D) { /* ** dump Lua function as precompiled chunk */ -export const luaU_dump = function(L, f, w, data, strip) { +const luaU_dump = function (L, f, w, data, strip) { let D = new DumpState(); D.L = L; D.writer = w; @@ -196,3 +190,6 @@ export const luaU_dump = function(L, f, w, data, strip) { DumpFunction(f, null, D); return D.status; }; + +const _luaU_dump = luaU_dump; +export { _luaU_dump as luaU_dump }; diff --git a/src/lfunc.js b/src/lfunc.js index f2e1b98a..09a08dc4 100644 --- a/src/lfunc.js +++ b/src/lfunc.js @@ -1,8 +1,7 @@ -import {LUA_TNIL} from "./defs.js"; +import { constant_types } from './defs.js'; +import { LClosure, TValue } from './lobject.js'; -import * as lobject from "./lobject.js"; - -const constant_types = { LUA_TNIL } +const { LUA_TNIL } = constant_types; class Proto { constructor(L) { @@ -24,7 +23,7 @@ class Proto { } const luaF_newLclosure = function(L, n) { - return new lobject.LClosure(L, n); + return new LClosure(L, n); }; @@ -37,7 +36,7 @@ const luaF_close = function(L, level) { * any closures will keep referencing old TValues */ for (let i=level; i=', '<=', '~=', - '<<', '>>', '::', '', - '', '', '', '' -].map((e, i)=>to_luastring(e)); + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "goto", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "//", "..", "...", "==", ">=", "<=", "~=", + "<<", ">>", "::", "", + "", "", "", "" +].map((e, i) => to_luastring(e)); class SemInfo { constructor() { @@ -148,38 +140,38 @@ class LexState { } } -const save = function(ls, c) { +const save = function (ls, c) { let b = ls.buff; if (b.n + 1 > b.buffer.length) { - if (b.buffer.length >= MAX_INT/2) - lexerror(ls, to_luastring('lexical element too long', true), 0); - let newsize = b.buffer.length*2; + if (b.buffer.length >= MAX_INT / 2) + lexerror(ls, to_luastring("lexical element too long", true), 0); + let newsize = b.buffer.length * 2; luaZ_resizebuffer(ls.L, b, newsize); } b.buffer[b.n++] = c < 0 ? 255 + c + 1 : c; }; -const luaX_token2str = function(ls, token) { +const luaX_token2str = function (ls, token) { if (token < FIRST_RESERVED) { /* single-byte symbols? */ - return lobject.luaO_pushfstring(ls.L, to_luastring('\'%c\'', true), token); + return luaO_pushfstring(ls.L, to_luastring("'%c'", true), token); } else { let s = luaX_tokens[token - FIRST_RESERVED]; if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ - return lobject.luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), s); + return luaO_pushfstring(ls.L, to_luastring("'%s'", true), s); else /* names, strings, and numerals */ return s; } }; -const currIsNewline = function(ls) { +const currIsNewline = function (ls) { return ls.current === 10 /* ('\n').charCodeAt(0) */ || ls.current === 13 /* ('\r').charCodeAt(0) */; }; -const next = function(ls) { +const next = function (ls) { ls.current = ls.z.zgetc(); }; -const save_and_next = function(ls) { +const save_and_next = function (ls) { save(ls, ls.current); next(ls); }; @@ -189,15 +181,15 @@ const save_and_next = function(ls) { ** it will not be collected until the end of the compilation ** (by that time it should be anchored somewhere) */ -const TVtrue = new lobject.TValue(LUA_TBOOLEAN, true); -const luaX_newstring = function(ls, str) { +const TVtrue = new TValue(LUA_TBOOLEAN, true); +const luaX_newstring = function (ls, str) { let L = ls.L; let ts = luaS_new(L, str); /* HACK: Workaround lack of ltable 'keyfromval' */ let tpair = ls.h.strong.get(luaS_hashlongstr(ts)); if (!tpair) { /* not in use yet? */ - let key = new lobject.TValue(LUA_TLNGSTR, ts); - ltable.luaH_setfrom(L, ls.h, key, TVtrue); + let key = new TValue(LUA_TLNGSTR, ts); + luaH_setfrom(L, ls.h, key, TVtrue); } else { /* string already present */ ts = tpair.key.tsvalue(); /* re-use value previously stored */ } @@ -208,17 +200,17 @@ const luaX_newstring = function(ls, str) { ** increment line number and skips newline sequence (any of ** \n, \r, \n\r, or \r\n) */ -const inclinenumber = function(ls) { +const inclinenumber = function (ls) { let old = ls.current; lua_assert(currIsNewline(ls)); next(ls); /* skip '\n' or '\r' */ if (currIsNewline(ls) && ls.current !== old) next(ls); /* skip '\n\r' or '\r\n' */ if (++ls.linenumber >= MAX_INT) - lexerror(ls, to_luastring('chunk has too many lines', true), 0); + lexerror(ls, to_luastring("chunk has too many lines", true), 0); }; -const luaX_setinput = function(L, ls, z, source, firstchar) { +const luaX_setinput = function (L, ls, z, source, firstchar) { ls.t = { token: 0, seminfo: new SemInfo() @@ -238,7 +230,7 @@ const luaX_setinput = function(L, ls, z, source, firstchar) { luaZ_resizebuffer(L, ls.buff, LUA_MINBUFFER); /* initialize buffer */ }; -const check_next1 = function(ls, c) { +const check_next1 = function (ls, c) { if (ls.current === c) { next(ls); return true; @@ -251,7 +243,7 @@ const check_next1 = function(ls, c) { ** Check whether current char is in set 'set' (with two chars) and ** saves it */ -const check_next2 = function(ls, set) { +const check_next2 = function (ls, set) { if (ls.current === set[0].charCodeAt(0) || ls.current === set[1].charCodeAt(0)) { save_and_next(ls); return true; @@ -260,17 +252,17 @@ const check_next2 = function(ls, set) { return false; }; -const read_numeral = function(ls, seminfo) { - let expo = 'Ee'; +const read_numeral = function (ls, seminfo) { + let expo = "Ee"; let first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); - if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, 'xX')) /* hexadecimal? */ - expo = 'Pp'; + if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, "xX")) /* hexadecimal? */ + expo = "Pp"; - for (;;) { + for (; ;) { if (check_next2(ls, expo)) /* exponent part? */ - check_next2(ls, '-+'); /* optional exponent sign */ + check_next2(ls, "-+"); /* optional exponent sign */ if (lisxdigit(ls.current)) save_and_next(ls); else if (ls.current === 46 /* ('.').charCodeAt(0) */) @@ -280,9 +272,9 @@ const read_numeral = function(ls, seminfo) { // save(ls, 0); - let obj = new lobject.TValue(); - if (lobject.luaO_str2num(luaZ_buffer(ls.buff), obj) === 0) /* format error? */ - lexerror(ls, to_luastring('malformed number', true), TK_FLT); + let obj = new TValue(); + if (luaO_str2num(luaZ_buffer(ls.buff), obj) === 0) /* format error? */ + lexerror(ls, to_luastring("malformed number", true), TK_FLT); if (obj.ttisinteger()) { seminfo.i = obj.value; return TK_INT; @@ -293,25 +285,25 @@ const read_numeral = function(ls, seminfo) { } }; -const txtToken = function(ls, token) { +const txtToken = function (ls, token) { switch (token) { case TK_NAME: case TK_STRING: case TK_FLT: case TK_INT: // save(ls, 0); - return lobject.luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), luaZ_buffer(ls.buff)); + return luaO_pushfstring(ls.L, to_luastring("'%s'", true), luaZ_buffer(ls.buff)); default: return luaX_token2str(ls, token); } }; -const lexerror = function(ls, msg, token) { - msg = ldebug.luaG_addinfo(ls.L, msg, ls.source, ls.linenumber); +const lexerror = function (ls, msg, token) { + msg = luaG_addinfo(ls.L, msg, ls.source, ls.linenumber); if (token) - lobject.luaO_pushfstring(ls.L, to_luastring('%s near %s'), msg, txtToken(ls, token)); - ldo.luaD_throw(ls.L, LUA_ERRSYNTAX); + luaO_pushfstring(ls.L, to_luastring("%s near %s"), msg, txtToken(ls, token)); + luaD_throw(ls.L, LUA_ERRSYNTAX); }; -const luaX_syntaxerror = function(ls, msg) { +const luaX_syntaxerror = function (ls, msg) { lexerror(ls, msg, ls.t.token); }; @@ -320,7 +312,7 @@ const luaX_syntaxerror = function(ls, msg) { ** its number of '='s; otherwise, return a negative number (-1 iff there ** are no '='s after initial bracket) */ -const skip_sep = function(ls) { +const skip_sep = function (ls) { let count = 0; let s = ls.current; lua_assert(s === 91 /* ('[').charCodeAt(0) */ || s === 93 /* (']').charCodeAt(0) */); @@ -332,7 +324,7 @@ const skip_sep = function(ls) { return ls.current === s ? count : (-count) - 1; }; -const read_long_string = function(ls, seminfo, sep) { +const read_long_string = function (ls, seminfo, sep) { let line = ls.linenumber; /* initial line (for error message) */ save_and_next(ls); /* skip 2nd '[' */ @@ -340,10 +332,10 @@ const read_long_string = function(ls, seminfo, sep) { inclinenumber(ls); /* skip it */ let skip = false; - for (; !skip ;) { + for (; !skip;) { switch (ls.current) { case EOZ: { /* error */ - let what = seminfo ? 'string' : 'comment'; + let what = seminfo ? "string" : "comment"; let msg = `unfinished long ${what} (starting at line ${line})`; lexerror(ls, to_luastring(msg), TK_EOS); break; @@ -373,7 +365,7 @@ const read_long_string = function(ls, seminfo, sep) { seminfo.ts = luaX_newstring(ls, ls.buff.buffer.subarray(2 + sep, ls.buff.n - (2 + sep))); }; -const esccheck = function(ls, c, msg) { +const esccheck = function (ls, c, msg) { if (!c) { if (ls.current !== EOZ) save_and_next(ls); /* add current to buffer for error message */ @@ -381,74 +373,74 @@ const esccheck = function(ls, c, msg) { } }; -const gethexa = function(ls) { +const gethexa = function (ls) { save_and_next(ls); - esccheck(ls, lisxdigit(ls.current), to_luastring('hexadecimal digit expected', true)); - return lobject.luaO_hexavalue(ls.current); + esccheck(ls, lisxdigit(ls.current), to_luastring("hexadecimal digit expected", true)); + return luaO_hexavalue(ls.current); }; -const readhexaesc = function(ls) { +const readhexaesc = function (ls) { let r = gethexa(ls); r = (r << 4) + gethexa(ls); luaZ_buffremove(ls.buff, 2); /* remove saved chars from buffer */ return r; }; -const readutf8desc = function(ls) { +const readutf8desc = function (ls) { let i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ save_and_next(ls); /* skip 'u' */ - esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring('missing \'{\'', true)); + esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring("missing '{'", true)); let r = gethexa(ls); /* must have at least one digit */ save_and_next(ls); while (lisxdigit(ls.current)) { i++; - r = (r << 4) + lobject.luaO_hexavalue(ls.current); - esccheck(ls, r <= 0x10FFFF, to_luastring('UTF-8 value too large', true)); + r = (r << 4) + luaO_hexavalue(ls.current); + esccheck(ls, r <= 0x10FFFF, to_luastring("UTF-8 value too large", true)); save_and_next(ls); } - esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring('missing \'}\'', true)); + esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring("missing '}'", true)); next(ls); /* skip '}' */ luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */ return r; }; -const utf8esc = function(ls) { - let buff = new Uint8Array(lobject.UTF8BUFFSZ); - let n = lobject.luaO_utf8esc(buff, readutf8desc(ls)); +const utf8esc = function (ls) { + let buff = new Uint8Array(UTF8BUFFSZ); + let n = luaO_utf8esc(buff, readutf8desc(ls)); for (; n > 0; n--) /* add 'buff' to string */ - save(ls, buff[lobject.UTF8BUFFSZ - n]); + save(ls, buff[UTF8BUFFSZ - n]); }; -const readdecesc = function(ls) { +const readdecesc = function (ls) { let r = 0; /* result accumulator */ let i; for (i = 0; i < 3 && lisdigit(ls.current); i++) { /* read up to 3 digits */ r = 10 * r + ls.current - 48 /* ('0').charCodeAt(0) */; save_and_next(ls); } - esccheck(ls, r <= 255, to_luastring('decimal escape too large', true)); + esccheck(ls, r <= 255, to_luastring("decimal escape too large", true)); luaZ_buffremove(ls.buff, i); /* remove read digits from buffer */ return r; }; -const read_string = function(ls, del, seminfo) { +const read_string = function (ls, del, seminfo) { save_and_next(ls); /* keep delimiter (for error messages) */ while (ls.current !== del) { switch (ls.current) { case EOZ: - lexerror(ls, to_luastring('unfinished string', true), TK_EOS); + lexerror(ls, to_luastring("unfinished string", true), TK_EOS); break; case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: - lexerror(ls, to_luastring('unfinished string', true), TK_STRING); + lexerror(ls, to_luastring("unfinished string", true), TK_STRING); break; case 92 /* ('\\').charCodeAt(0) */: { /* escape sequences */ save_and_next(ls); /* keep '\\' for error messages */ let will; let c; - switch(ls.current) { + switch (ls.current) { case 97 /* ('a').charCodeAt(0) */: c = 7 /* \a isn't valid JS */; will = 'read_save'; break; case 98 /* ('b').charCodeAt(0) */: c = 8 /* ('\b').charCodeAt(0) */; will = 'read_save'; break; case 102 /* ('f').charCodeAt(0) */: c = 12 /* ('\f').charCodeAt(0) */; will = 'read_save'; break; @@ -476,7 +468,7 @@ const read_string = function(ls, del, seminfo) { will = 'no_save'; break; } default: { - esccheck(ls, lisdigit(ls.current), to_luastring('invalid escape sequence', true)); + esccheck(ls, lisdigit(ls.current), to_luastring("invalid escape sequence", true)); c = readdecesc(ls); /* digital escape '\ddd' */ will = 'only_save'; break; } @@ -498,21 +490,21 @@ const read_string = function(ls, del, seminfo) { } save_and_next(ls); /* skip delimiter */ - seminfo.ts = luaX_newstring(ls, ls.buff.buffer.subarray(1, ls.buff.n-1)); + seminfo.ts = luaX_newstring(ls, ls.buff.buffer.subarray(1, ls.buff.n - 1)); }; const token_to_index = Object.create(null); /* don't want to return true for e.g. 'hasOwnProperty' */ -luaX_tokens.forEach((e, i)=>token_to_index[luaS_hash(e)] = i); +luaX_tokens.forEach((e, i) => token_to_index[luaS_hash(e)] = i); -const isreserved = function(w) { +const isreserved = function (w) { let kidx = token_to_index[luaS_hashlongstr(w)]; return kidx !== void 0 && kidx <= 22; }; -const llex = function(ls, seminfo) { +const llex = function (ls, seminfo) { luaZ_resetbuffer(ls.buff); - for (;;) { - lua_assert(typeof ls.current == 'number'); /* fengari addition */ + for (; ;) { + lua_assert(typeof ls.current == "number"); /* fengari addition */ switch (ls.current) { case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: { /* line breaks */ @@ -552,7 +544,7 @@ const llex = function(ls, seminfo) { read_long_string(ls, seminfo, sep); return TK_STRING; } else if (sep !== -1) /* '[=...' missing second bracket */ - lexerror(ls, to_luastring('invalid long string delimiter', true), TK_STRING); + lexerror(ls, to_luastring("invalid long string delimiter", true), TK_STRING); return 91 /* ('[').charCodeAt(0) */; } case 61 /* ('=').charCodeAt(0) */: { @@ -631,7 +623,7 @@ const llex = function(ls, seminfo) { } }; -const luaX_next = function(ls) { +const luaX_next = function (ls) { ls.lastline = ls.linenumber; if (ls.lookahead.token !== TK_EOS) { /* is there a look-ahead token? */ ls.t.token = ls.lookahead.token; /* use this one */ @@ -643,8 +635,33 @@ const luaX_next = function(ls) { ls.t.token = llex(ls, ls.t.seminfo); /* read next token */ }; -const luaX_lookahead = function(ls) { +const luaX_lookahead = function (ls) { lua_assert(ls.lookahead.token === TK_EOS); ls.lookahead.token = llex(ls, ls.lookahead.seminfo); return ls.lookahead.token; }; + +const _FIRST_RESERVED = FIRST_RESERVED; +export { _FIRST_RESERVED as FIRST_RESERVED }; +const _LUA_ENV = LUA_ENV; +export { _LUA_ENV as LUA_ENV }; +const _LexState = LexState; +export { _LexState as LexState }; +const _RESERVED = RESERVED; +export { _RESERVED as RESERVED }; +const _isreserved = isreserved; +export { _isreserved as isreserved }; +const _luaX_lookahead = luaX_lookahead; +export { _luaX_lookahead as luaX_lookahead }; +const _luaX_newstring = luaX_newstring; +export { _luaX_newstring as luaX_newstring }; +const _luaX_next = luaX_next; +export { _luaX_next as luaX_next }; +const _luaX_setinput = luaX_setinput; +export { _luaX_setinput as luaX_setinput }; +const _luaX_syntaxerror = luaX_syntaxerror; +export { _luaX_syntaxerror as luaX_syntaxerror }; +const _luaX_token2str = luaX_token2str; +export { _luaX_token2str as luaX_token2str }; +const _luaX_tokens = luaX_tokens; +export { _luaX_tokens as luaX_tokens }; diff --git a/src/llimits.js b/src/llimits.js index fc1270f1..8ec38bdc 100644 --- a/src/llimits.js +++ b/src/llimits.js @@ -1,23 +1,37 @@ -export const lua_assert = function(c) { - if (!c) throw Error('assertion failed'); +const lua_assert = function (c) { + if (!c) throw Error("assertion failed"); }; +const _lua_assert = lua_assert; +export { _lua_assert as lua_assert }; -export const api_check = function(l, e, msg) { +const api_check = function (l, e, msg) { if (!e) throw Error(msg); }; +const _api_check = api_check; +export { _api_check as api_check }; const LUAI_MAXCCALLS = 200; +const _LUAI_MAXCCALLS = LUAI_MAXCCALLS; +export { _LUAI_MAXCCALLS as LUAI_MAXCCALLS }; /* minimum size for string buffer */ const LUA_MINBUFFER = 32; +const _LUA_MINBUFFER = LUA_MINBUFFER; +export { _LUA_MINBUFFER as LUA_MINBUFFER }; -export const luai_nummod = function(L, a, b) { +const luai_nummod = function (L, a, b) { let m = a % b; - if ((m*b) < 0) + if ((m * b) < 0) m += b; return m; }; +const _luai_nummod = luai_nummod; +export { _luai_nummod as luai_nummod }; // If later integers are more than 32bit, LUA_MAXINTEGER will then be != MAX_INT const MAX_INT = 2147483647; +const _MAX_INT = MAX_INT; +export { _MAX_INT as MAX_INT }; const MIN_INT = -2147483648; +const _MIN_INT = MIN_INT; +export { _MIN_INT as MIN_INT }; diff --git a/src/lmathlib.js b/src/lmathlib.js index be66e73c..d71550d2 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,47 +1,24 @@ -import { - lua_compare, - lua_gettop, - lua_isinteger, - lua_isnoneornil, - LUA_OPLT, - lua_pushboolean, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushvalue, lua_setfield, - lua_settop, - LUA_TNUMBER, lua_tointeger, lua_tointegerx, lua_type -} from "./lua.js"; - - -import { - luaL_argcheck, - luaL_argerror, - luaL_checkany, - luaL_checkinteger, - luaL_checknumber, - luaL_error, luaL_newlib, luaL_optnumber -} from "./lauxlib.js"; - - -import {LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger} from "./luaconf.js"; - - -import {to_luastring} from "./fengaricore.js"; - +import { LUA_OPLT, LUA_TNUMBER, lua_compare, lua_gettop, lua_isinteger, lua_isnoneornil, lua_pushboolean, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushvalue, lua_setfield, lua_settop, lua_tointeger, lua_tointegerx, lua_type } from './lua.js'; +import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checknumber, luaL_error, luaL_newlib, luaL_optnumber } from './lauxlib.js'; +import { LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger } from './luaconf.js'; +import { to_luastring } from "./fengaricore.js"; let rand_state; /* use same parameters as glibc LCG */ -const l_rand = function() { +const l_rand = function () { rand_state = (1103515245 * rand_state + 12345) & 0x7fffffff; return rand_state; }; -const l_srand = function(x) { - rand_state = x|0; +const l_srand = function (x) { + rand_state = x | 0; if (rand_state === 0) rand_state = 1; }; -const math_random = function(L) { +const math_random = function (L) { let low, up; /* use Math.random until randomseed is called */ - let r = (rand_state === void 0)?Math.random():(l_rand() / 0x80000000); + let r = (rand_state === void 0) ? Math.random() : (l_rand() / 0x80000000); switch (lua_gettop(L)) { /* check number of arguments */ case 0: lua_pushnumber(L, r); /* Number between 0 and 1 */ @@ -56,29 +33,29 @@ const math_random = function(L) { up = luaL_checkinteger(L, 2); break; } - default: return luaL_error(L, 'wrong number of arguments'); + default: return luaL_error(L, "wrong number of arguments"); } /* random integer in the interval [low, up] */ - luaL_argcheck(L, low <= up, 1, 'interval is empty'); + luaL_argcheck(L, low <= up, 1, "interval is empty"); luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, - 'interval too large'); + "interval too large"); r *= (up - low) + 1; lua_pushinteger(L, Math.floor(r) + low); return 1; }; -const math_randomseed = function(L) { +const math_randomseed = function (L) { l_srand(luaL_checknumber(L, 1)); l_rand(); /* discard first value to avoid undesirable correlations */ return 0; }; -const math_abs = function(L) { +const math_abs = function (L) { if (lua_isinteger(L, 1)) { let n = lua_tointeger(L, 1); - if (n < 0) n = (-n)|0; + if (n < 0) n = (-n) | 0; lua_pushinteger(L, n); } else @@ -86,39 +63,39 @@ const math_abs = function(L) { return 1; }; -const math_sin = function(L) { +const math_sin = function (L) { lua_pushnumber(L, Math.sin(luaL_checknumber(L, 1))); return 1; }; -const math_cos = function(L) { +const math_cos = function (L) { lua_pushnumber(L, Math.cos(luaL_checknumber(L, 1))); return 1; }; -const math_tan = function(L) { +const math_tan = function (L) { lua_pushnumber(L, Math.tan(luaL_checknumber(L, 1))); return 1; }; -const math_asin = function(L) { +const math_asin = function (L) { lua_pushnumber(L, Math.asin(luaL_checknumber(L, 1))); return 1; }; -const math_acos = function(L) { +const math_acos = function (L) { lua_pushnumber(L, Math.acos(luaL_checknumber(L, 1))); return 1; }; -const math_atan = function(L) { +const math_atan = function (L) { let y = luaL_checknumber(L, 1); let x = luaL_optnumber(L, 2, 1); lua_pushnumber(L, Math.atan2(y, x)); return 1; }; -const math_toint = function(L) { +const math_toint = function (L) { let n = lua_tointegerx(L, 1); if (n !== false) lua_pushinteger(L, n); @@ -129,7 +106,7 @@ const math_toint = function(L) { return 1; }; -const pushnumint = function(L, d) { +const pushnumint = function (L, d) { let n = lua_numbertointeger(d); if (n !== false) /* does 'd' fit in an integer? */ lua_pushinteger(L, n); /* result is integer */ @@ -137,7 +114,7 @@ const pushnumint = function(L, d) { lua_pushnumber(L, d); /* result is float */ }; -const math_floor = function(L) { +const math_floor = function (L) { if (lua_isinteger(L, 1)) lua_settop(L, 1); else @@ -146,7 +123,7 @@ const math_floor = function(L) { return 1; }; -const math_ceil = function(L) { +const math_ceil = function (L) { if (lua_isinteger(L, 1)) lua_settop(L, 1); else @@ -155,19 +132,19 @@ const math_ceil = function(L) { return 1; }; -const math_sqrt = function(L) { +const math_sqrt = function (L) { lua_pushnumber(L, Math.sqrt(luaL_checknumber(L, 1))); return 1; }; -const math_ult = function(L) { +const math_ult = function (L) { let a = luaL_checkinteger(L, 1); let b = luaL_checkinteger(L, 2); - lua_pushboolean(L, (a >= 0)?(b<0 || a= 0) ? (b < 0 || a < b) : (b < 0 && a < b)); return 1; }; -const math_log = function(L) { +const math_log = function (L) { let x = luaL_checknumber(L, 1); let res; if (lua_isnoneornil(L, 2)) @@ -179,32 +156,32 @@ const math_log = function(L) { else if (base === 10) res = Math.log10(x); else - res = Math.log(x)/Math.log(base); + res = Math.log(x) / Math.log(base); } lua_pushnumber(L, res); return 1; }; -const math_exp = function(L) { +const math_exp = function (L) { lua_pushnumber(L, Math.exp(luaL_checknumber(L, 1))); return 1; }; -const math_deg = function(L) { +const math_deg = function (L) { lua_pushnumber(L, luaL_checknumber(L, 1) * (180 / Math.PI)); return 1; }; -const math_rad = function(L) { +const math_rad = function (L) { lua_pushnumber(L, luaL_checknumber(L, 1) * (Math.PI / 180)); return 1; }; -const math_min = function(L) { +const math_min = function (L) { let n = lua_gettop(L); /* number of arguments */ let imin = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, 'value expected'); - for (let i = 2; i <= n; i++){ + luaL_argcheck(L, n >= 1, 1, "value expected"); + for (let i = 2; i <= n; i++) { if (lua_compare(L, i, imin, LUA_OPLT)) imin = i; } @@ -212,11 +189,11 @@ const math_min = function(L) { return 1; }; -const math_max = function(L) { +const math_max = function (L) { let n = lua_gettop(L); /* number of arguments */ let imax = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, 'value expected'); - for (let i = 2; i <= n; i++){ + luaL_argcheck(L, n >= 1, 1, "value expected"); + for (let i = 2; i <= n; i++) { if (lua_compare(L, imax, i, LUA_OPLT)) imax = i; } @@ -224,12 +201,12 @@ const math_max = function(L) { return 1; }; -const math_type = function(L) { +const math_type = function (L) { if (lua_type(L, 1) === LUA_TNUMBER) { if (lua_isinteger(L, 1)) - lua_pushliteral(L, 'integer'); + lua_pushliteral(L, "integer"); else - lua_pushliteral(L, 'float'); + lua_pushliteral(L, "float"); } else { luaL_checkany(L, 1); lua_pushnil(L); @@ -237,23 +214,23 @@ const math_type = function(L) { return 1; }; -const math_fmod = function(L) { +const math_fmod = function (L) { if (lua_isinteger(L, 1) && lua_isinteger(L, 2)) { let d = lua_tointeger(L, 2); /* no special case needed for -1 in javascript */ if (d === 0) { - luaL_argerror(L, 2, 'zero'); + luaL_argerror(L, 2, "zero"); } else - lua_pushinteger(L, (lua_tointeger(L, 1) % d)|0); + lua_pushinteger(L, (lua_tointeger(L, 1) % d) | 0); } else { let a = luaL_checknumber(L, 1); let b = luaL_checknumber(L, 2); - lua_pushnumber(L, a%b); + lua_pushnumber(L, a % b); } return 1; }; -const math_modf = function(L) { +const math_modf = function (L) { if (lua_isinteger(L, 1)) { lua_settop(L, 1); /* number is its own integer part */ lua_pushnumber(L, 0); /* no fractional part */ @@ -267,42 +244,43 @@ const math_modf = function(L) { }; const mathlib = { - 'abs': math_abs, - 'acos': math_acos, - 'asin': math_asin, - 'atan': math_atan, - 'ceil': math_ceil, - 'cos': math_cos, - 'deg': math_deg, - 'exp': math_exp, - 'floor': math_floor, - 'fmod': math_fmod, - 'log': math_log, - 'max': math_max, - 'min': math_min, - 'modf': math_modf, - 'rad': math_rad, - 'random': math_random, - 'randomseed': math_randomseed, - 'sin': math_sin, - 'sqrt': math_sqrt, - 'tan': math_tan, - 'tointeger': math_toint, - 'type': math_type, - 'ult': math_ult + "abs": math_abs, + "acos": math_acos, + "asin": math_asin, + "atan": math_atan, + "ceil": math_ceil, + "cos": math_cos, + "deg": math_deg, + "exp": math_exp, + "floor": math_floor, + "fmod": math_fmod, + "log": math_log, + "max": math_max, + "min": math_min, + "modf": math_modf, + "rad": math_rad, + "random": math_random, + "randomseed": math_randomseed, + "sin": math_sin, + "sqrt": math_sqrt, + "tan": math_tan, + "tointeger": math_toint, + "type": math_type, + "ult": math_ult }; -const luaopen_math = function(L) { +const luaopen_math = function (L) { luaL_newlib(L, mathlib); lua_pushnumber(L, Math.PI); - lua_setfield(L, -2, to_luastring('pi', true)); + lua_setfield(L, -2, to_luastring("pi", true)); lua_pushnumber(L, Infinity); - lua_setfield(L, -2, to_luastring('huge', true)); + lua_setfield(L, -2, to_luastring("huge", true)); lua_pushinteger(L, LUA_MAXINTEGER); - lua_setfield(L, -2, to_luastring('maxinteger', true)); + lua_setfield(L, -2, to_luastring("maxinteger", true)); lua_pushinteger(L, LUA_MININTEGER); - lua_setfield(L, -2, to_luastring('mininteger', true)); + lua_setfield(L, -2, to_luastring("mininteger", true)); return 1; }; -module.exports.luaopen_math = luaopen_math; +const _luaopen_math = luaopen_math; +export { _luaopen_math as luaopen_math }; diff --git a/src/loadlib.js b/src/loadlib.js index 2a3fc698..a69d73d2 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -1,52 +1,15 @@ -import fs from "fs"; -import pathlib from "path"; -import { - LUA_DIRSEP, - LUA_EXEC_DIR, - LUA_JSPATH_DEFAULT, - LUA_PATH_DEFAULT, - LUA_PATH_MARK, - LUA_PATH_SEP -} from "./luaconf.js"; - - -import { - lua_callk, - lua_createtable, - lua_getfield, - lua_insert, lua_isfunction, lua_isnil, lua_isstring, lua_newtable, - LUA_OK, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, - lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgeti, - lua_rawgetp, lua_rawseti, lua_rawsetp, - LUA_REGISTRYINDEX, lua_remove, lua_setfield, lua_setmetatable, lua_settop, - LUA_TNIL, lua_toboolean, lua_tostring, lua_touserdata, - LUA_TTABLE, lua_upvalueindex -} from "./lua.js"; - - -import { - LUA_LOADED_TABLE, - LUA_PRELOAD_TABLE, - luaL_addvalue, - luaL_Buffer, - luaL_buffinit, - luaL_checkstring, luaL_error, luaL_getsubtable, luaL_gsub, luaL_len, luaL_loadfile, luaL_newlib, luaL_optstring, - luaL_pushresult, luaL_setfuncs -} from "./lauxlib.js"; - - -import * as lualib from "./lualib.js"; - -import {luastring_indexOf, to_jsstring, to_luastring, to_uristring} from "./fengaricore.js"; - - -import * as fengari from "./fengari.js"; - -const global_env = (function() { - if (typeof process !== 'undefined') { +import { LUA_DIRSEP, LUA_EXEC_DIR, LUA_JSPATH_DEFAULT, LUA_PATH_DEFAULT, LUA_PATH_MARK, LUA_PATH_SEP } from './luaconf.js'; +import { LUA_OK, LUA_REGISTRYINDEX, LUA_TNIL, LUA_TTABLE, lua_callk, lua_createtable, lua_getfield, lua_insert, lua_isfunction, lua_isnil, lua_isstring, lua_newtable, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgeti, lua_rawgetp, lua_rawseti, lua_rawsetp, lua_remove, lua_setfield, lua_setmetatable, lua_settop, lua_toboolean, lua_tostring, lua_touserdata, lua_upvalueindex } from './lua.js'; +import { LUA_LOADED_TABLE, LUA_PRELOAD_TABLE, luaL_Buffer, luaL_addvalue, luaL_buffinit, luaL_checkstring, luaL_error, luaL_getsubtable, luaL_gsub, luaL_len, luaL_loadfile, luaL_newlib, luaL_optstring, luaL_pushresult, luaL_setfuncs } from './lauxlib.js'; +import { LUA_VERSUFFIX } from './lualib.js'; +import { luastring_indexOf, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; +import fengari from './fengari.js'; + +const global_env = (function () { + if (typeof process !== "undefined") { /* node */ return global; - } else if (typeof window !== 'undefined') { + } else if (typeof window !== "undefined") { /* browser window */ return window; } else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { @@ -58,11 +21,11 @@ const global_env = (function() { } })(); -const JSLIBS = to_luastring('__JSLIBS__'); -const LUA_PATH_VAR = 'LUA_PATH'; -const LUA_JSPATH_VAR = 'LUA_JSPATH'; +const JSLIBS = to_luastring("__JSLIBS__"); +const LUA_PATH_VAR = "LUA_PATH"; +const LUA_JSPATH_VAR = "LUA_JSPATH"; -const LUA_IGMARK = '-'; +const LUA_IGMARK = "-"; /* ** LUA_CSUBSEP is the character that replaces dots in submodule names @@ -74,13 +37,13 @@ const LUA_CSUBSEP = LUA_DIRSEP; const LUA_LSUBSEP = LUA_DIRSEP; /* prefix for open functions in JS libraries */ -const LUA_POF = to_luastring('luaopen_'); +const LUA_POF = to_luastring("luaopen_"); /* separator for open functions in JS libraries */ -const LUA_OFSEP = to_luastring('_'); -const LIB_FAIL = 'open'; +const LUA_OFSEP = to_luastring("_"); +const LIB_FAIL = "open"; -const AUXMARK = to_luastring('\x01'); +const AUXMARK = to_luastring("\x01"); /* @@ -90,11 +53,11 @@ const AUXMARK = to_luastring('\x01'); ** error string in the stack. */ let lsys_load; -if (typeof process === 'undefined') { - lsys_load = function(L, path, seeglb) { +if (typeof process === "undefined") { + lsys_load = function (L, path, seeglb) { path = to_uristring(path); let xhr = new XMLHttpRequest(); - xhr.open('GET', path, false); + xhr.open("GET", path, false); xhr.send(); if (xhr.status < 200 || xhr.status >= 300) { @@ -105,16 +68,16 @@ if (typeof process === 'undefined') { let code = xhr.response; /* Add sourceURL comment to get path in debugger+tracebacks */ if (!/\/\/[#@] sourceURL=/.test(code)) - code += ' //# sourceURL=' + path; + code += " //# sourceURL=" + path; let func; try { - func = Function('fengari', code); + func = Function("fengari", code); } catch (e) { lua_pushstring(L, to_luastring(`${e.name}: ${e.message}`)); return null; } let res = func(fengari); - if (typeof res === 'function' || (typeof res === 'object' && res !== null)) { + if (typeof res === "function" || (typeof res === "object" && res !== null)) { return res; } else if (res === void 0) { /* assume library added symbols to global environment */ return global_env; @@ -124,12 +87,13 @@ if (typeof process === 'undefined') { } }; } else { - lsys_load = function(L, path, seeglb) { + const pathlib = require('path'); + lsys_load = function (L, path, seeglb) { path = to_jsstring(path); /* relative paths should be relative to cwd, not this js file */ path = pathlib.resolve(process.cwd(), path); try { - return require(path); // TODO: This cannot happen - need to convert this call to ES + return require(path); } catch (e) { lua_pushstring(L, to_luastring(e.message)); return null; @@ -142,13 +106,13 @@ if (typeof process === 'undefined') { ** Returns the function; in case of error, returns NULL plus an ** error string in the stack. */ -const lsys_sym = function(L, lib, sym) { +const lsys_sym = function (L, lib, sym) { let f = lib[to_jsstring(sym)]; if (f && typeof f === 'function') return f; else { - lua_pushfstring(L, to_luastring('undefined symbol: %s'), sym); + lua_pushfstring(L, to_luastring("undefined symbol: %s"), sym); return null; } }; @@ -156,17 +120,18 @@ const lsys_sym = function(L, lib, sym) { /* ** return registry.LUA_NOENV as a boolean */ -const noenv = function(L) { - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('LUA_NOENV')); +const noenv = function (L) { + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("LUA_NOENV")); let b = lua_toboolean(L, -1); lua_pop(L, 1); /* remove value */ return b; }; let readable; -if (typeof process !== 'undefined') { // Only with Node +if (typeof process !== "undefined") { // Only with Node + const fs = require('fs'); - readable = function(filename) { + readable = function (filename) { try { let fd = fs.openSync(filename, 'r'); fs.closeSync(fd); @@ -176,11 +141,11 @@ if (typeof process !== 'undefined') { // Only with Node return true; }; } else { - readable = function(path) { + readable = function (path) { path = to_uristring(path); let xhr = new XMLHttpRequest(); /* Following GET request done by searcher_Web will be cached */ - xhr.open('GET', path, false); + xhr.open("GET", path, false); xhr.send(); return xhr.status >= 200 && xhr.status <= 299; @@ -189,7 +154,7 @@ if (typeof process !== 'undefined') { // Only with Node /* error codes for 'lookforfunc' */ -const ERRLIB = 1; +const ERRLIB = 1; const ERRFUNC = 2; /* @@ -203,7 +168,7 @@ const ERRFUNC = 2; ** Return 0 and 'true' or a function in the stack; in case of ** errors, return an error code and an error message in the stack. */ -const lookforfunc = function(L, path, sym) { +const lookforfunc = function (L, path, sym) { let reg = checkjslib(L, path); /* check loaded JS libraries */ if (reg === null) { /* must load library? */ reg = lsys_load(L, path, sym[0] === '*'.charCodeAt(0)); /* a global symbols if 'sym'=='*' */ @@ -223,7 +188,7 @@ const lookforfunc = function(L, path, sym) { } }; -const ll_loadlib = function(L) { +const ll_loadlib = function (L) { let path = luaL_checkstring(L, 1); let init = luaL_checkstring(L, 2); let stat = lookforfunc(L, path, init); @@ -232,13 +197,13 @@ const ll_loadlib = function(L) { else { /* error; error message is on stack top */ lua_pushnil(L); lua_insert(L, -2); - lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : 'init'); + lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : "init"); return 3; /* return nil, error message, and where */ } }; -const env = (function() { - if (typeof process !== 'undefined') { +const env = (function () { + if (typeof process !== "undefined") { /* node */ return process.env; } else { @@ -249,8 +214,8 @@ const env = (function() { /* ** Set a path */ -const setpath = function(L, fieldname, envname, dft) { - let nver = `${envname}${lualib.LUA_VERSUFFIX}`; +const setpath = function (L, fieldname, envname, dft) { + let nver = `${envname}${LUA_VERSUFFIX}`; lua_pushstring(L, to_luastring(nver)); let path = env[nver]; /* use versioned name */ if (path === undefined) /* no environment variable? */ @@ -275,7 +240,7 @@ const setpath = function(L, fieldname, envname, dft) { /* ** return registry.JSLIBS[path] */ -const checkjslib = function(L, path) { +const checkjslib = function (L, path) { lua_rawgetp(L, LUA_REGISTRYINDEX, JSLIBS); lua_getfield(L, -1, path); let plib = lua_touserdata(L, -1); /* plib = JSLIBS[path] */ @@ -287,7 +252,7 @@ const checkjslib = function(L, path) { ** registry.JSLIBS[path] = plib -- for queries ** registry.JSLIBS[#JSLIBS + 1] = plib -- also keep a list of all libraries */ -const addtojslib = function(L, path, plib) { +const addtojslib = function (L, path, plib) { lua_rawgetp(L, LUA_REGISTRYINDEX, JSLIBS); lua_pushlightuserdata(L, plib); lua_pushvalue(L, -1); @@ -296,7 +261,7 @@ const addtojslib = function(L, path, plib) { lua_pop(L, 1); /* pop JSLIBS table */ }; -const pushnexttemplate = function(L, path) { +const pushnexttemplate = function (L, path) { while (path[0] === LUA_PATH_SEP.charCodeAt(0)) path = path.subarray(1); /* skip separators */ if (path.length === 0) return null; /* no more templates */ let l = luastring_indexOf(path, LUA_PATH_SEP.charCodeAt(0)); /* find next separator */ @@ -305,7 +270,7 @@ const pushnexttemplate = function(L, path) { return path.subarray(l); }; -const searchpath = function(L, name, path, sep, dirsep) { +const searchpath = function (L, name, path, sep, dirsep) { let msg = new luaL_Buffer(); /* to build error message */ luaL_buffinit(L, msg); if (sep[0] !== 0) /* non-empty separator? */ @@ -315,7 +280,7 @@ const searchpath = function(L, name, path, sep, dirsep) { lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pushfstring(L, to_luastring('\n\tno file \'%s\''), filename); + lua_pushfstring(L, to_luastring("\n\tno file '%s'"), filename); lua_remove(L, -2); /* remove file name */ luaL_addvalue(msg); } @@ -323,12 +288,12 @@ const searchpath = function(L, name, path, sep, dirsep) { return null; /* not found */ }; -const ll_searchpath = function(L) { +const ll_searchpath = function (L) { let f = searchpath( L, luaL_checkstring(L, 1), luaL_checkstring(L, 2), - luaL_optstring(L, 3, '.'), + luaL_optstring(L, 3, "."), luaL_optstring(L, 4, LUA_DIRSEP) ); if (f !== null) return 1; @@ -339,26 +304,26 @@ const ll_searchpath = function(L) { } }; -const findfile = function(L, name, pname, dirsep) { +const findfile = function (L, name, pname, dirsep) { lua_getfield(L, lua_upvalueindex(1), pname); let path = lua_tostring(L, -1); if (path === null) - luaL_error(L, to_luastring('\'package.%s\' must be a string'), pname); - return searchpath(L, name, path, to_luastring('.'), dirsep); + luaL_error(L, to_luastring("'package.%s' must be a string"), pname); + return searchpath(L, name, path, to_luastring("."), dirsep); }; -const checkload = function(L, stat, filename) { +const checkload = function (L, stat, filename) { if (stat) { /* module loaded successfully? */ lua_pushstring(L, filename); /* will be 2nd argument to module */ return 2; /* return open function and file name */ } else - return luaL_error(L, to_luastring('error loading module \'%s\' from file \'%s\':\n\t%s'), + return luaL_error(L, to_luastring("error loading module '%s' from file '%s':\n\t%s"), lua_tostring(L, 1), filename, lua_tostring(L, -1)); }; -const searcher_Lua = function(L) { +const searcher_Lua = function (L) { let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring('path', true), to_luastring(LUA_LSUBSEP, true)); + let filename = findfile(L, name, to_luastring("path", true), to_luastring(LUA_LSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, luaL_loadfile(L, filename) === LUA_OK, filename); }; @@ -371,41 +336,41 @@ const searcher_Lua = function(L) { ** fails, it also tries "luaopen_Y".) If there is no ignore mark, ** look for a function named "luaopen_modname". */ -const loadfunc = function(L, filename, modname) { +const loadfunc = function (L, filename, modname) { let openfunc; - modname = luaL_gsub(L, modname, to_luastring('.'), LUA_OFSEP); + modname = luaL_gsub(L, modname, to_luastring("."), LUA_OFSEP); let mark = luastring_indexOf(modname, LUA_IGMARK.charCodeAt(0)); if (mark >= 0) { openfunc = lua_pushlstring(L, modname, mark); - openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, openfunc); + openfunc = lua_pushfstring(L, to_luastring("%s%s"), LUA_POF, openfunc); let stat = lookforfunc(L, filename, openfunc); if (stat !== ERRFUNC) return stat; modname = mark + 1; /* else go ahead and try old-style name */ } - openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, modname); + openfunc = lua_pushfstring(L, to_luastring("%s%s"), LUA_POF, modname); return lookforfunc(L, filename, openfunc); }; -const searcher_C = function(L) { +const searcher_C = function (L) { let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); + let filename = findfile(L, name, to_luastring("jspath", true), to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, (loadfunc(L, filename, name) === 0), filename); }; -const searcher_Croot = function(L) { +const searcher_Croot = function (L) { let name = luaL_checkstring(L, 1); let p = luastring_indexOf(name, '.'.charCodeAt(0)); let stat; if (p < 0) return 0; /* is root */ lua_pushlstring(L, name, p); - let filename = findfile(L, lua_tostring(L, -1), to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); + let filename = findfile(L, lua_tostring(L, -1), to_luastring("jspath", true), to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* root not found */ if ((stat = loadfunc(L, filename, name)) !== 0) { if (stat != ERRFUNC) return checkload(L, 0, filename); /* real error */ else { /* open function not found */ - lua_pushfstring(L, to_luastring('\n\tno module \'%s\' in file \'%s\''), name, filename); + lua_pushfstring(L, to_luastring("\n\tno module '%s' in file '%s'"), name, filename); return 1; } } @@ -413,32 +378,32 @@ const searcher_Croot = function(L) { return 2; }; -const searcher_preload = function(L) { +const searcher_preload = function (L) { let name = luaL_checkstring(L, 1); lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); if (lua_getfield(L, -1, name) === LUA_TNIL) /* not found? */ - lua_pushfstring(L, to_luastring('\n\tno field package.preload[\'%s\']'), name); + lua_pushfstring(L, to_luastring("\n\tno field package.preload['%s']"), name); return 1; }; -const findloader = function(L, name, ctx, k) { +const findloader = function (L, name, ctx, k) { let msg = new luaL_Buffer(); /* to build error message */ luaL_buffinit(L, msg); /* push 'package.searchers' to index 3 in the stack */ - if (lua_getfield(L, lua_upvalueindex(1), to_luastring('searchers', true)) !== LUA_TTABLE) - luaL_error(L, to_luastring('\'package.searchers\' must be a table')); - let ctx2 = {name: name, i: 1, msg: msg, ctx: ctx, k: k}; + if (lua_getfield(L, lua_upvalueindex(1), to_luastring("searchers", true)) !== LUA_TTABLE) + luaL_error(L, to_luastring("'package.searchers' must be a table")); + let ctx2 = { name: name, i: 1, msg: msg, ctx: ctx, k: k }; return findloader_cont(L, LUA_OK, ctx2); }; -const findloader_cont = function(L, status, ctx) { +const findloader_cont = function (L, status, ctx) { /* iterate over available searchers to find a loader */ for (; ; ctx.i++) { if (status === LUA_OK) { if (lua_rawgeti(L, 3, ctx.i) === LUA_TNIL) { /* no more searchers? */ lua_pop(L, 1); /* remove nil */ luaL_pushresult(ctx.msg); /* create error message */ - luaL_error(L, to_luastring('module \'%s\' not found:%s'), ctx.name, lua_tostring(L, -1)); + luaL_error(L, to_luastring("module '%s' not found:%s"), ctx.name, lua_tostring(L, -1)); } lua_pushstring(L, ctx.name); lua_callk(L, 1, 2, ctx, findloader_cont); /* call it */ @@ -457,7 +422,7 @@ const findloader_cont = function(L, status, ctx) { return ctx.k(L, LUA_OK, ctx.ctx); }; -const ll_require = function(L) { +const ll_require = function (L) { let name = luaL_checkstring(L, 1); lua_settop(L, 1); /* LOADED table will be at index 2 */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); @@ -470,7 +435,7 @@ const ll_require = function(L) { return findloader(L, name, ctx, ll_require_cont); }; -const ll_require_cont = function(L, status, ctx) { +const ll_require_cont = function (L, status, ctx) { let name = ctx; lua_pushstring(L, name); /* pass name as argument to module loader */ lua_insert(L, -2); /* name is 1st argument (before search data) */ @@ -478,7 +443,7 @@ const ll_require_cont = function(L, status, ctx) { return ll_require_cont2(L, LUA_OK, ctx); /* run loader to load module */ }; -const ll_require_cont2 = function(L, status, ctx) { +const ll_require_cont2 = function (L, status, ctx) { let name = ctx; if (!lua_isnil(L, -1)) /* non-nil return? */ lua_setfield(L, 2, name); /* LOADED[name] = returned value */ @@ -491,15 +456,15 @@ const ll_require_cont2 = function(L, status, ctx) { }; const pk_funcs = { - 'loadlib': ll_loadlib, - 'searchpath': ll_searchpath + "loadlib": ll_loadlib, + "searchpath": ll_searchpath }; const ll_funcs = { - 'require': ll_require + "require": ll_require }; -const createsearcherstable = function(L) { +const createsearcherstable = function (L) { let searchers = [searcher_preload, searcher_Lua, searcher_C, searcher_Croot, null]; /* create 'searchers' table */ lua_createtable(L); @@ -507,42 +472,45 @@ const createsearcherstable = function(L) { for (let i = 0; searchers[i]; i++) { lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ lua_pushcclosure(L, searchers[i], 1); - lua_rawseti(L, -2, i+1); + lua_rawseti(L, -2, i + 1); } - lua_setfield(L, -2, to_luastring('searchers', true)); /* put it in field 'searchers' */ + lua_setfield(L, -2, to_luastring("searchers", true)); /* put it in field 'searchers' */ }; /* ** create table JSLIBS to keep track of loaded JS libraries, ** setting a finalizer to close all libraries when closing state. */ -const createjslibstable = function(L) { +const createjslibstable = function (L) { lua_newtable(L); /* create JSLIBS table */ lua_createtable(L, 0, 1); /* create metatable for JSLIBS */ lua_setmetatable(L, -2); lua_rawsetp(L, LUA_REGISTRYINDEX, JSLIBS); /* set JSLIBS table in registry */ }; -const luaopen_package = function(L) { +const luaopen_package = function (L) { createjslibstable(L); luaL_newlib(L, pk_funcs); /* create 'package' table */ createsearcherstable(L); /* set paths */ - setpath(L, to_luastring('path', true), LUA_PATH_VAR, LUA_PATH_DEFAULT); - setpath(L, to_luastring('jspath', true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); + setpath(L, to_luastring("path", true), LUA_PATH_VAR, LUA_PATH_DEFAULT); + setpath(L, to_luastring("jspath", true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); /* store config information */ - lua_pushliteral(L, LUA_DIRSEP + '\n' + LUA_PATH_SEP + '\n' + LUA_PATH_MARK + '\n' + - LUA_EXEC_DIR + '\n' + LUA_IGMARK + '\n'); - lua_setfield(L, -2, to_luastring('config', true)); + lua_pushliteral(L, LUA_DIRSEP + "\n" + LUA_PATH_SEP + "\n" + LUA_PATH_MARK + "\n" + + LUA_EXEC_DIR + "\n" + LUA_IGMARK + "\n"); + lua_setfield(L, -2, to_luastring("config", true)); /* set field 'loaded' */ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - lua_setfield(L, -2, to_luastring('loaded', true)); + lua_setfield(L, -2, to_luastring("loaded", true)); /* set field 'preload' */ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - lua_setfield(L, -2, to_luastring('preload', true)); + lua_setfield(L, -2, to_luastring("preload", true)); lua_pushglobaltable(L); lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ lua_pop(L, 1); /* pop global table */ return 1; /* return 'package' table */ }; + +const _luaopen_package = luaopen_package; +export { _luaopen_package as luaopen_package }; diff --git a/src/lobject.js b/src/lobject.js index ae2478ab..f23ac96e 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -1,20 +1,20 @@ -import { - from_userstring, +import { LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPIDIV, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, constant_types, from_userstring, luastring_indexOf, luastring_of, to_jsstring, to_luastring } from './defs.js'; +import { lisdigit, lisprint, lisspace, lisxdigit } from './ljstype.js'; +import { luaG_runerror } from './ldebug.js'; +import { luaD_inctop, luaD_checkstack } from './ldo.js'; +import { lua_State } from './lstate.js'; +import { luaS_bless, luaS_new } from './lstring.js'; +import { Table } from './ltable.js'; +import { LUA_COMPAT_FLOATSTRING, ldexp, lua_integer2str, lua_number2str } from './luaconf.js'; +import { luaV_concat, luaV_imul, luaV_mod, luaV_div, luaV_shiftl, tointeger, tonumber } from './lvm.js'; +import { MAX_INT, luai_nummod, lua_assert } from "./llimits.js"; +import { luaT_trybinTM, TMS } from './ltm.js'; + +const LUA_TPROTO = LUA_NUMTAGS; +const LUA_TDEADKEY = LUA_NUMTAGS + 1; + +const { LUA_NUMTAGS, - LUA_OPADD, - LUA_OPBAND, - LUA_OPBNOT, - LUA_OPBOR, - LUA_OPBXOR, - LUA_OPDIV, - LUA_OPIDIV, - LUA_OPMOD, - LUA_OPMUL, - LUA_OPPOW, - LUA_OPSHL, - LUA_OPSHR, - LUA_OPSUB, - LUA_OPUNM, LUA_TBOOLEAN, LUA_TCCL, LUA_TFUNCTION, @@ -28,43 +28,12 @@ import { LUA_TNUMINT, LUA_TSHRSTR, LUA_TSTRING, - LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, luastring_indexOf, luastring_of, to_jsstring, to_luastring -} from "./defs.js"; -import * as ltm from "./ltm.js"; -import {lua_assert, luai_nummod, MAX_INT} from "./llimits.js"; -import * as lvm from "./lvm.js"; -import {ldexp, LUA_COMPAT_FLOATSTRING, lua_integer2str, lua_number2str} from "./luaconf.js"; -import * as ltable from "./ltable.js"; -import {luaS_bless, luaS_new} from "./lstring.js"; -import * as lstate from "./lstate.js"; -import * as ldo from "./ldo.js"; -import * as ldebug from "./ldebug.js"; -import {lisdigit, lisprint, lisspace, lisxdigit} from "./ljstype.js"; - -const constant_types = { - LUA_NUMTAGS, - LUA_TBOOLEAN, - LUA_TCCL, - LUA_TFUNCTION, - LUA_TLCF, - LUA_TLCL, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMBER, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR, - LUA_TSTRING, - LUA_TTABLE, - LUA_TTHREAD, - LUA_TUSERDATA -} + LUA_TTABLE, + LUA_TTHREAD, + LUA_TUSERDATA +} = constant_types; -const LUA_TPROTO = LUA_NUMTAGS; -const LUA_TDEADKEY = LUA_NUMTAGS+1; - -export class TValue { +class TValue { constructor(type, value) { this.type = type; @@ -263,26 +232,28 @@ export class TValue { } } -export const pushobj2s = function(L, tv) { +const pushobj2s = function (L, tv) { L.stack[L.top++] = new TValue(tv.type, tv.value); }; -export const pushsvalue2s = function(L, ts) { +const pushsvalue2s = function (L, ts) { L.stack[L.top++] = new TValue(LUA_TLNGSTR, ts); }; /* from stack to (same) stack */ -export const setobjs2s = function(L, newidx, oldidx) { +const setobjs2s = function (L, newidx, oldidx) { L.stack[newidx].setfrom(L.stack[oldidx]); }; /* to stack (not from same stack) */ -export const setobj2s = function(L, newidx, oldtv) { +const setobj2s = function (L, newidx, oldtv) { L.stack[newidx].setfrom(oldtv); }; -const setsvalue2s = function(L, newidx, ts) { +const setsvalue2s = function (L, newidx, ts) { L.stack[newidx].setsvalue(ts); }; -export const luaO_nilobject = new TValue(LUA_TNIL, null); +const luaO_nilobject = new TValue(LUA_TNIL, null); Object.freeze(luaO_nilobject); +const _luaO_nilobject = luaO_nilobject; +export { _luaO_nilobject as luaO_nilobject }; class LClosure { @@ -296,7 +267,7 @@ class LClosure { } -export class CClosure { +class CClosure { constructor(L, f, n) { this.id = L.l_G.id_counter++; @@ -311,7 +282,7 @@ export class CClosure { } -export class Udata { +class Udata { constructor(L, size) { this.id = L.l_G.id_counter++; @@ -336,24 +307,24 @@ class LocVar { } } -const RETS = to_luastring('...'); -const PRE = to_luastring('[string "'); -const POS = to_luastring('"]'); +const RETS = to_luastring("..."); +const PRE = to_luastring("[string \""); +const POS = to_luastring("\"]"); -const luaO_chunkid = function(source, bufflen) { +const luaO_chunkid = function (source, bufflen) { let l = source.length; let out; if (source[0] === 61 /* ('=').charCodeAt(0) */) { /* 'literal' source */ if (l < bufflen) { /* small enough? */ - out = new Uint8Array(l-1); + out = new Uint8Array(l - 1); out.set(source.subarray(1)); } else { /* truncate it */ out = new Uint8Array(bufflen); - out.set(source.subarray(1, bufflen+1)); + out.set(source.subarray(1, bufflen + 1)); } } else if (source[0] === 64 /* ('@').charCodeAt(0) */) { /* file name */ if (l <= bufflen) { /* small enough? */ - out = new Uint8Array(l-1); + out = new Uint8Array(l - 1); out.set(source.subarray(1)); } else { /* add '...' before rest of name */ out = new Uint8Array(bufflen); @@ -385,14 +356,14 @@ const luaO_chunkid = function(source, bufflen) { return out; }; -const luaO_hexavalue = function(c) { +const luaO_hexavalue = function (c) { if (lisdigit(c)) return c - 48; else return (c & 0xdf) - 55; }; const UTF8BUFFSZ = 8; -const luaO_utf8esc = function(buff, x) { +const luaO_utf8esc = function (buff, x) { let n = 1; /* number of bytes put in buffer (backwards) */ lua_assert(x <= 0x10FFFF); if (x < 0x80) /* ascii? */ @@ -417,7 +388,7 @@ const MAXSIGDIG = 30; ** convert an hexadecimal numeric string to a number, following ** C99 specification for 'strtod' */ -const lua_strx2number = function(s) { +const lua_strx2number = function (s) { let i = 0; let r = 0.0; /* result (accumulator) */ let sigdig = 0; /* number of significant digits */ @@ -428,7 +399,7 @@ const lua_strx2number = function(s) { while (lisspace(s[i])) i++; /* skip initial spaces */ if ((neg = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++; /* check signal */ else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++; - if (!(s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i+1] === 120 /* ('x').charCodeAt(0) */ || s[i+1] === 88 /* ('X').charCodeAt(0) */))) /* check '0x' */ + if (!(s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i + 1] === 120 /* ('x').charCodeAt(0) */ || s[i + 1] === 88 /* ('X').charCodeAt(0) */))) /* check '0x' */ return null; /* invalid format (no '0x') */ for (i += 2; ; i++) { /* skip '0x' and read numeral */ if (s[i] === 46 /* ('.').charCodeAt(0) i.e. dot/lua_getlocaledecpoint(); */) { @@ -467,7 +438,7 @@ const lua_strx2number = function(s) { }; }; -const lua_str2number = function(s) { +const lua_str2number = function (s) { try { s = to_jsstring(s); } catch (e) { @@ -482,7 +453,7 @@ const lua_str2number = function(s) { return !isNaN(flt) ? { n: flt, i: r[0].length } : null; }; -const l_str2dloc = function(s, mode) { +const l_str2dloc = function (s, mode) { let result = mode === 'x' ? lua_strx2number(s) : lua_str2number(s); /* try to convert */ if (result === null) return null; while (lisspace(s[result.i])) result.i++; /* skip trailing spaces */ @@ -497,16 +468,16 @@ const SIGILS = [ 78 /* ("N").charCodeAt(0) */ ]; const modes = { - [ 46]: '.', - [120]: 'x', - [ 88]: 'x', - [110]: 'n', - [ 78]: 'n' + [46]: ".", + [120]: "x", + [88]: "x", + [110]: "n", + [78]: "n" }; -const l_str2d = function(s) { +const l_str2d = function (s) { let l = s.length; let pmode = 0; - for (let i=0; i= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */ return null; /* do not accept it (as integer) */ - a = (a * 10 + d)|0; + a = (a * 10 + d) | 0; empty = false; } } @@ -554,28 +525,28 @@ const l_str2int = function(s) { if (empty || (i !== s.length && s[i] !== 0)) return null; /* something wrong in the numeral */ else { return { - n: (neg ? -a : a)|0, + n: (neg ? -a : a) | 0, i: i }; } }; -export const luaO_str2num = function(s, o) { +const luaO_str2num = function (s, o) { let s2i = l_str2int(s); if (s2i !== null) { /* try as an integer */ o.setivalue(s2i.n); - return s2i.i+1; + return s2i.i + 1; } else { /* else try as a float */ s2i = l_str2d(s); if (s2i !== null) { o.setfltvalue(s2i.n); - return s2i.i+1; + return s2i.i + 1; } else return 0; /* conversion failed */ } }; -export const luaO_tostring = function(L, obj) { +const luaO_tostring = function (L, obj) { let buff; if (obj.ttisinteger()) buff = to_luastring(lua_integer2str(obj.value)); @@ -589,24 +560,24 @@ export const luaO_tostring = function(L, obj) { obj.setsvalue(luaS_bless(L, buff)); }; -const pushstr = function(L, str) { - ldo.luaD_inctop(L); - setsvalue2s(L, L.top-1, luaS_new(L, str)); +const pushstr = function (L, str) { + luaD_inctop(L); + setsvalue2s(L, L.top - 1, luaS_new(L, str)); }; -export const luaO_pushvfstring = function(L, fmt, argp) { +const luaO_pushvfstring = function (L, fmt, argp) { let n = 0; let i = 0; let a = 0; let e; - for (;;) { + for (; ;) { e = luastring_indexOf(fmt, 37 /* ('%').charCodeAt(0) */, i); if (e == -1) break; pushstr(L, fmt.subarray(i, e)); - switch(fmt[e+1]) { + switch (fmt[e + 1]) { case 115 /* ('s').charCodeAt(0) */: { let s = argp[a++]; - if (s === null) s = to_luastring('(null)', true); + if (s === null) s = to_luastring("(null)", true); else { s = from_userstring(s); /* respect null terminator */ @@ -622,60 +593,60 @@ export const luaO_pushvfstring = function(L, fmt, argp) { if (lisprint(buff)) pushstr(L, luastring_of(buff)); else - luaO_pushfstring(L, to_luastring('<\\%d>', true), buff); + luaO_pushfstring(L, to_luastring("<\\%d>", true), buff); break; } case 100 /* ('d').charCodeAt(0) */: case 73 /* ('I').charCodeAt(0) */: - ldo.luaD_inctop(L); - L.stack[L.top-1].setivalue(argp[a++]); - luaO_tostring(L, L.stack[L.top-1]); + luaD_inctop(L); + L.stack[L.top - 1].setivalue(argp[a++]); + luaO_tostring(L, L.stack[L.top - 1]); break; case 102 /* ('f').charCodeAt(0) */: - ldo.luaD_inctop(L); - L.stack[L.top-1].setfltvalue(argp[a++]); - luaO_tostring(L, L.stack[L.top-1]); + luaD_inctop(L); + L.stack[L.top - 1].setfltvalue(argp[a++]); + luaO_tostring(L, L.stack[L.top - 1]); break; case 112 /* ('p').charCodeAt(0) */: { let v = argp[a++]; - if (v instanceof lstate.lua_State || - v instanceof ltable.Table || + if (v instanceof lua_State || + v instanceof Table || v instanceof Udata || v instanceof LClosure || v instanceof CClosure) { - pushstr(L, to_luastring('0x'+v.id.toString(16))); + pushstr(L, to_luastring("0x" + v.id.toString(16))); } else { - switch(typeof v) { - case 'undefined': - pushstr(L, to_luastring('undefined')); + switch (typeof v) { + case "undefined": + pushstr(L, to_luastring("undefined")); break; - case 'number': /* before check object as null is an object */ - pushstr(L, to_luastring('Number('+v+')')); + case "number": /* before check object as null is an object */ + pushstr(L, to_luastring("Number(" + v + ")")); break; - case 'string': /* before check object as null is an object */ - pushstr(L, to_luastring('String('+JSON.stringify(v)+')')); + case "string": /* before check object as null is an object */ + pushstr(L, to_luastring("String(" + JSON.stringify(v) + ")")); break; - case 'boolean': /* before check object as null is an object */ - pushstr(L, to_luastring(v?'Boolean(true)':'Boolean(false)')); + case "boolean": /* before check object as null is an object */ + pushstr(L, to_luastring(v ? "Boolean(true)" : "Boolean(false)")); break; - case 'object': + case "object": if (v === null) { /* null is special */ - pushstr(L, to_luastring('null')); + pushstr(L, to_luastring("null")); break; } - /* fall through */ - case 'function': { + /* fall through */ + case "function": { let id = L.l_G.ids.get(v); if (!id) { id = L.l_G.id_counter++; L.l_G.ids.set(v, id); } - pushstr(L, to_luastring('0x'+id.toString(16))); + pushstr(L, to_luastring("0x" + id.toString(16))); break; } default: /* user provided object. no id available */ - pushstr(L, to_luastring('')); + pushstr(L, to_luastring("")); } } break; @@ -687,21 +658,21 @@ export const luaO_pushvfstring = function(L, fmt, argp) { break; } case 37 /* ('%').charCodeAt(0) */: - pushstr(L, to_luastring('%', true)); + pushstr(L, to_luastring("%", true)); break; default: - ldebug.luaG_runerror(L, to_luastring('invalid option \'%%%c\' to \'lua_pushfstring\''), fmt[e + 1]); + luaG_runerror(L, to_luastring("invalid option '%%%c' to 'lua_pushfstring'"), fmt[e + 1]); } n += 2; i = e + 2; } - ldo.luaD_checkstack(L, 1); + luaD_checkstack(L, 1); pushstr(L, fmt.subarray(i)); - if (n > 0) lvm.luaV_concat(L, n+1); - return L.stack[L.top-1].svalue(); + if (n > 0) luaV_concat(L, n + 1); + return L.stack[L.top - 1].svalue(); }; -const luaO_pushfstring = function(L, fmt, ...argp) { +const luaO_pushfstring = function (L, fmt, ...argp) { return luaO_pushvfstring(L, fmt, argp); }; @@ -711,7 +682,7 @@ const luaO_pushfstring = function(L, fmt, ...argp) { ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if ** eeeee !== 0 and (xxx) otherwise. */ -const luaO_int2fb = function(x) { +const luaO_int2fb = function (x) { let e = 0; /* exponent */ if (x < 8) return x; while (x >= (8 << 4)) { /* coarse steps */ @@ -722,51 +693,51 @@ const luaO_int2fb = function(x) { x = (x + 1) >> 1; /* x = ceil(x / 2) */ e++; } - return ((e+1) << 3) | (x - 8); + return ((e + 1) << 3) | (x - 8); }; -const intarith = function(L, op, v1, v2) { +const intarith = function (L, op, v1, v2) { switch (op) { - case LUA_OPADD: return (v1 + v2)|0; - case LUA_OPSUB: return (v1 - v2)|0; - case LUA_OPMUL: return lvm.luaV_imul(v1, v2); - case LUA_OPMOD: return lvm.luaV_mod(L, v1, v2); - case LUA_OPIDIV: return lvm.luaV_div(L, v1, v2); + case LUA_OPADD: return (v1 + v2) | 0; + case LUA_OPSUB: return (v1 - v2) | 0; + case LUA_OPMUL: return luaV_imul(v1, v2); + case LUA_OPMOD: return luaV_mod(L, v1, v2); + case LUA_OPIDIV: return luaV_div(L, v1, v2); case LUA_OPBAND: return (v1 & v2); - case LUA_OPBOR: return (v1 | v2); + case LUA_OPBOR: return (v1 | v2); case LUA_OPBXOR: return (v1 ^ v2); - case LUA_OPSHL: return lvm.luaV_shiftl(v1, v2); - case LUA_OPSHR: return lvm.luaV_shiftl(v1, -v2); - case LUA_OPUNM: return (0 - v1)|0; + case LUA_OPSHL: return luaV_shiftl(v1, v2); + case LUA_OPSHR: return luaV_shiftl(v1, -v2); + case LUA_OPUNM: return (0 - v1) | 0; case LUA_OPBNOT: return (~0 ^ v1); default: lua_assert(0); } }; -const numarith = function(L, op, v1, v2) { +const numarith = function (L, op, v1, v2) { switch (op) { - case LUA_OPADD: return v1 + v2; - case LUA_OPSUB: return v1 - v2; - case LUA_OPMUL: return v1 * v2; - case LUA_OPDIV: return v1 / v2; - case LUA_OPPOW: return Math.pow(v1, v2); + case LUA_OPADD: return v1 + v2; + case LUA_OPSUB: return v1 - v2; + case LUA_OPMUL: return v1 * v2; + case LUA_OPDIV: return v1 / v2; + case LUA_OPPOW: return Math.pow(v1, v2); case LUA_OPIDIV: return Math.floor(v1 / v2); - case LUA_OPUNM: return -v1; - case LUA_OPMOD: return luai_nummod(L, v1, v2); + case LUA_OPUNM: return -v1; + case LUA_OPMOD: return luai_nummod(L, v1, v2); default: lua_assert(0); } }; -export const luaO_arith = function(L, op, p1, p2, p3) { - let res = (typeof p3 === 'number') ? L.stack[p3] : p3; /* FIXME */ +const luaO_arith = function (L, op, p1, p2, p3) { + let res = (typeof p3 === "number") ? L.stack[p3] : p3; /* FIXME */ switch (op) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* operate only on integers */ let i1, i2; - if ((i1 = lvm.tointeger(p1)) !== false && (i2 = lvm.tointeger(p2)) !== false) { + if ((i1 = tointeger(p1)) !== false && (i2 = tointeger(p2)) !== false) { res.setivalue(intarith(L, op, i1, i2)); return; } @@ -774,7 +745,7 @@ export const luaO_arith = function(L, op, p1, p2, p3) { } case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */ let n1, n2; - if ((n1 = lvm.tonumber(p1)) !== false && (n2 = lvm.tonumber(p2)) !== false) { + if ((n1 = tonumber(p1)) !== false && (n2 = tonumber(p2)) !== false) { res.setfltvalue(numarith(L, op, n1, n2)); return; } @@ -786,7 +757,7 @@ export const luaO_arith = function(L, op, p1, p2, p3) { res.setivalue(intarith(L, op, p1.value, p2.value)); return; } - else if ((n1 = lvm.tonumber(p1)) !== false && (n2 = lvm.tonumber(p2)) !== false) { + else if ((n1 = tonumber(p1)) !== false && (n2 = tonumber(p2)) !== false) { res.setfltvalue(numarith(L, op, n1, n2)); return; } @@ -795,5 +766,53 @@ export const luaO_arith = function(L, op, p1, p2, p3) { } /* could not perform raw operation; try metamethod */ lua_assert(L !== null); /* should not fail when folding (compile time) */ - ltm.luaT_trybinTM(L, p1, p2, p3, (op - LUA_OPADD) + ltm.TMS.TM_ADD); + luaT_trybinTM(L, p1, p2, p3, (op - LUA_OPADD) + TMS.TM_ADD); }; + + +const _CClosure = CClosure; +export { _CClosure as CClosure }; +const _LClosure = LClosure; +export { _LClosure as LClosure }; +const _LUA_TDEADKEY = LUA_TDEADKEY; +export { _LUA_TDEADKEY as LUA_TDEADKEY }; +const _LUA_TPROTO = LUA_TPROTO; +export { _LUA_TPROTO as LUA_TPROTO }; +const _LocVar = LocVar; +export { _LocVar as LocVar }; +const _TValue = TValue; +export { _TValue as TValue }; +const _Udata = Udata; +export { _Udata as Udata }; +const _UTF8BUFFSZ = UTF8BUFFSZ; +export { _UTF8BUFFSZ as UTF8BUFFSZ }; +const _luaO_arith = luaO_arith; +export { _luaO_arith as luaO_arith }; +const _luaO_chunkid = luaO_chunkid; +export { _luaO_chunkid as luaO_chunkid }; +const _luaO_hexavalue = luaO_hexavalue; +export { _luaO_hexavalue as luaO_hexavalue }; +const _luaO_int2fb = luaO_int2fb; +export { _luaO_int2fb as luaO_int2fb }; +const _luaO_pushfstring = luaO_pushfstring; +export { _luaO_pushfstring as luaO_pushfstring }; +const _luaO_pushvfstring = luaO_pushvfstring; +export { _luaO_pushvfstring as luaO_pushvfstring }; +const _luaO_str2num = luaO_str2num; +export { _luaO_str2num as luaO_str2num }; +const _luaO_tostring = luaO_tostring; +export { _luaO_tostring as luaO_tostring }; +const _luaO_utf8esc = luaO_utf8esc; +export { _luaO_utf8esc as luaO_utf8esc }; +const _numarith = numarith; +export { _numarith as numarith }; +const _pushobj2s = pushobj2s; +export { _pushobj2s as pushobj2s }; +const _pushsvalue2s = pushsvalue2s; +export { _pushsvalue2s as pushsvalue2s }; +const _setobjs2s = setobjs2s; +export { _setobjs2s as setobjs2s }; +const _setobj2s = setobj2s; +export { _setobj2s as setobj2s }; +const _setsvalue2s = setsvalue2s; +export { _setsvalue2s as setsvalue2s }; diff --git a/src/lopcodes.js b/src/lopcodes.js index 099e5b3a..50faed38 100644 --- a/src/lopcodes.js +++ b/src/lopcodes.js @@ -1,59 +1,59 @@ const OpCodes = [ - 'MOVE', - 'LOADK', - 'LOADKX', - 'LOADBOOL', - 'LOADNIL', - 'GETUPVAL', - 'GETTABUP', - 'GETTABLE', - 'SETTABUP', - 'SETUPVAL', - 'SETTABLE', - 'NEWTABLE', - 'SELF', - 'ADD', - 'SUB', - 'MUL', - 'MOD', - 'POW', - 'DIV', - 'IDIV', - 'BAND', - 'BOR', - 'BXOR', - 'SHL', - 'SHR', - 'UNM', - 'BNOT', - 'NOT', - 'LEN', - 'CONCAT', - 'JMP', - 'EQ', - 'LT', - 'LE', - 'TEST', - 'TESTSET', - 'CALL', - 'TAILCALL', - 'RETURN', - 'FORLOOP', - 'FORPREP', - 'TFORCALL', - 'TFORLOOP', - 'SETLIST', - 'CLOSURE', - 'VARARG', - 'EXTRAARG' + "MOVE", + "LOADK", + "LOADKX", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETTABUP", + "GETTABLE", + "SETTABUP", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "MOD", + "POW", + "DIV", + "IDIV", + "BAND", + "BOR", + "BXOR", + "SHL", + "SHR", + "UNM", + "BNOT", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORCALL", + "TFORLOOP", + "SETLIST", + "CLOSURE", + "VARARG", + "EXTRAARG" ]; -export const OpCodesI = { - OP_MOVE: 0, - OP_LOADK: 1, - OP_LOADKX: 2, +const OpCodesI = { + OP_MOVE: 0, + OP_LOADK: 1, + OP_LOADKX: 2, OP_LOADBOOL: 3, - OP_LOADNIL: 4, + OP_LOADNIL: 4, OP_GETUPVAL: 5, OP_GETTABUP: 6, OP_GETTABLE: 7, @@ -61,40 +61,40 @@ export const OpCodesI = { OP_SETUPVAL: 9, OP_SETTABLE: 10, OP_NEWTABLE: 11, - OP_SELF: 12, - OP_ADD: 13, - OP_SUB: 14, - OP_MUL: 15, - OP_MOD: 16, - OP_POW: 17, - OP_DIV: 18, - OP_IDIV: 19, - OP_BAND: 20, - OP_BOR: 21, - OP_BXOR: 22, - OP_SHL: 23, - OP_SHR: 24, - OP_UNM: 25, - OP_BNOT: 26, - OP_NOT: 27, - OP_LEN: 28, - OP_CONCAT: 29, - OP_JMP: 30, - OP_EQ: 31, - OP_LT: 32, - OP_LE: 33, - OP_TEST: 34, - OP_TESTSET: 35, - OP_CALL: 36, + OP_SELF: 12, + OP_ADD: 13, + OP_SUB: 14, + OP_MUL: 15, + OP_MOD: 16, + OP_POW: 17, + OP_DIV: 18, + OP_IDIV: 19, + OP_BAND: 20, + OP_BOR: 21, + OP_BXOR: 22, + OP_SHL: 23, + OP_SHR: 24, + OP_UNM: 25, + OP_BNOT: 26, + OP_NOT: 27, + OP_LEN: 28, + OP_CONCAT: 29, + OP_JMP: 30, + OP_EQ: 31, + OP_LT: 32, + OP_LE: 33, + OP_TEST: 34, + OP_TESTSET: 35, + OP_CALL: 36, OP_TAILCALL: 37, - OP_RETURN: 38, - OP_FORLOOP: 39, - OP_FORPREP: 40, + OP_RETURN: 38, + OP_FORLOOP: 39, + OP_FORPREP: 40, OP_TFORCALL: 41, OP_TFORLOOP: 42, - OP_SETLIST: 43, - OP_CLOSURE: 44, - OP_VARARG: 45, + OP_SETLIST: 43, + OP_CLOSURE: 44, + OP_VARARG: 45, OP_EXTRAARG: 46 }; @@ -112,10 +112,10 @@ const OpArgR = 2; /* argument is a register or a jump offset */ const OpArgK = 3; /* argument is a constant or register/constant */ /* basic instruction format */ -const iABC = 0; -const iABx = 1; +const iABC = 0; +const iABx = 1; const iAsBx = 2; -const iAx = 3; +const iAx = 3; const luaP_opmodes = [ 0 << 7 | 1 << 6 | OpArgR << 4 | OpArgN << 2 | iABC, /* OP_MOVE */ @@ -167,182 +167,299 @@ const luaP_opmodes = [ 0 << 7 | 0 << 6 | OpArgU << 4 | OpArgU << 2 | iAx /* OP_EXTRAARG */ ]; -const getOpMode = function(m) { +const getOpMode = function (m) { return luaP_opmodes[m] & 3; }; -const getBMode = function(m) { +const getBMode = function (m) { return (luaP_opmodes[m] >> 4) & 3; }; -const getCMode = function(m) { +const getCMode = function (m) { return (luaP_opmodes[m] >> 2) & 3; }; -const testAMode = function(m) { +const testAMode = function (m) { return luaP_opmodes[m] & (1 << 6); }; -const testTMode = function(m) { +const testTMode = function (m) { return luaP_opmodes[m] & (1 << 7); }; -const SIZE_C = 9; -const SIZE_B = 9; -const SIZE_Bx = (SIZE_C + SIZE_B); -const SIZE_A = 8; -const SIZE_Ax = (SIZE_C + SIZE_B + SIZE_A); -const SIZE_OP = 6; -const POS_OP = 0; -const POS_A = (POS_OP + SIZE_OP); -const POS_C = (POS_A + SIZE_A); -const POS_B = (POS_C + SIZE_C); -const POS_Bx = POS_C; -const POS_Ax = POS_A; -const MAXARG_Bx = ((1 << SIZE_Bx) - 1); +const SIZE_C = 9; +const SIZE_B = 9; +const SIZE_Bx = (SIZE_C + SIZE_B); +const SIZE_A = 8; +const SIZE_Ax = (SIZE_C + SIZE_B + SIZE_A); +const SIZE_OP = 6; +const POS_OP = 0; +const POS_A = (POS_OP + SIZE_OP); +const POS_C = (POS_A + SIZE_A); +const POS_B = (POS_C + SIZE_C); +const POS_Bx = POS_C; +const POS_Ax = POS_A; +const MAXARG_Bx = ((1 << SIZE_Bx) - 1); const MAXARG_sBx = (MAXARG_Bx >> 1); /* 'sBx' is signed */ -const MAXARG_Ax = ((1<> POS_OP) & MASK1(SIZE_OP, 0), - A: (ins >> POS_A) & MASK1(SIZE_A, 0), - B: (ins >> POS_B) & MASK1(SIZE_B, 0), - C: (ins >> POS_C) & MASK1(SIZE_C, 0), - Bx: (ins >> POS_Bx) & MASK1(SIZE_Bx, 0), - Ax: (ins >> POS_Ax) & MASK1(SIZE_Ax, 0), - sBx: ((ins >> POS_Bx) & MASK1(SIZE_Bx, 0)) - MAXARG_sBx + A: (ins >> POS_A) & MASK1(SIZE_A, 0), + B: (ins >> POS_B) & MASK1(SIZE_B, 0), + C: (ins >> POS_C) & MASK1(SIZE_C, 0), + Bx: (ins >> POS_Bx) & MASK1(SIZE_Bx, 0), + Ax: (ins >> POS_Ax) & MASK1(SIZE_Ax, 0), + sBx: ((ins >> POS_Bx) & MASK1(SIZE_Bx, 0)) - MAXARG_sBx }; } else { let i = ins.code; ins.opcode = (i >> POS_OP) & MASK1(SIZE_OP, 0); - ins.A = (i >> POS_A) & MASK1(SIZE_A, 0); - ins.B = (i >> POS_B) & MASK1(SIZE_B, 0); - ins.C = (i >> POS_C) & MASK1(SIZE_C, 0); - ins.Bx = (i >> POS_Bx) & MASK1(SIZE_Bx, 0); - ins.Ax = (i >> POS_Ax) & MASK1(SIZE_Ax, 0); - ins.sBx = ((i >> POS_Bx) & MASK1(SIZE_Bx, 0)) - MAXARG_sBx; + ins.A = (i >> POS_A) & MASK1(SIZE_A, 0); + ins.B = (i >> POS_B) & MASK1(SIZE_B, 0); + ins.C = (i >> POS_C) & MASK1(SIZE_C, 0); + ins.Bx = (i >> POS_Bx) & MASK1(SIZE_Bx, 0); + ins.Ax = (i >> POS_Ax) & MASK1(SIZE_Ax, 0); + ins.sBx = ((i >> POS_Bx) & MASK1(SIZE_Bx, 0)) - MAXARG_sBx; return ins; } }; -const CREATE_ABC = function(o, a, b, c) { +const CREATE_ABC = function (o, a, b, c) { return fullins(o << POS_OP | a << POS_A | b << POS_B | c << POS_C); }; -const CREATE_ABx = function(o, a, bc) { +const CREATE_ABx = function (o, a, bc) { return fullins(o << POS_OP | a << POS_A | bc << POS_Bx); }; -const CREATE_Ax = function(o, a) { +const CREATE_Ax = function (o, a) { return fullins(o << POS_OP | a << POS_Ax); }; /* number of list items to accumulate before a SETLIST instruction */ -export const LFIELDS_PER_FLUSH = 50; +const LFIELDS_PER_FLUSH = 50; + +const _BITRK = BITRK; +export { _BITRK as BITRK }; +const _CREATE_ABC = CREATE_ABC; +export { _CREATE_ABC as CREATE_ABC }; +const _CREATE_ABx = CREATE_ABx; +export { _CREATE_ABx as CREATE_ABx }; +const _CREATE_Ax = CREATE_Ax; +export { _CREATE_Ax as CREATE_Ax }; +const _GET_OPCODE = GET_OPCODE; +export { _GET_OPCODE as GET_OPCODE }; +const _GETARG_A = GETARG_A; +export { _GETARG_A as GETARG_A }; +const _GETARG_B = GETARG_B; +export { _GETARG_B as GETARG_B }; +const _GETARG_C = GETARG_C; +export { _GETARG_C as GETARG_C }; +const _GETARG_Bx = GETARG_Bx; +export { _GETARG_Bx as GETARG_Bx }; +const _GETARG_Ax = GETARG_Ax; +export { _GETARG_Ax as GETARG_Ax }; +const _GETARG_sBx = GETARG_sBx; +export { _GETARG_sBx as GETARG_sBx }; +const _INDEXK = INDEXK; +export { _INDEXK as INDEXK }; +const _ISK = ISK; +export { _ISK as ISK }; +const _LFIELDS_PER_FLUSH = LFIELDS_PER_FLUSH; +export { _LFIELDS_PER_FLUSH as LFIELDS_PER_FLUSH }; +const _MAXARG_A = MAXARG_A; +export { _MAXARG_A as MAXARG_A }; +const _MAXARG_Ax = MAXARG_Ax; +export { _MAXARG_Ax as MAXARG_Ax }; +const _MAXARG_B = MAXARG_B; +export { _MAXARG_B as MAXARG_B }; +const _MAXARG_Bx = MAXARG_Bx; +export { _MAXARG_Bx as MAXARG_Bx }; +const _MAXARG_C = MAXARG_C; +export { _MAXARG_C as MAXARG_C }; +const _MAXARG_sBx = MAXARG_sBx; +export { _MAXARG_sBx as MAXARG_sBx }; +const _MAXINDEXRK = MAXINDEXRK; +export { _MAXINDEXRK as MAXINDEXRK }; +const _NO_REG = NO_REG; +export { _NO_REG as NO_REG }; +const _OpArgK = OpArgK; +export { _OpArgK as OpArgK }; +const _OpArgN = OpArgN; +export { _OpArgN as OpArgN }; +const _OpArgR = OpArgR; +export { _OpArgR as OpArgR }; +const _OpArgU = OpArgU; +export { _OpArgU as OpArgU }; +const _OpCodes = OpCodes; +export { _OpCodes as OpCodes }; +const _OpCodesI = OpCodesI; +export { _OpCodesI as OpCodesI }; +const _POS_A = POS_A; +export { _POS_A as POS_A }; +const _POS_Ax = POS_Ax; +export { _POS_Ax as POS_Ax }; +const _POS_B = POS_B; +export { _POS_B as POS_B }; +const _POS_Bx = POS_Bx; +export { _POS_Bx as POS_Bx }; +const _POS_C = POS_C; +export { _POS_C as POS_C }; +const _POS_OP = POS_OP; +export { _POS_OP as POS_OP }; +const _RKASK = RKASK; +export { _RKASK as RKASK }; +const _SETARG_A = SETARG_A; +export { _SETARG_A as SETARG_A }; +const _SETARG_Ax = SETARG_Ax; +export { _SETARG_Ax as SETARG_Ax }; +const _SETARG_B = SETARG_B; +export { _SETARG_B as SETARG_B }; +const _SETARG_Bx = SETARG_Bx; +export { _SETARG_Bx as SETARG_Bx }; +const _SETARG_C = SETARG_C; +export { _SETARG_C as SETARG_C }; +const _SETARG_sBx = SETARG_sBx; +export { _SETARG_sBx as SETARG_sBx }; +const _SET_OPCODE = SET_OPCODE; +export { _SET_OPCODE as SET_OPCODE }; +const _SIZE_A = SIZE_A; +export { _SIZE_A as SIZE_A }; +const _SIZE_Ax = SIZE_Ax; +export { _SIZE_Ax as SIZE_Ax }; +const _SIZE_B = SIZE_B; +export { _SIZE_B as SIZE_B }; +const _SIZE_Bx = SIZE_Bx; +export { _SIZE_Bx as SIZE_Bx }; +const _SIZE_C = SIZE_C; +export { _SIZE_C as SIZE_C }; +const _SIZE_OP = SIZE_OP; +export { _SIZE_OP as SIZE_OP }; +const _fullins = fullins; +export { _fullins as fullins }; +const _getBMode = getBMode; +export { _getBMode as getBMode }; +const _getCMode = getCMode; +export { _getCMode as getCMode }; +const _getOpMode = getOpMode; +export { _getOpMode as getOpMode }; +const _iABC = iABC; +export { _iABC as iABC }; +const _iABx = iABx; +export { _iABx as iABx }; +const _iAsBx = iAsBx; +export { _iAsBx as iAsBx }; +const _iAx = iAx; +export { _iAx as iAx }; +const _testAMode = testAMode; +export { _testAMode as testAMode }; +const _testTMode = testTMode; +export { _testTMode as testTMode }; diff --git a/src/loslib.js b/src/loslib.js index f8b8260e..b318de51 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -1,26 +1,8 @@ -import { - lua_close, - lua_createtable, - lua_getfield, - lua_isboolean, - lua_isnoneornil, - lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, - lua_pushstring, lua_setfield, lua_settop, - LUA_TNIL, lua_toboolean, lua_tointegerx, - LUA_TTABLE -} from "./lua.js"; -import { - luaL_addchar, - luaL_addstring, - luaL_argerror, - luaL_Buffer, - luaL_buffinit, - luaL_checkinteger, - luaL_checkoption, luaL_checkstring, luaL_checktype, luaL_error, luaL_execresult, luaL_fileresult, luaL_newlib, - luaL_optinteger, luaL_optlstring, luaL_optstring, luaL_pushresult -} from "./lauxlib.js"; -import {luastring_eq, to_jsstring, to_luastring} from "./fengaricore.js"; +"use strict"; +import { LUA_TNIL, LUA_TTABLE, lua_close, lua_createtable, lua_getfield, lua_isboolean, lua_isnoneornil, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushstring, lua_setfield, lua_settop, lua_toboolean, lua_tointegerx } from './lua.js'; +import { luaL_Buffer, luaL_addchar, luaL_addstring, luaL_argerror, luaL_buffinit, luaL_checkinteger, luaL_checkoption, luaL_checkstring, luaL_checktype, luaL_error, luaL_execresult, luaL_fileresult, luaL_newlib, luaL_optinteger, luaL_optlstring, luaL_optstring, luaL_pushresult } from './lauxlib.js'; +import { luastring_eq, to_jsstring, to_luastring } from "./fengaricore.js"; /* options for ANSI C 89 (only 1-char options) */ // const L_STRFTIMEC89 = to_luastring("aAbBcdHIjmMpSUwWxXyYZ%"); @@ -44,7 +26,7 @@ import {luastring_eq, to_jsstring, to_luastring} from "./fengaricore.js"; - %l: TZ extension: space-padded 12-hour - %P: GNU extension: lower-case am/pm */ -const LUA_STRFTIMEOPTIONS = to_luastring('aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%'); +const LUA_STRFTIMEOPTIONS = to_luastring("aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%"); const setfield = function(L, key, value) { @@ -53,14 +35,14 @@ const setfield = function(L, key, value) { }; const setallfields = function(L, time, utc) { - setfield(L, 'sec', utc ? time.getUTCSeconds() : time.getSeconds()); - setfield(L, 'min', utc ? time.getUTCMinutes() : time.getMinutes()); - setfield(L, 'hour', utc ? time.getUTCHours() : time.getHours()); - setfield(L, 'day', utc ? time.getUTCDate() : time.getDate()); - setfield(L, 'month', (utc ? time.getUTCMonth() : time.getMonth()) + 1); - setfield(L, 'year', utc ? time.getUTCFullYear() : time.getFullYear()); - setfield(L, 'wday', (utc ? time.getUTCDay() : time.getDay()) + 1); - setfield(L, 'yday', Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); + setfield(L, "sec", utc ? time.getUTCSeconds() : time.getSeconds()); + setfield(L, "min", utc ? time.getUTCMinutes() : time.getMinutes()); + setfield(L, "hour", utc ? time.getUTCHours() : time.getHours()); + setfield(L, "day", utc ? time.getUTCDate() : time.getDate()); + setfield(L, "month", (utc ? time.getUTCMonth() : time.getMonth()) + 1); + setfield(L, "year", utc ? time.getUTCFullYear() : time.getFullYear()); + setfield(L, "wday", (utc ? time.getUTCDay() : time.getDay()) + 1); + setfield(L, "yday", Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); // setboolfield(L, "isdst", time.get); }; @@ -71,14 +53,14 @@ const getfield = function(L, key, d, delta) { let res = lua_tointegerx(L, -1); if (res === false) { /* field is not an integer? */ if (t !== LUA_TNIL) /* some other value? */ - return luaL_error(L, to_luastring('field \'%s\' is not an integer'), key); + return luaL_error(L, to_luastring("field '%s' is not an integer"), key); else if (d < 0) /* absent field; no default? */ - return luaL_error(L, to_luastring('field \'%s\' missing in date table'), key); + return luaL_error(L, to_luastring("field '%s' missing in date table"), key); res = d; } else { if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) - return luaL_error(L, to_luastring('field \'%s\' is out-of-bound'), key); + return luaL_error(L, to_luastring("field '%s' is out-of-bound"), key); res -= delta; } lua_pop(L, 1); @@ -87,23 +69,23 @@ const getfield = function(L, key, d, delta) { const locale = { - days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ].map((s) => to_luastring(s)), - shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((s) => to_luastring(s)), - months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].map((s) => to_luastring(s)), - shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'].map((s) => to_luastring(s)), - AM: to_luastring('AM'), - PM: to_luastring('PM'), - am: to_luastring('am'), - pm: to_luastring('pm'), + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ].map((s) => to_luastring(s)), + shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].map((s) => to_luastring(s)), + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"].map((s) => to_luastring(s)), + shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map((s) => to_luastring(s)), + AM: to_luastring("AM"), + PM: to_luastring("PM"), + am: to_luastring("am"), + pm: to_luastring("pm"), formats: { - c: to_luastring('%a %b %e %H:%M:%S %Y'), - D: to_luastring('%m/%d/%y'), - F: to_luastring('%Y-%m-%d'), - R: to_luastring('%H:%M'), - r: to_luastring('%I:%M:%S %p'), - T: to_luastring('%H:%M:%S'), - X: to_luastring('%T'), - x: to_luastring('%D') + c: to_luastring("%a %b %e %H:%M:%S %Y"), + D: to_luastring("%m/%d/%y"), + F: to_luastring("%Y-%m-%d"), + R: to_luastring("%H:%M"), + r: to_luastring("%I:%M:%S %p"), + T: to_luastring("%H:%M:%S"), + X: to_luastring("%T"), + x: to_luastring("%D") } }; @@ -204,12 +186,12 @@ const strftime = function(L, b, s, date) { // '00' case 85 /* U */: - push_pad_2(b, week_number(date, 'sunday'), 48 /* 0 */); + push_pad_2(b, week_number(date, "sunday"), 48 /* 0 */); break; // '00' case 87 /* W */: - push_pad_2(b, week_number(date, 'monday'), 48 /* 0 */); + push_pad_2(b, week_number(date, "monday"), 48 /* 0 */); break; // '16:00:00' @@ -362,7 +344,7 @@ const checkoption = function(L, conv, i) { } } luaL_argerror(L, 1, - lua_pushfstring(L, to_luastring('invalid conversion specifier \'%%%s\''), conv)); + lua_pushfstring(L, to_luastring("invalid conversion specifier '%%%s'"), conv)); }; /* maximum size for an individual 'strftime' item */ @@ -370,7 +352,7 @@ const checkoption = function(L, conv, i) { const os_date = function(L) { - let s = luaL_optlstring(L, 1, '%c'); + let s = luaL_optlstring(L, 1, "%c"); let stm = lua_isnoneornil(L, 2) ? new Date() : new Date(l_checktime(L, 2) * 1000); let utc = false; let i = 0; @@ -378,12 +360,12 @@ const os_date = function(L) { utc = true; i++; /* skip '!' */ } - if (s[i] === '*'.charCodeAt(0) && s[i+1] === 't'.charCodeAt(0)) { + if (s[i] === "*".charCodeAt(0) && s[i+1] === "t".charCodeAt(0)) { lua_createtable(L, 0, 9); /* 9 = number of fields */ setallfields(L, stm, utc); } else { let cc = new Uint8Array(4); - cc[0] = '%'.charCodeAt(0); + cc[0] = "%".charCodeAt(0); let b = new luaL_Buffer(); luaL_buffinit(L, b); strftime(L, b, s, stm); @@ -400,12 +382,12 @@ const os_time = function(L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ t = new Date( - getfield(L, 'year', -1, 0), - getfield(L, 'month', -1, 1), - getfield(L, 'day', -1, 0), - getfield(L, 'hour', 12, 0), - getfield(L, 'min', 0, 0), - getfield(L, 'sec', 0, 0) + getfield(L, "year", -1, 0), + getfield(L, "month", -1, 1), + getfield(L, "day", -1, 0), + getfield(L, "hour", 12, 0), + getfield(L, "min", 0, 0), + getfield(L, "sec", 0, 0) ); setallfields(L, t); } @@ -427,12 +409,12 @@ const os_difftime = function(L) { return 1; }; -const catnames = ['all', 'collate', 'ctype', 'monetary', 'numeric', 'time'].map((lc) => to_luastring(lc)); -const C = to_luastring('C'); -const POSIX = to_luastring('POSIX'); +const catnames = ["all", "collate", "ctype", "monetary", "numeric", "time"].map((lc) => to_luastring(lc)); +const C = to_luastring("C"); +const POSIX = to_luastring("POSIX"); const os_setlocale = function(L) { const l = luaL_optstring(L, 1, null); - luaL_checkoption(L, 2, 'all', catnames); + luaL_checkoption(L, 2, "all", catnames); /* It is not possible to set the JS-VM wide locale, so we say that we only know the C locale. The "POSIX" locale is defined in IEEE Std 1003.1-2017 Section 7.2 as equivalent to "C" */ @@ -446,13 +428,13 @@ const os_setlocale = function(L) { }; const syslib = { - 'date': os_date, - 'difftime': os_difftime, - 'setlocale': os_setlocale, - 'time': os_time + "date": os_date, + "difftime": os_difftime, + "setlocale": os_setlocale, + "time": os_time }; -if (typeof process === 'undefined') { +if (typeof process === "undefined") { syslib.clock = function(L) { lua_pushnumber(L, performance.now()/1000); return 1; @@ -527,7 +509,7 @@ if (typeof process === 'undefined') { syslib.tmpname = function(L) { let name = lua_tmpname(); if (!name) - return luaL_error(L, to_luastring('unable to generate a unique filename')); + return luaL_error(L, to_luastring("unable to generate a unique filename")); lua_pushstring(L, to_luastring(name)); return 1; }; @@ -564,4 +546,5 @@ const luaopen_os = function(L) { return 1; }; -module.exports.luaopen_os = luaopen_os; +const _luaopen_os = luaopen_os; +export { _luaopen_os as luaopen_os }; diff --git a/src/lparser.js b/src/lparser.js index 4951e470..151ff58a 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1,32 +1,18 @@ -import {LUA_MULTRET, to_luastring} from "./defs.js"; -import * as ltable from "./ltable.js"; -import {luaS_eqlngstr, luaS_new, luaS_newliteral} from "./lstring.js"; -import { - LFIELDS_PER_FLUSH, - OP_CALL, - OP_CLOSURE, - OP_FORLOOP, - OP_FORPREP, - OP_GETUPVAL, - OP_MOVE, - OP_NEWTABLE, - OP_SETTABLE, OP_TAILCALL, OP_TFORCALL, OP_TFORLOOP, OP_VARARG, SET_OPCODE, SETARG_B, SETARG_C -} from "./lopcodes.js"; -import * as lobject from "./lobject.js"; -import {lua_assert, LUAI_MAXCCALLS, MAX_INT} from "./llimits.js"; -import * as llex from "./llex.js"; -import * as lfunc from "./lfunc.js"; -import * as ldo from "./ldo.js"; -import { - getinstruction, luaK_checkstack, luaK_codeABC, luaK_codeABx, luaK_codeAsBx, luaK_codek, luaK_concat, - luaK_dischargevars, luaK_exp2anyreg, luaK_exp2anyregup, luaK_exp2nextreg, luaK_exp2RK, luaK_exp2val, luaK_fixline, - luaK_getlabel, luaK_goiffalse, luaK_goiftrue, luaK_indexed, luaK_infix, luaK_intK, luaK_jump, luaK_jumpto, luaK_nil, - luaK_patchclose, luaK_patchlist, luaK_patchtohere, luaK_posfix, luaK_prefix, luaK_reserveregs, luaK_ret, luaK_self, - luaK_setlist, luaK_setmultret, luaK_setoneret, luaK_setreturns, luaK_storevar, luaK_stringK, - NO_JUMP, +import { LUA_MULTRET, to_luastring } from './defs.js'; +import { BinOpr, UnOpr, NO_JUMP, getinstruction, luaK_checkstack, luaK_codeABC, luaK_codeABx, luaK_codeAsBx, luaK_codek, luaK_concat, luaK_dischargevars, luaK_exp2RK, luaK_exp2anyreg, luaK_exp2anyregup, luaK_exp2nextreg, luaK_exp2val, luaK_fixline, luaK_getlabel, luaK_goiffalse, luaK_goiftrue, luaK_indexed, luaK_infix, luaK_intK, luaK_jump, luaK_jumpto, luaK_nil, luaK_patchclose, luaK_patchlist, luaK_patchtohere, luaK_posfix, luaK_prefix, luaK_reserveregs, luaK_ret, luaK_self, luaK_setlist, luaK_setmultret, luaK_setoneret, luaK_setreturns, luaK_storevar, luaK_stringK } from './lcode.js'; +import { luaD_inctop } from './ldo.js'; +import { Proto as _Proto, MAXUPVAL, luaF_newLclosure } from './lfunc.js'; +import { RESERVED, luaX_syntaxerror, luaX_token2str, luaX_next, luaX_newstring, isreserved, luaX_lookahead, LexState, luaX_setinput } from './llex.js'; +import { LUAI_MAXCCALLS, MAX_INT, lua_assert } from './llimits.js'; +import { luaO_pushfstring, LocVar, luaO_int2fb } from './lobject.js'; +import { OpCodesI, LFIELDS_PER_FLUSH, SETARG_B, SETARG_C, SET_OPCODE } from './lopcodes.js'; +import { luaS_eqlngstr, luaS_new, luaS_newliteral } from './lstring.js'; +import { luaH_new } from './ltable.js'; + +const { OPR_ADD, OPR_AND, - OPR_BAND, OPR_BNOT, + OPR_BAND, OPR_BOR, OPR_BXOR, OPR_CONCAT, @@ -34,69 +20,53 @@ import { OPR_EQ, OPR_GE, OPR_GT, - OPR_IDIV, OPR_LE, - OPR_LEN, OPR_LT, OPR_MINUS, OPR_MOD, OPR_MUL, OPR_NE, OPR_NOBINOPR, - OPR_NOT, OPR_NOUNOPR, OPR_OR, OPR_POW, OPR_SHL, OPR_SHR, OPR_SUB -} from "./lcode.js"; - -const BinOpr = { - OPR_ADD, - OPR_AND, - OPR_BAND, - OPR_BOR, - OPR_BXOR, - OPR_CONCAT, - OPR_DIV, - OPR_EQ, - OPR_GE, - OPR_GT, - OPR_IDIV, - OPR_LE, - OPR_LT, - OPR_MOD, - OPR_MUL, - OPR_NE, - OPR_NOBINOPR, - OPR_OR, - OPR_POW, - OPR_SHL, - OPR_SHR, - OPR_SUB -} - -const UnOpr = { + OPR_IDIV, + OPR_LE, + OPR_LT, + OPR_MOD, + OPR_MUL, + OPR_NE, + OPR_NOBINOPR, + OPR_OR, + OPR_POW, + OPR_SHL, + OPR_SHR, + OPR_SUB +} = BinOpr; + +const { OPR_BNOT, OPR_LEN, OPR_MINUS, OPR_NOT, OPR_NOUNOPR -}; +} = UnOpr; -const OpCodesI = { +const { OP_CALL, - OP_CLOSURE, - OP_FORLOOP, - OP_FORPREP, - OP_GETUPVAL, - OP_MOVE, - OP_NEWTABLE, - OP_SETTABLE, - OP_TAILCALL, - OP_TFORCALL, - OP_TFORLOOP, - OP_VARARG -}; - -const Proto = lfunc.Proto; -const R = llex.RESERVED; + OP_CLOSURE, + OP_FORLOOP, + OP_FORPREP, + OP_GETUPVAL, + OP_MOVE, + OP_NEWTABLE, + OP_SETTABLE, + OP_TAILCALL, + OP_TFORCALL, + OP_TFORLOOP, + OP_VARARG +} = OpCodesI; + +const Proto = _Proto; +const R = RESERVED; const MAXVARS = 200; -const hasmultret = function(k) { +const hasmultret = function (k) { return k === expkind.VCALL || k === expkind.VVARARG; }; -const eqstr = function(a, b) { +const eqstr = function (a, b) { /* TODO: use plain equality as strings are cached */ return luaS_eqlngstr(a, b); }; @@ -137,11 +107,11 @@ const expkind = { VVARARG: 14 /* vararg expression; info = instruction pc */ }; -const vkisvar = function(k) { +const vkisvar = function (k) { return expkind.VLOCAL <= k && k <= expkind.VINDEXED; }; -const vkisinreg = function(k) { +const vkisinreg = function (k) { return k === expkind.VNONRELOC || k === expkind.VLOCAL; }; @@ -230,128 +200,128 @@ class Dyndata { } } -const semerror = function(ls, msg) { +const semerror = function (ls, msg) { ls.t.token = 0; /* remove "near " from final message */ - llex.luaX_syntaxerror(ls, msg); + luaX_syntaxerror(ls, msg); }; -const error_expected = function(ls, token) { - llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, to_luastring('%s expected', true), llex.luaX_token2str(ls, token))); +const error_expected = function (ls, token) { + luaX_syntaxerror(ls, luaO_pushfstring(ls.L, to_luastring("%s expected", true), luaX_token2str(ls, token))); }; -const errorlimit = function(fs, limit, what) { +const errorlimit = function (fs, limit, what) { let L = fs.ls.L; let line = fs.f.linedefined; let where = (line === 0) - ? to_luastring('main function', true) - : lobject.luaO_pushfstring(L, to_luastring('function at line %d', true), line); - let msg = lobject.luaO_pushfstring(L, to_luastring('too many %s (limit is %d) in %s', true), + ? to_luastring("main function", true) + : luaO_pushfstring(L, to_luastring("function at line %d", true), line); + let msg = luaO_pushfstring(L, to_luastring("too many %s (limit is %d) in %s", true), what, limit, where); - llex.luaX_syntaxerror(fs.ls, msg); + luaX_syntaxerror(fs.ls, msg); }; -const checklimit = function(fs, v, l, what) { +const checklimit = function (fs, v, l, what) { if (v > l) errorlimit(fs, l, what); }; -const testnext = function(ls, c) { +const testnext = function (ls, c) { if (ls.t.token === c) { - llex.luaX_next(ls); + luaX_next(ls); return true; } return false; }; -const check = function(ls, c) { +const check = function (ls, c) { if (ls.t.token !== c) error_expected(ls, c); }; -const checknext = function(ls, c) { +const checknext = function (ls, c) { check(ls, c); - llex.luaX_next(ls); + luaX_next(ls); }; -const check_condition = function(ls, c, msg) { +const check_condition = function (ls, c, msg) { if (!c) - llex.luaX_syntaxerror(ls, msg); + luaX_syntaxerror(ls, msg); }; -const check_match = function(ls, what, who, where) { +const check_match = function (ls, what, who, where) { if (!testnext(ls, what)) { if (where === ls.linenumber) error_expected(ls, what); else - llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, - to_luastring('%s expected (to close %s at line %d)'), - llex.luaX_token2str(ls, what), llex.luaX_token2str(ls, who), where)); + luaX_syntaxerror(ls, luaO_pushfstring(ls.L, + to_luastring("%s expected (to close %s at line %d)"), + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); } }; -const str_checkname = function(ls) { +const str_checkname = function (ls) { check(ls, R.TK_NAME); let ts = ls.t.seminfo.ts; - llex.luaX_next(ls); + luaX_next(ls); return ts; }; -const init_exp = function(e, k, i) { +const init_exp = function (e, k, i) { e.f = e.t = NO_JUMP; e.k = k; e.u.info = i; }; -const codestring = function(ls, e, s) { +const codestring = function (ls, e, s) { init_exp(e, expkind.VK, luaK_stringK(ls.fs, s)); }; -const checkname = function(ls, e) { +const checkname = function (ls, e) { codestring(ls, e, str_checkname(ls)); }; -const registerlocalvar = function(ls, varname) { +const registerlocalvar = function (ls, varname) { let fs = ls.fs; let f = fs.f; - f.locvars[fs.nlocvars] = new lobject.LocVar(); + f.locvars[fs.nlocvars] = new LocVar(); f.locvars[fs.nlocvars].varname = varname; return fs.nlocvars++; }; -const new_localvar = function(ls, name) { +const new_localvar = function (ls, name) { let fs = ls.fs; let dyd = ls.dyd; let reg = registerlocalvar(ls, name); - checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring('local variables', true)); + checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring("local variables", true)); dyd.actvar.arr[dyd.actvar.n] = new Vardesc(); dyd.actvar.arr[dyd.actvar.n].idx = reg; dyd.actvar.n++; }; -const new_localvarliteral = function(ls, name) { - new_localvar(ls, llex.luaX_newstring(ls, to_luastring(name, true))); +const new_localvarliteral = function (ls, name) { + new_localvar(ls, luaX_newstring(ls, to_luastring(name, true))); }; -const getlocvar = function(fs, i) { +const getlocvar = function (fs, i) { let idx = fs.ls.dyd.actvar.arr[fs.firstlocal + i].idx; lua_assert(idx < fs.nlocvars); return fs.f.locvars[idx]; }; -const adjustlocalvars = function(ls, nvars) { +const adjustlocalvars = function (ls, nvars) { let fs = ls.fs; fs.nactvar = fs.nactvar + nvars; for (; nvars; nvars--) getlocvar(fs, fs.nactvar - nvars).startpc = fs.pc; }; -const removevars = function(fs, tolevel) { +const removevars = function (fs, tolevel) { fs.ls.dyd.actvar.n -= fs.nactvar - tolevel; while (fs.nactvar > tolevel) getlocvar(fs, --fs.nactvar).endpc = fs.pc; }; -const searchupvalue = function(fs, name) { +const searchupvalue = function (fs, name) { let up = fs.f.upvalues; for (let i = 0; i < fs.nups; i++) { if (eqstr(up[i].name, name)) @@ -360,9 +330,9 @@ const searchupvalue = function(fs, name) { return -1; /* not found */ }; -const newupvalue = function(fs, name, v) { +const newupvalue = function (fs, name, v) { let f = fs.f; - checklimit(fs, fs.nups + 1, lfunc.MAXUPVAL, to_luastring('upvalues', true)); + checklimit(fs, fs.nups + 1, MAXUPVAL, to_luastring("upvalues", true)); f.upvalues[fs.nups] = { instack: v.k === expkind.VLOCAL, idx: v.u.info, @@ -371,7 +341,7 @@ const newupvalue = function(fs, name, v) { return fs.nups++; }; -const searchvar = function(fs, n) { +const searchvar = function (fs, n) { for (let i = fs.nactvar - 1; i >= 0; i--) { if (eqstr(n, getlocvar(fs, i).varname)) return i; @@ -384,7 +354,7 @@ const searchvar = function(fs, n) { ** Mark block where variable at given level was defined ** (to emit close instructions later). */ -const markupval = function(fs, level) { +const markupval = function (fs, level) { let bl = fs.bl; while (bl.nactvar > level) bl = bl.previous; @@ -395,7 +365,7 @@ const markupval = function(fs, level) { ** Find variable with given name 'n'. If it is an upvalue, add this ** upvalue into all intermediate functions. */ -const singlevaraux = function(fs, n, vr, base) { +const singlevaraux = function (fs, n, vr, base) { if (fs === null) /* no more levels? */ init_exp(vr, expkind.VVOID, 0); /* default is global */ else { @@ -418,7 +388,7 @@ const singlevaraux = function(fs, n, vr, base) { } }; -const singlevar = function(ls, vr) { +const singlevar = function (ls, vr) { let varname = str_checkname(ls); let fs = ls.fs; singlevaraux(fs, varname, vr, 1); @@ -431,7 +401,7 @@ const singlevar = function(ls, vr) { } }; -const adjust_assign = function(ls, nvars, nexps, e) { +const adjust_assign = function (ls, nvars, nexps, e) { let fs = ls.fs; let extra = nvars - nexps; if (hasmultret(e.k)) { @@ -451,25 +421,25 @@ const adjust_assign = function(ls, nvars, nexps, e) { ls.fs.freereg -= nexps - nvars; /* remove extra values */ }; -const enterlevel = function(ls) { +const enterlevel = function (ls) { let L = ls.L; ++L.nCcalls; - checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); + checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true)); }; -const leavelevel = function(ls) { +const leavelevel = function (ls) { return ls.L.nCcalls--; }; -const closegoto = function(ls, g, label) { +const closegoto = function (ls, g, label) { let fs = ls.fs; let gl = ls.dyd.gt; let gt = gl.arr[g]; lua_assert(eqstr(gt.name, label.name)); if (gt.nactvar < label.nactvar) { let vname = getlocvar(fs, gt.nactvar).varname; - let msg = lobject.luaO_pushfstring(ls.L, - to_luastring(' at line %d jumps into the scope of local \'%s\''), + let msg = luaO_pushfstring(ls.L, + to_luastring(" at line %d jumps into the scope of local '%s'"), gt.name.getstr(), gt.line, vname.getstr()); semerror(ls, msg); } @@ -483,7 +453,7 @@ const closegoto = function(ls, g, label) { /* ** try to close a goto with existing labels; this solves backward jumps */ -const findlabel = function(ls, g) { +const findlabel = function (ls, g) { let bl = ls.fs.bl; let dyd = ls.dyd; let gt = dyd.gt.arr[g]; @@ -500,7 +470,7 @@ const findlabel = function(ls, g) { return false; /* label not found; cannot close goto */ }; -const newlabelentry = function(ls, l, name, line, pc) { +const newlabelentry = function (ls, l, name, line, pc) { let n = l.n; l.arr[n] = new Labeldesc(); l.arr[n].name = name; @@ -515,7 +485,7 @@ const newlabelentry = function(ls, l, name, line, pc) { ** check whether new label 'lb' matches any pending gotos in current ** block; solves forward jumps */ -const findgotos = function(ls, lb) { +const findgotos = function (ls, lb) { let gl = ls.dyd.gt; let i = ls.fs.bl.firstgoto; while (i < gl.n) { @@ -532,7 +502,7 @@ const findgotos = function(ls, lb) { ** the goto exits the scope of any variable (which can be the ** upvalue), close those variables being exited. */ -const movegotosout = function(fs, bl) { +const movegotosout = function (fs, bl) { let i = bl.firstgoto; let gl = fs.ls.dyd.gt; /* correct pending gotos to current block and try to close it @@ -549,7 +519,7 @@ const movegotosout = function(fs, bl) { } }; -const enterblock = function(fs, bl, isloop) { +const enterblock = function (fs, bl, isloop) { bl.isloop = isloop; bl.nactvar = fs.nactvar; bl.firstlabel = fs.ls.dyd.label.n; @@ -563,8 +533,8 @@ const enterblock = function(fs, bl, isloop) { /* ** create a label named 'break' to resolve break statements */ -const breaklabel = function(ls) { - let n = luaS_newliteral(ls.L, 'break'); +const breaklabel = function (ls) { + let n = luaS_newliteral(ls.L, "break"); let l = newlabelentry(ls, ls.dyd.label, n, 0, ls.fs.pc); findgotos(ls, ls.dyd.label.arr[l]); }; @@ -573,18 +543,18 @@ const breaklabel = function(ls) { ** generates an error for an undefined 'goto'; choose appropriate ** message when label name is a reserved word (which can only be 'break') */ -const undefgoto = function(ls, gt) { - let msg = llex.isreserved(gt.name) - ? '<%s> at line %d not inside a loop' - : 'no visible label \'%s\' for at line %d'; - msg = lobject.luaO_pushfstring(ls.L, to_luastring(msg), gt.name.getstr(), gt.line); +const undefgoto = function (ls, gt) { + let msg = isreserved(gt.name) + ? "<%s> at line %d not inside a loop" + : "no visible label '%s' for at line %d"; + msg = luaO_pushfstring(ls.L, to_luastring(msg), gt.name.getstr(), gt.line); semerror(ls, msg); }; /* ** adds a new prototype into list of prototypes */ -const addprototype = function(ls) { +const addprototype = function (ls) { let L = ls.L; let clp = new Proto(L); let fs = ls.fs; @@ -596,13 +566,13 @@ const addprototype = function(ls) { /* ** codes instruction to create new closure in parent function. */ -const codeclosure = function(ls, v) { +const codeclosure = function (ls, v) { let fs = ls.fs.prev; - init_exp(v, expkind.VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs.np -1)); + init_exp(v, expkind.VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs.np - 1)); luaK_exp2nextreg(fs, v); /* fix it at the last register */ }; -const open_func = function(ls, fs, bl) { +const open_func = function (ls, fs, bl) { fs.prev = ls.fs; /* linked list of funcstates */ fs.ls = ls; ls.fs = fs; @@ -623,13 +593,13 @@ const open_func = function(ls, fs, bl) { enterblock(fs, bl, false); }; -const leaveblock = function(fs) { +const leaveblock = function (fs) { let bl = fs.bl; let ls = fs.ls; if (bl.previous && bl.upval) { /* create a 'jump to here' to close upvalues */ let j = luaK_jump(fs); - luaK_patchclose(fs, j , bl.nactvar); + luaK_patchclose(fs, j, bl.nactvar); luaK_patchtohere(fs, j); } @@ -647,7 +617,7 @@ const leaveblock = function(fs) { undefgoto(ls, ls.dyd.gt.arr[bl.firstgoto]); /* error */ }; -const close_func = function(ls) { +const close_func = function (ls) { let fs = ls.fs; luaK_ret(fs, 0, 0); /* final return */ leaveblock(fs); @@ -659,7 +629,7 @@ const close_func = function(ls) { /* GRAMMAR RULES */ /*============================================================*/ -const block_follow = function(ls, withuntil) { +const block_follow = function (ls, withuntil) { switch (ls.t.token) { case R.TK_ELSE: case R.TK_ELSEIF: case R.TK_END: case R.TK_EOS: @@ -669,7 +639,7 @@ const block_follow = function(ls, withuntil) { } }; -const statlist = function(ls) { +const statlist = function (ls) { /* statlist -> { stat [';'] } */ while (!block_follow(ls, 1)) { if (ls.t.token === R.TK_RETURN) { @@ -680,19 +650,19 @@ const statlist = function(ls) { } }; -const fieldsel = function(ls, v) { +const fieldsel = function (ls, v) { /* fieldsel -> ['.' | ':'] NAME */ let fs = ls.fs; let key = new expdesc(); luaK_exp2anyregup(fs, v); - llex.luaX_next(ls); /* skip the dot or colon */ + luaX_next(ls); /* skip the dot or colon */ checkname(ls, key); luaK_indexed(fs, v, key); }; -const yindex = function(ls, v) { +const yindex = function (ls, v) { /* index -> '[' expr ']' */ - llex.luaX_next(ls); /* skip the '[' */ + luaX_next(ls); /* skip the '[' */ expr(ls, v); luaK_exp2val(ls.fs, v); checknext(ls, 93 /* (']').charCodeAt(0) */); @@ -714,7 +684,7 @@ class ConsControl { } } -const recfield = function(ls, cc) { +const recfield = function (ls, cc) { /* recfield -> (NAME | '['exp1']') = exp1 */ let fs = ls.fs; let reg = ls.fs.freereg; @@ -722,7 +692,7 @@ const recfield = function(ls, cc) { let val = new expdesc(); if (ls.t.token === R.TK_NAME) { - checklimit(fs, cc.nh, MAX_INT, to_luastring('items in a constructor', true)); + checklimit(fs, cc.nh, MAX_INT, to_luastring("items in a constructor", true)); checkname(ls, key); } else /* ls->t.token === '[' */ yindex(ls, key); @@ -734,7 +704,7 @@ const recfield = function(ls, cc) { fs.freereg = reg; /* free registers */ }; -const closelistfield = function(fs, cc) { +const closelistfield = function (fs, cc) { if (cc.v.k === expkind.VVOID) return; /* there is no list item */ luaK_exp2nextreg(fs, cc.v); cc.v.k = expkind.VVOID; @@ -744,7 +714,7 @@ const closelistfield = function(fs, cc) { } }; -const lastlistfield = function(fs, cc) { +const lastlistfield = function (fs, cc) { if (cc.tostore === 0) return; if (hasmultret(cc.v.k)) { luaK_setmultret(fs, cc.v); @@ -757,19 +727,19 @@ const lastlistfield = function(fs, cc) { } }; -const listfield = function(ls, cc) { +const listfield = function (ls, cc) { /* listfield -> exp */ expr(ls, cc.v); - checklimit(ls.fs, cc.na, MAX_INT, to_luastring('items in a constructor', true)); + checklimit(ls.fs, cc.na, MAX_INT, to_luastring("items in a constructor", true)); cc.na++; cc.tostore++; }; -const field = function(ls, cc) { +const field = function (ls, cc) { /* field -> listfield | recfield */ switch (ls.t.token) { case R.TK_NAME: { /* may be 'listfield' or 'recfield' */ - if (llex.luaX_lookahead(ls) !== 61 /* ('=').charCodeAt(0) */) /* expression? */ + if (luaX_lookahead(ls) !== 61 /* ('=').charCodeAt(0) */) /* expression? */ listfield(ls, cc); else recfield(ls, cc); @@ -786,7 +756,7 @@ const field = function(ls, cc) { } }; -const constructor = function(ls, t) { +const constructor = function (ls, t) { /* constructor -> '{' [ field { sep field } [sep] ] '}' sep -> ',' | ';' */ let fs = ls.fs; @@ -807,13 +777,13 @@ const constructor = function(ls, t) { } while (testnext(ls, 44 /* (',').charCodeAt(0) */) || testnext(ls, 59 /* (';').charCodeAt(0) */)); check_match(ls, 125 /* ('}').charCodeAt(0) */, 123 /* ('{').charCodeAt(0) */, line); lastlistfield(fs, cc); - SETARG_B(fs.f.code[pc], lobject.luaO_int2fb(cc.na)); /* set initial array size */ - SETARG_C(fs.f.code[pc], lobject.luaO_int2fb(cc.nh)); /* set initial table size */ + SETARG_B(fs.f.code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs.f.code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ }; /* }====================================================================== */ -const parlist = function(ls) { +const parlist = function (ls) { /* parlist -> [ param { ',' param } ] */ let fs = ls.fs; let f = fs.f; @@ -828,20 +798,20 @@ const parlist = function(ls) { break; } case R.TK_DOTS: { /* param -> '...' */ - llex.luaX_next(ls); + luaX_next(ls); f.is_vararg = true; /* declared vararg */ break; } - default: llex.luaX_syntaxerror(ls, to_luastring(' or \'...\' expected', true)); + default: luaX_syntaxerror(ls, to_luastring(" or '...' expected", true)); } - } while(!f.is_vararg && testnext(ls, 44 /* (',').charCodeAt(0) */)); + } while (!f.is_vararg && testnext(ls, 44 /* (',').charCodeAt(0) */)); } adjustlocalvars(ls, nparams); f.numparams = fs.nactvar; luaK_reserveregs(fs, fs.nactvar); /* reserve register for parameters */ }; -const body = function(ls, e, ismethod, line) { +const body = function (ls, e, ismethod, line) { /* body -> '(' parlist ')' block END */ let new_fs = new FuncState(); let bl = new BlockCnt(); @@ -850,7 +820,7 @@ const body = function(ls, e, ismethod, line) { open_func(ls, new_fs, bl); checknext(ls, 40 /* ('(').charCodeAt(0) */); if (ismethod) { - new_localvarliteral(ls, 'self'); /* create 'self' parameter */ + new_localvarliteral(ls, "self"); /* create 'self' parameter */ adjustlocalvars(ls, 1); } parlist(ls); @@ -862,7 +832,7 @@ const body = function(ls, e, ismethod, line) { close_func(ls); }; -const explist = function(ls, v) { +const explist = function (ls, v) { /* explist -> expr { ',' expr } */ let n = 1; /* at least one expression */ expr(ls, v); @@ -874,12 +844,12 @@ const explist = function(ls, v) { return n; }; -const funcargs = function(ls, f, line) { +const funcargs = function (ls, f, line) { let fs = ls.fs; let args = new expdesc(); switch (ls.t.token) { case 40 /* ('(').charCodeAt(0) */: { /* funcargs -> '(' [ explist ] ')' */ - llex.luaX_next(ls); + luaX_next(ls); if (ls.t.token === 41 /* (')').charCodeAt(0) */) /* arg list is empty? */ args.k = expkind.VVOID; else { @@ -895,11 +865,11 @@ const funcargs = function(ls, f, line) { } case R.TK_STRING: { /* funcargs -> STRING */ codestring(ls, args, ls.t.seminfo.ts); - llex.luaX_next(ls); /* must use 'seminfo' before 'next' */ + luaX_next(ls); /* must use 'seminfo' before 'next' */ break; } default: { - llex.luaX_syntaxerror(ls, to_luastring('function arguments expected', true)); + luaX_syntaxerror(ls, to_luastring("function arguments expected", true)); } } lua_assert(f.k === expkind.VNONRELOC); @@ -910,9 +880,9 @@ const funcargs = function(ls, f, line) { else { if (args.k !== expkind.VVOID) luaK_exp2nextreg(fs, args); /* close last argument */ - nparams = fs.freereg - (base+1); + nparams = fs.freereg - (base + 1); } - init_exp(f, expkind.VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + init_exp(f, expkind.VCALL, luaK_codeABC(fs, OP_CALL, base, nparams + 1, 2)); luaK_fixline(fs, line); fs.freereg = base + 1; /* call remove function and arguments and leaves (unless changed) one result */ }; @@ -923,12 +893,12 @@ const funcargs = function(ls, f, line) { ** ======================================================================= */ -const primaryexp = function(ls, v) { +const primaryexp = function (ls, v) { /* primaryexp -> NAME | '(' expr ')' */ switch (ls.t.token) { case 40 /* ('(').charCodeAt(0) */: { let line = ls.linenumber; - llex.luaX_next(ls); + luaX_next(ls); expr(ls, v); check_match(ls, 41 /* (')').charCodeAt(0) */, 40 /* ('(').charCodeAt(0) */, line); luaK_dischargevars(ls.fs, v); @@ -939,18 +909,18 @@ const primaryexp = function(ls, v) { return; } default: { - llex.luaX_syntaxerror(ls, to_luastring('unexpected symbol', true)); + luaX_syntaxerror(ls, to_luastring("unexpected symbol", true)); } } }; -const suffixedexp = function(ls, v) { +const suffixedexp = function (ls, v) { /* suffixedexp -> primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ let fs = ls.fs; let line = ls.linenumber; primaryexp(ls, v); - for (;;) { + for (; ;) { switch (ls.t.token) { case 46 /* ('.').charCodeAt(0) */: { /* fieldsel */ fieldsel(ls, v); @@ -965,7 +935,7 @@ const suffixedexp = function(ls, v) { } case 58 /* (':').charCodeAt(0) */: { /* ':' NAME funcargs */ let key = new expdesc(); - llex.luaX_next(ls); + luaX_next(ls); checkname(ls, key); luaK_self(fs, v, key); funcargs(ls, v, line); @@ -981,7 +951,7 @@ const suffixedexp = function(ls, v) { } }; -const simpleexp = function(ls, v) { +const simpleexp = function (ls, v) { /* simpleexp -> FLT | INT | STRING | NIL | TRUE | FALSE | ... | constructor | FUNCTION body | suffixedexp */ switch (ls.t.token) { @@ -1013,7 +983,7 @@ const simpleexp = function(ls, v) { } case R.TK_DOTS: { /* vararg */ let fs = ls.fs; - check_condition(ls, fs.f.is_vararg, to_luastring('cannot use \'...\' outside a vararg function', true)); + check_condition(ls, fs.f.is_vararg, to_luastring("cannot use '...' outside a vararg function", true)); init_exp(v, expkind.VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } @@ -1022,7 +992,7 @@ const simpleexp = function(ls, v) { return; } case R.TK_FUNCTION: { - llex.luaX_next(ls); + luaX_next(ls); body(ls, v, 0, ls.linenumber); return; } @@ -1031,10 +1001,10 @@ const simpleexp = function(ls, v) { return; } } - llex.luaX_next(ls); + luaX_next(ls); }; -const getunopr = function(op) { +const getunopr = function (op) { switch (op) { case R.TK_NOT: return OPR_NOT; case 45 /* ('-').charCodeAt(0) */: return OPR_MINUS; @@ -1044,7 +1014,7 @@ const getunopr = function(op) { } }; -const getbinopr = function(op) { +const getbinopr = function (op) { switch (op) { case 43 /* ('+').charCodeAt(0) */: return OPR_ADD; case 45 /* ('-').charCodeAt(0) */: return OPR_SUB; @@ -1052,36 +1022,36 @@ const getbinopr = function(op) { case 37 /* ('%').charCodeAt(0) */: return OPR_MOD; case 94 /* ('^').charCodeAt(0) */: return OPR_POW; case 47 /* ('/').charCodeAt(0) */: return OPR_DIV; - case R.TK_IDIV: return OPR_IDIV; + case R.TK_IDIV: return OPR_IDIV; case 38 /* ('&').charCodeAt(0) */: return OPR_BAND; case 124 /* ('|').charCodeAt(0) */: return OPR_BOR; case 126 /* ('~').charCodeAt(0) */: return OPR_BXOR; - case R.TK_SHL: return OPR_SHL; - case R.TK_SHR: return OPR_SHR; + case R.TK_SHL: return OPR_SHL; + case R.TK_SHR: return OPR_SHR; case R.TK_CONCAT: return OPR_CONCAT; - case R.TK_NE: return OPR_NE; - case R.TK_EQ: return OPR_EQ; + case R.TK_NE: return OPR_NE; + case R.TK_EQ: return OPR_EQ; case 60 /* ('<').charCodeAt(0) */: return OPR_LT; - case R.TK_LE: return OPR_LE; + case R.TK_LE: return OPR_LE; case 62 /* ('>').charCodeAt(0) */: return OPR_GT; - case R.TK_GE: return OPR_GE; - case R.TK_AND: return OPR_AND; - case R.TK_OR: return OPR_OR; - default: return OPR_NOBINOPR; + case R.TK_GE: return OPR_GE; + case R.TK_AND: return OPR_AND; + case R.TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; } }; const priority = [ /* ORDER OPR */ - {left: 10, right: 10}, {left: 10, right: 10}, /* '+' '-' */ - {left: 11, right: 11}, {left: 11, right: 11}, /* '*' '%' */ - {left: 14, right: 13}, /* '^' (right associative) */ - {left: 11, right: 11}, {left: 11, right: 11}, /* '/' '//' */ - {left: 6, right: 6}, {left: 4, right: 4}, {left: 5, right: 5}, /* '&' '|' '~' */ - {left: 7, right: 7}, {left: 7, right: 7}, /* '<<' '>>' */ - {left: 9, right: 8}, /* '..' (right associative) */ - {left: 3, right: 3}, {left: 3, right: 3}, {left: 3, right: 3}, /* ==, <, <= */ - {left: 3, right: 3}, {left: 3, right: 3}, {left: 3, right: 3}, /* ~=, >, >= */ - {left: 2, right: 2}, {left: 1, right: 1} /* and, or */ + { left: 10, right: 10 }, { left: 10, right: 10 }, /* '+' '-' */ + { left: 11, right: 11 }, { left: 11, right: 11 }, /* '*' '%' */ + { left: 14, right: 13 }, /* '^' (right associative) */ + { left: 11, right: 11 }, { left: 11, right: 11 }, /* '/' '//' */ + { left: 6, right: 6 }, { left: 4, right: 4 }, { left: 5, right: 5 }, /* '&' '|' '~' */ + { left: 7, right: 7 }, { left: 7, right: 7 }, /* '<<' '>>' */ + { left: 9, right: 8 }, /* '..' (right associative) */ + { left: 3, right: 3 }, { left: 3, right: 3 }, { left: 3, right: 3 }, /* ==, <, <= */ + { left: 3, right: 3 }, { left: 3, right: 3 }, { left: 3, right: 3 }, /* ~=, >, >= */ + { left: 2, right: 2 }, { left: 1, right: 1 } /* and, or */ ]; const UNARY_PRIORITY = 12; @@ -1090,12 +1060,12 @@ const UNARY_PRIORITY = 12; ** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where 'binop' is any binary operator with a priority higher than 'limit' */ -const subexpr = function(ls, v, limit) { +const subexpr = function (ls, v, limit) { enterlevel(ls); let uop = getunopr(ls.t.token); if (uop !== OPR_NOUNOPR) { let line = ls.linenumber; - llex.luaX_next(ls); + luaX_next(ls); subexpr(ls, v, UNARY_PRIORITY); luaK_prefix(ls.fs, uop, v, line); } else @@ -1105,7 +1075,7 @@ const subexpr = function(ls, v, limit) { while (op !== OPR_NOBINOPR && priority[op].left > limit) { let v2 = new expdesc(); let line = ls.linenumber; - llex.luaX_next(ls); + luaX_next(ls); luaK_infix(ls.fs, op, v); /* read sub-expression with higher priority */ let nextop = subexpr(ls, v2, priority[op].right); @@ -1116,7 +1086,7 @@ const subexpr = function(ls, v, limit) { return op; /* return first untreated operator */ }; -const expr = function(ls, v) { +const expr = function (ls, v) { subexpr(ls, v, 0); }; @@ -1130,7 +1100,7 @@ const expr = function(ls, v) { ** ======================================================================= */ -const block = function(ls) { +const block = function (ls) { /* block -> statlist */ let fs = ls.fs; let bl = new BlockCnt(); @@ -1156,7 +1126,7 @@ class LHS_assign { ** table. If so, save original upvalue/local value in a safe place and ** use this safe copy in the previous assignment. */ -const check_conflict = function(ls, lh, v) { +const check_conflict = function (ls, lh, v) { let fs = ls.fs; let extra = fs.freereg; /* eventual position to save local variable */ let conflict = false; @@ -1183,16 +1153,16 @@ const check_conflict = function(ls, lh, v) { } }; -const assignment = function(ls, lh, nvars) { +const assignment = function (ls, lh, nvars) { let e = new expdesc(); - check_condition(ls, vkisvar(lh.v.k), to_luastring('syntax error', true)); + check_condition(ls, vkisvar(lh.v.k), to_luastring("syntax error", true)); if (testnext(ls, 44 /* (',').charCodeAt(0) */)) { /* assignment -> ',' suffixedexp assignment */ let nv = new LHS_assign(); nv.prev = lh; suffixedexp(ls, nv.v); if (nv.v.k !== expkind.VINDEXED) check_conflict(ls, lh, nv.v); - checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); + checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true)); assignment(ls, nv, nvars + 1); } else { /* assignment -> '=' explist */ checknext(ls, 61 /* ('=').charCodeAt(0) */); @@ -1205,11 +1175,11 @@ const assignment = function(ls, lh, nvars) { return; /* avoid default */ } } - init_exp(e, expkind.VNONRELOC, ls.fs.freereg-1); /* default assignment */ + init_exp(e, expkind.VNONRELOC, ls.fs.freereg - 1); /* default assignment */ luaK_storevar(ls.fs, lh.v, e); }; -const cond = function(ls) { +const cond = function (ls) { /* cond -> exp */ let v = new expdesc(); expr(ls, v); /* read condition */ @@ -1218,25 +1188,25 @@ const cond = function(ls) { return v.f; }; -const gotostat = function(ls, pc) { +const gotostat = function (ls, pc) { let line = ls.linenumber; let label; if (testnext(ls, R.TK_GOTO)) label = str_checkname(ls); else { - llex.luaX_next(ls); /* skip break */ - label = luaS_newliteral(ls.L, 'break'); + luaX_next(ls); /* skip break */ + label = luaS_newliteral(ls.L, "break"); } let g = newlabelentry(ls, ls.dyd.gt, label, line, pc); findlabel(ls, g); /* close it if label already defined */ }; /* check for repeated labels on the same block */ -const checkrepeated = function(fs, ll, label) { +const checkrepeated = function (fs, ll, label) { for (let i = fs.bl.firstlabel; i < ll.n; i++) { if (eqstr(label, ll.arr[i].name)) { - let msg = lobject.luaO_pushfstring(fs.ls.L, - to_luastring('label \'%s\' already defined on line %d', true), + let msg = luaO_pushfstring(fs.ls.L, + to_luastring("label '%s' already defined on line %d", true), label.getstr(), ll.arr[i].line); semerror(fs.ls, msg); } @@ -1244,12 +1214,12 @@ const checkrepeated = function(fs, ll, label) { }; /* skip no-op statements */ -const skipnoopstat = function(ls) { +const skipnoopstat = function (ls) { while (ls.t.token === 59 /* (';').charCodeAt(0) */ || ls.t.token === R.TK_DBCOLON) statement(ls); }; -const labelstat = function(ls, label, line) { +const labelstat = function (ls, label, line) { /* label -> '::' NAME '::' */ let fs = ls.fs; let ll = ls.dyd.label; @@ -1266,11 +1236,11 @@ const labelstat = function(ls, label, line) { findgotos(ls, ll.arr[l]); }; -const whilestat = function(ls, line) { +const whilestat = function (ls, line) { /* whilestat -> WHILE cond DO block END */ let fs = ls.fs; let bl = new BlockCnt(); - llex.luaX_next(ls); /* skip WHILE */ + luaX_next(ls); /* skip WHILE */ let whileinit = luaK_getlabel(fs); let condexit = cond(ls); enterblock(fs, bl, 1); @@ -1282,7 +1252,7 @@ const whilestat = function(ls, line) { luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ }; -const repeatstat = function(ls, line) { +const repeatstat = function (ls, line) { /* repeatstat -> REPEAT block UNTIL cond */ let fs = ls.fs; let repeat_init = luaK_getlabel(fs); @@ -1290,7 +1260,7 @@ const repeatstat = function(ls, line) { let bl2 = new BlockCnt(); enterblock(fs, bl1, 1); /* loop block */ enterblock(fs, bl2, 0); /* scope block */ - llex.luaX_next(ls); /* skip REPEAT */ + luaX_next(ls); /* skip REPEAT */ statlist(ls); check_match(ls, R.TK_UNTIL, R.TK_REPEAT, line); let condexit = cond(ls); /* read condition (inside scope block) */ @@ -1301,7 +1271,7 @@ const repeatstat = function(ls, line) { leaveblock(fs); /* finish loop */ }; -const exp1 = function(ls) { +const exp1 = function (ls) { let e = new expdesc(); expr(ls, e); luaK_exp2nextreg(ls.fs, e); @@ -1310,7 +1280,7 @@ const exp1 = function(ls) { return reg; }; -const forbody = function(ls, base, line, nvars, isnum) { +const forbody = function (ls, base, line, nvars, isnum) { /* forbody -> DO block */ let bl = new BlockCnt(); let fs = ls.fs; @@ -1335,13 +1305,13 @@ const forbody = function(ls, base, line, nvars, isnum) { luaK_fixline(fs, line); }; -const fornum = function(ls, varname, line) { +const fornum = function (ls, varname, line) { /* fornum -> NAME = exp1,exp1[,exp1] forbody */ let fs = ls.fs; let base = fs.freereg; - new_localvarliteral(ls, '(for index)'); - new_localvarliteral(ls, '(for limit)'); - new_localvarliteral(ls, '(for step)'); + new_localvarliteral(ls, "(for index)"); + new_localvarliteral(ls, "(for limit)"); + new_localvarliteral(ls, "(for step)"); new_localvar(ls, varname); checknext(ls, 61 /* ('=').charCodeAt(0) */); exp1(ls); /* initial value */ @@ -1356,16 +1326,16 @@ const fornum = function(ls, varname, line) { forbody(ls, base, line, 1, 1); }; -const forlist = function(ls, indexname) { +const forlist = function (ls, indexname) { /* forlist -> NAME {,NAME} IN explist forbody */ let fs = ls.fs; let e = new expdesc(); let nvars = 4; /* gen, state, control, plus at least one declared var */ let base = fs.freereg; /* create control variables */ - new_localvarliteral(ls, '(for generator)'); - new_localvarliteral(ls, '(for state)'); - new_localvarliteral(ls, '(for control)'); + new_localvarliteral(ls, "(for generator)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for control)"); /* create declared variables */ new_localvar(ls, indexname); while (testnext(ls, 44 /* (',').charCodeAt(0) */)) { @@ -1379,30 +1349,30 @@ const forlist = function(ls, indexname) { forbody(ls, base, line, nvars - 3, 0); }; -const forstat = function(ls, line) { +const forstat = function (ls, line) { /* forstat -> FOR (fornum | forlist) END */ let fs = ls.fs; let bl = new BlockCnt(); enterblock(fs, bl, 1); /* scope for loop and control variables */ - llex.luaX_next(ls); /* skip 'for' */ + luaX_next(ls); /* skip 'for' */ let varname = str_checkname(ls); /* first variable name */ switch (ls.t.token) { case 61 /* ('=').charCodeAt(0) */: fornum(ls, varname, line); break; case 44 /* (',').charCodeAt(0) */: case R.TK_IN: forlist(ls, varname); break; - default: llex.luaX_syntaxerror(ls, to_luastring('\'=\' or \'in\' expected', true)); + default: luaX_syntaxerror(ls, to_luastring("'=' or 'in' expected", true)); } check_match(ls, R.TK_END, R.TK_FOR, line); leaveblock(fs); /* loop scope ('break' jumps to this point) */ }; -const test_then_block = function(ls, escapelist) { +const test_then_block = function (ls, escapelist) { /* test_then_block -> [IF | ELSEIF] cond THEN block */ let bl = new BlockCnt(); let fs = ls.fs; let v = new expdesc(); let jf; /* instruction to skip 'then' code (if condition is false) */ - llex.luaX_next(ls); /* skip IF or ELSEIF */ + luaX_next(ls); /* skip IF or ELSEIF */ expr(ls, v); /* read condition */ checknext(ls, R.TK_THEN); @@ -1431,7 +1401,7 @@ const test_then_block = function(ls, escapelist) { return escapelist; }; -const ifstat = function(ls, line) { +const ifstat = function (ls, line) { /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ let fs = ls.fs; let escapelist = NO_JUMP; /* exit list for finished parts */ @@ -1444,7 +1414,7 @@ const ifstat = function(ls, line) { luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ }; -const localfunc = function(ls) { +const localfunc = function (ls) { let b = new expdesc(); let fs = ls.fs; new_localvar(ls, str_checkname(ls)); /* new local variable */ @@ -1454,7 +1424,7 @@ const localfunc = function(ls) { getlocvar(fs, b.u.info).startpc = fs.pc; }; -const localstat = function(ls) { +const localstat = function (ls) { /* stat -> LOCAL NAME {',' NAME} ['=' explist] */ let nvars = 0; let nexps; @@ -1473,7 +1443,7 @@ const localstat = function(ls) { adjustlocalvars(ls, nvars); }; -const funcname = function(ls, v) { +const funcname = function (ls, v) { /* funcname -> NAME {fieldsel} [':' NAME] */ let ismethod = 0; singlevar(ls, v); @@ -1486,18 +1456,18 @@ const funcname = function(ls, v) { return ismethod; }; -const funcstat = function(ls, line) { +const funcstat = function (ls, line) { /* funcstat -> FUNCTION funcname body */ let v = new expdesc(); let b = new expdesc(); - llex.luaX_next(ls); /* skip FUNCTION */ + luaX_next(ls); /* skip FUNCTION */ let ismethod = funcname(ls, v); body(ls, b, ismethod, line); luaK_storevar(ls.fs, v, b); luaK_fixline(ls.fs, line); /* definition "happens" in the first line */ }; -const exprstat= function(ls) { +const exprstat = function (ls) { /* stat -> func | assignment */ let fs = ls.fs; let v = new LHS_assign(); @@ -1507,12 +1477,12 @@ const exprstat= function(ls) { assignment(ls, v, 1); } else { /* stat -> func */ - check_condition(ls, v.v.k === expkind.VCALL, to_luastring('syntax error', true)); + check_condition(ls, v.v.k === expkind.VCALL, to_luastring("syntax error", true)); SETARG_C(getinstruction(fs, v.v), 1); /* call statement uses no results */ } }; -const retstat = function(ls) { +const retstat = function (ls) { /* stat -> RETURN [explist] [';'] */ let fs = ls.fs; let e = new expdesc(); @@ -1543,12 +1513,12 @@ const retstat = function(ls) { testnext(ls, 59 /* (';').charCodeAt(0) */); /* skip optional semicolon */ }; -const statement = function(ls) { +const statement = function (ls) { let line = ls.linenumber; /* may be needed for error messages */ enterlevel(ls); - switch(ls.t.token) { + switch (ls.t.token) { case 59 /* (';').charCodeAt(0) */: { /* stat -> ';' (empty statement) */ - llex.luaX_next(ls); /* skip ';' */ + luaX_next(ls); /* skip ';' */ break; } case R.TK_IF: { /* stat -> ifstat */ @@ -1560,7 +1530,7 @@ const statement = function(ls) { break; } case R.TK_DO: { /* stat -> DO block END */ - llex.luaX_next(ls); /* skip DO */ + luaX_next(ls); /* skip DO */ block(ls); check_match(ls, R.TK_END, R.TK_DO, line); break; @@ -1578,7 +1548,7 @@ const statement = function(ls) { break; } case R.TK_LOCAL: { /* stat -> localstat */ - llex.luaX_next(ls); /* skip LOCAL */ + luaX_next(ls); /* skip LOCAL */ if (testnext(ls, R.TK_FUNCTION)) /* local function? */ localfunc(ls); else @@ -1586,12 +1556,12 @@ const statement = function(ls) { break; } case R.TK_DBCOLON: { /* stat -> label */ - llex.luaX_next(ls); /* skip double colon */ + luaX_next(ls); /* skip double colon */ labelstat(ls, str_checkname(ls), line); break; } case R.TK_RETURN: { /* skip double colon */ - llex.luaX_next(ls); /* skip RETURN */ + luaX_next(ls); /* skip RETURN */ retstat(ls); break; } @@ -1614,34 +1584,34 @@ const statement = function(ls) { ** compiles the main function, which is a regular vararg function with an ** upvalue named LUA_ENV */ -const mainfunc = function(ls, fs) { +const mainfunc = function (ls, fs) { let bl = new BlockCnt(); let v = new expdesc(); open_func(ls, fs, bl); fs.f.is_vararg = true; /* main function is always declared vararg */ init_exp(v, expkind.VLOCAL, 0); /* create and... */ newupvalue(fs, ls.envn, v); /* ...set environment upvalue */ - llex.luaX_next(ls); /* read first token */ + luaX_next(ls); /* read first token */ statlist(ls); /* parse main body */ check(ls, R.TK_EOS); close_func(ls); }; -const luaY_parser = function(L, z, buff, dyd, name, firstchar) { - let lexstate = new llex.LexState(); +const luaY_parser = function (L, z, buff, dyd, name, firstchar) { + let lexstate = new LexState(); let funcstate = new FuncState(); - let cl = lfunc.luaF_newLclosure(L, 1); /* create main closure */ - ldo.luaD_inctop(L); - L.stack[L.top-1].setclLvalue(cl); - lexstate.h = ltable.luaH_new(L); /* create table for scanner */ - ldo.luaD_inctop(L); - L.stack[L.top-1].sethvalue(lexstate.h); + let cl = luaF_newLclosure(L, 1); /* create main closure */ + luaD_inctop(L); + L.stack[L.top - 1].setclLvalue(cl); + lexstate.h = luaH_new(L); /* create table for scanner */ + luaD_inctop(L); + L.stack[L.top - 1].sethvalue(lexstate.h); funcstate.f = cl.p = new Proto(L); funcstate.f.source = luaS_new(L, name); lexstate.buff = buff; lexstate.dyd = dyd; dyd.actvar.n = dyd.gt.n = dyd.label.n = 0; - llex.luaX_setinput(L, lexstate, z, funcstate.f.source, firstchar); + luaX_setinput(L, lexstate, z, funcstate.f.source, firstchar); mainfunc(lexstate, funcstate); lua_assert(!funcstate.prev && funcstate.nups === 1 && !lexstate.fs); /* all scopes should be correctly finished */ @@ -1649,3 +1619,15 @@ const luaY_parser = function(L, z, buff, dyd, name, firstchar) { delete L.stack[--L.top]; /* remove scanner's table */ return cl; /* closure is on the stack, too */ }; + + +const _Dyndata = Dyndata; +export { _Dyndata as Dyndata }; +const _expkind = expkind; +export { _expkind as expkind }; +const _expdesc = expdesc; +export { _expdesc as expdesc }; +const _luaY_parser = luaY_parser; +export { _luaY_parser as luaY_parser }; +const _vkisinreg = vkisinreg; +export { _vkisinreg as vkisinreg }; diff --git a/src/lstate.js b/src/lstate.js index 79295d01..261a510f 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -1,20 +1,9 @@ -import { - LUA_MINSTACK, - constant_types, - thread_status, - LUA_NUMTAGS, LUA_OK, - LUA_RIDX_GLOBALS, - LUA_RIDX_MAINTHREAD, - LUA_TNIL, - LUA_TTABLE, - LUA_TTHREAD -} from "./defs.js"; - -import * as lobject from "./lobject.js"; -import * as ldo from "./ldo.js"; -import * as lapi from "./lapi.js"; -import * as ltable from "./ltable.js"; -import * as ltm from "./ltm.js"; +import { LUA_MINSTACK, LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD, constant_types, thread_status } from './defs.js'; +import { TValue } from './lobject.js'; +import { luaD_rawrunprotected } from './ldo.js'; +import { lua_version, api_incr_top } from './lapi.js'; +import { luaH_new, luaH_setint } from './ltable.js'; +import { TMS, luaT_init } from './ltm.js'; const { LUA_NUMTAGS, @@ -22,11 +11,12 @@ const { LUA_TTABLE, LUA_TTHREAD } = constant_types; + const { LUA_OK -} =thread_status; +} = thread_status; -export const EXTRA_STACK = 5; +const EXTRA_STACK = 5; const BASIC_STACK_SIZE = 2 * LUA_MINSTACK; @@ -54,7 +44,7 @@ class CallInfo { } -export class lua_State { +class lua_State { constructor(g) { this.id = g.id_counter++; @@ -89,11 +79,11 @@ class global_State { this.ids = new WeakMap(); this.mainthread = null; - this.l_registry = new lobject.TValue(LUA_TNIL, null); + this.l_registry = new TValue(LUA_TNIL, null); this.panic = null; this.atnativeerror = null; this.version = null; - this.tmname = new Array(ltm.TMS.TM_N); + this.tmname = new Array(TMS.TM_N); this.mt = new Array(LUA_NUMTAGS); } @@ -123,7 +113,7 @@ const stack_init = function (L1, L) { ci.callstatus = 0; ci.funcOff = L1.top; ci.func = L1.stack[L1.top]; - L1.stack[L1.top++] = new lobject.TValue(LUA_TNIL, null); + L1.stack[L1.top++] = new TValue(LUA_TNIL, null); ci.top = L1.top + LUA_MINSTACK; L1.ci = ci; }; @@ -138,10 +128,10 @@ const freestack = function (L) { ** Create registry table and its predefined values */ const init_registry = function (L, g) { - let registry = ltable.luaH_new(L); + let registry = luaH_new(L); g.l_registry.sethvalue(registry); - ltable.luaH_setint(registry, LUA_RIDX_MAINTHREAD, new lobject.TValue(LUA_TTHREAD, L)); - ltable.luaH_setint(registry, LUA_RIDX_GLOBALS, new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L))); + luaH_setint(registry, LUA_RIDX_MAINTHREAD, new TValue(LUA_TTHREAD, L)); + luaH_setint(registry, LUA_RIDX_GLOBALS, new TValue(LUA_TTABLE, luaH_new(L))); }; /* @@ -152,15 +142,15 @@ const f_luaopen = function (L) { let g = L.l_G; stack_init(L, L); init_registry(L, g); - ltm.luaT_init(L); - g.version = lapi.lua_version(null); + luaT_init(L); + g.version = lua_version(null); }; const lua_newthread = function (L) { let g = L.l_G; let L1 = new lua_State(g); - L.stack[L.top] = new lobject.TValue(LUA_TTHREAD, L1); - lapi.api_incr_top(L); + L.stack[L.top] = new TValue(LUA_TTHREAD, L1); + api_incr_top(L); L1.hookmask = L.hookmask; L1.basehookcount = L.basehookcount; L1.hook = L.hook; @@ -178,7 +168,7 @@ const lua_newstate = function () { let L = new lua_State(g); g.mainthread = L; - if (ldo.luaD_rawrunprotected(L, f_luaopen, null) !== LUA_OK) { + if (luaD_rawrunprotected(L, f_luaopen, null) !== LUA_OK) { L = null; } @@ -193,3 +183,31 @@ const lua_close = function (L) { L = L.l_G.mainthread; /* only the main thread can be closed */ close_state(L); }; + +const _lua_State = lua_State; +export { _lua_State as lua_State }; +const _CallInfo = CallInfo; +export { _CallInfo as CallInfo }; +export const CIST_OAH = (1 << 0); /* original value of 'allowhook' */ +export const CIST_LUA = (1 << 1); /* call is running a Lua function */ +export const CIST_HOOKED = (1 << 2); /* call is running a debug hook */ +export const CIST_FRESH = (1 << 3); /* call is running on a fresh invocation of luaV_execute */ +export const CIST_YPCALL = (1 << 4); /* call is a yieldable protected call */ +export const CIST_TAIL = (1 << 5); /* call was tail called */ +export const CIST_HOOKYIELD = (1 << 6); /* last hook called yielded */ +export const CIST_LEQ = (1 << 7); /* using __lt for __le */ +export const CIST_FIN = (1 << 8); /* call is running a finalizer */ +const _EXTRA_STACK = EXTRA_STACK; +export { _EXTRA_STACK as EXTRA_STACK }; +const _lua_close = lua_close; +export { _lua_close as lua_close }; +const _lua_newstate = lua_newstate; +export { _lua_newstate as lua_newstate }; +const _lua_newthread = lua_newthread; +export { _lua_newthread as lua_newthread }; +const _luaE_extendCI = luaE_extendCI; +export { _luaE_extendCI as luaE_extendCI }; +const _luaE_freeCI = luaE_freeCI; +export { _luaE_freeCI as luaE_freeCI }; +const _luaE_freethread = luaE_freethread; +export { _luaE_freethread as luaE_freethread }; diff --git a/src/lstring.js b/src/lstring.js index bddc6f3d..5f1bcae6 100644 --- a/src/lstring.js +++ b/src/lstring.js @@ -1,5 +1,5 @@ -import {is_luastring, luastring_eq, luastring_from, to_luastring} from "./defs.js"; -import {lua_assert} from "./llimits.js"; +import { is_luastring, luastring_eq, luastring_from, to_luastring } from './defs.js'; +import { lua_assert } from "./llimits.js"; class TString { @@ -18,7 +18,7 @@ class TString { } -export const luaS_eqlngstr = function(a, b) { +const luaS_eqlngstr = function (a, b) { lua_assert(a instanceof TString); lua_assert(b instanceof TString); return a == b || luastring_eq(a.realstring, b.realstring); @@ -26,35 +26,50 @@ export const luaS_eqlngstr = function(a, b) { /* converts strings (arrays) to a consistent map key make sure this doesn't conflict with any of the anti-collision strategies in ltable */ -const luaS_hash = function(str) { +const luaS_hash = function (str) { lua_assert(is_luastring(str)); let len = str.length; - let s = '|'; - for (let i=0; i -1 ? len : s.length; }; /* translate a relative string position: negative means back from end */ -const posrelat = function(pos, len) { +const posrelat = function (pos, len) { if (pos >= 0) return pos; else if (0 - pos > len) return 0; else return len + pos + 1; }; -const str_sub = function(L) { +const str_sub = function (L) { let s = luaL_checkstring(L, 1); let l = s.length; let start = posrelat(luaL_checkinteger(L, 2), l); @@ -69,41 +41,41 @@ const str_sub = function(L) { if (end > l) end = l; if (start <= end) lua_pushstring(L, s.subarray(start - 1, (start - 1) + (end - start + 1))); - else lua_pushliteral(L, ''); + else lua_pushliteral(L, ""); return 1; }; -const str_len = function(L) { +const str_len = function (L) { lua_pushinteger(L, luaL_checkstring(L, 1).length); return 1; }; -const str_char = function(L) { +const str_char = function (L) { let n = lua_gettop(L); /* number of arguments */ let b = new luaL_Buffer(); let p = luaL_buffinitsize(L, b, n); for (let i = 1; i <= n; i++) { let c = luaL_checkinteger(L, i); - luaL_argcheck(L, c >= 0 && c <= 255, 'value out of range'); // Strings are 8-bit clean - p[i-1] = c; + luaL_argcheck(L, c >= 0 && c <= 255, "value out of range"); // Strings are 8-bit clean + p[i - 1] = c; } luaL_pushresultsize(b, n); return 1; }; -const writer = function(L, b, size, B) { +const writer = function (L, b, size, B) { luaL_addlstring(B, b, size); return 0; }; -const str_dump = function(L) { +const str_dump = function (L) { let b = new luaL_Buffer(); let strip = lua_toboolean(L, 2); luaL_checktype(L, 1, LUA_TFUNCTION); lua_settop(L, 1); luaL_buffinit(L, b); if (lua_dump(L, writer, b, strip) !== 0) - return luaL_error(L, to_luastring('unable to dump given function')); + return luaL_error(L, to_luastring("unable to dump given function")); luaL_pushresult(b); return 1; }; @@ -112,7 +84,7 @@ const SIZELENMOD = LUA_NUMBER_FRMLEN.length + 1; const L_NBFD = 1; -const num2straux = function(x) { +const num2straux = function (x) { /* if 'inf' or 'NaN', format it like '%g' */ if (Object.is(x, Infinity)) return to_luastring('inf'); @@ -122,12 +94,12 @@ const num2straux = function(x) { return to_luastring('nan'); else if (x === 0) { /* can be -0... */ /* create "0" or "-0" followed by exponent */ - let zero = sprintf(LUA_NUMBER_FMT + 'x0p+0', x); + let zero = sprintf(LUA_NUMBER_FMT + "x0p+0", x); if (Object.is(x, -0)) - zero = '-' + zero; + zero = "-" + zero; return to_luastring(zero); } else { - let buff = ''; + let buff = ""; let fe = frexp(x); /* 'x' fraction and exponent */ let m = fe[0]; let e = fe[1]; @@ -135,15 +107,15 @@ const num2straux = function(x) { buff += '-'; /* add signal */ m = -m; /* make it positive */ } - buff += '0x'; /* add "0x" */ - buff += (m * (1< isgraph(e) && !isalnum(e); const isspace = e => e === 32 || (e >= 9 && e <= 13); const isxdigit = e => (48 <= e && e <= 57) || (65 <= e && e <= 70) || (97 <= e && e <= 102); -const addquoted = function(b, s, len) { +const addquoted = function (b, s, len) { luaL_addchar(b, 34 /* '"'.charCodeAt(0) */); let i = 0; while (len--) { @@ -195,10 +167,10 @@ const addquoted = function(b, s, len) { luaL_addchar(b, 92 /* '\\'.charCodeAt(0) */); luaL_addchar(b, s[i]); } else if (iscntrl(s[i])) { - let buff = '' + s[i]; /* stringify */ - if (isdigit(s[i+1])) - buff = ('000' + buff).slice(-3); /* pad to 3 digits with leading '0's */ - luaL_addstring(b, to_luastring('\\' + buff)); + let buff = "" + s[i]; /* stringify */ + if (isdigit(s[i + 1])) + buff = ("000" + buff).slice(-3); /* pad to 3 digits with leading '0's */ + luaL_addstring(b, to_luastring("\\" + buff)); } else luaL_addchar(b, s[i]); i++; @@ -209,7 +181,7 @@ const addquoted = function(b, s, len) { /* ** Ensures the 'buff' string uses a dot as the radix character. */ -const checkdp = function(buff) { +const checkdp = function (buff) { if (luastring_indexOf(buff, 46 /* ('.').charCodeAt(0) */) < 0) { /* no dot? */ let point = lua_getlocaledecpoint(); /* try locale point */ let ppoint = luastring_indexOf(buff, point); @@ -217,8 +189,8 @@ const checkdp = function(buff) { } }; -const addliteral = function(L, b, arg) { - switch(lua_type(L, arg)) { +const addliteral = function (L, b, arg) { + switch (lua_type(L, arg)) { case LUA_TSTRING: { let s = lua_tostring(L, arg); addquoted(b, s, s.length); @@ -233,7 +205,7 @@ const addliteral = function(L, b, arg) { } else { /* integers */ let n = lua_tointeger(L, arg); let format = (n === LUA_MININTEGER) /* corner case? */ - ? '0x%' + LUA_INTEGER_FRMLEN + 'x' /* use hexa */ + ? "0x%" + LUA_INTEGER_FRMLEN + "x" /* use hexa */ : LUA_INTEGER_FMT; /* else use default format */ buff = to_luastring(sprintf(format, n)); } @@ -246,16 +218,16 @@ const addliteral = function(L, b, arg) { break; } default: { - luaL_argerror(L, arg, to_luastring('value has no literal form')); + luaL_argerror(L, arg, to_luastring("value has no literal form")); } } }; -const scanformat = function(L, strfrmt, i, form) { +const scanformat = function (L, strfrmt, i, form) { let p = i; while (strfrmt[p] !== 0 && luastring_indexOf(FLAGS, strfrmt[p]) >= 0) p++; /* skip flags */ if (p - i >= FLAGS.length) - luaL_error(L, to_luastring('invalid format (repeated flags)')); + luaL_error(L, to_luastring("invalid format (repeated flags)")); if (isdigit(strfrmt[p])) p++; /* skip width */ if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ if (strfrmt[p] === 46 /* '.'.charCodeAt(0) */) { @@ -264,17 +236,17 @@ const scanformat = function(L, strfrmt, i, form) { if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ } if (isdigit(strfrmt[p])) - luaL_error(L, to_luastring('invalid format (width or precision too long)')); + luaL_error(L, to_luastring("invalid format (width or precision too long)")); form[0] = 37 /* "%".charCodeAt(0) */; for (let j = 0; j < p - i + 1; j++) - form[j+1] = strfrmt[i+j]; + form[j + 1] = strfrmt[i + j]; return p; }; /* ** add length modifier into formats */ -const addlenmod = function(form, lenmod) { +const addlenmod = function (form, lenmod) { let l = form.length; let lm = lenmod.length; let spec = form[l - 1]; @@ -284,7 +256,7 @@ const addlenmod = function(form, lenmod) { // form[l + lm] = 0; }; -const str_format = function(L) { +const str_format = function (L) { let top = lua_gettop(L); let arg = 1; let strfrmt = luaL_checkstring(L, arg); @@ -299,7 +271,7 @@ const str_format = function(L) { } else { /* format item */ let form = []; /* to store the format ('%...') */ if (++arg > top) - luaL_argerror(L, arg, to_luastring('no value')); + luaL_argerror(L, arg, to_luastring("no value")); i = scanformat(L, strfrmt, i, form); switch (String.fromCharCode(strfrmt[i++])) { case 'c': { @@ -335,7 +307,7 @@ const str_format = function(L) { if (form.length <= 2 || form[2] === 0) { /* no modifiers? */ luaL_addvalue(b); /* keep entire string */ } else { - luaL_argcheck(L, s.length === strlen(s), arg, 'string contains zeros'); + luaL_argcheck(L, s.length === strlen(s), arg, "string contains zeros"); if (luastring_indexOf(form, 46 /* '.'.charCodeAt(0) */) < 0 && s.length >= 100) { /* no precision and string is too long to be formatted */ luaL_addvalue(b); /* keep entire string */ @@ -348,7 +320,7 @@ const str_format = function(L) { break; } default: { /* also treat cases 'pnLlh' */ - return luaL_error(L, to_luastring('invalid option \'%%%c\' to \'format\''), strfrmt[i-1]); + return luaL_error(L, to_luastring("invalid option '%%%c' to 'format'"), strfrmt[i - 1]); } } } @@ -387,26 +359,26 @@ class Header { /* ** options for pack/unpack */ -const Kint = 0; /* signed integers */ -const Kuint = 1; /* unsigned integers */ -const Kfloat = 2; /* floating-point numbers */ -const Kchar = 3; /* fixed-length strings */ -const Kstring = 4; /* strings with prefixed length */ -const Kzstr = 5; /* zero-terminated strings */ -const Kpadding = 6; /* padding */ +const Kint = 0; /* signed integers */ +const Kuint = 1; /* unsigned integers */ +const Kfloat = 2; /* floating-point numbers */ +const Kchar = 3; /* fixed-length strings */ +const Kstring = 4; /* strings with prefixed length */ +const Kzstr = 5; /* zero-terminated strings */ +const Kpadding = 6; /* padding */ const Kpaddalign = 7; /* padding for alignment */ -const Knop = 8; /* no-op (configuration or spaces) */ +const Knop = 8; /* no-op (configuration or spaces) */ const digit = isdigit; -const getnum = function(fmt, df) { +const getnum = function (fmt, df) { if (fmt.off >= fmt.s.length || !digit(fmt.s[fmt.off])) /* no number? */ return df; /* return default value */ else { let a = 0; do { a = a * 10 + (fmt.s[fmt.off++] - 48 /* '0'.charCodeAt(0) */); - } while (fmt.off < fmt.s.length && digit(fmt.s[fmt.off]) && a <= (MAXSIZE - 9)/10); + } while (fmt.off < fmt.s.length && digit(fmt.s[fmt.off]) && a <= (MAXSIZE - 9) / 10); return a; } }; @@ -415,53 +387,53 @@ const getnum = function(fmt, df) { ** Read an integer numeral and raises an error if it is larger ** than the maximum size for integers. */ -const getnumlimit = function(h, fmt, df) { +const getnumlimit = function (h, fmt, df) { let sz = getnum(fmt, df); if (sz > MAXINTSIZE || sz <= 0) - luaL_error(h.L, to_luastring('integral size (%d) out of limits [1,%d]'), sz, MAXINTSIZE); + luaL_error(h.L, to_luastring("integral size (%d) out of limits [1,%d]"), sz, MAXINTSIZE); return sz; }; /* ** Read and classify next option. 'size' is filled with option's size. */ -const getoption = function(h, fmt) { +const getoption = function (h, fmt) { let r = { opt: fmt.s[fmt.off++], size: 0 /* default */ }; switch (r.opt) { - case 98 /*'b'*/: r.size = 1; r.opt = Kint; return r; // sizeof(char): 1 - case 66 /*'B'*/: r.size = 1; r.opt = Kuint; return r; - case 104 /*'h'*/: r.size = 2; r.opt = Kint; return r; // sizeof(short): 2 - case 72 /*'H'*/: r.size = 2; r.opt = Kuint; return r; - case 108 /*'l'*/: r.size = 4; r.opt = Kint; return r; // sizeof(long): 4 - case 76 /*'L'*/: r.size = 4; r.opt = Kuint; return r; - case 106 /*'j'*/: r.size = 4; r.opt = Kint; return r; // sizeof(lua_Integer): 4 - case 74 /*'J'*/: r.size = 4; r.opt = Kuint; return r; - case 84 /*'T'*/: r.size = 4; r.opt = Kuint; return r; // sizeof(size_t): 4 + case 98 /*'b'*/: r.size = 1; r.opt = Kint; return r; // sizeof(char): 1 + case 66 /*'B'*/: r.size = 1; r.opt = Kuint; return r; + case 104 /*'h'*/: r.size = 2; r.opt = Kint; return r; // sizeof(short): 2 + case 72 /*'H'*/: r.size = 2; r.opt = Kuint; return r; + case 108 /*'l'*/: r.size = 4; r.opt = Kint; return r; // sizeof(long): 4 + case 76 /*'L'*/: r.size = 4; r.opt = Kuint; return r; + case 106 /*'j'*/: r.size = 4; r.opt = Kint; return r; // sizeof(lua_Integer): 4 + case 74 /*'J'*/: r.size = 4; r.opt = Kuint; return r; + case 84 /*'T'*/: r.size = 4; r.opt = Kuint; return r; // sizeof(size_t): 4 case 102 /*'f'*/: r.size = 4; r.opt = Kfloat; return r; // sizeof(float): 4 case 100 /*'d'*/: r.size = 8; r.opt = Kfloat; return r; // sizeof(double): 8 case 110 /*'n'*/: r.size = 8; r.opt = Kfloat; return r; // sizeof(lua_Number): 8 - case 105 /*'i'*/: r.size = getnumlimit(h, fmt, 4); r.opt = Kint; return r; // sizeof(int): 4 - case 73 /*'I'*/: r.size = getnumlimit(h, fmt, 4); r.opt = Kuint; return r; + case 105 /*'i'*/: r.size = getnumlimit(h, fmt, 4); r.opt = Kint; return r; // sizeof(int): 4 + case 73 /*'I'*/: r.size = getnumlimit(h, fmt, 4); r.opt = Kuint; return r; case 115 /*'s'*/: r.size = getnumlimit(h, fmt, 4); r.opt = Kstring; return r; case 99 /*'c'*/: { r.size = getnum(fmt, -1); if (r.size === -1) - luaL_error(h.L, to_luastring('missing size for format option \'c\'')); + luaL_error(h.L, to_luastring("missing size for format option 'c'")); r.opt = Kchar; return r; } - case 122 /*'z'*/: r.opt = Kzstr; return r; - case 120 /*'x'*/: r.size = 1; r.opt = Kpadding; return r; - case 88 /*'X'*/: r.opt = Kpaddalign; return r; + case 122 /*'z'*/: r.opt = Kzstr; return r; + case 120 /*'x'*/: r.size = 1; r.opt = Kpadding; return r; + case 88 /*'X'*/: r.opt = Kpaddalign; return r; case 32 /*' '*/: break; case 60 /*'<'*/: h.islittle = true; break; case 62 /*'>'*/: h.islittle = false; break; case 61 /*'='*/: h.islittle = true; break; case 33 /*'!'*/: h.maxalign = getnumlimit(h, fmt, MAXALIGN); break; - default: luaL_error(h.L, to_luastring('invalid format option \'%c\''), r.opt); + default: luaL_error(h.L, to_luastring("invalid format option '%c'"), r.opt); } r.opt = Knop; return r; @@ -476,7 +448,7 @@ const getoption = function(h, fmt) { ** the maximum alignment ('maxalign'). Kchar option needs no alignment ** despite its size. */ -const getdetails = function(h, totalsize, fmt) { +const getdetails = function (h, totalsize, fmt) { let r = { opt: NaN, size: NaN, @@ -489,13 +461,13 @@ const getdetails = function(h, totalsize, fmt) { let align = r.size; /* usually, alignment follows size */ if (r.opt === Kpaddalign) { /* 'X' gets alignment from following option */ if (fmt.off >= fmt.s.length || fmt.s[fmt.off] === 0) - luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); + luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'")); else { let o = getoption(h, fmt); align = o.size; o = o.opt; if (o === Kchar || align === 0) - luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); + luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'")); } } if (align <= 1 || r.opt === Kchar) /* need no alignment? */ @@ -503,8 +475,8 @@ const getdetails = function(h, totalsize, fmt) { else { if (align > h.maxalign) /* enforce maximum alignment */ align = h.maxalign; - if ((align & (align -1)) !== 0) /* is 'align' not a power of 2? */ - luaL_argerror(h.L, 1, to_luastring('format asks for alignment not power of 2')); + if ((align & (align - 1)) !== 0) /* is 'align' not a power of 2? */ + luaL_argerror(h.L, 1, to_luastring("format asks for alignment not power of 2")); r.ntoalign = (align - (totalsize & (align - 1))) & (align - 1); } return r; @@ -516,7 +488,7 @@ const getdetails = function(h, totalsize, fmt) { ** the size of a Lua integer, correcting the extra sign-extension ** bytes if necessary (by default they would be zeros). */ -const packint = function(b, n, islittle, size, neg) { +const packint = function (b, n, islittle, size, neg) { let buff = luaL_prepbuffsize(b, size); buff[islittle ? 0 : size - 1] = n & MC; /* first byte */ for (let i = 1; i < size; i++) { @@ -530,7 +502,7 @@ const packint = function(b, n, islittle, size, neg) { luaL_addsize(b, size); /* add result to buffer */ }; -const str_pack = function(L) { +const str_pack = function (L) { let b = new luaL_Buffer(); let h = new Header(L); let fmt = { @@ -555,7 +527,7 @@ const str_pack = function(L) { let n = luaL_checkinteger(L, arg); if (size < SZINT) { /* need overflow check? */ let lim = 1 << (size * 8) - 1; - luaL_argcheck(L, -lim <= n && n < lim, arg, 'integer overflow'); + luaL_argcheck(L, -lim <= n && n < lim, arg, "integer overflow"); } packint(b, n, h.islittle, size, n < 0); break; @@ -563,8 +535,8 @@ const str_pack = function(L) { case Kuint: { /* unsigned integers */ let n = luaL_checkinteger(L, arg); if (size < SZINT) - luaL_argcheck(L, (n>>>0) < (1 << (size * NB)), arg, 'unsigned overflow'); - packint(b, n>>>0, h.islittle, size, false); + luaL_argcheck(L, (n >>> 0) < (1 << (size * NB)), arg, "unsigned overflow"); + packint(b, n >>> 0, h.islittle, size, false); break; } case Kfloat: { /* floating-point options */ @@ -579,7 +551,7 @@ const str_pack = function(L) { case Kchar: { /* fixed-size string */ let s = luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, len <= size, arg, 'string longer than given size'); + luaL_argcheck(L, len <= size, arg, "string longer than given size"); luaL_addlstring(b, s, len); /* add string */ while (len++ < size) /* pad extra space */ luaL_addchar(b, LUAL_PACKPADBYTE); @@ -590,7 +562,7 @@ const str_pack = function(L) { let len = s.length; luaL_argcheck(L, size >= 4 /* sizeof(size_t) */ || len < (1 << (size * NB)), - arg, 'string length does not fit in given size'); + arg, "string length does not fit in given size"); packint(b, len, h.islittle, size, 0); /* pack length */ luaL_addlstring(b, s, len); totalsize += len; @@ -599,7 +571,7 @@ const str_pack = function(L) { case Kzstr: { /* zero-terminated string */ let s = luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, 'strings contains zeros'); + luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, "strings contains zeros"); luaL_addlstring(b, s, len); luaL_addchar(b, 0); /* add zero at the end */ totalsize += len + 1; @@ -615,21 +587,21 @@ const str_pack = function(L) { return 1; }; -const str_reverse = function(L) { +const str_reverse = function (L) { let s = luaL_checkstring(L, 1); let l = s.length; let r = new Uint8Array(l); - for (let i=0; i MAXSIZE / n) /* may overflow? */ - return luaL_error(L, to_luastring('resulting string too large')); + return luaL_error(L, to_luastring("resulting string too large")); else { let totallen = n * l + (n - 1) * lsep; let b = new luaL_Buffer(); @@ -681,7 +653,7 @@ const str_rep = function(L) { return 1; }; -const str_byte = function(L) { +const str_byte = function (L) { let s = luaL_checkstring(L, 1); let l = s.length; let posi = posrelat(luaL_optinteger(L, 2, 1), l); @@ -691,16 +663,16 @@ const str_byte = function(L) { if (pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) /* arithmetic overflow? */ - return luaL_error(L, 'string slice too long'); + return luaL_error(L, "string slice too long"); let n = (pose - posi) + 1; - luaL_checkstack(L, n, 'string slice too long'); + luaL_checkstack(L, n, "string slice too long"); for (let i = 0; i < n; i++) lua_pushinteger(L, s[posi + i - 1]); return n; }; -const str_packsize = function(L) { +const str_packsize = function (L) { let h = new Header(L); let fmt = { s: luaL_checkstring(L, 1), @@ -713,14 +685,14 @@ const str_packsize = function(L) { let size = details.size; let ntoalign = details.ntoalign; size += ntoalign; /* total space used by option */ - luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, 'format result too large'); + luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, "format result too large"); totalsize += size; switch (opt) { case Kstring: /* strings with length count */ case Kzstr: /* zero-terminated string */ - luaL_argerror(L, 1, 'variable-length format'); - /* call never return, but to avoid warnings: *//* fall through */ - default: break; + luaL_argerror(L, 1, "variable-length format"); + /* call never return, but to avoid warnings: *//* fall through */ + default: break; } } lua_pushinteger(L, totalsize); @@ -735,7 +707,7 @@ const str_packsize = function(L) { ** it must check the unread bytes to see whether they do not cause an ** overflow. */ -const unpackint = function(L, str, islittle, size, issigned) { +const unpackint = function (L, str, islittle, size, issigned) { let res = 0; let limit = size <= SZINT ? size : SZINT; for (let i = limit - 1; i >= 0; i--) { @@ -751,14 +723,14 @@ const unpackint = function(L, str, islittle, size, issigned) { let mask = !issigned || res >= 0 ? 0 : MC; for (let i = limit; i < size; i++) { if (str[islittle ? i : size - 1 - i] !== mask) - luaL_error(L, to_luastring('%d-byte integer does not fit into Lua Integer'), size); + luaL_error(L, to_luastring("%d-byte integer does not fit into Lua Integer"), size); } } return res; }; -const unpacknum = function(L, b, islittle, size) { - lualib.lua_assert(b.length >= size); +const unpacknum = function (L, b, islittle, size) { + lua_assert(b.length >= size); let dv = new DataView(new ArrayBuffer(size)); for (let i = 0; i < size; i++) @@ -768,7 +740,7 @@ const unpacknum = function(L, b, islittle, size) { else return dv.getFloat64(0, islittle); }; -const str_unpack = function(L) { +const str_unpack = function (L) { let h = new Header(L); let fmt = { s: luaL_checkstring(L, 1), @@ -778,17 +750,17 @@ const str_unpack = function(L) { let ld = data.length; let pos = posrelat(luaL_optinteger(L, 3, 1), ld) - 1; let n = 0; /* number of results */ - luaL_argcheck(L, pos <= ld && pos >= 0, 3, 'initial position out of string'); + luaL_argcheck(L, pos <= ld && pos >= 0, 3, "initial position out of string"); while (fmt.off < fmt.s.length) { let details = getdetails(h, pos, fmt); let opt = details.opt; let size = details.size; let ntoalign = details.ntoalign; if (/*ntoalign + size > ~pos ||*/ pos + ntoalign + size > ld) - luaL_argerror(L, 2, to_luastring('data string too short')); + luaL_argerror(L, 2, to_luastring("data string too short")); pos += ntoalign; /* skip alignment */ /* stack space for item + next position */ - luaL_checkstack(L, 2, 'too many results'); + luaL_checkstack(L, 2, "too many results"); n++; switch (opt) { case Kint: @@ -808,7 +780,7 @@ const str_unpack = function(L) { } case Kstring: { let len = unpackint(L, data.subarray(pos), h.islittle, size, 0); - luaL_argcheck(L, pos + len + size <= ld, 2, 'data string too short'); + luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short"); lua_pushstring(L, data.subarray(pos + size, pos + size + len)); pos += len; /* skip string */ break; @@ -831,9 +803,9 @@ const str_unpack = function(L) { }; const CAP_UNFINISHED = -1; -const CAP_POSITION = -2; -const MAXCCALLS = 200; -const SPECIALS = to_luastring('^$*+?.([%-'); +const CAP_POSITION = -2; +const MAXCCALLS = 200; +const SPECIALS = to_luastring("^$*+?.([%-"); class MatchState { constructor(L) { @@ -849,32 +821,32 @@ class MatchState { } } -const check_capture = function(ms, l) { +const check_capture = function (ms, l) { l = l - 49 /* '1'.charCodeAt(0) */; if (l < 0 || l >= ms.level || ms.capture[l].len === CAP_UNFINISHED) - return luaL_error(ms.L, to_luastring('invalid capture index %%%d'), l + 1); + return luaL_error(ms.L, to_luastring("invalid capture index %%%d"), l + 1); return l; }; -const capture_to_close = function(ms) { +const capture_to_close = function (ms) { let level = ms.level; for (level--; level >= 0; level--) if (ms.capture[level].len === CAP_UNFINISHED) return level; - return luaL_error(ms.L, to_luastring('invalid pattern capture')); + return luaL_error(ms.L, to_luastring("invalid pattern capture")); }; -const classend = function(ms, p) { - switch(ms.p[p++]) { +const classend = function (ms, p) { + switch (ms.p[p++]) { case L_ESC: { if (p === ms.p_end) - luaL_error(ms.L, to_luastring('malformed pattern (ends with \'%%\')')); + luaL_error(ms.L, to_luastring("malformed pattern (ends with '%%')")); return p + 1; } case 91 /* '['.charCodeAt(0) */: { if (ms.p[p] === 94 /* '^'.charCodeAt(0) */) p++; do { /* look for a ']' */ if (p === ms.p_end) - luaL_error(ms.L, to_luastring('malformed pattern (missing \']\')')); + luaL_error(ms.L, to_luastring("malformed pattern (missing ']')")); if (ms.p[p++] === L_ESC && p < ms.p_end) p++; /* skip escapes (e.g. '%]') */ } while (ms.p[p] !== 93 /* ']'.charCodeAt(0) */); @@ -886,27 +858,27 @@ const classend = function(ms, p) { } }; -const match_class = function(c, cl) { +const match_class = function (c, cl) { switch (cl) { - case 97 /* 'a'.charCodeAt(0) */: return isalpha(c); + case 97 /* 'a'.charCodeAt(0) */: return isalpha(c); case 65 /* 'A'.charCodeAt(0) */: return !isalpha(c); - case 99 /* 'c'.charCodeAt(0) */: return iscntrl(c); + case 99 /* 'c'.charCodeAt(0) */: return iscntrl(c); case 67 /* 'C'.charCodeAt(0) */: return !iscntrl(c); - case 100 /* 'd'.charCodeAt(0) */: return isdigit(c); + case 100 /* 'd'.charCodeAt(0) */: return isdigit(c); case 68 /* 'D'.charCodeAt(0) */: return !isdigit(c); - case 103 /* 'g'.charCodeAt(0) */: return isgraph(c); + case 103 /* 'g'.charCodeAt(0) */: return isgraph(c); case 71 /* 'G'.charCodeAt(0) */: return !isgraph(c); - case 108 /* 'l'.charCodeAt(0) */: return islower(c); + case 108 /* 'l'.charCodeAt(0) */: return islower(c); case 76 /* 'L'.charCodeAt(0) */: return !islower(c); - case 112 /* 'p'.charCodeAt(0) */: return ispunct(c); + case 112 /* 'p'.charCodeAt(0) */: return ispunct(c); case 80 /* 'P'.charCodeAt(0) */: return !ispunct(c); - case 115 /* 's'.charCodeAt(0) */: return isspace(c); + case 115 /* 's'.charCodeAt(0) */: return isspace(c); case 83 /* 'S'.charCodeAt(0) */: return !isspace(c); - case 117 /* 'u'.charCodeAt(0) */: return isupper(c); + case 117 /* 'u'.charCodeAt(0) */: return isupper(c); case 85 /* 'U'.charCodeAt(0) */: return !isupper(c); - case 119 /* 'w'.charCodeAt(0) */: return isalnum(c); + case 119 /* 'w'.charCodeAt(0) */: return isalnum(c); case 87 /* 'W'.charCodeAt(0) */: return !isalnum(c); - case 120 /* 'x'.charCodeAt(0) */: return isxdigit(c); + case 120 /* 'x'.charCodeAt(0) */: return isxdigit(c); case 88 /* 'X'.charCodeAt(0) */: return !isxdigit(c); case 122 /* 'z'.charCodeAt(0) */: return (c === 0); /* deprecated option */ case 90 /* 'z'.charCodeAt(0) */: return (c !== 0); /* deprecated option */ @@ -914,7 +886,7 @@ const match_class = function(c, cl) { } }; -const matchbracketclass = function(ms, c, p, ec) { +const matchbracketclass = function (ms, c, p, ec) { let sig = true; if (ms.p[p + 1] === 94 /* '^'.charCodeAt(0) */) { sig = false; @@ -934,7 +906,7 @@ const matchbracketclass = function(ms, c, p, ec) { return !sig; }; -const singlematch = function(ms, s, p, ep) { +const singlematch = function (ms, s, p, ep) { if (s >= ms.src_end) return false; else { @@ -948,9 +920,9 @@ const singlematch = function(ms, s, p, ep) { } }; -const matchbalance = function(ms, s, p) { +const matchbalance = function (ms, s, p) { if (p >= ms.p_end - 1) - luaL_error(ms.L, to_luastring('malformed pattern (missing arguments to \'%%b\'')); + luaL_error(ms.L, to_luastring("malformed pattern (missing arguments to '%%b'")); if (ms.src[s] !== ms.p[p]) return null; else { @@ -967,7 +939,7 @@ const matchbalance = function(ms, s, p) { return null; /* string ends out of balance */ }; -const max_expand = function(ms, s, p, ep) { +const max_expand = function (ms, s, p, ep) { let i = 0; /* counts maximum expand for item */ while (singlematch(ms, s + i, p, ep)) i++; @@ -980,8 +952,8 @@ const max_expand = function(ms, s, p, ep) { return null; }; -const min_expand = function(ms, s, p, ep) { - for (;;) { +const min_expand = function (ms, s, p, ep) { + for (; ;) { let res = match(ms, s, ep + 1); if (res !== null) return res; @@ -991,9 +963,9 @@ const min_expand = function(ms, s, p, ep) { } }; -const start_capture = function(ms, s, p, what) { +const start_capture = function (ms, s, p, what) { let level = ms.level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring('too many captures')); + if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring("too many captures")); ms.capture[level] = ms.capture[level] ? ms.capture[level] : {}; ms.capture[level].init = s; ms.capture[level].len = what; @@ -1004,7 +976,7 @@ const start_capture = function(ms, s, p, what) { return res; }; -const end_capture = function(ms, s, p) { +const end_capture = function (ms, s, p) { let l = capture_to_close(ms); ms.capture[l].len = s - ms.capture[l].init; /* close capture */ let res; @@ -1014,24 +986,24 @@ const end_capture = function(ms, s, p) { }; /* Compare the elements of arrays 'a' and 'b' to see if they contain the same elements */ -const array_cmp = function(a, ai, b, bi, len) { - return luastring_eq(a.subarray(ai, ai+len), b.subarray(bi, bi+len)); +const array_cmp = function (a, ai, b, bi, len) { + return luastring_eq(a.subarray(ai, ai + len), b.subarray(bi, bi + len)); }; -const match_capture = function(ms, s, l) { +const match_capture = function (ms, s, l) { l = check_capture(ms, l); let len = ms.capture[l].len; - if ((ms.src_end-s) >= len && array_cmp(ms.src, ms.capture[l].init, ms.src, s, len)) - return s+len; + if ((ms.src_end - s) >= len && array_cmp(ms.src, ms.capture[l].init, ms.src, s, len)) + return s + len; else return null; }; -const match = function(ms, s, p) { +const match = function (ms, s, p) { let gotodefault = false; let gotoinit = true; if (ms.matchdepth-- === 0) - luaL_error(ms.L, to_luastring('pattern too complex')); + luaL_error(ms.L, to_luastring("pattern too complex")); while (gotoinit || gotodefault) { gotoinit = false; @@ -1069,10 +1041,10 @@ const match = function(ms, s, p) { case 102 /* 'f'.charCodeAt(0) */: { /* frontier? */ p += 2; if (ms.p[p] !== 91 /* '['.charCodeAt(0) */) - luaL_error(ms.L, to_luastring('missing \'[\' after \'%%f\' in pattern')); + luaL_error(ms.L, to_luastring("missing '[' after '%%f' in pattern")); let ep = classend(ms, p); /* points to what is next */ - let previous = s === ms.src_init ? 0 : ms.src[s-1]; - if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, (s===ms.src_end)?0:ms.src[s], p, ep - 1)) { + let previous = s === ms.src_init ? 0 : ms.src[s - 1]; + if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, (s === ms.src_end) ? 0 : ms.src[s], p, ep - 1)) { p = ep; gotoinit = true; break; } s = null; /* match failed */ @@ -1115,7 +1087,7 @@ const match = function(ms, s, p) { } case 43 /* '+'.charCodeAt(0) */: /* 1 or more repetitions */ s++; /* 1 match already done */ - /* fall through */ + /* fall through */ case 42 /* '*'.charCodeAt(0) */: /* 0 or more repetitions */ s = max_expand(ms, s, p, ep); break; @@ -1135,15 +1107,15 @@ const match = function(ms, s, p) { return s; }; -const push_onecapture = function(ms, i, s, e) { +const push_onecapture = function (ms, i, s, e) { if (i >= ms.level) { if (i === 0) lua_pushlstring(ms.L, ms.src.subarray(s, e), e - s); /* add whole match */ else - luaL_error(ms.L, to_luastring('invalid capture index %%%d'), i + 1); + luaL_error(ms.L, to_luastring("invalid capture index %%%d"), i + 1); } else { let l = ms.capture[i].len; - if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring('unfinished capture')); + if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring("unfinished capture")); if (l === CAP_POSITION) lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1); else @@ -1151,23 +1123,23 @@ const push_onecapture = function(ms, i, s, e) { } }; -const push_captures = function(ms, s, e) { +const push_captures = function (ms, s, e) { let nlevels = (ms.level === 0 && s != null) ? 1 : ms.level; - luaL_checkstack(ms.L, nlevels, 'too many captures'); + luaL_checkstack(ms.L, nlevels, "too many captures"); for (let i = 0; i < nlevels; i++) push_onecapture(ms, i, s, e); return nlevels; /* number of strings pushed */ }; -const nospecials = function(p, l) { - for (let i=0; i>> 0, sl = subarr.length; @@ -1190,14 +1162,14 @@ const find_subarray = function(arr, subarr, from_index) { return i; for (; (i = arr.indexOf(subarr[0], i)) !== -1; i++) { - if (luastring_eq(arr.subarray(i, i+sl), subarr)) + if (luastring_eq(arr.subarray(i, i + sl), subarr)) return i; } return -1; }; -const str_find_aux = function(L, find) { +const str_find_aux = function (L, find) { let s = luaL_checkstring(L, 1); let p = luaL_checkstring(L, 2); let ls = s.length; @@ -1242,11 +1214,11 @@ const str_find_aux = function(L, find) { return 1; }; -const str_find = function(L) { +const str_find = function (L) { return str_find_aux(L, 1); }; -const str_match = function(L) { +const str_match = function (L) { return str_find_aux(L, 0); }; @@ -1260,7 +1232,7 @@ class GMatchState { } } -const gmatch_aux = function(L) { +const gmatch_aux = function (L) { let gm = lua_touserdata(L, lua_upvalueindex(3)); gm.ms.L = L; for (let src = gm.src; src <= gm.ms.src_end; src++) { @@ -1274,7 +1246,7 @@ const gmatch_aux = function(L) { return 0; /* not found */ }; -const str_gmatch = function(L) { +const str_gmatch = function (L) { let s = luaL_checkstring(L, 1); let p = luaL_checkstring(L, 2); let ls = s.length; @@ -1290,7 +1262,7 @@ const str_gmatch = function(L) { return 1; }; -const add_s = function(ms, b, s, e) { +const add_s = function (ms, b, s, e) { let L = ms.L; let news = lua_tostring(L, 3); let l = news.length; @@ -1301,7 +1273,7 @@ const add_s = function(ms, b, s, e) { i++; /* skip ESC */ if (!isdigit(news[i])) { if (news[i] !== L_ESC) - luaL_error(L, to_luastring('invalid use of \'%c\' in replacement string'), L_ESC); + luaL_error(L, to_luastring("invalid use of '%c' in replacement string"), L_ESC); luaL_addchar(b, news[i]); } else if (news[i] === 48 /* '0'.charCodeAt(0) */) luaL_addlstring(b, ms.src.subarray(s, e), e - s); @@ -1315,7 +1287,7 @@ const add_s = function(ms, b, s, e) { } }; -const add_value = function(ms, b, s, e, tr) { +const add_value = function (ms, b, s, e, tr) { let L = ms.L; switch (tr) { case LUA_TFUNCTION: { @@ -1338,11 +1310,11 @@ const add_value = function(ms, b, s, e, tr) { lua_pop(L, 1); lua_pushlstring(L, ms.src.subarray(s, e), e - s); /* keep original text */ } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('invalid replacement value (a %s)'), luaL_typename(L, -1)); + luaL_error(L, to_luastring("invalid replacement value (a %s)"), luaL_typename(L, -1)); luaL_addvalue(b); /* add result to accumulator */ }; -const str_gsub = function(L) { +const str_gsub = function (L) { let src = luaL_checkstring(L, 1); /* subject */ let srcl = src.length; let p = luaL_checkstring(L, 2); /* pattern */ @@ -1355,7 +1327,7 @@ const str_gsub = function(L) { let ms = new MatchState(L); let b = new luaL_Buffer(); luaL_argcheck(L, tr === LUA_TNUMBER || tr === LUA_TSTRING || tr === LUA_TFUNCTION || tr === LUA_TTABLE, 3, - 'string/function/table expected'); + "string/function/table expected"); luaL_buffinit(L, b); if (anchor) { p = p.subarray(1); lp--; /* skip anchor character */ @@ -1381,38 +1353,41 @@ const str_gsub = function(L) { }; const strlib = { - 'byte': str_byte, - 'char': str_char, - 'dump': str_dump, - 'find': str_find, - 'format': str_format, - 'gmatch': str_gmatch, - 'gsub': str_gsub, - 'len': str_len, - 'lower': str_lower, - 'match': str_match, - 'pack': str_pack, - 'packsize': str_packsize, - 'rep': str_rep, - 'reverse': str_reverse, - 'sub': str_sub, - 'unpack': str_unpack, - 'upper': str_upper + "byte": str_byte, + "char": str_char, + "dump": str_dump, + "find": str_find, + "format": str_format, + "gmatch": str_gmatch, + "gsub": str_gsub, + "len": str_len, + "lower": str_lower, + "match": str_match, + "pack": str_pack, + "packsize": str_packsize, + "rep": str_rep, + "reverse": str_reverse, + "sub": str_sub, + "unpack": str_unpack, + "upper": str_upper }; -const createmetatable = function(L) { +const createmetatable = function (L) { lua_createtable(L, 0, 1); /* table to be metatable for strings */ - lua_pushliteral(L, ''); /* dummy string */ + lua_pushliteral(L, ""); /* dummy string */ lua_pushvalue(L, -2); /* copy table */ lua_setmetatable(L, -2); /* set table as metatable for strings */ lua_pop(L, 1); /* pop dummy string */ lua_pushvalue(L, -2); /* get string library */ - lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = string */ + lua_setfield(L, -2, to_luastring("__index", true)); /* metatable.__index = string */ lua_pop(L, 1); /* pop metatable */ }; -const luaopen_string = function(L) { +const luaopen_string = function (L) { luaL_newlib(L, strlib); createmetatable(L); return 1; }; + +const _luaopen_string = luaopen_string; +export { _luaopen_string as luaopen_string }; diff --git a/src/ltable.js b/src/ltable.js index 3ef98c5c..db558e01 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -1,4 +1,12 @@ -import { +import { constant_types, to_luastring } from './defs.js'; +import { LUA_MAXINTEGER } from './luaconf.js'; +import { lua_assert } from './llimits.js'; +import { luaG_runerror } from './ldebug.js'; +import { Udata, LClosure, CClosure, luaO_nilobject, TValue, setobj2s } from './lobject.js'; +import { luaS_hashlongstr, TString } from './lstring.js'; +import { lua_State } from './lstate.js'; + +const { LUA_TBOOLEAN, LUA_TCCL, LUA_TLCF, @@ -6,34 +14,17 @@ import { LUA_TLIGHTUSERDATA, LUA_TLNGSTR, LUA_TNIL, - LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR, LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, to_luastring -} from "./defs.js"; -import {LUA_MAXINTEGER} from "./luaconf.js"; -import {lua_assert} from "./llimits.js"; -import * as ldebug from "./ldebug.js"; -import * as lobject from "./lobject.js"; -import {luaS_hashlongstr, TString} from "./lstring.js"; -import * as lstate from "./lstate.js"; - -const constant_types = { - LUA_TBOOLEAN, - LUA_TCCL, - LUA_TLCF, - LUA_TLCL, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR, - LUA_TTABLE, - LUA_TTHREAD, - LUA_TUSERDATA -} + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, + LUA_TTABLE, + LUA_TTHREAD, + LUA_TUSERDATA +} = constant_types; /* used to prevent conflicts with lightuserdata keys */ let lightuserdata_hashes = new WeakMap(); -const get_lightuserdata_hash = function(v) { +const get_lightuserdata_hash = function (v) { let hash = lightuserdata_hashes.get(v); if (!hash) { /* Hash should be something unique that is a valid WeakMap key @@ -44,14 +35,14 @@ const get_lightuserdata_hash = function(v) { return hash; }; -const table_hash = function(L, key) { - switch(key.type) { +const table_hash = function (L, key) { + switch (key.type) { case LUA_TNIL: - return ldebug.luaG_runerror(L, to_luastring('table index is nil', true)); + return luaG_runerror(L, to_luastring("table index is nil", true)); case LUA_TNUMFLT: if (isNaN(key.value)) - return ldebug.luaG_runerror(L, to_luastring('table index is NaN', true)); - /* fall through */ + return luaG_runerror(L, to_luastring("table index is NaN", true)); + /* fall through */ case LUA_TNUMINT: /* takes advantage of floats and integers being same in JS */ case LUA_TBOOLEAN: case LUA_TTABLE: @@ -66,39 +57,39 @@ const table_hash = function(L, key) { return luaS_hashlongstr(key.tsvalue()); case LUA_TLIGHTUSERDATA: { let v = key.value; - switch(typeof v) { - case 'string': + switch (typeof v) { + case "string": /* possible conflict with LUA_TSTRING. prefix this string with "*" so they don't clash */ - return '*' + v; - case 'number': + return "*" + v; + case "number": /* possible conflict with LUA_TNUMBER. turn into string and prefix with "#" to avoid clash with other strings */ - return '#' + v; - case 'boolean': + return "#" + v; + case "boolean": /* possible conflict with LUA_TBOOLEAN. use strings ?true and ?false instead */ - return v?'?true':'?false'; - case 'function': + return v ? "?true" : "?false"; + case "function": /* possible conflict with LUA_TLCF. indirect via a weakmap */ return get_lightuserdata_hash(v); - case 'object': + case "object": /* v could be a lua_State, CClosure, LClosure, Table or Userdata from this state as returned by lua_topointer */ - if ((v instanceof lstate.lua_State && v.l_G === L.l_G) || + if ((v instanceof lua_State && v.l_G === L.l_G) || v instanceof Table || - v instanceof lobject.Udata || - v instanceof lobject.LClosure || - v instanceof lobject.CClosure) { + v instanceof Udata || + v instanceof LClosure || + v instanceof CClosure) { /* indirect via a weakmap */ return get_lightuserdata_hash(v); } - /* fall through */ + /* fall through */ default: return v; } } default: - throw new Error('unknown key type: ' + key.type); + throw new Error("unknown key type: " + key.type); } }; @@ -115,11 +106,11 @@ class Table { } } -export const invalidateTMcache = function(t) { +const invalidateTMcache = function (t) { t.flags = 0; }; -const add = function(t, hash, key, value) { +const add = function (t, hash, key, value) { t.dead_strong.clear(); t.dead_weak = void 0; let prev = null; @@ -135,12 +126,12 @@ const add = function(t, hash, key, value) { t.l = entry; }; -const is_valid_weakmap_key = function(k) { +const is_valid_weakmap_key = function (k) { return typeof k === 'object' ? k !== null : typeof k === 'function'; }; /* Move out of 'strong' part and into 'dead' part. */ -const mark_dead = function(t, hash) { +const mark_dead = function (t, hash) { let e = t.strong.get(hash); if (e) { e.key.setdeadvalue(); @@ -148,10 +139,10 @@ const mark_dead = function(t, hash) { let next = e.n; let prev = e.p; e.p = void 0; /* no need to know previous item any more */ - if(prev) prev.n = next; - if(next) next.p = prev; - if(t.f === e) t.f = next; - if(t.l === e) t.l = prev; + if (prev) prev.n = next; + if (next) next.p = prev; + if (t.f === e) t.f = next; + if (t.l === e) t.l = prev; t.strong.delete(hash); if (is_valid_weakmap_key(hash)) { if (!t.dead_weak) t.dead_weak = new WeakMap(); @@ -163,34 +154,34 @@ const mark_dead = function(t, hash) { } }; -export const luaH_new = function(L) { +const luaH_new = function (L) { return new Table(L); }; -const getgeneric = function(t, hash) { +const getgeneric = function (t, hash) { let v = t.strong.get(hash); - return v ? v.value : lobject.luaO_nilobject; + return v ? v.value : luaO_nilobject; }; -export const luaH_getint = function(t, key) { - lua_assert(typeof key == 'number' && (key|0) === key); +const luaH_getint = function (t, key) { + lua_assert(typeof key == "number" && (key | 0) === key); return getgeneric(t, key); }; -const luaH_getstr = function(t, key) { +const luaH_getstr = function (t, key) { lua_assert(key instanceof TString); return getgeneric(t, luaS_hashlongstr(key)); }; -export const luaH_get = function(L, t, key) { - lua_assert(key instanceof lobject.TValue); +const luaH_get = function (L, t, key) { + lua_assert(key instanceof TValue); if (key.ttisnil() || (key.ttisfloat() && isNaN(key.value))) - return lobject.luaO_nilobject; + return luaO_nilobject; return getgeneric(t, table_hash(L, key)); }; -export const luaH_setint = function(t, key, value) { - lua_assert(typeof key == 'number' && (key|0) === key && value instanceof lobject.TValue); +const luaH_setint = function (t, key, value) { + lua_assert(typeof key == "number" && (key | 0) === key && value instanceof TValue); let hash = key; /* table_hash known result */ if (value.ttisnil()) { mark_dead(t, hash); @@ -201,14 +192,14 @@ export const luaH_setint = function(t, key, value) { let tv = e.value; tv.setfrom(value); } else { - let k = new lobject.TValue(LUA_TNUMINT, key); - let v = new lobject.TValue(value.type, value.value); + let k = new TValue(LUA_TNUMINT, key); + let v = new TValue(value.type, value.value); add(t, hash, k, v); } }; -export const luaH_setfrom = function(L, t, key, value) { - lua_assert(key instanceof lobject.TValue); +const luaH_setfrom = function (L, t, key, value) { + lua_assert(key instanceof TValue); let hash = table_hash(L, key); if (value.ttisnil()) { /* delete */ mark_dead(t, hash); @@ -221,13 +212,13 @@ export const luaH_setfrom = function(L, t, key, value) { } else { let k; let kv = key.value; - if ((key.ttisfloat() && (kv|0) === kv)) { /* does index fit in an integer? */ + if ((key.ttisfloat() && (kv | 0) === kv)) { /* does index fit in an integer? */ /* insert it as an integer */ - k = new lobject.TValue(LUA_TNUMINT, kv); + k = new TValue(LUA_TNUMINT, kv); } else { - k = new lobject.TValue(key.type, kv); + k = new TValue(key.type, kv); } - let v = new lobject.TValue(value.type, value.value); + let v = new TValue(value.type, value.value); add(t, hash, k, v); } }; @@ -236,7 +227,7 @@ export const luaH_setfrom = function(L, t, key, value) { ** Try to find a boundary in table 't'. A 'boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). */ -export const luaH_getn = function(t) { +const luaH_getn = function (t) { let i = 0; let j = t.strong.size + 1; /* use known size of Map to kick start search */ /* find 'i' and 'j' such that i is present and j is not */ @@ -252,14 +243,14 @@ export const luaH_getn = function(t) { } /* now do a binary search between them */ while (j - i > 1) { - let m = Math.floor((i+j)/2); + let m = Math.floor((i + j) / 2); if (luaH_getint(t, m).ttisnil()) j = m; else i = m; } return i; }; -export const luaH_next = function(L, table, keyI) { +const luaH_next = function (L, table, keyI) { let keyO = L.stack[keyI]; let entry; @@ -281,7 +272,7 @@ export const luaH_next = function(L, table, keyI) { entry = (table.dead_weak && table.dead_weak.get(hash)) || table.dead_strong.get(hash); if (!entry) /* item not in table */ - return ldebug.luaG_runerror(L, to_luastring('invalid key to \'next\'')); + return luaG_runerror(L, to_luastring("invalid key to 'next'")); /* Iterate until either out of keys, or until finding a non-dead key */ do { entry = entry.n; @@ -290,7 +281,28 @@ export const luaH_next = function(L, table, keyI) { } while (entry.key.ttisdeadkey()); } } - lobject.setobj2s(L, keyI, entry.key); - lobject.setobj2s(L, keyI+1, entry.value); + setobj2s(L, keyI, entry.key); + setobj2s(L, keyI + 1, entry.value); return true; }; + +const _invalidateTMcache = invalidateTMcache; +export { _invalidateTMcache as invalidateTMcache }; +const _luaH_get = luaH_get; +export { _luaH_get as luaH_get }; +const _luaH_getint = luaH_getint; +export { _luaH_getint as luaH_getint }; +const _luaH_getn = luaH_getn; +export { _luaH_getn as luaH_getn }; +const _luaH_getstr = luaH_getstr; +export { _luaH_getstr as luaH_getstr }; +const _luaH_setfrom = luaH_setfrom; +export { _luaH_setfrom as luaH_setfrom }; +const _luaH_setint = luaH_setint; +export { _luaH_setint as luaH_setint }; +const _luaH_new = luaH_new; +export { _luaH_new as luaH_new }; +const _luaH_next = luaH_next; +export { _luaH_next as luaH_next }; +const _Table = Table; +export { _Table as Table }; diff --git a/src/ltablib.js b/src/ltablib.js index 422a26e4..22e5381d 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -1,33 +1,8 @@ -import {LUA_MAXINTEGER} from "./luaconf.js"; - -import { - lua_call, - lua_checkstack, - lua_compare, - lua_createtable, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnoneornil, lua_isstring, - LUA_OPEQ, - LUA_OPLT, lua_pop, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawget, lua_setfield, lua_seti, - lua_settop, - LUA_TFUNCTION, - LUA_TNIL, lua_toboolean, - LUA_TTABLE, lua_type -} from "./lua.js"; - - -import { - luaL_addlstring, - luaL_addvalue, - luaL_argcheck, - luaL_Buffer, - luaL_buffinit, - luaL_checkinteger, luaL_checktype, luaL_error, luaL_len, luaL_newlib, luaL_opt, luaL_optinteger, luaL_optlstring, - luaL_pushresult, luaL_typename -} from "./lauxlib.js"; - - -import lualib from "./lualib.js"; -import {to_luastring} from "./fengaricore.js"; - +import { LUA_MAXINTEGER } from './luaconf.js'; +import { LUA_OPEQ, LUA_OPLT, LUA_TFUNCTION, LUA_TNIL, LUA_TTABLE, lua_call, lua_checkstack, lua_compare, lua_createtable, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnoneornil, lua_isstring, lua_pop, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawget, lua_setfield, lua_seti, lua_settop, lua_toboolean, lua_type } from './lua.js'; +import { luaL_Buffer, luaL_addlstring, luaL_addvalue, luaL_argcheck, luaL_buffinit, luaL_checkinteger, luaL_checktype, luaL_error, luaL_len, luaL_newlib, luaL_opt, luaL_optinteger, luaL_optlstring, luaL_pushresult, luaL_typename } from './lauxlib.js'; +import { lua_assert } from './lualib.js'; +import { to_luastring } from "./fengaricore.js"; /* ** Operations that an object must define to mimic a table @@ -51,9 +26,9 @@ const checktab = function(L, arg, what) { if (lua_type(L, arg) !== LUA_TTABLE) { /* is it not a table? */ let n = 1; if (lua_getmetatable(L, arg) && /* must have metatable */ - (!(what & TAB_R) || checkfield(L, to_luastring('__index', true), ++n)) && - (!(what & TAB_W) || checkfield(L, to_luastring('__newindex', true), ++n)) && - (!(what & TAB_L) || checkfield(L, to_luastring('__len', true), ++n))) { + (!(what & TAB_R) || checkfield(L, to_luastring("__index", true), ++n)) && + (!(what & TAB_W) || checkfield(L, to_luastring("__newindex", true), ++n)) && + (!(what & TAB_L) || checkfield(L, to_luastring("__len", true), ++n))) { lua_pop(L, n); /* pop metatable and tested metamethods */ } else @@ -69,7 +44,7 @@ const aux_getn = function(L, n, w) { const addfield = function(L, b, i) { lua_geti(L, 1, i); if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('invalid value (%s) at index %d in table for \'concat\''), + luaL_error(L, to_luastring("invalid value (%s) at index %d in table for 'concat'"), luaL_typename(L, -1), i); luaL_addvalue(b); @@ -84,7 +59,7 @@ const tinsert = function(L) { break; case 3: { pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ - luaL_argcheck(L, 1 <= pos && pos <= e, 2, 'position out of bounds'); + luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); for (let i = e; i > pos; i--) { /* move up elements */ lua_geti(L, 1, i - 1); lua_seti(L, 1, i); /* t[i] = t[i - 1] */ @@ -92,7 +67,7 @@ const tinsert = function(L) { break; } default: { - return luaL_error(L, 'wrong number of arguments to \'insert\''); + return luaL_error(L, "wrong number of arguments to 'insert'"); } } @@ -104,7 +79,7 @@ const tremove = function(L) { let size = aux_getn(L, 1, TAB_RW); let pos = luaL_optinteger(L, 2, size); if (pos !== size) /* validate 'pos' if given */ - luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, 'position out of bounds'); + luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); lua_geti(L, 1, pos); /* result = t[pos] */ for (; pos < size; pos++) { lua_geti(L, 1, pos + 1); @@ -129,9 +104,9 @@ const tmove = function(L) { checktab(L, 1, TAB_R); checktab(L, tt, TAB_W); if (e >= f) { /* otherwise, nothing to move */ - luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, 'too many elements to move'); + luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, "too many elements to move"); let n = e - f + 1; /* number of elements to move */ - luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, 'destination wrap around'); + luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, "destination wrap around"); if (t > e || t <= f || (tt !== 1 && lua_compare(L, 1, tt, LUA_OPEQ) !== 1)) { for (let i = 0; i < n; i++) { @@ -152,7 +127,7 @@ const tmove = function(L) { const tconcat = function(L) { let last = aux_getn(L, 1, TAB_R); - let sep = luaL_optlstring(L, 2, ''); + let sep = luaL_optlstring(L, 2, ""); let lsep = sep.length; let i = luaL_optinteger(L, 3, 1); last = luaL_optinteger(L, 4, last); @@ -180,7 +155,7 @@ const pack = function(L) { for (let i = n; i >= 1; i--) /* assign elements */ lua_seti(L, 1, i); lua_pushinteger(L, n); - lua_setfield(L, 1, to_luastring('n')); /* t.n = number of elements */ + lua_setfield(L, 1, to_luastring("n")); /* t.n = number of elements */ return 1; /* return table */ }; @@ -190,7 +165,7 @@ const unpack = function(L) { if (i > e) return 0; /* empty range */ let n = e - i; /* number of elements minus 1 (avoid overflows) */ if (n >= Number.MAX_SAFE_INTEGER || !lua_checkstack(L, ++n)) - return luaL_error(L, to_luastring('too many results to unpack')); + return luaL_error(L, to_luastring("too many results to unpack")); for (; i < e; i++) /* push arg[i..e - 1] (to avoid overflows) */ lua_geti(L, 1, i); lua_geti(L, 1, e); /* push last element */ @@ -230,14 +205,14 @@ const partition = function(L, lo, up) { /* next loop: repeat ++i while a[i] < P */ while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ - luaL_error(L, to_luastring('invalid order function for sorting')); + luaL_error(L, to_luastring("invalid order function for sorting")); lua_pop(L, 1); /* remove a[i] */ } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) /* j < i but a[j] > P ?? */ - luaL_error(L, to_luastring('invalid order function for sorting')); + luaL_error(L, to_luastring("invalid order function for sorting")); lua_pop(L, 1); /* remove a[j] */ } /* after the loop, a[j] <= P and a[j + 1 .. up] >= P */ @@ -256,7 +231,7 @@ const partition = function(L, lo, up) { const choosePivot = function(lo, up, rnd) { let r4 = Math.floor((up - lo) / 4); /* range/4 */ let p = rnd % (r4 * 2) + (lo + r4); - lualib.lua_assert(lo + r4 <= p && p <= up - r4); + lua_assert(lo + r4 <= p && p <= up - r4); return p; }; @@ -314,7 +289,7 @@ const auxsort = function(L, lo, up, rnd) { const sort = function(L) { let n = aux_getn(L, 1, TAB_RW); if (n > 1) { /* non-trivial interval? */ - luaL_argcheck(L, n < LUA_MAXINTEGER, 1, 'array too big'); + luaL_argcheck(L, n < LUA_MAXINTEGER, 1, "array too big"); if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ luaL_checktype(L, 2, LUA_TFUNCTION); /* must be a function */ lua_settop(L, 2); /* make sure there are two arguments */ @@ -324,16 +299,19 @@ const sort = function(L) { }; const tab_funcs = { - 'concat': tconcat, - 'insert': tinsert, - 'move': tmove, - 'pack': pack, - 'remove': tremove, - 'sort': sort, - 'unpack': unpack + "concat": tconcat, + "insert": tinsert, + "move": tmove, + "pack": pack, + "remove": tremove, + "sort": sort, + "unpack": unpack }; const luaopen_table = function(L) { luaL_newlib(L, tab_funcs); return 1; }; + +const _luaopen_table = luaopen_table; +export { _luaopen_table as luaopen_table }; diff --git a/src/ltm.js b/src/ltm.js index 1db56e0c..c0002d7f 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -1,36 +1,33 @@ -import {LUA_TTABLE, LUA_TUSERDATA, to_luastring} from "./defs.js"; - - -import {lua_assert} from "./llimits.js"; - -import * as lobject from "./lobject.js"; -import * as ldo from "./ldo.js"; -import * as lstate from "./lstate.js"; -import {luaS_bless, luaS_new} from "./lstring.js"; -import * as lvm from "./lvm.js"; -import * as ldebug from "./ldebug.js"; -import * as ltable from "./ltable.js"; - -const constant_types = { +import { constant_types, to_luastring } from './defs.js'; +import { lua_assert } from './llimits.js'; +import { pushobj2s, TValue, luaO_nilobject } from './lobject.js'; +import { luaD_call, luaD_callnoyield } from './ldo.js'; +import { CIST_LUA } from './lstate.js'; +import { luaS_bless, luaS_new } from './lstring.js'; +import { luaH_getstr } from './ltable.js'; +import { luaG_concaterror, luaG_tointerror, luaG_opinterror } from './ldebug.js'; +import { tonumber } from './lvm.js'; + +const { LUA_TTABLE, - LUA_TUSERDATA -} + LUA_TUSERDATA +} = constant_types; const luaT_typenames_ = [ - 'no value', - 'nil', - 'boolean', - 'userdata', - 'number', - 'string', - 'table', - 'function', - 'userdata', - 'thread', - 'proto' /* this last case is used for tests only */ + "no value", + "nil", + "boolean", + "userdata", + "number", + "string", + "table", + "function", + "userdata", + "thread", + "proto" /* this last case is used for tests only */ ].map(e => to_luastring(e)); -export const ttypename = function(t) { +const ttypename = function (t) { return luaT_typenames_[t + 1]; }; @@ -40,58 +37,58 @@ export const ttypename = function(t) { * grep "ORDER TM" and "ORDER OP" */ const TMS = { - TM_INDEX: 0, + TM_INDEX: 0, TM_NEWINDEX: 1, - TM_GC: 2, - TM_MODE: 3, - TM_LEN: 4, - TM_EQ: 5, /* last tag method with fast access */ - TM_ADD: 6, - TM_SUB: 7, - TM_MUL: 8, - TM_MOD: 9, - TM_POW: 10, - TM_DIV: 11, - TM_IDIV: 12, - TM_BAND: 13 , - TM_BOR: 14, - TM_BXOR: 15, - TM_SHL: 16, - TM_SHR: 17, - TM_UNM: 18, - TM_BNOT: 19, - TM_LT: 20, - TM_LE: 21, - TM_CONCAT: 22, - TM_CALL: 23, - TM_N: 24 /* number of elements in the enum */ + TM_GC: 2, + TM_MODE: 3, + TM_LEN: 4, + TM_EQ: 5, /* last tag method with fast access */ + TM_ADD: 6, + TM_SUB: 7, + TM_MUL: 8, + TM_MOD: 9, + TM_POW: 10, + TM_DIV: 11, + TM_IDIV: 12, + TM_BAND: 13, + TM_BOR: 14, + TM_BXOR: 15, + TM_SHL: 16, + TM_SHR: 17, + TM_UNM: 18, + TM_BNOT: 19, + TM_LT: 20, + TM_LE: 21, + TM_CONCAT: 22, + TM_CALL: 23, + TM_N: 24 /* number of elements in the enum */ }; -const luaT_init = function(L) { - L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring('__index', true)); - L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring('__newindex', true)); - L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring('__gc', true)); - L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring('__mode', true)); - L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring('__len', true)); - L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring('__eq', true)); - L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring('__add', true)); - L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring('__sub', true)); - L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring('__mul', true)); - L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring('__mod', true)); - L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring('__pow', true)); - L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring('__div', true)); - L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring('__idiv', true)); - L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring('__band', true)); - L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring('__bor', true)); - L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring('__bxor', true)); - L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring('__shl', true)); - L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring('__shr', true)); - L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring('__unm', true)); - L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring('__bnot', true)); - L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring('__lt', true)); - L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring('__le', true)); - L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring('__concat', true)); - L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring('__call', true)); +const luaT_init = function (L) { + L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring("__index", true)); + L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring("__newindex", true)); + L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring("__gc", true)); + L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring("__mode", true)); + L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring("__len", true)); + L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring("__eq", true)); + L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring("__add", true)); + L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring("__sub", true)); + L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring("__mul", true)); + L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring("__mod", true)); + L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring("__pow", true)); + L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring("__div", true)); + L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring("__idiv", true)); + L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring("__band", true)); + L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring("__bor", true)); + L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring("__bxor", true)); + L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring("__shl", true)); + L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring("__shr", true)); + L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring("__unm", true)); + L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring("__bnot", true)); + L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring("__lt", true)); + L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring("__le", true)); + L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring("__concat", true)); + L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring("__call", true)); }; /* @@ -99,40 +96,40 @@ const luaT_init = function(L) { ** with metatable, use their '__name' metafield, if present. */ const __name = to_luastring('__name', true); -const luaT_objtypename = function(L, o) { +const luaT_objtypename = function (L, o) { let mt; if ((o.ttistable() && (mt = o.value.metatable) !== null) || (o.ttisfulluserdata() && (mt = o.value.metatable) !== null)) { - let name = ltable.luaH_getstr(mt, luaS_bless(L, __name)); + let name = luaH_getstr(mt, luaS_bless(L, __name)); if (name.ttisstring()) return name.svalue(); } return ttypename(o.ttnov()); }; -const luaT_callTM = function(L, f, p1, p2, p3, hasres) { +const luaT_callTM = function (L, f, p1, p2, p3, hasres) { let func = L.top; - lobject.pushobj2s(L, f); /* push function (assume EXTRA_STACK) */ - lobject.pushobj2s(L, p1); /* 1st argument */ - lobject.pushobj2s(L, p2); /* 2nd argument */ + pushobj2s(L, f); /* push function (assume EXTRA_STACK) */ + pushobj2s(L, p1); /* 1st argument */ + pushobj2s(L, p2); /* 2nd argument */ if (!hasres) /* no result? 'p3' is third argument */ - lobject.pushobj2s(L, p3); /* 3rd argument */ + pushobj2s(L, p3); /* 3rd argument */ - if (L.ci.callstatus & lstate.CIST_LUA) - ldo.luaD_call(L, func, hasres); + if (L.ci.callstatus & CIST_LUA) + luaD_call(L, func, hasres); else - ldo.luaD_callnoyield(L, func, hasres); + luaD_callnoyield(L, func, hasres); if (hasres) { /* if has result, move it to its place */ - let tv = L.stack[L.top-1]; + let tv = L.stack[L.top - 1]; delete L.stack[--L.top]; p3.setfrom(tv); } }; -const luaT_callbinTM = function(L, p1, p2, res, event) { +const luaT_callbinTM = function (L, p1, p2, res, event) { let tm = luaT_gettmbyobj(L, p1, event); if (tm.ttisnil()) tm = luaT_gettmbyobj(L, p2, event); @@ -141,52 +138,52 @@ const luaT_callbinTM = function(L, p1, p2, res, event) { return true; }; -const luaT_trybinTM = function(L, p1, p2, res, event) { +const luaT_trybinTM = function (L, p1, p2, res, event) { if (!luaT_callbinTM(L, p1, p2, res, event)) { switch (event) { case TMS.TM_CONCAT: - return ldebug.luaG_concaterror(L, p1, p2); + return luaG_concaterror(L, p1, p2); case TMS.TM_BAND: case TMS.TM_BOR: case TMS.TM_BXOR: case TMS.TM_SHL: case TMS.TM_SHR: case TMS.TM_BNOT: { - let n1 = lvm.tonumber(p1); - let n2 = lvm.tonumber(p2); + let n1 = tonumber(p1); + let n2 = tonumber(p2); if (n1 !== false && n2 !== false) - return ldebug.luaG_tointerror(L, p1, p2); + return luaG_tointerror(L, p1, p2); else - return ldebug.luaG_opinterror(L, p1, p2, to_luastring('perform bitwise operation on', true)); + return luaG_opinterror(L, p1, p2, to_luastring("perform bitwise operation on", true)); } default: - return ldebug.luaG_opinterror(L, p1, p2, to_luastring('perform arithmetic on', true)); + return luaG_opinterror(L, p1, p2, to_luastring("perform arithmetic on", true)); } } }; -const luaT_callorderTM = function(L, p1, p2, event) { - let res = new lobject.TValue(); +const luaT_callorderTM = function (L, p1, p2, event) { + let res = new TValue(); if (!luaT_callbinTM(L, p1, p2, res, event)) return null; else return !res.l_isfalse(); }; -const fasttm = function(l, et, e) { +const fasttm = function (l, et, e) { return et === null ? null : (et.flags & (1 << e)) ? null : luaT_gettm(et, e, l.l_G.tmname[e]); }; -const luaT_gettm = function(events, event, ename) { - const tm = ltable.luaH_getstr(events, ename); +const luaT_gettm = function (events, event, ename) { + const tm = luaH_getstr(events, ename); lua_assert(event <= TMS.TM_EQ); if (tm.ttisnil()) { /* no tag method? */ - events.flags |= 1<= LUA_MININTEGER && n < -LUA_MININTEGER ? n : false; }; @@ -126,9 +162,9 @@ const LUA_INTEGER_FRMLEN = ""; const LUA_NUMBER_FRMLEN = ""; const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; -const LUA_NUMBER_FMT = "%.14g"; +const LUA_NUMBER_FMT = "%.14g"; -const lua_getlocaledecpoint = function () { +const lua_getlocaledecpoint = function() { /* we hard-code the decimal point to '.' as a user cannot change the locale in most JS environments, and in that you can, a multi-byte locale is common. @@ -142,7 +178,7 @@ const lua_getlocaledecpoint = function () { const LUAL_BUFFERSIZE = conf.LUAL_BUFFERSIZE || 8192; // See: http://croquetweak.blogspot.fr/2014/08/deconstructing-floats-frexp-and-ldexp.html -const frexp = function (value) { +const frexp = function(value) { if (value === 0) return [value, 0]; var data = new DataView(new ArrayBuffer(8)); data.setFloat64(0, value); @@ -156,7 +192,7 @@ const frexp = function (value) { return [mantissa, exponent]; }; -const ldexp = function (mantissa, exponent) { +const ldexp = function(mantissa, exponent) { var steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023)); var result = mantissa; for (var i = 0; i < steps; i++) @@ -164,21 +200,35 @@ const ldexp = function (mantissa, exponent) { return result; }; -{ - LUAI_MAXSTACK, - LUA_COMPAT_FLOATSTRING, - LUA_IDSIZE, - LUA_INTEGER_FMT, - LUA_INTEGER_FRMLEN, - LUA_MAXINTEGER, - LUA_MININTEGER, - LUA_NUMBER_FMT, - LUA_NUMBER_FRMLEN, - LUAL_BUFFERSIZE, - frexp, - ldexp, - lua_getlocaledecpoint, - lua_integer2str, - lua_number2str, - lua_numbertointeger -}; +const _LUAI_MAXSTACK = LUAI_MAXSTACK; +export { _LUAI_MAXSTACK as LUAI_MAXSTACK }; +const _LUA_COMPAT_FLOATSTRING = LUA_COMPAT_FLOATSTRING; +export { _LUA_COMPAT_FLOATSTRING as LUA_COMPAT_FLOATSTRING }; +const _LUA_IDSIZE = LUA_IDSIZE; +export { _LUA_IDSIZE as LUA_IDSIZE }; +const _LUA_INTEGER_FMT = LUA_INTEGER_FMT; +export { _LUA_INTEGER_FMT as LUA_INTEGER_FMT }; +const _LUA_INTEGER_FRMLEN = LUA_INTEGER_FRMLEN; +export { _LUA_INTEGER_FRMLEN as LUA_INTEGER_FRMLEN }; +const _LUA_MAXINTEGER = LUA_MAXINTEGER; +export { _LUA_MAXINTEGER as LUA_MAXINTEGER }; +const _LUA_MININTEGER = LUA_MININTEGER; +export { _LUA_MININTEGER as LUA_MININTEGER }; +const _LUA_NUMBER_FMT = LUA_NUMBER_FMT; +export { _LUA_NUMBER_FMT as LUA_NUMBER_FMT }; +const _LUA_NUMBER_FRMLEN = LUA_NUMBER_FRMLEN; +export { _LUA_NUMBER_FRMLEN as LUA_NUMBER_FRMLEN }; +const _LUAL_BUFFERSIZE = LUAL_BUFFERSIZE; +export { _LUAL_BUFFERSIZE as LUAL_BUFFERSIZE }; +const _frexp = frexp; +export { _frexp as frexp }; +const _ldexp = ldexp; +export { _ldexp as ldexp }; +const _lua_getlocaledecpoint = lua_getlocaledecpoint; +export { _lua_getlocaledecpoint as lua_getlocaledecpoint }; +const _lua_integer2str = lua_integer2str; +export { _lua_integer2str as lua_integer2str }; +const _lua_number2str = lua_number2str; +export { _lua_number2str as lua_number2str }; +const _lua_numbertointeger = lua_numbertointeger; +export { _lua_numbertointeger as lua_numbertointeger }; diff --git a/src/lualib.js b/src/lualib.js index 33928abd..889d3b04 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,30 +1,68 @@ -import {LUA_VERSION_MAJOR, LUA_VERSION_MINOR} from "./lua.js"; - -import linit from "./linit.js"; -import {luaopen_fengari} from "./fengarilib.js"; -import {luaopen_package} from "./loadlib.js"; -import {luaopen_debug} from "./ldblib.js"; -import {luaopen_math} from "./lmathlib.js"; -import {luaopen_utf8} from "./lutf8lib.js"; -import {luaopen_string} from "./lstrlib.js"; -import {luaopen_os} from "./loslib.js"; -import {luaopen_io} from "./liolib.js"; -import {luaopen_table} from "./ltablib.js"; -import {luaopen_coroutine} from "./lcorolib.js"; -import {luaopen_base} from "./lbaselib.js"; - -const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; -const LUA_COLIBNAME = 'coroutine'; -const LUA_TABLIBNAME = 'table'; -const LUA_IOLIBNAME = 'io'; -const LUA_OSLIBNAME = 'os'; -const LUA_STRLIBNAME = 'string'; -const LUA_UTF8LIBNAME = 'utf8'; -const LUA_BITLIBNAME = 'bit32'; +import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR } from "./lua.js"; + +const LUA_VERSUFFIX = "_" + LUA_VERSION_MAJOR + "_" + LUA_VERSION_MINOR; +const _LUA_VERSUFFIX = LUA_VERSUFFIX; +export { _LUA_VERSUFFIX as LUA_VERSUFFIX }; + +export function lua_assert(c) { } + +export const luaopen_base = require("./lbaselib.js").luaopen_base; + +const LUA_COLIBNAME = "coroutine"; +const _LUA_COLIBNAME = LUA_COLIBNAME; +export { _LUA_COLIBNAME as LUA_COLIBNAME }; +export const luaopen_coroutine = require("./lcorolib.js").luaopen_coroutine; + +const LUA_TABLIBNAME = "table"; +const _LUA_TABLIBNAME = LUA_TABLIBNAME; +export { _LUA_TABLIBNAME as LUA_TABLIBNAME }; +export const luaopen_table = require("./ltablib.js").luaopen_table; + +if (typeof process !== "undefined") { + const LUA_IOLIBNAME = "io"; + module.exports.LUA_IOLIBNAME = LUA_IOLIBNAME; + module.exports.luaopen_io = require("./liolib.js").luaopen_io; +} + +const LUA_OSLIBNAME = "os"; +const _LUA_OSLIBNAME = LUA_OSLIBNAME; +export { _LUA_OSLIBNAME as LUA_OSLIBNAME }; +export const luaopen_os = require("./loslib.js").luaopen_os; + +const LUA_STRLIBNAME = "string"; +const _LUA_STRLIBNAME = LUA_STRLIBNAME; +export { _LUA_STRLIBNAME as LUA_STRLIBNAME }; +export const luaopen_string = require("./lstrlib.js").luaopen_string; + +const LUA_UTF8LIBNAME = "utf8"; +const _LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; +export { _LUA_UTF8LIBNAME as LUA_UTF8LIBNAME }; +export const luaopen_utf8 = require("./lutf8lib.js").luaopen_utf8; + +const LUA_BITLIBNAME = "bit32"; +const _LUA_BITLIBNAME = LUA_BITLIBNAME; +export { _LUA_BITLIBNAME as LUA_BITLIBNAME }; // module.exports.luaopen_bit32 = require("./lbitlib.js").luaopen_bit32; -const LUA_MATHLIBNAME = 'math'; -const LUA_DBLIBNAME = 'debug'; -const LUA_LOADLIBNAME = 'package'; -const LUA_FENGARILIBNAME = 'fengari'; -const luaL_openlibs = linit.luaL_openlibs; +const LUA_MATHLIBNAME = "math"; +const _LUA_MATHLIBNAME = LUA_MATHLIBNAME; +export { _LUA_MATHLIBNAME as LUA_MATHLIBNAME }; +export const luaopen_math = require("./lmathlib.js").luaopen_math; + +const LUA_DBLIBNAME = "debug"; +const _LUA_DBLIBNAME = LUA_DBLIBNAME; +export { _LUA_DBLIBNAME as LUA_DBLIBNAME }; +export const luaopen_debug = require("./ldblib.js").luaopen_debug; + +const LUA_LOADLIBNAME = "package"; +const _LUA_LOADLIBNAME = LUA_LOADLIBNAME; +export { _LUA_LOADLIBNAME as LUA_LOADLIBNAME }; +export const luaopen_package = require("./loadlib.js").luaopen_package; + +const LUA_FENGARILIBNAME = "fengari"; +const _LUA_FENGARILIBNAME = LUA_FENGARILIBNAME; +export { _LUA_FENGARILIBNAME as LUA_FENGARILIBNAME }; +export const luaopen_fengari = require("./fengarilib.js").luaopen_fengari; + +import { luaL_openlibs } from './linit.js'; +export const luaL_openlibs = luaL_openlibs; diff --git a/src/lundump.js b/src/lundump.js index cb1c57b8..f7dce294 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -1,47 +1,22 @@ -import { - is_luastring, - LUA_ERRSYNTAX, - LUA_SIGNATURE, - LUA_TBOOLEAN, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR, luastring_eq, to_luastring -} from "./defs.js"; -import * as ldo from "./ldo.js"; -import * as lfunc from "./lfunc.js"; -import * as lobject from "./lobject.js"; -import { - MAXARG_sBx, - POS_A, - POS_Ax, - POS_B, - POS_Bx, - POS_C, - POS_OP, - SIZE_A, - SIZE_Ax, - SIZE_B, - SIZE_Bx, - SIZE_C, SIZE_OP -} from "./lopcodes.js"; - -import {ZIO} from "./lzio.js"; -import {luaZ_read, ZIO} from "./lzio.js"; -import {luaS_bless} from "./lstring.js"; -import {lua_assert} from "./llimits.js"; - - -const constant_types = { +import { LUA_SIGNATURE, constant_types, thread_status, is_luastring, luastring_eq, to_luastring } from './defs.js'; +import { luaD_throw, luaD_inctop } from './ldo.js'; +import { Proto, luaF_newLclosure } from './lfunc.js'; +import { TValue, luaO_pushfstring } from './lobject.js'; +import { MAXARG_sBx, POS_A, POS_Ax, POS_B, POS_Bx, POS_C, POS_OP, SIZE_A, SIZE_Ax, SIZE_B, SIZE_Bx, SIZE_C, SIZE_OP } from './lopcodes.js'; +import { lua_assert } from "./llimits.js"; +import { luaS_bless } from './lstring.js'; +import { luaZ_read, ZIO } from './lzio.js'; + +const { LUA_TBOOLEAN, LUA_TLNGSTR, LUA_TNIL, LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR -}; -const thread_status = {LUA_ERRSYNTAX}; +} = constant_types; + +const { LUA_ERRSYNTAX } = thread_status; let LUAC_DATA = [0x19, 0x93, 13, 10, 0x1a, 10]; @@ -54,13 +29,13 @@ class BytecodeParser { this.integerSize = 4; this.numberSize = 8; - lua_assert(Z instanceof ZIO, 'BytecodeParser only operates on a ZIO'); + lua_assert(Z instanceof ZIO, "BytecodeParser only operates on a ZIO"); lua_assert(is_luastring(name)); if (name[0] === 64 /* ('@').charCodeAt(0) */ || name[0] === 61 /* ('=').charCodeAt(0) */) this.name = name.subarray(1); else if (name[0] == LUA_SIGNATURE[0]) - this.name = to_luastring('binary string', true); + this.name = to_luastring("binary string", true); else this.name = name; @@ -78,31 +53,31 @@ class BytecodeParser { read(size) { let u8 = new Uint8Array(size); if (luaZ_read(this.Z, u8, 0, size) !== 0) - this.error('truncated'); + this.error("truncated"); return u8; } LoadByte() { if (luaZ_read(this.Z, this.u8, 0, 1) !== 0) - this.error('truncated'); + this.error("truncated"); return this.u8[0]; } LoadInt() { if (luaZ_read(this.Z, this.u8, 0, this.intSize) !== 0) - this.error('truncated'); + this.error("truncated"); return this.dv.getInt32(0, true); } LoadNumber() { if (luaZ_read(this.Z, this.u8, 0, this.numberSize) !== 0) - this.error('truncated'); + this.error("truncated"); return this.dv.getFloat64(0, true); } LoadInteger() { if (luaZ_read(this.Z, this.u8, 0, this.integerSize) !== 0) - this.error('truncated'); + this.error("truncated"); return this.dv.getInt32(0, true); } @@ -130,7 +105,7 @@ class BytecodeParser { for (let i = 0; i < n; i++) { if (luaZ_read(this.Z, this.u8, 0, this.instructionSize) !== 0) - this.error('truncated'); + this.error("truncated"); let ins = this.dv.getUint32(0, true); f.code[i] = { code: ins, @@ -153,20 +128,20 @@ class BytecodeParser { switch (t) { case LUA_TNIL: - f.k.push(new lobject.TValue(LUA_TNIL, null)); + f.k.push(new TValue(LUA_TNIL, null)); break; case LUA_TBOOLEAN: - f.k.push(new lobject.TValue(LUA_TBOOLEAN, this.LoadByte() !== 0)); + f.k.push(new TValue(LUA_TBOOLEAN, this.LoadByte() !== 0)); break; case LUA_TNUMFLT: - f.k.push(new lobject.TValue(LUA_TNUMFLT, this.LoadNumber())); + f.k.push(new TValue(LUA_TNUMFLT, this.LoadNumber())); break; case LUA_TNUMINT: - f.k.push(new lobject.TValue(LUA_TNUMINT, this.LoadInteger())); + f.k.push(new TValue(LUA_TNUMINT, this.LoadInteger())); break; case LUA_TSHRSTR: case LUA_TLNGSTR: - f.k.push(new lobject.TValue(LUA_TLNGSTR, this.LoadString())); + f.k.push(new TValue(LUA_TLNGSTR, this.LoadString())); break; default: this.error(`unrecognized constant '${t}'`); @@ -178,7 +153,7 @@ class BytecodeParser { let n = this.LoadInt(); for (let i = 0; i < n; i++) { - f.p[i] = new lfunc.Proto(this.L); + f.p[i] = new Proto(this.L); this.LoadFunction(f.p[i], f.source); } } @@ -238,15 +213,15 @@ class BytecodeParser { } checkHeader() { - this.checkliteral(LUA_SIGNATURE.subarray(1), 'not a'); /* 1st char already checked */ + this.checkliteral(LUA_SIGNATURE.subarray(1), "not a"); /* 1st char already checked */ if (this.LoadByte() !== 0x53) - this.error('version mismatch in'); + this.error("version mismatch in"); if (this.LoadByte() !== 0) - this.error('format mismatch in'); + this.error("format mismatch in"); - this.checkliteral(LUAC_DATA, 'corrupted'); + this.checkliteral(LUAC_DATA, "corrupted"); this.intSize = this.LoadByte(); this.size_tSize = this.LoadByte(); @@ -254,23 +229,23 @@ class BytecodeParser { this.integerSize = this.LoadByte(); this.numberSize = this.LoadByte(); - this.checksize(this.intSize, 4, 'int'); - this.checksize(this.size_tSize, 4, 'size_t'); - this.checksize(this.instructionSize, 4, 'instruction'); - this.checksize(this.integerSize, 4, 'integer'); - this.checksize(this.numberSize, 8, 'number'); + this.checksize(this.intSize, 4, "int"); + this.checksize(this.size_tSize, 4, "size_t"); + this.checksize(this.instructionSize, 4, "instruction"); + this.checksize(this.integerSize, 4, "integer"); + this.checksize(this.numberSize, 8, "number"); if (this.LoadInteger() !== 0x5678) - this.error('endianness mismatch in'); + this.error("endianness mismatch in"); if (this.LoadNumber() !== 370.5) - this.error('float format mismatch in'); + this.error("float format mismatch in"); } error(why) { - lobject.luaO_pushfstring(this.L, to_luastring('%s: %s precompiled chunk'), this.name, to_luastring(why)); - ldo.luaD_throw(this.L, LUA_ERRSYNTAX); + luaO_pushfstring(this.L, to_luastring("%s: %s precompiled chunk"), this.name, to_luastring(why)); + luaD_throw(this.L, LUA_ERRSYNTAX); } checksize(byte, size, tname) { @@ -282,12 +257,15 @@ class BytecodeParser { const luaU_undump = function (L, Z, name) { let S = new BytecodeParser(L, Z, name); S.checkHeader(); - let cl = lfunc.luaF_newLclosure(L, S.LoadByte()); - ldo.luaD_inctop(L); + let cl = luaF_newLclosure(L, S.LoadByte()); + luaD_inctop(L); L.stack[L.top - 1].setclLvalue(cl); - cl.p = new lfunc.Proto(L); + cl.p = new Proto(L); S.LoadFunction(cl.p, null); lua_assert(cl.nupvalues === cl.p.upvalues.length); /* luai_verifycode */ return cl; }; + +const _luaU_undump = luaU_undump; +export { _luaU_undump as luaU_undump }; diff --git a/src/lutf8lib.js b/src/lutf8lib.js index 79f4ec00..21b88541 100644 --- a/src/lutf8lib.js +++ b/src/lutf8lib.js @@ -1,23 +1,6 @@ -import { - lua_gettop, - lua_pushcfunction, - lua_pushfstring, - lua_pushinteger, - lua_pushnil, - lua_pushstring, - lua_pushvalue, lua_setfield, lua_tointeger -} from "./lua.js"; - -import { - luaL_addvalue, - luaL_argcheck, - luaL_Buffer, - luaL_buffinit, - luaL_checkinteger, - luaL_checkstack, luaL_checkstring, luaL_error, luaL_newlib, luaL_optinteger, luaL_pushresult -} from "./lauxlib.js"; - -import {luastring_of, to_luastring} from "./fengaricore.js"; +import { lua_gettop, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_setfield, lua_tointeger } from './lua.js'; +import { luaL_Buffer, luaL_addvalue, luaL_argcheck, luaL_buffinit, luaL_checkinteger, luaL_checkstack, luaL_checkstring, luaL_error, luaL_newlib, luaL_optinteger, luaL_pushresult } from './lauxlib.js'; +import { luastring_of, to_luastring } from "./fengaricore.js"; const MAXUNICODE = 0x10FFFF; @@ -75,8 +58,8 @@ const utflen = function(L) { let posi = u_posrelat(luaL_optinteger(L, 2, 1), len); let posj = u_posrelat(luaL_optinteger(L, 3, -1), len); - luaL_argcheck(L, 1 <= posi && --posi <= len, 2, 'initial position out of string'); - luaL_argcheck(L, --posj < len, 3, 'final position out of string'); + luaL_argcheck(L, 1 <= posi && --posi <= len, 2, "initial position out of string"); + luaL_argcheck(L, --posj < len, 3, "final position out of string"); while (posi <= posj) { let dec = utf8_decode(s, posi); @@ -92,10 +75,10 @@ const utflen = function(L) { return 1; }; -const p_U = to_luastring('%U'); +const p_U = to_luastring("%U"); const pushutfchar = function(L, arg) { let code = luaL_checkinteger(L, arg); - luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, 'value out of range'); + luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); lua_pushfstring(L, p_U, code); }; @@ -128,14 +111,14 @@ const byteoffset = function(L) { let posi = n >= 0 ? 1 : s.length + 1; posi = u_posrelat(luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, 'position out of range'); + luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, "position out of range"); if (n === 0) { /* find beginning of current byte sequence */ while (posi > 0 && iscont(s[posi])) posi--; } else { if (iscont(s[posi])) - luaL_error(L, 'initial position is a continuation byte'); + luaL_error(L, "initial position is a continuation byte"); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ @@ -172,19 +155,19 @@ const codepoint = function(L) { let posi = u_posrelat(luaL_optinteger(L, 2, 1), s.length); let pose = u_posrelat(luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, posi >= 1, 2, 'out of range'); - luaL_argcheck(L, pose <= s.length, 3, 'out of range'); + luaL_argcheck(L, posi >= 1, 2, "out of range"); + luaL_argcheck(L, pose <= s.length, 3, "out of range"); if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) - return luaL_error(L, 'string slice too long'); + return luaL_error(L, "string slice too long"); let n = (pose - posi) + 1; - luaL_checkstack(L, n, 'string slice too long'); + luaL_checkstack(L, n, "string slice too long"); n = 0; for (posi -= 1; posi < pose;) { let dec = utf8_decode(s, posi); if (dec === null) - return luaL_error(L, 'invalid UTF-8 code'); + return luaL_error(L, "invalid UTF-8 code"); lua_pushinteger(L, dec.code); posi = dec.pos; n++; @@ -209,7 +192,7 @@ const iter_aux = function(L) { else { let dec = utf8_decode(s, n); if (dec === null || iscont(s[dec.pos])) - return luaL_error(L, to_luastring('invalid UTF-8 code')); + return luaL_error(L, to_luastring("invalid UTF-8 code")); lua_pushinteger(L, n + 1); lua_pushinteger(L, dec.code); return 2; @@ -225,11 +208,11 @@ const iter_codes = function(L) { }; const funcs = { - 'char': utfchar, - 'codepoint': codepoint, - 'codes': iter_codes, - 'len': utflen, - 'offset': byteoffset + "char": utfchar, + "codepoint": codepoint, + "codes": iter_codes, + "len": utflen, + "offset": byteoffset }; /* pattern to match a single UTF-8 character */ @@ -238,6 +221,9 @@ const UTF8PATT = luastring_of(91, 0, 45, 127, 194, 45, 244, 93, 91, 128, 45, 191 const luaopen_utf8 = function(L) { luaL_newlib(L, funcs); lua_pushstring(L, UTF8PATT); - lua_setfield(L, -2, to_luastring('charpattern', true)); + lua_setfield(L, -2, to_luastring("charpattern", true)); return 1; }; + +const _luaopen_utf8 = luaopen_utf8; +export { _luaopen_utf8 as luaopen_utf8 }; diff --git a/src/lvm.js b/src/lvm.js index f5cba0ee..9a9e0ca5 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -1,31 +1,29 @@ -import { - LUA_MASKCOUNT, - LUA_MASKLINE, - LUA_MULTRET, - constant_types, - to_luastring -} from "./defs.js"; - -import { - INDEXK, - ISK, - LFIELDS_PER_FLUSH, - OpCodesI -} from "./lopcodes.js"; - -import {LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger} from "./luaconf.js"; - -import {lua_assert, luai_nummod} from "./llimits.js"; - -import * as lobject from "./lobject.js"; -import * as lfunc from "./lfunc.js"; -import * as lstate from "./lstate.js"; -import {luaS_bless, luaS_eqlngstr, luaS_hashlongstr} from "./lstring.js"; - -import * as ldebug from "./ldebug.js"; -import * as ltable from "./ltable.js"; -import * as ltm from "./ltm.js"; -import * as ldo from "./ldo.js"; +import { LUA_MASKLINE, LUA_MASKCOUNT, LUA_MULTRET, constant_types, to_luastring } from './defs.js'; +import { INDEXK, ISK, LFIELDS_PER_FLUSH, OpCodesI } from './lopcodes.js'; +import { LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger } from './luaconf.js'; +import { lua_assert, luai_nummod } from './llimits.js'; +import { setobjs2s, setobj2s, TValue, luaO_str2num, LClosure, luaO_tostring, setsvalue2s } from './lobject.js'; +import { luaF_close, luaF_findupval } from './lfunc.js'; +import { CIST_LEQ, CIST_FRESH, CIST_TAIL, CIST_LUA } from './lstate.js'; +import { luaS_bless, luaS_eqlngstr, luaS_hashlongstr } from './lstring.js'; +import { adjust_top, luaD_precall, luaD_poscall, luaD_call, luaD_checkstack } from './ldo.js'; +import { luaT_trybinTM, TMS, luaT_callorderTM, fasttm, luaT_callTM, luaT_gettmbyobj } from './ltm.js'; +import { luaH_new, luaH_setint, luaH_getn, luaH_get, luaH_setfrom, invalidateTMcache } from './ltable.js'; +import { luaG_traceexec, luaG_runerror, luaG_ordererror, luaG_typeerror } from './ldebug.js'; + +const { + LUA_TBOOLEAN, + LUA_TLCF, + LUA_TLIGHTUSERDATA, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMBER, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, + LUA_TTABLE, + LUA_TUSERDATA +} = constant_types; const { OP_ADD, @@ -77,20 +75,6 @@ const { OP_VARARG } = OpCodesI; -const { - LUA_TBOOLEAN, - LUA_TLCF, - LUA_TLIGHTUSERDATA, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMBER, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR, - LUA_TTABLE, - LUA_TUSERDATA -} = constant_types; - /* ** finish execution of an opcode interrupted by an yield */ @@ -101,36 +85,21 @@ const luaV_finishOp = function (L) { let op = inst.opcode; switch (op) { /* finish its execution */ - case OP_ADD: - case OP_SUB: - case OP_MUL: - case OP_DIV: - case OP_IDIV: - case OP_BAND: - case OP_BOR: - case OP_BXOR: - case OP_SHL: - case OP_SHR: - case OP_MOD: - case OP_POW: - case OP_UNM: - case OP_BNOT: - case OP_LEN: - case OP_GETTABUP: - case OP_GETTABLE: - case OP_SELF: { - lobject.setobjs2s(L, base + inst.A, L.top - 1); + case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_IDIV: + case OP_BAND: case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: + case OP_MOD: case OP_POW: + case OP_UNM: case OP_BNOT: case OP_LEN: + case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { + setobjs2s(L, base + inst.A, L.top - 1); delete L.stack[--L.top]; break; } - case OP_LE: - case OP_LT: - case OP_EQ: { + case OP_LE: case OP_LT: case OP_EQ: { let res = !L.stack[L.top - 1].l_isfalse(); delete L.stack[--L.top]; - if (ci.callstatus & lstate.CIST_LEQ) { /* "<=" using "<" instead? */ + if (ci.callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ lua_assert(op === OP_LE); - ci.callstatus ^= lstate.CIST_LEQ; /* clear mark */ + ci.callstatus ^= CIST_LEQ; /* clear mark */ res = !res; /* negate result */ } lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_JMP); @@ -142,24 +111,24 @@ const luaV_finishOp = function (L) { let top = L.top - 1; /* top when 'luaT_trybinTM' was called */ let b = inst.B; /* first element to concatenate */ let total = top - 1 - (base + b); /* yet to concatenate */ - lobject.setobjs2s(L, top - 2, top); /* put TM result in proper position */ + setobjs2s(L, top - 2, top); /* put TM result in proper position */ if (total > 1) { /* are there elements to concat? */ L.top = top - 1; /* top is one after last element (at top-2) */ luaV_concat(L, total); /* concat them (may yield again) */ } /* move final result to final position */ - lobject.setobjs2s(L, ci.l_base + inst.A, L.top - 1); - ldo.adjust_top(L, ci.top); /* restore top */ + setobjs2s(L, ci.l_base + inst.A, L.top - 1); + adjust_top(L, ci.top); /* restore top */ break; } case OP_TFORCALL: { lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_TFORLOOP); - ldo.adjust_top(L, ci.top); /* correct top */ + adjust_top(L, ci.top); /* correct top */ break; } case OP_CALL: { if (inst.C - 1 >= 0) /* nresults >= 0? */ - ldo.adjust_top(L, ci.top); /* adjust results */ + adjust_top(L, ci.top); /* adjust results */ break; } } @@ -188,528 +157,528 @@ const RKC = function (L, base, k, i) { const luaV_execute = function (L) { let ci = L.ci; - ci.callstatus |= lstate.CIST_FRESH; + ci.callstatus |= CIST_FRESH; newframe: - for (; ;) { - lua_assert(ci === L.ci); - let cl = ci.func.value; - let k = cl.p.k; - let base = ci.l_base; + for (; ;) { + lua_assert(ci === L.ci); + let cl = ci.func.value; + let k = cl.p.k; + let base = ci.l_base; - let i = ci.l_code[ci.l_savedpc++]; + let i = ci.l_code[ci.l_savedpc++]; - if (L.hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) { - ldebug.luaG_traceexec(L); - } + if (L.hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) { + luaG_traceexec(L); + } - let ra = RA(L, base, i); - let opcode = i.opcode; + let ra = RA(L, base, i); + let opcode = i.opcode; - switch (opcode) { - case OP_MOVE: { - lobject.setobjs2s(L, ra, RB(L, base, i)); - break; - } - case OP_LOADK: { - let konst = k[i.Bx]; - lobject.setobj2s(L, ra, konst); - break; - } - case OP_LOADKX: { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); - let konst = k[ci.l_code[ci.l_savedpc++].Ax]; - lobject.setobj2s(L, ra, konst); - break; - } - case OP_LOADBOOL: { - L.stack[ra].setbvalue(i.B !== 0); + switch (opcode) { + case OP_MOVE: { + setobjs2s(L, ra, RB(L, base, i)); + break; + } + case OP_LOADK: { + let konst = k[i.Bx]; + setobj2s(L, ra, konst); + break; + } + case OP_LOADKX: { + lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); + let konst = k[ci.l_code[ci.l_savedpc++].Ax]; + setobj2s(L, ra, konst); + break; + } + case OP_LOADBOOL: { + L.stack[ra].setbvalue(i.B !== 0); - if (i.C !== 0) - ci.l_savedpc++; /* skip next instruction (if C) */ + if (i.C !== 0) + ci.l_savedpc++; /* skip next instruction (if C) */ - break; - } - case OP_LOADNIL: { - for (let j = 0; j <= i.B; j++) - L.stack[ra + j].setnilvalue(); - break; - } - case OP_GETUPVAL: { - let b = i.B; - lobject.setobj2s(L, ra, cl.upvals[b]); - break; - } - case OP_GETTABUP: { - let upval = cl.upvals[i.B]; - let rc = RKC(L, base, k, i); - luaV_gettable(L, upval, rc, ra); - break; - } - case OP_GETTABLE: { - let rb = L.stack[RB(L, base, i)]; - let rc = RKC(L, base, k, i); - luaV_gettable(L, rb, rc, ra); - break; - } - case OP_SETTABUP: { - let upval = cl.upvals[i.A]; - let rb = RKB(L, base, k, i); - let rc = RKC(L, base, k, i); - settable(L, upval, rb, rc); - break; - } - case OP_SETUPVAL: { - let uv = cl.upvals[i.B]; - uv.setfrom(L.stack[ra]); - break; - } - case OP_SETTABLE: { - let table = L.stack[ra]; - let key = RKB(L, base, k, i); - let v = RKC(L, base, k, i); + break; + } + case OP_LOADNIL: { + for (let j = 0; j <= i.B; j++) + L.stack[ra + j].setnilvalue(); + break; + } + case OP_GETUPVAL: { + let b = i.B; + setobj2s(L, ra, cl.upvals[b]); + break; + } + case OP_GETTABUP: { + let upval = cl.upvals[i.B]; + let rc = RKC(L, base, k, i); + luaV_gettable(L, upval, rc, ra); + break; + } + case OP_GETTABLE: { + let rb = L.stack[RB(L, base, i)]; + let rc = RKC(L, base, k, i); + luaV_gettable(L, rb, rc, ra); + break; + } + case OP_SETTABUP: { + let upval = cl.upvals[i.A]; + let rb = RKB(L, base, k, i); + let rc = RKC(L, base, k, i); + settable(L, upval, rb, rc); + break; + } + case OP_SETUPVAL: { + let uv = cl.upvals[i.B]; + uv.setfrom(L.stack[ra]); + break; + } + case OP_SETTABLE: { + let table = L.stack[ra]; + let key = RKB(L, base, k, i); + let v = RKC(L, base, k, i); - settable(L, table, key, v); - break; - } - case OP_NEWTABLE: { - L.stack[ra].sethvalue(ltable.luaH_new(L)); - break; - } - case OP_SELF: { - let rb = RB(L, base, i); - let rc = RKC(L, base, k, i); - lobject.setobjs2s(L, ra + 1, rb); - luaV_gettable(L, L.stack[rb], rc, ra); - break; - } - case OP_ADD: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue((op1.value + op2.value) | 0); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 + numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_ADD); - } - break; + settable(L, table, key, v); + break; + } + case OP_NEWTABLE: { + L.stack[ra].sethvalue(luaH_new(L)); + break; + } + case OP_SELF: { + let rb = RB(L, base, i); + let rc = RKC(L, base, k, i); + setobjs2s(L, ra + 1, rb); + luaV_gettable(L, L.stack[rb], rc, ra); + break; + } + case OP_ADD: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue((op1.value + op2.value) | 0); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 + numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_ADD); } - case OP_SUB: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue((op1.value - op2.value) | 0); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 - numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SUB); - } - break; + break; + } + case OP_SUB: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue((op1.value - op2.value) | 0); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 - numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_SUB); } - case OP_MUL: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue(luaV_imul(op1.value, op2.value)); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 * numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MUL); - } - break; + break; + } + case OP_MUL: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue(luaV_imul(op1.value, op2.value)); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 * numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_MUL); } - case OP_MOD: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue(luaV_mod(L, op1.value, op2.value)); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(luai_nummod(L, numberop1, numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MOD); - } - break; + break; + } + case OP_MOD: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue(luaV_mod(L, op1.value, op2.value)); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(luai_nummod(L, numberop1, numberop2)); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_MOD); } - case OP_POW: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(Math.pow(numberop1, numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_POW); - } - break; + break; + } + case OP_POW: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(Math.pow(numberop1, numberop2)); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_POW); } - case OP_DIV: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(numberop1 / numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_DIV); - } - break; + break; + } + case OP_DIV: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(numberop1 / numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_DIV); } - case OP_IDIV: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue(luaV_div(L, op1.value, op2.value)); - } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(Math.floor(numberop1 / numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_IDIV); - } - break; + break; + } + case OP_IDIV: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if (op1.ttisinteger() && op2.ttisinteger()) { + L.stack[ra].setivalue(luaV_div(L, op1.value, op2.value)); + } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { + L.stack[ra].setfltvalue(Math.floor(numberop1 / numberop2)); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_IDIV); } - case OP_BAND: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(numberop1 & numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BAND); - } - break; + break; + } + case OP_BAND: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(numberop1 & numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_BAND); } - case OP_BOR: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(numberop1 | numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BOR); - } - break; + break; + } + case OP_BOR: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(numberop1 | numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_BOR); } - case OP_BXOR: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(numberop1 ^ numberop2); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BXOR); - } - break; + break; + } + case OP_BXOR: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(numberop1 ^ numberop2); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_BXOR); } - case OP_SHL: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(luaV_shiftl(numberop1, numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHL); - } - break; + break; + } + case OP_SHL: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(luaV_shiftl(numberop1, numberop2)); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_SHL); } - case OP_SHR: { - let op1 = RKB(L, base, k, i); - let op2 = RKC(L, base, k, i); - let numberop1, numberop2; - - if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { - L.stack[ra].setivalue(luaV_shiftl(numberop1, -numberop2)); - } else { - ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHR); - } - break; + break; + } + case OP_SHR: { + let op1 = RKB(L, base, k, i); + let op2 = RKC(L, base, k, i); + let numberop1, numberop2; + + if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { + L.stack[ra].setivalue(luaV_shiftl(numberop1, -numberop2)); + } else { + luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_SHR); } - case OP_UNM: { - let op = L.stack[RB(L, base, i)]; - let numberop; - - if (op.ttisinteger()) { - L.stack[ra].setivalue((-op.value) | 0); - } else if ((numberop = tonumber(op)) !== false) { - L.stack[ra].setfltvalue(-numberop); - } else { - ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_UNM); - } - break; + break; + } + case OP_UNM: { + let op = L.stack[RB(L, base, i)]; + let numberop; + + if (op.ttisinteger()) { + L.stack[ra].setivalue((-op.value) | 0); + } else if ((numberop = tonumber(op)) !== false) { + L.stack[ra].setfltvalue(-numberop); + } else { + luaT_trybinTM(L, op, op, L.stack[ra], TMS.TM_UNM); } - case OP_BNOT: { - let op = L.stack[RB(L, base, i)]; + break; + } + case OP_BNOT: { + let op = L.stack[RB(L, base, i)]; - if (op.ttisinteger()) { - L.stack[ra].setivalue(~op.value); - } else { - ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_BNOT); - } - break; + if (op.ttisinteger()) { + L.stack[ra].setivalue(~op.value); + } else { + luaT_trybinTM(L, op, op, L.stack[ra], TMS.TM_BNOT); } - case OP_NOT: { - let op = L.stack[RB(L, base, i)]; - L.stack[ra].setbvalue(op.l_isfalse()); - break; - } - case OP_LEN: { - luaV_objlen(L, L.stack[ra], L.stack[RB(L, base, i)]); - break; - } - case OP_CONCAT: { - let b = i.B; - let c = i.C; - L.top = base + c + 1; /* mark the end of concat operands */ - luaV_concat(L, c - b + 1); - let rb = base + b; - lobject.setobjs2s(L, ra, rb); - ldo.adjust_top(L, ci.top); /* restore top */ - break; - } - case OP_JMP: { - dojump(L, ci, i, 0); - break; - } - case OP_EQ: { - if (luaV_equalobj(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_LT: { - if (luaV_lessthan(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_LE: { - if (luaV_lessequal(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) - ci.l_savedpc++; - else - donextjump(L, ci); - break; - } - case OP_TEST: { - if (i.C ? L.stack[ra].l_isfalse() : !L.stack[ra].l_isfalse()) - ci.l_savedpc++; - else - donextjump(L, ci); - break; + break; + } + case OP_NOT: { + let op = L.stack[RB(L, base, i)]; + L.stack[ra].setbvalue(op.l_isfalse()); + break; + } + case OP_LEN: { + luaV_objlen(L, L.stack[ra], L.stack[RB(L, base, i)]); + break; + } + case OP_CONCAT: { + let b = i.B; + let c = i.C; + L.top = base + c + 1; /* mark the end of concat operands */ + luaV_concat(L, c - b + 1); + let rb = base + b; + setobjs2s(L, ra, rb); + adjust_top(L, ci.top); /* restore top */ + break; + } + case OP_JMP: { + dojump(L, ci, i, 0); + break; + } + case OP_EQ: { + if (luaV_equalobj(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_LT: { + if (luaV_lessthan(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_LE: { + if (luaV_lessequal(L, RKB(L, base, k, i), RKC(L, base, k, i)) !== i.A) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_TEST: { + if (i.C ? L.stack[ra].l_isfalse() : !L.stack[ra].l_isfalse()) + ci.l_savedpc++; + else + donextjump(L, ci); + break; + } + case OP_TESTSET: { + let rbIdx = RB(L, base, i); + let rb = L.stack[rbIdx]; + if (i.C ? rb.l_isfalse() : !rb.l_isfalse()) + ci.l_savedpc++; + else { + setobjs2s(L, ra, rbIdx); + donextjump(L, ci); } - case OP_TESTSET: { - let rbIdx = RB(L, base, i); - let rb = L.stack[rbIdx]; - if (i.C ? rb.l_isfalse() : !rb.l_isfalse()) - ci.l_savedpc++; - else { - lobject.setobjs2s(L, ra, rbIdx); - donextjump(L, ci); - } - break; + break; + } + case OP_CALL: { + let b = i.B; + let nresults = i.C - 1; + if (b !== 0) adjust_top(L, ra + b); /* else previous instruction set top */ + if (luaD_precall(L, ra, nresults)) { + if (nresults >= 0) + adjust_top(L, ci.top); /* adjust results */ + } else { + ci = L.ci; + continue newframe; } - case OP_CALL: { - let b = i.B; - let nresults = i.C - 1; - if (b !== 0) ldo.adjust_top(L, ra + b); /* else previous instruction set top */ - if (ldo.luaD_precall(L, ra, nresults)) { - if (nresults >= 0) - ldo.adjust_top(L, ci.top); /* adjust results */ - } else { - ci = L.ci; - continue newframe; - } - break; - } - case OP_TAILCALL: { - let b = i.B; - if (b !== 0) ldo.adjust_top(L, ra + b); /* else previous instruction set top */ - if (ldo.luaD_precall(L, ra, LUA_MULTRET)) { // JS function - } else { - /* tail call: put called frame (n) in place of caller one (o) */ - let nci = L.ci; - let oci = nci.previous; - let nfunc = nci.func; - let nfuncOff = nci.funcOff; - let ofuncOff = oci.funcOff; - let lim = nci.l_base + nfunc.value.p.numparams; - if (cl.p.p.length > 0) lfunc.luaF_close(L, oci.l_base); - for (let aux = 0; nfuncOff + aux < lim; aux++) - lobject.setobjs2s(L, ofuncOff + aux, nfuncOff + aux); - oci.l_base = ofuncOff + (nci.l_base - nfuncOff); - oci.top = ofuncOff + (L.top - nfuncOff); - ldo.adjust_top(L, oci.top); /* correct top */ - oci.l_code = nci.l_code; - oci.l_savedpc = nci.l_savedpc; - oci.callstatus |= lstate.CIST_TAIL; - oci.next = null; - ci = L.ci = oci; - - lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); - - continue newframe; - } - break; - } - case OP_RETURN: { - if (cl.p.p.length > 0) lfunc.luaF_close(L, base); - let b = ldo.luaD_poscall(L, ci, ra, (i.B !== 0 ? i.B - 1 : L.top - ra)); + break; + } + case OP_TAILCALL: { + let b = i.B; + if (b !== 0) adjust_top(L, ra + b); /* else previous instruction set top */ + if (luaD_precall(L, ra, LUA_MULTRET)) { // JS function + } else { + /* tail call: put called frame (n) in place of caller one (o) */ + let nci = L.ci; + let oci = nci.previous; + let nfunc = nci.func; + let nfuncOff = nci.funcOff; + let ofuncOff = oci.funcOff; + let lim = nci.l_base + nfunc.value.p.numparams; + if (cl.p.p.length > 0) luaF_close(L, oci.l_base); + for (let aux = 0; nfuncOff + aux < lim; aux++) + setobjs2s(L, ofuncOff + aux, nfuncOff + aux); + oci.l_base = ofuncOff + (nci.l_base - nfuncOff); + oci.top = ofuncOff + (L.top - nfuncOff); + adjust_top(L, oci.top); /* correct top */ + oci.l_code = nci.l_code; + oci.l_savedpc = nci.l_savedpc; + oci.callstatus |= CIST_TAIL; + oci.next = null; + ci = L.ci = oci; + + lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); - if (ci.callstatus & lstate.CIST_FRESH) - return; /* external invocation: return */ - /* invocation via reentry: continue execution */ - ci = L.ci; - if (b) ldo.adjust_top(L, ci.top); - lua_assert(ci.callstatus & lstate.CIST_LUA); - lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); continue newframe; } - case OP_FORLOOP: { - if (L.stack[ra].ttisinteger()) { /* integer loop? */ - let step = L.stack[ra + 2].value; - let idx = (L.stack[ra].value + step) | 0; - let limit = L.stack[ra + 1].value; - - if (0 < step ? idx <= limit : limit <= idx) { - ci.l_savedpc += i.sBx; - L.stack[ra].chgivalue(idx); /* update internal index... */ - L.stack[ra + 3].setivalue(idx); - } - } else { /* floating loop */ - let step = L.stack[ra + 2].value; - let idx = L.stack[ra].value + step; - let limit = L.stack[ra + 1].value; - - if (0 < step ? idx <= limit : limit <= idx) { - ci.l_savedpc += i.sBx; - L.stack[ra].chgfltvalue(idx); /* update internal index... */ - L.stack[ra + 3].setfltvalue(idx); - } + break; + } + case OP_RETURN: { + if (cl.p.p.length > 0) luaF_close(L, base); + let b = luaD_poscall(L, ci, ra, (i.B !== 0 ? i.B - 1 : L.top - ra)); + + if (ci.callstatus & CIST_FRESH) + return; /* external invocation: return */ + /* invocation via reentry: continue execution */ + ci = L.ci; + if (b) adjust_top(L, ci.top); + lua_assert(ci.callstatus & CIST_LUA); + lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); + continue newframe; + } + case OP_FORLOOP: { + if (L.stack[ra].ttisinteger()) { /* integer loop? */ + let step = L.stack[ra + 2].value; + let idx = (L.stack[ra].value + step) | 0; + let limit = L.stack[ra + 1].value; + + if (0 < step ? idx <= limit : limit <= idx) { + ci.l_savedpc += i.sBx; + L.stack[ra].chgivalue(idx); /* update internal index... */ + L.stack[ra + 3].setivalue(idx); } - break; - } - case OP_FORPREP: { - let init = L.stack[ra]; - let plimit = L.stack[ra + 1]; - let pstep = L.stack[ra + 2]; - let forlim; - - if (init.ttisinteger() && pstep.ttisinteger() && (forlim = forlimit(plimit, pstep.value))) { - /* all values are integer */ - let initv = forlim.stopnow ? 0 : init.value; - plimit.value = forlim.ilimit; - init.value = (initv - pstep.value) | 0; - } else { /* try making all values floats */ - let nlimit, nstep, ninit; - if ((nlimit = tonumber(plimit)) === false) - ldebug.luaG_runerror(L, to_luastring('\'for\' limit must be a number', true)); - L.stack[ra + 1].setfltvalue(nlimit); - if ((nstep = tonumber(pstep)) === false) - ldebug.luaG_runerror(L, to_luastring('\'for\' step must be a number', true)); - L.stack[ra + 2].setfltvalue(nstep); - if ((ninit = tonumber(init)) === false) - ldebug.luaG_runerror(L, to_luastring('\'for\' initial value must be a number', true)); - L.stack[ra].setfltvalue(ninit - nstep); + } else { /* floating loop */ + let step = L.stack[ra + 2].value; + let idx = L.stack[ra].value + step; + let limit = L.stack[ra + 1].value; + + if (0 < step ? idx <= limit : limit <= idx) { + ci.l_savedpc += i.sBx; + L.stack[ra].chgfltvalue(idx); /* update internal index... */ + L.stack[ra + 3].setfltvalue(idx); } - - ci.l_savedpc += i.sBx; - break; } - case OP_TFORCALL: { - let cb = ra + 3; /* call base */ - lobject.setobjs2s(L, cb + 2, ra + 2); - lobject.setobjs2s(L, cb + 1, ra + 1); - lobject.setobjs2s(L, cb, ra); - ldo.adjust_top(L, cb + 3); /* func. + 2 args (state and index) */ - ldo.luaD_call(L, cb, i.C); - ldo.adjust_top(L, ci.top); - /* go straight to OP_TFORLOOP */ - i = ci.l_code[ci.l_savedpc++]; - ra = RA(L, base, i); - lua_assert(i.opcode === OP_TFORLOOP); + break; + } + case OP_FORPREP: { + let init = L.stack[ra]; + let plimit = L.stack[ra + 1]; + let pstep = L.stack[ra + 2]; + let forlim; + + if (init.ttisinteger() && pstep.ttisinteger() && (forlim = forlimit(plimit, pstep.value))) { + /* all values are integer */ + let initv = forlim.stopnow ? 0 : init.value; + plimit.value = forlim.ilimit; + init.value = (initv - pstep.value) | 0; + } else { /* try making all values floats */ + let nlimit, nstep, ninit; + if ((nlimit = tonumber(plimit)) === false) + luaG_runerror(L, to_luastring("'for' limit must be a number", true)); + L.stack[ra + 1].setfltvalue(nlimit); + if ((nstep = tonumber(pstep)) === false) + luaG_runerror(L, to_luastring("'for' step must be a number", true)); + L.stack[ra + 2].setfltvalue(nstep); + if ((ninit = tonumber(init)) === false) + luaG_runerror(L, to_luastring("'for' initial value must be a number", true)); + L.stack[ra].setfltvalue(ninit - nstep); } - /* fall through */ - case OP_TFORLOOP: { - if (!L.stack[ra + 1].ttisnil()) { /* continue loop? */ - lobject.setobjs2s(L, ra, ra + 1); /* save control variable */ - ci.l_savedpc += i.sBx; /* jump back */ - } - break; + + ci.l_savedpc += i.sBx; + break; + } + case OP_TFORCALL: { + let cb = ra + 3; /* call base */ + setobjs2s(L, cb + 2, ra + 2); + setobjs2s(L, cb + 1, ra + 1); + setobjs2s(L, cb, ra); + adjust_top(L, cb + 3); /* func. + 2 args (state and index) */ + luaD_call(L, cb, i.C); + adjust_top(L, ci.top); + /* go straight to OP_TFORLOOP */ + i = ci.l_code[ci.l_savedpc++]; + ra = RA(L, base, i); + lua_assert(i.opcode === OP_TFORLOOP); + } + /* fall through */ + case OP_TFORLOOP: { + if (!L.stack[ra + 1].ttisnil()) { /* continue loop? */ + setobjs2s(L, ra, ra + 1); /* save control variable */ + ci.l_savedpc += i.sBx; /* jump back */ } - case OP_SETLIST: { - let n = i.B; - let c = i.C; + break; + } + case OP_SETLIST: { + let n = i.B; + let c = i.C; - if (n === 0) n = L.top - ra - 1; + if (n === 0) n = L.top - ra - 1; - if (c === 0) { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); - c = ci.l_code[ci.l_savedpc++].Ax; - } + if (c === 0) { + lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); + c = ci.l_code[ci.l_savedpc++].Ax; + } - let h = L.stack[ra].value; - let last = ((c - 1) * LFIELDS_PER_FLUSH) + n; + let h = L.stack[ra].value; + let last = ((c - 1) * LFIELDS_PER_FLUSH) + n; - for (; n > 0; n--) { - ltable.luaH_setint(h, last--, L.stack[ra + n]); - } - ldo.adjust_top(L, ci.top); /* correct top (in case of previous open call) */ - break; + for (; n > 0; n--) { + luaH_setint(h, last--, L.stack[ra + n]); } - case OP_CLOSURE: { - let p = cl.p.p[i.Bx]; - let ncl = getcached(p, cl.upvals, L.stack, base); /* cached closure */ - if (ncl === null) /* no match? */ - pushclosure(L, p, cl.upvals, base, ra); /* create a new one */ - else - L.stack[ra].setclLvalue(ncl); - break; + adjust_top(L, ci.top); /* correct top (in case of previous open call) */ + break; + } + case OP_CLOSURE: { + let p = cl.p.p[i.Bx]; + let ncl = getcached(p, cl.upvals, L.stack, base); /* cached closure */ + if (ncl === null) /* no match? */ + pushclosure(L, p, cl.upvals, base, ra); /* create a new one */ + else + L.stack[ra].setclLvalue(ncl); + break; + } + case OP_VARARG: { + let b = i.B - 1; + let n = base - ci.funcOff - cl.p.numparams - 1; + let j; + + if (n < 0) /* less arguments than parameters? */ + n = 0; /* no vararg arguments */ + + if (b < 0) { + b = n; /* get all var. arguments */ + luaD_checkstack(L, n); + adjust_top(L, ra + n); } - case OP_VARARG: { - let b = i.B - 1; - let n = base - ci.funcOff - cl.p.numparams - 1; - let j; - - if (n < 0) /* less arguments than parameters? */ - n = 0; /* no vararg arguments */ - - if (b < 0) { - b = n; /* get all var. arguments */ - ldo.luaD_checkstack(L, n); - ldo.adjust_top(L, ra + n); - } - for (j = 0; j < b && j < n; j++) - lobject.setobjs2s(L, ra + j, base - n + j); + for (j = 0; j < b && j < n; j++) + setobjs2s(L, ra + j, base - n + j); - for (; j < b; j++) /* complete required results with nil */ - L.stack[ra + j].setnilvalue(); - break; - } - case OP_EXTRAARG: { - throw Error('invalid opcode'); - } + for (; j < b; j++) /* complete required results with nil */ + L.stack[ra + j].setnilvalue(); + break; + } + case OP_EXTRAARG: { + throw Error("invalid opcode"); } } + } }; const dojump = function (L, ci, i, e) { let a = i.A; - if (a !== 0) lfunc.luaF_close(L, ci.l_base + a - 1); + if (a !== 0) luaF_close(L, ci.l_base + a - 1); ci.l_savedpc += i.sBx + e; }; @@ -718,20 +687,20 @@ const donextjump = function (L, ci) { }; -export const luaV_lessthan = function (L, l, r) { +const luaV_lessthan = function (L, l, r) { if (l.ttisnumber() && r.ttisnumber()) return LTnum(l, r) ? 1 : 0; else if (l.ttisstring() && r.ttisstring()) return l_strcmp(l.tsvalue(), r.tsvalue()) < 0 ? 1 : 0; else { - let res = ltm.luaT_callorderTM(L, l, r, ltm.TMS.TM_LT); + let res = luaT_callorderTM(L, l, r, TMS.TM_LT); if (res === null) - ldebug.luaG_ordererror(L, l, r); + luaG_ordererror(L, l, r); return res ? 1 : 0; } }; -export const luaV_lessequal = function (L, l, r) { +const luaV_lessequal = function (L, l, r) { let res; if (l.ttisnumber() && r.ttisnumber()) @@ -739,20 +708,20 @@ export const luaV_lessequal = function (L, l, r) { else if (l.ttisstring() && r.ttisstring()) return l_strcmp(l.tsvalue(), r.tsvalue()) <= 0 ? 1 : 0; else { - res = ltm.luaT_callorderTM(L, l, r, ltm.TMS.TM_LE); + res = luaT_callorderTM(L, l, r, TMS.TM_LE); if (res !== null) return res ? 1 : 0; } /* try 'lt': */ - L.ci.callstatus |= lstate.CIST_LEQ; /* mark it is doing 'lt' for 'le' */ - res = ltm.luaT_callorderTM(L, r, l, ltm.TMS.TM_LT); - L.ci.callstatus ^= lstate.CIST_LEQ; /* clear mark */ + L.ci.callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ + res = luaT_callorderTM(L, r, l, TMS.TM_LT); + L.ci.callstatus ^= CIST_LEQ; /* clear mark */ if (res === null) - ldebug.luaG_ordererror(L, l, r); + luaG_ordererror(L, l, r); return res ? 0 : 1; /* result is negated */ }; -export const luaV_equalobj = function (L, t1, t2) { +const luaV_equalobj = function (L, t1, t2) { if (t1.ttype() !== t2.ttype()) { /* not the same variant? */ if (t1.ttnov() !== t2.ttnov() || t1.ttnov() !== LUA_TNUMBER) return 0; /* only numbers can be equal with different variants */ @@ -784,9 +753,9 @@ export const luaV_equalobj = function (L, t1, t2) { if (t1.value === t2.value) return 1; else if (L === null) return 0; - tm = ltm.fasttm(L, t1.value.metatable, ltm.TMS.TM_EQ); + tm = fasttm(L, t1.value.metatable, TMS.TM_EQ); if (tm === null) - tm = ltm.fasttm(L, t2.value.metatable, ltm.TMS.TM_EQ); + tm = fasttm(L, t2.value.metatable, TMS.TM_EQ); break; default: return t1.value === t2.value ? 1 : 0; @@ -795,8 +764,8 @@ export const luaV_equalobj = function (L, t1, t2) { if (tm === null) /* no TM? */ return 0; - let tv = new lobject.TValue(); /* doesn't use the stack */ - ltm.luaT_callTM(L, tm, t1, t2, tv, 1); + let tv = new TValue(); /* doesn't use the stack */ + luaT_callTM(L, tm, t1, t2, tv, 1); return tv.l_isfalse() ? 0 : 1; }; @@ -849,25 +818,25 @@ const luaV_tointeger = function (obj, mode) { } else if (obj.ttisinteger()) { return obj.value; } else if (cvt2num(obj)) { - let v = new lobject.TValue(); - if (lobject.luaO_str2num(obj.svalue(), v) === (obj.vslen() + 1)) + let v = new TValue(); + if (luaO_str2num(obj.svalue(), v) === (obj.vslen() + 1)) return luaV_tointeger(v, mode); } return false; }; -export const tointeger = function (o) { +const tointeger = function (o) { return o.ttisinteger() ? o.value : luaV_tointeger(o, 0); }; -export const tonumber = function (o) { +const tonumber = function (o) { if (o.ttnov() === LUA_TNUMBER) return o.value; if (cvt2num(o)) { /* string convertible to number? */ - let v = new lobject.TValue(); - if (lobject.luaO_str2num(o.svalue(), v) === (o.vslen() + 1)) + let v = new TValue(); + if (luaO_str2num(o.svalue(), v) === (o.vslen() + 1)) return v.value; } @@ -909,14 +878,14 @@ const l_strcmp = function (ls, rs) { /* ** Main operation 'ra' = #rb'. */ -export const luaV_objlen = function (L, ra, rb) { +const luaV_objlen = function (L, ra, rb) { let tm; switch (rb.ttype()) { case LUA_TTABLE: { let h = rb.value; - tm = ltm.fasttm(L, h.metatable, ltm.TMS.TM_LEN); + tm = fasttm(L, h.metatable, TMS.TM_LEN); if (tm !== null) break; /* metamethod? break switch to call it */ - ra.setivalue(ltable.luaH_getn(h)); /* else primitive len */ + ra.setivalue(luaH_getn(h)); /* else primitive len */ return; } case LUA_TSHRSTR: @@ -924,14 +893,14 @@ export const luaV_objlen = function (L, ra, rb) { ra.setivalue(rb.vslen()); return; default: { - tm = ltm.luaT_gettmbyobj(L, rb, ltm.TMS.TM_LEN); + tm = luaT_gettmbyobj(L, rb, TMS.TM_LEN); if (tm.ttisnil()) - ldebug.luaG_typeerror(L, rb, to_luastring('get length of', true)); + luaG_typeerror(L, rb, to_luastring("get length of", true)); break; } } - ltm.luaT_callTM(L, tm, rb, rb, ra, 1); + luaT_callTM(L, tm, rb, rb, ra, 1); }; /* Shim taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul */ @@ -949,14 +918,14 @@ const luaV_imul = Math.imul || function (a, b) { const luaV_div = function (L, m, n) { if (n === 0) - ldebug.luaG_runerror(L, to_luastring('attempt to divide by zero')); + luaG_runerror(L, to_luastring("attempt to divide by zero")); return Math.floor(m / n) | 0; }; // % semantic on negative numbers is different in js const luaV_mod = function (L, m, n) { if (n === 0) - ldebug.luaG_runerror(L, to_luastring('attempt to perform \'n%%0\'')); + luaG_runerror(L, to_luastring("attempt to perform 'n%%0'")); return (m - Math.floor(m / n) * n) | 0; }; @@ -966,7 +935,8 @@ const luaV_shiftl = function (x, y) { if (y < 0) { /* shift right? */ if (y <= -NBITS) return 0; else return x >>> -y; - } else { /* shift left */ + } + else { /* shift left */ if (y >= NBITS) return 0; else return x << y; } @@ -998,19 +968,19 @@ const getcached = function (p, encup, stack, base) { const pushclosure = function (L, p, encup, base, ra) { let nup = p.upvalues.length; let uv = p.upvalues; - let ncl = new lobject.LClosure(L, nup); + let ncl = new LClosure(L, nup); ncl.p = p; L.stack[ra].setclLvalue(ncl); for (let i = 0; i < nup; i++) { if (uv[i].instack) - ncl.upvals[i] = lfunc.luaF_findupval(L, base + uv[i].idx); + ncl.upvals[i] = luaF_findupval(L, base + uv[i].idx); else ncl.upvals[i] = encup[uv[i].idx]; } p.cache = ncl; /* save it on cache for reuse */ }; -export const cvt2str = function (o) { +const cvt2str = function (o) { return o.ttisnumber(); }; @@ -1024,7 +994,7 @@ const tostring = function (L, i) { if (o.ttisstring()) return true; if (cvt2str(o)) { - lobject.luaO_tostring(L, o); + luaO_tostring(L, o); return true; } @@ -1051,18 +1021,18 @@ const copy2buff = function (L, top, n, buff) { ** Main operation for concatenation: concat 'total' values in the stack, ** from 'L->top - total' up to 'L->top - 1'. */ -export const luaV_concat = function (L, total) { +const luaV_concat = function (L, total) { lua_assert(total >= 2); do { let top = L.top; let n = 2; /* number of elements handled in this pass (at least 2) */ if (!(L.stack[top - 2].ttisstring() || cvt2str(L.stack[top - 2])) || !tostring(L, top - 1)) { - ltm.luaT_trybinTM(L, L.stack[top - 2], L.stack[top - 1], L.stack[top - 2], ltm.TMS.TM_CONCAT); + luaT_trybinTM(L, L.stack[top - 2], L.stack[top - 1], L.stack[top - 2], TMS.TM_CONCAT); } else if (isemptystr(L.stack[top - 1])) { tostring(L, top - 2); } else if (isemptystr(L.stack[top - 2])) { - lobject.setobjs2s(L, top - 2, top - 1); + setobjs2s(L, top - 2, top - 1); } else { /* at least two non-empty string values; get as many as possible */ let tl = L.stack[top - 1].vslen(); @@ -1074,7 +1044,7 @@ export const luaV_concat = function (L, total) { let buff = new Uint8Array(tl); copy2buff(L, top, n, buff); let ts = luaS_bless(L, buff); - lobject.setsvalue2s(L, top - n, ts); + setsvalue2s(L, top - n, ts); } total -= n - 1; /* got 'n' strings to create 1 new */ /* popped 'n' strings and pushed one */ @@ -1085,22 +1055,22 @@ export const luaV_concat = function (L, total) { const MAXTAGLOOP = 2000; -export const luaV_gettable = function (L, t, key, ra) { +const luaV_gettable = function (L, t, key, ra) { for (let loop = 0; loop < MAXTAGLOOP; loop++) { let tm; if (!t.ttistable()) { - tm = ltm.luaT_gettmbyobj(L, t, ltm.TMS.TM_INDEX); + tm = luaT_gettmbyobj(L, t, TMS.TM_INDEX); if (tm.ttisnil()) - ldebug.luaG_typeerror(L, t, to_luastring('index', true)); /* no metamethod */ + luaG_typeerror(L, t, to_luastring('index', true)); /* no metamethod */ /* else will try the metamethod */ } else { - let slot = ltable.luaH_get(L, t.value, key); + let slot = luaH_get(L, t.value, key); if (!slot.ttisnil()) { - lobject.setobj2s(L, ra, slot); + setobj2s(L, ra, slot); return; } else { /* 't' is a table */ - tm = ltm.fasttm(L, t.value.metatable, ltm.TMS.TM_INDEX); /* table's metamethod */ + tm = fasttm(L, t.value.metatable, TMS.TM_INDEX); /* table's metamethod */ if (tm === null) { /* no metamethod? */ L.stack[ra].setnilvalue(); /* result is nil */ return; @@ -1109,38 +1079,78 @@ export const luaV_gettable = function (L, t, key, ra) { /* else will try the metamethod */ } if (tm.ttisfunction()) { /* is metamethod a function? */ - ltm.luaT_callTM(L, tm, t, key, L.stack[ra], 1); /* call it */ + luaT_callTM(L, tm, t, key, L.stack[ra], 1); /* call it */ return; } t = tm; /* else try to access 'tm[key]' */ } - ldebug.luaG_runerror(L, to_luastring('\'__index\' chain too long; possible loop', true)); + luaG_runerror(L, to_luastring("'__index' chain too long; possible loop", true)); }; -export const settable = function (L, t, key, val) { +const settable = function (L, t, key, val) { for (let loop = 0; loop < MAXTAGLOOP; loop++) { let tm; if (t.ttistable()) { let h = t.value; /* save 't' table */ - let slot = ltable.luaH_get(L, h, key); - if (!slot.ttisnil() || (tm = ltm.fasttm(L, h.metatable, ltm.TMS.TM_NEWINDEX)) === null) { - ltable.luaH_setfrom(L, h, key, val); - ltable.invalidateTMcache(h); + let slot = luaH_get(L, h, key); + if (!slot.ttisnil() || (tm = fasttm(L, h.metatable, TMS.TM_NEWINDEX)) === null) { + luaH_setfrom(L, h, key, val); + invalidateTMcache(h); return; } /* else will try the metamethod */ } else { /* not a table; check metamethod */ - if ((tm = ltm.luaT_gettmbyobj(L, t, ltm.TMS.TM_NEWINDEX)).ttisnil()) - ldebug.luaG_typeerror(L, t, to_luastring('index', true)); + if ((tm = luaT_gettmbyobj(L, t, TMS.TM_NEWINDEX)).ttisnil()) + luaG_typeerror(L, t, to_luastring('index', true)); } /* try the metamethod */ if (tm.ttisfunction()) { - ltm.luaT_callTM(L, tm, t, key, val, 0); + luaT_callTM(L, tm, t, key, val, 0); return; } t = tm; /* else repeat assignment over 'tm' */ } - ldebug.luaG_runerror(L, to_luastring('\'__newindex\' chain too long; possible loop', true)); + luaG_runerror(L, to_luastring("'__newindex' chain too long; possible loop", true)); }; + + +const _cvt2str = cvt2str; +export { _cvt2str as cvt2str }; +const _cvt2num = cvt2num; +export { _cvt2num as cvt2num }; +const _luaV_gettable = luaV_gettable; +export { _luaV_gettable as luaV_gettable }; +const _luaV_concat = luaV_concat; +export { _luaV_concat as luaV_concat }; +const _luaV_div = luaV_div; +export { _luaV_div as luaV_div }; +const _luaV_equalobj = luaV_equalobj; +export { _luaV_equalobj as luaV_equalobj }; +const _luaV_execute = luaV_execute; +export { _luaV_execute as luaV_execute }; +const _luaV_finishOp = luaV_finishOp; +export { _luaV_finishOp as luaV_finishOp }; +const _luaV_imul = luaV_imul; +export { _luaV_imul as luaV_imul }; +const _luaV_lessequal = luaV_lessequal; +export { _luaV_lessequal as luaV_lessequal }; +const _luaV_lessthan = luaV_lessthan; +export { _luaV_lessthan as luaV_lessthan }; +const _luaV_mod = luaV_mod; +export { _luaV_mod as luaV_mod }; +const _luaV_objlen = luaV_objlen; +export { _luaV_objlen as luaV_objlen }; +const _luaV_rawequalobj = luaV_rawequalobj; +export { _luaV_rawequalobj as luaV_rawequalobj }; +const _luaV_shiftl = luaV_shiftl; +export { _luaV_shiftl as luaV_shiftl }; +const _luaV_tointeger = luaV_tointeger; +export { _luaV_tointeger as luaV_tointeger }; +const _settable = settable; +export { _settable as settable }; +const _tointeger = tointeger; +export { _tointeger as tointeger }; +const _tonumber = tonumber; +export { _tonumber as tonumber }; diff --git a/src/lzio.js b/src/lzio.js index 306a8475..8a0c318b 100644 --- a/src/lzio.js +++ b/src/lzio.js @@ -1,4 +1,4 @@ -import {lua_assert} from "./llimits.js"; +import { lua_assert } from "./llimits.js"; class MBuffer { constructor() { @@ -26,10 +26,10 @@ const luaZ_resizebuffer = function(L, buff, size) { buff.buffer = newbuff; }; -export class ZIO { +class ZIO { constructor(L, reader, data) { this.L = L; /* Lua state (for reader) */ - lua_assert(typeof reader == 'function', 'ZIO requires a reader'); + lua_assert(typeof reader == "function", "ZIO requires a reader"); this.reader = reader; /* reader function */ this.data = data; /* additional data */ this.n = 0; /* bytes still unread */ @@ -48,7 +48,7 @@ const luaZ_fill = function(z) { let buff = z.reader(z.L, z.data); if (buff === null) return EOZ; - lua_assert(buff instanceof Uint8Array, 'Should only load binary of array of bytes'); + lua_assert(buff instanceof Uint8Array, "Should only load binary of array of bytes"); let size = buff.length; if (size === 0) return EOZ; @@ -82,3 +82,22 @@ const luaZ_read = function(z, b, b_offset, n) { return 0; }; + +const _EOZ = EOZ; +export { _EOZ as EOZ }; +const _luaZ_buffer = luaZ_buffer; +export { _luaZ_buffer as luaZ_buffer }; +const _luaZ_buffremove = luaZ_buffremove; +export { _luaZ_buffremove as luaZ_buffremove }; +const _luaZ_fill = luaZ_fill; +export { _luaZ_fill as luaZ_fill }; +const _luaZ_read = luaZ_read; +export { _luaZ_read as luaZ_read }; +const _luaZ_resetbuffer = luaZ_resetbuffer; +export { _luaZ_resetbuffer as luaZ_resetbuffer }; +const _luaZ_resizebuffer = luaZ_resizebuffer; +export { _luaZ_resizebuffer as luaZ_resizebuffer }; +const _MBuffer = MBuffer; +export { _MBuffer as MBuffer }; +const _ZIO = ZIO; +export { _ZIO as ZIO }; diff --git a/test/defs.test.js b/test/defs.test.js index 5ed17f5f..ead9a7b4 100644 --- a/test/defs.test.js +++ b/test/defs.test.js @@ -1,47 +1,48 @@ -import { luastring_of, to_luastring, to_jsstring } from '../src/defs.js'; +const defs = require('../src/defs.js'); + const unicode_tests = [ { - description: 'Convert normal ascii string', - literal: 'foo', - byte_array: luastring_of('f'.charCodeAt(0), 'o'.charCodeAt(0), 'o'.charCodeAt(0)) + description: "Convert normal ascii string", + literal: "foo", + byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)) }, { - description: 'Convert ascii string containing null byte', - literal: 'fo\0o', - byte_array: luastring_of('f'.charCodeAt(0), 'o'.charCodeAt(0), 0, 'o'.charCodeAt(0)) + description: "Convert ascii string containing null byte", + literal: "fo\0o", + byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)) }, { - description: 'Convert string with BMP unicode chars', - literal: 'Café', - byte_array: luastring_of(67, 97, 102, 195, 169) + description: "Convert string with BMP unicode chars", + literal: "Café", + byte_array: defs.luastring_of(67, 97, 102, 195, 169) }, { - description: 'Convert string with codepoint in PUA (U+E000 to U+F8FF)', - literal: '', - byte_array: luastring_of(239, 163, 191) + description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)", + literal: "", + byte_array: defs.luastring_of(239, 163, 191) }, { - description: 'Convert string with surrogate pair', - literal: '❤️🍾', - byte_array: luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) + description: "Convert string with surrogate pair", + literal: "❤️🍾", + byte_array: defs.luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) }, { - description: 'Convert string with broken surrogate pair', - literal: '\uD800a', - byte_array: luastring_of(237, 160, 128, 97) + description: "Convert string with broken surrogate pair", + literal: "\uD800a", + byte_array: defs.luastring_of(237, 160, 128, 97) }, { - description: 'Convert string with broken surrogate pair at end of string', - literal: '\uD823', - byte_array: luastring_of(237, 160, 163) + description: "Convert string with broken surrogate pair at end of string", + literal: "\uD823", + byte_array: defs.luastring_of(237, 160, 163) } ]; describe('to_luastring', () => { unicode_tests.forEach((v) => { test(v.description, () => { - expect(to_luastring(v.literal)).toEqual(v.byte_array); + expect(defs.to_luastring(v.literal)).toEqual(v.byte_array); }); }); }); @@ -49,45 +50,45 @@ describe('to_luastring', () => { describe('to_jsstring', () => { unicode_tests.forEach((v) => { test(v.description, () => { - expect(to_jsstring(v.byte_array)).toEqual(v.literal); + expect(defs.to_jsstring(v.byte_array)).toEqual(v.literal); }); }); }); describe('to_jsstring fails on invalid unicode', () => { - test('non-utf8 char', () => { - expect(() => to_jsstring(luastring_of(165))) - .toThrowError(RangeError); + test("non-utf8 char", () => { + expect(() => defs.to_jsstring(defs.luastring_of(165))) + .toThrow(RangeError); }); - test('invalid continuation byte', () => { - expect(() => to_jsstring(luastring_of(208, 60))) - .toThrowError(RangeError); + test("invalid continuation byte", () => { + expect(() => defs.to_jsstring(defs.luastring_of(208, 60))) + .toThrow(RangeError); }); - test('invalid continuation byte', () => { - expect(() => to_jsstring(luastring_of(225, 60, 145))) - .toThrowError(RangeError); + test("invalid continuation byte", () => { + expect(() => defs.to_jsstring(defs.luastring_of(225, 60, 145))) + .toThrow(RangeError); }); - test('invalid continuation byte', () => { - expect(() => to_jsstring(luastring_of(225, 145, 60))) - .toThrowError(RangeError); + test("invalid continuation byte", () => { + expect(() => defs.to_jsstring(defs.luastring_of(225, 145, 60))) + .toThrow(RangeError); }); - test('invalid continuation byte', () => { - expect(() => to_jsstring(luastring_of(242, 60, 145, 145))) - .toThrowError(RangeError); + test("invalid continuation byte", () => { + expect(() => defs.to_jsstring(defs.luastring_of(242, 60, 145, 145))) + .toThrow(RangeError); }); - test('invalid continuation byte', () => { - expect(() => to_jsstring(luastring_of(242, 145, 60, 145))) - .toThrowError(RangeError); + test("invalid continuation byte", () => { + expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 60, 145))) + .toThrow(RangeError); }); - test('invalid continuation byte', () => { - expect(() => to_jsstring(luastring_of(242, 145, 145, 60))) - .toThrowError(RangeError); + test("invalid continuation byte", () => { + expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 145, 60))) + .toThrow(RangeError); }); }); diff --git a/test/lapi.test.js b/test/lapi.test.js index 209623d0..399155a8 100644 --- a/test/lapi.test.js +++ b/test/lapi.test.js @@ -1,35 +1,35 @@ -'use strict'; +"use strict"; -const {toByteCode} = require('./tests.js'); +const {toByteCode} = require("./tests.js"); const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const lauxlib = require("../src/lauxlib.js"); +const {to_luastring} = require("../src/fengaricore.js"); test('luaL_newstate, lua_pushnil, luaL_typename', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_pushnil(L); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('nil')); + .toEqual(to_luastring("nil")); }); test('lua_pushnumber', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_pushnumber(L, 10.5); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('number')); + .toEqual(to_luastring("number")); expect(lua.lua_tonumber(L, -1)) .toBe(10.5); @@ -38,14 +38,14 @@ test('lua_pushnumber', () => { test('lua_pushinteger', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_pushinteger(L, 10); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('number')); + .toEqual(to_luastring("number")); expect(lua.lua_tointeger(L, -1)) .toBe(10); @@ -54,30 +54,30 @@ test('lua_pushinteger', () => { test('lua_pushliteral', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { - lua.lua_pushliteral(L, 'hello'); + lua.lua_pushliteral(L, "hello"); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('string')); + .toEqual(to_luastring("string")); expect(lua.lua_tojsstring(L, -1)) - .toBe('hello'); + .toBe("hello"); }); test('lua_pushboolean', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_pushboolean(L, true); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('boolean')); + .toEqual(to_luastring("boolean")); expect(lua.lua_toboolean(L, -1)) .toBe(true); @@ -86,47 +86,47 @@ test('lua_pushboolean', () => { test('lua_pushvalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { - lua.lua_pushliteral(L, 'hello'); + lua.lua_pushliteral(L, "hello"); lua.lua_pushvalue(L, -1); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('string')); + .toEqual(to_luastring("string")); expect(lauxlib.luaL_typename(L, -2)) - .toEqual(to_luastring('string')); + .toEqual(to_luastring("string")); expect(lua.lua_tojsstring(L, -1)) - .toBe('hello'); + .toBe("hello"); expect(lua.lua_tojsstring(L, -2)) - .toBe('hello'); + .toBe("hello"); }); test('lua_pushjsclosure', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let fn = function(L) { return 0; }; - lua.lua_pushliteral(L, 'a value associated to the C closure'); + lua.lua_pushliteral(L, "a value associated to the C closure"); lua.lua_pushjsclosure(L, fn, 1); } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('function')); + .toEqual(to_luastring("function")); }); test('lua_pushjsfunction', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let fn = function(L) { @@ -136,17 +136,17 @@ test('lua_pushjsfunction', () => { } expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring('function')); + .toEqual(to_luastring("function")); }); test('lua_call (calling a light JS function)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let fn = function(L) { - lua.lua_pushliteral(L, 'hello'); + lua.lua_pushliteral(L, "hello"); return 1; }; lua.lua_pushjsfunction(L, fn); @@ -154,36 +154,36 @@ test('lua_call (calling a light JS function)', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello'); + .toBe("hello"); }); test('lua_call (calling a JS closure)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let fn = function(L) { lua.lua_pushstring(L, lua.lua_tostring(L, lua.lua_upvalueindex(1))); return 1; }; - lua.lua_pushliteral(L, 'upvalue hello!'); + lua.lua_pushliteral(L, "upvalue hello!"); lua.lua_pushjsclosure(L, fn, 1); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('upvalue hello!'); + .toBe("upvalue hello!"); }); test('lua_pcall (calling a light JS function)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let fn = function(L) { - lua.lua_pushliteral(L, 'hello'); + lua.lua_pushliteral(L, "hello"); return 1; }; lua.lua_pushjsfunction(L, fn); @@ -191,17 +191,17 @@ test('lua_pcall (calling a light JS function)', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello'); + .toBe("hello"); }); test('lua_pcall that breaks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let fn = function(L) { - return 'undefined_value'; + return "undefined_value"; }; lua.lua_pushjsfunction(L, fn); expect(lua.lua_pcall(L, 0, 1, 0)).not.toBe(lua.LUA_OK); @@ -211,22 +211,22 @@ test('lua_pcall that breaks', () => { test('lua_pop', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { - lua.lua_pushliteral(L, 'hello'); - lua.lua_pushliteral(L, 'world'); + lua.lua_pushliteral(L, "hello"); + lua.lua_pushliteral(L, "world"); lua.lua_pop(L, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello'); + .toBe("hello"); }); test('lua_load with no chunkname', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_load(L, function(L, s) { @@ -234,18 +234,18 @@ test('lua_load with no chunkname', () => { s.code = null; return r; }, { - code: to_luastring('return \'hello\'') + code: to_luastring("return 'hello'") }, null, null); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello'); + .toBe("hello"); }); test('lua_load and lua_call it', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let luaCode = ` @@ -257,37 +257,37 @@ test('lua_load and lua_call it', () => { let r = s.bc; s.bc = null; return r; - }, {bc: bc}, to_luastring('test-lua_load'), to_luastring('binary')); + }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary")); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('JS > Lua > JS \\o/'); + .toBe("JS > Lua > JS \\o/"); }); test('lua script reads js upvalues', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { let luaCode = ` return js .. " world" `; expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pushliteral(L, 'hello'); - lua.lua_setglobal(L, to_luastring('js')); + lua.lua_pushliteral(L, "hello"); + lua.lua_setglobal(L, to_luastring("js")); lua.lua_call(L, 0, 1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello world'); + .toBe("hello world"); }); test('lua_createtable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_createtable(L, 3, 3); @@ -299,7 +299,7 @@ test('lua_createtable', () => { test('lua_newtable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_newtable(L); @@ -311,28 +311,28 @@ test('lua_newtable', () => { test('lua_settable, lua_gettable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_newtable(L); - lua.lua_pushliteral(L, 'key'); - lua.lua_pushliteral(L, 'value'); + lua.lua_pushliteral(L, "key"); + lua.lua_pushliteral(L, "value"); lua.lua_settable(L, -3); - lua.lua_pushliteral(L, 'key'); + lua.lua_pushliteral(L, "key"); lua.lua_gettable(L, -2); } expect(lua.lua_tojsstring(L, -1)) - .toBe('value'); + .toBe("value"); }); describe('lua_atnativeerror', () => { test('no native error handler', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let errob = {}; @@ -345,39 +345,39 @@ describe('lua_atnativeerror', () => { test('native error handler returns string', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let errob = {}; lua.lua_atnativeerror(L, function(L) { let e = lua.lua_touserdata(L, 1); expect(e).toBe(errob); - lua.lua_pushstring(L, to_luastring('runtime error!')); + lua.lua_pushstring(L, to_luastring("runtime error!")); return 1; }); lua.lua_pushcfunction(L, function(L) { throw errob; }); expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN); - expect(lua.lua_tojsstring(L, -1)).toBe('runtime error!'); + expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!"); }); test('native error handler rethrows lua error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let errob = {}; lua.lua_atnativeerror(L, function(L) { let e = lua.lua_touserdata(L, 1); expect(e).toBe(errob); - lauxlib.luaL_error(L, to_luastring('runtime error!')); + lauxlib.luaL_error(L, to_luastring("runtime error!")); }); lua.lua_pushcfunction(L, function(L) { throw errob; }); expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN); - expect(lua.lua_tojsstring(L, -1)).toBe('runtime error!'); + expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!"); }); }); @@ -385,7 +385,7 @@ describe('lua_atnativeerror', () => { describe('lua_len', () => { test('table with two potential boundaries', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_createtable(L); @@ -403,7 +403,7 @@ describe('lua_len', () => { test('pathological case', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { lua.lua_createtable(L); diff --git a/test/lauxlib.test.js b/test/lauxlib.test.js index dbf8c9ca..62198ac4 100644 --- a/test/lauxlib.test.js +++ b/test/lauxlib.test.js @@ -1,16 +1,16 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const lauxlib = require("../src/lauxlib.js"); +const {to_luastring} = require("../src/fengaricore.js"); test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); { - lua.lua_pushstring(L, to_luastring('hello references!')); + lua.lua_pushstring(L, to_luastring("hello references!")); let r = lauxlib.luaL_ref(L, lua.LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, r); // pushes a value associated with the reference @@ -18,5 +18,5 @@ test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello references!'); + .toBe("hello references!"); }); diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js index 43ab869a..dc30a984 100644 --- a/test/lbaselib.test.js +++ b/test/lbaselib.test.js @@ -1,14 +1,14 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('print', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` print("hello", "world", 123) @@ -23,7 +23,7 @@ test('print', () => { test('setmetatable, getmetatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -45,7 +45,7 @@ test('setmetatable, getmetatable', () => { } expect(lua.lua_tojsstring(L, -2)) - .toBe('hello'); + .toBe("hello"); expect(lua.lua_istable(L, -1)).toBe(true); }); @@ -53,7 +53,7 @@ test('setmetatable, getmetatable', () => { test('rawequal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -83,7 +83,7 @@ test('rawequal', () => { test('rawset, rawget', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -108,22 +108,22 @@ test('rawset, rawget', () => { } expect(lua.lua_tojsstring(L, -4)) - .toBe('hello'); + .toBe("hello"); expect(lua.lua_tojsstring(L, -3)) - .toBe('hello'); + .toBe("hello"); expect(lua.lua_tojsstring(L, -2)) - .toBe('bye'); + .toBe("bye"); expect(lua.lua_tojsstring(L, -1)) - .toBe('bye'); + .toBe("bye"); }); test('type', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return type(1), type(true), type("hello"), type({}), type(nil) @@ -135,25 +135,25 @@ test('type', () => { } expect(lua.lua_tojsstring(L, -5)) - .toBe('number'); + .toBe("number"); expect(lua.lua_tojsstring(L, -4)) - .toBe('boolean'); + .toBe("boolean"); expect(lua.lua_tojsstring(L, -3)) - .toBe('string'); + .toBe("string"); expect(lua.lua_tojsstring(L, -2)) - .toBe('table'); + .toBe("table"); expect(lua.lua_tojsstring(L, -1)) - .toBe('nil'); + .toBe("nil"); }); test('error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` error("you fucked up") @@ -170,7 +170,7 @@ test('error', () => { test('error, protected', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` error("you fucked up") @@ -187,7 +187,7 @@ test('error, protected', () => { test('pcall', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local willFail = function () @@ -208,7 +208,7 @@ test('pcall', () => { test('xpcall', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local willFail = function () @@ -233,7 +233,7 @@ test('xpcall', () => { test('ipairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 2, 3, 4, 5, ['yo'] = 'lo'} @@ -257,7 +257,7 @@ test('ipairs', () => { test('select', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return {select('#', 1, 2, 3)}, {select(2, 1, 2, 3)}, {select(-2, 1, 2, 3)} @@ -281,7 +281,7 @@ test('select', () => { test('tonumber', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return tonumber('foo'), @@ -306,7 +306,7 @@ test('tonumber', () => { test('assert', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(1 < 0, "this doesn't makes sense") @@ -323,7 +323,7 @@ test('assert', () => { test('rawlen', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return rawlen({1, 2, 3}), rawlen('hello') @@ -341,7 +341,7 @@ test('rawlen', () => { test('next', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 @@ -370,7 +370,7 @@ test('next', () => { test('pairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 @@ -399,7 +399,7 @@ test('pairs', () => { test('pairs with __pairs', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 diff --git a/test/lcorolib.test.js b/test/lcorolib.test.js index 15a36ada..e9ad8ed4 100644 --- a/test/lcorolib.test.js +++ b/test/lcorolib.test.js @@ -1,14 +1,14 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); const lstate = require('../src/lstate.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('coroutine.create, coroutine.yield, coroutine.resume', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local co = coroutine.create(function (start) @@ -34,7 +34,7 @@ test('coroutine.create, coroutine.yield, coroutine.resume', () => { test('coroutine.status', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local co = coroutine.create(function (start) @@ -60,16 +60,16 @@ test('coroutine.status', () => { } expect(lua.lua_tojsstring(L, -2)) - .toBe('suspended'); + .toBe("suspended"); expect(lua.lua_tojsstring(L, -1)) - .toBe('dead'); + .toBe("dead"); }); test('coroutine.isyieldable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local co = coroutine.create(function () @@ -93,7 +93,7 @@ test('coroutine.isyieldable', () => { test('coroutine.running', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local running, ismain @@ -119,7 +119,7 @@ test('coroutine.running', () => { test('coroutine.wrap', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local co = coroutine.wrap(function (start) diff --git a/test/ldblib.test.js b/test/ldblib.test.js index 82158143..ba68853a 100644 --- a/test/ldblib.test.js +++ b/test/ldblib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('debug.sethook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local result = "" @@ -31,13 +31,13 @@ test('debug.sethook', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe('return count line count line count line call count line return count line count line call count line return count line count line call count line return count line '); + .toBe("return count line count line count line call count line return count line count line call count line return count line count line call count line return count line "); }); test('debug.gethook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local result = "" @@ -61,15 +61,15 @@ test('debug.gethook', () => { } expect(lua.lua_typename(L, lua.lua_type(L, -3))) - .toEqual(to_luastring('function')); - expect(lua.lua_tojsstring(L, -2)).toBe('crl'); + .toEqual(to_luastring("function")); + expect(lua.lua_tojsstring(L, -2)).toBe("crl"); expect(lua.lua_tointeger(L, -1)).toBe(1); }); test('debug.getlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local alocal = "alocal" @@ -97,12 +97,12 @@ test('debug.getlocal', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe('alocal alocalanother anotherinfunction infunctionanotherin anotherin'); + .toBe("alocal alocalanother anotherinfunction infunctionanotherin anotherin"); }); test('debug.setlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local alocal = "alocal" @@ -138,7 +138,7 @@ test('debug.setlocal', () => { test('debug.upvalueid', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local upvalue = "upvalue" @@ -161,7 +161,7 @@ test('debug.upvalueid', () => { test('debug.upvaluejoin', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local upvalue1 = "upvalue1" @@ -186,13 +186,13 @@ test('debug.upvaluejoin', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe('upvalue2'); + .toBe("upvalue2"); }); test('debug.traceback (with a global)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local trace @@ -213,7 +213,7 @@ test('debug.traceback (with a global)', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('traceback-test')); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test")); lua.lua_call(L, 0, -1); } @@ -236,7 +236,7 @@ test('debug.traceback (with a global)', () => { test('debug.traceback (with a upvalue)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local trace @@ -258,7 +258,7 @@ test('debug.traceback (with a upvalue)', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('traceback-test')); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test")); lua.lua_call(L, 0, -1); } @@ -280,7 +280,7 @@ test('debug.traceback (with a upvalue)', () => { test('debug.getinfo', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local alocal = function(p1, p2) end @@ -295,16 +295,16 @@ test('debug.getinfo', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('getinfo-test')); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("getinfo-test")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -8)).toBe('[string "getinfo-test"]'); + expect(lua.lua_tojsstring(L, -8)).toBe(`[string "getinfo-test"]`); expect(lua.lua_tointeger(L, -7)).toBe(0); - expect(lua.lua_tojsstring(L, -6)).toBe('Lua'); + expect(lua.lua_tojsstring(L, -6)).toBe(`Lua`); expect(lua.lua_tointeger(L, -5)).toBe(2); - expect(lua.lua_tojsstring(L, -4)).toBe('[string "getinfo-test"]'); + expect(lua.lua_tojsstring(L, -4)).toBe(`[string "getinfo-test"]`); expect(lua.lua_tointeger(L, -3)).toBe(1); - expect(lua.lua_tojsstring(L, -2)).toBe('Lua'); + expect(lua.lua_tojsstring(L, -2)).toBe(`Lua`); expect(lua.lua_tointeger(L, -1)).toBe(0); }); diff --git a/test/ldebug.test.js b/test/ldebug.test.js index 57d24d6e..d52cfcba 100644 --- a/test/ldebug.test.js +++ b/test/ldebug.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -20,13 +20,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('attempt to get length of a boolean value (local \'a\')'); + .toMatch("attempt to get length of a boolean value (local 'a')"); }); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -39,13 +39,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('attempt to index a boolean value (local \'a\')'); + .toMatch("attempt to index a boolean value (local 'a')"); }); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -58,13 +58,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('attempt to index a boolean value (local \'a\')'); + .toMatch("attempt to index a boolean value (local 'a')"); }); test('luaG_typeerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -77,13 +77,13 @@ test('luaG_typeerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('attempt to index a boolean value (local \'a\')'); + .toMatch("attempt to index a boolean value (local 'a')"); }); test('luaG_concaterror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return {} .. 'hello' @@ -95,13 +95,13 @@ test('luaG_concaterror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('attempt to concatenate a table value'); + .toMatch("attempt to concatenate a table value"); }); test('luaG_opinterror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return {} + 'hello' @@ -113,13 +113,13 @@ test('luaG_opinterror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('attempt to perform arithmetic on a table value'); + .toMatch("attempt to perform arithmetic on a table value"); }); test('luaG_tointerror', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return 123.5 & 12 @@ -131,5 +131,5 @@ test('luaG_tointerror', () => { } expect(lua.lua_tojsstring(L, -1)) - .toMatch('number has no integer representation'); + .toMatch("number has no integer representation"); }); diff --git a/test/lexparse.test.js b/test/lexparse.test.js index 71176986..a9407ed9 100644 --- a/test/lexparse.test.js +++ b/test/lexparse.test.js @@ -1,15 +1,15 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const lstring = require('../src/lstring.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const lstring = require("../src/lstring.js"); +const {to_luastring} = require("../src/fengaricore.js"); // Roughly the same tests as test/lvm.js to cover all opcodes test('LOADK, RETURN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "hello world" @@ -22,18 +22,18 @@ test('LOADK, RETURN', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); }); test('MOVE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "hello world" @@ -47,18 +47,18 @@ test('MOVE', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); }); test('Binary op', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = 5 @@ -72,7 +72,7 @@ test('Binary op', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -84,7 +84,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = 5 @@ -98,7 +98,7 @@ test('Unary op, LOADBOOL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -110,7 +110,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = {} @@ -123,7 +123,7 @@ test('NEWTABLE', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -134,7 +134,7 @@ test('NEWTABLE', () => { test('CALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (a, b) @@ -152,7 +152,7 @@ test('CALL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -162,7 +162,7 @@ test('CALL', () => { test('Multiple return', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (a, b) @@ -184,7 +184,7 @@ test('Multiple return', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -196,7 +196,7 @@ test('Multiple return', () => { test('TAILCALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (a, b) @@ -212,7 +212,7 @@ test('TAILCALL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -223,7 +223,7 @@ test('TAILCALL', () => { test('VARARG', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (...) @@ -239,7 +239,7 @@ test('VARARG', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -251,7 +251,7 @@ test('VARARG', () => { test('LE, JMP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 1, 1 @@ -265,7 +265,7 @@ test('LE, JMP', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -276,7 +276,7 @@ test('LE, JMP', () => { test('LT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 1, 1 @@ -290,7 +290,7 @@ test('LT', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -301,7 +301,7 @@ test('LT', () => { test('EQ', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 1, 1 @@ -315,7 +315,7 @@ test('EQ', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -326,7 +326,7 @@ test('EQ', () => { test('TESTSET (and)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -341,18 +341,18 @@ test('TESTSET (and)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('TESTSET (or)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = false @@ -367,18 +367,18 @@ test('TESTSET (or)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('TEST (false)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = false @@ -397,18 +397,18 @@ test('TEST (false)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('goodbye'); + expect(lua.lua_tojsstring(L, -1)).toBe("goodbye"); }); test('FORPREP, FORLOOP (int)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 @@ -426,7 +426,7 @@ test('FORPREP, FORLOOP (int)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -437,7 +437,7 @@ test('FORPREP, FORLOOP (int)', () => { test('FORPREP, FORLOOP (float)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 @@ -455,7 +455,7 @@ test('FORPREP, FORLOOP (float)', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -466,7 +466,7 @@ test('FORPREP, FORLOOP (float)', () => { test('SETTABLE, GETTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {} @@ -483,21 +483,21 @@ test('SETTABLE, GETTABLE', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe('hello'); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) - .toBe('world'); + .toBe("hello"); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + .toBe("world"); }); test('SETUPVAL, GETUPVAL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local up = "hello" @@ -517,18 +517,18 @@ test('SETUPVAL, GETUPVAL', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('world'); + expect(lua.lua_tojsstring(L, -1)).toBe("world"); }); test('SETTABUP, GETTABUP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = {} @@ -545,21 +545,21 @@ test('SETTABUP, GETTABUP', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe('hello'); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) - .toBe('world'); + .toBe("hello"); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + .toBe("world"); }); test('SELF', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {} @@ -578,18 +578,18 @@ test('SELF', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -603,7 +603,7 @@ test('SETLIST', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -615,7 +615,7 @@ test('SETLIST', () => { test('Variable SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = function () @@ -633,7 +633,7 @@ test('Variable SETLIST', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -644,7 +644,7 @@ test('Variable SETLIST', () => { test('Long SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} @@ -658,7 +658,7 @@ test('Long SETLIST', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -670,7 +670,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local iterator = function (t, i) @@ -700,7 +700,7 @@ test('TFORCALL, TFORLOOP', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -711,7 +711,7 @@ test('TFORCALL, TFORLOOP', () => { test('LEN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {[10000] = "foo"} @@ -727,7 +727,7 @@ test('LEN', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } @@ -740,7 +740,7 @@ test('LEN', () => { test('CONCAT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return "hello " .. 2 .. " you" @@ -752,10 +752,10 @@ test('CONCAT', () => { luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello 2 you'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you"); }); diff --git a/test/lmathlib.test.js b/test/lmathlib.test.js index 3e616f57..0ee0b1c8 100644 --- a/test/lmathlib.test.js +++ b/test/lmathlib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.abs(-10), math.abs(-10.5), math.cos(10), math.tan(10), @@ -31,7 +31,7 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', test('math.ceil, math.floor', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.ceil(10.5), math.floor(10.5) @@ -49,7 +49,7 @@ test('math.ceil, math.floor', () => { test('math.deg, math.rad', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.deg(10), math.rad(10) @@ -67,7 +67,7 @@ test('math.deg, math.rad', () => { test('math.log', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.log(10), math.log(10, 2), math.log(10, 10) @@ -87,7 +87,7 @@ test('math.log', () => { /* Node.js 6 has incorrect results for Math.exp */ (parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.exp(10) @@ -104,7 +104,7 @@ test('math.log', () => { test('math.min, math.max', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.max(10, 5, 23), math.min(10, 5, 23) @@ -122,7 +122,7 @@ test('math.min, math.max', () => { test('math.random', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.random(), math.random(10, 15) @@ -148,7 +148,7 @@ test('math.random', () => { test('math.sqrt', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.sqrt(10) @@ -165,7 +165,7 @@ test('math.sqrt', () => { test('math.tointeger', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.tointeger('10') @@ -182,7 +182,7 @@ test('math.tointeger', () => { test('math.type', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.type(10), math.type(10.5), math.type('hello') @@ -193,15 +193,15 @@ test('math.type', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -3)).toBe('integer'); - expect(lua.lua_tojsstring(L, -2)).toBe('float'); + expect(lua.lua_tojsstring(L, -3)).toBe("integer"); + expect(lua.lua_tojsstring(L, -2)).toBe("float"); expect(lua.lua_tojsstring(L, -1)).toBe(null); }); test('math.ult', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.ult(5, 200) @@ -218,7 +218,7 @@ test('math.ult', () => { test('math.fmod', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.fmod(2,5) @@ -235,7 +235,7 @@ test('math.fmod', () => { test('math.modf', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.modf(3.4, 0.6) diff --git a/test/load.test.js b/test/load.test.js index af440ec9..e8f39ea4 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -1,15 +1,15 @@ -'use strict'; +"use strict"; -const {toByteCode} = require('./tests.js'); +const {toByteCode} = require("./tests.js"); const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('luaL_loadstring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "hello world" @@ -21,13 +21,13 @@ test('luaL_loadstring', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello world'); + .toBe("hello world"); }); test('load', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = load("return 'js running lua running lua'") @@ -39,13 +39,13 @@ test('load', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('js running lua running lua'); + .toBe("js running lua running lua"); }); test('undump empty string', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(load(string.dump(function() @@ -63,7 +63,7 @@ test('undump empty string', () => { test('luaL_loadbuffer', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "hello world" @@ -72,17 +72,17 @@ test('luaL_loadbuffer', () => { { lualib.luaL_openlibs(L); let bc = toByteCode(luaCode); - lauxlib.luaL_loadbuffer(L, bc, null, to_luastring('test')); + lauxlib.luaL_loadbuffer(L, bc, null, to_luastring("test")); lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello world'); + .toBe("hello world"); }); // TODO: test stdin test('loadfile', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = assert(loadfile("test/loadfile-test.lua")) @@ -94,13 +94,13 @@ test('loadfile', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello world'); + .toBe("hello world"); }); test('loadfile (binary)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = assert(loadfile("test/loadfile-test.bc")) @@ -112,13 +112,13 @@ test('loadfile (binary)', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello world'); + .toBe("hello world"); }); test('dofile', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return dofile("test/loadfile-test.lua") @@ -129,5 +129,5 @@ test('dofile', () => { lua.lua_call(L, 0, -1); } expect(lua.lua_tojsstring(L, -1)) - .toBe('hello world'); + .toBe("hello world"); }); diff --git a/test/loadlib.test.js b/test/loadlib.test.js index a3be494c..c0125c08 100644 --- a/test/loadlib.test.js +++ b/test/loadlib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('require an existing module', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return require('os') @@ -24,7 +24,7 @@ test('require an existing module', () => { test('require a file', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return require('test.module-hello')() @@ -35,13 +35,13 @@ test('require a file', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello from module'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello from module"); }); test('package.loadlib', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return package.loadlib('./test/lib-hello.js.mod', 'hello')() @@ -52,13 +52,13 @@ test('package.loadlib', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello from js lib'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello from js lib"); }); test('package.searchpath', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return package.searchpath('module-hello', './?.lua;./test/?.lua') @@ -69,5 +69,5 @@ test('package.searchpath', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('./test/module-hello.lua'); + expect(lua.lua_tojsstring(L, -1)).toBe("./test/module-hello.lua"); }); diff --git a/test/loslib.test.js b/test/loslib.test.js index 9c3d68d6..af7de92a 100644 --- a/test/loslib.test.js +++ b/test/loslib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('os.time', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.time() @@ -24,7 +24,7 @@ test('os.time', () => { test('os.time (with format)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.time({ @@ -46,7 +46,7 @@ test('os.time (with format)', () => { test('os.difftime', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t1 = os.time() @@ -65,7 +65,7 @@ test('os.difftime', () => { test('os.date', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -80,13 +80,13 @@ test('os.date', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('2015-02-08'); + expect(lua.lua_tojsstring(L, -1)).toBe("2015-02-08"); }); test('os.date normalisation', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -101,13 +101,13 @@ test('os.date normalisation', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('2013-11-30'); + expect(lua.lua_tojsstring(L, -1)).toBe("2013-11-30"); }); test('os.time normalisation of table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = { @@ -130,7 +130,7 @@ test('os.time normalisation of table', () => { test('os.setlocale', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert("C" == os.setlocale()) @@ -147,7 +147,7 @@ test('os.setlocale', () => { test('os.getenv', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.getenv('PATH') diff --git a/test/lstrlib.test.js b/test/lstrlib.test.js index 53383430..3ae2ec3f 100644 --- a/test/lstrlib.test.js +++ b/test/lstrlib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('string.len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "world" @@ -26,7 +26,7 @@ test('string.len', () => { test('string.char', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.char(104, 101, 108, 108, 111) @@ -37,13 +37,13 @@ test('string.char', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('string.upper, string.lower', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.upper("hello"), string.lower("HELLO") @@ -54,14 +54,14 @@ test('string.upper, string.lower', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('HELLO'); - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -2)).toBe("HELLO"); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('string.rep', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.rep("hello", 3, ", ") @@ -72,13 +72,13 @@ test('string.rep', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello, hello, hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello, hello, hello"); }); test('string.reverse', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.reverse("olleh") @@ -89,13 +89,13 @@ test('string.reverse', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('string.byte', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.byte("hello", 2, 4) @@ -114,7 +114,7 @@ test('string.byte', () => { test('string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.format("%%%d %010d", 10, 23) @@ -125,13 +125,13 @@ test('string.format', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('%10 0000000023'); + expect(lua.lua_tojsstring(L, -1)).toBe("%10 0000000023"); }); test('string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.format("%07X", 0xFFFFFFF) @@ -142,13 +142,13 @@ test('string.format', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('FFFFFFF'); + expect(lua.lua_tojsstring(L, -1)).toBe("FFFFFFF"); }); test('string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.format("%q", 'a string with "quotes" and \\n new line') @@ -160,14 +160,14 @@ test('string.format', () => { } expect(lua.lua_tojsstring(L, -1)).toBe('"a string with \\"quotes\\" and \\\n new line"', - 'Correct element(s) on the stack' + "Correct element(s) on the stack" ); }); test('string.sub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.sub("123456789",2,4), -- "234" @@ -188,23 +188,23 @@ test('string.sub', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -11)).toBe('234'); - expect(lua.lua_tojsstring(L, -10)).toBe('789'); - expect(lua.lua_tojsstring(L, -9)).toBe(''); - expect(lua.lua_tojsstring(L, -8)).toBe('7'); - expect(lua.lua_tojsstring(L, -7)).toBe(''); - expect(lua.lua_tojsstring(L, -6)).toBe('123456789'); - expect(lua.lua_tojsstring(L, -5)).toBe('123456789'); - expect(lua.lua_tojsstring(L, -4)).toBe(''); - expect(lua.lua_tojsstring(L, -3)).toBe('9'); - expect(lua.lua_tojsstring(L, -2)).toBe('6789'); - expect(lua.lua_tojsstring(L, -1)).toBe('456'); + expect(lua.lua_tojsstring(L, -11)).toBe("234"); + expect(lua.lua_tojsstring(L, -10)).toBe("789"); + expect(lua.lua_tojsstring(L, -9)).toBe(""); + expect(lua.lua_tojsstring(L, -8)).toBe("7"); + expect(lua.lua_tojsstring(L, -7)).toBe(""); + expect(lua.lua_tojsstring(L, -6)).toBe("123456789"); + expect(lua.lua_tojsstring(L, -5)).toBe("123456789"); + expect(lua.lua_tojsstring(L, -4)).toBe(""); + expect(lua.lua_tojsstring(L, -3)).toBe("9"); + expect(lua.lua_tojsstring(L, -2)).toBe("6789"); + expect(lua.lua_tojsstring(L, -1)).toBe("456"); }); test('string.dump', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local todump = function() @@ -227,17 +227,17 @@ test('string.dump', () => { let r = s.str; s.str = null; return r; - }, {str: str}, to_luastring('test'), to_luastring('binary')); + }, {str: str}, to_luastring("test"), to_luastring("binary")); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello1212.5'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello1212.5"); }); test('string.pack/unpack/packsize', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local s1, n, s2 = "hello", 2, "you" @@ -258,7 +258,7 @@ test('string.pack/unpack/packsize', () => { test('string.find without pattern', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.find("hello to you", " to ") @@ -276,7 +276,7 @@ test('string.find without pattern', () => { test('string.find with special pattern (issue #185)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.find("-", "-") @@ -295,7 +295,7 @@ test('string.find with special pattern (issue #185)', () => { test('string.match', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)") @@ -306,14 +306,14 @@ test('string.match', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('foo'); - expect(lua.lua_tojsstring(L, -1)).toBe('123'); + expect(lua.lua_tojsstring(L, -2)).toBe("foo"); + expect(lua.lua_tojsstring(L, -1)).toBe("123"); }); test('string.find', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)") @@ -326,14 +326,14 @@ test('string.find', () => { expect(lua.lua_tointeger(L, -4)).toBe(1); expect(lua.lua_tointeger(L, -3)).toBe(8); - expect(lua.lua_tojsstring(L, -2)).toBe('foo'); - expect(lua.lua_tojsstring(L, -1)).toBe('123'); + expect(lua.lua_tojsstring(L, -2)).toBe("foo"); + expect(lua.lua_tojsstring(L, -1)).toBe("123"); }); test('string.gmatch', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local s = "hello world from Lua" @@ -351,16 +351,16 @@ test('string.gmatch', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -4)).toBe('hello'); - expect(lua.lua_tojsstring(L, -3)).toBe('world'); - expect(lua.lua_tojsstring(L, -2)).toBe('from'); - expect(lua.lua_tojsstring(L, -1)).toBe('Lua'); + expect(lua.lua_tojsstring(L, -4)).toBe("hello"); + expect(lua.lua_tojsstring(L, -3)).toBe("world"); + expect(lua.lua_tojsstring(L, -2)).toBe("from"); + expect(lua.lua_tojsstring(L, -1)).toBe("Lua"); }); test('string.gsub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("hello world", "(%w+)", "%1 %1") @@ -371,14 +371,14 @@ test('string.gsub', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('hello hello world world'); + expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world world"); expect(lua.lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (number)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("hello world", "%w+", "%0 %0", 1) @@ -389,14 +389,14 @@ test('string.gsub (number)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('hello hello world'); + expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world"); expect(lua.lua_tointeger(L, -1)).toBe(1); }); test('string.gsub (pattern)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1") @@ -407,14 +407,14 @@ test('string.gsub (pattern)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('world hello Lua from'); + expect(lua.lua_tojsstring(L, -2)).toBe("world hello Lua from"); expect(lua.lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (function)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) @@ -427,7 +427,7 @@ test('string.gsub (function)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('4+5 = 9'); + expect(lua.lua_tojsstring(L, -2)).toBe("4+5 = 9"); expect(lua.lua_tointeger(L, -1)).toBe(1); }); @@ -435,7 +435,7 @@ test('string.gsub (function)', () => { test('string.gsub (table)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {name="lua", version="5.3"} @@ -447,6 +447,6 @@ test('string.gsub (table)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe('lua-5.3.tar.gz'); + expect(lua.lua_tojsstring(L, -2)).toBe("lua-5.3.tar.gz"); expect(lua.lua_tointeger(L, -1)).toBe(2); }); diff --git a/test/ltablib.test.js b/test/ltablib.test.js index 91b1c3ad..2cce1189 100644 --- a/test/ltablib.test.js +++ b/test/ltablib.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); const inttable2array = function(t) { let a = []; @@ -16,7 +16,7 @@ const inttable2array = function(t) { test('table.concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return table.concat({1, 2, 3, 4, 5, 6, 7}, ",", 3, 5) @@ -27,13 +27,13 @@ test('table.concat', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('3,4,5'); + expect(lua.lua_tojsstring(L, -1)).toBe("3,4,5"); }); test('table.pack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return table.pack(1, 2, 3) @@ -53,7 +53,7 @@ test('table.pack', () => { test('table.unpack', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return table.unpack({1, 2, 3, 4, 5}, 2, 4) @@ -72,7 +72,7 @@ test('table.unpack', () => { test('table.insert', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 3, 4} @@ -96,7 +96,7 @@ test('table.insert', () => { test('table.remove', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 2, 3, 3, 4, 4} @@ -120,7 +120,7 @@ test('table.remove', () => { test('table.move', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t1 = {3, 4, 5} @@ -143,7 +143,7 @@ test('table.move', () => { test('table.sort (<)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} @@ -163,7 +163,7 @@ test('table.sort (<)', () => { test('table.sort with cmp function', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} diff --git a/test/ltm.test.js b/test/ltm.test.js index ba56539d..c4e03da8 100644 --- a/test/ltm.test.js +++ b/test/ltm.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); test('__index, __newindex: with actual table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {yo=1} @@ -26,7 +26,7 @@ test('__index, __newindex: with actual table', () => { test('__newindex: with non table', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = "a string" @@ -45,7 +45,7 @@ test('__newindex: with non table', () => { test('__index function in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -66,13 +66,13 @@ test('__index function in metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('__index'); + expect(lua.lua_tojsstring(L, -1)).toBe("__index"); }); test('__newindex function in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -101,7 +101,7 @@ test('__newindex function in metatable', () => { test('__index table in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mmt = { @@ -124,13 +124,13 @@ test('__index table in metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('__newindex table in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mmt = { @@ -155,14 +155,14 @@ test('__newindex table in metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('world'); + expect(lua.lua_tojsstring(L, -1)).toBe("world"); expect(lua.lua_isnil(L, -2)).toBe(true); }); test('__index table with own metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mmmt = { @@ -193,13 +193,13 @@ test('__index table with own metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('__newindex table with own metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local up = nil @@ -234,14 +234,14 @@ test('__newindex table with own metatable', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); expect(lua.lua_isnil(L, -2)).toBe(true); }); test('binary __xxx functions in metatable', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -321,25 +321,25 @@ test('binary __xxx functions in metatable', () => { expect(L.stack.slice(L.top - 12, L.top).map(e => e.jsstring())) .toEqual([ - '{} + 1', - '{} - 1', - '{} * 1', - '{} % 1', - '{} ^ 1', - '{} / 1', - '{} // 1', - '{} & 1', - '{} | 1', - '{} ~ 1', - '{} << 1', - '{} >> 1' + "{} + 1", + "{} - 1", + "{} * 1", + "{} % 1", + "{} ^ 1", + "{} / 1", + "{} // 1", + "{} & 1", + "{} | 1", + "{} ~ 1", + "{} << 1", + "{} >> 1" ]); }); test('__eq', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -366,7 +366,7 @@ test('__eq', () => { test('__lt', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -393,7 +393,7 @@ test('__lt', () => { test('__le', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -420,7 +420,7 @@ test('__le', () => { test('__le that uses __lt', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -447,7 +447,7 @@ test('__le that uses __lt', () => { test('__unm, __bnot', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -472,14 +472,14 @@ test('__unm, __bnot', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('world'); - expect(lua.lua_tojsstring(L, -2)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("world"); + expect(lua.lua_tojsstring(L, -2)).toBe("hello"); }); test('__len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -500,13 +500,13 @@ test('__len', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('__concat', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -527,13 +527,13 @@ test('__concat', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('__call', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt = { @@ -555,5 +555,5 @@ test('__call', () => { } expect(L.stack.slice(L.top - 3, L.top).map(e => e.jsstring())) - .toEqual(['hello', 'world', 'wow']); + .toEqual(["hello", "world", "wow"]); }); diff --git a/test/lua.test.js b/test/lua.test.js index f4a060cb..0f12238b 100644 --- a/test/lua.test.js +++ b/test/lua.test.js @@ -1,14 +1,14 @@ -'use strict'; +"use strict"; const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const {to_luastring} = require("../src/fengaricore.js"); // TODO: remove test.skip('locals.lua', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _soft = true @@ -25,7 +25,7 @@ test.skip('locals.lua', () => { test.skip('constructs.lua', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _soft = true @@ -42,7 +42,7 @@ test.skip('constructs.lua', () => { test.skip('strings.lua', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return dofile("tests/lua-tests/strings.lua") @@ -57,7 +57,7 @@ test.skip('strings.lua', () => { test('__newindex leaves nils', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local x = setmetatable({}, { diff --git a/test/lutf8lib.test.js b/test/lutf8lib.test.js index 4bb04fa7..d2d51b31 100644 --- a/test/lutf8lib.test.js +++ b/test/lutf8lib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const lua = require("../src/lua.js"); +const lauxlib = require("../src/lauxlib.js"); +const lualib = require("../src/lualib.js"); +const {to_luastring} = require("../src/fengaricore.js"); test('utf8.offset', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.offset("( ͡° ͜ʖ ͡° )", 5) @@ -24,7 +24,7 @@ test('utf8.offset', () => { test('utf8.codepoint', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8) @@ -43,7 +43,7 @@ test('utf8.codepoint', () => { test('utf8.char', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.char(40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 32, 41) @@ -54,13 +54,13 @@ test('utf8.char', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('( ͡° ͜ʖ ͡° )'); + expect(lua.lua_tojsstring(L, -1)).toBe("( ͡° ͜ʖ ͡° )"); }); test('utf8.len', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.len("( ͡° ͜ʖ ͡° )") @@ -77,7 +77,7 @@ test('utf8.len', () => { test('utf8.codes', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local s = "( ͡° ͜ʖ ͡° )" @@ -93,5 +93,5 @@ test('utf8.codes', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] '); + expect(lua.lua_tojsstring(L, -1)).toBe("[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] "); }); diff --git a/test/lvm.test.js b/test/lvm.test.js index 5630c4c4..daa4539f 100644 --- a/test/lvm.test.js +++ b/test/lvm.test.js @@ -1,14 +1,14 @@ -'use strict'; +"use strict"; -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lstring = require('../src/lstring.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const lua = require("../src/lua.js"); +const lauxlib = require("../src/lauxlib.js"); +const lstring = require("../src/lstring.js"); +const {to_luastring} = require("../src/fengaricore.js"); test('LOADK, RETURN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "hello world" @@ -19,13 +19,13 @@ test('LOADK, RETURN', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); }); test('MOVE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = "hello world" @@ -37,12 +37,12 @@ test('MOVE', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello world'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); }); test('Binary op', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = 5 @@ -61,7 +61,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = 5 @@ -80,7 +80,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = {} @@ -97,7 +97,7 @@ test('NEWTABLE', () => { test('CALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (a, b) @@ -119,7 +119,7 @@ test('CALL', () => { test('Multiple return', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (a, b) @@ -146,7 +146,7 @@ test('Multiple return', () => { test('TAILCALL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (a, b) @@ -166,7 +166,7 @@ test('TAILCALL', () => { test('VARARG', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (...) @@ -187,7 +187,7 @@ test('VARARG', () => { test('LE, JMP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 1, 1 @@ -205,7 +205,7 @@ test('LE, JMP', () => { test('LT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 1, 1 @@ -223,7 +223,7 @@ test('LT', () => { test('EQ', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 1, 1 @@ -241,7 +241,7 @@ test('EQ', () => { test('TESTSET (and)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -254,13 +254,13 @@ test('TESTSET (and)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('TESTSET (or)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = false @@ -273,13 +273,13 @@ test('TESTSET (or)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('TEST (true)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = true @@ -296,13 +296,13 @@ test('TEST (true)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('TEST (false)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = false @@ -319,13 +319,13 @@ test('TEST (false)', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('goodbye'); + expect(lua.lua_tojsstring(L, -1)).toBe("goodbye"); }); test('FORPREP, FORLOOP (int)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 @@ -347,7 +347,7 @@ test('FORPREP, FORLOOP (int)', () => { test('FORPREP, FORLOOP (float)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local total = 0 @@ -369,7 +369,7 @@ test('FORPREP, FORLOOP (float)', () => { test('SETTABLE, GETTABLE', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {} @@ -385,15 +385,15 @@ test('SETTABLE, GETTABLE', () => { } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe('hello'); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) - .toBe('world'); + .toBe("hello"); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + .toBe("world"); }); test('SETUPVAL, GETUPVAL', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local up = "hello" @@ -411,13 +411,13 @@ test('SETUPVAL, GETUPVAL', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('world'); + expect(lua.lua_tojsstring(L, -1)).toBe("world"); }); test('SETTABUP, GETTABUP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = {} @@ -433,15 +433,15 @@ test('SETTABUP, GETTABUP', () => { } expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe('hello'); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring('two'))).value.jsstring()) - .toBe('world'); + .toBe("hello"); + expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + .toBe("world"); }); test('SELF', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {} @@ -458,13 +458,13 @@ test('SELF', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello"); }); test('SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -483,7 +483,7 @@ test('SETLIST', () => { test('Variable SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = function () @@ -506,7 +506,7 @@ test('Variable SETLIST', () => { test('Long SETLIST', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} @@ -549,7 +549,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local iterator = function (t, i) @@ -583,7 +583,7 @@ test('TFORCALL, TFORLOOP', () => { test('LEN', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {[10000] = "foo"} @@ -605,7 +605,7 @@ test('LEN', () => { test('CONCAT', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` return "hello " .. 2 .. " you" @@ -615,5 +615,5 @@ test('CONCAT', () => { lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('hello 2 you'); + expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you"); }); diff --git a/test/manual-tests/debug-cli.js b/test/manual-tests/debug-cli.js index f4ce8e9a..dc49a0e0 100755 --- a/test/manual-tests/debug-cli.js +++ b/test/manual-tests/debug-cli.js @@ -1,10 +1,10 @@ #!/usr/bin/env node -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); let luaCode = ` a = "debug me" diff --git a/test/test-suite/api.test.js b/test/test-suite/api.test.js index eb101174..5a5e10ea 100644 --- a/test/test-suite/api.test.js +++ b/test/test-suite/api.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const ltests = require('./ltests.js'); @@ -26,9 +26,9 @@ const prefix = ` end `; -test('[test-suite] api: registry', () => { +test("[test-suite] api: registry", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = T.testC("pushvalue R; return 1") @@ -42,9 +42,9 @@ test('[test-suite] api: registry', () => { }); -test('[test-suite] api: absindex', () => { +test("[test-suite] api: absindex", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(T.testC("settop 10; absindex -1; return 1") == 10) @@ -60,9 +60,9 @@ test('[test-suite] api: absindex', () => { }); -test('[test-suite] api: testing alignment', () => { +test("[test-suite] api: testing alignment", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- Useless tests in fengari since we do the same thing in d2s than in string.pack @@ -85,9 +85,9 @@ test('[test-suite] api: testing alignment', () => { }); -test('[test-suite] api: test that all trues are equal', () => { +test("[test-suite] api: test that all trues are equal", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a,b,c = T.testC("pushbool 1; pushbool 2; pushbool 0; return 3") @@ -138,9 +138,9 @@ test('[test-suite] api: test that all trues are equal', () => { }); -test('[test-suite] api: testing \'rotate\'', () => { +test("[test-suite] api: testing 'rotate'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- testing 'rotate' @@ -174,9 +174,9 @@ test('[test-suite] api: testing \'rotate\'', () => { }); -test('[test-suite] api: testing non-function message handlers', () => { +test("[test-suite] api: testing non-function message handlers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -215,9 +215,9 @@ test('[test-suite] api: testing non-function message handlers', () => { }); -test('[test-suite] api: testing MULTRET', () => { +test("[test-suite] api: testing MULTRET", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = pack(T.testC("call 2,-1; return *", @@ -232,9 +232,9 @@ test('[test-suite] api: testing MULTRET', () => { }); -test('[test-suite] api: test returning more results than fit in the caller stack', () => { +test("[test-suite] api: test returning more results than fit in the caller stack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- test returning more results than fit in the caller stack @@ -253,9 +253,9 @@ test('[test-suite] api: test returning more results than fit in the caller stack }); -test('[test-suite] api: testing globals', () => { +test("[test-suite] api: testing globals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _G.a = 14; _G.b = "a31" @@ -276,9 +276,9 @@ test('[test-suite] api: testing globals', () => { }); -test('[test-suite] api: testing arith', () => { +test("[test-suite] api: testing arith", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5) @@ -322,9 +322,9 @@ test('[test-suite] api: testing arith', () => { }); -test('[test-suite] api: errors in arithmetic', () => { +test("[test-suite] api: errors in arithmetic", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerr("divide by zero", T.testC, "arith \\\\", 10, 0) @@ -338,9 +338,9 @@ test('[test-suite] api: errors in arithmetic', () => { }); -test('[test-suite] api: testing lessthan and lessequal', () => { +test("[test-suite] api: testing lessthan and lessequal", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(T.testC("compare LT 2 5, return 1", 3, 2, 2, 4, 2, 2)) @@ -359,9 +359,9 @@ test('[test-suite] api: testing lessthan and lessequal', () => { }); -test('[test-suite] api: non-valid indices produce false', () => { +test("[test-suite] api: non-valid indices produce false", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not T.testC("compare LT 1 4, return 1")) @@ -390,9 +390,9 @@ test('[test-suite] api: non-valid indices produce false', () => { }); -test('[test-suite] api: testing length', () => { +test("[test-suite] api: testing length", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = setmetatable({x = 20}, {__len = function (t) return t.x end}) @@ -429,9 +429,9 @@ test('[test-suite] api: testing length', () => { }); -test('[test-suite] api: testing __concat', () => { +test("[test-suite] api: testing __concat", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = setmetatable({x="u"}, {__concat = function (a,b) return a.x..'.'..b.x end}) @@ -459,9 +459,9 @@ test('[test-suite] api: testing __concat', () => { }); -test('[test-suite] api: testing lua_is', () => { +test("[test-suite] api: testing lua_is", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function B(x) return x and 1 or 0 end @@ -502,9 +502,9 @@ test('[test-suite] api: testing lua_is', () => { }); -test('[test-suite] api: testing lua_to...', () => { +test("[test-suite] api: testing lua_to...", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function to (s, x, n) @@ -550,9 +550,9 @@ test('[test-suite] api: testing lua_to...', () => { lua.lua_call(L, 0, 0); }); -test('[test-suite] api: testing panic function', () => { +test("[test-suite] api: testing panic function", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -598,9 +598,9 @@ test('[test-suite] api: testing panic function', () => { }); -test.skip('[test-suite] api: testing deep JS stack', () => { +test.skip("[test-suite] api: testing deep JS stack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -642,9 +642,9 @@ test.skip('[test-suite] api: testing deep JS stack', () => { }); -test('[test-suite] api: testing errors', () => { +test("[test-suite] api: testing errors", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = T.testC([[ @@ -673,9 +673,9 @@ test('[test-suite] api: testing errors', () => { }); -test('[test-suite] api: test errors in non protected threads', () => { +test("[test-suite] api: test errors in non protected threads", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function checkerrnopro (code, msg) @@ -699,9 +699,9 @@ test('[test-suite] api: test errors in non protected threads', () => { }); -test('[test-suite] api: testing table access', () => { +test("[test-suite] api: testing table access", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- getp/setp @@ -750,9 +750,9 @@ test('[test-suite] api: testing table access', () => { }); -test('[test-suite] api: testing getfield/setfield with long keys', () => { +test("[test-suite] api: testing getfield/setfield with long keys", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- testing getfield/setfield with long keys @@ -778,9 +778,9 @@ test('[test-suite] api: testing getfield/setfield with long keys', () => { }); -test('[test-suite] api: testing next', () => { +test("[test-suite] api: testing next", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -800,9 +800,9 @@ test('[test-suite] api: testing next', () => { }); -test('[test-suite] api: testing upvalues', () => { +test("[test-suite] api: testing upvalues", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -828,9 +828,9 @@ test('[test-suite] api: testing upvalues', () => { }); -test('[test-suite] api: testing absent upvalues from JS-function pointers', () => { +test("[test-suite] api: testing absent upvalues from JS-function pointers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(T.testC[[isnull U1; return 1]] == true) @@ -852,9 +852,9 @@ test('[test-suite] api: testing absent upvalues from JS-function pointers', () = }); -test('[test-suite] api: large closures', () => { +test("[test-suite] api: large closures", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -877,9 +877,9 @@ test('[test-suite] api: large closures', () => { }); -test('[test-suite] api: testing get/setuservalue', () => { +test("[test-suite] api: testing get/setuservalue", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- bug in 5.1.2 @@ -912,9 +912,9 @@ test('[test-suite] api: testing get/setuservalue', () => { }); -test.skip('[test-suite] api: testing get/setuservalue', () => { +test.skip("[test-suite] api: testing get/setuservalue", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` T.gcstate("atomic") @@ -931,9 +931,9 @@ test.skip('[test-suite] api: testing get/setuservalue', () => { }); -test.skip('[test-suite] api: long chain of userdata', () => { +test.skip("[test-suite] api: long chain of userdata", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for i = 1, 1000 do @@ -956,9 +956,9 @@ test.skip('[test-suite] api: long chain of userdata', () => { }); -test.skip('[test-suite] api: reuse of references', () => { +test.skip("[test-suite] api: reuse of references", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local i = T.ref{} @@ -1016,9 +1016,9 @@ test.skip('[test-suite] api: reuse of references', () => { }); -test.skip('[test-suite] api: collect in cl the `val\' of all collected userdata', () => { +test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` tt = {} @@ -1132,9 +1132,9 @@ test.skip('[test-suite] api: collect in cl the `val\' of all collected userdata' }); -test.skip('[test-suite] api: test whether udate collection frees memory in the right time', () => { +test.skip("[test-suite] api: test whether udate collection frees memory in the right time", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -1176,9 +1176,9 @@ test.skip('[test-suite] api: test whether udate collection frees memory in the r }); -test('[test-suite] api: testing lua_equal', () => { +test("[test-suite] api: testing lua_equal", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(T.testC("compare EQ 2 4; return 1", print, 1, print, 20)) @@ -1196,9 +1196,9 @@ test('[test-suite] api: testing lua_equal', () => { }); -test('[test-suite] api: testing lua_equal with fallbacks', () => { +test("[test-suite] api: testing lua_equal with fallbacks", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -1226,9 +1226,9 @@ test('[test-suite] api: testing lua_equal with fallbacks', () => { }); -test('[test-suite] api: testing changing hooks during hooks', () => { +test("[test-suite] api: testing changing hooks during hooks", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _G.t = {} @@ -1260,9 +1260,9 @@ test('[test-suite] api: testing changing hooks during hooks', () => { }); -test.skip('[test-suite] api: testing errors during GC', () => { +test.skip("[test-suite] api: testing errors during GC", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- testing errors during GC @@ -1300,9 +1300,9 @@ test.skip('[test-suite] api: testing errors during GC', () => { }); -test('[test-suite] api: test for userdata vals', () => { +test("[test-suite] api: test for userdata vals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -1323,9 +1323,9 @@ test('[test-suite] api: test for userdata vals', () => { }); -test('[test-suite] api: testing multiple states', () => { +test("[test-suite] api: testing multiple states", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` T.closestate(T.newstate()); @@ -1382,9 +1382,9 @@ test('[test-suite] api: testing multiple states', () => { }); -test.skip('[test-suite] api: testing memory limits', () => { +test.skip("[test-suite] api: testing memory limits", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerr("block too big", T.newuserdata, math.maxinteger) @@ -1428,9 +1428,9 @@ const memprefix = ` `; -test.skip('[test-suite] api: testing memory errors when creating a new state', () => { +test.skip("[test-suite] api: testing memory errors when creating a new state", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` b = testamem("state creation", T.newstate) @@ -1443,9 +1443,9 @@ test.skip('[test-suite] api: testing memory errors when creating a new state', ( lua.lua_call(L, 0, 0); }); -test('[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)', () => { +test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` mt = T.testC("rawgeti R 1; return 1") @@ -1458,9 +1458,9 @@ test('[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHR lua.lua_call(L, 0, 0); }); -test.skip('[test-suite] api: test thread creation after stressing GC', () => { +test.skip("[test-suite] api: test thread creation after stressing GC", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function expand (n,s) @@ -1486,9 +1486,9 @@ test.skip('[test-suite] api: test thread creation after stressing GC', () => { }); -test.skip('[test-suite] api: testing memory x compiler', () => { +test.skip("[test-suite] api: testing memory x compiler", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` testamem("loadstring", function () @@ -1503,9 +1503,9 @@ test.skip('[test-suite] api: testing memory x compiler', () => { }); -test.skip('[test-suite] api: testing memory x dofile', () => { +test.skip("[test-suite] api: testing memory x dofile", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local testprog = [[ @@ -1537,9 +1537,9 @@ test.skip('[test-suite] api: testing memory x dofile', () => { }); -test.skip('[test-suite] api: other generic tests', () => { +test.skip("[test-suite] api: other generic tests", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` testamem("string creation", function () @@ -1608,9 +1608,9 @@ test.skip('[test-suite] api: other generic tests', () => { }); -test('[test-suite] api: testing some auxlib functions', () => { +test("[test-suite] api: testing some auxlib functions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function gsub (a, b, c) @@ -1633,9 +1633,9 @@ test('[test-suite] api: testing some auxlib functions', () => { }); -test('[test-suite] api: testing luaL_newmetatable', () => { +test("[test-suite] api: testing luaL_newmetatable", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local mt_xuxu, res, top = T.testC("newmetatable xuxu; gettop; return 3") diff --git a/test/test-suite/attrib.test.js b/test/test-suite/attrib.test.js index 3b419bc1..bb07e628 100644 --- a/test/test-suite/attrib.test.js +++ b/test/test-suite/attrib.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); -test('[test-suite] attrib: testing require', () => { +test("[test-suite] attrib: testing require", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(require"string" == string) @@ -62,15 +62,15 @@ test('[test-suite] attrib: testing require', () => { // TODO: when io.write etc. -test.skip('[test-suite] attrib: system specific tests for \'require\'', () => { +test.skip("[test-suite] attrib: system specific tests for 'require'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); }); -test('[test-suite] attrib: testing assignments, logical operators, and constructors', () => { +test("[test-suite] attrib: testing assignments, logical operators, and constructors", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local res, res2 = 27 @@ -168,9 +168,9 @@ test('[test-suite] attrib: testing assignments, logical operators, and construct }); -test('[test-suite] attrib: test of large float/integer indices ', () => { +test("[test-suite] attrib: test of large float/integer indices ", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -232,9 +232,9 @@ test('[test-suite] attrib: test of large float/integer indices ', () => { }); -test('[test-suite] attrib: test conflicts in multiple assignment', () => { +test("[test-suite] attrib: test conflicts in multiple assignment", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -252,9 +252,9 @@ test('[test-suite] attrib: test conflicts in multiple assignment', () => { }); -test('[test-suite] attrib: repeat test with upvalues', () => { +test("[test-suite] attrib: repeat test with upvalues", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -278,9 +278,9 @@ test('[test-suite] attrib: repeat test with upvalues', () => { }); -test('[test-suite] attrib: bug in 5.2 beta', () => { +test("[test-suite] attrib: bug in 5.2 beta", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo () diff --git a/test/test-suite/bitwise.test.js b/test/test-suite/bitwise.test.js index a5e3722c..bf8de5c5 100644 --- a/test/test-suite/bitwise.test.js +++ b/test/test-suite/bitwise.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` package.preload.bit32 = function () --{ @@ -114,9 +114,9 @@ const prefix = ` local bit32 = require'bit32' `; -test('[test-suite] bitwise: testing bitwise operations', () => { +test("[test-suite] bitwise: testing bitwise operations", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local numbits = string.packsize('j') * 8 @@ -184,9 +184,9 @@ test('[test-suite] bitwise: testing bitwise operations', () => { }); -test('[test-suite] bitwise: testing bitwise library', () => { +test("[test-suite] bitwise: testing bitwise library", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(bit32.band() == bit32.bnot(0)) @@ -204,9 +204,9 @@ test('[test-suite] bitwise: testing bitwise library', () => { }); -test('[test-suite] bitwise: out-of-range numbers', () => { +test("[test-suite] bitwise: out-of-range numbers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(bit32.band(-1) == 0xffffffff) @@ -269,9 +269,9 @@ test('[test-suite] bitwise: out-of-range numbers', () => { }); -test('[test-suite] bitwise: some special cases', () => { +test("[test-suite] bitwise: some special cases", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555, @@ -312,9 +312,9 @@ test('[test-suite] bitwise: some special cases', () => { }); -test('[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)', () => { +test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` c = {0, 1, 2, 3, 10, 0x800000, 0xaaaaaa, 0x555555, 0xffffff, 0x7fffff} @@ -339,9 +339,9 @@ test('[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si }); -test('[test-suite] bitwise: testing extract/replace', () => { +test("[test-suite] bitwise: testing extract/replace", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(bit32.extract(0x12345678, 0, 4) == 8) @@ -370,9 +370,9 @@ test('[test-suite] bitwise: testing extract/replace', () => { }); -test('[test-suite] bitwise: testing conversion of floats', () => { +test("[test-suite] bitwise: testing conversion of floats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(bit32.bor(3.0) == 3) @@ -385,9 +385,9 @@ test('[test-suite] bitwise: testing conversion of floats', () => { }); -test('[test-suite] bitwise: large floats and large-enough integers?', () => { +test("[test-suite] bitwise: large floats and large-enough integers?", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` if 2.0^50 < 2.0^50 + 1.0 and 2.0^50 < (-1 >> 1) then diff --git a/test/test-suite/calls.test.js b/test/test-suite/calls.test.js index 34b926b1..16043376 100644 --- a/test/test-suite/calls.test.js +++ b/test/test-suite/calls.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); -test('[test-suite] calls: test \'type\'', () => { +test("[test-suite] calls: test 'type'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(type(1<2) == 'boolean') @@ -30,9 +30,9 @@ test('[test-suite] calls: test \'type\'', () => { }); -test('[test-suite] calls: test error in \'print\'', () => { +test("[test-suite] calls: test error in 'print'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- test error in 'print' too... @@ -56,9 +56,9 @@ test('[test-suite] calls: test error in \'print\'', () => { }); -test('[test-suite] calls: testing local-function recursion', () => { +test("[test-suite] calls: testing local-function recursion", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` fact = false @@ -80,9 +80,9 @@ test('[test-suite] calls: testing local-function recursion', () => { }); -test('[test-suite] calls: testing declarations', () => { +test("[test-suite] calls: testing declarations", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {i = 10} @@ -175,9 +175,9 @@ test('[test-suite] calls: testing declarations', () => { }); -test('[test-suite] calls: testing closures', () => { +test("[test-suite] calls: testing closures", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- fixed-point operator @@ -221,9 +221,9 @@ test('[test-suite] calls: testing closures', () => { }); -test('[test-suite] calls: testing multiple returns', () => { +test("[test-suite] calls: testing multiple returns", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function unlpack (t, i) @@ -267,9 +267,9 @@ test('[test-suite] calls: testing multiple returns', () => { }); -test('[test-suite] calls: testing calls with \'incorrect\' arguments', () => { +test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` rawget({}, "x", 1) @@ -284,9 +284,9 @@ test('[test-suite] calls: testing calls with \'incorrect\' arguments', () => { }); -test('[test-suite] calls: test for generic load', () => { +test("[test-suite] calls: test for generic load", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local x = "-- a comment\\0\\0\\0\\n x = 10 + \\n23; \\ @@ -344,9 +344,9 @@ test('[test-suite] calls: test for generic load', () => { }); -test('[test-suite] calls: any value is valid for _ENV', () => { +test("[test-suite] calls: any value is valid for _ENV", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(load("return _ENV", nil, nil, 123)() == 123) @@ -358,9 +358,9 @@ test('[test-suite] calls: any value is valid for _ENV', () => { }); -test('[test-suite] calls: load when _ENV is not first upvalue', () => { +test("[test-suite] calls: load when _ENV is not first upvalue", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local x; XX = 123 @@ -383,9 +383,9 @@ test('[test-suite] calls: load when _ENV is not first upvalue', () => { }); -test('[test-suite] calls: test generic load with nested functions', () => { +test("[test-suite] calls: test generic load with nested functions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function read1 (x) @@ -416,9 +416,9 @@ test('[test-suite] calls: test generic load with nested functions', () => { }); -test('[test-suite] calls: test for dump/undump with upvalues', () => { +test("[test-suite] calls: test for dump/undump with upvalues", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a, b = 20, 30 @@ -444,9 +444,9 @@ test('[test-suite] calls: test for dump/undump with upvalues', () => { }); -test('[test-suite] calls: test for dump/undump with many upvalues', () => { +test("[test-suite] calls: test for dump/undump with many upvalues", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -479,9 +479,9 @@ test('[test-suite] calls: test for dump/undump with many upvalues', () => { }); -test('[test-suite] calls: test for long method names', () => { +test("[test-suite] calls: test for long method names", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -499,9 +499,9 @@ test('[test-suite] calls: test for long method names', () => { }); -test('[test-suite] calls: test for bug in parameter adjustment', () => { +test("[test-suite] calls: test for bug in parameter adjustment", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert((function () return nil end)(4) == nil) @@ -515,9 +515,9 @@ test('[test-suite] calls: test for bug in parameter adjustment', () => { }); -test('[test-suite] calls: testing binary chunks', () => { +test("[test-suite] calls: testing binary chunks", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do diff --git a/test/test-suite/closure.test.js b/test/test-suite/closure.test.js index 0ee21b99..d44d908f 100644 --- a/test/test-suite/closure.test.js +++ b/test/test-suite/closure.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); -test('[test-suite] closure: testing equality', () => { +test("[test-suite] closure: testing equality", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -29,9 +29,9 @@ test('[test-suite] closure: testing equality', () => { }); -test('[test-suite] closure: testing closures with \'for\' control variable', () => { +test("[test-suite] closure: testing closures with 'for' control variable", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -70,9 +70,9 @@ test('[test-suite] closure: testing closures with \'for\' control variable', () }); -test('[test-suite] closure: testing closures with \'for\' control variable x break', () => { +test("[test-suite] closure: testing closures with 'for' control variable x break", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {"a", "b"} @@ -98,9 +98,9 @@ test('[test-suite] closure: testing closures with \'for\' control variable x bre }); -test('[test-suite] closure: testing closure x break x return x errors', () => { +test("[test-suite] closure: testing closure x break x return x errors", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local b @@ -142,9 +142,9 @@ test('[test-suite] closure: testing closure x break x return x errors', () => { }); -test('[test-suite] closure: testing multi-level closure', () => { +test("[test-suite] closure: testing multi-level closure", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local w @@ -165,9 +165,9 @@ test('[test-suite] closure: testing multi-level closure', () => { }); -test('[test-suite] closure: testing closures x repeat-until', () => { +test("[test-suite] closure: testing closures x repeat-until", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = {} @@ -185,9 +185,9 @@ test('[test-suite] closure: testing closures x repeat-until', () => { }); -test('[test-suite] closure: testing closures created in \'then\' and \'else\' parts of \'if\'s', () => { +test("[test-suite] closure: testing closures created in 'then' and 'else' parts of 'if's", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -226,9 +226,9 @@ test('[test-suite] closure: testing closures created in \'then\' and \'else\' pa }); -test('[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions', () => { +test("[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function t () diff --git a/test/test-suite/code.test.js b/test/test-suite/code.test.js index 3fdfeb02..377dd630 100644 --- a/test/test-suite/code.test.js +++ b/test/test-suite/code.test.js @@ -1,15 +1,15 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const ltests = require('./ltests.js'); -test('[test-suite] code: testing reuse in constant table', () => { +test("[test-suite] code: testing reuse in constant table", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function checkKlist (func, list) @@ -64,9 +64,9 @@ const prefix = ` `; -test('[test-suite] code: some basic instructions', () => { +test("[test-suite] code: some basic instructions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () @@ -81,9 +81,9 @@ test('[test-suite] code: some basic instructions', () => { }); -test('[test-suite] code: sequence of LOADNILs', () => { +test("[test-suite] code: sequence of LOADNILs", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () @@ -112,9 +112,9 @@ test('[test-suite] code: sequence of LOADNILs', () => { }); -test('[test-suite] code: single return', () => { +test("[test-suite] code: single return", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check (function (a,b,c) return a end, 'RETURN') @@ -127,9 +127,9 @@ test('[test-suite] code: single return', () => { }); -test('[test-suite] code: infinite loops', () => { +test("[test-suite] code: infinite loops", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () while true do local a = -1 end end, @@ -149,9 +149,9 @@ test('[test-suite] code: infinite loops', () => { }); -test('[test-suite] code: concat optimization', () => { +test("[test-suite] code: concat optimization", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function (a,b,c,d) return a..b..c..d end, @@ -165,9 +165,9 @@ test('[test-suite] code: concat optimization', () => { }); -test('[test-suite] code: not', () => { +test("[test-suite] code: not", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () return not not nil end, 'LOADBOOL', 'RETURN') @@ -183,9 +183,9 @@ test('[test-suite] code: not', () => { }); -test('[test-suite] code: direct access to locals', () => { +test("[test-suite] code: direct access to locals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () @@ -206,9 +206,9 @@ test('[test-suite] code: direct access to locals', () => { }); -test('[test-suite] code: direct access to constants', () => { +test("[test-suite] code: direct access to constants", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () @@ -241,9 +241,9 @@ test('[test-suite] code: direct access to constants', () => { }); -test('[test-suite] code: constant folding', () => { +test("[test-suite] code: constant folding", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function checkK (func, val) @@ -275,9 +275,9 @@ test('[test-suite] code: constant folding', () => { }); -test('[test-suite] code: no folding', () => { +test("[test-suite] code: no folding", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () return -0.0 end, 'LOADK', 'UNM', 'RETURN') @@ -293,9 +293,9 @@ test('[test-suite] code: no folding', () => { }); -test('[test-suite] code: bug in constant folding for 5.1', () => { +test("[test-suite] code: bug in constant folding for 5.1", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN') @@ -323,9 +323,9 @@ test('[test-suite] code: bug in constant folding for 5.1', () => { }); -test('[test-suite] code: x == nil , x ~= nil', () => { +test("[test-suite] code: x == nil , x ~= nil", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkequal(function () if (a==nil) then a=1 end; if a~=nil then a=1 end end, @@ -348,9 +348,9 @@ test('[test-suite] code: x == nil , x ~= nil', () => { }); -test('[test-suite] code: if-goto optimizations', () => { +test("[test-suite] code: if-goto optimizations", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function (a, b, c, d, e) diff --git a/test/test-suite/constructs.test.js b/test/test-suite/constructs.test.js index 180e99e6..e79778ae 100644 --- a/test/test-suite/constructs.test.js +++ b/test/test-suite/constructs.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const checkload = ` local function checkload (s, msg) @@ -13,7 +13,7 @@ const checkload = ` test('[test-suite] constructs: testing semicolons', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do ;;; end @@ -29,7 +29,7 @@ test('[test-suite] constructs: testing semicolons', () => { test('[test-suite] constructs: invalid operations should not raise errors when not executed', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` if false then a = 3 // 0; a = 0 % 0 end @@ -43,7 +43,7 @@ test('[test-suite] constructs: invalid operations should not raise errors when n test('[test-suite] constructs: testing priorities', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(2^3^2 == 2^(3^2)); @@ -96,7 +96,7 @@ test('[test-suite] constructs: testing priorities', () => { test('[test-suite] constructs: silly loops', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` repeat until 1; repeat until true; @@ -269,7 +269,7 @@ test('[test-suite] constructs: silly loops', () => { test.skip('[test-suite] constructs: huge loops, upvalue', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- sometimes will be 0, sometimes will not... @@ -343,9 +343,9 @@ test.skip('[test-suite] constructs: huge loops, upvalue', () => { }); -test('[test-suite] constructs: testing some syntax errors (chosen through \'gcov\')', () => { +test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _soft = true diff --git a/test/test-suite/coroutine.test.js b/test/test-suite/coroutine.test.js index c967c639..de92317f 100644 --- a/test/test-suite/coroutine.test.js +++ b/test/test-suite/coroutine.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const ltests = require('./ltests.js'); @@ -55,9 +55,9 @@ const prefix = ` end `; -test('[test-suite] coroutine: is main thread', () => { +test("[test-suite] coroutine: is main thread", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local main, ismain = coroutine.running() @@ -73,9 +73,9 @@ test('[test-suite] coroutine: is main thread', () => { }); -test('[test-suite] coroutine: trivial errors', () => { +test("[test-suite] coroutine: trivial errors", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(coroutine.resume, 0)) @@ -88,9 +88,9 @@ test('[test-suite] coroutine: trivial errors', () => { }); -test('[test-suite] coroutine: tests for multiple yield/resume arguments', () => { +test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function eqtab (t1, t2) @@ -143,9 +143,9 @@ test('[test-suite] coroutine: tests for multiple yield/resume arguments', () => }); -test('[test-suite] coroutine: yields in tail calls', () => { +test("[test-suite] coroutine: yields in tail calls", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo (i) return coroutine.yield(i) end @@ -165,9 +165,9 @@ test('[test-suite] coroutine: yields in tail calls', () => { }); -test('[test-suite] coroutine: recursive', () => { +test("[test-suite] coroutine: recursive", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function pf (n, i) @@ -189,9 +189,9 @@ test('[test-suite] coroutine: recursive', () => { }); -test('[test-suite] coroutine: sieve', () => { +test("[test-suite] coroutine: sieve", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function gen (n) @@ -230,9 +230,9 @@ test('[test-suite] coroutine: sieve', () => { }); -test('[test-suite] coroutine: yielding across JS boundaries', () => { +test("[test-suite] coroutine: yielding across JS boundaries", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (s, i) return coroutine.yield(i) end @@ -270,9 +270,9 @@ test('[test-suite] coroutine: yielding across JS boundaries', () => { }); -test('[test-suite] coroutine: unyieldable JS call', () => { +test("[test-suite] coroutine: unyieldable JS call", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -296,9 +296,9 @@ test('[test-suite] coroutine: unyieldable JS call', () => { }); -test('[test-suite] coroutine: errors in coroutines', () => { +test("[test-suite] coroutine: errors in coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function foo () @@ -329,9 +329,9 @@ test('[test-suite] coroutine: errors in coroutines', () => { }); -test('[test-suite] coroutine: co-routines x for loop', () => { +test("[test-suite] coroutine: co-routines x for loop", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function all (a, n, k) @@ -357,9 +357,9 @@ test('[test-suite] coroutine: co-routines x for loop', () => { }); -test('[test-suite] coroutine: old bug: attempt to resume itself', () => { +test("[test-suite] coroutine: old bug: attempt to resume itself", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function co_func (current_co) @@ -388,9 +388,9 @@ test('[test-suite] coroutine: old bug: attempt to resume itself', () => { }); -test('[test-suite] coroutine: old bug: other old bug when attempting to resume itself', () => { +test("[test-suite] coroutine: old bug: other old bug when attempting to resume itself", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -411,9 +411,9 @@ test('[test-suite] coroutine: old bug: other old bug when attempting to resume i }); -test('[test-suite] coroutine: attempt to resume \'normal\' coroutine', () => { +test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local co1, co2 @@ -435,9 +435,9 @@ test('[test-suite] coroutine: attempt to resume \'normal\' coroutine', () => { }); -test('[test-suite] coroutine: infinite recursion of coroutines', () => { +test("[test-suite] coroutine: infinite recursion of coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = function(a) coroutine.wrap(a)(a) end @@ -451,9 +451,9 @@ test('[test-suite] coroutine: infinite recursion of coroutines', () => { }); -test('[test-suite] coroutine: access to locals of erroneous coroutines', () => { +test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local x = coroutine.create (function () @@ -474,9 +474,9 @@ test('[test-suite] coroutine: access to locals of erroneous coroutines', () => { lua.lua_call(L, 0, 0); }); -test('[test-suite] coroutine: leaving a pending coroutine open', () => { +test("[test-suite] coroutine: leaving a pending coroutine open", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _X = coroutine.wrap(function () @@ -494,9 +494,9 @@ test('[test-suite] coroutine: leaving a pending coroutine open', () => { }); -test('[test-suite] coroutine: stack overflow', () => { +test("[test-suite] coroutine: stack overflow", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- bug (stack overflow) @@ -522,9 +522,9 @@ test('[test-suite] coroutine: stack overflow', () => { }); -test('[test-suite] coroutine: testing yields inside metamethods', () => { +test("[test-suite] coroutine: testing yields inside metamethods", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = new(10) @@ -570,9 +570,9 @@ test('[test-suite] coroutine: testing yields inside metamethods', () => { }); -test('[test-suite] coroutine: tests for comparsion operators', () => { +test("[test-suite] coroutine: tests for comparsion operators", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -622,9 +622,9 @@ test('[test-suite] coroutine: tests for comparsion operators', () => { }); -test('[test-suite] coroutine: getuptable & setuptable', () => { +test("[test-suite] coroutine: getuptable & setuptable", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do local _ENV = _ENV @@ -642,9 +642,9 @@ test('[test-suite] coroutine: getuptable & setuptable', () => { }); -test('[test-suite] coroutine: testing yields inside \'for\' iterators', () => { +test("[test-suite] coroutine: testing yields inside 'for' iterators", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local f = function (s, i) @@ -676,9 +676,9 @@ const jsprefix = ` end `; -test('[test-suite] coroutine: testing yields inside hooks', () => { +test("[test-suite] coroutine: testing yields inside hooks", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local A, B = 0, 0 @@ -708,9 +708,9 @@ test('[test-suite] coroutine: testing yields inside hooks', () => { }); -test('[test-suite] coroutine: testing yields inside line hook', () => { +test("[test-suite] coroutine: testing yields inside line hook", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -739,9 +739,9 @@ test('[test-suite] coroutine: testing yields inside line hook', () => { }); -test('[test-suite] coroutine: testing yields in count hook', () => { +test("[test-suite] coroutine: testing yields in count hook", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -768,9 +768,9 @@ test('[test-suite] coroutine: testing yields in count hook', () => { }); -test('[test-suite] coroutine: testing yields inside line hook', () => { +test("[test-suite] coroutine: testing yields inside line hook", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -806,9 +806,9 @@ test('[test-suite] coroutine: testing yields inside line hook', () => { }); -test('[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook', () => { +test("[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -846,9 +846,9 @@ test('[test-suite] coroutine: testing debug library on a coroutine suspended ins }); -test('[test-suite] coroutine: testing debug library on last function in a suspended coroutine', () => { +test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -870,9 +870,9 @@ test('[test-suite] coroutine: testing debug library on last function in a suspen }); -test('[test-suite] coroutine: reusing a thread', () => { +test("[test-suite] coroutine: reusing a thread", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(T.testC([[ @@ -904,9 +904,9 @@ test('[test-suite] coroutine: reusing a thread', () => { }); -test('[test-suite] coroutine: resuming running coroutine', () => { +test("[test-suite] coroutine: resuming running coroutine", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` C = coroutine.create(function () @@ -940,9 +940,9 @@ test('[test-suite] coroutine: resuming running coroutine', () => { lua.lua_call(L, 0, 0); }); -test('[test-suite] coroutine: using a main thread as a coroutine', () => { +test("[test-suite] coroutine: using a main thread as a coroutine", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local state = T.newstate() @@ -984,9 +984,9 @@ test('[test-suite] coroutine: using a main thread as a coroutine', () => { }); -test('[test-suite] coroutine: tests for coroutine API', () => { +test("[test-suite] coroutine: tests for coroutine API", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function apico (...) @@ -1036,9 +1036,9 @@ test('[test-suite] coroutine: tests for coroutine API', () => { }); -test('[test-suite] coroutine: tests for coroutine API', () => { +test("[test-suite] coroutine: tests for coroutine API", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` f = T.makeCfunc("pushnum 3; pushnum 5; yield 1;") @@ -1057,9 +1057,9 @@ test('[test-suite] coroutine: tests for coroutine API', () => { }); -test('[test-suite] coroutine: testing coroutines with C bodies', () => { +test("[test-suite] coroutine: testing coroutines with C bodies", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function eqtab (t1, t2) @@ -1102,9 +1102,9 @@ test('[test-suite] coroutine: testing coroutines with C bodies', () => { }); -test('[test-suite] coroutine: testing chain of suspendable C calls', () => { +test("[test-suite] coroutine: testing chain of suspendable C calls", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local count = 3 -- number of levels @@ -1145,9 +1145,9 @@ test('[test-suite] coroutine: testing chain of suspendable C calls', () => { }); -test('[test-suite] coroutine: testing yields with continuations', () => { +test("[test-suite] coroutine: testing yields with continuations", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` co = coroutine.wrap(function (...) return @@ -1210,9 +1210,9 @@ test('[test-suite] coroutine: testing yields with continuations', () => { }); -test('[test-suite] coroutine: bug in nCcalls', () => { +test("[test-suite] coroutine: bug in nCcalls", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local co = coroutine.wrap(function () diff --git a/test/test-suite/db.test.js b/test/test-suite/db.test.js index 9fce2154..89ec66da 100644 --- a/test/test-suite/db.test.js +++ b/test/test-suite/db.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` local function dostring(s) return assert(load(s))() end @@ -22,9 +22,9 @@ const prefix = ` end `; -test('[test-suite] db: getinfo, ...line...', () => { +test("[test-suite] db: getinfo, ...line...", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(debug.getinfo, print, "X")) -- invalid option @@ -50,9 +50,9 @@ test('[test-suite] db: getinfo, ...line...', () => { }); -test('[test-suite] db: test file and string names truncation', () => { +test("[test-suite] db: test file and string names truncation", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = "function f () end" @@ -85,9 +85,9 @@ test('[test-suite] db: test file and string names truncation', () => { lua.lua_call(L, 0, 0); }); -test('[test-suite] db: local', () => { +test("[test-suite] db: local", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` repeat @@ -133,9 +133,9 @@ test('[test-suite] db: local', () => { }); -test('[test-suite] db: line hook', () => { +test("[test-suite] db: line hook", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` test([[if @@ -199,9 +199,9 @@ test('[test-suite] db: line hook', () => { }); -test('[test-suite] db: invalid levels in [gs]etlocal', () => { +test("[test-suite] db: invalid levels in [gs]etlocal", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(debug.getlocal, 20, 1)) @@ -214,9 +214,9 @@ test('[test-suite] db: invalid levels in [gs]etlocal', () => { }); -test('[test-suite] db: parameter names', () => { +test("[test-suite] db: parameter names", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo (a,b,...) local d, e end @@ -238,9 +238,9 @@ test('[test-suite] db: parameter names', () => { }); -test('[test-suite] db: vararg', () => { +test("[test-suite] db: vararg", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo (a, ...) @@ -275,9 +275,9 @@ test('[test-suite] db: vararg', () => { }); -test('[test-suite] db: access to vararg in non-vararg function', () => { +test("[test-suite] db: access to vararg in non-vararg function", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo () return debug.getlocal(1, -1) end @@ -290,9 +290,9 @@ test('[test-suite] db: access to vararg in non-vararg function', () => { }); -test('[test-suite] db: test hook presence in debug info', () => { +test("[test-suite] db: test hook presence in debug info", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- test hook presence in debug info @@ -386,9 +386,9 @@ test('[test-suite] db: test hook presence in debug info', () => { }); -test('[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)', () => { +test("[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local n, v = debug.getlocal(0, 1) @@ -420,9 +420,9 @@ test('[test-suite] db: tests for manipulating non-registered locals (C and Lua t }); -test('[test-suite] db: testing access to function arguments', () => { +test("[test-suite] db: testing access to function arguments", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function collectlocals (level) @@ -469,9 +469,9 @@ test('[test-suite] db: testing access to function arguments', () => { }); -test('[test-suite] db: testing access to local variables in return hook (bug in 5.2)', () => { +test("[test-suite] db: testing access to local variables in return hook (bug in 5.2)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function collectlocals (level) @@ -516,9 +516,9 @@ test('[test-suite] db: testing access to local variables in return hook (bug in }); -test('[test-suite] db: testing upvalue access', () => { +test("[test-suite] db: testing upvalue access", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function getupvalues (f) @@ -556,9 +556,9 @@ test('[test-suite] db: testing upvalue access', () => { }); -test('[test-suite] db: testing count hooks', () => { +test("[test-suite] db: testing count hooks", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a=0 @@ -586,9 +586,9 @@ test('[test-suite] db: testing count hooks', () => { }); -test('[test-suite] db: tests for tail calls', () => { +test("[test-suite] db: tests for tail calls", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function f (x) @@ -652,9 +652,9 @@ test('[test-suite] db: tests for tail calls', () => { }); -test('[test-suite] db: testing local function information', () => { +test("[test-suite] db: testing local function information", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` co = load[[ @@ -682,9 +682,9 @@ test('[test-suite] db: testing local function information', () => { }); -test('[test-suite] db: testing traceback', () => { +test("[test-suite] db: testing traceback", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(debug.traceback(print) == print) @@ -707,9 +707,9 @@ test('[test-suite] db: testing traceback', () => { }); -test('[test-suite] db: testing nparams, nups e isvararg', () => { +test("[test-suite] db: testing nparams, nups e isvararg", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = debug.getinfo(print, "u") @@ -732,9 +732,9 @@ test('[test-suite] db: testing nparams, nups e isvararg', () => { }); -test('[test-suite] db: testing debugging of coroutines', () => { +test("[test-suite] db: testing debugging of coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function checktraceback (co, p, level) @@ -805,15 +805,15 @@ test('[test-suite] db: testing debugging of coroutines', () => { `; lualib.luaL_openlibs(L); let b = to_luastring(luaCode); - if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring('@db.lua')) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test('[test-suite] db: check get/setlocal in coroutines', () => { +test("[test-suite] db: check get/setlocal in coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` co = coroutine.create(function (x) @@ -838,9 +838,9 @@ test('[test-suite] db: check get/setlocal in coroutines', () => { }); -test('[test-suite] db: check traceback of suspended (or dead with error) coroutines', () => { +test("[test-suite] db: check traceback of suspended (or dead with error) coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function checktraceback (co, p, level) @@ -873,9 +873,9 @@ test('[test-suite] db: check traceback of suspended (or dead with error) corouti }); -test('[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function', () => { +test("[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function g(x) @@ -904,9 +904,9 @@ test('[test-suite] db: check test acessing line numbers of a coroutine from a re }); -test('[test-suite] db: test tagmethod information', () => { +test("[test-suite] db: test tagmethod information", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = {} @@ -944,9 +944,9 @@ test('[test-suite] db: test tagmethod information', () => { }); -test('[test-suite] db: testing for-iterator name', () => { +test("[test-suite] db: testing for-iterator name", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -964,9 +964,9 @@ test('[test-suite] db: testing for-iterator name', () => { }); -test('[test-suite] db: testing traceback sizes', () => { +test("[test-suite] db: testing traceback sizes", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function countlines (s) @@ -1006,15 +1006,15 @@ test('[test-suite] db: testing traceback sizes', () => { `; lualib.luaL_openlibs(L); let b = to_luastring(luaCode); - if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring('@db.lua')) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test('[test-suite] db: testing debug functions on chunk without debug info', () => { +test("[test-suite] db: testing debug functions on chunk without debug info", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` prog = [[-- program to be loaded without debug information @@ -1067,9 +1067,9 @@ test('[test-suite] db: testing debug functions on chunk without debug info', () }); -test('[test-suite] db: tests for \'source\' in binary dumps', () => { +test("[test-suite] db: tests for 'source' in binary dumps", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do diff --git a/test/test-suite/errors.test.js b/test/test-suite/errors.test.js index 8c514056..83c7a909 100644 --- a/test/test-suite/errors.test.js +++ b/test/test-suite/errors.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` -- avoid problems with 'strict' module (which may generate other error messages) @@ -42,9 +42,9 @@ const prefix = ` end `; -test('[test-suite] errors: test error message with no extra info', () => { +test("[test-suite] errors: test error message with no extra info", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(doit("error('hi', 0)") == 'hi') @@ -56,9 +56,9 @@ test('[test-suite] errors: test error message with no extra info', () => { }); -test('[test-suite] errors: test error message with no info', () => { +test("[test-suite] errors: test error message with no info", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(doit("error()") == nil) @@ -70,9 +70,9 @@ test('[test-suite] errors: test error message with no info', () => { }); -test('[test-suite] errors: test common errors/errors that crashed in the past', () => { +test("[test-suite] errors: test common errors/errors that crashed in the past", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(doit("table.unpack({}, 1, n=2^30)")) @@ -99,9 +99,9 @@ test('[test-suite] errors: test common errors/errors that crashed in the past', }); -test('[test-suite] errors: tests for better error messages', () => { +test("[test-suite] errors: tests for better error messages", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage("a = {} + 1", "arithmetic") @@ -133,9 +133,9 @@ test('[test-suite] errors: tests for better error messages', () => { }); -test('[test-suite] errors: upvalues being indexed do not go to the stack', () => { +test("[test-suite] errors: upvalues being indexed do not go to the stack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage("local a,b,cc; (function () a = cc[1] end)()", "upvalue 'cc'") @@ -155,9 +155,9 @@ test('[test-suite] errors: upvalues being indexed do not go to the stack', () => }); -test('[test-suite] errors: short circuit', () => { +test("[test-suite] errors: short circuit", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage("a=1; local a,bbbb=2,3; a = math.sin(1) and bbbb(3)", @@ -180,9 +180,9 @@ test('[test-suite] errors: short circuit', () => { }); -test('[test-suite] errors: float->integer conversions', () => { +test("[test-suite] errors: float->integer conversions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage("local a = 2.0^100; x = a << 2", "local a") @@ -210,9 +210,9 @@ test('[test-suite] errors: float->integer conversions', () => { }); -test('[test-suite] errors: passing light userdata instead of full userdata', () => { +test("[test-suite] errors: passing light userdata instead of full userdata", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _G.D = debug @@ -230,9 +230,9 @@ test('[test-suite] errors: passing light userdata instead of full userdata', () }); -test('[test-suite] errors: named objects (field \'__name\')', () => { +test("[test-suite] errors: named objects (field '__name')", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -255,9 +255,9 @@ test('[test-suite] errors: named objects (field \'__name\')', () => { }); -test('[test-suite] errors: global functions', () => { +test("[test-suite] errors: global functions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage("(io.write or print){}", "io.write") @@ -270,9 +270,9 @@ test('[test-suite] errors: global functions', () => { }); -test('[test-suite] errors: errors in functions without debug info', () => { +test("[test-suite] errors: errors in functions without debug info", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -296,9 +296,9 @@ test('[test-suite] errors: errors in functions without debug info', () => { }); -test('[test-suite] errors: tests for field accesses after RK limit', () => { +test("[test-suite] errors: tests for field accesses after RK limit", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {} @@ -319,9 +319,9 @@ test('[test-suite] errors: tests for field accesses after RK limit', () => { }); -test('[test-suite] errors: global', () => { +test("[test-suite] errors: global", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage([[aaa=9 @@ -342,9 +342,9 @@ test('[test-suite] errors: global', () => { }); -test('[test-suite] errors: field', () => { +test("[test-suite] errors: field", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage([[ @@ -359,9 +359,9 @@ test('[test-suite] errors: field', () => { }); -test('[test-suite] errors: global insert', () => { +test("[test-suite] errors: global insert", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage([[ @@ -380,9 +380,9 @@ test('[test-suite] errors: global insert', () => { }); -test('[test-suite] errors: sin', () => { +test("[test-suite] errors: sin", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage([[ -- tail call @@ -396,9 +396,9 @@ test('[test-suite] errors: sin', () => { }); -test('[test-suite] errors: concatenate', () => { +test("[test-suite] errors: concatenate", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage([[x = print .. "a"]], "concatenate") @@ -412,9 +412,9 @@ test('[test-suite] errors: concatenate', () => { }); -test('[test-suite] errors: unknown global', () => { +test("[test-suite] errors: unknown global", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage([[ @@ -432,9 +432,9 @@ test('[test-suite] errors: unknown global', () => { }); -test('[test-suite] errors: __index', () => { +test("[test-suite] errors: __index", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {}; setmetatable(a, {__index = string}) @@ -452,9 +452,9 @@ test('[test-suite] errors: __index', () => { }); -test('[test-suite] errors: tests for errors in coroutines', () => { +test("[test-suite] errors: tests for errors in coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function f (n) @@ -476,9 +476,9 @@ test('[test-suite] errors: tests for errors in coroutines', () => { }); -test('[test-suite] errors: testing size of \'source\' info', () => { +test("[test-suite] errors: testing size of 'source' info", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` idsize = 60 - 1 @@ -503,9 +503,9 @@ test('[test-suite] errors: testing size of \'source\' info', () => { }); -test('[test-suite] errors: testing line error', () => { +test("[test-suite] errors: testing line error", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function lineerror (s, l) @@ -568,9 +568,9 @@ test('[test-suite] errors: testing line error', () => { }); -test('[test-suite] errors: several tests that exhaust the Lua stack', () => { +test("[test-suite] errors: several tests that exhaust the Lua stack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` C = 0 @@ -591,9 +591,9 @@ test('[test-suite] errors: several tests that exhaust the Lua stack', () => { }); -test('[test-suite] errors: error lines in stack overflow', () => { +test("[test-suite] errors: error lines in stack overflow", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` C = 0 @@ -622,9 +622,9 @@ test('[test-suite] errors: error lines in stack overflow', () => { }); -test('[test-suite] errors: error in error handling', () => { +test("[test-suite] errors: error in error handling", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local res, msg = xpcall(error, error) @@ -647,9 +647,9 @@ test('[test-suite] errors: error in error handling', () => { }); -test('[test-suite] errors: too many results', () => { +test("[test-suite] errors: too many results", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function loop (x,y,z) return 1 + loop(x, y, z) end @@ -674,9 +674,9 @@ test('[test-suite] errors: too many results', () => { }); -test('[test-suite] errors: non string messages', () => { +test("[test-suite] errors: non string messages", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -714,15 +714,15 @@ test('[test-suite] errors: non string messages', () => { end `; lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring('@errors.lua')) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua")) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test('[test-suite] errors: xpcall with arguments', () => { +test("[test-suite] errors: xpcall with arguments", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a, b, c = xpcall(string.find, error, "alo", "al") @@ -737,9 +737,9 @@ test('[test-suite] errors: xpcall with arguments', () => { }); -test('[test-suite] errors: testing tokens in error messages', () => { +test("[test-suite] errors: testing tokens in error messages", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checksyntax("syntax error", "", "error", 1) @@ -756,9 +756,9 @@ test('[test-suite] errors: testing tokens in error messages', () => { }); -test('[test-suite] errors: test invalid non-printable char in a chunk', () => { +test("[test-suite] errors: test invalid non-printable char in a chunk", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checksyntax("a\\1a = 1", "", "<\\\\1>", 1) @@ -770,9 +770,9 @@ test('[test-suite] errors: test invalid non-printable char in a chunk', () => { }); -test('[test-suite] errors: test 255 as first char in a chunk', () => { +test("[test-suite] errors: test 255 as first char in a chunk", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checksyntax("\\255a = 1", "", "<\\\\255>", 1) @@ -787,9 +787,9 @@ test('[test-suite] errors: test 255 as first char in a chunk', () => { }); -test('[test-suite] errors: lots of errors', () => { +test("[test-suite] errors: lots of errors", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` lim = 1000 @@ -806,9 +806,9 @@ test('[test-suite] errors: lots of errors', () => { }); -test('[test-suite] errors: testing syntax limits', () => { +test("[test-suite] errors: testing syntax limits", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local maxClevel = 200 -- LUAI_MAXCCALLS (in llimits.h) @@ -841,9 +841,9 @@ test('[test-suite] errors: testing syntax limits', () => { }); -test('[test-suite] errors: upvalues limit', () => { +test("[test-suite] errors: upvalues limit", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local lim = 127 @@ -875,9 +875,9 @@ test('[test-suite] errors: upvalues limit', () => { }); -test('[test-suite] errors: local variables limit', () => { +test("[test-suite] errors: local variables limit", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` s = "\\nfunction foo ()\\n local " diff --git a/test/test-suite/events.test.js b/test/test-suite/events.test.js index 085a2461..67faad64 100644 --- a/test/test-suite/events.test.js +++ b/test/test-suite/events.test.js @@ -1,15 +1,15 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const ltests = require('./ltests.js'); -test('[test-suite] events: testing metatable', () => { +test("[test-suite] events: testing metatable", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` X = 20; B = 30 @@ -190,9 +190,9 @@ test('[test-suite] events: testing metatable', () => { }); -test('[test-suite] events: test for rawlen', () => { +test("[test-suite] events: test for rawlen", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = setmetatable({1,2,3}, {__len = function () return 10 end}) @@ -212,9 +212,9 @@ test('[test-suite] events: test for rawlen', () => { }); -test('[test-suite] events: test comparison', () => { +test("[test-suite] events: test comparison", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = {} @@ -261,9 +261,9 @@ test('[test-suite] events: test comparison', () => { }); -test('[test-suite] events: test \'partial order\'', () => { +test("[test-suite] events: test 'partial order'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = {} @@ -332,9 +332,9 @@ test('[test-suite] events: test \'partial order\'', () => { }); -test('[test-suite] events: __eq between userdata', () => { +test("[test-suite] events: __eq between userdata", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` T = require('T') @@ -364,9 +364,9 @@ test('[test-suite] events: __eq between userdata', () => { }); -test('[test-suite] events: concat', () => { +test("[test-suite] events: concat", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` t = {} @@ -403,9 +403,9 @@ test('[test-suite] events: concat', () => { }); -test('[test-suite] events: concat metamethod x numbers (bug in 5.1.1)', () => { +test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` c = {} @@ -425,9 +425,9 @@ test('[test-suite] events: concat metamethod x numbers (bug in 5.1.1)', () => { }); -test('[test-suite] events: test comparison compatibilities', () => { +test("[test-suite] events: test comparison compatibilities", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t1, t2, c, d @@ -451,9 +451,9 @@ test('[test-suite] events: test comparison compatibilities', () => { }); -test('[test-suite] events: test for several levels of callstest for several levels of calls', () => { +test("[test-suite] events: test for several levels of callstest for several levels of calls", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local i @@ -482,9 +482,9 @@ test('[test-suite] events: test for several levels of callstest for several leve }); -test('[test-suite] events: __index on _ENV', () => { +test("[test-suite] events: __index on _ENV", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local _g = _G @@ -502,9 +502,9 @@ test('[test-suite] events: __index on _ENV', () => { }); -test('[test-suite] events: testing metatables for basic types', () => { +test("[test-suite] events: testing metatables for basic types", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` mt = {__index = function (a,b) return a+b end, @@ -544,9 +544,9 @@ test('[test-suite] events: testing metatables for basic types', () => { }); -test('[test-suite] events: loops in delegation', () => { +test("[test-suite] events: loops in delegation", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {}; setmetatable(a, a); a.__index = a; a.__newindex = a @@ -561,9 +561,9 @@ test('[test-suite] events: loops in delegation', () => { }); -test('[test-suite] events: bug in 5.1', () => { +test("[test-suite] events: bug in 5.1", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` T, K, V = nil diff --git a/test/test-suite/goto.test.js b/test/test-suite/goto.test.js index 95b5903b..17e0397d 100644 --- a/test/test-suite/goto.test.js +++ b/test/test-suite/goto.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); -test('[test-suite] goto: error messages', () => { +test("[test-suite] goto: error messages", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function errmsg (code, m) @@ -53,9 +53,9 @@ test('[test-suite] goto: error messages', () => { }); -test('[test-suite] goto', () => { +test("[test-suite] goto", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- simple gotos @@ -120,9 +120,9 @@ test('[test-suite] goto', () => { }); -test('[test-suite] goto: to repeat a label in a different function is OK', () => { +test("[test-suite] goto: to repeat a label in a different function is OK", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo () @@ -148,9 +148,9 @@ test('[test-suite] goto: to repeat a label in a different function is OK', () => }); -test('[test-suite] goto: bug in 5.2 -> 5.3.2', () => { +test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- bug in 5.2 -> 5.3.2 @@ -175,9 +175,9 @@ test('[test-suite] goto: bug in 5.2 -> 5.3.2', () => { }); -test('[test-suite] goto: testing closing of upvalues', () => { +test("[test-suite] goto: testing closing of upvalues", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo () @@ -248,9 +248,9 @@ test('[test-suite] goto: testing closing of upvalues', () => { }); -test('[test-suite] goto: testing if x goto optimizations', () => { +test("[test-suite] goto: testing if x goto optimizations", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function testG (a) diff --git a/test/test-suite/literals.test.js b/test/test-suite/literals.test.js index ecddad5e..3e9307bf 100644 --- a/test/test-suite/literals.test.js +++ b/test/test-suite/literals.test.js @@ -1,17 +1,17 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const dostring = ` local function dostring (x) return assert(load(x), "")() end `; -test('[test-suite] literals: dostring', () => { +test("[test-suite] literals: dostring", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` dostring("x \\v\\f = \\t\\r 'a\\0a' \\v\\f\\f") @@ -25,9 +25,9 @@ test('[test-suite] literals: dostring', () => { // TODO: bell character '\a' in JS is parsed as 'a' -test('[test-suite] literals: escape sequences', () => { +test("[test-suite] literals: escape sequences", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert('\\n\\"\\'\\\\' == [[ @@ -42,9 +42,9 @@ test('[test-suite] literals: escape sequences', () => { }); -test('[test-suite] literals: assume ASCII just for tests', () => { +test("[test-suite] literals: assume ASCII just for tests", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert("\\09912" == 'c12') @@ -62,9 +62,9 @@ test('[test-suite] literals: assume ASCII just for tests', () => { }); -test('[test-suite] literals: hexadecimal escapes', () => { +test("[test-suite] literals: hexadecimal escapes", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert("\\x00\\x05\\x10\\x1f\\x3C\\xfF\\xe8" == "\\0\\5\\16\\31\\60\\255\\232") @@ -97,9 +97,9 @@ assert("abc\\z }); -test('[test-suite] literals: UTF-8 sequences', () => { +test("[test-suite] literals: UTF-8 sequences", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert("\\u{0}\\u{00000000}\\x00\\0" == string.char(0, 0, 0, 0)) @@ -123,9 +123,9 @@ test('[test-suite] literals: UTF-8 sequences', () => { }); -test('[test-suite] literals: Error in escape sequences', () => { +test("[test-suite] literals: Error in escape sequences", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function lexerror (s, err) @@ -177,9 +177,9 @@ test('[test-suite] literals: Error in escape sequences', () => { }); -test('[test-suite] literals: valid characters in variable names', () => { +test("[test-suite] literals: valid characters in variable names", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for i = 0, 255 do @@ -196,9 +196,9 @@ test('[test-suite] literals: valid characters in variable names', () => { }); -test('[test-suite] literals: long variable names', () => { +test("[test-suite] literals: long variable names", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` var1 = string.rep('a', 15000) .. '1' @@ -219,9 +219,9 @@ test('[test-suite] literals: long variable names', () => { }); -test('[test-suite] literals: escapes', () => { +test("[test-suite] literals: escapes", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = `assert("\\n\\t" == [[\n\n\t]]) assert([[\n\n $debug]] == "\\n $debug") @@ -233,9 +233,9 @@ assert([[ [ ]] ~= [[ ] ]])`; }); -test('[test-suite] literals: long strings', () => { +test("[test-suite] literals: long strings", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = `b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789" assert(string.len(b) == 960) @@ -296,9 +296,9 @@ b = nil`; }); -test('[test-suite] literals: testing line ends', () => { +test("[test-suite] literals: testing line ends", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = `prog = [[ a = 1 -- a comment @@ -326,9 +326,9 @@ end`; }); -test('[test-suite] literals: testing comments and strings with long brackets', () => { +test("[test-suite] literals: testing comments and strings with long brackets", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = `a = [==[]=]==] assert(a == "]=") @@ -356,9 +356,9 @@ error error]=]===]`; }); -test('[test-suite] literals: generate all strings of four of these chars', () => { +test("[test-suite] literals: generate all strings of four of these chars", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = `local x = {"=", "[", "]", "\\n"} local len = 4 @@ -381,9 +381,9 @@ end`; }); -test('[test-suite] literals: testing %q x line ends', () => { +test("[test-suite] literals: testing %q x line ends", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local s = "a string with \\r and \\n and \\r\\n and \\n\\r" @@ -397,9 +397,9 @@ test('[test-suite] literals: testing %q x line ends', () => { }); -test('[test-suite] literals: testing errors', () => { +test("[test-suite] literals: testing errors", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not load"a = 'non-ending string") diff --git a/test/test-suite/locals.test.js b/test/test-suite/locals.test.js index 821d0e03..27015194 100644 --- a/test/test-suite/locals.test.js +++ b/test/test-suite/locals.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); test('[test-suite] locals: bug in 5.1', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function f(x) x = nil; return x end @@ -28,7 +28,7 @@ test('[test-suite] locals: bug in 5.1', () => { test('[test-suite] locals: local scope', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -97,7 +97,7 @@ const getenv = ` test('[test-suite] locals: test for global table of loaded chunks', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(getenv(load"a=3") == _G) @@ -116,7 +116,7 @@ test('[test-suite] locals: test for global table of loaded chunks', () => { test('[test-suite] locals: old test for limits for special instructions (now just a generic test)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -147,7 +147,7 @@ test('[test-suite] locals: old test for limits for special instructions (now jus test('[test-suite] locals: testing lexical environments', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(_ENV == _G) diff --git a/test/test-suite/ltests.js b/test/test-suite/ltests.js index 948a7b86..6fc086c9 100644 --- a/test/test-suite/ltests.js +++ b/test/test-suite/ltests.js @@ -1,6 +1,6 @@ -'use strict'; +"use strict"; -const assert = require('assert'); +const assert = require("assert"); const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); @@ -9,13 +9,13 @@ const { luastring_indexOf, to_jsstring, to_luastring -} = require('../../src/fengaricore.js'); +} = require("../../src/fengaricore.js"); const ljstype = require('../../src/ljstype.js'); const lopcodes = require('../../src/lopcodes.js'); const { pushobj2s } = require('../../src/lobject.js'); const sprintf = require('sprintf-js').sprintf; -const delimits = [' ', '\t', '\n', ',', ';'].map(e => e.charCodeAt(0)); +const delimits = [" ", "\t", "\n", ",", ";"].map(e => e.charCodeAt(0)); const skip = function(pc) { for (;;) { @@ -47,7 +47,7 @@ const getnum = function(L, L1, pc) { pc.offset++; } if (!ljstype.lisdigit(pc.script[pc.offset])) - lauxlib.luaL_error(L, to_luastring('number expected (%s)'), pc.script); + lauxlib.luaL_error(L, to_luastring("number expected (%s)"), pc.script); while (ljstype.lisdigit(pc.script[pc.offset])) res = res*10 + pc.script[pc.offset++] - '0'.charCodeAt(0); return sig*res; }; @@ -59,7 +59,7 @@ const getstring = function(L, buff, pc) { let quote = pc.script[pc.offset++]; while (pc.script[pc.offset] !== quote) { if (pc.script[pc.offset] === 0 || pc.offset >= pc.script.length) - lauxlib.luaL_error(L, to_luastring('unfinished string in JS script', true)); + lauxlib.luaL_error(L, to_luastring("unfinished string in JS script", true)); buff[i++] = pc.script[pc.offset++]; } pc.offset++; @@ -74,13 +74,13 @@ const getindex = function(L, L1, pc) { skip(pc); switch (pc.script[pc.offset++]) { case 'R'.charCodeAt(0): return lua.LUA_REGISTRYINDEX; - case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, to_luastring('deprecated index \'G\'', true)); + case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, to_luastring("deprecated index 'G'", true)); case 'U'.charCodeAt(0): return lua.lua_upvalueindex(getnum(L, L1, pc)); default: pc.offset--; return getnum(L, L1, pc); } }; -const codes = ['OK', 'YIELD', 'ERRRUN', 'ERRSYNTAX', 'ERRMEM', 'ERRGCMM', 'ERRERR'].map(e => to_luastring(e)); +const codes = ["OK", "YIELD", "ERRRUN", "ERRSYNTAX", "ERRMEM", "ERRGCMM", "ERRERR"].map(e => to_luastring(e)); const pushcode = function(L, code) { lua.lua_pushstring(L, codes[code]); @@ -89,10 +89,10 @@ const pushcode = function(L, code) { const printstack = function(L) { let n = lua.lua_gettop(L); for (let i = 1; i <= n; i++) { - console.log('${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n'); + console.log("${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n"); lua.lua_pop(L, 1); } - console.log(''); + console.log(""); }; /* @@ -103,47 +103,47 @@ const printstack = function(L) { ** LUA_OPUNM -> _ ** LUA_OPBNOT -> ! */ -const ops = '+-*%^/\\&|~<>_!'.split('').map(e => e.charCodeAt(0)); +const ops = "+-*%^/\\&|~<>_!".split('').map(e => e.charCodeAt(0)); const runJS = function(L, L1, pc) { let buff = new Uint8Array(300); let status = 0; - if (!pc || !pc.script) return lauxlib.luaL_error(L, to_luastring('attempt to runJS null script')); + if (!pc || !pc.script) return lauxlib.luaL_error(L, to_luastring("attempt to runJS null script")); for (;;) { let inst = to_jsstring(getstring(L, buff, pc)); if (inst.length === 0) return 0; switch (inst) { - case 'absindex': { + case "absindex": { lua.lua_pushnumber(L1, lua.lua_absindex(L1, getindex(L, L1, pc))); break; } - case 'append': { + case "append": { let t = getindex(L, L1, pc); let i = lua.lua_rawlen(L1, t); lua.lua_rawseti(L1, t, i + 1); break; } - case 'arith': { + case "arith": { let op; skip(pc); op = ops.indexOf(pc.script[pc.offset++]); lua.lua_arith(L1, op); break; } - case 'call': { + case "call": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); lua.lua_call(L1, narg, nres); break; } - case 'callk': { + case "callk": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); lua.lua_callk(L1, narg, nres, i, Cfunck); break; } - case 'checkstack': { + case "checkstack": { let sz = getnum(L, L1, pc); let msg = getstring(L, buff, pc); if (msg.length === 0) @@ -151,7 +151,7 @@ const runJS = function(L, L1, pc) { lauxlib.luaL_checkstack(L1, sz, msg); break; } - case 'compare': { + case "compare": { let opt = getstring(L, buff, pc); /* EQ, LT, or LE */ let op = (opt[0] === 'E'.charCodeAt(0)) ? lua.LUA_OPEQ @@ -161,150 +161,150 @@ const runJS = function(L, L1, pc) { lua.lua_pushboolean(L1, lua.lua_compare(L1, a, b, op)); break; } - case 'concat': { + case "concat": { lua.lua_concat(L1, getnum(L, L1, pc)); break; } - case 'copy': { + case "copy": { let f = getindex(L, L1, pc); lua.lua_copy(L1, f, getindex(L, L1, pc)); break; } - case 'func2num': { + case "func2num": { let func = lua.lua_tocfunction(L1, getindex(L, L1, pc)); if (func === null) func = 0; else if (func.id) func = func.id; lua.lua_pushnumber(L1, func); break; } - case 'getfield': { + case "getfield": { let t = getindex(L, L1, pc); lua.lua_getfield(L1, t, getstring(L, buff, pc)); break; } - case 'getglobal': { + case "getglobal": { lua.lua_getglobal(L1, getstring(L, buff, pc)); break; } - case 'getmetatable': { + case "getmetatable": { if (lua.lua_getmetatable(L1, getindex(L, L1, pc)) === 0) lua.lua_pushnil(L1); break; } - case 'gettable': { + case "gettable": { lua.lua_gettable(L1, getindex(L, L1, pc)); break; } - case 'gettop': { + case "gettop": { lua.lua_pushinteger(L1, lua.lua_gettop(L1)); break; } - case 'gsub': { + case "gsub": { let a = getnum(L, L1, pc); let b = getnum(L, L1, pc); let c = getnum(L, L1, pc); lauxlib.luaL_gsub(L1, lua.lua_tostring(L1, a), lua.lua_tostring(L1, b), lua.lua_tostring(L1, c)); break; } - case 'insert': { + case "insert": { lua.lua_insert(L1, getnum(L, L1, pc)); break; } - case 'iscfunction': { + case "iscfunction": { lua.lua_pushboolean(L1, lua.lua_iscfunction(L1, getindex(L, L1, pc))); break; } - case 'isfunction': { + case "isfunction": { lua.lua_pushboolean(L1, lua.lua_isfunction(L1, getindex(L, L1, pc))); break; } - case 'isnil': { + case "isnil": { lua.lua_pushboolean(L1, lua.lua_isnil(L1, getindex(L, L1, pc))); break; } - case 'isnull': { + case "isnull": { lua.lua_pushboolean(L1, lua.lua_isnone(L1, getindex(L, L1, pc))); break; } - case 'isnumber': { + case "isnumber": { lua.lua_pushboolean(L1, lua.lua_isnumber(L1, getindex(L, L1, pc))); break; } - case 'isstring': { + case "isstring": { lua.lua_pushboolean(L1, lua.lua_isstring(L1, getindex(L, L1, pc))); break; } - case 'istable': { + case "istable": { lua.lua_pushboolean(L1, lua.lua_istable(L1, getindex(L, L1, pc))); break; } - case 'isudataval': { + case "isudataval": { lua.lua_pushboolean(L1, lua.lua_islightuserdata(L1, getindex(L, L1, pc))); break; } - case 'isuserdata': { + case "isuserdata": { lua.lua_pushboolean(L1, lua.lua_isuserdata(L1, getindex(L, L1, pc))); break; } - case 'len': { + case "len": { lua.lua_len(L1, getindex(L, L1, pc)); break; } - case 'Llen': { + case "Llen": { lua.lua_pushinteger(L1, lauxlib.luaL_len(L1, getindex(L, L1, pc))); break; } - case 'loadfile': { + case "loadfile": { lauxlib.luaL_loadfile(L1, lauxlib.luaL_checkstring(L1, getnum(L, L1, pc))); break; } - case 'loadstring': { + case "loadstring": { let s = lauxlib.luaL_checkstring(L1, getnum(L, L1, pc)); lauxlib.luaL_loadstring(L1, s); break; } - case 'newmetatable': { + case "newmetatable": { lua.lua_pushboolean(L1, lauxlib.luaL_newmetatable(L1, getstring(L, buff, pc))); break; } - case 'newtable': { + case "newtable": { lua.lua_newtable(L1); break; } - case 'newthread': { + case "newthread": { lua.lua_newthread(L1); break; } - case 'newuserdata': { + case "newuserdata": { lua.lua_newuserdata(L1, getnum(L, L1, pc)); break; } - case 'next': { + case "next": { lua.lua_next(L1, -2); break; } - case 'objsize': { + case "objsize": { lua.lua_pushinteger(L1, lua.lua_rawlen(L1, getindex(L, L1, pc))); break; } - case 'pcall': { + case "pcall": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); status = lua.lua_pcall(L1, narg, nres, getnum(L, L1, pc)); break; } - case 'pcallk': { + case "pcallk": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); status = lua.lua_pcallk(L1, narg, nres, 0, i, Cfunck); break; } - case 'pop': { + case "pop": { lua.lua_pop(L1, getnum(L, L1, pc)); break; } - case 'print': { + case "print": { let n = getnum(L, L1, pc); if (n !== 0) { console.log(`${lauxlib.luaL_tojsstring(L1, n, null)}\n`); @@ -313,71 +313,71 @@ const runJS = function(L, L1, pc) { else printstack(L1); break; } - case 'pushbool': { + case "pushbool": { lua.lua_pushboolean(L1, getnum(L, L1, pc)); break; } - case 'pushcclosure': { + case "pushcclosure": { lua.lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); break; } - case 'pushint': { + case "pushint": { lua.lua_pushinteger(L1, getnum(L, L1, pc)); break; } - case 'pushnil': { + case "pushnil": { lua.lua_pushnil(L1); break; } - case 'pushnum': { + case "pushnum": { lua.lua_pushnumber(L1, getnum(L, L1, pc)); break; } - case 'pushstatus': { + case "pushstatus": { pushcode(L1, status); break; } - case 'pushstring': { + case "pushstring": { lua.lua_pushstring(L1, getstring(L, buff, pc)); break; } - case 'pushupvalueindex': { + case "pushupvalueindex": { lua.lua_pushinteger(L1, lua.lua_upvalueindex(getnum(L, L1, pc))); break; } - case 'pushvalue': { + case "pushvalue": { lua.lua_pushvalue(L1, getindex(L, L1, pc)); break; } - case 'rawgeti': { + case "rawgeti": { let t = getindex(L, L1, pc); lua.lua_rawgeti(L1, t, getnum(L, L1, pc)); break; } - case 'rawgetp': { + case "rawgetp": { let t = getindex(L, L1, pc); lua.lua_rawgetp(L1, t, getnum(L, L1, pc)); break; } - case 'rawsetp': { + case "rawsetp": { let t = getindex(L, L1, pc); lua.lua_rawsetp(L1, t, getnum(L, L1, pc)); break; } - case 'remove': { + case "remove": { lua.lua_remove(L1, getnum(L, L1, pc)); break; } - case 'replace': { + case "replace": { lua.lua_replace(L1, getindex(L, L1, pc)); break; } - case 'resume': { + case "resume": { let i = getindex(L, L1, pc); status = lua.lua_resume(lua.lua_tothread(L1, i), L, getnum(L, L1, pc)); break; } - case 'return': { + case "return": { let n = getnum(L, L1, pc); if (L1 != L) { let i; @@ -386,84 +386,84 @@ const runJS = function(L, L1, pc) { } return n; } - case 'rotate': { + case "rotate": { let i = getindex(L, L1, pc); lua.lua_rotate(L1, i, getnum(L, L1, pc)); break; } - case 'setfield': { + case "setfield": { let t = getindex(L, L1, pc); lua.lua_setfield(L1, t, getstring(L, buff, pc)); break; } - case 'setglobal': { + case "setglobal": { lua.lua_setglobal(L1, getstring(L, buff, pc)); break; } - case 'sethook': { + case "sethook": { let mask = getnum(L, L1, pc); let count = getnum(L, L1, pc); sethookaux(L1, mask, count, getstring(L, buff, pc)); break; } - case 'setmetatable': { + case "setmetatable": { lua.lua_setmetatable(L1, getindex(L, L1, pc)); break; } - case 'settable': { + case "settable": { lua.lua_settable(L1, getindex(L, L1, pc)); break; } - case 'settop': { + case "settop": { lua.lua_settop(L1, getnum(L, L1, pc)); break; } - case 'testudata': { + case "testudata": { let i = getindex(L, L1, pc); lua.lua_pushboolean(L1, lauxlib.luaL_testudata(L1, i, getstring(L, buff, pc)) !== null); break; } - case 'error': { + case "error": { lua.lua_error(L1); break; } - case 'throw': { + case "throw": { throw new Error(); } - case 'tobool': { + case "tobool": { lua.lua_pushboolean(L1, lua.lua_toboolean(L1, getindex(L, L1, pc))); break; } - case 'tocfunction': { + case "tocfunction": { lua.lua_pushcfunction(L1, lua.lua_tocfunction(L1, getindex(L, L1, pc))); break; } - case 'tointeger': { + case "tointeger": { lua.lua_pushinteger(L1, lua.lua_tointeger(L1, getindex(L, L1, pc))); break; } - case 'tonumber': { + case "tonumber": { lua.lua_pushnumber(L1, lua.lua_tonumber(L1, getindex(L, L1, pc))); break; } - case 'topointer': { + case "topointer": { let p = lua.lua_topointer(L1, getindex(L, L1, pc)); if (p === null) p = 0; else if (p.id) p = p.id; lua.lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */ break; } - case 'tostring': { + case "tostring": { let s = lua.lua_tostring(L1, getindex(L, L1, pc)); let s1 = lua.lua_pushstring(L1, s); assert(luastring_eq(s, s1)); break; } - case 'type': { + case "type": { lua.lua_pushstring(L1, lauxlib.luaL_typename(L1, getnum(L, L1, pc))); break; } - case 'xmove': { + case "xmove": { let f = getindex(L, L1, pc); let t = getindex(L, L1, pc); let fs = (f === 0) ? L1 : lua.lua_tothread(L1, f); @@ -473,16 +473,16 @@ const runJS = function(L, L1, pc) { lua.lua_xmove(fs, ts, n); break; } - case 'yield': { + case "yield": { return lua.lua_yield(L1, getnum(L, L1, pc)); } - case 'yieldk': { + case "yieldk": { let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); return lua.lua_yieldk(L1, nres, i, Cfunck); } default: - lauxlib.luaL_error(L, to_luastring('unknown instruction %s'), buff); + lauxlib.luaL_error(L, to_luastring("unknown instruction %s"), buff); } } }; @@ -559,36 +559,36 @@ const newstate = function(L) { const getstate = function(L) { let L1 = lua.lua_touserdata(L, 1); - lauxlib.luaL_argcheck(L, L1 !== null, 1, 'state expected'); + lauxlib.luaL_argcheck(L, L1 !== null, 1, "state expected"); return L1; }; -const luaopen_base = require('../../src/lbaselib.js').luaopen_base; -const luaopen_coroutine = require('../../src/lcorolib.js').luaopen_coroutine; -const luaopen_debug = require('../../src/ldblib.js').luaopen_debug; -const luaopen_io = require('../../src/liolib.js').luaopen_io; -const luaopen_os = require('../../src/loslib.js').luaopen_os; -const luaopen_math = require('../../src/lmathlib.js').luaopen_math; -const luaopen_string = require('../../src/lstrlib.js').luaopen_string; -const luaopen_table = require('../../src/ltablib.js').luaopen_table; -const luaopen_package = require('../../src/loadlib.js').luaopen_package; +const luaopen_base = require("../../src/lbaselib.js").luaopen_base; +const luaopen_coroutine = require("../../src/lcorolib.js").luaopen_coroutine; +const luaopen_debug = require("../../src/ldblib.js").luaopen_debug; +const luaopen_io = require("../../src/liolib.js").luaopen_io; +const luaopen_os = require("../../src/loslib.js").luaopen_os; +const luaopen_math = require("../../src/lmathlib.js").luaopen_math; +const luaopen_string = require("../../src/lstrlib.js").luaopen_string; +const luaopen_table = require("../../src/ltablib.js").luaopen_table; +const luaopen_package = require("../../src/loadlib.js").luaopen_package; const loadlib = function(L) { let libs = { - '_G': luaopen_base, - 'coroutine': luaopen_coroutine, - 'debug': luaopen_debug, - 'io': luaopen_io, - 'os': luaopen_os, - 'math': luaopen_math, - 'string': luaopen_string, - 'table': luaopen_table + "_G": luaopen_base, + "coroutine": luaopen_coroutine, + "debug": luaopen_debug, + "io": luaopen_io, + "os": luaopen_os, + "math": luaopen_math, + "string": luaopen_string, + "table": luaopen_table }; let L1 = getstate(L); - lauxlib.luaL_requiref(L1, to_luastring('package', true), luaopen_package, 0); + lauxlib.luaL_requiref(L1, to_luastring("package", true), luaopen_package, 0); assert(lua.lua_type(L1, -1) == lua.LUA_TTABLE); /* 'requiref' should not reload module already loaded... */ - lauxlib.luaL_requiref(L1, to_luastring('package', true), null, 1); /* seg. fault if it reloads */ + lauxlib.luaL_requiref(L1, to_luastring("package", true), null, 1); /* seg. fault if it reloads */ /* ...but should return the same module */ assert(lua.lua_compare(L1, -1, -2, lua.LUA_OPEQ)); lauxlib.luaL_getsubtable(L1, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE); @@ -644,8 +644,8 @@ const newuserdata = function(L) { */ const Chook = function(L, ar) { let scpt; - let events = ['call', 'ret', 'line', 'count', 'tailcall'].map(e => to_luastring(e)); - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); + let events = ["call", "ret", "line", "count", "tailcall"].map(e => to_luastring(e)); + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); lua.lua_pushlightuserdata(L, L); lua.lua_gettable(L, -2); /* get C_HOOK[L] (script saved by sethookaux) */ scpt = lua.lua_tostring(L, -1); /* not very religious (string will be popped) */ @@ -668,7 +668,7 @@ class Aux { const panicback = function(L) { let b = new Aux(); lua.lua_checkstack(L, 1); /* open space for 'Aux' struct */ - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring('_jmpbuf', true)); /* get 'Aux' struct */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* get 'Aux' struct */ b = lua.lua_touserdata(L, -1); lua.lua_pop(L, 1); /* remove 'Aux' struct */ runJS(b.L, L, { script: b.paniccode, offset: 0 }); /* run optional panic code */ @@ -678,7 +678,7 @@ const panicback = function(L) { const checkpanic = function(L) { let b = new Aux(); let code = lauxlib.luaL_checkstring(L, 1); - b.paniccode = lauxlib.luaL_optstring(L, 2, ''); + b.paniccode = lauxlib.luaL_optstring(L, 2, ""); b.L = L; let L1 = lua.lua_newstate(); /* create new state */ if (L1 === null) { /* error? */ @@ -687,10 +687,10 @@ const checkpanic = function(L) { } lua.lua_atpanic(L1, panicback); /* set its panic function */ lua.lua_pushlightuserdata(L1, b); - lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, to_luastring('_jmpbuf', true)); /* store 'Aux' struct */ + lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* store 'Aux' struct */ try { /* set jump buffer */ runJS(L, L1, { script: code, offset: 0 }); /* run code unprotected */ - lua.lua_pushliteral(L, 'no errors'); + lua.lua_pushliteral(L, "no errors"); } catch (e) { /* error handling */ /* move error message to original state */ lua.lua_pushstring(L, lua.lua_tostring(L1, -1)); @@ -707,12 +707,12 @@ const sethookaux = function(L, mask, count, scpt) { lua.lua_sethook(L, null, 0, 0); /* turn off hooks */ return; } - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); /* get C_HOOK table */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* get C_HOOK table */ if (!lua.lua_istable(L, -1)) { /* no hook table? */ lua.lua_pop(L, 1); /* remove previous value */ lua.lua_newtable(L); /* create new C_HOOK table */ lua.lua_pushvalue(L, -1); - lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); /* register it */ + lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* register it */ } lua.lua_pushlightuserdata(L, L); lua.lua_pushstring(L, scpt); @@ -743,9 +743,9 @@ const Cfunc = function(L) { const Cfunck = function(L, status, ctx) { pushcode(L, status); - lua.lua_setglobal(L, to_luastring('status', true)); + lua.lua_setglobal(L, to_luastring("status", true)); lua.lua_pushinteger(L, ctx); - lua.lua_setglobal(L, to_luastring('ctx', true)); + lua.lua_setglobal(L, to_luastring("ctx", true)); return runJS(L, L, { script: lua.lua_tostring(L, ctx), offset: 0 }); }; @@ -758,7 +758,7 @@ const makeCfunc = function(L) { const coresume = function(L) { let status; let co = lua.lua_tothread(L, 1); - lauxlib.luaL_argcheck(L, co, 1, 'coroutine expected'); + lauxlib.luaL_argcheck(L, co, 1, "coroutine expected"); status = lua.lua_resume(co, L, 0); if (status != lua.LUA_OK && status !== lua.LUA_YIELD) { lua.lua_pushboolean(L, 0); @@ -783,7 +783,7 @@ const setnameval = function(L, name, val) { const pushobject = function(L, o){ pushobj2s(L, o); - assert(L.top <= L.ci.top, 'stack overflow'); + assert(L.top <= L.ci.top, "stack overflow"); }; const buildop = function(p, pc) { @@ -791,19 +791,19 @@ const buildop = function(p, pc) { let o = lopcodes.GET_OPCODE(i); let name = lopcodes.OpCodes[o]; let line = p.lineinfo.length !== 0 ? p.lineinfo[pc] : -1; - let result = sprintf('(%4d) %4d - ', line, pc); //`(${line}) ${pc} - `; + let result = sprintf("(%4d) %4d - ", line, pc); //`(${line}) ${pc} - `; switch (lopcodes.getOpMode(o)) { case lopcodes.iABC: - result += sprintf('%-12s%4d %4d %4d', name, lopcodes.GETARG_A(i), lopcodes.GETARG_B(i), lopcodes.GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; + result += sprintf("%-12s%4d %4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_B(i), lopcodes.GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; break; case lopcodes.iABx: - result += sprintf('%-12s%4d %4d', name, lopcodes.GETARG_A(i), lopcodes.GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; + result += sprintf("%-12s%4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; break; case lopcodes.iAsBx: - result += sprintf('%-12s%4d %4d', name, lopcodes.GETARG_A(i), lopcodes.GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; + result += sprintf("%-12s%4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; break; case lopcodes.iAx: - result += sprintf('%-12s%4d', name, lopcodes.GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; + result += sprintf("%-12s%4d", name, lopcodes.GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; break; } @@ -812,11 +812,11 @@ const buildop = function(p, pc) { const listcode = function(L) { lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1), - 1, 'Lua function expected'); + 1, "Lua function expected"); let p = obj_at(L, 1); lua.lua_newtable(L); - setnameval(L, to_luastring('maxstack', true), p.maxstacksize); - setnameval(L, to_luastring('numparams', true), p.numparams); + setnameval(L, to_luastring("maxstack", true), p.maxstacksize); + setnameval(L, to_luastring("numparams", true), p.numparams); for (let pc = 0; pc < p.code.length; pc++) { lua.lua_pushinteger(L, pc+1); lua.lua_pushstring(L, buildop(p, pc)); @@ -828,7 +828,7 @@ const listcode = function(L) { const listk = function(L) { lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1), - 1, 'Lua function expected'); + 1, "Lua function expected"); let p = obj_at(L, 1); lua.lua_createtable(L, p.k.length, 0); for (let i = 0; i < p.k.length; i++) { @@ -839,24 +839,24 @@ const listk = function(L) { }; const tests_funcs = { - 'checkpanic': checkpanic, - 'closestate': closestate, - 'd2s': d2s, - 'doremote': doremote, - 'listcode': listcode, - 'listk': listk, - 'loadlib': loadlib, - 'makeCfunc': makeCfunc, - 'newstate': newstate, - 'newuserdata': newuserdata, - 'pushuserdata': pushuserdata, - 'resume': coresume, - 's2d': s2d, - 'sethook': sethook, - 'testC': testJS, - 'testJS': testJS, - 'udataval': udataval, - 'upvalue': upvalue + "checkpanic": checkpanic, + "closestate": closestate, + "d2s": d2s, + "doremote": doremote, + "listcode": listcode, + "listk": listk, + "loadlib": loadlib, + "makeCfunc": makeCfunc, + "newstate": newstate, + "newuserdata": newuserdata, + "pushuserdata": pushuserdata, + "resume": coresume, + "s2d": s2d, + "sethook": sethook, + "testC": testJS, + "testJS": testJS, + "udataval": udataval, + "upvalue": upvalue }; const luaB_opentests = function(L) { @@ -866,7 +866,7 @@ const luaB_opentests = function(L) { }; const luaopen_tests = function(L) { - lauxlib.luaL_requiref(L, to_luastring('T'), luaB_opentests, 1); + lauxlib.luaL_requiref(L, to_luastring("T"), luaB_opentests, 1); lua.lua_pop(L, 1); /* remove lib */ }; diff --git a/test/test-suite/math.test.js b/test/test-suite/math.test.js index dacc038c..9cf4e21a 100644 --- a/test/test-suite/math.test.js +++ b/test/test-suite/math.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` local minint = math.mininteger @@ -52,9 +52,9 @@ const prefix = ` end `; -test('[test-suite] math: int bits', () => { +test("[test-suite] math: int bits", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -67,9 +67,9 @@ test('[test-suite] math: int bits', () => { }); -test('[test-suite] math: number of bits in the mantissa of a floating-point number', () => { +test("[test-suite] math: number of bits in the mantissa of a floating-point number", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(isNaN(0/0)) @@ -94,9 +94,9 @@ test('[test-suite] math: number of bits in the mantissa of a floating-point numb }); -test('[test-suite] math: basic float notation', () => { +test("[test-suite] math: basic float notation", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(0e12 == 0 and .0 == 0 and 0. == 0 and .2e2 == 20 and 2.E-1 == 0.2) @@ -146,9 +146,9 @@ test('[test-suite] math: basic float notation', () => { }); -test('[test-suite] math: math.huge', () => { +test("[test-suite] math: math.huge", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(math.huge > 10e30) @@ -161,9 +161,9 @@ test('[test-suite] math: math.huge', () => { }); -test('[test-suite] math: integer arithmetic', () => { +test("[test-suite] math: integer arithmetic", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(minint < minint + 1) @@ -179,9 +179,9 @@ test('[test-suite] math: integer arithmetic', () => { }); -test('[test-suite] math: testing floor division and conversions', () => { +test("[test-suite] math: testing floor division and conversions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for _, i in pairs{-16, -15, -3, -2, -1, 0, 1, 2, 3, 15} do @@ -222,9 +222,9 @@ test('[test-suite] math: testing floor division and conversions', () => { }); -test('[test-suite] math: negative exponents', () => { +test("[test-suite] math: negative exponents", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -247,9 +247,9 @@ test('[test-suite] math: negative exponents', () => { }); -test('[test-suite] math: comparison between floats and integers (border cases)', () => { +test("[test-suite] math: comparison between floats and integers (border cases)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` if floatbits < intbits then @@ -275,9 +275,9 @@ test('[test-suite] math: comparison between floats and integers (border cases)', }); -test('[test-suite] math: order between floats and integers', () => { +test("[test-suite] math: order between floats and integers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -312,9 +312,9 @@ test('[test-suite] math: order between floats and integers', () => { }); -test('[test-suite] math: testing order (floats can represent all integers)', () => { +test("[test-suite] math: testing order (floats can represent all integers)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(floatbits >= intbits) @@ -354,9 +354,9 @@ test('[test-suite] math: testing order (floats can represent all integers)', () }); -test('[test-suite] math: NaN order', () => { +test("[test-suite] math: NaN order", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local NaN = 0/0 @@ -375,9 +375,9 @@ test('[test-suite] math: NaN order', () => { }); -test('[test-suite] math: avoiding errors at compile time', () => { +test("[test-suite] math: avoiding errors at compile time", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkcompt("divide by zero", "return 2 // 0") @@ -393,9 +393,9 @@ test('[test-suite] math: avoiding errors at compile time', () => { lua.lua_call(L, 0, 0); }); -test('[test-suite] math: testing overflow errors when converting from float to integer (runtime)', () => { +test("[test-suite] math: testing overflow errors when converting from float to integer (runtime)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function f2i (x) return x | x end @@ -435,9 +435,9 @@ test('[test-suite] math: testing overflow errors when converting from float to i }); -test('[test-suite] math: testing numeric strings', () => { +test("[test-suite] math: testing numeric strings", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert("2" + 1 == 3) @@ -452,9 +452,9 @@ test('[test-suite] math: testing numeric strings', () => { }); -test('[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)', () => { +test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -498,9 +498,9 @@ test('[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)', () }); -test('[test-suite] math: \'tonumber\' with numbers', () => { +test("[test-suite] math: 'tonumber' with numbers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(tonumber(3.4) == 3.4) @@ -515,9 +515,9 @@ test('[test-suite] math: \'tonumber\' with numbers', () => { }); -test('[test-suite] math: \'tonumber\' with strings', () => { +test("[test-suite] math: 'tonumber' with strings", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(tonumber("0") == 0) @@ -565,9 +565,9 @@ test('[test-suite] math: \'tonumber\' with strings', () => { }); -test('[test-suite] math: tests with very long numerals', () => { +test("[test-suite] math: tests with very long numerals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(tonumber("0x"..string.rep("f", 13)..".0") == 2.0^(4*13) - 1) @@ -591,9 +591,9 @@ test('[test-suite] math: tests with very long numerals', () => { }); -test('[test-suite] math: testing \'tonumber\' for invalid formats', () => { +test("[test-suite] math: testing 'tonumber' for invalid formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function f (...) @@ -635,9 +635,9 @@ test('[test-suite] math: testing \'tonumber\' for invalid formats', () => { }); -test('[test-suite] math: testing \'tonumber\' for invalid hexadecimal formats', () => { +test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(tonumber('0x') == nil) @@ -660,9 +660,9 @@ test('[test-suite] math: testing \'tonumber\' for invalid hexadecimal formats', }); -test('[test-suite] math: testing hexadecimal numerals', () => { +test("[test-suite] math: testing hexadecimal numerals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(0x10 == 16 and 0xfff == 2^12 - 1 and 0XFB == 251) @@ -682,9 +682,9 @@ test('[test-suite] math: testing hexadecimal numerals', () => { }); -test('[test-suite] math: floating hexas', () => { +test("[test-suite] math: floating hexas", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(tonumber(' 0x2.5 ') == 0x25/16) @@ -718,9 +718,9 @@ test('[test-suite] math: floating hexas', () => { }); -test('[test-suite] math: testing order operators', () => { +test("[test-suite] math: testing order operators", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not(1<1) and (1<2) and not(2<1)) @@ -740,9 +740,9 @@ test('[test-suite] math: testing order operators', () => { }); -test('[test-suite] math: testing mod operator', () => { +test("[test-suite] math: testing mod operator", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(eqT(-4 % 3, 2)) @@ -769,9 +769,9 @@ test('[test-suite] math: testing mod operator', () => { }); -test('[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly', () => { +test("[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function anan (x) assert(isNaN(x)) end -- assert Not a Number @@ -794,9 +794,9 @@ test('[test-suite] math: non-portable tests because Windows C library cannot com }); -test('[test-suite] math: testing unsigned comparisons', () => { +test("[test-suite] math: testing unsigned comparisons", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(math.ult(3, 4)) @@ -838,9 +838,9 @@ test('[test-suite] math: testing unsigned comparisons', () => { }); -test('[test-suite] math: testing constant limits', () => { +test("[test-suite] math: testing constant limits", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(8388609 + -8388609 == 0) @@ -854,9 +854,9 @@ test('[test-suite] math: testing constant limits', () => { }); -test('[test-suite] math: testing floor & ceil', () => { +test("[test-suite] math: testing floor & ceil", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -909,9 +909,9 @@ test('[test-suite] math: testing floor & ceil', () => { }); -test('[test-suite] math: testing fmod for integers', () => { +test("[test-suite] math: testing fmod for integers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for i = -6, 6 do @@ -941,9 +941,9 @@ test('[test-suite] math: testing fmod for integers', () => { }); -test('[test-suite] math: testing max/min', () => { +test("[test-suite] math: testing max/min", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -969,9 +969,9 @@ test('[test-suite] math: testing max/min', () => { }); -test('[test-suite] math: testing implicit convertions', () => { +test("[test-suite] math: testing implicit convertions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a,b = '10', '20' @@ -985,9 +985,9 @@ test('[test-suite] math: testing implicit convertions', () => { }); -test('[test-suite] math: testing -0 and NaN', () => { +test("[test-suite] math: testing -0 and NaN", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -1031,9 +1031,9 @@ test('[test-suite] math: testing -0 and NaN', () => { }); -test('[test-suite] math: test random for floats', () => { +test("[test-suite] math: test random for floats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` math.randomseed(0) @@ -1062,9 +1062,9 @@ test('[test-suite] math: test random for floats', () => { }); -test('[test-suite] math: test random for small intervals', () => { +test("[test-suite] math: test random for small intervals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -1106,9 +1106,9 @@ test('[test-suite] math: test random for small intervals', () => { }); -test('[test-suite] math: test random for large intervals', () => { +test("[test-suite] math: test random for large intervals", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -1152,9 +1152,9 @@ test('[test-suite] math: test random for large intervals', () => { }); -test('[test-suite] math: test random for empty interval', () => { +test("[test-suite] math: test random for empty interval", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(math.random, minint + 1, minint)) @@ -1168,9 +1168,9 @@ test('[test-suite] math: test random for empty interval', () => { }); -test('[test-suite] math: interval too large', () => { +test("[test-suite] math: interval too large", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(math.random, minint, 0)) diff --git a/test/test-suite/nextvar.test.js b/test/test-suite/nextvar.test.js index 940082b3..1c4f3319 100644 --- a/test/test-suite/nextvar.test.js +++ b/test/test-suite/nextvar.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` local function checkerror (msg, f, ...) @@ -12,9 +12,9 @@ const prefix = ` end `; -test('[test-suite] nextvar: testing size operator', () => { +test("[test-suite] nextvar: testing size operator", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = {} @@ -35,9 +35,9 @@ test('[test-suite] nextvar: testing size operator', () => { }); -test('[test-suite] nextvar: testing ipairs', () => { +test("[test-suite] nextvar: testing ipairs", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local x = 0 @@ -55,9 +55,9 @@ test('[test-suite] nextvar: testing ipairs', () => { }); -test('[test-suite] nextvar: test for \'false\' x ipair', () => { +test("[test-suite] nextvar: test for 'false' x ipair", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` x = false @@ -76,9 +76,9 @@ test('[test-suite] nextvar: test for \'false\' x ipair', () => { }); -test('[test-suite] nextvar: iterator function is always the same', () => { +test("[test-suite] nextvar: iterator function is always the same", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{}) @@ -90,9 +90,9 @@ test('[test-suite] nextvar: iterator function is always the same', () => { }); -test.skip('[test-suite] nextvar: JS tests', () => { +test.skip("[test-suite] nextvar: JS tests", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- testing table sizes @@ -232,9 +232,9 @@ test.skip('[test-suite] nextvar: JS tests', () => { }); -test('[test-suite] nextvar: test size operation on empty tables', () => { +test("[test-suite] nextvar: test size operation on empty tables", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(#{} == 0) @@ -250,9 +250,9 @@ test('[test-suite] nextvar: test size operation on empty tables', () => { }); -test('[test-suite] nextvar: test size operation on empty tables', () => { +test("[test-suite] nextvar: test size operation on empty tables", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(#{} == 0) @@ -268,9 +268,9 @@ test('[test-suite] nextvar: test size operation on empty tables', () => { }); -test('[test-suite] nextvar: next uses always the same iteration function', () => { +test("[test-suite] nextvar: next uses always the same iteration function", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local nofind = {} @@ -317,9 +317,9 @@ test('[test-suite] nextvar: next uses always the same iteration function', () => }); -test('[test-suite] nextvar: invalid key to \'next\'', () => { +test("[test-suite] nextvar: invalid key to 'next'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("invalid key", next, {10,20}, 3) @@ -331,9 +331,9 @@ test('[test-suite] nextvar: invalid key to \'next\'', () => { }); -test('[test-suite] nextvar: both \'pairs\' and \'ipairs\' need an argument', () => { +test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("bad argument", pairs) @@ -346,9 +346,9 @@ test('[test-suite] nextvar: both \'pairs\' and \'ipairs\' need an argument', () }); -test('[test-suite] nextvar: fmod table', () => { +test("[test-suite] nextvar: fmod table", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -373,9 +373,9 @@ test('[test-suite] nextvar: fmod table', () => { }); -test('[test-suite] nextvar: check next', () => { +test("[test-suite] nextvar: check next", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function checknext (a) @@ -398,9 +398,9 @@ test('[test-suite] nextvar: check next', () => { }); -test('[test-suite] nextvar: # operator', () => { +test("[test-suite] nextvar: # operator", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(#{} == 0) @@ -419,9 +419,9 @@ test('[test-suite] nextvar: # operator', () => { }); -test('[test-suite] nextvar: maxn', () => { +test("[test-suite] nextvar: maxn", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` -- 'maxn' is now deprecated, but it is easily defined in Lua @@ -448,9 +448,9 @@ test('[test-suite] nextvar: maxn', () => { }); -test('[test-suite] nextvar: int overflow', () => { +test("[test-suite] nextvar: int overflow", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -464,9 +464,9 @@ test('[test-suite] nextvar: int overflow', () => { }); -test('[test-suite] nextvar: erasing values', () => { +test("[test-suite] nextvar: erasing values", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local t = {[{1}] = 1, [{2}] = 2, [string.rep("x ", 4)] = 3, @@ -549,9 +549,9 @@ test('[test-suite] nextvar: erasing values', () => { }); -test('[test-suite] nextvar: testing table library with metamethods', () => { +test("[test-suite] nextvar: testing table library with metamethods", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -607,9 +607,9 @@ test('[test-suite] nextvar: testing table library with metamethods', () => { }); -test.skip('[test-suite] nextvar: JS tests', () => { +test.skip("[test-suite] nextvar: JS tests", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local tab = {10, 20, 30} @@ -648,9 +648,9 @@ test.skip('[test-suite] nextvar: JS tests', () => { }); -test('[test-suite] nextvar: next', () => { +test("[test-suite] nextvar: next", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -675,9 +675,9 @@ test('[test-suite] nextvar: next', () => { }); -test('[test-suite] nextvar: testing floats in numeric for', () => { +test("[test-suite] nextvar: testing floats in numeric for", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -706,9 +706,9 @@ test('[test-suite] nextvar: testing floats in numeric for', () => { }); -test('[test-suite] nextvar: conversion', () => { +test("[test-suite] nextvar: conversion", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5) @@ -720,9 +720,9 @@ test('[test-suite] nextvar: conversion', () => { }); -test('[test-suite] nextvar: checking types', () => { +test("[test-suite] nextvar: checking types", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -786,9 +786,9 @@ test('[test-suite] nextvar: checking types', () => { }); -test('[test-suite] nextvar: testing generic \'for\'', () => { +test("[test-suite] nextvar: testing generic 'for'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function f (n, p) @@ -815,9 +815,9 @@ test('[test-suite] nextvar: testing generic \'for\'', () => { }); -test('[test-suite] nextvar: testing __pairs and __ipairs metamethod', () => { +test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {} @@ -855,9 +855,9 @@ test('[test-suite] nextvar: testing __pairs and __ipairs metamethod', () => { }); -test('[test-suite] nextvar: testing ipairs with metamethods', () => { +test("[test-suite] nextvar: testing ipairs with metamethods", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = {n=10} diff --git a/test/test-suite/pm.test.js b/test/test-suite/pm.test.js index 062f377a..c2d0de5c 100644 --- a/test/test-suite/pm.test.js +++ b/test/test-suite/pm.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); -test('[test-suite] pm: pattern matching', () => { +test("[test-suite] pm: pattern matching", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function f(s, p) @@ -94,9 +94,9 @@ test('[test-suite] pm: pattern matching', () => { }); -test('[test-suite] pm: tonumber', () => { +test("[test-suite] pm: tonumber", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function f1(s, p) @@ -121,9 +121,9 @@ test('[test-suite] pm: tonumber', () => { }); -test('[test-suite] pm: range', () => { +test("[test-suite] pm: range", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function range (i, j) @@ -162,32 +162,32 @@ test('[test-suite] pm: range', () => { // Can't be represented by JS string, testing from actual lua file -test('[test-suite] pm: classes', () => { +test("[test-suite] pm: classes", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadfile(L, to_luastring('test/test-suite/pm-classes.lua')) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-classes.lua")) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); // Can't be represented by JS string, testing from actual lua file -test('[test-suite] pm: gsub', () => { +test("[test-suite] pm: gsub", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadfile(L, to_luastring('test/test-suite/pm-gsub.lua')) === lua.LUA_ERRSYNTAX) + if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-gsub.lua")) === lua.LUA_ERRSYNTAX) throw new SyntaxError(lua.lua_tojsstring(L, -1)); lua.lua_call(L, 0, 0); }); -test('[test-suite] pm: empty matches', () => { +test("[test-suite] pm: empty matches", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- new (5.3.3) semantics for empty matches @@ -210,9 +210,9 @@ test('[test-suite] pm: empty matches', () => { }); -test('[test-suite] pm: gsub', () => { +test("[test-suite] pm: gsub", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.gsub("um (dois) tres (quatro)", "(%(%w+%))", string.upper) == @@ -252,9 +252,9 @@ test('[test-suite] pm: gsub', () => { }); -test('[test-suite] pm: gsub isbalanced', () => { +test("[test-suite] pm: gsub isbalanced", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function isbalanced (s) @@ -272,9 +272,9 @@ test('[test-suite] pm: gsub isbalanced', () => { }); -test('[test-suite] pm: capture', () => { +test("[test-suite] pm: capture", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function checkerror (msg, f, ...) @@ -309,9 +309,9 @@ test('[test-suite] pm: capture', () => { }); -test('[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)', () => { +test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _soft = true @@ -334,9 +334,9 @@ test('[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)', () => { }); -test('[test-suite] pm: big strings (TODO: _soft)', () => { +test("[test-suite] pm: big strings (TODO: _soft)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` _soft = true -- TODO @@ -359,9 +359,9 @@ test('[test-suite] pm: big strings (TODO: _soft)', () => { }); -test('[test-suite] pm: recursive nest of gsubs', () => { +test("[test-suite] pm: recursive nest of gsubs", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function rev (s) @@ -378,9 +378,9 @@ test('[test-suite] pm: recursive nest of gsubs', () => { }); -test('[test-suite] pm: gsub with tables', () => { +test("[test-suite] pm: gsub with tables", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.gsub("alo alo", ".", {}) == "alo alo") @@ -400,9 +400,9 @@ test('[test-suite] pm: gsub with tables', () => { }); -test('[test-suite] pm: gmatch', () => { +test("[test-suite] pm: gmatch", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = 0 @@ -436,9 +436,9 @@ test('[test-suite] pm: gmatch', () => { }); -test('[test-suite] pm: tests for \'%f\' (\'frontiers\')', () => { +test("[test-suite] pm: tests for '%f' ('frontiers')", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") @@ -474,9 +474,9 @@ test('[test-suite] pm: tests for \'%f\' (\'frontiers\')', () => { }); -test('[test-suite] pm: malformed patterns', () => { +test("[test-suite] pm: malformed patterns", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function malform (p, m) @@ -504,9 +504,9 @@ test('[test-suite] pm: malformed patterns', () => { }); -test('[test-suite] pm: \\0 in patterns', () => { +test("[test-suite] pm: \\0 in patterns", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.match("ab\\0\\1\\2c", "[\\0-\\2]+") == "\\0\\1\\2") @@ -524,9 +524,9 @@ test('[test-suite] pm: \\0 in patterns', () => { }); -test('[test-suite] pm: magic char after \\0', () => { +test("[test-suite] pm: magic char after \\0", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.find("abc\\0\\0","\\0.") == 4) diff --git a/test/test-suite/sort.test.js b/test/test-suite/sort.test.js index 82059067..cc33c0ca 100644 --- a/test/test-suite/sort.test.js +++ b/test/test-suite/sort.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` local unpack = table.unpack @@ -30,9 +30,9 @@ const prefix = ` if _soft then limit = 5000 end `; -test('[test-suite] sort: testing unpack', () => { +test("[test-suite] sort: testing unpack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("wrong number of arguments", table.insert, {}, 2, 3, 4) @@ -67,9 +67,9 @@ test('[test-suite] sort: testing unpack', () => { }); -test('[test-suite] sort: testing unpack', () => { +test("[test-suite] sort: testing unpack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -107,9 +107,9 @@ test('[test-suite] sort: testing unpack', () => { }); -test('[test-suite] sort: testing unpack', () => { +test("[test-suite] sort: testing unpack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- length is not an integer @@ -125,9 +125,9 @@ test('[test-suite] sort: testing unpack', () => { }); -test('[test-suite] sort: testing pack', () => { +test("[test-suite] sort: testing pack", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` a = table.pack() @@ -146,9 +146,9 @@ test('[test-suite] sort: testing pack', () => { }); -test('[test-suite] sort: testing move', () => { +test("[test-suite] sort: testing move", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -229,9 +229,9 @@ test('[test-suite] sort: testing move', () => { }); -test('[test-suite] sort: testing long move', () => { +test("[test-suite] sort: testing long move", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -268,9 +268,9 @@ test('[test-suite] sort: testing long move', () => { }); -test('[test-suite] sort: testing sort, strange lengths', () => { +test("[test-suite] sort: testing sort, strange lengths", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local a = setmetatable({}, {__len = function () return -1 end}) @@ -286,9 +286,9 @@ test('[test-suite] sort: testing sort, strange lengths', () => { }); -test('[test-suite] sort: test checks for invalid order functions', () => { +test("[test-suite] sort: test checks for invalid order functions", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function check (t) @@ -307,9 +307,9 @@ test('[test-suite] sort: test checks for invalid order functions', () => { }); -test('[test-suite] sort: sort alpha', () => { +test("[test-suite] sort: sort alpha", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function check (a, f) @@ -332,9 +332,9 @@ test('[test-suite] sort: sort alpha', () => { }); -test('[test-suite] sort: sort perm', () => { +test("[test-suite] sort: sort perm", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function check (a, f) @@ -377,9 +377,9 @@ test('[test-suite] sort: sort perm', () => { }); -test('[test-suite] sort: Invert-sorting', () => { +test("[test-suite] sort: Invert-sorting", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function check (a, f) @@ -415,9 +415,9 @@ test('[test-suite] sort: Invert-sorting', () => { }); -test('[test-suite] sort: sorting', () => { +test("[test-suite] sort: sorting", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function check (a, f) diff --git a/test/test-suite/strings.test.js b/test/test-suite/strings.test.js index eaf8e3ff..0e37674b 100644 --- a/test/test-suite/strings.test.js +++ b/test/test-suite/strings.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const checkerror = ` local maxi, mini = math.maxinteger, math.mininteger @@ -16,7 +16,7 @@ const checkerror = ` test('[test-suite] strings: string comparisons', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert('alo' < 'alo1') @@ -46,7 +46,7 @@ test('[test-suite] strings: string comparisons', () => { test('[test-suite] strings: string.sub', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert('alo' < 'alo1') @@ -76,7 +76,7 @@ test('[test-suite] strings: string.sub', () => { test('[test-suite] strings: string.find', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.find("123456789", "345") == 3) @@ -102,7 +102,7 @@ test('[test-suite] strings: string.find', () => { test('[test-suite] strings: string.len and #', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.len("") == 0) @@ -122,7 +122,7 @@ test('[test-suite] strings: string.len and #', () => { test('[test-suite] strings: string.byte/string.char', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.byte("a") == 97) @@ -167,7 +167,7 @@ test('[test-suite] strings: string.byte/string.char', () => { test('[test-suite] strings: repetitions with separator', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.rep('teste', 0, 'xuxu') == '') @@ -192,7 +192,7 @@ test('[test-suite] strings: repetitions with separator', () => { test('[test-suite] strings: tostring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(type(tostring(nil)) == 'string') @@ -232,7 +232,7 @@ test('[test-suite] strings: tostring', () => { test('[test-suite] strings: string.format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` x = '"ílo"\\n\\\\' @@ -267,7 +267,7 @@ test('[test-suite] strings: string.format', () => { test('[test-suite] strings: %q', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -296,7 +296,7 @@ test('[test-suite] strings: %q', () => { test('[test-suite] strings: embedded zeros error', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.format("\\0%s\\0", "\\0\\0\\1") == "\\0\\0\\0\\1\\0") @@ -311,7 +311,7 @@ test('[test-suite] strings: embedded zeros error', () => { test('[test-suite] strings: format x tostring', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.format("%s %s", nil, true) == "nil true") @@ -342,7 +342,7 @@ test('[test-suite] strings: format x tostring', () => { test('[test-suite] strings: longest number that can be formatted', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -367,7 +367,7 @@ test('[test-suite] strings: longest number that can be formatted', () => { test('[test-suite] strings: large numbers for format', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do -- assume at least 32 bits @@ -402,9 +402,9 @@ test('[test-suite] strings: large numbers for format', () => { }); -test('[test-suite] strings: \'format %a %A\'', () => { +test("[test-suite] strings: 'format %a %A'", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -447,9 +447,9 @@ test('[test-suite] strings: \'format %a %A\'', () => { }); -test('[test-suite] strings: errors in format', () => { +test("[test-suite] strings: errors in format", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` local function check (fmt, msg) @@ -475,9 +475,9 @@ test('[test-suite] strings: errors in format', () => { }); -test('[test-suite] strings: table.concat', () => { +test("[test-suite] strings: table.concat", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("table expected", table.concat, 3) @@ -515,9 +515,9 @@ test('[test-suite] strings: table.concat', () => { // TODO: os.setlocale NYI -test.skip('[test-suite] strings: locale', () => { +test.skip("[test-suite] strings: locale", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` if not _port then @@ -558,9 +558,9 @@ test.skip('[test-suite] strings: locale', () => { }); -test('[test-suite] strings: bug in Lua 5.3.2: \'gmatch\' iterator does not work across coroutines', () => { +test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do diff --git a/test/test-suite/tpack.test.js b/test/test-suite/tpack.test.js index 25950a7c..3b97d3a5 100644 --- a/test/test-suite/tpack.test.js +++ b/test/test-suite/tpack.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` local pack = string.pack @@ -30,9 +30,9 @@ const prefix = ` local align = packsize("!xXi16") `; -test('[test-suite] tpack: maximum size for integers', () => { +test("[test-suite] tpack: maximum size for integers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and @@ -54,9 +54,9 @@ test('[test-suite] tpack: maximum size for integers', () => { }); -test('[test-suite] tpack: minimum behavior for integer formats', () => { +test("[test-suite] tpack: minimum behavior for integer formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(unpack("B", pack("B", 0xff)) == 0xff) @@ -78,9 +78,9 @@ test('[test-suite] tpack: minimum behavior for integer formats', () => { }); -test('[test-suite] tpack: minimum behavior for integer formats', () => { +test("[test-suite] tpack: minimum behavior for integer formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for i = 1, NB do @@ -105,9 +105,9 @@ test('[test-suite] tpack: minimum behavior for integer formats', () => { }); -test('[test-suite] tpack: minimum behavior for integer formats', () => { +test("[test-suite] tpack: minimum behavior for integer formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -138,9 +138,9 @@ test('[test-suite] tpack: minimum behavior for integer formats', () => { }); -test('[test-suite] tpack: minimum behavior for integer formats', () => { +test("[test-suite] tpack: minimum behavior for integer formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for i = 1, sizeLI do @@ -160,9 +160,9 @@ test('[test-suite] tpack: minimum behavior for integer formats', () => { }); -test('[test-suite] tpack: sign extension', () => { +test("[test-suite] tpack: sign extension", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -181,9 +181,9 @@ test('[test-suite] tpack: sign extension', () => { }); -test('[test-suite] tpack: mixed endianness', () => { +test("[test-suite] tpack: mixed endianness", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -200,9 +200,9 @@ test('[test-suite] tpack: mixed endianness', () => { }); -test('[test-suite] tpack: testing invalid formats', () => { +test("[test-suite] tpack: testing invalid formats", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("out of limits", pack, "i0", 0) @@ -223,9 +223,9 @@ test('[test-suite] tpack: testing invalid formats', () => { }); -test('[test-suite] tpack: overflow in option size (error will be in digit after limit)', () => { +test("[test-suite] tpack: overflow in option size (error will be in digit after limit)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("invalid format", packsize, "c1" .. string.rep("0", 40)) @@ -246,9 +246,9 @@ test('[test-suite] tpack: overflow in option size (error will be in digit after }); -test('[test-suite] tpack: overflow in packing', () => { +test("[test-suite] tpack: overflow in packing", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for i = 1, sizeLI - 1 do @@ -275,9 +275,9 @@ test('[test-suite] tpack: overflow in packing', () => { }); -test('[test-suite] tpack: Lua integer size', () => { +test("[test-suite] tpack: Lua integer size", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(unpack(">j", pack(">j", math.maxinteger)) == math.maxinteger) @@ -297,9 +297,9 @@ test('[test-suite] tpack: Lua integer size', () => { }); -test('[test-suite] tpack: testing pack/unpack of floating-point numbers', () => { +test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do @@ -325,9 +325,9 @@ test('[test-suite] tpack: testing pack/unpack of floating-point numbers', () => }); -test('[test-suite] tpack: testing pack/unpack of strings', () => { +test("[test-suite] tpack: testing pack/unpack of strings", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -379,9 +379,9 @@ test('[test-suite] tpack: testing pack/unpack of strings', () => { }); -test('[test-suite] tpack: testing multiple types and sequence', () => { +test("[test-suite] tpack: testing multiple types and sequence", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -399,9 +399,9 @@ test('[test-suite] tpack: testing multiple types and sequence', () => { }); -test('[test-suite] tpack: testing alignment', () => { +test("[test-suite] tpack: testing alignment", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do @@ -453,9 +453,9 @@ test('[test-suite] tpack: testing alignment', () => { }); -test('[test-suite] tpack: testing initial position', () => { +test("[test-suite] tpack: testing initial position", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` do diff --git a/test/test-suite/utf8.test.js b/test/test-suite/utf8.test.js index dd7116e9..7e809da2 100644 --- a/test/test-suite/utf8.test.js +++ b/test/test-suite/utf8.test.js @@ -1,9 +1,9 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); const prefix = ` local function checkerror (msg, f, ...) @@ -94,9 +94,9 @@ const prefix = ` end `; -test('[test-suite] utf8: offset', () => { +test("[test-suite] utf8: offset", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` assert(utf8.offset("alo", 5) == nil) @@ -109,9 +109,9 @@ test('[test-suite] utf8: offset', () => { }); -test('[test-suite] utf8: error indication in utf8.len', () => { +test("[test-suite] utf8: error indication in utf8.len", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` do @@ -132,9 +132,9 @@ test('[test-suite] utf8: error indication in utf8.len', () => { }); -test('[test-suite] utf8: error in initial position for offset', () => { +test("[test-suite] utf8: error in initial position for offset", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` checkerror("position out of range", utf8.offset, "abc", 1, 5) @@ -152,9 +152,9 @@ test('[test-suite] utf8: error in initial position for offset', () => { }); -test('[test-suite] utf8: codepoints', () => { +test("[test-suite] utf8: codepoints", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` local s = "hello World" @@ -190,9 +190,9 @@ test('[test-suite] utf8: codepoints', () => { }); -test('[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)', () => { +test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` invalid("\\xF4\\x9F\\xBF\\xBF") @@ -204,9 +204,9 @@ test('[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid r }); -test('[test-suite] utf8: overlong sequences', () => { +test("[test-suite] utf8: overlong sequences", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` invalid("\\xC0\\x80") -- zero @@ -221,9 +221,9 @@ test('[test-suite] utf8: overlong sequences', () => { }); -test('[test-suite] utf8: invalid bytes', () => { +test("[test-suite] utf8: invalid bytes", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` invalid("\\x80") -- continuation byte @@ -238,9 +238,9 @@ test('[test-suite] utf8: invalid bytes', () => { }); -test('[test-suite] utf8: empty strings', () => { +test("[test-suite] utf8: empty strings", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` check("", {}) @@ -252,9 +252,9 @@ test('[test-suite] utf8: empty strings', () => { }); -test('[test-suite] utf8: minimum and maximum values for each sequence size', () => { +test("[test-suite] utf8: minimum and maximum values for each sequence size", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` s = "\\0 \\x7F\\z diff --git a/test/test-suite/vararg.test.js b/test/test-suite/vararg.test.js index d4f3eb96..05385411 100644 --- a/test/test-suite/vararg.test.js +++ b/test/test-suite/vararg.test.js @@ -1,13 +1,13 @@ -'use strict'; +"use strict"; const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); -const {to_luastring} = require('../../src/fengaricore.js'); +const {to_luastring} = require("../../src/fengaricore.js"); -test('[test-suite] vararg: testing vararg', () => { +test("[test-suite] vararg: testing vararg", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function f(a, ...) @@ -81,9 +81,9 @@ test('[test-suite] vararg: testing vararg', () => { }); -test('[test-suite] vararg: new-style varargs', () => { +test("[test-suite] vararg: new-style varargs", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function oneless (a, ...) return ... end @@ -114,9 +114,9 @@ test('[test-suite] vararg: new-style varargs', () => { }); -test('[test-suite] vararg: varargs for main chunks', () => { +test("[test-suite] vararg: varargs for main chunks", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` f = load[[ return {...} ]] @@ -152,9 +152,9 @@ test('[test-suite] vararg: varargs for main chunks', () => { }); -test('[test-suite] vararg: bug in 5.2.2', () => { +test("[test-suite] vararg: bug in 5.2.2", () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); let luaCode = ` function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, diff --git a/test/tests.js b/test/tests.js index 5609fce0..631594b1 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,12 +1,12 @@ -'use strict'; +"use strict"; -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const {to_luastring} = require('../src/fengaricore.js'); +const lua = require("../src/lua.js"); +const lauxlib = require("../src/lauxlib.js"); +const {to_luastring} = require("../src/fengaricore.js"); const toByteCode = function(luaCode) { let L = lauxlib.luaL_newstate(); - if (!L) throw Error('failed to create lua state'); + if (!L) throw Error("failed to create lua state"); if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) !== lua.LUA_OK) throw Error(lua.lua_tojsstring(L, -1)); @@ -16,7 +16,7 @@ const toByteCode = function(luaCode) { B.push(...b.slice(0, size)); return 0; }, b, false) !== 0) - throw Error('unable to dump given function'); + throw Error("unable to dump given function"); return Uint8Array.from(b); }; From 68f70f9ba1841709f7506b103dea8c6a77af5f27 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Mon, 1 Jun 2026 15:38:10 +0100 Subject: [PATCH 03/11] Second pass - remove dynamic and odd require and export statements --- src/fengari.js | 18 +---- src/fengaricore.js | 11 +-- src/lauxlib.js | 179 +++++++++++++++++++++---------------------- src/ldblib.js | 2 +- src/linit.js | 25 +++--- src/loadlib.js | 9 +-- src/loslib.js | 6 +- src/lua.js | 186 ++------------------------------------------- src/luaconf.js | 82 ++++++++------------ src/lualib.js | 30 ++++---- 10 files changed, 161 insertions(+), 387 deletions(-) diff --git a/src/fengari.js b/src/fengari.js index 3d1ca73c..3c216753 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -8,23 +8,7 @@ Copyright © 1994–2017 Lua.org, PUC-Rio. "use strict"; -import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; - -export const FENGARI_AUTHORS = FENGARI_AUTHORS; -export const FENGARI_COPYRIGHT = FENGARI_COPYRIGHT; -export const FENGARI_RELEASE = FENGARI_RELEASE; -export const FENGARI_VERSION = FENGARI_VERSION; -export const FENGARI_VERSION_MAJOR = FENGARI_VERSION_MAJOR; -export const FENGARI_VERSION_MINOR = FENGARI_VERSION_MINOR; -export const FENGARI_VERSION_NUM = FENGARI_VERSION_NUM; -export const FENGARI_VERSION_RELEASE = FENGARI_VERSION_RELEASE; - -export const luastring_eq = luastring_eq; -export const luastring_indexOf = luastring_indexOf; -export const luastring_of = luastring_of; -export const to_jsstring = to_jsstring; -export const to_luastring = to_luastring; -export const to_uristring = to_uristring; +export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; import luaconf from './luaconf.js'; import lua from './lua.js'; diff --git a/src/fengaricore.js b/src/fengaricore.js index e56fe399..d52143b5 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,7 +6,7 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ -import { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from "./defs.js"; +export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from "./defs.js"; const FENGARI_VERSION_MAJOR = "0"; const FENGARI_VERSION_MINOR = "1"; @@ -33,12 +33,3 @@ const _FENGARI_VERSION_NUM = FENGARI_VERSION_NUM; export { _FENGARI_VERSION_NUM as FENGARI_VERSION_NUM }; const _FENGARI_VERSION_RELEASE = FENGARI_VERSION_RELEASE; export { _FENGARI_VERSION_RELEASE as FENGARI_VERSION_RELEASE }; -export const is_luastring = is_luastring; -export const luastring_eq = luastring_eq; -export const luastring_from = luastring_from; -export const luastring_indexOf = luastring_indexOf; -export const luastring_of = luastring_of; -export const to_jsstring = to_jsstring; -export const to_luastring = to_luastring; -export const to_uristring = to_uristring; -export const from_userstring = from_userstring; diff --git a/src/lauxlib.js b/src/lauxlib.js index 042b8b23..b92ef8fb 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -1,11 +1,10 @@ -"use strict"; - import { LUAL_BUFFERSIZE } from './luaconf.js'; import { LUA_ERRERR, LUA_MULTRET, LUA_REGISTRYINDEX, LUA_SIGNATURE, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_VERSION_NUM, lua_Debug, lua_absindex, lua_atpanic, lua_call, lua_checkstack, lua_concat, lua_copy, lua_createtable, lua_error, lua_getfield, lua_getinfo, lua_getmetatable, lua_getstack, lua_gettop, lua_insert, lua_isinteger, lua_isnil, lua_isnumber, lua_isstring, lua_istable, lua_len, lua_load, lua_newstate, lua_newtable, lua_next, lua_pcall, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawlen, lua_rawseti, lua_remove, lua_setfield, lua_setglobal, lua_setmetatable, lua_settop, lua_toboolean, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_tostring, lua_touserdata, lua_type, lua_typename, lua_version } from './lua.js'; import { from_userstring, luastring_eq, to_luastring, to_uristring } from "./fengaricore.js"; +import fs from 'fs'; /* extra error code for 'luaL_loadfilex' */ -const LUA_ERRFILE = LUA_ERRERR+1; +const LUA_ERRFILE = LUA_ERRERR + 1; /* key, in the registry, for table of loaded modules */ const LUA_LOADED_TABLE = to_luastring("_LOADED"); @@ -15,7 +14,7 @@ const LUA_PRELOAD_TABLE = to_luastring("_PRELOAD"); const LUA_FILEHANDLE = to_luastring("FILE*"); -const LUAL_NUMSIZES = 4*16 + 8; +const LUAL_NUMSIZES = 4 * 16 + 8; const __name = to_luastring("__name"); const __tostring = to_luastring("__tostring"); @@ -37,7 +36,7 @@ const LEVELS2 = 11; /* size of the second part of the stack */ ** search for 'objidx' in table at index -1. ** return 1 + string at top if find a good name. */ -const findfield = function(L, objidx, level) { +const findfield = function (L, objidx, level) { if (level === 0 || !lua_istable(L, -1)) return 0; /* not found */ @@ -65,7 +64,7 @@ const findfield = function(L, objidx, level) { /* ** Search for a name for a function in all loaded modules */ -const pushglobalfuncname = function(L, ar) { +const pushglobalfuncname = function (L, ar) { let top = lua_gettop(L); lua_getinfo(L, to_luastring("f"), ar); /* push function */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); @@ -87,7 +86,7 @@ const pushglobalfuncname = function(L, ar) { } }; -const pushfuncname = function(L, ar) { +const pushfuncname = function (L, ar) { if (pushglobalfuncname(L, ar)) { /* try first a global name */ lua_pushfstring(L, to_luastring("function '%s'"), lua_tostring(L, -1)); lua_remove(L, -2); /* remove name */ @@ -102,7 +101,7 @@ const pushfuncname = function(L, ar) { lua_pushliteral(L, "?"); }; -const lastlevel = function(L) { +const lastlevel = function (L) { let ar = new lua_Debug(); let li = 1; let le = 1; @@ -110,14 +109,14 @@ const lastlevel = function(L) { while (lua_getstack(L, le, ar)) { li = le; le *= 2; } /* do a binary search */ while (li < le) { - let m = Math.floor((li + le)/2); + let m = Math.floor((li + le) / 2); if (lua_getstack(L, m, ar)) li = m + 1; else le = m; } return le - 1; }; -const luaL_traceback = function(L, L1, msg, level) { +const luaL_traceback = function (L, L1, msg, level) { let ar = new lua_Debug(); let top = lua_gettop(L); let last = lastlevel(L1); @@ -145,12 +144,12 @@ const luaL_traceback = function(L, L1, msg, level) { lua_concat(L, lua_gettop(L) - top); }; -const panic = function(L) { +const panic = function (L) { let msg = "PANIC: unprotected error in call to Lua API (" + lua_tojsstring(L, -1) + ")"; throw new Error(msg); }; -const luaL_argerror = function(L, arg, extramsg) { +const luaL_argerror = function (L, arg, extramsg) { let ar = new lua_Debug(); if (!lua_getstack(L, 0, ar)) /* no stack frame? */ @@ -170,7 +169,7 @@ const luaL_argerror = function(L, arg, extramsg) { return luaL_error(L, to_luastring("bad argument #%d to '%s' (%s)"), arg, ar.name, extramsg); }; -const typeerror = function(L, arg, tname) { +const typeerror = function (L, arg, tname) { let typearg; if (luaL_getmetafield(L, arg, __name) === LUA_TSTRING) typearg = lua_tostring(L, -1); @@ -183,7 +182,7 @@ const typeerror = function(L, arg, tname) { return luaL_argerror(L, arg, msg); }; -const luaL_where = function(L, level) { +const luaL_where = function (L, level) { let ar = new lua_Debug(); if (lua_getstack(L, level, ar)) { lua_getinfo(L, to_luastring("Sl", true), ar); @@ -195,7 +194,7 @@ const luaL_where = function(L, level) { lua_pushstring(L, to_luastring("")); }; -const luaL_error = function(L, fmt, ...argp) { +const luaL_error = function (L, fmt, ...argp) { luaL_where(L, 1); lua_pushvfstring(L, fmt, argp); lua_concat(L, 2); @@ -203,7 +202,7 @@ const luaL_error = function(L, fmt, ...argp) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_fileresult = function(L, stat, fname, e) { +const luaL_fileresult = function (L, stat, fname, e) { if (stat) { lua_pushboolean(L, 1); return 1; @@ -227,7 +226,7 @@ const luaL_fileresult = function(L, stat, fname, e) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_execresult = function(L, e) { +const luaL_execresult = function (L, e) { let what, stat; if (e === null) { lua_pushboolean(L, 1); @@ -250,11 +249,11 @@ const luaL_execresult = function(L, e) { return 3; }; -const luaL_getmetatable = function(L, n) { +const luaL_getmetatable = function (L, n) { return lua_getfield(L, LUA_REGISTRYINDEX, n); }; -const luaL_newmetatable = function(L, tname) { +const luaL_newmetatable = function (L, tname) { if (luaL_getmetatable(L, tname) !== LUA_TNIL) /* name already in use? */ return 0; /* leave previous value on top, but return 0 */ lua_pop(L, 1); @@ -267,12 +266,12 @@ const luaL_newmetatable = function(L, tname) { }; -const luaL_setmetatable = function(L, tname) { +const luaL_setmetatable = function (L, tname) { luaL_getmetatable(L, tname); lua_setmetatable(L, -2); }; -const luaL_testudata = function(L, ud, tname) { +const luaL_testudata = function (L, ud, tname) { let p = lua_touserdata(L, ud); if (p !== null) { /* value is a userdata? */ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ @@ -286,13 +285,13 @@ const luaL_testudata = function(L, ud, tname) { return null; /* value is not a userdata with a metatable */ }; -const luaL_checkudata = function(L, ud, tname) { +const luaL_checkudata = function (L, ud, tname) { let p = luaL_testudata(L, ud, tname); if (p === null) typeerror(L, ud, tname); return p; }; -const luaL_checkoption = function(L, arg, def, lst) { +const luaL_checkoption = function (L, arg, def, lst) { let name = def !== null ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); for (let i = 0; lst[i]; i++) if (luastring_eq(lst[i], name)) @@ -300,36 +299,36 @@ const luaL_checkoption = function(L, arg, def, lst) { return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring("invalid option '%s'"), name)); }; -const tag_error = function(L, arg, tag) { +const tag_error = function (L, arg, tag) { typeerror(L, arg, lua_typename(L, tag)); }; -const luaL_newstate = function() { +const luaL_newstate = function () { let L = lua_newstate(); if (L) lua_atpanic(L, panic); return L; }; -const luaL_typename = function(L, i) { +const luaL_typename = function (L, i) { return lua_typename(L, lua_type(L, i)); }; -const luaL_argcheck = function(L, cond, arg, extramsg) { +const luaL_argcheck = function (L, cond, arg, extramsg) { if (!cond) luaL_argerror(L, arg, extramsg); }; -const luaL_checkany = function(L, arg) { +const luaL_checkany = function (L, arg) { if (lua_type(L, arg) === LUA_TNONE) luaL_argerror(L, arg, to_luastring("value expected", true)); }; -const luaL_checktype = function(L, arg, t) { +const luaL_checktype = function (L, arg, t) { if (lua_type(L, arg) !== t) tag_error(L, arg, t); }; -const luaL_checklstring = function(L, arg) { +const luaL_checklstring = function (L, arg) { let s = lua_tolstring(L, arg); if (s === null || s === undefined) tag_error(L, arg, LUA_TSTRING); return s; @@ -337,7 +336,7 @@ const luaL_checklstring = function(L, arg) { const luaL_checkstring = luaL_checklstring; -const luaL_optlstring = function(L, arg, def) { +const luaL_optlstring = function (L, arg, def) { if (lua_type(L, arg) <= 0) { return def === null ? null : from_userstring(def); } else return luaL_checklstring(L, arg); @@ -345,36 +344,36 @@ const luaL_optlstring = function(L, arg, def) { const luaL_optstring = luaL_optlstring; -const interror = function(L, arg) { +const interror = function (L, arg) { if (lua_isnumber(L, arg)) luaL_argerror(L, arg, to_luastring("number has no integer representation", true)); else tag_error(L, arg, LUA_TNUMBER); }; -const luaL_checknumber = function(L, arg) { +const luaL_checknumber = function (L, arg) { let d = lua_tonumberx(L, arg); if (d === false) tag_error(L, arg, LUA_TNUMBER); return d; }; -const luaL_optnumber = function(L, arg, def) { +const luaL_optnumber = function (L, arg, def) { return luaL_opt(L, luaL_checknumber, arg, def); }; -const luaL_checkinteger = function(L, arg) { +const luaL_checkinteger = function (L, arg) { let d = lua_tointegerx(L, arg); if (d === false) interror(L, arg); return d; }; -const luaL_optinteger = function(L, arg, def) { +const luaL_optinteger = function (L, arg, def) { return luaL_opt(L, luaL_checkinteger, arg, def); }; -const luaL_prepbuffsize = function(B, sz) { +const luaL_prepbuffsize = function (B, sz) { let newend = B.n + sz; if (B.b.length < newend) { let newsize = Math.max(B.b.length * 2, newend); /* double buffer size */ @@ -385,21 +384,21 @@ const luaL_prepbuffsize = function(B, sz) { return B.b.subarray(B.n, newend); }; -const luaL_buffinit = function(L, B) { +const luaL_buffinit = function (L, B) { B.L = L; B.b = empty; }; -const luaL_buffinitsize = function(L, B, sz) { +const luaL_buffinitsize = function (L, B, sz) { luaL_buffinit(L, B); return luaL_prepbuffsize(B, sz); }; -const luaL_prepbuffer = function(B) { +const luaL_prepbuffer = function (B) { return luaL_prepbuffsize(B, LUAL_BUFFERSIZE); }; -const luaL_addlstring = function(B, s, l) { +const luaL_addlstring = function (B, s, l) { if (l > 0) { s = from_userstring(s); let b = luaL_prepbuffsize(B, l); @@ -408,66 +407,66 @@ const luaL_addlstring = function(B, s, l) { } }; -const luaL_addstring = function(B, s) { +const luaL_addstring = function (B, s) { s = from_userstring(s); luaL_addlstring(B, s, s.length); }; -const luaL_pushresult = function(B) { +const luaL_pushresult = function (B) { lua_pushlstring(B.L, B.b, B.n); /* delete old buffer */ B.n = 0; B.b = empty; }; -const luaL_addchar = function(B, c) { +const luaL_addchar = function (B, c) { luaL_prepbuffsize(B, 1); B.b[B.n++] = c; }; -const luaL_addsize = function(B, s) { +const luaL_addsize = function (B, s) { B.n += s; }; -const luaL_pushresultsize = function(B, sz) { +const luaL_pushresultsize = function (B, sz) { luaL_addsize(B, sz); luaL_pushresult(B); }; -const luaL_addvalue = function(B) { +const luaL_addvalue = function (B) { let L = B.L; let s = lua_tostring(L, -1); luaL_addlstring(B, s, s.length); lua_pop(L, 1); /* remove value */ }; -const luaL_opt = function(L, f, n, d) { +const luaL_opt = function (L, f, n, d) { return lua_type(L, n) <= 0 ? d : f(L, n); }; -const getS = function(L, ud) { +const getS = function (L, ud) { let s = ud.string; ud.string = null; return s; }; -const luaL_loadbufferx = function(L, buff, size, name, mode) { - return lua_load(L, getS, {string: buff}, name, mode); +const luaL_loadbufferx = function (L, buff, size, name, mode) { + return lua_load(L, getS, { string: buff }, name, mode); }; -const luaL_loadbuffer = function(L, s, sz, n) { +const luaL_loadbuffer = function (L, s, sz, n) { return luaL_loadbufferx(L, s, sz, n, null); }; -const luaL_loadstring = function(L, s) { +const luaL_loadstring = function (L, s) { return luaL_loadbuffer(L, s, s.length, s); }; -const luaL_dostring = function(L, s) { +const luaL_dostring = function (L, s) { return (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)); }; -const luaL_getmetafield = function(L, obj, event) { +const luaL_getmetafield = function (L, obj, event) { if (!lua_getmetatable(L, obj)) /* no metatable? */ return LUA_TNIL; else { @@ -481,7 +480,7 @@ const luaL_getmetafield = function(L, obj, event) { } }; -const luaL_callmeta = function(L, obj, event) { +const luaL_callmeta = function (L, obj, event) { obj = lua_absindex(L, obj); if (luaL_getmetafield(L, obj, event) === LUA_TNIL) return false; @@ -492,7 +491,7 @@ const luaL_callmeta = function(L, obj, event) { return true; }; -const luaL_len = function(L, idx) { +const luaL_len = function (L, idx) { lua_len(L, idx); let l = lua_tointegerx(L, -1); if (l === false) @@ -503,13 +502,13 @@ const luaL_len = function(L, idx) { const p_I = to_luastring("%I"); const p_f = to_luastring("%f"); -const luaL_tolstring = function(L, idx) { +const luaL_tolstring = function (L, idx) { if (luaL_callmeta(L, idx, __tostring)) { if (!lua_isstring(L, -1)) luaL_error(L, to_luastring("'__tostring' must return a string")); } else { let t = lua_type(L, idx); - switch(t) { + switch (t) { case LUA_TNUMBER: { if (lua_isinteger(L, idx)) lua_pushfstring(L, p_I, lua_tointeger(L, idx)); @@ -546,7 +545,7 @@ const luaL_tolstring = function(L, idx) { ** if 'glb' is true, also registers the result in the global table. ** Leaves resulting module on the top. */ -const luaL_requiref = function(L, modname, openf, glb) { +const luaL_requiref = function (L, modname, openf, glb) { luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); lua_getfield(L, -1, modname); /* LOADED[modname] */ if (!lua_toboolean(L, -1)) { /* package not already loaded? */ @@ -564,21 +563,21 @@ const luaL_requiref = function(L, modname, openf, glb) { } }; -const find_subarray = function(arr, subarr, from_index) { +const find_subarray = function (arr, subarr, from_index) { var i = from_index >>> 0, sl = subarr.length, l = arr.length + 1 - sl; loop: for (; i < l; i++) { for (let j = 0; j < sl; j++) - if (arr[i+j] !== subarr[j]) + if (arr[i + j] !== subarr[j]) continue loop; return i; } return -1; }; -const luaL_gsub = function(L, s, p, r) { +const luaL_gsub = function (L, s, p, r) { let wild; let b = new luaL_Buffer(); luaL_buffinit(L, b); @@ -596,7 +595,7 @@ const luaL_gsub = function(L, s, p, r) { ** ensure that stack[idx][fname] has a table and push that table ** into the stack */ -const luaL_getsubtable = function(L, idx, fname) { +const luaL_getsubtable = function (L, idx, fname) { if (lua_getfield(L, idx, fname) === LUA_TTABLE) return true; /* table already there */ else { @@ -614,7 +613,7 @@ const luaL_getsubtable = function(L, idx, fname) { ** function gets the 'nup' elements at the top as upvalues. ** Returns with only the table at the stack. */ -const luaL_setfuncs = function(L, l, nup) { +const luaL_setfuncs = function (L, l, nup) { luaL_checkstack(L, nup, to_luastring("too many upvalues", true)); for (let lib in l) { /* fill the table with given functions */ for (let i = 0; i < nup; i++) /* copy upvalues to the top */ @@ -632,7 +631,7 @@ const luaL_setfuncs = function(L, l, nup) { ** this extra space, Lua will generate the same 'stack overflow' error, ** but without 'msg'.) */ -const luaL_checkstack = function(L, space, msg) { +const luaL_checkstack = function (L, space, msg) { if (!lua_checkstack(L, space)) { if (msg) luaL_error(L, to_luastring("stack overflow (%s)"), msg); @@ -641,20 +640,20 @@ const luaL_checkstack = function(L, space, msg) { } }; -const luaL_newlibtable = function(L) { +const luaL_newlibtable = function (L) { lua_createtable(L); }; -const luaL_newlib = function(L, l) { +const luaL_newlib = function (L, l) { lua_createtable(L); luaL_setfuncs(L, l, 0); }; /* predefined references */ -const LUA_NOREF = -2; +const LUA_NOREF = -2; const LUA_REFNIL = -1; -const luaL_ref = function(L, t) { +const luaL_ref = function (L, t) { let ref; if (lua_isnil(L, -1)) { lua_pop(L, 1); /* remove from stack */ @@ -675,7 +674,7 @@ const luaL_ref = function(L, t) { }; -const luaL_unref = function(L, t, ref) { +const luaL_unref = function (L, t, ref) { if (ref >= 0) { t = lua_absindex(L, t); lua_rawgeti(L, t, 0); @@ -686,7 +685,7 @@ const luaL_unref = function(L, t, ref) { }; -const errfile = function(L, what, fnameindex, error) { +const errfile = function (L, what, fnameindex, error) { let serr = error.message; let filename = lua_tostring(L, fnameindex).subarray(1); lua_pushfstring(L, to_luastring("cannot %s %s: %s"), to_luastring(what), filename, to_luastring(serr)); @@ -697,7 +696,7 @@ const errfile = function(L, what, fnameindex, error) { let getc; const utf8_bom = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ -const skipBOM = function(lf) { +const skipBOM = function (lf) { lf.n = 0; let c; let p = 0; @@ -718,7 +717,7 @@ const skipBOM = function(lf) { ** first "valid" character of the file (after the optional BOM and ** a first-line comment). */ -const skipcomment = function(lf) { +const skipcomment = function (lf) { let c = skipBOM(lf); if (c === 35 /* '#'.charCodeAt(0) */) { /* first line is a comment (Unix exec. file)? */ do { /* skip first line */ @@ -750,7 +749,7 @@ if (typeof process === "undefined") { } } - const getF = function(L, ud) { + const getF = function (L, ud) { let lf = ud; if (lf.f !== null && lf.n > 0) { /* are there pre-read characters to be read? */ @@ -765,11 +764,11 @@ if (typeof process === "undefined") { return f; }; - getc = function(lf) { + getc = function (lf) { return lf.pos < lf.f.length ? lf.f[lf.pos++] : null; }; - luaL_loadfilex = function(L, filename, mode) { + luaL_loadfilex = function (L, filename, mode) { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { @@ -817,8 +816,6 @@ if (typeof process === "undefined") { return status; }; } else { - const fs = require('fs'); - class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -829,7 +826,7 @@ if (typeof process === "undefined") { } } - const getF = function(L, ud) { + const getF = function (L, ud) { let lf = ud; let bytes = 0; if (lf.n > 0) { /* are there pre-read characters to be read? */ @@ -838,7 +835,7 @@ if (typeof process === "undefined") { } else { /* read a block from file */ try { bytes = fs.readSync(lf.f, lf.buff, 0, lf.buff.length, lf.pos); /* read block */ - } catch(e) { + } catch (e) { lf.err = e; bytes = 0; } @@ -849,12 +846,12 @@ if (typeof process === "undefined") { else return null; }; - getc = function(lf) { + getc = function (lf) { let b = Buffer.alloc(1); let bytes; try { bytes = fs.readSync(lf.f, b, 0, 1, lf.pos); - } catch(e) { + } catch (e) { lf.err = e; return null; } @@ -862,7 +859,7 @@ if (typeof process === "undefined") { return bytes > 0 ? b.readUInt8() : null; }; - luaL_loadfilex = function(L, filename, mode) { + luaL_loadfilex = function (L, filename, mode) { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { @@ -887,7 +884,7 @@ if (typeof process === "undefined") { lf.buff[lf.n++] = com.c; /* 'c' is the first character of the stream */ let status = lua_load(L, getF, lf, lua_tostring(L, -1), mode); let readstatus = lf.err; - if (filename) try { fs.closeSync(lf.f); } catch (e) {} /* close file (even in case of errors) */ + if (filename) try { fs.closeSync(lf.f); } catch (e) { } /* close file (even in case of errors) */ if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ return errfile(L, "read", fnameindex, readstatus); @@ -897,16 +894,16 @@ if (typeof process === "undefined") { }; } -const luaL_loadfile = function(L, filename) { +const luaL_loadfile = function (L, filename) { return luaL_loadfilex(L, filename, null); }; -const luaL_dofile = function(L, filename) { +const luaL_dofile = function (L, filename) { return (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0)); }; -const lua_writestringerror = function() { - for (let i=0; i ' }); diff --git a/src/linit.js b/src/linit.js index df50d303..46fae546 100644 --- a/src/linit.js +++ b/src/linit.js @@ -1,6 +1,17 @@ import { lua_pop } from './lua.js'; import { luaL_requiref } from './lauxlib.js'; import { to_luastring } from "./fengaricore.js"; +import { luaopen_fengari } from './fengarilib.js'; +import { LUA_LOADLIBNAME, LUA_COLIBNAME, LUA_TABLIBNAME, LUA_OSLIBNAME, LUA_STRLIBNAME, LUA_MATHLIBNAME, LUA_UTF8LIBNAME, LUA_DBLIBNAME, LUA_IOLIBNAME, LUA_FENGARILIBNAME, luaopen_io } from './lualib.js'; +import { luaopen_base } from './lbaselib.js'; +import { luaopen_coroutine } from './lcorolib.js'; +import { luaopen_debug } from './ldblib.js'; +import { luaopen_math } from './lmathlib.js'; +import { luaopen_package } from './loadlib.js'; +import { luaopen_os } from './loslib.js'; +import { luaopen_string } from './lstrlib.js'; +import { luaopen_table } from './ltablib.js'; +import { luaopen_utf8 } from './lutf8lib.js'; const loadedlibs = {}; @@ -15,17 +26,6 @@ const luaL_openlibs = function(L) { const _luaL_openlibs = luaL_openlibs; export { _luaL_openlibs as luaL_openlibs }; -import { LUA_LOADLIBNAME, LUA_COLIBNAME, LUA_TABLIBNAME, LUA_OSLIBNAME, LUA_STRLIBNAME, LUA_MATHLIBNAME, LUA_UTF8LIBNAME, LUA_DBLIBNAME, LUA_IOLIBNAME, LUA_FENGARILIBNAME } from './lualib.js'; -import { luaopen_base } from './lbaselib.js'; -import { luaopen_coroutine } from './lcorolib.js'; -import { luaopen_debug } from './ldblib.js'; -import { luaopen_math } from './lmathlib.js'; -import { luaopen_package } from './loadlib.js'; -import { luaopen_os } from './loslib.js'; -import { luaopen_string } from './lstrlib.js'; -import { luaopen_table } from './ltablib.js'; -import { luaopen_utf8 } from './lutf8lib.js'; - loadedlibs["_G"] = luaopen_base, loadedlibs[LUA_LOADLIBNAME] = luaopen_package; loadedlibs[LUA_COLIBNAME] = luaopen_coroutine; @@ -36,8 +36,7 @@ loadedlibs[LUA_MATHLIBNAME] = luaopen_math; loadedlibs[LUA_UTF8LIBNAME] = luaopen_utf8; loadedlibs[LUA_DBLIBNAME] = luaopen_debug; if (typeof process !== "undefined") - loadedlibs[LUA_IOLIBNAME] = require('./liolib.js').luaopen_io; + loadedlibs[LUA_IOLIBNAME] = luaopen_io; /* Extension: fengari library */ -import { luaopen_fengari } from './fengarilib.js'; loadedlibs[LUA_FENGARILIBNAME] = luaopen_fengari; diff --git a/src/loadlib.js b/src/loadlib.js index a69d73d2..a3505e79 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -4,6 +4,8 @@ import { LUA_LOADED_TABLE, LUA_PRELOAD_TABLE, luaL_Buffer, luaL_addvalue, luaL_b import { LUA_VERSUFFIX } from './lualib.js'; import { luastring_indexOf, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; import fengari from './fengari.js'; +import pathlib from 'path'; +import fs from 'fs'; const global_env = (function () { if (typeof process !== "undefined") { @@ -87,13 +89,12 @@ if (typeof process === "undefined") { } }; } else { - const pathlib = require('path'); - lsys_load = function (L, path, seeglb) { + lsys_load = async function (L, path, seeglb) { path = to_jsstring(path); /* relative paths should be relative to cwd, not this js file */ path = pathlib.resolve(process.cwd(), path); try { - return require(path); + return await import(path); // TODO: use dynamic import - require is not supported in ESM modules } catch (e) { lua_pushstring(L, to_luastring(e.message)); return null; @@ -129,8 +130,6 @@ const noenv = function (L) { let readable; if (typeof process !== "undefined") { // Only with Node - const fs = require('fs'); - readable = function (filename) { try { let fd = fs.openSync(filename, 'r'); diff --git a/src/loslib.js b/src/loslib.js index b318de51..62c2e187 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -1,5 +1,8 @@ "use strict"; +import fs from 'fs'; +import tmp from 'tmp'; +import child_process from 'child_process'; import { LUA_TNIL, LUA_TTABLE, lua_close, lua_createtable, lua_getfield, lua_isboolean, lua_isnoneornil, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushstring, lua_setfield, lua_settop, lua_toboolean, lua_tointegerx } from './lua.js'; import { luaL_Buffer, luaL_addchar, luaL_addstring, luaL_argerror, luaL_buffinit, luaL_checkinteger, luaL_checkoption, luaL_checkstring, luaL_checktype, luaL_error, luaL_execresult, luaL_fileresult, luaL_newlib, luaL_optinteger, luaL_optlstring, luaL_optstring, luaL_pushresult } from './lauxlib.js'; import { luastring_eq, to_jsstring, to_luastring } from "./fengaricore.js"; @@ -441,9 +444,6 @@ if (typeof process === "undefined") { }; } else { /* Only with Node */ - const fs = require('fs'); - const tmp = require('tmp'); - const child_process = require('child_process'); syslib.exit = function(L) { let status; diff --git a/src/lua.js b/src/lua.js index ab03e690..4711382a 100644 --- a/src/lua.js +++ b/src/lua.js @@ -1,189 +1,13 @@ -import { LUA_AUTHORS, LUA_COPYRIGHT, thread_status, LUA_HOOKCALL, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, constant_types, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RELEASE, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, LUA_SIGNATURE, LUA_VERSION, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, LUA_VERSION_NUM, LUA_VERSION_RELEASE, lua_Debug, lua_upvalueindex } from "./defs.js"; -import { lua_absindex, lua_arith, lua_atpanic, lua_atnativeerror, lua_call, lua_callk, lua_checkstack, lua_compare, lua_concat, lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, lua_getextraspace, lua_getfield, lua_getglobal, lua_geti, lua_getmetatable, lua_gettable, lua_gettop, lua_getupvalue, lua_getuservalue, lua_insert, lua_isboolean, lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isproxy, lua_isstring, lua_istable, lua_isthread, lua_isuserdata, lua_len, lua_load, lua_newtable, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushinteger, lua_pushjsclosure, lua_pushjsfunction, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, lua_replace, lua_rotate, lua_setallocf, lua_setfield, lua_setglobal, lua_seti, lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, lua_setuservalue, lua_status, lua_stringtonumber, lua_toboolean, lua_todataview, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, lua_upvalueid, lua_upvaluejoin, lua_version, lua_xmove, lua_tocfunction } from "./lapi.js"; -import { lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getstack, lua_sethook, lua_setlocal } from "./ldebug.js"; -import { lua_isyieldable, lua_resume, lua_yield, lua_yieldk } from "./ldo.js"; -import { lua_close, lua_newstate, lua_newthread } from "./lstate.js"; +export { LUA_AUTHORS, LUA_COPYRIGHT, thread_status, LUA_HOOKCALL, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, constant_types, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RELEASE, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, LUA_SIGNATURE, LUA_VERSION, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, LUA_VERSION_NUM, LUA_VERSION_RELEASE, lua_Debug, lua_upvalueindex } from "./defs.js"; +export { lua_absindex, lua_arith, lua_atpanic, lua_atnativeerror, lua_call, lua_callk, lua_checkstack, lua_compare, lua_concat, lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, lua_getextraspace, lua_getfield, lua_getglobal, lua_geti, lua_getmetatable, lua_gettable, lua_gettop, lua_getupvalue, lua_getuservalue, lua_insert, lua_isboolean, lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isproxy, lua_isstring, lua_istable, lua_isthread, lua_isuserdata, lua_len, lua_load, lua_newtable, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushinteger, lua_pushjsclosure, lua_pushjsfunction, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, lua_replace, lua_rotate, lua_setallocf, lua_setfield, lua_setglobal, lua_seti, lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, lua_setuservalue, lua_status, lua_stringtonumber, lua_toboolean, lua_todataview, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, lua_upvalueid, lua_upvaluejoin, lua_version, lua_xmove, lua_tocfunction } from "./lapi.js"; +export { lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getstack, lua_sethook, lua_setlocal } from "./ldebug.js"; +export { lua_isyieldable, lua_resume, lua_yield, lua_yieldk } from "./ldo.js"; +export { lua_close, lua_newstate, lua_newthread } from "./lstate.js"; -export const LUA_AUTHORS = LUA_AUTHORS; -export const LUA_COPYRIGHT = LUA_COPYRIGHT; export const LUA_ERRERR = thread_status.LUA_ERRERR; export const LUA_ERRGCMM = thread_status.LUA_ERRGCMM; export const LUA_ERRMEM = thread_status.LUA_ERRMEM; export const LUA_ERRRUN = thread_status.LUA_ERRRUN; export const LUA_ERRSYNTAX = thread_status.LUA_ERRSYNTAX; -export const LUA_HOOKCALL = LUA_HOOKCALL; -export const LUA_HOOKCOUNT = LUA_HOOKCOUNT; -export const LUA_HOOKLINE = LUA_HOOKLINE; -export const LUA_HOOKRET = LUA_HOOKRET; -export const LUA_HOOKTAILCALL = LUA_HOOKTAILCALL; -export const LUA_MASKCALL = LUA_MASKCALL; -export const LUA_MASKCOUNT = LUA_MASKCOUNT; -export const LUA_MASKLINE = LUA_MASKLINE; -export const LUA_MASKRET = LUA_MASKRET; -export const LUA_MINSTACK = LUA_MINSTACK; -export const LUA_MULTRET = LUA_MULTRET; export const LUA_NUMTAGS = constant_types.LUA_NUMTAGS; export const LUA_OK = thread_status.LUA_OK; -export const LUA_OPADD = LUA_OPADD; -export const LUA_OPBAND = LUA_OPBAND; -export const LUA_OPBNOT = LUA_OPBNOT; -export const LUA_OPBOR = LUA_OPBOR; -export const LUA_OPBXOR = LUA_OPBXOR; -export const LUA_OPDIV = LUA_OPDIV; -export const LUA_OPEQ = LUA_OPEQ; -export const LUA_OPIDIV = LUA_OPIDIV; -export const LUA_OPLE = LUA_OPLE; -export const LUA_OPLT = LUA_OPLT; -export const LUA_OPMOD = LUA_OPMOD; -export const LUA_OPMUL = LUA_OPMUL; -export const LUA_OPPOW = LUA_OPPOW; -export const LUA_OPSHL = LUA_OPSHL; -export const LUA_OPSHR = LUA_OPSHR; -export const LUA_OPSUB = LUA_OPSUB; -export const LUA_OPUNM = LUA_OPUNM; -export const LUA_REGISTRYINDEX = LUA_REGISTRYINDEX; -export const LUA_RELEASE = LUA_RELEASE; -export const LUA_RIDX_GLOBALS = LUA_RIDX_GLOBALS; -export const LUA_RIDX_LAST = LUA_RIDX_LAST; -export const LUA_RIDX_MAINTHREAD = LUA_RIDX_MAINTHREAD; -export const LUA_SIGNATURE = LUA_SIGNATURE; -export const LUA_TNONE = constant_types.LUA_TNONE; -export const LUA_TNIL = constant_types.LUA_TNIL; -export const LUA_TBOOLEAN = constant_types.LUA_TBOOLEAN; -export const LUA_TLIGHTUSERDATA = constant_types.LUA_TLIGHTUSERDATA; -export const LUA_TNUMBER = constant_types.LUA_TNUMBER; -export const LUA_TSTRING = constant_types.LUA_TSTRING; -export const LUA_TTABLE = constant_types.LUA_TTABLE; -export const LUA_TFUNCTION = constant_types.LUA_TFUNCTION; -export const LUA_TUSERDATA = constant_types.LUA_TUSERDATA; -export const LUA_TTHREAD = constant_types.LUA_TTHREAD; -export const LUA_VERSION = LUA_VERSION; -export const LUA_VERSION_MAJOR = LUA_VERSION_MAJOR; -export const LUA_VERSION_MINOR = LUA_VERSION_MINOR; -export const LUA_VERSION_NUM = LUA_VERSION_NUM; -export const LUA_VERSION_RELEASE = LUA_VERSION_RELEASE; -export const LUA_YIELD = thread_status.LUA_YIELD; -export const lua_Debug = lua_Debug; -export const lua_upvalueindex = lua_upvalueindex; -export const lua_absindex = lua_absindex; -export const lua_arith = lua_arith; -export const lua_atpanic = lua_atpanic; -export const lua_atnativeerror = lua_atnativeerror; -export const lua_call = lua_call; -export const lua_callk = lua_callk; -export const lua_checkstack = lua_checkstack; -export const lua_close = lua_close; -export const lua_compare = lua_compare; -export const lua_concat = lua_concat; -export const lua_copy = lua_copy; -export const lua_createtable = lua_createtable; -export const lua_dump = lua_dump; -export const lua_error = lua_error; -export const lua_gc = lua_gc; -export const lua_getallocf = lua_getallocf; -export const lua_getextraspace = lua_getextraspace; -export const lua_getfield = lua_getfield; -export const lua_getglobal = lua_getglobal; -export const lua_gethook = lua_gethook; -export const lua_gethookcount = lua_gethookcount; -export const lua_gethookmask = lua_gethookmask; -export const lua_geti = lua_geti; -export const lua_getinfo = lua_getinfo; -export const lua_getlocal = lua_getlocal; -export const lua_getmetatable = lua_getmetatable; -export const lua_getstack = lua_getstack; -export const lua_gettable = lua_gettable; -export const lua_gettop = lua_gettop; -export const lua_getupvalue = lua_getupvalue; -export const lua_getuservalue = lua_getuservalue; -export const lua_insert = lua_insert; -export const lua_isboolean = lua_isboolean; -export const lua_iscfunction = lua_iscfunction; -export const lua_isfunction = lua_isfunction; -export const lua_isinteger = lua_isinteger; -export const lua_islightuserdata = lua_islightuserdata; -export const lua_isnil = lua_isnil; -export const lua_isnone = lua_isnone; -export const lua_isnoneornil = lua_isnoneornil; -export const lua_isnumber = lua_isnumber; -export const lua_isproxy = lua_isproxy; -export const lua_isstring = lua_isstring; -export const lua_istable = lua_istable; -export const lua_isthread = lua_isthread; -export const lua_isuserdata = lua_isuserdata; -export const lua_isyieldable = lua_isyieldable; -export const lua_len = lua_len; -export const lua_load = lua_load; -export const lua_newstate = lua_newstate; -export const lua_newtable = lua_newtable; -export const lua_newthread = lua_newthread; -export const lua_newuserdata = lua_newuserdata; -export const lua_next = lua_next; -export const lua_pcall = lua_pcall; -export const lua_pcallk = lua_pcallk; -export const lua_pop = lua_pop; -export const lua_pushboolean = lua_pushboolean; -export const lua_pushcclosure = lua_pushcclosure; -export const lua_pushcfunction = lua_pushcfunction; -export const lua_pushfstring = lua_pushfstring; -export const lua_pushglobaltable = lua_pushglobaltable; -export const lua_pushinteger = lua_pushinteger; -export const lua_pushjsclosure = lua_pushjsclosure; -export const lua_pushjsfunction = lua_pushjsfunction; -export const lua_pushlightuserdata = lua_pushlightuserdata; -export const lua_pushliteral = lua_pushliteral; -export const lua_pushlstring = lua_pushlstring; -export const lua_pushnil = lua_pushnil; -export const lua_pushnumber = lua_pushnumber; -export const lua_pushstring = lua_pushstring; -export const lua_pushthread = lua_pushthread; -export const lua_pushvalue = lua_pushvalue; -export const lua_pushvfstring = lua_pushvfstring; -export const lua_rawequal = lua_rawequal; -export const lua_rawget = lua_rawget; -export const lua_rawgeti = lua_rawgeti; -export const lua_rawgetp = lua_rawgetp; -export const lua_rawlen = lua_rawlen; -export const lua_rawset = lua_rawset; -export const lua_rawseti = lua_rawseti; -export const lua_rawsetp = lua_rawsetp; -export const lua_register = lua_register; -export const lua_remove = lua_remove; -export const lua_replace = lua_replace; -export const lua_resume = lua_resume; -export const lua_rotate = lua_rotate; -export const lua_setallocf = lua_setallocf; -export const lua_setfield = lua_setfield; -export const lua_setglobal = lua_setglobal; -export const lua_sethook = lua_sethook; -export const lua_seti = lua_seti; -export const lua_setlocal = lua_setlocal; -export const lua_setmetatable = lua_setmetatable; -export const lua_settable = lua_settable; -export const lua_settop = lua_settop; -export const lua_setupvalue = lua_setupvalue; -export const lua_setuservalue = lua_setuservalue; -export const lua_status = lua_status; -export const lua_stringtonumber = lua_stringtonumber; -export const lua_toboolean = lua_toboolean; -export const lua_todataview = lua_todataview; -export const lua_tointeger = lua_tointeger; -export const lua_tointegerx = lua_tointegerx; -export const lua_tojsstring = lua_tojsstring; -export const lua_tolstring = lua_tolstring; -export const lua_tonumber = lua_tonumber; -export const lua_tonumberx = lua_tonumberx; -export const lua_topointer = lua_topointer; -export const lua_toproxy = lua_toproxy; -export const lua_tostring = lua_tostring; -export const lua_tothread = lua_tothread; -export const lua_touserdata = lua_touserdata; -export const lua_type = lua_type; -export const lua_typename = lua_typename; -export const lua_upvalueid = lua_upvalueid; -export const lua_upvaluejoin = lua_upvaluejoin; -export const lua_version = lua_version; -export const lua_xmove = lua_xmove; -export const lua_yield = lua_yield; -export const lua_yieldk = lua_yieldk; -export const lua_tocfunction = lua_tocfunction; diff --git a/src/luaconf.js b/src/luaconf.js index 0fcfe105..f5d53ef4 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -1,4 +1,4 @@ -"use strict"; +import { platform } from 'os'; const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); @@ -11,7 +11,7 @@ import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR, to_luastring } from './defs.js'; ** LUA_EXEC_DIR in a Windows path is replaced by the executable's ** directory. */ -const LUA_PATH_SEP = ";"; +const LUA_PATH_SEP = ";"; const _LUA_PATH_SEP = LUA_PATH_SEP; export { _LUA_PATH_SEP as LUA_PATH_SEP }; @@ -19,7 +19,7 @@ const LUA_PATH_MARK = "?"; const _LUA_PATH_MARK = LUA_PATH_MARK; export { _LUA_PATH_MARK as LUA_PATH_MARK }; -const LUA_EXEC_DIR = "!"; +const LUA_EXEC_DIR = "!"; const _LUA_EXEC_DIR = LUA_EXEC_DIR; export { _LUA_EXEC_DIR as LUA_EXEC_DIR }; @@ -36,88 +36,72 @@ const LUA_VDIR = LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; const _LUA_VDIR = LUA_VDIR; export { _LUA_VDIR as LUA_VDIR }; +export let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT; + if (typeof process === "undefined") { - const LUA_DIRSEP = "/"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; + LUA_DIRSEP = "/"; - const LUA_LDIR = "./lua/" + LUA_VDIR + "/"; - module.exports.LUA_LDIR = LUA_LDIR; + LUA_LDIR = "./lua/" + LUA_VDIR + "/"; - const LUA_JSDIR = LUA_LDIR; - module.exports.LUA_JSDIR = LUA_JSDIR; + LUA_JSDIR = LUA_LDIR; - const LUA_PATH_DEFAULT = to_luastring( + LUA_PATH_DEFAULT = to_luastring( LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + /* LUA_JSDIR excluded as it is equal to LUA_LDIR */ "./?.lua;./?/init.lua" ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - const LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = to_luastring( LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;./?.js" ); - module.exports.LUA_JSPATH_DEFAULT = LUA_JSPATH_DEFAULT; -} else if (require('os').platform() === 'win32') { - const LUA_DIRSEP = "\\"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; +} else if (platform() === 'win32') { + LUA_DIRSEP = "\\"; /* ** In Windows, any exclamation mark ('!') in the path is replaced by the ** path of the directory of the executable file of the current process. */ - const LUA_LDIR = "!\\lua\\"; - module.exports.LUA_LDIR = LUA_LDIR; + LUA_LDIR = "!\\lua\\"; - const LUA_JSDIR = "!\\"; - module.exports.LUA_JSDIR = LUA_JSDIR; + LUA_JSDIR = "!\\"; - const LUA_SHRDIR = "!\\..\\share\\lua\\" + LUA_VDIR + "\\"; - module.exports.LUA_SHRDIR = LUA_SHRDIR; + LUA_SHRDIR = "!\\..\\share\\lua\\" + LUA_VDIR + "\\"; - const LUA_PATH_DEFAULT = to_luastring( + LUA_PATH_DEFAULT = to_luastring( LUA_LDIR + "?.lua;" + LUA_LDIR + "?\\init.lua;" + LUA_JSDIR + "?.lua;" + LUA_JSDIR + "?\\init.lua;" + LUA_SHRDIR + "?.lua;" + LUA_SHRDIR + "?\\init.lua;" + ".\\?.lua;.\\?\\init.lua" ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - const LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = to_luastring( LUA_JSDIR + "?.js;" + LUA_JSDIR + "..\\share\\lua\\" + LUA_VDIR + "\\?.js;" + LUA_JSDIR + "loadall.js;.\\?.js" ); - module.exports.LUA_JSPATH_DEFAULT = LUA_JSPATH_DEFAULT; } else { - const LUA_DIRSEP = "/"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; + LUA_DIRSEP = "/"; - const LUA_ROOT = "/usr/local/"; - module.exports.LUA_ROOT = LUA_ROOT; - const LUA_ROOT2 = "/usr/"; + LUA_ROOT = "/usr/local/"; - const LUA_LDIR = LUA_ROOT + "share/lua/" + LUA_VDIR + "/"; - const LUA_LDIR2 = LUA_ROOT2 + "share/lua/" + LUA_VDIR + "/"; - module.exports.LUA_LDIR = LUA_LDIR; + LUA_LDIR = LUA_ROOT + "share/lua/" + LUA_VDIR + "/"; + LUA_LDIR2 = LUA_ROOT2 + "share/lua/" + LUA_VDIR + "/"; - const LUA_JSDIR = LUA_LDIR; - module.exports.LUA_JSDIR = LUA_JSDIR; - const LUA_JSDIR2 = LUA_LDIR2; + LUA_JSDIR = LUA_LDIR; + LUA_JSDIR2 = LUA_LDIR2; - const LUA_PATH_DEFAULT = to_luastring( + LUA_PATH_DEFAULT = to_luastring( LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + LUA_LDIR2 + "?.lua;" + LUA_LDIR2 + "?/init.lua;" + /* LUA_JSDIR(2) excluded as it is equal to LUA_LDIR(2) */ "./?.lua;./?/init.lua" ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - const LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = to_luastring( LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;" + LUA_JSDIR2 + "?.js;" + LUA_JSDIR2 + "loadall.js;" + "./?.js" ); - module.exports.LUA_JSPATH_DEFAULT = LUA_JSPATH_DEFAULT; } /* @@ -144,17 +128,17 @@ const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; @@ of a function in debug information. ** CHANGE it if you want a different size. */ -const LUA_IDSIZE = conf.LUA_IDSIZE || (60-1); /* fengari uses 1 less than lua as we don't embed the null byte */ +const LUA_IDSIZE = conf.LUA_IDSIZE || (60 - 1); /* fengari uses 1 less than lua as we don't embed the null byte */ -const lua_integer2str = function(n) { +const lua_integer2str = function (n) { return String(n); /* should match behaviour of LUA_INTEGER_FMT */ }; -const lua_number2str = function(n) { +const lua_number2str = function (n) { return String(Number(n.toPrecision(14))); /* should match behaviour of LUA_NUMBER_FMT */ }; -const lua_numbertointeger = function(n) { +const lua_numbertointeger = function (n) { return n >= LUA_MININTEGER && n < -LUA_MININTEGER ? n : false; }; @@ -162,9 +146,9 @@ const LUA_INTEGER_FRMLEN = ""; const LUA_NUMBER_FRMLEN = ""; const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; -const LUA_NUMBER_FMT = "%.14g"; +const LUA_NUMBER_FMT = "%.14g"; -const lua_getlocaledecpoint = function() { +const lua_getlocaledecpoint = function () { /* we hard-code the decimal point to '.' as a user cannot change the locale in most JS environments, and in that you can, a multi-byte locale is common. @@ -178,7 +162,7 @@ const lua_getlocaledecpoint = function() { const LUAL_BUFFERSIZE = conf.LUAL_BUFFERSIZE || 8192; // See: http://croquetweak.blogspot.fr/2014/08/deconstructing-floats-frexp-and-ldexp.html -const frexp = function(value) { +const frexp = function (value) { if (value === 0) return [value, 0]; var data = new DataView(new ArrayBuffer(8)); data.setFloat64(0, value); @@ -192,7 +176,7 @@ const frexp = function(value) { return [mantissa, exponent]; }; -const ldexp = function(mantissa, exponent) { +const ldexp = function (mantissa, exponent) { var steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023)); var result = mantissa; for (var i = 0; i < steps; i++) diff --git a/src/lualib.js b/src/lualib.js index 889d3b04..3a026121 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,3 +1,14 @@ +export { luaL_openlibs } from './linit.js'; +export { luaopen_io } from "./liolib.js"; +export { luaopen_table } from "./ltablib.js"; +export { luaopen_coroutine } from "./lcorolib.js"; +export { luaopen_os } from "./loslib.js"; +export { luaopen_string } from "./lstrlib.js"; +export { luaopen_utf8 } from "./lutf8lib.js"; +export { luaopen_math } from "./lmathlib.js"; +export { luaopen_debug } from "./ldblib.js"; +export { luaopen_package } from "./loadlib.js"; +export { luaopen_fengari } from "./fengarilib.js"; import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR } from "./lua.js"; const LUA_VERSUFFIX = "_" + LUA_VERSION_MAJOR + "_" + LUA_VERSION_MINOR; @@ -6,38 +17,29 @@ export { _LUA_VERSUFFIX as LUA_VERSUFFIX }; export function lua_assert(c) { } -export const luaopen_base = require("./lbaselib.js").luaopen_base; +export const luaopen_base = luaopen_base; const LUA_COLIBNAME = "coroutine"; const _LUA_COLIBNAME = LUA_COLIBNAME; export { _LUA_COLIBNAME as LUA_COLIBNAME }; -export const luaopen_coroutine = require("./lcorolib.js").luaopen_coroutine; const LUA_TABLIBNAME = "table"; const _LUA_TABLIBNAME = LUA_TABLIBNAME; export { _LUA_TABLIBNAME as LUA_TABLIBNAME }; -export const luaopen_table = require("./ltablib.js").luaopen_table; -if (typeof process !== "undefined") { - const LUA_IOLIBNAME = "io"; - module.exports.LUA_IOLIBNAME = LUA_IOLIBNAME; - module.exports.luaopen_io = require("./liolib.js").luaopen_io; -} +export const LUA_IOLIBNAME = "io"; const LUA_OSLIBNAME = "os"; const _LUA_OSLIBNAME = LUA_OSLIBNAME; export { _LUA_OSLIBNAME as LUA_OSLIBNAME }; -export const luaopen_os = require("./loslib.js").luaopen_os; const LUA_STRLIBNAME = "string"; const _LUA_STRLIBNAME = LUA_STRLIBNAME; export { _LUA_STRLIBNAME as LUA_STRLIBNAME }; -export const luaopen_string = require("./lstrlib.js").luaopen_string; const LUA_UTF8LIBNAME = "utf8"; const _LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; export { _LUA_UTF8LIBNAME as LUA_UTF8LIBNAME }; -export const luaopen_utf8 = require("./lutf8lib.js").luaopen_utf8; const LUA_BITLIBNAME = "bit32"; const _LUA_BITLIBNAME = LUA_BITLIBNAME; @@ -47,22 +49,16 @@ export { _LUA_BITLIBNAME as LUA_BITLIBNAME }; const LUA_MATHLIBNAME = "math"; const _LUA_MATHLIBNAME = LUA_MATHLIBNAME; export { _LUA_MATHLIBNAME as LUA_MATHLIBNAME }; -export const luaopen_math = require("./lmathlib.js").luaopen_math; const LUA_DBLIBNAME = "debug"; const _LUA_DBLIBNAME = LUA_DBLIBNAME; export { _LUA_DBLIBNAME as LUA_DBLIBNAME }; -export const luaopen_debug = require("./ldblib.js").luaopen_debug; const LUA_LOADLIBNAME = "package"; const _LUA_LOADLIBNAME = LUA_LOADLIBNAME; export { _LUA_LOADLIBNAME as LUA_LOADLIBNAME }; -export const luaopen_package = require("./loadlib.js").luaopen_package; const LUA_FENGARILIBNAME = "fengari"; const _LUA_FENGARILIBNAME = LUA_FENGARILIBNAME; export { _LUA_FENGARILIBNAME as LUA_FENGARILIBNAME }; -export const luaopen_fengari = require("./fengarilib.js").luaopen_fengari; -import { luaL_openlibs } from './linit.js'; -export const luaL_openlibs = luaL_openlibs; From bccadc581949b7c5cd456a34ec301df6f5cb9f7c Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Mon, 1 Jun 2026 16:34:52 +0100 Subject: [PATCH 04/11] Third pass - MVP complete --- jest.config.cjs | 5 +- src/common.js | 9 + src/defs.js | 4 +- src/fengari.js | 8 +- src/fengaricore.js | 2 + src/lapi.js | 2 +- src/ldo.js | 2 +- src/linit.js | 13 +- src/loadlib.js | 6 +- src/lobject.js | 6 +- src/lua.js | 14 + src/luaconf.js | 12 +- src/lualib.js | 5 +- test/defs.test.js | 34 +- test/lapi.test.js | 240 ++++++------ test/lauxlib.test.js | 20 +- test/lbaselib.test.js | 208 +++++----- test/lcorolib.test.js | 68 ++-- test/ldblib.test.js | 2 - test/ldebug.test.js | 80 ++-- test/lexparse.test.js | 282 +++++++------- test/lmathlib.test.js | 170 +++++---- test/load.test.js | 80 ++-- test/loadlib.test.js | 50 ++- test/loslib.test.js | 86 +++-- test/lstrlib.test.js | 296 ++++++++------- test/ltablib.test.js | 94 +++-- test/ltm.test.js | 182 +++++---- test/lua.test.js | 42 +-- test/lutf8lib.test.js | 64 ++-- test/lvm.test.js | 234 ++++++------ test/manual-tests/debug-cli.js | 17 +- test/test-suite/api.test.js | 588 ++++++++++++++--------------- test/test-suite/attrib.test.js | 72 ++-- test/test-suite/bitwise.test.js | 90 +++-- test/test-suite/calls.test.js | 170 +++++---- test/test-suite/closure.test.js | 90 +++-- test/test-suite/code.test.js | 180 +++++---- test/test-suite/constructs.test.js | 70 ++-- test/test-suite/coroutine.test.js | 402 ++++++++++---------- test/test-suite/db.test.js | 280 +++++++------- test/test-suite/errors.test.js | 360 +++++++++--------- test/test-suite/events.test.js | 160 ++++---- test/test-suite/goto.test.js | 70 ++-- test/test-suite/literals.test.js | 160 ++++---- test/test-suite/locals.test.js | 60 ++- test/test-suite/ltests.js | 506 ++++++++++++------------- test/test-suite/math.test.js | 378 +++++++++---------- test/test-suite/nextvar.test.js | 258 ++++++------- test/test-suite/pm.test.js | 190 +++++----- test/test-suite/sort.test.js | 130 ++++--- test/test-suite/strings.test.js | 190 +++++----- test/test-suite/tpack.test.js | 170 +++++---- test/test-suite/utf8.test.js | 100 +++-- test/test-suite/vararg.test.js | 50 ++- test/tests.js | 19 +- 56 files changed, 3513 insertions(+), 3567 deletions(-) create mode 100644 src/common.js diff --git a/jest.config.cjs b/jest.config.cjs index 3d53a3db..9fc662d6 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -161,8 +161,7 @@ const config = { // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped testPathIgnorePatterns: [ "/node_modules/", - "/dist/", - "/test/test-suite/" + "/dist/" ], // The regexp pattern or array of patterns that Jest uses to detect test files @@ -176,7 +175,7 @@ const config = { // A map from regular expressions to paths to transformers transform: { - "^.+\\.js$": "babel-jest", + "^.+\\.jsx$": "babel-jest", }, // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation diff --git a/src/common.js b/src/common.js new file mode 100644 index 00000000..6a6af9bb --- /dev/null +++ b/src/common.js @@ -0,0 +1,9 @@ +const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +export const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; diff --git a/src/defs.js b/src/defs.js index cbd76083..e87f715b 100644 --- a/src/defs.js +++ b/src/defs.js @@ -2,7 +2,9 @@ * Fengari specific string conversion functions */ -export { LUAI_MAXSTACK } from './luaconf.js'; +import { LUAI_MAXSTACK } from './common.js'; + +export { LUAI_MAXSTACK }; export const luastring_from = (typeof Uint8Array.from === "function") ? Uint8Array.from.bind(Uint8Array) : diff --git a/src/fengari.js b/src/fengari.js index 3c216753..7450c00c 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -10,10 +10,10 @@ Copyright © 1994–2017 Lua.org, PUC-Rio. export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; -import luaconf from './luaconf.js'; -import lua from './lua.js'; -import lauxlib from './lauxlib.js'; -import lualib from './lualib.js'; +import * as luaconf from './luaconf.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as lualib from './lualib.js'; const _luaconf = luaconf; export { _luaconf as luaconf }; diff --git a/src/fengaricore.js b/src/fengaricore.js index d52143b5..af01cc5e 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,6 +6,8 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ +import { LUA_COPYRIGHT } from "./defs.js"; + export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from "./defs.js"; const FENGARI_VERSION_MAJOR = "0"; diff --git a/src/lapi.js b/src/lapi.js index 7c1df733..163ee336 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -8,7 +8,7 @@ import { TValue as _TValue, CClosure as _CClosure, luaO_nilobject, setobj2s, pus import { EXTRA_STACK, lua_State, CIST_LUA, CIST_OAH, CIST_YPCALL } from './lstate.js'; import { luaS_bless, luaS_new, luaS_newliteral } from './lstring.js'; import { ttypename } from './ltm.js'; -import { LUAI_MAXSTACK } from './luaconf.js'; +import { LUAI_MAXSTACK } from './common.js'; import { settable, luaV_gettable, cvt2str, tointeger, tonumber, luaV_equalobj, luaV_lessthan, luaV_lessequal, luaV_concat, luaV_objlen } from './lvm.js'; import { luaH_getint, luaH_setfrom, invalidateTMcache, luaH_setint, luaH_get, luaH_new, luaH_getn, luaH_next } from './ltable.js'; import { ZIO } from './lzio.js'; diff --git a/src/ldo.js b/src/ldo.js index 38613316..d2b29c03 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -9,7 +9,7 @@ import { Dyndata, luaY_parser } from './lparser.js'; import { EXTRA_STACK, luaE_freeCI, luaE_extendCI, CIST_LUA, CIST_HOOKED, CIST_TAIL, CIST_YPCALL, CIST_OAH } from './lstate.js'; import { luaS_newliteral } from './lstring.js'; import { luaT_gettmbyobj, TMS } from './ltm.js'; -import { LUAI_MAXSTACK } from './luaconf.js'; +import { LUAI_MAXSTACK } from './common.js'; import { luaU_undump } from './lundump.js'; import { luaV_execute, luaV_finishOp } from './lvm.js'; import { MBuffer } from './lzio.js'; diff --git a/src/linit.js b/src/linit.js index 46fae546..bf857715 100644 --- a/src/linit.js +++ b/src/linit.js @@ -2,10 +2,10 @@ import { lua_pop } from './lua.js'; import { luaL_requiref } from './lauxlib.js'; import { to_luastring } from "./fengaricore.js"; import { luaopen_fengari } from './fengarilib.js'; -import { LUA_LOADLIBNAME, LUA_COLIBNAME, LUA_TABLIBNAME, LUA_OSLIBNAME, LUA_STRLIBNAME, LUA_MATHLIBNAME, LUA_UTF8LIBNAME, LUA_DBLIBNAME, LUA_IOLIBNAME, LUA_FENGARILIBNAME, luaopen_io } from './lualib.js'; import { luaopen_base } from './lbaselib.js'; import { luaopen_coroutine } from './lcorolib.js'; import { luaopen_debug } from './ldblib.js'; +import { luaopen_io } from './liolib.js'; import { luaopen_math } from './lmathlib.js'; import { luaopen_package } from './loadlib.js'; import { luaopen_os } from './loslib.js'; @@ -13,6 +13,17 @@ import { luaopen_string } from './lstrlib.js'; import { luaopen_table } from './ltablib.js'; import { luaopen_utf8 } from './lutf8lib.js'; +const LUA_COLIBNAME = "coroutine"; +const LUA_TABLIBNAME = "table"; +const LUA_IOLIBNAME = "io"; +const LUA_OSLIBNAME = "os"; +const LUA_STRLIBNAME = "string"; +const LUA_MATHLIBNAME = "math"; +const LUA_UTF8LIBNAME = "utf8"; +const LUA_DBLIBNAME = "debug"; +const LUA_LOADLIBNAME = "package"; +const LUA_FENGARILIBNAME = "fengari"; + const loadedlibs = {}; /* export before requiring lualib.js */ diff --git a/src/loadlib.js b/src/loadlib.js index a3505e79..4b6aaf48 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -3,7 +3,7 @@ import { LUA_OK, LUA_REGISTRYINDEX, LUA_TNIL, LUA_TTABLE, lua_callk, lua_createt import { LUA_LOADED_TABLE, LUA_PRELOAD_TABLE, luaL_Buffer, luaL_addvalue, luaL_buffinit, luaL_checkstring, luaL_error, luaL_getsubtable, luaL_gsub, luaL_len, luaL_loadfile, luaL_newlib, luaL_optstring, luaL_pushresult, luaL_setfuncs } from './lauxlib.js'; import { LUA_VERSUFFIX } from './lualib.js'; import { luastring_indexOf, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; -import fengari from './fengari.js'; +import * as fengari from './fengari.js'; import pathlib from 'path'; import fs from 'fs'; @@ -89,12 +89,12 @@ if (typeof process === "undefined") { } }; } else { - lsys_load = async function (L, path, seeglb) { + lsys_load = function (L, path, seeglb) { path = to_jsstring(path); /* relative paths should be relative to cwd, not this js file */ path = pathlib.resolve(process.cwd(), path); try { - return await import(path); // TODO: use dynamic import - require is not supported in ESM modules + return require(path); } catch (e) { lua_pushstring(L, to_luastring(e.message)); return null; diff --git a/src/lobject.js b/src/lobject.js index f23ac96e..31f522a3 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -10,9 +10,6 @@ import { luaV_concat, luaV_imul, luaV_mod, luaV_div, luaV_shiftl, tointeger, ton import { MAX_INT, luai_nummod, lua_assert } from "./llimits.js"; import { luaT_trybinTM, TMS } from './ltm.js'; -const LUA_TPROTO = LUA_NUMTAGS; -const LUA_TDEADKEY = LUA_NUMTAGS + 1; - const { LUA_NUMTAGS, LUA_TBOOLEAN, @@ -33,6 +30,9 @@ const { LUA_TUSERDATA } = constant_types; +const LUA_TPROTO = LUA_NUMTAGS; +const LUA_TDEADKEY = LUA_NUMTAGS + 1; + class TValue { constructor(type, value) { diff --git a/src/lua.js b/src/lua.js index 4711382a..a8eba907 100644 --- a/src/lua.js +++ b/src/lua.js @@ -1,3 +1,5 @@ +import { thread_status, constant_types } from "./defs.js"; + export { LUA_AUTHORS, LUA_COPYRIGHT, thread_status, LUA_HOOKCALL, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, constant_types, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RELEASE, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, LUA_SIGNATURE, LUA_VERSION, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, LUA_VERSION_NUM, LUA_VERSION_RELEASE, lua_Debug, lua_upvalueindex } from "./defs.js"; export { lua_absindex, lua_arith, lua_atpanic, lua_atnativeerror, lua_call, lua_callk, lua_checkstack, lua_compare, lua_concat, lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, lua_getextraspace, lua_getfield, lua_getglobal, lua_geti, lua_getmetatable, lua_gettable, lua_gettop, lua_getupvalue, lua_getuservalue, lua_insert, lua_isboolean, lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isproxy, lua_isstring, lua_istable, lua_isthread, lua_isuserdata, lua_len, lua_load, lua_newtable, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushinteger, lua_pushjsclosure, lua_pushjsfunction, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, lua_replace, lua_rotate, lua_setallocf, lua_setfield, lua_setglobal, lua_seti, lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, lua_setuservalue, lua_status, lua_stringtonumber, lua_toboolean, lua_todataview, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, lua_upvalueid, lua_upvaluejoin, lua_version, lua_xmove, lua_tocfunction } from "./lapi.js"; export { lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getstack, lua_sethook, lua_setlocal } from "./ldebug.js"; @@ -11,3 +13,15 @@ export const LUA_ERRRUN = thread_status.LUA_ERRRUN; export const LUA_ERRSYNTAX = thread_status.LUA_ERRSYNTAX; export const LUA_NUMTAGS = constant_types.LUA_NUMTAGS; export const LUA_OK = thread_status.LUA_OK; +export const LUA_YIELD = thread_status.LUA_YIELD; + +export const LUA_TNONE = constant_types.LUA_TNONE; +export const LUA_TNIL = constant_types.LUA_TNIL; +export const LUA_TBOOLEAN = constant_types.LUA_TBOOLEAN; +export const LUA_TLIGHTUSERDATA = constant_types.LUA_TLIGHTUSERDATA; +export const LUA_TNUMBER = constant_types.LUA_TNUMBER; +export const LUA_TSTRING = constant_types.LUA_TSTRING; +export const LUA_TTABLE = constant_types.LUA_TTABLE; +export const LUA_TFUNCTION = constant_types.LUA_TFUNCTION; +export const LUA_TUSERDATA = constant_types.LUA_TUSERDATA; +export const LUA_TTHREAD = constant_types.LUA_TTHREAD; diff --git a/src/luaconf.js b/src/luaconf.js index f5d53ef4..e72e26c2 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -36,7 +36,7 @@ const LUA_VDIR = LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; const _LUA_VDIR = LUA_VDIR; export { _LUA_VDIR as LUA_VDIR }; -export let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT; +export let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT, LUA_ROOT, LUA_ROOT2, LUA_LDIR2, LUA_JSDIR2; if (typeof process === "undefined") { LUA_DIRSEP = "/"; @@ -115,14 +115,6 @@ const LUA_COMPAT_FLOATSTRING = conf.LUA_COMPAT_FLOATSTRING || false; const LUA_MAXINTEGER = 2147483647; const LUA_MININTEGER = -2147483648; -/* -@@ LUAI_MAXSTACK limits the size of the Lua stack. -** CHANGE it if you need a different limit. This limit is arbitrary; -** its only purpose is to stop Lua from consuming unlimited stack -** space (and to reserve some numbers for pseudo-indices). -*/ -const LUAI_MAXSTACK = conf.LUAI_MAXSTACK || 1000000; - /* @@ LUA_IDSIZE gives the maximum size for the description of the source @@ of a function in debug information. @@ -184,8 +176,6 @@ const ldexp = function (mantissa, exponent) { return result; }; -const _LUAI_MAXSTACK = LUAI_MAXSTACK; -export { _LUAI_MAXSTACK as LUAI_MAXSTACK }; const _LUA_COMPAT_FLOATSTRING = LUA_COMPAT_FLOATSTRING; export { _LUA_COMPAT_FLOATSTRING as LUA_COMPAT_FLOATSTRING }; const _LUA_IDSIZE = LUA_IDSIZE; diff --git a/src/lualib.js b/src/lualib.js index 3a026121..e5a1e609 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,5 +1,6 @@ export { luaL_openlibs } from './linit.js'; -export { luaopen_io } from "./liolib.js"; +import { luaopen_io } from "./liolib.js"; +export { luaopen_io }; export { luaopen_table } from "./ltablib.js"; export { luaopen_coroutine } from "./lcorolib.js"; export { luaopen_os } from "./loslib.js"; @@ -17,7 +18,7 @@ export { _LUA_VERSUFFIX as LUA_VERSUFFIX }; export function lua_assert(c) { } -export const luaopen_base = luaopen_base; +export { luaopen_base } from "./lbaselib.js"; const LUA_COLIBNAME = "coroutine"; const _LUA_COLIBNAME = LUA_COLIBNAME; diff --git a/test/defs.test.js b/test/defs.test.js index ead9a7b4..669fa97f 100644 --- a/test/defs.test.js +++ b/test/defs.test.js @@ -1,48 +1,48 @@ -const defs = require('../src/defs.js'); +import { luastring_of, to_luastring, to_jsstring } from '../src/defs.js'; const unicode_tests = [ { description: "Convert normal ascii string", literal: "foo", - byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)) + byte_array: luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)) }, { description: "Convert ascii string containing null byte", literal: "fo\0o", - byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)) + byte_array: luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)) }, { description: "Convert string with BMP unicode chars", literal: "Café", - byte_array: defs.luastring_of(67, 97, 102, 195, 169) + byte_array: luastring_of(67, 97, 102, 195, 169) }, { description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)", literal: "", - byte_array: defs.luastring_of(239, 163, 191) + byte_array: luastring_of(239, 163, 191) }, { description: "Convert string with surrogate pair", literal: "❤️🍾", - byte_array: defs.luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) + byte_array: luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) }, { description: "Convert string with broken surrogate pair", literal: "\uD800a", - byte_array: defs.luastring_of(237, 160, 128, 97) + byte_array: luastring_of(237, 160, 128, 97) }, { description: "Convert string with broken surrogate pair at end of string", literal: "\uD823", - byte_array: defs.luastring_of(237, 160, 163) + byte_array: luastring_of(237, 160, 163) } ]; describe('to_luastring', () => { unicode_tests.forEach((v) => { test(v.description, () => { - expect(defs.to_luastring(v.literal)).toEqual(v.byte_array); + expect(to_luastring(v.literal)).toEqual(v.byte_array); }); }); }); @@ -50,7 +50,7 @@ describe('to_luastring', () => { describe('to_jsstring', () => { unicode_tests.forEach((v) => { test(v.description, () => { - expect(defs.to_jsstring(v.byte_array)).toEqual(v.literal); + expect(to_jsstring(v.byte_array)).toEqual(v.literal); }); }); }); @@ -58,37 +58,37 @@ describe('to_jsstring', () => { describe('to_jsstring fails on invalid unicode', () => { test("non-utf8 char", () => { - expect(() => defs.to_jsstring(defs.luastring_of(165))) + expect(() => to_jsstring(luastring_of(165))) .toThrow(RangeError); }); test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(208, 60))) + expect(() => to_jsstring(luastring_of(208, 60))) .toThrow(RangeError); }); test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(225, 60, 145))) + expect(() => to_jsstring(luastring_of(225, 60, 145))) .toThrow(RangeError); }); test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(225, 145, 60))) + expect(() => to_jsstring(luastring_of(225, 145, 60))) .toThrow(RangeError); }); test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(242, 60, 145, 145))) + expect(() => to_jsstring(luastring_of(242, 60, 145, 145))) .toThrow(RangeError); }); test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 60, 145))) + expect(() => to_jsstring(luastring_of(242, 145, 60, 145))) .toThrow(RangeError); }); test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 145, 60))) + expect(() => to_jsstring(luastring_of(242, 145, 145, 60))) .toThrow(RangeError); }); }); diff --git a/test/lapi.test.js b/test/lapi.test.js index 399155a8..62291e4e 100644 --- a/test/lapi.test.js +++ b/test/lapi.test.js @@ -1,250 +1,248 @@ -"use strict"; +import { toByteCode } from "./tests.js"; -const {toByteCode} = require("./tests.js"); - -const lua = require('../src/lua.js'); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +import { lua_pushnil, lua_pushnumber, lua_tonumber, lua_pushinteger, lua_tointeger, lua_pushliteral, lua_tojsstring, lua_pushboolean, lua_toboolean, lua_pushvalue, lua_pushjsclosure, lua_pushjsfunction, lua_call, lua_pushstring, lua_tostring, lua_upvalueindex, lua_pcall, LUA_OK, lua_pop, lua_load, lua_setglobal, lua_createtable, lua_istable, lua_newtable, lua_settable, lua_gettable, lua_pushcfunction, lua_atnativeerror, lua_touserdata, LUA_ERRRUN, lua_seti, lua_len } from '../src/lua.js'; +import { luaL_newstate, luaL_typename, luaL_loadstring, luaL_error } from "../src/lauxlib.js"; +import { to_luastring } from "../src/fengaricore.js"; test('luaL_newstate, lua_pushnil, luaL_typename', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushnil(L); + lua_pushnil(L); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("nil")); }); test('lua_pushnumber', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushnumber(L, 10.5); + lua_pushnumber(L, 10.5); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("number")); - expect(lua.lua_tonumber(L, -1)) + expect(lua_tonumber(L, -1)) .toBe(10.5); }); test('lua_pushinteger', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushinteger(L, 10); + lua_pushinteger(L, 10); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("number")); - expect(lua.lua_tointeger(L, -1)) + expect(lua_tointeger(L, -1)) .toBe(10); }); test('lua_pushliteral', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushliteral(L, "hello"); + lua_pushliteral(L, "hello"); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("string")); - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello"); }); test('lua_pushboolean', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushboolean(L, true); + lua_pushboolean(L, true); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("boolean")); - expect(lua.lua_toboolean(L, -1)) + expect(lua_toboolean(L, -1)) .toBe(true); }); test('lua_pushvalue', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushliteral(L, "hello"); - lua.lua_pushvalue(L, -1); + lua_pushliteral(L, "hello"); + lua_pushvalue(L, -1); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("string")); - expect(lauxlib.luaL_typename(L, -2)) + expect(luaL_typename(L, -2)) .toEqual(to_luastring("string")); - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello"); - expect(lua.lua_tojsstring(L, -2)) + expect(lua_tojsstring(L, -2)) .toBe("hello"); }); test('lua_pushjsclosure', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let fn = function(L) { return 0; }; - lua.lua_pushliteral(L, "a value associated to the C closure"); - lua.lua_pushjsclosure(L, fn, 1); + lua_pushliteral(L, "a value associated to the C closure"); + lua_pushjsclosure(L, fn, 1); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("function")); }); test('lua_pushjsfunction', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let fn = function(L) { return 0; }; - lua.lua_pushjsfunction(L, fn); + lua_pushjsfunction(L, fn); } - expect(lauxlib.luaL_typename(L, -1)) + expect(luaL_typename(L, -1)) .toEqual(to_luastring("function")); }); test('lua_call (calling a light JS function)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let fn = function(L) { - lua.lua_pushliteral(L, "hello"); + lua_pushliteral(L, "hello"); return 1; }; - lua.lua_pushjsfunction(L, fn); - lua.lua_call(L, 0, 1); + lua_pushjsfunction(L, fn); + lua_call(L, 0, 1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello"); }); test('lua_call (calling a JS closure)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let fn = function(L) { - lua.lua_pushstring(L, lua.lua_tostring(L, lua.lua_upvalueindex(1))); + lua_pushstring(L, lua_tostring(L, lua_upvalueindex(1))); return 1; }; - lua.lua_pushliteral(L, "upvalue hello!"); - lua.lua_pushjsclosure(L, fn, 1); - lua.lua_call(L, 0, 1); + lua_pushliteral(L, "upvalue hello!"); + lua_pushjsclosure(L, fn, 1); + lua_call(L, 0, 1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("upvalue hello!"); }); test('lua_pcall (calling a light JS function)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let fn = function(L) { - lua.lua_pushliteral(L, "hello"); + lua_pushliteral(L, "hello"); return 1; }; - lua.lua_pushjsfunction(L, fn); - expect(lua.lua_pcall(L, 0, 1, 0)).toBe(lua.LUA_OK); + lua_pushjsfunction(L, fn); + expect(lua_pcall(L, 0, 1, 0)).toBe(LUA_OK); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello"); }); test('lua_pcall that breaks', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let fn = function(L) { return "undefined_value"; }; - lua.lua_pushjsfunction(L, fn); - expect(lua.lua_pcall(L, 0, 1, 0)).not.toBe(lua.LUA_OK); + lua_pushjsfunction(L, fn); + expect(lua_pcall(L, 0, 1, 0)).not.toBe(LUA_OK); } }); test('lua_pop', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushliteral(L, "hello"); - lua.lua_pushliteral(L, "world"); - lua.lua_pop(L, 1); + lua_pushliteral(L, "hello"); + lua_pushliteral(L, "world"); + lua_pop(L, 1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello"); }); test('lua_load with no chunkname', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_load(L, function(L, s) { + lua_load(L, function(L, s) { let r = s.code; s.code = null; return r; }, { code: to_luastring("return 'hello'") }, null, null); - lua.lua_call(L, 0, 1); + lua_call(L, 0, 1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello"); }); test('lua_load and lua_call it', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { @@ -253,174 +251,174 @@ test('lua_load and lua_call it', () => { return a `; let bc = toByteCode(luaCode); - lua.lua_load(L, function(L, s) { + lua_load(L, function(L, s) { let r = s.bc; s.bc = null; return r; }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary")); - lua.lua_call(L, 0, 1); + lua_call(L, 0, 1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("JS > Lua > JS \\o/"); }); test('lua script reads js upvalues', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { let luaCode = ` return js .. " world" `; - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pushliteral(L, "hello"); - lua.lua_setglobal(L, to_luastring("js")); - lua.lua_call(L, 0, 1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pushliteral(L, "hello"); + lua_setglobal(L, to_luastring("js")); + lua_call(L, 0, 1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello world"); }); test('lua_createtable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_createtable(L, 3, 3); + lua_createtable(L, 3, 3); } - expect(lua.lua_istable(L, -1)).toBe(true); + expect(lua_istable(L, -1)).toBe(true); }); test('lua_newtable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_newtable(L); + lua_newtable(L); } - expect(lua.lua_istable(L, -1)).toBe(true); + expect(lua_istable(L, -1)).toBe(true); }); test('lua_settable, lua_gettable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_newtable(L); + lua_newtable(L); - lua.lua_pushliteral(L, "key"); - lua.lua_pushliteral(L, "value"); + lua_pushliteral(L, "key"); + lua_pushliteral(L, "value"); - lua.lua_settable(L, -3); + lua_settable(L, -3); - lua.lua_pushliteral(L, "key"); - lua.lua_gettable(L, -2); + lua_pushliteral(L, "key"); + lua_gettable(L, -2); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("value"); }); describe('lua_atnativeerror', () => { test('no native error handler', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let errob = {}; - lua.lua_pushcfunction(L, function(L) { + lua_pushcfunction(L, function(L) { throw errob; }); // without a native error handler pcall should be -1 - expect(lua.lua_pcall(L, 0, 0, 0)).toBe(-1); + expect(lua_pcall(L, 0, 0, 0)).toBe(-1); }); test('native error handler returns string', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let errob = {}; - lua.lua_atnativeerror(L, function(L) { - let e = lua.lua_touserdata(L, 1); + lua_atnativeerror(L, function(L) { + let e = lua_touserdata(L, 1); expect(e).toBe(errob); - lua.lua_pushstring(L, to_luastring("runtime error!")); + lua_pushstring(L, to_luastring("runtime error!")); return 1; }); - lua.lua_pushcfunction(L, function(L) { + lua_pushcfunction(L, function(L) { throw errob; }); - expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN); - expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!"); + expect(lua_pcall(L, 0, 0, 0)).toBe(LUA_ERRRUN); + expect(lua_tojsstring(L, -1)).toBe("runtime error!"); }); test('native error handler rethrows lua error', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let errob = {}; - lua.lua_atnativeerror(L, function(L) { - let e = lua.lua_touserdata(L, 1); + lua_atnativeerror(L, function(L) { + let e = lua_touserdata(L, 1); expect(e).toBe(errob); - lauxlib.luaL_error(L, to_luastring("runtime error!")); + luaL_error(L, to_luastring("runtime error!")); }); - lua.lua_pushcfunction(L, function(L) { + lua_pushcfunction(L, function(L) { throw errob; }); - expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN); - expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!"); + expect(lua_pcall(L, 0, 0, 0)).toBe(LUA_ERRRUN); + expect(lua_tojsstring(L, -1)).toBe("runtime error!"); }); }); describe('lua_len', () => { test('table with two potential boundaries', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_createtable(L); + lua_createtable(L); for (let i=3; i<=8; i++) { - lua.lua_pushinteger(L, i); - lua.lua_seti(L, -2, i); + lua_pushinteger(L, i); + lua_seti(L, -2, i); } - lua.lua_len(L, -1); + lua_len(L, -1); } // could be 0 or 8 - let len = lua.lua_tointeger(L, -1); + let len = lua_tointeger(L, -1); expect(len == 0 || len == 8).toBe(true); }); test('pathological case', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_createtable(L); + lua_createtable(L); let i = 1; for (let j=1; j<=1023; j++) { - lua.lua_pushnumber(L, i); - lua.lua_pushnumber(L, i); - lua.lua_settable(L, -3); + lua_pushnumber(L, i); + lua_pushnumber(L, i); + lua_settable(L, -3); i *= 2; } - lua.lua_len(L, -1); + lua_len(L, -1); } /* is allowed to be a power of 2 larger than 2 however if the result ever changes from 2 then the pathological code path has probably moved */ - let len = lua.lua_tointeger(L, -1); + let len = lua_tointeger(L, -1); expect(len).toBe(2); }); }); diff --git a/test/lauxlib.test.js b/test/lauxlib.test.js index 62198ac4..1f8dd345 100644 --- a/test/lauxlib.test.js +++ b/test/lauxlib.test.js @@ -1,22 +1,20 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +import { lua_pushstring, LUA_REGISTRYINDEX, lua_rawgeti, lua_tojsstring } from '../src/lua.js'; +import { luaL_newstate, luaL_ref, luaL_unref } from "../src/lauxlib.js"; +import { to_luastring } from "../src/fengaricore.js"; test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); { - lua.lua_pushstring(L, to_luastring("hello references!")); + lua_pushstring(L, to_luastring("hello references!")); - let r = lauxlib.luaL_ref(L, lua.LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference - lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, r); // pushes a value associated with the reference - lauxlib.luaL_unref(L, lua.LUA_REGISTRYINDEX, r); // releases the reference + let r = luaL_ref(L, LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference + lua_rawgeti(L, LUA_REGISTRYINDEX, r); // pushes a value associated with the reference + luaL_unref(L, LUA_REGISTRYINDEX, r); // releases the reference } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello references!"); }); diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js index dc30a984..12cb0e09 100644 --- a/test/lbaselib.test.js +++ b/test/lbaselib.test.js @@ -1,28 +1,26 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_toboolean, lua_pcall, lua_tointeger, lua_topointer, lua_isnil, lua_tonumber } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('print', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` print("hello", "world", 123) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } }); test('setmetatable, getmetatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -39,20 +37,20 @@ test('setmetatable, getmetatable', () => { return t[1], getmetatable(t) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)) + expect(lua_tojsstring(L, -2)) .toBe("hello"); - expect(lua.lua_istable(L, -1)).toBe(true); + expect(lua_istable(L, -1)).toBe(true); }); test('rawequal', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -70,19 +68,19 @@ test('rawequal', () => { return rawequal(t1, t2), t1 == t2 `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -2)).toBe(false); + expect(lua_toboolean(L, -2)).toBe(false); - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('rawset, rawget', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -102,91 +100,91 @@ test('rawset, rawget', () => { return rawget(t, "yo"), t["yo"], rawget(t, "yoyo"), t["yoyo"] `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -4)) + expect(lua_tojsstring(L, -4)) .toBe("hello"); - expect(lua.lua_tojsstring(L, -3)) + expect(lua_tojsstring(L, -3)) .toBe("hello"); - expect(lua.lua_tojsstring(L, -2)) + expect(lua_tojsstring(L, -2)) .toBe("bye"); - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("bye"); }); test('type', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return type(1), type(true), type("hello"), type({}), type(nil) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -5)) + expect(lua_tojsstring(L, -5)) .toBe("number"); - expect(lua.lua_tojsstring(L, -4)) + expect(lua_tojsstring(L, -4)) .toBe("boolean"); - expect(lua.lua_tojsstring(L, -3)) + expect(lua_tojsstring(L, -3)) .toBe("string"); - expect(lua.lua_tojsstring(L, -2)) + expect(lua_tojsstring(L, -2)) .toBe("table"); - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("nil"); }); test('error', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` error("you fucked up") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); expect(() => { - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); }).toThrow(/you fucked up/); } }); test('error, protected', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` error("you fucked up") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)).toMatch(/you fucked up/); + expect(lua_tojsstring(L, -1)).toMatch(/you fucked up/); }); test('pcall', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -197,17 +195,17 @@ test('pcall', () => { return pcall(willFail) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toMatch(/you fucked up/); + expect(lua_tojsstring(L, -1)).toMatch(/you fucked up/); }); test('xpcall', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -222,17 +220,17 @@ test('xpcall', () => { return xpcall(willFail, msgh) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toMatch(/Something's wrong: .*you fucked up/); + expect(lua_tojsstring(L, -1)).toMatch(/Something's wrong: .*you fucked up/); }); test('ipairs', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -246,41 +244,41 @@ test('ipairs', () => { return sum `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(15); + expect(lua_tointeger(L, -1)).toBe(15); }); test('select', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return {select('#', 1, 2, 3)}, {select(2, 1, 2, 3)}, {select(-2, 1, 2, 3)} `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -3).strong.entries()].map(e => e[1].value.value)) + expect([...lua_topointer(L, -3).strong.entries()].map(e => e[1].value.value)) .toEqual([3]); - expect([...lua.lua_topointer(L, -2).strong.entries()].map(e => e[1].value.value).sort()) + expect([...lua_topointer(L, -2).strong.entries()].map(e => e[1].value.value).sort()) .toEqual([2, 3]); - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort()) .toEqual([2, 3]); }); test('tonumber', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -291,56 +289,56 @@ test('tonumber', () => { tonumber('10', 2) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_isnil(L, -5)).toBe(true); - expect(lua.lua_tonumber(L, -4)).toBe(123); - expect(lua.lua_tonumber(L, -3)).toBe(12.3); - expect(lua.lua_tonumber(L, -2)).toBe(395); - expect(lua.lua_tonumber(L, -1)).toBe(2); + expect(lua_isnil(L, -5)).toBe(true); + expect(lua_tonumber(L, -4)).toBe(123); + expect(lua_tonumber(L, -3)).toBe(12.3); + expect(lua_tonumber(L, -2)).toBe(395); + expect(lua_tonumber(L, -1)).toBe(2); }); test('assert', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(1 < 0, "this doesn't makes sense") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)).toMatch(/this doesn't makes sense/); + expect(lua_tojsstring(L, -1)).toMatch(/this doesn't makes sense/); }); test('rawlen', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return rawlen({1, 2, 3}), rawlen('hello') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -2)).toBe(3); - expect(lua.lua_tonumber(L, -1)).toBe(5); + expect(lua_tonumber(L, -2)).toBe(3); + expect(lua_tonumber(L, -1)).toBe(5); }); test('next', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -359,17 +357,17 @@ test('next', () => { return total `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(10); + expect(lua_tonumber(L, -1)).toBe(10); }); test('pairs', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -388,17 +386,17 @@ test('pairs', () => { return total `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(10); + expect(lua_tonumber(L, -1)).toBe(10); }); test('pairs with __pairs', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -426,10 +424,10 @@ test('pairs with __pairs', () => { return total `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(26); + expect(lua_tonumber(L, -1)).toBe(26); }); diff --git a/test/lcorolib.test.js b/test/lcorolib.test.js index e9ad8ed4..8418665a 100644 --- a/test/lcorolib.test.js +++ b/test/lcorolib.test.js @@ -1,13 +1,11 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const lstate = require('../src/lstate.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tonumber, lua_tojsstring, lua_toboolean, lua_tothread } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { lua_State } from '../src/lstate.js'; +import { to_luastring } from "../src/fengaricore.js"; test('coroutine.create, coroutine.yield, coroutine.resume', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -22,18 +20,18 @@ test('coroutine.create, coroutine.yield, coroutine.resume', () => { return pow `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)) + expect(lua_tonumber(L, -1)) .toBe(625); }); test('coroutine.status', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -54,21 +52,21 @@ test('coroutine.status', () => { return s1, s2 `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)) + expect(lua_tojsstring(L, -2)) .toBe("suspended"); - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("dead"); }); test('coroutine.isyieldable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -81,18 +79,18 @@ test('coroutine.isyieldable', () => { return yieldable, coroutine.isyieldable() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -2)).toBe(true); - expect(lua.lua_toboolean(L, -1)).toBe(false); + expect(lua_toboolean(L, -2)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(false); }); test('coroutine.running', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -107,18 +105,18 @@ test('coroutine.running', () => { return running, ismain `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tothread(L, -2)).toBeInstanceOf(lstate.lua_State); - expect(lua.lua_toboolean(L, -1)).toBe(false); + expect(lua_tothread(L, -2)).toBeInstanceOf(lua_State); + expect(lua_toboolean(L, -1)).toBe(false); }); test('coroutine.wrap', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -133,11 +131,11 @@ test('coroutine.wrap', () => { return pow `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)) + expect(lua_tonumber(L, -1)) .toBe(625); }); diff --git a/test/ldblib.test.js b/test/ldblib.test.js index ba68853a..879123e7 100644 --- a/test/ldblib.test.js +++ b/test/ldblib.test.js @@ -1,5 +1,3 @@ -"use strict"; - const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); diff --git a/test/ldebug.test.js b/test/ldebug.test.js index d52cfcba..69f98f0e 100644 --- a/test/ldebug.test.js +++ b/test/ldebug.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_pcall, lua_tojsstring } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('luaG_typeerror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -14,18 +12,18 @@ test('luaG_typeerror', () => { return #a `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("attempt to get length of a boolean value (local 'a')"); }); test('luaG_typeerror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -33,18 +31,18 @@ test('luaG_typeerror', () => { return a.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("attempt to index a boolean value (local 'a')"); }); test('luaG_typeerror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -52,18 +50,18 @@ test('luaG_typeerror', () => { return a.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("attempt to index a boolean value (local 'a')"); }); test('luaG_typeerror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -71,65 +69,65 @@ test('luaG_typeerror', () => { a.yo = 1 `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("attempt to index a boolean value (local 'a')"); }); test('luaG_concaterror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return {} .. 'hello' `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("attempt to concatenate a table value"); }); test('luaG_opinterror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return {} + 'hello' `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("attempt to perform arithmetic on a table value"); }); test('luaG_tointerror', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return 123.5 & 12 `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_pcall(L, 0, -1, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_pcall(L, 0, -1, 0); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toMatch("number has no integer representation"); }); diff --git a/test/lexparse.test.js b/test/lexparse.test.js index a9407ed9..5ef59894 100644 --- a/test/lexparse.test.js +++ b/test/lexparse.test.js @@ -1,14 +1,12 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const lstring = require("../src/lstring.js"); -const {to_luastring} = require("../src/fengaricore.js"); +import { lua_load, lua_call, lua_tojsstring, lua_type, LUA_TTABLE, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from '../src/lua.js'; +import { luaL_newstate } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { luaS_hash } from "../src/lstring.js"; +import { to_luastring } from "../src/fengaricore.js"; // Roughly the same tests as test/lvm.js to cover all opcodes test('LOADK, RETURN', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -16,23 +14,23 @@ test('LOADK, RETURN', () => { return a `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe("hello world"); }); test('MOVE', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -41,23 +39,23 @@ test('MOVE', () => { return b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe("hello world"); }); test('Binary op', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -66,15 +64,15 @@ test('Binary op', () => { return a + b, a - b, a * b, a / b, a % b, a^b, a // b, a & b, a | b, a ~ b, a << b, a >> b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 12, L.top).map(e => e.value)) @@ -83,7 +81,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -92,15 +90,15 @@ test('Unary op, LOADBOOL', () => { return -a, not b, ~a `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.value)) @@ -109,7 +107,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -117,23 +115,23 @@ test('NEWTABLE', () => { return a `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_type(L, -1)).toBe(lua.LUA_TTABLE); + expect(lua_type(L, -1)).toBe(LUA_TTABLE); }); test('CALL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -146,22 +144,22 @@ test('CALL', () => { return c `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(3); + expect(lua_tointeger(L, -1)).toBe(3); }); test('Multiple return', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -178,15 +176,15 @@ test('Multiple return', () => { return c, d, e `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.value)) @@ -195,7 +193,7 @@ test('Multiple return', () => { test('TAILCALL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -206,23 +204,23 @@ test('TAILCALL', () => { return f(1,2) `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(3); + expect(lua_tointeger(L, -1)).toBe(3); }); test('VARARG', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -233,15 +231,15 @@ test('VARARG', () => { return f(1,2,3) `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.value)) @@ -250,7 +248,7 @@ test('VARARG', () => { test('LE, JMP', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -259,23 +257,23 @@ test('LE, JMP', () => { return a >= b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('LT', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -284,23 +282,23 @@ test('LT', () => { return a > b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(false); + expect(lua_toboolean(L, -1)).toBe(false); }); test('EQ', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -309,23 +307,23 @@ test('EQ', () => { return a == b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('TESTSET (and)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -335,23 +333,23 @@ test('TESTSET (and)', () => { return a and b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('TESTSET (or)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -361,23 +359,23 @@ test('TESTSET (or)', () => { return a or b `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('TEST (false)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -391,23 +389,23 @@ test('TEST (false)', () => { return "goodbye" `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("goodbye"); + expect(lua_tojsstring(L, -1)).toBe("goodbye"); }); test('FORPREP, FORLOOP (int)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -420,23 +418,23 @@ test('FORPREP, FORLOOP (int)', () => { return total `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(55); + expect(lua_tointeger(L, -1)).toBe(55); }); test('FORPREP, FORLOOP (float)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -449,23 +447,23 @@ test('FORPREP, FORLOOP (float)', () => { return total `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(60.5); + expect(lua_tonumber(L, -1)).toBe(60.5); }); test('SETTABLE, GETTABLE', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -477,26 +475,26 @@ test('SETTABLE, GETTABLE', () => { return t `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) .toBe("world"); }); test('SETUPVAL, GETUPVAL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -511,23 +509,23 @@ test('SETUPVAL, GETUPVAL', () => { return f() `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); + expect(lua_tojsstring(L, -1)).toBe("world"); }); test('SETTABUP, GETTABUP', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -539,26 +537,26 @@ test('SETTABUP, GETTABUP', () => { return t `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) .toBe("world"); }); test('SELF', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -572,23 +570,23 @@ test('SELF', () => { return t:get() `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('SETLIST', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -597,24 +595,24 @@ test('SETLIST', () => { return t `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort()) .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); }); test('Variable SETLIST', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -627,23 +625,23 @@ test('Variable SETLIST', () => { return t `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort()) .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); }); test('Long SETLIST', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -652,24 +650,24 @@ test('Long SETLIST', () => { return t `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) .toEqual([1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]); }); test('TFORCALL, TFORLOOP', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -694,23 +692,23 @@ test('TFORCALL, TFORLOOP', () => { return r `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(6); + expect(lua_tonumber(L, -1)).toBe(6); }); test('LEN', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -721,41 +719,41 @@ test('LEN', () => { return #t, #t2, #s `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(5); - expect(lua.lua_tonumber(L, -2)).toBe(3); - expect(lua.lua_tonumber(L, -3)).toBe(0); + expect(lua_tonumber(L, -1)).toBe(5); + expect(lua_tonumber(L, -2)).toBe(3); + expect(lua_tonumber(L, -3)).toBe(0); }); test('CONCAT', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return "hello " .. 2 .. " you" `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you"); + expect(lua_tojsstring(L, -1)).toBe("hello 2 you"); }); diff --git a/test/lmathlib.test.js b/test/lmathlib.test.js index 0ee0b1c8..68fca7dc 100644 --- a/test/lmathlib.test.js +++ b/test/lmathlib.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tointeger, lua_tonumber, lua_tojsstring, lua_toboolean } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -14,132 +12,132 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', math.asin(1), math.acos(0.5), math.atan(10) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -7)).toBe(10); - expect(lua.lua_tonumber(L, -6)).toBe(10.5); - expect(lua.lua_tonumber(L, -5)).toBe(-0.8390715290764524); - expect(lua.lua_tonumber(L, -4)).toBe(0.6483608274590866); - expect(lua.lua_tonumber(L, -3)).toBe(1.5707963267948966); - expect(lua.lua_tonumber(L, -2)).toBe(1.0471975511965979); - expect(lua.lua_tonumber(L, -1)).toBe(1.4711276743037347); + expect(lua_tointeger(L, -7)).toBe(10); + expect(lua_tonumber(L, -6)).toBe(10.5); + expect(lua_tonumber(L, -5)).toBe(-0.8390715290764524); + expect(lua_tonumber(L, -4)).toBe(0.6483608274590866); + expect(lua_tonumber(L, -3)).toBe(1.5707963267948966); + expect(lua_tonumber(L, -2)).toBe(1.0471975511965979); + expect(lua_tonumber(L, -1)).toBe(1.4711276743037347); }); test('math.ceil, math.floor', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.ceil(10.5), math.floor(10.5) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -2)).toBe(11); - expect(lua.lua_tointeger(L, -1)).toBe(10); + expect(lua_tointeger(L, -2)).toBe(11); + expect(lua_tointeger(L, -1)).toBe(10); }); test('math.deg, math.rad', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.deg(10), math.rad(10) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -2)).toBe(572.9577951308232); - expect(lua.lua_tonumber(L, -1)).toBe(0.17453292519943295); + expect(lua_tonumber(L, -2)).toBe(572.9577951308232); + expect(lua_tonumber(L, -1)).toBe(0.17453292519943295); }); test('math.log', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.log(10), math.log(10, 2), math.log(10, 10) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -3)).toBe(2.302585092994046); - expect(lua.lua_tonumber(L, -2)).toBe(3.321928094887362); - expect(lua.lua_tonumber(L, -1)).toBe(1); + expect(lua_tonumber(L, -3)).toBe(2.302585092994046); + expect(lua_tonumber(L, -2)).toBe(3.321928094887362); + expect(lua_tonumber(L, -1)).toBe(1); }); /* Node.js 6 has incorrect results for Math.exp */ (parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.exp(10) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(22026.465794806718); + expect(lua_tonumber(L, -1)).toBe(22026.465794806718); }); test('math.min, math.max', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.max(10, 5, 23), math.min(10, 5, 23) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -2)).toBe(23); - expect(lua.lua_tonumber(L, -1)).toBe(5); + expect(lua_tonumber(L, -2)).toBe(23); + expect(lua_tonumber(L, -1)).toBe(5); }); test('math.random', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.random(), math.random(10, 15) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } { - let r = expect(lua.lua_tonumber(L, -2)); + let r = expect(lua_tonumber(L, -2)); r.toBeGreaterThanOrEqual(0); r.toBeLessThanOrEqual(1); } { - let r = expect(lua.lua_tonumber(L, -1)); + let r = expect(lua_tonumber(L, -1)); r.toBeGreaterThanOrEqual(10); r.toBeLessThanOrEqual(15); } @@ -147,105 +145,105 @@ test('math.random', () => { test('math.sqrt', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.sqrt(10) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(3.1622776601683795); + expect(lua_tonumber(L, -1)).toBe(3.1622776601683795); }); test('math.tointeger', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.tointeger('10') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(10); + expect(lua_tonumber(L, -1)).toBe(10); }); test('math.type', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.type(10), math.type(10.5), math.type('hello') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -3)).toBe("integer"); - expect(lua.lua_tojsstring(L, -2)).toBe("float"); - expect(lua.lua_tojsstring(L, -1)).toBe(null); + expect(lua_tojsstring(L, -3)).toBe("integer"); + expect(lua_tojsstring(L, -2)).toBe("float"); + expect(lua_tojsstring(L, -1)).toBe(null); }); test('math.ult', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.ult(5, 200) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('math.fmod', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.fmod(2,5) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(2); + expect(lua_tonumber(L, -1)).toBe(2); }); test('math.modf', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return math.modf(3.4, 0.6) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -2)).toBe(3); - expect(lua.lua_tonumber(L, -1)).toBe(0.3999999999999999); + expect(lua_tonumber(L, -2)).toBe(3); + expect(lua_tonumber(L, -1)).toBe(0.3999999999999999); }); diff --git a/test/load.test.js b/test/load.test.js index e8f39ea4..c8870c6b 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -1,14 +1,12 @@ -"use strict"; +import { toByteCode } from "./tests.js"; -const {toByteCode} = require("./tests.js"); - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tojsstring } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('luaL_loadstring', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -16,17 +14,17 @@ test('luaL_loadstring', () => { return a `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello world"); }); test('load', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -34,17 +32,17 @@ test('load', () => { return f() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("js running lua running lua"); }); test('undump empty string', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -54,15 +52,15 @@ test('undump empty string', () => { end)))() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, 0); } }); test('luaL_loadbuffer', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -70,18 +68,18 @@ test('luaL_loadbuffer', () => { return a `; { - lualib.luaL_openlibs(L); + luaL_openlibs(L); let bc = toByteCode(luaCode); - lauxlib.luaL_loadbuffer(L, bc, null, to_luastring("test")); - lua.lua_call(L, 0, -1); + luaL_loadbuffer(L, bc, null, to_luastring("test")); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello world"); }); // TODO: test stdin test('loadfile', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -89,17 +87,17 @@ test('loadfile', () => { return f() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello world"); }); test('loadfile (binary)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -107,27 +105,27 @@ test('loadfile (binary)', () => { return f() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello world"); }); test('dofile', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return dofile("test/loadfile-test.lua") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)) + expect(lua_tojsstring(L, -1)) .toBe("hello world"); }); diff --git a/test/loadlib.test.js b/test/loadlib.test.js index c0125c08..3f28600c 100644 --- a/test/loadlib.test.js +++ b/test/loadlib.test.js @@ -1,73 +1,71 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_istable, lua_tojsstring } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('require an existing module', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return require('os') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_istable(L, -1)).toBe(true); + expect(lua_istable(L, -1)).toBe(true); }); test('require a file', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return require('test.module-hello')() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello from module"); + expect(lua_tojsstring(L, -1)).toBe("hello from module"); }); test('package.loadlib', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return package.loadlib('./test/lib-hello.js.mod', 'hello')() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello from js lib"); + expect(lua_tojsstring(L, -1)).toBe("hello from js lib"); }); test('package.searchpath', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return package.searchpath('module-hello', './?.lua;./test/?.lua') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("./test/module-hello.lua"); + expect(lua_tojsstring(L, -1)).toBe("./test/module-hello.lua"); }); diff --git a/test/loslib.test.js b/test/loslib.test.js index af7de92a..202e50c3 100644 --- a/test/loslib.test.js +++ b/test/loslib.test.js @@ -1,29 +1,27 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_isinteger, lua_tointeger, lua_isnumber, lua_tojsstring, lua_isstring } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('os.time', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.time() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_isinteger(L, -1)).toBe(true); + expect(lua_isinteger(L, -1)).toBe(true); }); test('os.time (with format)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -34,18 +32,18 @@ test('os.time (with format)', () => { }) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)) + expect(lua_tointeger(L, -1)) .toBe(new Date(2015, 1, 8, 12, 0, 0, 0).getTime() / 1000); }); test('os.difftime', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -54,17 +52,17 @@ test('os.difftime', () => { return os.difftime(t2, t1) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_isnumber(L, -1)).toBe(true); + expect(lua_isnumber(L, -1)).toBe(true); }); test('os.date', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -75,17 +73,17 @@ test('os.date', () => { })) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("2015-02-08"); + expect(lua_tojsstring(L, -1)).toBe("2015-02-08"); }); test('os.date normalisation', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -96,17 +94,17 @@ test('os.date normalisation', () => { })) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("2013-11-30"); + expect(lua_tojsstring(L, -1)).toBe("2013-11-30"); }); test('os.time normalisation of table', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -122,14 +120,14 @@ test('os.time normalisation of table', () => { assert(t.wday == 3, "correct wday") assert(t.yday == 51, "correct yday") `; - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, 0); }); test('os.setlocale', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -139,24 +137,24 @@ test('os.setlocale', () => { assert("C" == os.setlocale("POSIX")) assert(nil == os.setlocale("any_other_locale")) `; - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, 0); }); test('os.getenv', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return os.getenv('PATH') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_isstring(L, -1)).toBe(true); + expect(lua_isstring(L, -1)).toBe(true); }); diff --git a/test/lstrlib.test.js b/test/lstrlib.test.js index 3ae2ec3f..a611ced5 100644 --- a/test/lstrlib.test.js +++ b/test/lstrlib.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring, lua_tostring, lua_load, lua_toboolean, lua_gettop } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('string.len', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -14,159 +12,159 @@ test('string.len', () => { return string.len("hello"), a:len() `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -2)).toBe(5); - expect(lua.lua_tointeger(L, -1)).toBe(5); + expect(lua_tointeger(L, -2)).toBe(5); + expect(lua_tointeger(L, -1)).toBe(5); }); test('string.char', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.char(104, 101, 108, 108, 111) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('string.upper, string.lower', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.upper("hello"), string.lower("HELLO") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("HELLO"); - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -2)).toBe("HELLO"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('string.rep', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.rep("hello", 3, ", ") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello, hello, hello"); + expect(lua_tojsstring(L, -1)).toBe("hello, hello, hello"); }); test('string.reverse', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.reverse("olleh") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('string.byte', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.byte("hello", 2, 4) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -3)).toBe(101); - expect(lua.lua_tointeger(L, -2)).toBe(108); - expect(lua.lua_tointeger(L, -1)).toBe(108); + expect(lua_tointeger(L, -3)).toBe(101); + expect(lua_tointeger(L, -2)).toBe(108); + expect(lua_tointeger(L, -1)).toBe(108); }); test('string.format', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.format("%%%d %010d", 10, 23) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("%10 0000000023"); + expect(lua_tojsstring(L, -1)).toBe("%10 0000000023"); }); test('string.format', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.format("%07X", 0xFFFFFFF) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("FFFFFFF"); + expect(lua_tojsstring(L, -1)).toBe("FFFFFFF"); }); test('string.format', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.format("%q", 'a string with "quotes" and \\n new line') `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe('"a string with \\"quotes\\" and \\\n new line"', + expect(lua_tojsstring(L, -1)).toBe('"a string with \\"quotes\\" and \\\n new line"', "Correct element(s) on the stack" ); }); test('string.sub', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -183,27 +181,27 @@ test('string.sub', () => { string.sub("123456789",-6, -4) -- "456" `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -11)).toBe("234"); - expect(lua.lua_tojsstring(L, -10)).toBe("789"); - expect(lua.lua_tojsstring(L, -9)).toBe(""); - expect(lua.lua_tojsstring(L, -8)).toBe("7"); - expect(lua.lua_tojsstring(L, -7)).toBe(""); - expect(lua.lua_tojsstring(L, -6)).toBe("123456789"); - expect(lua.lua_tojsstring(L, -5)).toBe("123456789"); - expect(lua.lua_tojsstring(L, -4)).toBe(""); - expect(lua.lua_tojsstring(L, -3)).toBe("9"); - expect(lua.lua_tojsstring(L, -2)).toBe("6789"); - expect(lua.lua_tojsstring(L, -1)).toBe("456"); + expect(lua_tojsstring(L, -11)).toBe("234"); + expect(lua_tojsstring(L, -10)).toBe("789"); + expect(lua_tojsstring(L, -9)).toBe(""); + expect(lua_tojsstring(L, -8)).toBe("7"); + expect(lua_tojsstring(L, -7)).toBe(""); + expect(lua_tojsstring(L, -6)).toBe("123456789"); + expect(lua_tojsstring(L, -5)).toBe("123456789"); + expect(lua_tojsstring(L, -4)).toBe(""); + expect(lua_tojsstring(L, -3)).toBe("9"); + expect(lua_tojsstring(L, -2)).toBe("6789"); + expect(lua_tojsstring(L, -1)).toBe("456"); }); test('string.dump', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -219,24 +217,24 @@ test('string.dump', () => { return string.dump(todump) `; { - lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, to_luastring(luaCode.trim())); - lua.lua_call(L, 0, -1); - let str = lua.lua_tostring(L, -1); - lua.lua_load(L, function(L, s) { + luaL_openlibs(L); + luaL_loadstring(L, to_luastring(luaCode.trim())); + lua_call(L, 0, -1); + let str = lua_tostring(L, -1); + lua_load(L, function(L, s) { let r = s.str; s.str = null; return r; }, {str: str}, to_luastring("test"), to_luastring("binary")); - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello1212.5"); + expect(lua_tojsstring(L, -1)).toBe("hello1212.5"); }); test('string.pack/unpack/packsize', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -246,93 +244,93 @@ test('string.pack/unpack/packsize', () => { return string.packsize("c5jc3"), s1 == us1 and n == un and s2 == us2 `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -2)).toBe(12); - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_tointeger(L, -2)).toBe(12); + expect(lua_toboolean(L, -1)).toBe(true); }); test('string.find without pattern', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.find("hello to you", " to ") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -2)).toBe(6); - expect(lua.lua_tointeger(L, -1)).toBe(9); + expect(lua_tointeger(L, -2)).toBe(6); + expect(lua_tointeger(L, -1)).toBe(9); }); test('string.find with special pattern (issue #185)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.find("-", "-") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_gettop(L)).toBe(2); - expect(lua.lua_tointeger(L, -2)).toBe(1); - expect(lua.lua_tointeger(L, -1)).toBe(1); + expect(lua_gettop(L)).toBe(2); + expect(lua_tointeger(L, -2)).toBe(1); + expect(lua_tointeger(L, -1)).toBe(1); }); test('string.match', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("foo"); - expect(lua.lua_tojsstring(L, -1)).toBe("123"); + expect(lua_tojsstring(L, -2)).toBe("foo"); + expect(lua_tojsstring(L, -1)).toBe("123"); }); test('string.find', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -4)).toBe(1); - expect(lua.lua_tointeger(L, -3)).toBe(8); - expect(lua.lua_tojsstring(L, -2)).toBe("foo"); - expect(lua.lua_tojsstring(L, -1)).toBe("123"); + expect(lua_tointeger(L, -4)).toBe(1); + expect(lua_tointeger(L, -3)).toBe(8); + expect(lua_tojsstring(L, -2)).toBe("foo"); + expect(lua_tojsstring(L, -1)).toBe("123"); }); test('string.gmatch', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -346,74 +344,74 @@ test('string.gmatch', () => { return table.unpack(t) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -4)).toBe("hello"); - expect(lua.lua_tojsstring(L, -3)).toBe("world"); - expect(lua.lua_tojsstring(L, -2)).toBe("from"); - expect(lua.lua_tojsstring(L, -1)).toBe("Lua"); + expect(lua_tojsstring(L, -4)).toBe("hello"); + expect(lua_tojsstring(L, -3)).toBe("world"); + expect(lua_tojsstring(L, -2)).toBe("from"); + expect(lua_tojsstring(L, -1)).toBe("Lua"); }); test('string.gsub', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("hello world", "(%w+)", "%1 %1") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world world"); - expect(lua.lua_tointeger(L, -1)).toBe(2); + expect(lua_tojsstring(L, -2)).toBe("hello hello world world"); + expect(lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (number)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("hello world", "%w+", "%0 %0", 1) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world"); - expect(lua.lua_tointeger(L, -1)).toBe(1); + expect(lua_tojsstring(L, -2)).toBe("hello hello world"); + expect(lua_tointeger(L, -1)).toBe(1); }); test('string.gsub (pattern)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("world hello Lua from"); - expect(lua.lua_tointeger(L, -1)).toBe(2); + expect(lua_tojsstring(L, -2)).toBe("world hello Lua from"); + expect(lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (function)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -422,19 +420,19 @@ test('string.gsub (function)', () => { end) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("4+5 = 9"); - expect(lua.lua_tointeger(L, -1)).toBe(1); + expect(lua_tojsstring(L, -2)).toBe("4+5 = 9"); + expect(lua_tointeger(L, -1)).toBe(1); }); test('string.gsub (table)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -442,11 +440,11 @@ test('string.gsub (table)', () => { return string.gsub("$name-$version.tar.gz", "%$(%w+)", t) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -2)).toBe("lua-5.3.tar.gz"); - expect(lua.lua_tointeger(L, -1)).toBe(2); + expect(lua_tojsstring(L, -2)).toBe("lua-5.3.tar.gz"); + expect(lua_tointeger(L, -1)).toBe(2); }); diff --git a/test/ltablib.test.js b/test/ltablib.test.js index 2cce1189..42771ef1 100644 --- a/test/ltablib.test.js +++ b/test/ltablib.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tojsstring, lua_topointer, lua_tointeger } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; const inttable2array = function(t) { let a = []; @@ -15,36 +13,36 @@ const inttable2array = function(t) { }; test('table.concat', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return table.concat({1, 2, 3, 4, 5, 6, 7}, ",", 3, 5) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("3,4,5"); + expect(lua_tojsstring(L, -1)).toBe("3,4,5"); }); test('table.pack', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return table.pack(1, 2, 3) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()] + expect([...lua_topointer(L, -1).strong.entries()] .filter(e => e[1].key.ttisnumber()) // Filter out the 'n' field .map(e => e[1].value.value).reverse() ).toEqual([1, 2, 3]); @@ -52,26 +50,26 @@ test('table.pack', () => { test('table.unpack', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return table.unpack({1, 2, 3, 4, 5}, 2, 4) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -3)).toBe(2); - expect(lua.lua_tointeger(L, -2)).toBe(3); - expect(lua.lua_tointeger(L, -1)).toBe(4); + expect(lua_tointeger(L, -3)).toBe(2); + expect(lua_tointeger(L, -2)).toBe(3); + expect(lua_tointeger(L, -1)).toBe(4); }); test('table.insert', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -81,13 +79,13 @@ test('table.insert', () => { return t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect( - [...lua.lua_topointer(L, -1).strong.entries()] + [...lua_topointer(L, -1).strong.entries()] .filter(e => e[1].key.ttisnumber()) .map(e => e[1].value.value).sort() ).toEqual([1, 2, 3, 4, 5]); @@ -95,7 +93,7 @@ test('table.insert', () => { test('table.remove', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -105,13 +103,13 @@ test('table.remove', () => { return t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect( - [...lua.lua_topointer(L, -1).strong.entries()] + [...lua_topointer(L, -1).strong.entries()] .filter(e => e[1].key.ttisnumber()) .map(e => e[1].value.value).sort() ).toEqual([1, 2, 3, 4]); @@ -119,7 +117,7 @@ test('table.remove', () => { test('table.move', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -128,13 +126,13 @@ test('table.move', () => { return table.move(t1, 1, #t1, 3, t2) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect( - [...lua.lua_topointer(L, -1).strong.entries()] + [...lua_topointer(L, -1).strong.entries()] .filter(e => e[1].key.ttisnumber()) .map(e => e[1].value.value).sort() ).toEqual([1, 2, 3, 4, 5, 6]); @@ -142,7 +140,7 @@ test('table.move', () => { test('table.sort (<)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -151,18 +149,18 @@ test('table.sort (<)', () => { return t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(inttable2array(lua.lua_topointer(L, -1))) + expect(inttable2array(lua_topointer(L, -1))) .toEqual([1, 2, 3, 4, 5]); }); test('table.sort with cmp function', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -173,11 +171,11 @@ test('table.sort with cmp function', () => { return t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(inttable2array(lua.lua_topointer(L, -1))) + expect(inttable2array(lua_topointer(L, -1))) .toEqual([5, 4, 3, 2, 1]); }); diff --git a/test/ltm.test.js b/test/ltm.test.js index c4e03da8..ec844b74 100644 --- a/test/ltm.test.js +++ b/test/ltm.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_isnil, lua_tointeger, lua_tojsstring, lua_toboolean } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; test('__index, __newindex: with actual table', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -14,18 +12,18 @@ test('__index, __newindex: with actual table', () => { return t.yo, t.lo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_isnil(L, -1)).toBe(true); - expect(lua.lua_tointeger(L, -2)).toBe(1); + expect(lua_isnil(L, -1)).toBe(true); + expect(lua_tointeger(L, -2)).toBe(1); }); test('__newindex: with non table', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -33,18 +31,18 @@ test('__newindex: with non table', () => { t.yo = "hello" `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); } expect(() => { - lua.lua_call(L, 0, -1); + lua_call(L, 0, -1); }).toThrow(); }); test('__index function in metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -61,17 +59,17 @@ test('__index function in metatable', () => { return t.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("__index"); + expect(lua_tojsstring(L, -1)).toBe("__index"); }); test('__newindex function in metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -90,17 +88,17 @@ test('__newindex function in metatable', () => { return t.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_isnil(L, -1)).toBe(true); + expect(lua_isnil(L, -1)).toBe(true); }); test('__index table in metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -119,17 +117,17 @@ test('__index table in metatable', () => { return t.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('__newindex table in metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -150,18 +148,18 @@ test('__newindex table in metatable', () => { return t.yo, mmt.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); - expect(lua.lua_isnil(L, -2)).toBe(true); + expect(lua_tojsstring(L, -1)).toBe("world"); + expect(lua_isnil(L, -2)).toBe(true); }); test('__index table with own metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -188,17 +186,17 @@ test('__index table with own metatable', () => { return t.yo `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('__newindex table with own metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -229,18 +227,18 @@ test('__newindex table with own metatable', () => { return t.yo, up `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); - expect(lua.lua_isnil(L, -2)).toBe(true); + expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_isnil(L, -2)).toBe(true); }); test('binary __xxx functions in metatable', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -314,9 +312,9 @@ test('binary __xxx functions in metatable', () => { t >> 1 `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 12, L.top).map(e => e.jsstring())) @@ -338,7 +336,7 @@ test('binary __xxx functions in metatable', () => { test('__eq', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -355,17 +353,17 @@ test('__eq', () => { return t == {} `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('__lt', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -382,17 +380,17 @@ test('__lt', () => { return t < {} `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('__le', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -409,17 +407,17 @@ test('__le', () => { return t <= {} `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('__le that uses __lt', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -436,17 +434,17 @@ test('__le that uses __lt', () => { return {} <= t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('__unm, __bnot', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -467,18 +465,18 @@ test('__unm, __bnot', () => { return -t, ~t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); - expect(lua.lua_tojsstring(L, -2)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("world"); + expect(lua_tojsstring(L, -2)).toBe("hello"); }); test('__len', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -495,17 +493,17 @@ test('__len', () => { return #t `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('__concat', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -522,17 +520,17 @@ test('__concat', () => { return t .. " world" `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('__call', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -549,9 +547,9 @@ test('__call', () => { return t("world","wow") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.jsstring())) diff --git a/test/lua.test.js b/test/lua.test.js index 0f12238b..8520dcd1 100644 --- a/test/lua.test.js +++ b/test/lua.test.js @@ -1,13 +1,11 @@ -"use strict"; - -const lua = require('../src/lua.js'); -const lauxlib = require('../src/lauxlib.js'); -const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from "../src/fengaricore.js"; // TODO: remove test.skip('locals.lua', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -16,15 +14,15 @@ test.skip('locals.lua', () => { return dofile("tests/lua-tests/locals.lua") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } }); test.skip('constructs.lua', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -33,30 +31,30 @@ test.skip('constructs.lua', () => { return dofile("tests/lua-tests/constructs.lua") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } }); test.skip('strings.lua', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return dofile("tests/lua-tests/strings.lua") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } }); test('__newindex leaves nils', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -71,8 +69,8 @@ test('__newindex leaves nils', () => { end `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } }); diff --git a/test/lutf8lib.test.js b/test/lutf8lib.test.js index d2d51b31..af38dfc4 100644 --- a/test/lutf8lib.test.js +++ b/test/lutf8lib.test.js @@ -1,82 +1,80 @@ -"use strict"; - -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const lualib = require("../src/lualib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring } from "../src/lua.js"; +import { luaL_newstate, luaL_loadstring } from "../src/lauxlib.js"; +import { luaL_openlibs } from "../src/lualib.js"; +import { to_luastring } from "../src/fengaricore.js"; test('utf8.offset', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.offset("( ͡° ͜ʖ ͡° )", 5) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(7); + expect(lua_tointeger(L, -1)).toBe(7); }); test('utf8.codepoint', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -3)).toBe(176); - expect(lua.lua_tointeger(L, -2)).toBe(32); - expect(lua.lua_tointeger(L, -1)).toBe(860); + expect(lua_tointeger(L, -3)).toBe(176); + expect(lua_tointeger(L, -2)).toBe(32); + expect(lua_tointeger(L, -1)).toBe(860); }); test('utf8.char', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.char(40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 32, 41) `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("( ͡° ͜ʖ ͡° )"); + expect(lua_tojsstring(L, -1)).toBe("( ͡° ͜ʖ ͡° )"); }); test('utf8.len', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return utf8.len("( ͡° ͜ʖ ͡° )") `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(12); + expect(lua_tointeger(L, -1)).toBe(12); }); test('utf8.codes', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -88,10 +86,10 @@ test('utf8.codes', () => { return results `; { - lualib.luaL_openlibs(L); - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + luaL_openlibs(L); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] "); + expect(lua_tojsstring(L, -1)).toBe("[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] "); }); diff --git a/test/lvm.test.js b/test/lvm.test.js index daa4539f..3acb9a5e 100644 --- a/test/lvm.test.js +++ b/test/lvm.test.js @@ -1,13 +1,11 @@ -"use strict"; - -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const lstring = require("../src/lstring.js"); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from "../src/lua.js"; +import { luaL_newstate, luaL_loadstring } from "../src/lauxlib.js"; +import { luaS_hash } from "../src/lstring.js"; +import { to_luastring } from "../src/fengaricore.js"; test('LOADK, RETURN', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -15,16 +13,16 @@ test('LOADK, RETURN', () => { return a `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe("hello world"); }); test('MOVE', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -33,15 +31,15 @@ test('MOVE', () => { return b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe("hello world"); }); test('Binary op', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -50,8 +48,8 @@ test('Binary op', () => { return a + b, a - b, a * b, a / b, a % b, a^b, a // b, a & b, a | b, a ~ b, a << b, a >> b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 12, L.top).map(e => e.value)) @@ -60,7 +58,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -69,8 +67,8 @@ test('Unary op, LOADBOOL', () => { return -a, not b, ~a `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.value)) @@ -79,7 +77,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -87,16 +85,16 @@ test('NEWTABLE', () => { return a `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_istable(L, -1)).toBe(true); + expect(lua_istable(L, -1)).toBe(true); }); test('CALL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -109,16 +107,16 @@ test('CALL', () => { return c `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(3); + expect(lua_tointeger(L, -1)).toBe(3); }); test('Multiple return', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -135,8 +133,8 @@ test('Multiple return', () => { return c, d, e `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.value)) @@ -145,7 +143,7 @@ test('Multiple return', () => { test('TAILCALL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -156,16 +154,16 @@ test('TAILCALL', () => { return f(1,2) `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(3); + expect(lua_tointeger(L, -1)).toBe(3); }); test('VARARG', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -176,8 +174,8 @@ test('VARARG', () => { return f(1,2,3) `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } expect(L.stack.slice(L.top - 3, L.top).map(e => e.value)) @@ -186,7 +184,7 @@ test('VARARG', () => { test('LE, JMP', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -195,16 +193,16 @@ test('LE, JMP', () => { return a >= b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('LT', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -213,16 +211,16 @@ test('LT', () => { return a > b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(false); + expect(lua_toboolean(L, -1)).toBe(false); }); test('EQ', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -231,16 +229,16 @@ test('EQ', () => { return a == b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_toboolean(L, -1)).toBe(true); + expect(lua_toboolean(L, -1)).toBe(true); }); test('TESTSET (and)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -250,16 +248,16 @@ test('TESTSET (and)', () => { return a and b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('TESTSET (or)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -269,16 +267,16 @@ test('TESTSET (or)', () => { return a or b `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('TEST (true)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -292,16 +290,16 @@ test('TEST (true)', () => { return "goodbye" `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('TEST (false)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -315,16 +313,16 @@ test('TEST (false)', () => { return "goodbye" `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("goodbye"); + expect(lua_tojsstring(L, -1)).toBe("goodbye"); }); test('FORPREP, FORLOOP (int)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -337,16 +335,16 @@ test('FORPREP, FORLOOP (int)', () => { return total `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(55); + expect(lua_tointeger(L, -1)).toBe(55); }); test('FORPREP, FORLOOP (float)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -359,16 +357,16 @@ test('FORPREP, FORLOOP (float)', () => { return total `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tonumber(L, -1)).toBe(60.5); + expect(lua_tonumber(L, -1)).toBe(60.5); }); test('SETTABLE, GETTABLE', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -380,19 +378,19 @@ test('SETTABLE, GETTABLE', () => { return t `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) .toBe("world"); }); test('SETUPVAL, GETUPVAL', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -407,16 +405,16 @@ test('SETUPVAL, GETUPVAL', () => { return f() `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("world"); + expect(lua_tojsstring(L, -1)).toBe("world"); }); test('SETTABUP, GETTABUP', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -428,19 +426,19 @@ test('SETTABUP, GETTABUP', () => { return t `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) .toBe("world"); }); test('SELF', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -454,16 +452,16 @@ test('SELF', () => { return t:get() `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe("hello"); }); test('SETLIST', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -472,17 +470,17 @@ test('SETLIST', () => { return t `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); }); test('Variable SETLIST', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -495,17 +493,17 @@ test('Variable SETLIST', () => { return t `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); }); test('Long SETLIST', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -514,11 +512,11 @@ test('Long SETLIST', () => { return t `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) + expect([...lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse()) .toEqual([1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]); }); @@ -548,7 +546,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -573,16 +571,16 @@ test('TFORCALL, TFORLOOP', () => { return r `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(6); + expect(lua_tointeger(L, -1)).toBe(6); }); test('LEN', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -593,27 +591,27 @@ test('LEN', () => { return #t, #t2, #s `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tointeger(L, -1)).toBe(5); - expect(lua.lua_tointeger(L, -2)).toBe(3); - expect(lua.lua_tointeger(L, -3)).toBe(0); + expect(lua_tointeger(L, -1)).toBe(5); + expect(lua_tointeger(L, -2)).toBe(3); + expect(lua_tointeger(L, -3)).toBe(0); }); test('CONCAT', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` return "hello " .. 2 .. " you" `; { - expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); - lua.lua_call(L, 0, -1); + expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); + lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you"); + expect(lua_tojsstring(L, -1)).toBe("hello 2 you"); }); diff --git a/test/manual-tests/debug-cli.js b/test/manual-tests/debug-cli.js index dc49a0e0..37a63ed8 100755 --- a/test/manual-tests/debug-cli.js +++ b/test/manual-tests/debug-cli.js @@ -1,20 +1,19 @@ #!/usr/bin/env node -"use strict"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; let luaCode = ` a = "debug me" debug.debug() `, L; -L = lauxlib.luaL_newstate(); +L = luaL_newstate(); -lualib.luaL_openlibs(L); +luaL_openlibs(L); -lauxlib.luaL_loadstring(L, to_luastring(luaCode)); +luaL_loadstring(L, to_luastring(luaCode)); -lua.lua_call(L, 0, 0); +lua_call(L, 0, 0); diff --git a/test/test-suite/api.test.js b/test/test-suite/api.test.js index 5a5e10ea..9381b150 100644 --- a/test/test-suite/api.test.js +++ b/test/test-suite/api.test.js @@ -1,11 +1,9 @@ -"use strict"; +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); - -const ltests = require('./ltests.js'); +import { luaopen_tests } from './ltests.js'; // TODO: a lot of gc related tests are skipped // TODO: io.read is used in several tests, uncomment them when it's implemented @@ -27,23 +25,23 @@ const prefix = ` `; test("[test-suite] api: registry", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` a = T.testC("pushvalue R; return 1") assert(a == debug.getregistry()) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: absindex", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -52,16 +50,16 @@ test("[test-suite] api: absindex", () => { assert(T.testC("settop 10; absindex 1; return 1") == 1) assert(T.testC("settop 10; absindex R; return 1") < -10) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing alignment", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -77,16 +75,16 @@ test("[test-suite] api: testing alignment", () => { a,b,c = f() assert(a == 2 and b == 3 and not c) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: test that all trues are equal", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -130,16 +128,16 @@ test("[test-suite] api: test that all trues are equal", () => { t = pack(T.testC("copy -3 -1; return *", 2, 3, 4, 5)) tcheck(t, {n=4,2,3,4,3}) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing 'rotate'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -166,16 +164,16 @@ test("[test-suite] api: testing 'rotate'", () => { tcheck(t, {10, 20, 30, 40}) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing non-function message handlers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -207,16 +205,16 @@ test("[test-suite] api: testing non-function message handlers", () => { t = pack(T.testC("concat 5; return *", "alo", 2, 3, "joao", 12)) tcheck(t, {n=1,"alo23joao12"}) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing MULTRET", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -224,16 +222,16 @@ test("[test-suite] api: testing MULTRET", () => { function (a,b) return 1,2,3,4,a,b end, "alo", "joao")) tcheck(t, {n=6,1,2,3,4,"alo", "joao"}) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: test returning more results than fit in the caller stack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -245,16 +243,16 @@ test("[test-suite] api: test returning more results than fit in the caller stack assert(b == "10") end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing globals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -268,16 +266,16 @@ test("[test-suite] api: testing globals", () => { ]]} assert(a[2] == 14 and a[3] == "a31" and a[4] == nil and _G.a == "a31") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing arith", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -314,32 +312,32 @@ test("[test-suite] api: testing arith", () => { assert(T.testC("arith _; arith +; arith %; return 1", b, a, c)[1] == 8 % (4 + (-3)*2)) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: errors in arithmetic", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerr("divide by zero", T.testC, "arith \\\\", 10, 0) checkerr("%%0", T.testC, "arith %", 10, 0) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing lessthan and lessequal", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -351,16 +349,16 @@ test("[test-suite] api: testing lessthan and lessequal", () => { assert(not T.testC("compare LT 2 -3, return 1", "4", "2", "2", "3", "2", "2")) assert(not T.testC("compare LT -3 2, return 1", "3", "2", "2", "4", "2", "2")) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: non-valid indices produce false", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -382,16 +380,16 @@ test("[test-suite] api: non-valid indices produce false", () => { a,b = T.testC("compare LE 5 -6, return 2", a1, 2, 2, a1, 2, 20) assert(a == 20 and b == true) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing length", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -421,16 +419,16 @@ test("[test-suite] api: testing length", () => { ]], t) assert(a == print and c == 1) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing __concat", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -451,16 +449,16 @@ test("[test-suite] api: testing __concat", () => { -- concat with 1 element assert(T.testC("concat 1; return 1", "xuxu") == "xuxu") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing lua_is", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -494,16 +492,16 @@ test("[test-suite] api: testing lua_is", () => { assert(count(io.stdin) == 1) assert(count(nil, 15) == 100) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing lua_to...", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -543,15 +541,15 @@ test("[test-suite] api: testing lua_to...", () => { a = to("tocfunction", math.deg) assert(a(3) == math.deg(3) and a == math.deg) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing panic function", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -590,16 +588,16 @@ test("[test-suite] api: testing panic function", () => { end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: testing deep JS stack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -634,16 +632,16 @@ test.skip("[test-suite] api: testing deep JS stack", () => { assert(next(t) == nil) prog, g, t = nil `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing errors", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -665,16 +663,16 @@ test("[test-suite] api: testing errors", () => { check3("%.", T.testC("loadfile 2; return *", ".")) check3("xxxx", T.testC("loadfile 2; return *", "xxxx")) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: test errors in non protected threads", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -691,16 +689,16 @@ test("[test-suite] api: test errors in non protected threads", () => { checkerrnopro("getglobal 'f'; call 0 0;", "stack overflow") end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing table access", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -742,16 +740,16 @@ test("[test-suite] api: testing table access", () => { assert(a[b] == 19) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing getfield/setfield with long keys", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -770,16 +768,16 @@ test("[test-suite] api: testing getfield/setfield with long keys", () => { _012345678901234567890123456789012345678901234567890123456789 = nil end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing next", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -792,16 +790,16 @@ test("[test-suite] api: testing next", () => { t = pack(T.testC("next; pop 1; next; return *", a, nil)) tcheck(t, {n=1,a}) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing upvalues", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -820,16 +818,16 @@ test("[test-suite] api: testing upvalues", () => { -- T.checkmemory() end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing absent upvalues from JS-function pointers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -844,16 +842,16 @@ test("[test-suite] api: testing absent upvalues from JS-function pointers", () = T.upvalue(f, 2, "xuxu") assert(T.upvalue(f, 2) == "xuxu") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: large closures", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -869,16 +867,16 @@ test("[test-suite] api: large closures", () => { assert(not A("isnil U256; return 1")) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing get/setuservalue", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -904,16 +902,16 @@ test("[test-suite] api: testing get/setuservalue", () => { -- collectgarbage() -- number should not be a problem for collector assert(debug.getuservalue(b) == 134) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: testing get/setuservalue", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -923,16 +921,16 @@ test.skip("[test-suite] api: testing get/setuservalue", () => { T.gcstate("pause") -- complete collection assert(debug.getuservalue(b).x == 100) -- uvalue should be there `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: long chain of userdata", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -948,16 +946,16 @@ test.skip("[test-suite] api: long chain of userdata", () => { assert(debug.getuservalue(b).x == 100) b = nil `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: reuse of references", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1008,16 +1006,16 @@ test.skip("[test-suite] api: reuse of references", () => { assert(type(T.getref(a)) == 'table') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1124,16 +1122,16 @@ test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", collectgarbage() assert(#cl == 1 and cl[1] == x) -- old 'x' must be collected `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: test whether udate collection frees memory in the right time", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1168,16 +1166,16 @@ test.skip("[test-suite] api: test whether udate collection frees memory in the r collectgarbage("restart") end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing lua_equal", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1188,16 +1186,16 @@ test("[test-suite] api: testing lua_equal", () => { assert(not T.testC("compare EQ 2 3; return 1")) assert(not T.testC("compare EQ 2 3; return 1", 3)) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing lua_equal with fallbacks", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1218,16 +1216,16 @@ test("[test-suite] api: testing lua_equal with fallbacks", () => { assert(f(10) ~= f(10)) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing changing hooks during hooks", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1252,16 +1250,16 @@ test("[test-suite] api: testing changing hooks during hooks", () => { assert(t[5] == "line" and t[6] == line + 2) assert(t[7] == nil) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: testing errors during GC", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1292,16 +1290,16 @@ test.skip("[test-suite] api: testing errors during GC", () => { assert(A == 10) -- number of normal collections end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: test for userdata vals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1315,16 +1313,16 @@ test("[test-suite] api: test for userdata vals", () => { assert(type(tostring(a[1])) == "string") end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing multiple states", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1374,16 +1372,16 @@ test("[test-suite] api: testing multiple states", () => { T.closestate(L1) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: testing memory limits", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1393,11 +1391,11 @@ test.skip("[test-suite] api: testing memory limits", () => { checkerr("not enough memory", load"local a={}; for i=1,100000 do a[i]=i end") T.totalmem(0) -- restore high limit `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); @@ -1429,37 +1427,37 @@ const memprefix = ` test.skip("[test-suite] api: testing memory errors when creating a new state", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` b = testamem("state creation", T.newstate) T.closestate(b); -- close new state `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` mt = T.testC("rawgeti R 1; return 1") assert(type(mt) == "thread" and coroutine.running() == mt) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: test thread creation after stressing GC", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1478,16 +1476,16 @@ test.skip("[test-suite] api: test thread creation after stressing GC", () => { return T.doonnewstack("x=1") == 0 -- try to create thread end) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: testing memory x compiler", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1495,16 +1493,16 @@ test.skip("[test-suite] api: testing memory x compiler", () => { return load("x=1") -- try to do load a string end) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: testing memory x dofile", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1529,16 +1527,16 @@ test.skip("[test-suite] api: testing memory x dofile", () => { assert(os.remove(t)) assert(_G.a == "aaax") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] api: other generic tests", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1600,16 +1598,16 @@ test.skip("[test-suite] api: other generic tests", () => { end) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing some auxlib functions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1625,16 +1623,16 @@ test("[test-suite] api: testing some auxlib functions", () => { assert(gsub("...", ".", "/.") == "/././.") assert(gsub("...", "...", "") == "") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] api: testing luaL_newmetatable", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1685,9 +1683,9 @@ test("[test-suite] api: testing luaL_newmetatable", () => { r.xuxu = nil; r.xuxu1 = nil end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/attrib.test.js b/test/test-suite/attrib.test.js index bb07e628..5797dac0 100644 --- a/test/test-suite/attrib.test.js +++ b/test/test-suite/attrib.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test("[test-suite] attrib: testing require", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -54,22 +52,22 @@ test("[test-suite] attrib: testing require", () => { package.path = oldpath end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); // TODO: when io.write etc. test.skip("[test-suite] attrib: system specific tests for 'require'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); }); test("[test-suite] attrib: testing assignments, logical operators, and constructors", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -161,15 +159,15 @@ test("[test-suite] attrib: testing assignments, logical operators, and construct a[1], f(a)[2], b, c = {['alo']=assert}, 10, a[1], a[f], 6, 10, 23, f(a), 2 a[1].alo(a[2]==10 and b==10 and c==print) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] attrib: test of large float/integer indices ", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -225,15 +223,15 @@ test("[test-suite] attrib: test of large float/integer indices ", () => { assert(a[maxintF] == 20 and a[maxintF - 1.0] == 11 and a[-maxintF] == 22 and a[-maxintF + 1.0] == 13) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] attrib: test conflicts in multiple assignment", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -245,15 +243,15 @@ test("[test-suite] attrib: test conflicts in multiple assignment", () => { b[3] == 1) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] attrib: repeat test with upvalues", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -271,15 +269,15 @@ test("[test-suite] attrib: repeat test with upvalues", () => { assert(t[1] == 10) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] attrib: bug in 5.2 beta", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -295,8 +293,8 @@ test("[test-suite] attrib: bug in 5.2 beta", () => { local a, b = foo()() assert(a == 3 and b == 14) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/bitwise.test.js b/test/test-suite/bitwise.test.js index bf8de5c5..08644f69 100644 --- a/test/test-suite/bitwise.test.js +++ b/test/test-suite/bitwise.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` package.preload.bit32 = function () --{ @@ -115,7 +113,7 @@ const prefix = ` `; test("[test-suite] bitwise: testing bitwise operations", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -177,15 +175,15 @@ test("[test-suite] bitwise: testing bitwise operations", () => { -- embedded zeros assert(not pcall(function () return "0xffffffffffffffff\\0" | 0 end)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: testing bitwise library", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -197,15 +195,15 @@ test("[test-suite] bitwise: testing bitwise library", () => { assert(bit32.band() == bit32.band(0xffffffff)) assert(bit32.band(1,2) == 0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: out-of-range numbers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -262,15 +260,15 @@ test("[test-suite] bitwise: out-of-range numbers", () => { assert(0x12345678 >> 32 == 0) assert(0x12345678 >> -32 == 0x1234567800000000) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: some special cases", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -305,15 +303,15 @@ test("[test-suite] bitwise: some special cases", () => { assert(bit32.rshift(bit32.rshift(b, 4), -4) == bit32.band(b, bit32.bnot(0xf))) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -332,15 +330,15 @@ test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si assert(not pcall(bit32.lshift, 45, print)) assert(not pcall(bit32.rshift, 45, print)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: testing extract/replace", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -363,30 +361,30 @@ test("[test-suite] bitwise: testing extract/replace", () => { assert(bit32.replace(-1, 0, 31) == (1 << 31) - 1) assert(bit32.replace(-1, 0, 1, 2) == (1 << 32) - 7) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: testing conversion of floats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(bit32.bor(3.0) == 3) assert(bit32.bor(-4.0) == 0xfffffffc) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] bitwise: large floats and large-enough integers?", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -397,8 +395,8 @@ test("[test-suite] bitwise: large floats and large-enough integers?", () => { assert(bit32.bor(-2.0^48 - 6.0) == 0xfffffffa) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/calls.test.js b/test/test-suite/calls.test.js index 16043376..94566aef 100644 --- a/test/test-suite/calls.test.js +++ b/test/test-suite/calls.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test("[test-suite] calls: test 'type'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -23,15 +21,15 @@ test("[test-suite] calls: test 'type'", () => { assert(type(f) == 'function') assert(not pcall(type)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: test error in 'print'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -49,15 +47,15 @@ test("[test-suite] calls: test error in 'print'", () => { _ENV.tostring = tostring end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: testing local-function recursion", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -73,15 +71,15 @@ test("[test-suite] calls: testing local-function recursion", () => { end assert(fact == false) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: testing declarations", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -168,15 +166,15 @@ test("[test-suite] calls: testing declarations", () => { (function (x) a=x end)(23) assert(a == 23 and (function (x) return x*2 end)(20) == 40) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: testing closures", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -214,15 +212,15 @@ test("[test-suite] calls: testing closures", () => { Z, F, f = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: testing multiple returns", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -260,15 +258,15 @@ test("[test-suite] calls: testing multiple returns", () => { a = ret2{ unlpack{1,2,3}, unlpack{3,2,1}, unlpack{"a", "b"}} assert(a[1] == 1 and a[2] == 3 and a[3] == "a" and a[4] == "b") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -277,15 +275,15 @@ test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { assert(math.sin(1,2) == math.sin(1)) table.sort({10,9,8,4,19,23,0,0}, function (a,b) return a { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -337,29 +335,29 @@ test("[test-suite] calls: test for generic load", () => { cannotload("unexpected symbol", load("*a = 123")) cannotload("hhi", load(function () error("hhi") end)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: any value is valid for _ENV", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(load("return _ENV", nil, nil, 123)() == 123) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: load when _ENV is not first upvalue", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -376,15 +374,15 @@ test("[test-suite] calls: load when _ENV is not first upvalue", () => { assert(assert(load("return XX + ...", nil, nil, {XX = 13}))(4) == 17) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: test generic load with nested functions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -409,15 +407,15 @@ test("[test-suite] calls: test generic load with nested functions", () => { a = assert(load(read1(x))) assert(a()(2)(3)(10) == 15) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: test for dump/undump with upvalues", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -437,15 +435,15 @@ test("[test-suite] calls: test for dump/undump with upvalues", () => { x("set") assert(x() == 24) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: test for dump/undump with many upvalues", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -472,15 +470,15 @@ test("[test-suite] calls: test for dump/undump with many upvalues", () => { assert(f() == 10 * nup) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: test for long method names", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -492,15 +490,15 @@ test("[test-suite] calls: test for long method names", () => { assert(t:_012345678901234567890123456789012345678901234567890123456789() == 1) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: test for bug in parameter adjustment", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -508,15 +506,15 @@ test("[test-suite] calls: test for bug in parameter adjustment", () => { assert((function () local a; return a end)(4) == nil) assert((function (a) return a end)() == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] calls: testing binary chunks", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -555,8 +553,8 @@ test("[test-suite] calls: testing binary chunks", () => { assert(assert(load(c))() == 10) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/closure.test.js b/test/test-suite/closure.test.js index d44d908f..f00d4de6 100644 --- a/test/test-suite/closure.test.js +++ b/test/test-suite/closure.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test("[test-suite] closure: testing equality", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -22,15 +20,15 @@ test("[test-suite] closure: testing equality", () => { end assert(f() == f()) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: testing closures with 'for' control variable", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -63,15 +61,15 @@ test("[test-suite] closure: testing closures with 'for' control variable", () => r,s = a[2].get() assert(r == "a" and s == "b") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: testing closures with 'for' control variable x break", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -91,15 +89,15 @@ test("[test-suite] closure: testing closures with 'for' control variable x break assert(({f()})[1] == 1) assert(({f()})[2] == "a") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: testing closure x break x return x errors", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -135,15 +133,15 @@ test("[test-suite] closure: testing closure x break x return x errors", () => { assert(b('get') == 'xuxu') b('set', 10); assert(b('get') == 14) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: testing multi-level closure", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -158,15 +156,15 @@ test("[test-suite] closure: testing multi-level closure", () => { w = 1.345 assert(y(20)(30) == 60+w) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: testing closures x repeat-until", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -178,15 +176,15 @@ test("[test-suite] closure: testing closures x repeat-until", () => { until i > 10 or a[i]() ~= x assert(i == 11 and a[1]() == 1 and a[3]() == 3 and i == 4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: testing closures created in 'then' and 'else' parts of 'if's", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -219,15 +217,15 @@ test("[test-suite] closure: testing closures created in 'then' and 'else' parts assert(a[i](i * 10) == i % 3 and a[i]() == i * 10) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -239,8 +237,8 @@ test("[test-suite] closure: test for correctly closing upvalues in tail calls of end t() `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/code.test.js b/test/test-suite/code.test.js index 377dd630..16c56812 100644 --- a/test/test-suite/code.test.js +++ b/test/test-suite/code.test.js @@ -1,14 +1,12 @@ -"use strict"; +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); - -const ltests = require('./ltests.js'); +import { luaopen_tests } from './ltests.js'; test("[test-suite] code: testing reuse in constant table", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -32,11 +30,11 @@ test("[test-suite] code: testing reuse in constant table", () => { checkKlist(foo, {3, 0, 0.0, 3.78/4, -3.78/4, -3.79/4, 3.0}) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); @@ -65,7 +63,7 @@ const prefix = ` test("[test-suite] code: some basic instructions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -73,16 +71,16 @@ test("[test-suite] code: some basic instructions", () => { (function () end){f()} end, 'CLOSURE', 'NEWTABLE', 'GETTABUP', 'CALL', 'SETLIST', 'CALL', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: sequence of LOADNILs", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -104,31 +102,31 @@ test("[test-suite] code: sequence of LOADNILs", () => { assert(a == nil and b == nil and c == nil and d == nil) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: single return", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` check (function (a,b,c) return a end, 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: infinite loops", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -141,32 +139,32 @@ test("[test-suite] code: infinite loops", () => { check(function () repeat local x = 1 until true end, 'LOADK', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: concat optimization", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` check(function (a,b,c,d) return a..b..c..d end, 'MOVE', 'MOVE', 'MOVE', 'MOVE', 'CONCAT', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: not", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -175,16 +173,16 @@ test("[test-suite] code: not", () => { check(function () return not not true end, 'LOADBOOL', 'RETURN') check(function () return not not 1 end, 'LOADBOOL', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: direct access to locals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -198,16 +196,16 @@ test("[test-suite] code: direct access to locals", () => { 'DIV', 'ADD', 'GETTABLE', 'SUB', 'GETTABLE', 'POW', 'UNM', 'SETTABLE', 'SETTABLE', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: direct access to constants", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -233,16 +231,16 @@ test("[test-suite] code: direct access to constants", () => { end, 'LOADNIL', 'SETTABLE', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: constant folding", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -267,16 +265,16 @@ test("[test-suite] code: constant folding", () => { checkK(function () return ~~-100024.0 end, -100024) checkK(function () return ((100 << 6) << -4) >> 2 end, 100) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: no folding", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -285,16 +283,16 @@ test("[test-suite] code: no folding", () => { check(function () return 0%0 end, 'MOD', 'RETURN') check(function () return -4//0 end, 'IDIV', 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: bug in constant folding for 5.1", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -315,16 +313,16 @@ test("[test-suite] code: bug in constant folding for 5.1", () => { -- no code for a = a 'RETURN') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: x == nil , x ~= nil", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -340,16 +338,16 @@ test("[test-suite] code: x == nil , x ~= nil", () => { checkequal(function (l) local a; return 0 <= a and a <= l end, function (l) local a; return not (not(a >= 0) or not(a <= l)) end) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] code: if-goto optimizations", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -375,9 +373,9 @@ test("[test-suite] code: if-goto optimizations", () => { function (a) while true do if not(a < 10) then break end; a = a + 1; end end ) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/constructs.test.js b/test/test-suite/constructs.test.js index e79778ae..df2ebf49 100644 --- a/test/test-suite/constructs.test.js +++ b/test/test-suite/constructs.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const checkload = ` local function checkload (s, msg) @@ -12,7 +10,7 @@ const checkload = ` `; test('[test-suite] constructs: testing semicolons', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -20,29 +18,29 @@ test('[test-suite] constructs: testing semicolons', () => { ; do ; a = 3; assert(a == 3) end; ; `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkload + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] constructs: invalid operations should not raise errors when not executed', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` if false then a = 3 // 0; a = 0 % 0 end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkload + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] constructs: testing priorities', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -87,15 +85,15 @@ test('[test-suite] constructs: testing priorities', () => { assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkload + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] constructs: silly loops', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -261,14 +259,14 @@ test('[test-suite] constructs: silly loops', () => { a,b = F(1)~=nil; assert(a == true and b == nil); a,b = F(nil)==nil; assert(a == true and b == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkload + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip('[test-suite] constructs: huge loops, upvalue', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -336,15 +334,15 @@ test.skip('[test-suite] constructs: huge loops, upvalue', () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkload + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -360,8 +358,8 @@ test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov' checkload(s, "too long") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkload + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/coroutine.test.js b/test/test-suite/coroutine.test.js index de92317f..193de600 100644 --- a/test/test-suite/coroutine.test.js +++ b/test/test-suite/coroutine.test.js @@ -1,11 +1,9 @@ -"use strict"; +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); - -const ltests = require('./ltests.js'); +import { luaopen_tests } from './ltests.js'; const prefix = ` mt = { @@ -56,7 +54,7 @@ const prefix = ` `; test("[test-suite] coroutine: is main thread", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -66,30 +64,30 @@ test("[test-suite] coroutine: is main thread", () => { assert(not coroutine.isyieldable()) assert(not pcall(coroutine.yield)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: trivial errors", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(coroutine.resume, 0)) assert(not pcall(coroutine.status, 0)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -136,15 +134,15 @@ test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => s, a = coroutine.resume(f, "xuxu") assert(not s and string.find(a, "dead") and coroutine.status(f) == "dead") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: yields in tail calls", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -158,15 +156,15 @@ test("[test-suite] coroutine: yields in tail calls", () => { for i=1,10 do _G.x = i; assert(f(i) == i) end _G.x = 'xuxu'; assert(f('xuxu') == 'a') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: recursive", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -182,15 +180,15 @@ test("[test-suite] coroutine: recursive", () => { s = s*i end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: sieve", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -223,15 +221,15 @@ test("[test-suite] coroutine: sieve", () => { assert(#a == 25 and a[#a] == 97) x, a = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: yielding across JS boundaries", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -263,15 +261,15 @@ test("[test-suite] coroutine: yielding across JS boundaries", () => { r, msg = co(100) assert(not r and msg == 240) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: unyieldable JS call", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -289,15 +287,15 @@ test("[test-suite] coroutine: unyieldable JS call", () => { assert(co() == "aa") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: errors in coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -322,15 +320,15 @@ test("[test-suite] coroutine: errors in coroutines", () => { a,b = coroutine.resume(x) assert(not a and string.find(b, "dead") and coroutine.status(x) == "dead") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: co-routines x for loop", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -350,15 +348,15 @@ test("[test-suite] coroutine: co-routines x for loop", () => { end assert(a == 5^4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: old bug: attempt to resume itself", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -381,15 +379,15 @@ test("[test-suite] coroutine: old bug: attempt to resume itself", () => { assert(coroutine.resume(co, co) == false) assert(coroutine.resume(co, co) == false) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: old bug: other old bug when attempting to resume itself", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -404,15 +402,15 @@ test("[test-suite] coroutine: old bug: other old bug when attempting to resume i assert(not st and string.find(res, "non%-suspended")) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -428,15 +426,15 @@ test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { assert(a and b == 3) assert(coroutine.status(co1) == 'dead') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: infinite recursion of coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -444,15 +442,15 @@ test("[test-suite] coroutine: infinite recursion of coroutines", () => { assert(not pcall(a, a)) a = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -468,14 +466,14 @@ test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { assert(_G.f() == 11) assert(_G.f() == 12) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: leaving a pending coroutine open", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -487,15 +485,15 @@ test("[test-suite] coroutine: leaving a pending coroutine open", () => { _X() `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: stack overflow", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -515,15 +513,15 @@ test("[test-suite] coroutine: stack overflow", () => { end co = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing yields inside metamethods", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -563,15 +561,15 @@ test("[test-suite] coroutine: testing yields inside metamethods", () => { return a.BB end, {"nidx", "idx"}) == print) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: tests for comparsion operators", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -615,15 +613,15 @@ test("[test-suite] coroutine: tests for comparsion operators", () => { end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: getuptable & setuptable", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -635,15 +633,15 @@ test("[test-suite] coroutine: getuptable & setuptable", () => { assert(run(f, {"idx", "nidx", "idx"}) == 11) assert(g.k.AAA == 11) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing yields inside 'for' iterators", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -658,10 +656,10 @@ test("[test-suite] coroutine: testing yields inside 'for' iterators", () => { return s end, {"for", "for", "for"}) == 10) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); @@ -677,7 +675,7 @@ const jsprefix = ` `; test("[test-suite] coroutine: testing yields inside hooks", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -700,16 +698,16 @@ test("[test-suite] coroutine: testing yields inside hooks", () => { assert(B // A == 7) -- fact(7) // fact(6) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing yields inside line hook", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -731,16 +729,16 @@ test("[test-suite] coroutine: testing yields inside line hook", () => { _G.X = nil; co(); assert(_G.X == line + 3 and _G.XX == 20) assert(co() == 10) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing yields in count hook", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -760,16 +758,16 @@ test("[test-suite] coroutine: testing yields in count hook", () => { repeat c = c + 1; local a = co() until a == 10 assert(_G.XX == 20 and c >= 5) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing yields inside line hook", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -798,16 +796,16 @@ test("[test-suite] coroutine: testing yields inside line hook", () => { assert(_G.XX == 20 and c >= 5) _G.X = nil; _G.XX = nil `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -838,16 +836,16 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins assert(not coroutine.resume(c)) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -862,16 +860,16 @@ test("[test-suite] coroutine: testing debug library on last function in a suspen assert(b == 10) end `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: reusing a thread", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -896,16 +894,16 @@ test("[test-suite] coroutine: reusing a thread", () => { assert(X == 'a a a' and Y == 'OK') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: resuming running coroutine", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -933,15 +931,15 @@ test("[test-suite] coroutine: resuming running coroutine", () => { assert(a == coroutine.running() and string.find(b, "non%-suspended") and c == "ERRRUN" and d == 4) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: using a main thread as a coroutine", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -976,16 +974,16 @@ test("[test-suite] coroutine: using a main thread as a coroutine", () => { T.closestate(state) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: tests for coroutine API", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1028,16 +1026,16 @@ test("[test-suite] coroutine: tests for coroutine API", () => { a[9] == "YIELD" and a[10] == 4) assert(not pcall(co)) -- coroutine is dead now `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: tests for coroutine API", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1049,16 +1047,16 @@ test("[test-suite] coroutine: tests for coroutine API", () => { assert(co(23,16) == 5) assert(co(23,16) == 10) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing coroutines with C bodies", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1094,16 +1092,16 @@ test("[test-suite] coroutine: testing coroutines with C bodies", () => { assert(a == 'YIELD' and b == 'a' and c == 102 and d == 'OK') `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing chain of suspendable C calls", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1137,16 +1135,16 @@ test("[test-suite] coroutine: testing chain of suspendable C calls", () => { -- three '34's (one from each pending C call) assert(#a == 3 and a[1] == a[2] and a[2] == a[3] and a[3] == 34) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: testing yields with continuations", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1202,16 +1200,16 @@ test("[test-suite] coroutine: testing yields with continuations", () => { assert(not pcall(co)) -- coroutine should be dead `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] coroutine: bug in nCcalls", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1223,9 +1221,9 @@ test("[test-suite] coroutine: bug in nCcalls", () => { local a = {co()} assert(a[10] == "hi") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/db.test.js b/test/test-suite/db.test.js index 89ec66da..58b2911b 100644 --- a/test/test-suite/db.test.js +++ b/test/test-suite/db.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` local function dostring(s) return assert(load(s))() end @@ -23,7 +21,7 @@ const prefix = ` `; test("[test-suite] db: getinfo, ...line...", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -43,15 +41,15 @@ test("[test-suite] db: getinfo, ...line...", () => { assert(not b.activelines[b.linedefined] and not b.activelines[b.lastlinedefined + 1]) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: test file and string names truncation", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -79,14 +77,14 @@ test("[test-suite] db: test file and string names truncation", () => { assert(debug.getinfo(f).short_src == "") a = nil; f = nil; `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: local", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -126,15 +124,15 @@ test("[test-suite] db: local", () => { assert(g(f) == 'a') until 1 `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: line hook", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -192,30 +190,30 @@ test("[test-suite] db: line hook", () => { test([[for i=1,4 do a=1 end]], {1,1,1,1,1}) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: invalid levels in [gs]etlocal", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(not pcall(debug.getlocal, 20, 1)) assert(not pcall(debug.setlocal, -1, 1, 10)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: parameter names", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -231,15 +229,15 @@ test("[test-suite] db: parameter names", () => { assert(not debug.getlocal(print, 1)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: vararg", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -268,30 +266,30 @@ test("[test-suite] db: vararg", () => { foo(table.unpack(a)) a = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: access to vararg in non-vararg function", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` local function foo () return debug.getlocal(1, -1) end assert(not foo(10)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: test hook presence in debug info", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -379,15 +377,15 @@ test("[test-suite] db: test hook presence in debug info", () => { assert(a[f] and a[g] and a[assert] and a[debug.getlocal] and not a[print]) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -413,15 +411,15 @@ test("[test-suite] db: tests for manipulating non-registered locals (C and Lua t debug.sethook(nil); assert(debug.gethook() == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing access to function arguments", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -462,15 +460,15 @@ test("[test-suite] db: testing access to function arguments", () => { assert(XX == 12) assert(debug.gethook() == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing access to local variables in return hook (bug in 5.2)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -509,15 +507,15 @@ test("[test-suite] db: testing access to local variables in return hook (bug in assert(foo == nil) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing upvalue access", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -549,15 +547,15 @@ test("[test-suite] db: testing upvalue access", () => { -- upvalues of C functions are allways "called" "" (the empty string) assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing count hooks", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -579,15 +577,15 @@ test("[test-suite] db: testing count hooks", () => { debug.sethook() `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: tests for tail calls", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -645,15 +643,15 @@ test("[test-suite] db: tests for tail calls", () => { foo(lim) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing local function information", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -675,15 +673,15 @@ test("[test-suite] db: testing local function information", () => { debug.sethook() -- turn off hook assert(a == 2) -- ensure all two lines where hooked `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing traceback", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -700,15 +698,15 @@ test("[test-suite] db: testing traceback", () => { assert(st == true and string.find(msg, "pcall")) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing nparams, nups e isvararg", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -725,15 +723,15 @@ test("[test-suite] db: testing nparams, nups e isvararg", () => { assert(t.isvararg == true and t.nparams == 0 and t.nups == 1 and debug.getupvalue(t.func, 1) == "_ENV") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing debugging of coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -803,16 +801,16 @@ test("[test-suite] db: testing debugging of coroutines", () => { assert(not debug.gethook()) checktraceback(co, {}) `; - lualib.luaL_openlibs(L); + luaL_openlibs(L); let b = to_luastring(luaCode); - if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + if (luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: check get/setlocal in coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -831,15 +829,15 @@ test("[test-suite] db: check get/setlocal in coroutines", () => { a, b = coroutine.resume(co, 100) assert(a and b == 30) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: check traceback of suspended (or dead with error) coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -866,15 +864,15 @@ test("[test-suite] db: check traceback of suspended (or dead with error) corouti t[1] = "'error'" checktraceback(co, t) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -897,15 +895,15 @@ test("[test-suite] db: check test acessing line numbers of a coroutine from a re assert(type(debug.getregistry()) == "table") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: test tagmethod information", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -937,15 +935,15 @@ test("[test-suite] db: test tagmethod information", () => { assert (a>b and a.op == "__lt") assert(~a == "__bnot") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing for-iterator name", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -957,15 +955,15 @@ test("[test-suite] db: testing for-iterator name", () => { for i in f do end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing traceback sizes", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1004,16 +1002,16 @@ test("[test-suite] db: testing traceback sizes", () => { end end `; - lualib.luaL_openlibs(L); + luaL_openlibs(L); let b = to_luastring(luaCode); - if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + if (luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: testing debug functions on chunk without debug info", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1060,15 +1058,15 @@ test("[test-suite] db: testing debug functions on chunk without debug info", () assert(f() == 13) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] db: tests for 'source' in binary dumps", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1104,8 +1102,8 @@ test("[test-suite] db: tests for 'source' in binary dumps", () => { debug.getinfo(h).source == '=?') end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/errors.test.js b/test/test-suite/errors.test.js index 83c7a909..8131cceb 100644 --- a/test/test-suite/errors.test.js +++ b/test/test-suite/errors.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` -- avoid problems with 'strict' module (which may generate other error messages) @@ -43,35 +41,35 @@ const prefix = ` `; test("[test-suite] errors: test error message with no extra info", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(doit("error('hi', 0)") == 'hi') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: test error message with no info", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(doit("error()") == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: test common errors/errors that crashed in the past", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -92,15 +90,15 @@ test("[test-suite] errors: test common errors/errors that crashed in the past", ]], "'}' expected (to close '{' at line 1)", "", 3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: tests for better error messages", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -126,15 +124,15 @@ test("[test-suite] errors: tests for better error messages", () => { checkmessage("local a,b,c; (function () a = b+1 end)()", "upvalue 'b'") assert(not doit"local aaa={bbb={ddd=next}}; aaa.bbb:ddd(nil)") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: upvalues being indexed do not go to the stack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -148,15 +146,15 @@ test("[test-suite] errors: upvalues being indexed do not go to the stack", () => checkmessage("aaa='2'; b=nil;x=aaa*b", "global 'b'") checkmessage("aaa={}; x=-aaa", "global 'aaa'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: short circuit", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -173,15 +171,15 @@ test("[test-suite] errors: short circuit", () => { checkmessage("print('10' < 10)", "string with number") checkmessage("print(10 < '23')", "number with string") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: float->integer conversions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -203,15 +201,15 @@ test("[test-suite] errors: float->integer conversions", () => { checkmessage("a = 24 // 0", "divide by zero") checkmessage("a = 1 % 0", "'n%0'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: passing light userdata instead of full userdata", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -223,15 +221,15 @@ test("[test-suite] errors: passing light userdata instead of full userdata", () ]], "light userdata") _G.D = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: named objects (field '__name')", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -248,30 +246,30 @@ test("[test-suite] errors: named objects (field '__name')", () => { _G.XX = nil end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: global functions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` checkmessage("(io.write or print){}", "io.write") checkmessage("(collectgarbage or print){}", "collectgarbage") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: errors in functions without debug info", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -289,15 +287,15 @@ test("[test-suite] errors: errors in functions without debug info", () => { checkerr("^%?:%-1:.*table value", f) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: tests for field accesses after RK limit", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -312,15 +310,15 @@ test("[test-suite] errors: tests for field accesses after RK limit", () => { checkmessage(s.."; local t = {}; a = t.bbb + 1", "field 'bbb'") checkmessage(s.."; local t = {}; t:bbb()", "method 'bbb'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: global", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -335,15 +333,15 @@ test("[test-suite] errors: global", () => { {d = x and aaa[x or y]}} ]], "global 'aaa'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: field", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -352,15 +350,15 @@ test("[test-suite] errors: field", () => { if math.sin(1) == 0 then return 3 end -- return x.a()]], "field 'a'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: global insert", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -373,15 +371,15 @@ test("[test-suite] errors: global insert", () => { insert(prefix, a) end]], "global 'insert'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: sin", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -389,15 +387,15 @@ test("[test-suite] errors: sin", () => { return math.sin("a") ]], "'sin'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: concatenate", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -405,15 +403,15 @@ test("[test-suite] errors: concatenate", () => { checkmessage([[x = "a" .. false]], "concatenate") checkmessage([[x = {} .. 2]], "concatenate") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: unknown global", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -425,15 +423,15 @@ test("[test-suite] errors: unknown global", () => { main() ]], "global 'NoSuchName'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: __index", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -445,15 +443,15 @@ test("[test-suite] errors: __index", () => { checkmessage("table.sort({1,2,3}, table.sort)", "'table.sort'") checkmessage("string.gsub('s', 's', setmetatable)", "'setmetatable'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: tests for errors in coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -469,15 +467,15 @@ test("[test-suite] errors: tests for errors in coroutines", () => { f = coroutine.wrap(function () table.sort({1,2,3}, coroutine.yield) end) checkerr("yield across", f) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: testing size of 'source' info", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -496,15 +494,15 @@ test("[test-suite] errors: testing size of 'source' info", () => { end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: testing line error", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -561,15 +559,15 @@ test("[test-suite] errors: testing line error", () => { X=1;lineerror((p), 2) X=2;lineerror((p), 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: several tests that exhaust the Lua stack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -584,15 +582,15 @@ test("[test-suite] errors: several tests that exhaust the Lua stack", () => { assert(checkstackmessage(doit('y()'))) assert(checkstackmessage(doit('y()'))) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: error lines in stack overflow", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -615,15 +613,15 @@ test("[test-suite] errors: error lines in stack overflow", () => { end assert(i > 15) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: error in error handling", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -640,15 +638,15 @@ test("[test-suite] errors: error in error handling", () => { end f(3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: too many results", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -667,15 +665,15 @@ test("[test-suite] errors: too many results", () => { end checkerr("too many results", f) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: non string messages", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -713,15 +711,15 @@ test("[test-suite] errors: non string messages", () => { assert(not res and string.find(msg, "value expected")) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua")) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua")) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: xpcall with arguments", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -730,15 +728,15 @@ test("[test-suite] errors: xpcall with arguments", () => { a, b, c = xpcall(string.find, function (x) return {} end, true, "al") assert(not a and type(b) == "table" and c == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: testing tokens in error messages", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -749,29 +747,29 @@ test("[test-suite] errors: testing tokens in error messages", () => { checksyntax("while << do end", "", "<<", 1) checksyntax("for >> do end", "", ">>", 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: test invalid non-printable char in a chunk", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` checksyntax("a\\1a = 1", "", "<\\\\1>", 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: test 255 as first char in a chunk", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -780,15 +778,15 @@ test("[test-suite] errors: test 255 as first char in a chunk", () => { doit('I = load("a=9+"); a=3') assert(a==3 and I == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: lots of errors", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -799,15 +797,15 @@ test("[test-suite] errors: lots of errors", () => { doit('a = 4+nil') end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: testing syntax limits", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -834,15 +832,15 @@ test("[test-suite] errors: testing syntax limits", () => { checkmessage("a = f(x" .. string.rep(",x", 260) .. ")", "too many registers") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: upvalues limit", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -868,15 +866,15 @@ test("[test-suite] errors: upvalues limit", () => { assert(c > 255 and string.find(b, "too many upvalues") and string.find(b, "line 5")) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] errors: local variables limit", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -888,8 +886,8 @@ test("[test-suite] errors: local variables limit", () => { local a,b = load(s) assert(string.find(b, "line 2") and string.find(b, "too many local variables")) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/events.test.js b/test/test-suite/events.test.js index 67faad64..0f4f6e08 100644 --- a/test/test-suite/events.test.js +++ b/test/test-suite/events.test.js @@ -1,14 +1,12 @@ -"use strict"; +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); - -const ltests = require('./ltests.js'); +import { luaopen_tests } from './ltests.js'; test("[test-suite] events: testing metatable", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -183,15 +181,15 @@ test("[test-suite] events: testing metatable", () => { assert(1.5 >> a == 1.5) assert(cap[0] == "shr" and cap[1] == 1.5 and cap[2] == a) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: test for rawlen", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -205,15 +203,15 @@ test("[test-suite] events: test for rawlen", () => { -- rawlen for long strings assert(rawlen(string.rep('a', 1000)) == 1000) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: test comparison", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -254,15 +252,15 @@ test("[test-suite] events: test comparison", () => { test() -- retest comparisons, now using both 'lt' and 'le' `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: test 'partial order'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -325,15 +323,15 @@ test("[test-suite] events: test 'partial order'", () => { t[Set{1,3,5}] = 1 assert(t[Set{1,3,5}] == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: __eq between userdata", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -356,16 +354,16 @@ test("[test-suite] events: __eq between userdata", () => { assert(u2 == u1 and u2 == u3 and u3 == u2) assert(u2 ~= {}) -- different types cannot be equal `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: concat", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -395,16 +393,16 @@ test("[test-suite] events: concat", () => { x = 0 .."a".."b"..c..d.."e".."f".."g" assert(x.val == "0abcdefg") `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -417,16 +415,16 @@ test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { assert(c..5 == c and 5 .. c == c) assert(4 .. c .. 5 == c and 4 .. 5 .. 6 .. 7 .. c == c) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: test comparison compatibilities", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -443,16 +441,16 @@ test("[test-suite] events: test comparison compatibilities", () => { setmetatable(d, t2) assert(c == d and c < d and not(d <= c)) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: test for several levels of callstest for several levels of calls", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -474,16 +472,16 @@ test("[test-suite] events: test for several levels of callstest for several leve x = c(3,4,5) assert(i == 3 and x[1] == 3 and x[3] == 5) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: __index on _ENV", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -494,16 +492,16 @@ test("[test-suite] events: __index on _ENV", () => { rawset(a, "x", 1, 2, 3) assert(a.x == 1 and rawget(a, "x", 3) == 1) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: testing metatables for basic types", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -536,16 +534,16 @@ test("[test-suite] events: testing metatables for basic types", () => { debug.setmetatable(nil, {}) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: loops in delegation", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -553,16 +551,16 @@ test("[test-suite] events: loops in delegation", () => { assert(not pcall(function (a,b) return a[b] end, a, 10)) assert(not pcall(function (a,b,c) a[b] = c end, a, 10, true)) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] events: bug in 5.1", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -578,9 +576,9 @@ test("[test-suite] events: bug in 5.1", () => { child.foo = 10 --> CRASH (on some machines) assert(T == parent and K == "foo" and V == 10) `; - lualib.luaL_openlibs(L); - ltests.luaopen_tests(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + luaopen_tests(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/goto.test.js b/test/test-suite/goto.test.js index 17e0397d..cef94c53 100644 --- a/test/test-suite/goto.test.js +++ b/test/test-suite/goto.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test("[test-suite] goto: error messages", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -46,15 +44,15 @@ test("[test-suite] goto: error messages", () => { until xuxu < x ]], "local 'xuxu'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] goto", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -113,15 +111,15 @@ test("[test-suite] goto", () => { ::l1:: ; ::l2:: ;; else end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] goto: to repeat a label in a different function is OK", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -141,15 +139,15 @@ test("[test-suite] goto: to repeat a label in a different function is OK", () => ::l6:: foo() `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -168,15 +166,15 @@ test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { assert(x == 2 and y == true) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] goto: testing closing of upvalues", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -241,15 +239,15 @@ test("[test-suite] goto: testing closing of upvalues", () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] goto: testing if x goto optimizations", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -283,8 +281,8 @@ test("[test-suite] goto: testing if x goto optimizations", () => { assert(testG(4) == 5) assert(testG(5) == 10) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/literals.test.js b/test/test-suite/literals.test.js index 3e9307bf..25181e62 100644 --- a/test/test-suite/literals.test.js +++ b/test/test-suite/literals.test.js @@ -1,32 +1,30 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const dostring = ` local function dostring (x) return assert(load(x), "")() end `; test("[test-suite] literals: dostring", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` dostring("x \\v\\f = \\t\\r 'a\\0a' \\v\\f\\f") assert(x == 'a\\0a' and string.len(x) == 3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); // TODO: bell character '\a' in JS is parsed as 'a' test("[test-suite] literals: escape sequences", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -35,15 +33,15 @@ test("[test-suite] literals: escape sequences", () => { "'\\]]) assert(string.find("\\b\\f\\n\\r\\t\\v", "^%c%c%c%c%c%c$")) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: assume ASCII just for tests", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -55,15 +53,15 @@ test("[test-suite] literals: assume ASCII just for tests", () => { assert(010 .. 020 .. -030 == "1020-30") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: hexadecimal escapes", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -90,15 +88,15 @@ assert("abc\\z ghi\\z " == 'abcdefghi') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: UTF-8 sequences", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -116,15 +114,15 @@ test("[test-suite] literals: UTF-8 sequences", () => { -- limits for 4-byte sequences assert("\\u{10000}\\u{10FFFF}" == "\\xF0\\x90\\x80\\x80\\z\\xF4\\x8F\\xBF\\xBF") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: Error in escape sequences", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -170,15 +168,15 @@ test("[test-suite] literals: Error in escape sequences", () => { lexerror("'alo \\\\z", "") lexerror([['alo \\98]], "") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: valid characters in variable names", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -189,15 +187,15 @@ test("[test-suite] literals: valid characters in variable names", () => { not load("a" .. s .. "1 = 1", "")) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: long variable names", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -212,29 +210,29 @@ test("[test-suite] literals: long variable names", () => { assert(_G[var1] == 5 and _G[var2] == 6 and f() == -1) var1, var2, f = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: escapes", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = `assert("\\n\\t" == [[\n\n\t]]) assert([[\n\n $debug]] == "\\n $debug") assert([[ [ ]] ~= [[ ] ]])`; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: long strings", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = `b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789" @@ -289,15 +287,15 @@ assert(x) prog = nil a = nil b = nil`; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: testing line ends", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = `prog = [[ @@ -319,15 +317,15 @@ for _, n in pairs{"\\n", "\\r", "\\n\\r", "\\r\\n"} do assert(dostring(prog) == nn) assert(_G.x == "hi\\n" and _G.y == "\\nhello\\r\\n\\n") end`; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: testing comments and strings with long brackets", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = `a = [==[]=]==] @@ -349,15 +347,15 @@ x y z [==[ blu foo ] ]=]==] error error]=]===]`; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: generate all strings of four of these chars", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = `local x = {"=", "[", "]", "\\n"} @@ -374,15 +372,15 @@ end for s in coroutine.wrap(function () gen("", len) end) do assert(s == load("return [====[\\n"..s.."]====]", "")()) end`; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: testing %q x line ends", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -390,15 +388,15 @@ test("[test-suite] literals: testing %q x line ends", () => { local c = string.format("return %q", s) assert(assert(load(c))() == s) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] literals: testing errors", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -407,8 +405,8 @@ test("[test-suite] literals: testing errors", () => { assert(not load"a = '\\\\345'") assert(not load"a = [=x]") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(dostring + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/locals.test.js b/test/test-suite/locals.test.js index 27015194..8f92d931 100644 --- a/test/test-suite/locals.test.js +++ b/test/test-suite/locals.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test('[test-suite] locals: bug in 5.1', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -19,15 +17,15 @@ test('[test-suite] locals: bug in 5.1', () => { local function f(x) x = nil; local y; return x, y end assert(f(10) == nil and select(2, f(20)) == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] locals: local scope', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -79,10 +77,10 @@ test('[test-suite] locals: local scope', () => { f(2) assert(type(f) == 'function') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); @@ -96,7 +94,7 @@ const getenv = ` test('[test-suite] locals: test for global table of loaded chunks', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -107,15 +105,15 @@ test('[test-suite] locals: test for global table of loaded chunks', () => { f() assert(c.a == 3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(getenv + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] locals: old test for limits for special instructions (now just a generic test)', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -138,15 +136,15 @@ test('[test-suite] locals: old test for limits for special instructions (now jus until p <= 0 end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] locals: testing lexical environments', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -180,8 +178,8 @@ test('[test-suite] locals: testing lexical environments', () => { assert(x==20) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(getenv + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/ltests.js b/test/test-suite/ltests.js index 6fc086c9..fb33e1a2 100644 --- a/test/test-suite/ltests.js +++ b/test/test-suite/ltests.js @@ -1,19 +1,12 @@ -"use strict"; - -const assert = require("assert"); - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const { - luastring_eq, - luastring_indexOf, - to_jsstring, - to_luastring -} = require("../../src/fengaricore.js"); -const ljstype = require('../../src/ljstype.js'); -const lopcodes = require('../../src/lopcodes.js'); -const { pushobj2s } = require('../../src/lobject.js'); -const sprintf = require('sprintf-js').sprintf; +import assert from "assert"; + +import { lua_tointeger, lua_pop, lua_gettop, LUA_REGISTRYINDEX, lua_upvalueindex, lua_pushstring, lua_pushnumber, lua_absindex, lua_rawlen, lua_rawseti, lua_arith, lua_call, lua_callk, LUA_OPEQ, LUA_OPLT, LUA_OPLE, lua_pushboolean, lua_compare, lua_concat, lua_copy, lua_tocfunction, lua_getfield, lua_getglobal, lua_getmetatable, lua_pushnil, lua_gettable, lua_pushinteger, lua_tostring, lua_insert, lua_iscfunction, lua_isfunction, lua_isnil, lua_isnone, lua_isnumber, lua_isstring, lua_istable, lua_islightuserdata, lua_isuserdata, lua_len, lua_newtable, lua_newthread, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pushcclosure, lua_pushvalue, lua_rawgeti, lua_rawgetp, lua_rawsetp, lua_remove, lua_replace, lua_resume, lua_tothread, lua_rotate, lua_setfield, lua_setglobal, lua_setmetatable, lua_settable, lua_settop, lua_error, lua_toboolean, lua_pushcfunction, lua_tonumber, lua_topointer, lua_xmove, lua_yield, lua_yieldk, lua_isthread, LUA_TFUNCTION, lua_getupvalue, lua_setupvalue, lua_pushlightuserdata, lua_touserdata, lua_pushlstring, lua_newstate, lua_atpanic, lua_type, LUA_TTABLE, lua_close, LUA_OK, LUA_MULTRET, lua_tojsstring, lua_checkstack, lua_pushliteral, lua_sethook, lua_isnoneornil, LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, LUA_MASKCOUNT, LUA_YIELD, lua_createtable } from '../../src/lua.js'; +import { luaL_error, luaL_checkstack, luaL_gsub, luaL_len, luaL_loadfile, luaL_checkstring, luaL_loadstring, luaL_newmetatable, luaL_tojsstring, luaL_testudata, luaL_typename, luaL_checkinteger, luaL_checktype, luaL_checknumber, luaL_argcheck, luaL_requiref, luaL_getsubtable, LUA_PRELOAD_TABLE, luaL_checklstring, luaL_loadbuffer, luaL_optstring, luaL_optinteger, luaL_newlib } from '../../src/lauxlib.js'; +import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from "../../src/fengaricore.js"; +import { lisdigit } from '../../src/ljstype.js'; +import { GET_OPCODE, OpCodes, getOpMode, iABC, GETARG_A, GETARG_B, GETARG_C, iABx, GETARG_Bx, iAsBx, GETARG_sBx, iAx, GETARG_Ax } from '../../src/lopcodes.js'; +import { pushobj2s } from '../../src/lobject.js'; +import { sprintf } from 'sprintf-js'; const delimits = [" ", "\t", "\n", ",", ";"].map(e => e.charCodeAt(0)); @@ -33,12 +26,12 @@ const getnum = function(L, L1, pc) { let sig = 1; skip(pc); if (pc.script[pc.offset] === '.'.charCodeAt(0)) { - res = lua.lua_tointeger(L1, -1); - lua.lua_pop(L1, 1); + res = lua_tointeger(L1, -1); + lua_pop(L1, 1); pc.offset++; return res; } else if (pc.script[pc.offset] === '*'.charCodeAt(0)) { - res = lua.lua_gettop(L1); + res = lua_gettop(L1); pc.offset++; return res; } @@ -46,9 +39,9 @@ const getnum = function(L, L1, pc) { sig = -1; pc.offset++; } - if (!ljstype.lisdigit(pc.script[pc.offset])) - lauxlib.luaL_error(L, to_luastring("number expected (%s)"), pc.script); - while (ljstype.lisdigit(pc.script[pc.offset])) res = res*10 + pc.script[pc.offset++] - '0'.charCodeAt(0); + if (!lisdigit(pc.script[pc.offset])) + luaL_error(L, to_luastring("number expected (%s)"), pc.script); + while (lisdigit(pc.script[pc.offset])) res = res*10 + pc.script[pc.offset++] - '0'.charCodeAt(0); return sig*res; }; @@ -59,7 +52,7 @@ const getstring = function(L, buff, pc) { let quote = pc.script[pc.offset++]; while (pc.script[pc.offset] !== quote) { if (pc.script[pc.offset] === 0 || pc.offset >= pc.script.length) - lauxlib.luaL_error(L, to_luastring("unfinished string in JS script", true)); + luaL_error(L, to_luastring("unfinished string in JS script", true)); buff[i++] = pc.script[pc.offset++]; } pc.offset++; @@ -73,9 +66,9 @@ const getstring = function(L, buff, pc) { const getindex = function(L, L1, pc) { skip(pc); switch (pc.script[pc.offset++]) { - case 'R'.charCodeAt(0): return lua.LUA_REGISTRYINDEX; - case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, to_luastring("deprecated index 'G'", true)); - case 'U'.charCodeAt(0): return lua.lua_upvalueindex(getnum(L, L1, pc)); + case 'R'.charCodeAt(0): return LUA_REGISTRYINDEX; + case 'G'.charCodeAt(0): return luaL_error(L, to_luastring("deprecated index 'G'", true)); + case 'U'.charCodeAt(0): return lua_upvalueindex(getnum(L, L1, pc)); default: pc.offset--; return getnum(L, L1, pc); } }; @@ -83,14 +76,14 @@ const getindex = function(L, L1, pc) { const codes = ["OK", "YIELD", "ERRRUN", "ERRSYNTAX", "ERRMEM", "ERRGCMM", "ERRERR"].map(e => to_luastring(e)); const pushcode = function(L, code) { - lua.lua_pushstring(L, codes[code]); + lua_pushstring(L, codes[code]); }; const printstack = function(L) { - let n = lua.lua_gettop(L); + let n = lua_gettop(L); for (let i = 1; i <= n; i++) { console.log("${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n"); - lua.lua_pop(L, 1); + lua_pop(L, 1); } console.log(""); }; @@ -108,39 +101,39 @@ const ops = "+-*%^/\\&|~<>_!".split('').map(e => e.charCodeAt(0)); const runJS = function(L, L1, pc) { let buff = new Uint8Array(300); let status = 0; - if (!pc || !pc.script) return lauxlib.luaL_error(L, to_luastring("attempt to runJS null script")); + if (!pc || !pc.script) return luaL_error(L, to_luastring("attempt to runJS null script")); for (;;) { let inst = to_jsstring(getstring(L, buff, pc)); if (inst.length === 0) return 0; switch (inst) { case "absindex": { - lua.lua_pushnumber(L1, lua.lua_absindex(L1, getindex(L, L1, pc))); + lua_pushnumber(L1, lua_absindex(L1, getindex(L, L1, pc))); break; } case "append": { let t = getindex(L, L1, pc); - let i = lua.lua_rawlen(L1, t); - lua.lua_rawseti(L1, t, i + 1); + let i = lua_rawlen(L1, t); + lua_rawseti(L1, t, i + 1); break; } case "arith": { let op; skip(pc); op = ops.indexOf(pc.script[pc.offset++]); - lua.lua_arith(L1, op); + lua_arith(L1, op); break; } case "call": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); - lua.lua_call(L1, narg, nres); + lua_call(L1, narg, nres); break; } case "callk": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); - lua.lua_callk(L1, narg, nres, i, Cfunck); + lua_callk(L1, narg, nres, i, Cfunck); break; } case "checkstack": { @@ -148,189 +141,189 @@ const runJS = function(L, L1, pc) { let msg = getstring(L, buff, pc); if (msg.length === 0) msg = null; /* to test 'luaL_checkstack' with no message */ - lauxlib.luaL_checkstack(L1, sz, msg); + luaL_checkstack(L1, sz, msg); break; } case "compare": { let opt = getstring(L, buff, pc); /* EQ, LT, or LE */ let op = (opt[0] === 'E'.charCodeAt(0)) - ? lua.LUA_OPEQ - : (opt[1] === 'T'.charCodeAt(0)) ? lua.LUA_OPLT : lua.LUA_OPLE; + ? LUA_OPEQ + : (opt[1] === 'T'.charCodeAt(0)) ? LUA_OPLT : LUA_OPLE; let a = getindex(L, L1, pc); let b = getindex(L, L1, pc); - lua.lua_pushboolean(L1, lua.lua_compare(L1, a, b, op)); + lua_pushboolean(L1, lua_compare(L1, a, b, op)); break; } case "concat": { - lua.lua_concat(L1, getnum(L, L1, pc)); + lua_concat(L1, getnum(L, L1, pc)); break; } case "copy": { let f = getindex(L, L1, pc); - lua.lua_copy(L1, f, getindex(L, L1, pc)); + lua_copy(L1, f, getindex(L, L1, pc)); break; } case "func2num": { - let func = lua.lua_tocfunction(L1, getindex(L, L1, pc)); + let func = lua_tocfunction(L1, getindex(L, L1, pc)); if (func === null) func = 0; else if (func.id) func = func.id; - lua.lua_pushnumber(L1, func); + lua_pushnumber(L1, func); break; } case "getfield": { let t = getindex(L, L1, pc); - lua.lua_getfield(L1, t, getstring(L, buff, pc)); + lua_getfield(L1, t, getstring(L, buff, pc)); break; } case "getglobal": { - lua.lua_getglobal(L1, getstring(L, buff, pc)); + lua_getglobal(L1, getstring(L, buff, pc)); break; } case "getmetatable": { - if (lua.lua_getmetatable(L1, getindex(L, L1, pc)) === 0) - lua.lua_pushnil(L1); + if (lua_getmetatable(L1, getindex(L, L1, pc)) === 0) + lua_pushnil(L1); break; } case "gettable": { - lua.lua_gettable(L1, getindex(L, L1, pc)); + lua_gettable(L1, getindex(L, L1, pc)); break; } case "gettop": { - lua.lua_pushinteger(L1, lua.lua_gettop(L1)); + lua_pushinteger(L1, lua_gettop(L1)); break; } case "gsub": { let a = getnum(L, L1, pc); let b = getnum(L, L1, pc); let c = getnum(L, L1, pc); - lauxlib.luaL_gsub(L1, lua.lua_tostring(L1, a), lua.lua_tostring(L1, b), lua.lua_tostring(L1, c)); + luaL_gsub(L1, lua_tostring(L1, a), lua_tostring(L1, b), lua_tostring(L1, c)); break; } case "insert": { - lua.lua_insert(L1, getnum(L, L1, pc)); + lua_insert(L1, getnum(L, L1, pc)); break; } case "iscfunction": { - lua.lua_pushboolean(L1, lua.lua_iscfunction(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_iscfunction(L1, getindex(L, L1, pc))); break; } case "isfunction": { - lua.lua_pushboolean(L1, lua.lua_isfunction(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_isfunction(L1, getindex(L, L1, pc))); break; } case "isnil": { - lua.lua_pushboolean(L1, lua.lua_isnil(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_isnil(L1, getindex(L, L1, pc))); break; } case "isnull": { - lua.lua_pushboolean(L1, lua.lua_isnone(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_isnone(L1, getindex(L, L1, pc))); break; } case "isnumber": { - lua.lua_pushboolean(L1, lua.lua_isnumber(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_isnumber(L1, getindex(L, L1, pc))); break; } case "isstring": { - lua.lua_pushboolean(L1, lua.lua_isstring(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_isstring(L1, getindex(L, L1, pc))); break; } case "istable": { - lua.lua_pushboolean(L1, lua.lua_istable(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_istable(L1, getindex(L, L1, pc))); break; } case "isudataval": { - lua.lua_pushboolean(L1, lua.lua_islightuserdata(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_islightuserdata(L1, getindex(L, L1, pc))); break; } case "isuserdata": { - lua.lua_pushboolean(L1, lua.lua_isuserdata(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_isuserdata(L1, getindex(L, L1, pc))); break; } case "len": { - lua.lua_len(L1, getindex(L, L1, pc)); + lua_len(L1, getindex(L, L1, pc)); break; } case "Llen": { - lua.lua_pushinteger(L1, lauxlib.luaL_len(L1, getindex(L, L1, pc))); + lua_pushinteger(L1, luaL_len(L1, getindex(L, L1, pc))); break; } case "loadfile": { - lauxlib.luaL_loadfile(L1, lauxlib.luaL_checkstring(L1, getnum(L, L1, pc))); + luaL_loadfile(L1, luaL_checkstring(L1, getnum(L, L1, pc))); break; } case "loadstring": { - let s = lauxlib.luaL_checkstring(L1, getnum(L, L1, pc)); - lauxlib.luaL_loadstring(L1, s); + let s = luaL_checkstring(L1, getnum(L, L1, pc)); + luaL_loadstring(L1, s); break; } case "newmetatable": { - lua.lua_pushboolean(L1, lauxlib.luaL_newmetatable(L1, getstring(L, buff, pc))); + lua_pushboolean(L1, luaL_newmetatable(L1, getstring(L, buff, pc))); break; } case "newtable": { - lua.lua_newtable(L1); + lua_newtable(L1); break; } case "newthread": { - lua.lua_newthread(L1); + lua_newthread(L1); break; } case "newuserdata": { - lua.lua_newuserdata(L1, getnum(L, L1, pc)); + lua_newuserdata(L1, getnum(L, L1, pc)); break; } case "next": { - lua.lua_next(L1, -2); + lua_next(L1, -2); break; } case "objsize": { - lua.lua_pushinteger(L1, lua.lua_rawlen(L1, getindex(L, L1, pc))); + lua_pushinteger(L1, lua_rawlen(L1, getindex(L, L1, pc))); break; } case "pcall": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); - status = lua.lua_pcall(L1, narg, nres, getnum(L, L1, pc)); + status = lua_pcall(L1, narg, nres, getnum(L, L1, pc)); break; } case "pcallk": { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); - status = lua.lua_pcallk(L1, narg, nres, 0, i, Cfunck); + status = lua_pcallk(L1, narg, nres, 0, i, Cfunck); break; } case "pop": { - lua.lua_pop(L1, getnum(L, L1, pc)); + lua_pop(L1, getnum(L, L1, pc)); break; } case "print": { let n = getnum(L, L1, pc); if (n !== 0) { - console.log(`${lauxlib.luaL_tojsstring(L1, n, null)}\n`); - lua.lua_pop(L1, 1); + console.log(`${luaL_tojsstring(L1, n, null)}\n`); + lua_pop(L1, 1); } else printstack(L1); break; } case "pushbool": { - lua.lua_pushboolean(L1, getnum(L, L1, pc)); + lua_pushboolean(L1, getnum(L, L1, pc)); break; } case "pushcclosure": { - lua.lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); + lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); break; } case "pushint": { - lua.lua_pushinteger(L1, getnum(L, L1, pc)); + lua_pushinteger(L1, getnum(L, L1, pc)); break; } case "pushnil": { - lua.lua_pushnil(L1); + lua_pushnil(L1); break; } case "pushnum": { - lua.lua_pushnumber(L1, getnum(L, L1, pc)); + lua_pushnumber(L1, getnum(L, L1, pc)); break; } case "pushstatus": { @@ -338,43 +331,43 @@ const runJS = function(L, L1, pc) { break; } case "pushstring": { - lua.lua_pushstring(L1, getstring(L, buff, pc)); + lua_pushstring(L1, getstring(L, buff, pc)); break; } case "pushupvalueindex": { - lua.lua_pushinteger(L1, lua.lua_upvalueindex(getnum(L, L1, pc))); + lua_pushinteger(L1, lua_upvalueindex(getnum(L, L1, pc))); break; } case "pushvalue": { - lua.lua_pushvalue(L1, getindex(L, L1, pc)); + lua_pushvalue(L1, getindex(L, L1, pc)); break; } case "rawgeti": { let t = getindex(L, L1, pc); - lua.lua_rawgeti(L1, t, getnum(L, L1, pc)); + lua_rawgeti(L1, t, getnum(L, L1, pc)); break; } case "rawgetp": { let t = getindex(L, L1, pc); - lua.lua_rawgetp(L1, t, getnum(L, L1, pc)); + lua_rawgetp(L1, t, getnum(L, L1, pc)); break; } case "rawsetp": { let t = getindex(L, L1, pc); - lua.lua_rawsetp(L1, t, getnum(L, L1, pc)); + lua_rawsetp(L1, t, getnum(L, L1, pc)); break; } case "remove": { - lua.lua_remove(L1, getnum(L, L1, pc)); + lua_remove(L1, getnum(L, L1, pc)); break; } case "replace": { - lua.lua_replace(L1, getindex(L, L1, pc)); + lua_replace(L1, getindex(L, L1, pc)); break; } case "resume": { let i = getindex(L, L1, pc); - status = lua.lua_resume(lua.lua_tothread(L1, i), L, getnum(L, L1, pc)); + status = lua_resume(lua_tothread(L1, i), L, getnum(L, L1, pc)); break; } case "return": { @@ -382,22 +375,22 @@ const runJS = function(L, L1, pc) { if (L1 != L) { let i; for (i = 0; i < n; i++) - lua.lua_pushstring(L, lua.lua_tostring(L1, -(n - i))); + lua_pushstring(L, lua_tostring(L1, -(n - i))); } return n; } case "rotate": { let i = getindex(L, L1, pc); - lua.lua_rotate(L1, i, getnum(L, L1, pc)); + lua_rotate(L1, i, getnum(L, L1, pc)); break; } case "setfield": { let t = getindex(L, L1, pc); - lua.lua_setfield(L1, t, getstring(L, buff, pc)); + lua_setfield(L1, t, getstring(L, buff, pc)); break; } case "setglobal": { - lua.lua_setglobal(L1, getstring(L, buff, pc)); + lua_setglobal(L1, getstring(L, buff, pc)); break; } case "sethook": { @@ -407,82 +400,82 @@ const runJS = function(L, L1, pc) { break; } case "setmetatable": { - lua.lua_setmetatable(L1, getindex(L, L1, pc)); + lua_setmetatable(L1, getindex(L, L1, pc)); break; } case "settable": { - lua.lua_settable(L1, getindex(L, L1, pc)); + lua_settable(L1, getindex(L, L1, pc)); break; } case "settop": { - lua.lua_settop(L1, getnum(L, L1, pc)); + lua_settop(L1, getnum(L, L1, pc)); break; } case "testudata": { let i = getindex(L, L1, pc); - lua.lua_pushboolean(L1, lauxlib.luaL_testudata(L1, i, getstring(L, buff, pc)) !== null); + lua_pushboolean(L1, luaL_testudata(L1, i, getstring(L, buff, pc)) !== null); break; } case "error": { - lua.lua_error(L1); + lua_error(L1); break; } case "throw": { throw new Error(); } case "tobool": { - lua.lua_pushboolean(L1, lua.lua_toboolean(L1, getindex(L, L1, pc))); + lua_pushboolean(L1, lua_toboolean(L1, getindex(L, L1, pc))); break; } case "tocfunction": { - lua.lua_pushcfunction(L1, lua.lua_tocfunction(L1, getindex(L, L1, pc))); + lua_pushcfunction(L1, lua_tocfunction(L1, getindex(L, L1, pc))); break; } case "tointeger": { - lua.lua_pushinteger(L1, lua.lua_tointeger(L1, getindex(L, L1, pc))); + lua_pushinteger(L1, lua_tointeger(L1, getindex(L, L1, pc))); break; } case "tonumber": { - lua.lua_pushnumber(L1, lua.lua_tonumber(L1, getindex(L, L1, pc))); + lua_pushnumber(L1, lua_tonumber(L1, getindex(L, L1, pc))); break; } case "topointer": { - let p = lua.lua_topointer(L1, getindex(L, L1, pc)); + let p = lua_topointer(L1, getindex(L, L1, pc)); if (p === null) p = 0; else if (p.id) p = p.id; - lua.lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */ + lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */ break; } case "tostring": { - let s = lua.lua_tostring(L1, getindex(L, L1, pc)); - let s1 = lua.lua_pushstring(L1, s); + let s = lua_tostring(L1, getindex(L, L1, pc)); + let s1 = lua_pushstring(L1, s); assert(luastring_eq(s, s1)); break; } case "type": { - lua.lua_pushstring(L1, lauxlib.luaL_typename(L1, getnum(L, L1, pc))); + lua_pushstring(L1, luaL_typename(L1, getnum(L, L1, pc))); break; } case "xmove": { let f = getindex(L, L1, pc); let t = getindex(L, L1, pc); - let fs = (f === 0) ? L1 : lua.lua_tothread(L1, f); - let ts = (t === 0) ? L1 : lua.lua_tothread(L1, t); + let fs = (f === 0) ? L1 : lua_tothread(L1, f); + let ts = (t === 0) ? L1 : lua_tothread(L1, t); let n = getnum(L, L1, pc); - if (n === 0) n = lua.lua_gettop(fs); - lua.lua_xmove(fs, ts, n); + if (n === 0) n = lua_gettop(fs); + lua_xmove(fs, ts, n); break; } case "yield": { - return lua.lua_yield(L1, getnum(L, L1, pc)); + return lua_yield(L1, getnum(L, L1, pc)); } case "yieldk": { let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); - return lua.lua_yieldk(L1, nres, i, Cfunck); + return lua_yieldk(L1, nres, i, Cfunck); } default: - lauxlib.luaL_error(L, to_luastring("unknown instruction %s"), buff); + luaL_error(L, to_luastring("unknown instruction %s"), buff); } } }; @@ -491,87 +484,87 @@ const runJS = function(L, L1, pc) { const testJS = function(L) { let L1; let pc; - if (lua.lua_isuserdata(L, 1)) { + if (lua_isuserdata(L, 1)) { L1 = getstate(L); - pc = lauxlib.luaL_checkstring(L, 2); - } else if (lua.lua_isthread(L, 1)) { - L1 = lua.lua_tothread(L, 1); - pc = lauxlib.luaL_checkstring(L, 2); + pc = luaL_checkstring(L, 2); + } else if (lua_isthread(L, 1)) { + L1 = lua_tothread(L, 1); + pc = luaL_checkstring(L, 2); } else { L1 = L; - pc = lauxlib.luaL_checkstring(L, 1); + pc = luaL_checkstring(L, 1); } return runJS(L, L1, { script: pc, offset: 0 }); }; const upvalue = function(L) { - let n = lauxlib.luaL_checkinteger(L, 2); - lauxlib.luaL_checktype(L, 1, lua.LUA_TFUNCTION); - if (lua.lua_isnone(L, 3)) { - let name = lua.lua_getupvalue(L, 1, n); + let n = luaL_checkinteger(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_isnone(L, 3)) { + let name = lua_getupvalue(L, 1, n); if (name === null) return 0; - lua.lua_pushstring(L, name); + lua_pushstring(L, name); return 2; } else { - let name = lua.lua_setupvalue(L, 1, n); - lua.lua_pushstring(L, name); + let name = lua_setupvalue(L, 1, n); + lua_pushstring(L, name); return 1; } }; const pushuserdata = function(L) { - let u = lauxlib.luaL_checkinteger(L, 1); - lua.lua_pushlightuserdata(L, u); + let u = luaL_checkinteger(L, 1); + lua_pushlightuserdata(L, u); return 1; }; const udataval = function(L) { - lua.lua_pushinteger(L, lua.lua_touserdata(L, 1)); + lua_pushinteger(L, lua_touserdata(L, 1)); return 1; }; const d2s = function(L) { - let d = lauxlib.luaL_checknumber(L, 1); + let d = luaL_checknumber(L, 1); let b = new ArrayBuffer(8); new DataView(b).setFloat64(0, d, true); - lua.lua_pushlstring(L, new Uint8Array(b), 8); + lua_pushlstring(L, new Uint8Array(b), 8); return 1; }; const s2d = function(L) { - let b = lauxlib.luaL_checkstring(L, 1); + let b = luaL_checkstring(L, 1); let dv = new DataView(b.buffer); - lua.lua_pushnumber(L, dv.getFloat64(0, true)); + lua_pushnumber(L, dv.getFloat64(0, true)); return 1; }; const newstate = function(L) { - let L1 = lua.lua_newstate(); + let L1 = lua_newstate(); if (L1) { - lua.lua_atpanic(L1, tpanic); - lua.lua_pushlightuserdata(L, L1); + lua_atpanic(L1, tpanic); + lua_pushlightuserdata(L, L1); } else - lua.lua_pushnil(L); + lua_pushnil(L); return 1; }; const getstate = function(L) { - let L1 = lua.lua_touserdata(L, 1); - lauxlib.luaL_argcheck(L, L1 !== null, 1, "state expected"); + let L1 = lua_touserdata(L, 1); + luaL_argcheck(L, L1 !== null, 1, "state expected"); return L1; }; -const luaopen_base = require("../../src/lbaselib.js").luaopen_base; -const luaopen_coroutine = require("../../src/lcorolib.js").luaopen_coroutine; -const luaopen_debug = require("../../src/ldblib.js").luaopen_debug; -const luaopen_io = require("../../src/liolib.js").luaopen_io; -const luaopen_os = require("../../src/loslib.js").luaopen_os; -const luaopen_math = require("../../src/lmathlib.js").luaopen_math; -const luaopen_string = require("../../src/lstrlib.js").luaopen_string; -const luaopen_table = require("../../src/ltablib.js").luaopen_table; -const luaopen_package = require("../../src/loadlib.js").luaopen_package; +import { luaopen_base } from "../../src/lbaselib.js"; +import { luaopen_coroutine } from "../../src/lcorolib.js"; +import { luaopen_debug } from "../../src/ldblib.js"; +import { luaopen_io } from "../../src/liolib.js"; +import { luaopen_os } from "../../src/loslib.js"; +import { luaopen_math } from "../../src/lmathlib.js"; +import { luaopen_string } from "../../src/lstrlib.js"; +import { luaopen_table } from "../../src/ltablib.js"; +import { luaopen_package } from "../../src/loadlib.js"; const loadlib = function(L) { let libs = { @@ -585,57 +578,57 @@ const loadlib = function(L) { "table": luaopen_table }; let L1 = getstate(L); - lauxlib.luaL_requiref(L1, to_luastring("package", true), luaopen_package, 0); - assert(lua.lua_type(L1, -1) == lua.LUA_TTABLE); + luaL_requiref(L1, to_luastring("package", true), luaopen_package, 0); + assert(lua_type(L1, -1) == LUA_TTABLE); /* 'requiref' should not reload module already loaded... */ - lauxlib.luaL_requiref(L1, to_luastring("package", true), null, 1); /* seg. fault if it reloads */ + luaL_requiref(L1, to_luastring("package", true), null, 1); /* seg. fault if it reloads */ /* ...but should return the same module */ - assert(lua.lua_compare(L1, -1, -2, lua.LUA_OPEQ)); - lauxlib.luaL_getsubtable(L1, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE); + assert(lua_compare(L1, -1, -2, LUA_OPEQ)); + luaL_getsubtable(L1, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); for (let name in libs) { - lua.lua_pushcfunction(L1, libs[name]); - lua.lua_setfield(L1, -2, to_luastring(name, true)); + lua_pushcfunction(L1, libs[name]); + lua_setfield(L1, -2, to_luastring(name, true)); } return 0; }; const closestate = function(L) { let L1 = getstate(L); - lua.lua_close(L1); + lua_close(L1); return 0; }; const doremote = function(L) { let L1 = getstate(L); let lcode; - let code = lauxlib.luaL_checklstring(L, 2, lcode); + let code = luaL_checklstring(L, 2, lcode); let status; - lua.lua_settop(L1, 0); - status = lauxlib.luaL_loadbuffer(L1, code, lcode, code); - if (status === lua.LUA_OK) - status = lua.lua_pcall(L1, 0, lua.LUA_MULTRET, 0); - if (status !== lua.LUA_OK) { - lua.lua_pushnil(L); - lua.lua_pushstring(L, lua.lua_tostring(L1, -1)); - lua.lua_pushinteger(L, status); + lua_settop(L1, 0); + status = luaL_loadbuffer(L1, code, lcode, code); + if (status === LUA_OK) + status = lua_pcall(L1, 0, LUA_MULTRET, 0); + if (status !== LUA_OK) { + lua_pushnil(L); + lua_pushstring(L, lua_tostring(L1, -1)); + lua_pushinteger(L, status); return 3; } else { let i = 0; - while (!lua.lua_isnone(L1, ++i)) - lua.lua_pushstring(L, lua.lua_tostring(L1, i)); - lua.lua_pop(L1, i-1); + while (!lua_isnone(L1, ++i)) + lua_pushstring(L, lua_tostring(L1, i)); + lua_pop(L1, i-1); return i-1; } }; const tpanic = function(L) { - console.error(`PANIC: unprotected error in call to Lua API (${lua.lua_tojsstring(L, -1)})\n`); + console.error(`PANIC: unprotected error in call to Lua API (${lua_tojsstring(L, -1)})\n`); return process.exit(1); /* do not return to Lua */ }; const newuserdata = function(L) { - lua.lua_newuserdata(L, lauxlib.luaL_checkinteger(L, 1)); + lua_newuserdata(L, luaL_checkinteger(L, 1)); return 1; }; @@ -645,13 +638,13 @@ const newuserdata = function(L) { const Chook = function(L, ar) { let scpt; let events = ["call", "ret", "line", "count", "tailcall"].map(e => to_luastring(e)); - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); - lua.lua_pushlightuserdata(L, L); - lua.lua_gettable(L, -2); /* get C_HOOK[L] (script saved by sethookaux) */ - scpt = lua.lua_tostring(L, -1); /* not very religious (string will be popped) */ - lua.lua_pop(L, 2); /* remove C_HOOK and script */ - lua.lua_pushstring(L, events[ar.event]); /* may be used by script */ - lua.lua_pushinteger(L, ar.currentline); /* may be used by script */ + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); + lua_pushlightuserdata(L, L); + lua_gettable(L, -2); /* get C_HOOK[L] (script saved by sethookaux) */ + scpt = lua_tostring(L, -1); /* not very religious (string will be popped) */ + lua_pop(L, 2); /* remove C_HOOK and script */ + lua_pushstring(L, events[ar.event]); /* may be used by script */ + lua_pushinteger(L, ar.currentline); /* may be used by script */ runJS(L, L, { script: scpt, offset: 0 }); /* run script from C_HOOK[L] */ }; @@ -667,35 +660,35 @@ class Aux { */ const panicback = function(L) { let b = new Aux(); - lua.lua_checkstack(L, 1); /* open space for 'Aux' struct */ - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* get 'Aux' struct */ - b = lua.lua_touserdata(L, -1); - lua.lua_pop(L, 1); /* remove 'Aux' struct */ + lua_checkstack(L, 1); /* open space for 'Aux' struct */ + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* get 'Aux' struct */ + b = lua_touserdata(L, -1); + lua_pop(L, 1); /* remove 'Aux' struct */ runJS(b.L, L, { script: b.paniccode, offset: 0 }); /* run optional panic code */ throw 1; }; const checkpanic = function(L) { let b = new Aux(); - let code = lauxlib.luaL_checkstring(L, 1); - b.paniccode = lauxlib.luaL_optstring(L, 2, ""); + let code = luaL_checkstring(L, 1); + b.paniccode = luaL_optstring(L, 2, ""); b.L = L; - let L1 = lua.lua_newstate(); /* create new state */ + let L1 = lua_newstate(); /* create new state */ if (L1 === null) { /* error? */ - lua.lua_pushnil(L); + lua_pushnil(L); return 1; } - lua.lua_atpanic(L1, panicback); /* set its panic function */ - lua.lua_pushlightuserdata(L1, b); - lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* store 'Aux' struct */ + lua_atpanic(L1, panicback); /* set its panic function */ + lua_pushlightuserdata(L1, b); + lua_setfield(L1, LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* store 'Aux' struct */ try { /* set jump buffer */ runJS(L, L1, { script: code, offset: 0 }); /* run code unprotected */ - lua.lua_pushliteral(L, "no errors"); + lua_pushliteral(L, "no errors"); } catch (e) { /* error handling */ /* move error message to original state */ - lua.lua_pushstring(L, lua.lua_tostring(L1, -1)); + lua_pushstring(L, lua_tostring(L1, -1)); } - lua.lua_close(L1); + lua_close(L1); return 1; }; @@ -704,69 +697,69 @@ const checkpanic = function(L) { */ const sethookaux = function(L, mask, count, scpt) { if (scpt.length <= 0) { /* no script? */ - lua.lua_sethook(L, null, 0, 0); /* turn off hooks */ + lua_sethook(L, null, 0, 0); /* turn off hooks */ return; } - lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* get C_HOOK table */ - if (!lua.lua_istable(L, -1)) { /* no hook table? */ - lua.lua_pop(L, 1); /* remove previous value */ - lua.lua_newtable(L); /* create new C_HOOK table */ - lua.lua_pushvalue(L, -1); - lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* register it */ + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* get C_HOOK table */ + if (!lua_istable(L, -1)) { /* no hook table? */ + lua_pop(L, 1); /* remove previous value */ + lua_newtable(L); /* create new C_HOOK table */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* register it */ } - lua.lua_pushlightuserdata(L, L); - lua.lua_pushstring(L, scpt); - lua.lua_settable(L, -3); /* C_HOOK[L] = script */ - lua.lua_sethook(L, Chook, mask, count); + lua_pushlightuserdata(L, L); + lua_pushstring(L, scpt); + lua_settable(L, -3); /* C_HOOK[L] = script */ + lua_sethook(L, Chook, mask, count); }; const sethook = function(L) { - if (lua.lua_isnoneornil(L, 1)) - lua.lua_sethook(L, null, 0, 0); /* turn off hooks */ + if (lua_isnoneornil(L, 1)) + lua_sethook(L, null, 0, 0); /* turn off hooks */ else { - const scpt = lauxlib.luaL_checkstring(L, 1); - const smask = lauxlib.luaL_checkstring(L, 2); - let count = lauxlib.luaL_optinteger(L, 3, 0); + const scpt = luaL_checkstring(L, 1); + const smask = luaL_checkstring(L, 2); + let count = luaL_optinteger(L, 3, 0); let mask = 0; - if (luastring_indexOf(smask, 'c'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKCALL; - if (luastring_indexOf(smask, 'r'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKRET; - if (luastring_indexOf(smask, 'l'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKLINE; - if (count > 0) mask |= lua.LUA_MASKCOUNT; + if (luastring_indexOf(smask, 'c'.charCodeAt(0)) >= 0) mask |= LUA_MASKCALL; + if (luastring_indexOf(smask, 'r'.charCodeAt(0)) >= 0) mask |= LUA_MASKRET; + if (luastring_indexOf(smask, 'l'.charCodeAt(0)) >= 0) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; sethookaux(L, mask, count, scpt); } return 0; }; const Cfunc = function(L) { - return runJS(L, L, { script: lua.lua_tostring(L, lua.lua_upvalueindex(1)), offset: 0 }); + return runJS(L, L, { script: lua_tostring(L, lua_upvalueindex(1)), offset: 0 }); }; const Cfunck = function(L, status, ctx) { pushcode(L, status); - lua.lua_setglobal(L, to_luastring("status", true)); - lua.lua_pushinteger(L, ctx); - lua.lua_setglobal(L, to_luastring("ctx", true)); - return runJS(L, L, { script: lua.lua_tostring(L, ctx), offset: 0 }); + lua_setglobal(L, to_luastring("status", true)); + lua_pushinteger(L, ctx); + lua_setglobal(L, to_luastring("ctx", true)); + return runJS(L, L, { script: lua_tostring(L, ctx), offset: 0 }); }; const makeCfunc = function(L) { - lauxlib.luaL_checkstring(L, 1); - lua.lua_pushcclosure(L, Cfunc, lua.lua_gettop(L)); + luaL_checkstring(L, 1); + lua_pushcclosure(L, Cfunc, lua_gettop(L)); return 1; }; const coresume = function(L) { let status; - let co = lua.lua_tothread(L, 1); - lauxlib.luaL_argcheck(L, co, 1, "coroutine expected"); - status = lua.lua_resume(co, L, 0); - if (status != lua.LUA_OK && status !== lua.LUA_YIELD) { - lua.lua_pushboolean(L, 0); - lua.lua_insert(L, -2); + let co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + status = lua_resume(co, L, 0); + if (status != LUA_OK && status !== LUA_YIELD) { + lua_pushboolean(L, 0); + lua_insert(L, -2); return 2; /* return false + error message */ } else { - lua.lua_pushboolean(L, 1); + lua_pushboolean(L, 1); return 1; } }; @@ -776,9 +769,9 @@ const obj_at = function(L, k) { }; const setnameval = function(L, name, val) { - lua.lua_pushstring(L, name); - lua.lua_pushinteger(L, val); - lua.lua_settable(L, -3); + lua_pushstring(L, name); + lua_pushinteger(L, val); + lua_settable(L, -3); }; const pushobject = function(L, o){ @@ -788,22 +781,22 @@ const pushobject = function(L, o){ const buildop = function(p, pc) { let i = p.code[pc]; - let o = lopcodes.GET_OPCODE(i); - let name = lopcodes.OpCodes[o]; + let o = GET_OPCODE(i); + let name = OpCodes[o]; let line = p.lineinfo.length !== 0 ? p.lineinfo[pc] : -1; let result = sprintf("(%4d) %4d - ", line, pc); //`(${line}) ${pc} - `; - switch (lopcodes.getOpMode(o)) { - case lopcodes.iABC: - result += sprintf("%-12s%4d %4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_B(i), lopcodes.GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; + switch (getOpMode(o)) { + case iABC: + result += sprintf("%-12s%4d %4d %4d", name, GETARG_A(i), GETARG_B(i), GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; break; - case lopcodes.iABx: - result += sprintf("%-12s%4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; + case iABx: + result += sprintf("%-12s%4d %4d", name, GETARG_A(i), GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; break; - case lopcodes.iAsBx: - result += sprintf("%-12s%4d %4d", name, lopcodes.GETARG_A(i), lopcodes.GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; + case iAsBx: + result += sprintf("%-12s%4d %4d", name, GETARG_A(i), GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; break; - case lopcodes.iAx: - result += sprintf("%-12s%4d", name, lopcodes.GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; + case iAx: + result += sprintf("%-12s%4d", name, GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; break; } @@ -811,29 +804,29 @@ const buildop = function(p, pc) { }; const listcode = function(L) { - lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1), + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, "Lua function expected"); let p = obj_at(L, 1); - lua.lua_newtable(L); + lua_newtable(L); setnameval(L, to_luastring("maxstack", true), p.maxstacksize); setnameval(L, to_luastring("numparams", true), p.numparams); for (let pc = 0; pc < p.code.length; pc++) { - lua.lua_pushinteger(L, pc+1); - lua.lua_pushstring(L, buildop(p, pc)); - lua.lua_settable(L, -3); + lua_pushinteger(L, pc+1); + lua_pushstring(L, buildop(p, pc)); + lua_settable(L, -3); } return 1; }; const listk = function(L) { - lauxlib.luaL_argcheck(L, - lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1), + luaL_argcheck(L, + lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, "Lua function expected"); let p = obj_at(L, 1); - lua.lua_createtable(L, p.k.length, 0); + lua_createtable(L, p.k.length, 0); for (let i = 0; i < p.k.length; i++) { pushobject(L, p.k[i]); - lua.lua_rawseti(L, -2, i + 1); + lua_rawseti(L, -2, i + 1); } return 1; }; @@ -860,14 +853,15 @@ const tests_funcs = { }; const luaB_opentests = function(L) { - lua.lua_atpanic(L, tpanic); - lauxlib.luaL_newlib(L, tests_funcs); + lua_atpanic(L, tpanic); + luaL_newlib(L, tests_funcs); return 1; }; const luaopen_tests = function(L) { - lauxlib.luaL_requiref(L, to_luastring("T"), luaB_opentests, 1); - lua.lua_pop(L, 1); /* remove lib */ + luaL_requiref(L, to_luastring("T"), luaB_opentests, 1); + lua_pop(L, 1); /* remove lib */ }; -module.exports.luaopen_tests = luaopen_tests; +const _luaopen_tests = luaopen_tests; +export { _luaopen_tests as luaopen_tests }; diff --git a/test/test-suite/math.test.js b/test/test-suite/math.test.js index 9cf4e21a..d1035d92 100644 --- a/test/test-suite/math.test.js +++ b/test/test-suite/math.test.js @@ -1,9 +1,9 @@ "use strict"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` local minint = math.mininteger @@ -53,22 +53,22 @@ const prefix = ` `; test("[test-suite] math: int bits", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(minint == 1 << (intbits - 1)) assert(maxint == minint - 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: number of bits in the mantissa of a floating-point number", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -87,15 +87,15 @@ test("[test-suite] math: number of bits in the mantissa of a floating-point numb assert(math.type(0) == "integer" and math.type(0.0) == "float" and math.type("10") == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: basic float notation", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -139,30 +139,30 @@ test("[test-suite] math: basic float notation", () => { assert(eqT(a, minint) and eqT(b, 0.0)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: math.huge", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(math.huge > 10e30) assert(-math.huge < -10e30) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: integer arithmetic", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -172,15 +172,15 @@ test("[test-suite] math: integer arithmetic", () => { assert(minint * minint == 0) assert(maxint * maxint * maxint == maxint) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing floor division and conversions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -215,15 +215,15 @@ test("[test-suite] math: testing floor division and conversions", () => { assert(minint // -2 == 2^(intbits - 2)) assert(maxint // -1 == -maxint) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: negative exponents", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -240,15 +240,15 @@ test("[test-suite] math: negative exponents", () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: comparison between floats and integers (border cases)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -268,15 +268,15 @@ test("[test-suite] math: comparison between floats and integers (border cases)", assert(minint + 0.0 == minint) assert(minint + 0.0 == -2.0^(intbits - 1)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: order between floats and integers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -305,15 +305,15 @@ test("[test-suite] math: order between floats and integers", () => { assert(-2^(intbits - 1) <= minint) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing order (floats can represent all integers)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -347,15 +347,15 @@ test("[test-suite] math: testing order (floats can represent all integers)", () assert(not (minint + 0.5 <= minint)) assert(not (minint <= minint - 1.0)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: NaN order", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -368,15 +368,15 @@ test("[test-suite] math: NaN order", () => { assert(not (minint <= NaN)) assert(not (minint < NaN)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: avoiding errors at compile time", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -387,14 +387,14 @@ test("[test-suite] math: avoiding errors at compile time", () => { checkcompt(msgf2i, ("return 1 | 2.0^%d"):format(intbits - 1)) checkcompt(msgf2i, "return 2.3 ~ '0.0'") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing overflow errors when converting from float to integer (runtime)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -428,15 +428,15 @@ test("[test-suite] math: testing overflow errors when converting from float to i -- 'minint' should be representable as a float no matter the precision assert(f2i(minint + 0.0) == minint) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing numeric strings", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -445,15 +445,15 @@ test("[test-suite] math: testing numeric strings", () => { assert(" -2 " + 1 == -1) assert(" -0xa " + 1 == -9) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -491,15 +491,15 @@ test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () assert(eqT(-10000000000000000000000.0, -10000000000000000000000)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: 'tonumber' with numbers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -508,15 +508,15 @@ test("[test-suite] math: 'tonumber' with numbers", () => { assert(eqT(tonumber(maxint), maxint) and eqT(tonumber(minint), minint)) assert(tonumber(1/0) == 1/0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: 'tonumber' with strings", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -558,15 +558,15 @@ test("[test-suite] math: 'tonumber' with strings", () => { assert(tonumber('\\t10000000000\\t', i) == i10) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: tests with very long numerals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -584,15 +584,15 @@ test("[test-suite] math: tests with very long numerals", () => { assert(tonumber('0xe03' .. string.rep('0', 1000) .. 'p-4000') == 3587.0) assert(tonumber('0x.' .. string.rep('0', 1000) .. '74p4004') == 0x7.4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing 'tonumber' for invalid formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -628,15 +628,15 @@ test("[test-suite] math: testing 'tonumber' for invalid formats", () => { assert(f(tonumber('e 1')) == nil) assert(f(tonumber(' 3.4.5 ')) == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -653,15 +653,15 @@ test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () assert(tonumber('0x0.51p') == nil) assert(tonumber('0x5p+-2') == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing hexadecimal numerals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -675,15 +675,15 @@ test("[test-suite] math: testing hexadecimal numerals", () => { -- possible confusion with decimal exponent assert(0E+1 == 0 and 0xE+1 == 15 and 0xe-1 == 13) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: floating hexas", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -711,15 +711,15 @@ test("[test-suite] math: floating hexas", () => { assert(tonumber('+1.23E18') == 1.23*10.0^18) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing order operators", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -733,15 +733,15 @@ test("[test-suite] math: testing order operators", () => { assert(('a'>='a') and not('a'>='b') and ('b'>='a')) assert(1.3 < 1.4 and 1.3 <= 1.4 and not (1.3 < 1.3) and 1.3 <= 1.3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing mod operator", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -762,15 +762,15 @@ test("[test-suite] math: testing mod operator", () => { assert(minint % -2 == 0) assert(maxint % -2 == -1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -787,15 +787,15 @@ test("[test-suite] math: non-portable tests because Windows C library cannot com assert(-1 % math.huge == math.huge) assert(-1 % -math.huge == -1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing unsigned comparisons", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -831,15 +831,15 @@ test("[test-suite] math: testing unsigned comparisons", () => { assert(tonumber(' 1.3e-2 ') == 1.3e-2) assert(tonumber(' -1.00000000000001 ') == -1.00000000000001) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing constant limits", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -847,15 +847,15 @@ test("[test-suite] math: testing constant limits", () => { assert(8388608 + -8388608 == 0) assert(8388607 + -8388607 == 0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing floor & ceil", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -902,15 +902,15 @@ test("[test-suite] math: testing floor & ceil", () => { assert(math.tointeger(0/0) == nil) -- NaN end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing fmod for integers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -934,15 +934,15 @@ test("[test-suite] math: testing fmod for integers", () => { checkerror("zero", math.fmod, 3, 0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing max/min", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -962,15 +962,15 @@ test("[test-suite] math: testing max/min", () => { assert(eqT(math.min(maxint - 2, maxint, maxint - 1), maxint - 2)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing implicit convertions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -978,15 +978,15 @@ test("[test-suite] math: testing implicit convertions", () => { assert(a*b == 200 and a+b == 30 and a-b == -10 and a/b == 0.5 and -b == -20) assert(a == '10' and b == '20') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: testing -0 and NaN", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1024,15 +1024,15 @@ test("[test-suite] math: testing -0 and NaN", () => { assert(a3 == a5) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: test random for floats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1055,15 +1055,15 @@ test("[test-suite] math: test random for floats", () => { ::ok:: end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: test random for small intervals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1099,15 +1099,15 @@ test("[test-suite] math: test random for small intervals", () => { aux({maxint - 3, maxint}) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: test random for large intervals", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1145,15 +1145,15 @@ test("[test-suite] math: test random for large intervals", () => { assert(not pcall(math.random, 1, 2, 3)) -- too many arguments `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: test random for empty interval", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1161,15 +1161,15 @@ test("[test-suite] math: test random for empty interval", () => { assert(not pcall(math.random, maxint, maxint - 1)) assert(not pcall(math.random, maxint, minint)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] math: interval too large", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -1177,8 +1177,8 @@ test("[test-suite] math: interval too large", () => { assert(not pcall(math.random, -1, maxint)) assert(not pcall(math.random, minint // 2, maxint // 2 + 1)) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/nextvar.test.js b/test/test-suite/nextvar.test.js index 1c4f3319..f360959d 100644 --- a/test/test-suite/nextvar.test.js +++ b/test/test-suite/nextvar.test.js @@ -1,9 +1,9 @@ "use strict"; -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` local function checkerror (msg, f, ...) @@ -13,7 +13,7 @@ const prefix = ` `; test("[test-suite] nextvar: testing size operator", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -28,15 +28,15 @@ test("[test-suite] nextvar: testing size operator", () => { assert(#a == i) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: testing ipairs", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -48,15 +48,15 @@ test("[test-suite] nextvar: testing ipairs", () => { for _ in ipairs{x=12, y=24} do assert(nil) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: test for 'false' x ipair", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -69,29 +69,29 @@ test("[test-suite] nextvar: test for 'false' x ipair", () => { end assert(i == 4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: iterator function is always the same", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{}) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] nextvar: JS tests", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -225,15 +225,15 @@ test.skip("[test-suite] nextvar: JS tests", () => { local a = {} for i=1,lim do a[i] = true; foo(i, table.unpack(a)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: test size operation on empty tables", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -243,15 +243,15 @@ test("[test-suite] nextvar: test size operation on empty tables", () => { assert(#{nil, nil, nil} == 0) assert(#{nil, nil, nil, nil} == 0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: test size operation on empty tables", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -261,15 +261,15 @@ test("[test-suite] nextvar: test size operation on empty tables", () => { assert(#{nil, nil, nil} == 0) assert(#{nil, nil, nil, nil} == 0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: next uses always the same iteration function", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -310,44 +310,44 @@ test("[test-suite] nextvar: next uses always the same iteration function", () => _G["xxx"] = 1 assert(xxx==find("xxx")) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: invalid key to 'next'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("invalid key", next, {10,20}, 3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` checkerror("bad argument", pairs) checkerror("bad argument", ipairs) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: fmod table", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -366,15 +366,15 @@ test("[test-suite] nextvar: fmod table", () => { assert(n.n == 9000) a = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: check next", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -391,15 +391,15 @@ test("[test-suite] nextvar: check next", () => { checknext{1,2,3,4,x=1,y=2,z=3} checknext{1,2,3,4,5,x=1,y=2,z=3} `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: # operator", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -412,15 +412,15 @@ test("[test-suite] nextvar: # operator", () => { assert(#a == i) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: maxn", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -441,15 +441,15 @@ test("[test-suite] nextvar: maxn", () => { table.maxn = nil `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: int overflow", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -457,15 +457,15 @@ test("[test-suite] nextvar: int overflow", () => { for i=0,50 do a[2^i] = true end assert(a[#a]) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: erasing values", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -542,15 +542,15 @@ test("[test-suite] nextvar: erasing values", () => { assert(table.remove(a, 2) == 20) assert(a[#a] == 30 and #a == 2) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: testing table library with metamethods", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -600,15 +600,15 @@ test("[test-suite] nextvar: testing table library with metamethods", () => { end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test.skip("[test-suite] nextvar: JS tests", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -641,15 +641,15 @@ test.skip("[test-suite] nextvar: JS tests", () => { table.move(u, 1, 4, 1, u2) assert(#tab2 == 4 and tab2[1] == tab[1] and tab2[4] == tab[4]) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: next", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -668,15 +668,15 @@ test("[test-suite] nextvar: next", () => { a = nil; for i=1,1 do assert(not a); a=1 end; assert(a) a = nil; for i=1,1,-1 do assert(not a); a=1 end; assert(a) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: testing floats in numeric for", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -699,29 +699,29 @@ test("[test-suite] nextvar: testing floats in numeric for", () => { a = 0; for i=1.0, 0.99999, -1 do a=a+1 end; assert(a==1) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: conversion", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: checking types", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -779,15 +779,15 @@ test("[test-suite] nextvar: checking types", () => { end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: testing generic 'for'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -808,15 +808,15 @@ test("[test-suite] nextvar: testing generic 'for'", () => { end assert(x == 5) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -848,15 +848,15 @@ test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { a.n = 5 a[3] = 30 `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] nextvar: testing ipairs with metamethods", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -871,8 +871,8 @@ test("[test-suite] nextvar: testing ipairs with metamethods", () => { end assert(i == a.n) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/pm.test.js b/test/test-suite/pm.test.js index c2d0de5c..47140d48 100644 --- a/test/test-suite/pm.test.js +++ b/test/test-suite/pm.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring, luaL_loadfile } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test("[test-suite] pm: pattern matching", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -87,15 +85,15 @@ test("[test-suite] pm: pattern matching", () => { assert(f("0alo alo", "%x*") == "0a") assert(f("alo alo", "%C+") == "alo alo") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: tonumber", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -114,15 +112,15 @@ test("[test-suite] pm: tonumber", () => { -- assert(f1('=======', '^(=*)=%1$') == '=======') assert(string.match('==========', '^([=]*)=%1$') == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: range", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -154,39 +152,39 @@ test("[test-suite] pm: range", () => { assert(strset('%Z') == strset('[\\1-\\255]')) assert(strset('.') == strset('[\\1-\\255%z]')) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); // Can't be represented by JS string, testing from actual lua file test("[test-suite] pm: classes", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-classes.lua")) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadfile(L, to_luastring("test/test-suite/pm-classes.lua")) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); // Can't be represented by JS string, testing from actual lua file test("[test-suite] pm: gsub", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-gsub.lua")) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadfile(L, to_luastring("test/test-suite/pm-gsub.lua")) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: empty matches", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -203,15 +201,15 @@ test("[test-suite] pm: empty matches", () => { assert(res == "-a-b-c-d-") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: gsub", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -245,15 +243,15 @@ test("[test-suite] pm: gsub", () => { end) assert(s == r and t[1] == 1 and t[3] == 3 and t[7] == 4 and t[13] == 4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: gsub isbalanced", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -265,15 +263,15 @@ test("[test-suite] pm: gsub isbalanced", () => { assert(not isbalanced("(9 ((8) 7) a b (\\0 c) a")) assert(string.gsub("alo 'oi' alo", "%b''", '"') == 'alo " alo') `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: capture", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -302,15 +300,15 @@ test("[test-suite] pm: capture", () => { checkerror("invalid capture index %%1", string.gsub, "alo", "(%1)", "a") checkerror("invalid use of '%%'", string.gsub, "alo", ".", "%x") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -327,15 +325,15 @@ test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { assert(not r and string.find(m, "too complex")) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: big strings (TODO: _soft)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -352,15 +350,15 @@ test("[test-suite] pm: big strings (TODO: _soft)", () => { assert(not pcall(string.gsub, a, 'b')) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: recursive nest of gsubs", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -371,15 +369,15 @@ test("[test-suite] pm: recursive nest of gsubs", () => { local x = "abcdef" assert(rev(rev(x)) == x) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: gsub with tables", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -393,15 +391,15 @@ test("[test-suite] pm: gsub with tables", () => { t = {}; setmetatable(t, {__index = function (t,s) return string.upper(s) end}) assert(string.gsub("a alo b hi", "%w%w+", t) == "a ALO b HI") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: gmatch", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -429,15 +427,15 @@ test("[test-suite] pm: gmatch", () => { for k,v in pairs(t) do assert(k+1 == v+0); a=a+1 end assert(a == 3) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: tests for '%f' ('frontiers')", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -467,15 +465,15 @@ test("[test-suite] pm: tests for '%f' ('frontiers')", () => { end assert(#a == 0) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: malformed patterns", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -497,15 +495,15 @@ test("[test-suite] pm: malformed patterns", () => { malform("%") malform("%f", "missing") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: \\0 in patterns", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -517,23 +515,23 @@ test("[test-suite] pm: \\0 in patterns", () => { assert(string.match("abc\\0\\0\\0", "%\\0+") == "\\0\\0\\0") assert(string.match("abc\\0\\0\\0", "%\\0%\\0?") == "\\0\\0") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] pm: magic char after \\0", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.find("abc\\0\\0","\\0.") == 4) assert(string.find("abcx\\0\\0abc\\0abc","x\\0\\0abc\\0a.") == 4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/sort.test.js b/test/test-suite/sort.test.js index cc33c0ca..38816a0b 100644 --- a/test/test-suite/sort.test.js +++ b/test/test-suite/sort.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` local unpack = table.unpack @@ -31,7 +29,7 @@ const prefix = ` `; test("[test-suite] sort: testing unpack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -60,15 +58,15 @@ test("[test-suite] sort: testing unpack", () => { a,x = unpack({1,2}, 1, 1) assert(a==1 and x==nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: testing unpack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -100,15 +98,15 @@ test("[test-suite] sort: testing unpack", () => { a, b = unpack(t, minI + 1, minI); assert(a == nil and b == nil) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: testing unpack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -118,15 +116,15 @@ test("[test-suite] sort: testing unpack", () => { checkerror("object length is not an integer", table.insert, t, 1) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: testing pack", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -139,15 +137,15 @@ test("[test-suite] sort: testing pack", () => { a = table.pack(nil, nil, nil, nil) assert(a[1] == nil and a.n == 4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: testing move", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -222,15 +220,15 @@ test("[test-suite] sort: testing move", () => { assert(not stat and msg == b) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: testing long move", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -261,15 +259,15 @@ test("[test-suite] sort: testing long move", () => { checkerror("wrap around", table.move, {}, 1, 2, maxI) checkerror("wrap around", table.move, {}, minI, -2, 2) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: testing sort, strange lengths", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -279,15 +277,15 @@ test("[test-suite] sort: testing sort, strange lengths", () => { a = setmetatable({}, {__len = function () return maxI end}) checkerror("too big", table.sort, a) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: test checks for invalid order functions", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -300,15 +298,15 @@ test("[test-suite] sort: test checks for invalid order functions", () => { check{1,2,3,4,5} check{1,2,3,4,5,6} `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: sort alpha", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -325,15 +323,15 @@ test("[test-suite] sort: sort alpha", () => { table.sort(a) check(a) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: sort perm", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -370,15 +368,15 @@ test("[test-suite] sort: sort perm", () => { perm{1,2,3,4,5,6} perm{2,2,3,3,5,6} `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: Invert-sorting", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -408,15 +406,15 @@ test("[test-suite] sort: Invert-sorting", () => { for i,v in pairs(a) do assert(v == false) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] sort: sorting", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -445,8 +443,8 @@ test("[test-suite] sort: sorting", () => { check(a, tt.__lt) check(a) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/strings.test.js b/test/test-suite/strings.test.js index 0e37674b..10fe6f7b 100644 --- a/test/test-suite/strings.test.js +++ b/test/test-suite/strings.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const checkerror = ` local maxi, mini = math.maxinteger, math.mininteger @@ -15,7 +13,7 @@ const checkerror = ` `; test('[test-suite] strings: string comparisons', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -37,15 +35,15 @@ test('[test-suite] strings: string comparisons', () => { assert('\\0\\0\\0' >= '\\0\\0\\0') assert(not ('\\0\\0b' < '\\0\\0a\\0')) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: string.sub', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -67,15 +65,15 @@ test('[test-suite] strings: string.sub', () => { assert('\\0\\0\\0' >= '\\0\\0\\0') assert(not ('\\0\\0b' < '\\0\\0a\\0')) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: string.find', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -93,15 +91,15 @@ test('[test-suite] strings: string.find', () => { assert(string.find('', 'aaa', 1) == nil) assert(('alo(.)alo'):find('(.)', 1, 1) == 4) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: string.len and #', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -113,15 +111,15 @@ test('[test-suite] strings: string.len and #', () => { assert(#"\\0\\0\\0" == 3) assert(#"1234567890" == 10) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: string.byte/string.char', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -158,15 +156,15 @@ test('[test-suite] strings: string.byte/string.char', () => { checkerror("too large", string.rep, 'a', (1 << 30), ',') end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: repetitions with separator', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -183,15 +181,15 @@ test('[test-suite] strings: repetitions with separator', () => { for i=0,30 do assert(string.len(string.rep('a', i)) == i) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: tostring', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -223,15 +221,15 @@ test('[test-suite] strings: tostring', () => { assert(tostring(-1203 + 0.0) == "-1203") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: string.format', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -258,15 +256,15 @@ test('[test-suite] strings: string.format', () => { assert(string.format('"-%20s.20s"', string.rep("%", 2000)) == string.format("%q", "-"..string.rep("%", 2000)..".20s")) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: %q', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -287,30 +285,30 @@ test('[test-suite] strings: %q', () => { checkerror("no literal", string.format, "%q", {}) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: embedded zeros error', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` assert(string.format("\\0%s\\0", "\\0\\0\\1") == "\\0\\0\\0\\1\\0") checkerror("contains zeros", string.format, "%10s", "\\0") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: format x tostring', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -333,15 +331,15 @@ test('[test-suite] strings: format x tostring', () => { assert(string.format("%+08d", 31501) == "+0031501") assert(string.format("%+08d", -30927) == "-0030927") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: longest number that can be formatted', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -358,15 +356,15 @@ test('[test-suite] strings: longest number that can be formatted', () => { assert(tonumber(s) == -(10^i)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test('[test-suite] strings: large numbers for format', () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -395,15 +393,15 @@ test('[test-suite] strings: large numbers for format', () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] strings: 'format %a %A'", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -440,15 +438,15 @@ test("[test-suite] strings: 'format %a %A'", () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] strings: errors in format", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -468,15 +466,15 @@ test("[test-suite] strings: errors in format", () => { assert(load("return 1\\n--comment without ending EOL")() == 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] strings: table.concat", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -507,16 +505,16 @@ test("[test-suite] strings: table.concat", () => { assert(table.concat(a, ",", 3) == "c") assert(table.concat(a, ",", 4) == "") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); // TODO: os.setlocale NYI test.skip("[test-suite] strings: locale", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -551,15 +549,15 @@ test.skip("[test-suite] strings: locale", () => { end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -570,8 +568,8 @@ test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work ac assert(co() == "2") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(checkerror + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/tpack.test.js b/test/test-suite/tpack.test.js index 3b97d3a5..422228fb 100644 --- a/test/test-suite/tpack.test.js +++ b/test/test-suite/tpack.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` local pack = string.pack @@ -31,7 +29,7 @@ const prefix = ` `; test("[test-suite] tpack: maximum size for integers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -47,15 +45,15 @@ test("[test-suite] tpack: maximum size for integers", () => { -- print("\\t" .. (little and "little" or "big") .. " endian") -- print("\\talignment: " .. align) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: minimum behavior for integer formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -71,15 +69,15 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { assert(unpack("l", pack("l", 0x7fffffff)) == 0x7fffffff) assert(unpack("l", pack("l", -0x80000000)) == -0x80000000) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: minimum behavior for integer formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -98,15 +96,15 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { assert(unpack(">I" .. i, s:reverse()) == 0xAA) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: minimum behavior for integer formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -131,15 +129,15 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: minimum behavior for integer formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -153,15 +151,15 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { assert(unpack(">i" .. i, s:reverse()) == n) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: sign extension", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -174,15 +172,15 @@ test("[test-suite] tpack: sign extension", () => { end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: mixed endianness", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -193,15 +191,15 @@ test("[test-suite] tpack: mixed endianness", () => { assert(pack("=i4", 2001) == pack("i4", 2001)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: testing invalid formats", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -216,15 +214,15 @@ test("[test-suite] tpack: testing invalid formats", () => { checkerror("variable%-length format", packsize, "s") checkerror("variable%-length format", packsize, "z") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: overflow in option size (error will be in digit after limit)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -239,15 +237,15 @@ test("[test-suite] tpack: overflow in option size (error will be in digit after assert(packsize(s) == 0x7fffffff) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: overflow in packing", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -268,15 +266,15 @@ test("[test-suite] tpack: overflow in packing", () => { assert(unpack(">I" .. i, pack(">I" .. i, umax)) == umax) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: Lua integer size", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -290,15 +288,15 @@ test("[test-suite] tpack: Lua integer size", () => { assert(pack("f", 24) == pack(">f", 24)) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -318,15 +316,15 @@ test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => assert(unpack(">d", pack(">d", n)) == n) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: testing pack/unpack of strings", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -372,15 +370,15 @@ test("[test-suite] tpack: testing pack/unpack of strings", () => { checkerror("longer than", pack, "c3", "1234") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: testing multiple types and sequence", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -392,15 +390,15 @@ test("[test-suite] tpack: testing multiple types and sequence", () => { g == 7 and h == 8) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: testing alignment", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -446,15 +444,15 @@ test("[test-suite] tpack: testing alignment", () => { checkerror("invalid next option", pack, "Xc1") end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] tpack: testing initial position", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -489,8 +487,8 @@ test("[test-suite] tpack: testing initial position", () => { end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(prefix + luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/utf8.test.js b/test/test-suite/utf8.test.js index 7e809da2..124681ea 100644 --- a/test/test-suite/utf8.test.js +++ b/test/test-suite/utf8.test.js @@ -1,9 +1,7 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; const prefix = ` local function checkerror (msg, f, ...) @@ -95,22 +93,22 @@ const prefix = ` `; test("[test-suite] utf8: offset", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` assert(utf8.offset("alo", 5) == nil) assert(utf8.offset("alo", -4) == nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: error indication in utf8.len", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` @@ -125,15 +123,15 @@ test("[test-suite] utf8: error indication in utf8.len", () => { check("\\xF4\\x9F\\xBF\\xBF", 1) end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: error in initial position for offset", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` @@ -145,15 +143,15 @@ test("[test-suite] utf8: error in initial position for offset", () => { checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) checkerror("continuation byte", utf8.offset, "\\x80", 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: codepoints", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` @@ -183,29 +181,29 @@ test("[test-suite] utf8: codepoints", () => { checkerror("value out of range", utf8.char, 0x10FFFF + 1) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` invalid("\\xF4\\x9F\\xBF\\xBF") `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: overlong sequences", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` @@ -214,15 +212,15 @@ test("[test-suite] utf8: overlong sequences", () => { invalid("\\xE0\\x9F\\xBF") -- 0x7FF (should be coded in 2 bytes) invalid("\\xF0\\x8F\\xBF\\xBF") -- 0xFFFF (should be coded in 3 bytes) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: invalid bytes", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` @@ -231,29 +229,29 @@ test("[test-suite] utf8: invalid bytes", () => { invalid("\\xFE") -- invalid byte invalid("\\xFF") -- invalid byte `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: empty strings", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` check("", {}) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] utf8: minimum and maximum values for each sequence size", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = prefix + ` @@ -286,8 +284,8 @@ test("[test-suite] utf8: minimum and maximum values for each sequence size", () end end `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/test-suite/vararg.test.js b/test/test-suite/vararg.test.js index 05385411..61f218d8 100644 --- a/test/test-suite/vararg.test.js +++ b/test/test-suite/vararg.test.js @@ -1,12 +1,10 @@ -"use strict"; - -const lua = require('../../src/lua.js'); -const lauxlib = require('../../src/lauxlib.js'); -const lualib = require('../../src/lualib.js'); -const {to_luastring} = require("../../src/fengaricore.js"); +import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; +import { luaL_openlibs } from '../../src/lualib.js'; +import { to_luastring } from "../../src/fengaricore.js"; test("[test-suite] vararg: testing vararg", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -74,15 +72,15 @@ test("[test-suite] vararg: testing vararg", () => { while i <= lim do a[i] = i; i=i+1 end assert(call(math.max, a) == lim) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] vararg: new-style varargs", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -107,15 +105,15 @@ test("[test-suite] vararg: new-style varargs", () => { a,b,c,d,e = f(4) assert(a==nil and b==nil and c==nil and d==nil and e==nil) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] vararg: varargs for main chunks", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -145,15 +143,15 @@ test("[test-suite] vararg: varargs for main chunks", () => { pcall(select, 10000) pcall(select, -10000) `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); test("[test-suite] vararg: bug in 5.2.2", () => { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); let luaCode = ` @@ -169,8 +167,8 @@ test("[test-suite] vararg: bug in 5.2.2", () => { -- assertion fail here f() `; - lualib.luaL_openlibs(L); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX) - throw new SyntaxError(lua.lua_tojsstring(L, -1)); - lua.lua_call(L, 0, 0); + luaL_openlibs(L); + if (luaL_loadstring(L, to_luastring(luaCode)) === LUA_ERRSYNTAX) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); diff --git a/test/tests.js b/test/tests.js index 631594b1..f8e7ebac 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,18 +1,16 @@ -"use strict"; - -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +import { LUA_OK, lua_tojsstring, lua_dump } from "../src/lua.js"; +import { luaL_newstate, luaL_loadstring } from "../src/lauxlib.js"; +import { to_luastring } from "../src/fengaricore.js"; const toByteCode = function(luaCode) { - let L = lauxlib.luaL_newstate(); + let L = luaL_newstate(); if (!L) throw Error("failed to create lua state"); - if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) !== lua.LUA_OK) - throw Error(lua.lua_tojsstring(L, -1)); + if (luaL_loadstring(L, to_luastring(luaCode)) !== LUA_OK) + throw Error(lua_tojsstring(L, -1)); let b = []; - if (lua.lua_dump(L, function(L, b, size, B) { + if (lua_dump(L, function(L, b, size, B) { B.push(...b.slice(0, size)); return 0; }, b, false) !== 0) @@ -20,4 +18,5 @@ const toByteCode = function(luaCode) { return Uint8Array.from(b); }; -module.exports.toByteCode = toByteCode; +const _toByteCode = toByteCode; +export { _toByteCode as toByteCode }; From 8fe4a9d334f08026e1dad4dd0e4e1124ec2ec757 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Tue, 2 Jun 2026 09:21:15 +0000 Subject: [PATCH 05/11] Fourth pass - formatting --- src/defs.js | 78 +++++++++++------------ src/fengari.js | 4 +- src/fengaricore.js | 18 +++--- src/fengarilib.js | 18 +++--- src/lapi.js | 128 ++++++++++++++++++------------------- src/lauxlib.js | 138 +++++++++++++++++++-------------------- src/lbaselib.js | 108 +++++++++++++++---------------- src/lcode.js | 10 +-- src/lcorolib.js | 36 +++++------ src/ldblib.js | 102 ++++++++++++++--------------- src/ldebug.js | 62 +++++++++--------- src/ldo.js | 34 +++++----- src/ldump.js | 2 +- src/linit.js | 26 ++++---- src/liolib.js | 54 ++++++++-------- src/llex.js | 134 +++++++++++++++++++------------------- src/llimits.js | 2 +- src/lmathlib.js | 72 ++++++++++----------- src/loadlib.js | 98 ++++++++++++++-------------- src/lobject.js | 56 ++++++++-------- src/lopcodes.js | 96 ++++++++++++++-------------- src/loslib.js | 104 +++++++++++++++--------------- src/lparser.js | 62 +++++++++--------- src/lstring.js | 4 +- src/lstrlib.js | 156 ++++++++++++++++++++++----------------------- src/ltable.js | 28 ++++---- src/ltablib.js | 46 ++++++------- src/ltm.js | 74 ++++++++++----------- src/lua.js | 12 ++-- src/luaconf.js | 73 ++++++++++----------- src/lualib.js | 50 +++++++-------- src/lundump.js | 42 ++++++------ src/lutf8lib.js | 38 +++++------ src/lvm.js | 18 +++--- src/lzio.js | 6 +- 35 files changed, 995 insertions(+), 994 deletions(-) diff --git a/src/defs.js b/src/defs.js index e87f715b..c700e401 100644 --- a/src/defs.js +++ b/src/defs.js @@ -6,7 +6,7 @@ import { LUAI_MAXSTACK } from './common.js'; export { LUAI_MAXSTACK }; -export const luastring_from = (typeof Uint8Array.from === "function") ? +export const luastring_from = (typeof Uint8Array.from === 'function') ? Uint8Array.from.bind(Uint8Array) : function (a) { let i = 0; @@ -16,19 +16,19 @@ export const luastring_from = (typeof Uint8Array.from === "function") ? return r; }; -export const luastring_indexOf = (typeof (new Uint8Array().indexOf) === "function") ? +export const luastring_indexOf = (typeof (new Uint8Array().indexOf) === 'function') ? function (s, v, i) { return s.indexOf(v, i); } : /* Browsers that don't support Uint8Array.indexOf seem to allow using Array.indexOf on Uint8Array objects e.g. IE11 */ function (s, v, i) { let array_indexOf = [].indexOf; - if (array_indexOf.call(new Uint8Array(1), 0) !== 0) throw Error("missing .indexOf"); + if (array_indexOf.call(new Uint8Array(1), 0) !== 0) throw Error('missing .indexOf'); return array_indexOf.call(s, v, i); }; -export const luastring_of = (typeof Uint8Array.of === "function") ? +export const luastring_of = (typeof Uint8Array.of === 'function') ? Uint8Array.of.bind(Uint8Array) : function () { return luastring_from(arguments); @@ -36,7 +36,7 @@ export const luastring_of = (typeof Uint8Array.of === "function") ? export function is_luastring(s) { return s instanceof Uint8Array; -}; +} /* test two lua strings for equality */ export function luastring_eq(a, b) { @@ -48,11 +48,11 @@ export function luastring_eq(a, b) { if (a[i] !== b[i]) return false; } return true; -}; +} -const unicode_error_message = "cannot convert invalid utf8 to javascript string"; +const unicode_error_message = 'cannot convert invalid utf8 to javascript string'; export function to_jsstring(value, from, to, replacement_char) { - if (!is_luastring(value)) throw new TypeError("to_jsstring expects a Uint8Array"); + if (!is_luastring(value)) throw new TypeError('to_jsstring expects a Uint8Array'); if (to === void 0) { to = value.length; @@ -60,7 +60,7 @@ export function to_jsstring(value, from, to, replacement_char) { to = Math.min(value.length, to); } - let str = ""; + let str = ''; for (let i = (from !== void 0 ? from : 0); i < to;) { let u0 = value[i++]; if (u0 < 0x80) { @@ -68,18 +68,18 @@ export function to_jsstring(value, from, to, replacement_char) { str += String.fromCharCode(u0); } else if (u0 < 0xC2 || u0 > 0xF4) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; } else if (u0 <= 0xDF) { /* two byte sequence */ if (i >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u1 = value[i++]; if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } str += String.fromCharCode(((u0 & 0x1F) << 6) + (u1 & 0x3F)); @@ -87,19 +87,19 @@ export function to_jsstring(value, from, to, replacement_char) { /* three byte sequence */ if (i + 1 >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u1 = value[i++]; if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u2 = value[i++]; if ((u2 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u = ((u0 & 0x0F) << 12) + ((u1 & 0x3F) << 6) + (u2 & 0x3F); @@ -115,25 +115,25 @@ export function to_jsstring(value, from, to, replacement_char) { /* four byte sequence */ if (i + 2 >= to) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u1 = value[i++]; if ((u1 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u2 = value[i++]; if ((u2 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } let u3 = value[i++]; if ((u3 & 0xC0) !== 0x80) { if (!replacement_char) throw RangeError(unicode_error_message); - str += "�"; + str += '�'; continue; } /* Has to be astral codepoint */ @@ -145,33 +145,33 @@ export function to_jsstring(value, from, to, replacement_char) { } } return str; -}; +} /* bytes allowed unescaped in a uri */ -const uri_allowed = (";,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*'()#").split('').reduce(function (uri_allowed, c) { +const uri_allowed = (';,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*\'()#').split('').reduce(function (uri_allowed, c) { uri_allowed[c.charCodeAt(0)] = true; return uri_allowed; }, {}); /* utility function to convert a lua string to a js string with uri escaping */ export function to_uristring(a) { - if (!is_luastring(a)) throw new TypeError("to_uristring expects a Uint8Array"); - let s = ""; + if (!is_luastring(a)) throw new TypeError('to_uristring expects a Uint8Array'); + let s = ''; for (let i = 0; i < a.length; i++) { let v = a[i]; if (uri_allowed[v]) { s += String.fromCharCode(v); } else { - s += "%" + (v < 0x10 ? "0" : "") + v.toString(16); + s += '%' + (v < 0x10 ? '0' : '') + v.toString(16); } } return s; -}; +} const to_luastring_cache = {}; export function to_luastring(str, cache) { - if (typeof str !== "string") throw new TypeError("to_luastring expects a javascript string"); + if (typeof str !== 'string') throw new TypeError('to_luastring expects a javascript string'); if (cache) { let cached = to_luastring_cache[str]; @@ -216,31 +216,31 @@ export function to_luastring(str, cache) { if (cache) to_luastring_cache[str] = outU8Array; return outU8Array; -}; +} export function from_userstring(str) { if (!is_luastring(str)) { - if (typeof str === "string") { + if (typeof str === 'string') { str = to_luastring(str); } else { - throw new TypeError("expects an array of bytes or javascript string"); + throw new TypeError('expects an array of bytes or javascript string'); } } return str; -}; +} /* mark for precompiled code ('Lua') */ -export const LUA_SIGNATURE = to_luastring("\x1bLua"); +export const LUA_SIGNATURE = to_luastring('\x1bLua'); -export const LUA_VERSION_MAJOR = "5"; -export const LUA_VERSION_MINOR = "3"; +export const LUA_VERSION_MAJOR = '5'; +export const LUA_VERSION_MINOR = '3'; export const LUA_VERSION_NUM = 503; -export const LUA_VERSION_RELEASE = "4"; +export const LUA_VERSION_RELEASE = '4'; -export const LUA_VERSION = "Lua " + LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; -export const LUA_RELEASE = LUA_VERSION + "." + LUA_VERSION_RELEASE; -export const LUA_COPYRIGHT = LUA_RELEASE + " Copyright (C) 1994-2017 Lua.org, PUC-Rio"; -export const LUA_AUTHORS = "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"; +export const LUA_VERSION = 'Lua ' + LUA_VERSION_MAJOR + '.' + LUA_VERSION_MINOR; +export const LUA_RELEASE = LUA_VERSION + '.' + LUA_VERSION_RELEASE; +export const LUA_COPYRIGHT = LUA_RELEASE + ' Copyright (C) 1994-2017 Lua.org, PUC-Rio'; +export const LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo, W. Celes'; export const thread_status = { LUA_OK: 0, @@ -307,7 +307,7 @@ export const LUA_REGISTRYINDEX = -LUAI_MAXSTACK - 1000; export function lua_upvalueindex(i) { return LUA_REGISTRYINDEX - i; -}; +} /* predefined values in the registry */ export const LUA_RIDX_MAINTHREAD = 1; diff --git a/src/fengari.js b/src/fengari.js index 7450c00c..cd22878f 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -6,9 +6,9 @@ Copyright © 2017-2019 Daurnimator Copyright © 1994–2017 Lua.org, PUC-Rio. */ -"use strict"; +'use strict'; -export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; +export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from './fengaricore.js'; import * as luaconf from './luaconf.js'; import * as lua from './lua.js'; diff --git a/src/fengaricore.js b/src/fengaricore.js index af01cc5e..34f766f5 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,18 +6,18 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ -import { LUA_COPYRIGHT } from "./defs.js"; +import { LUA_COPYRIGHT } from './defs.js'; -export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from "./defs.js"; +export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from './defs.js'; -const FENGARI_VERSION_MAJOR = "0"; -const FENGARI_VERSION_MINOR = "1"; +const FENGARI_VERSION_MAJOR = '0'; +const FENGARI_VERSION_MINOR = '1'; const FENGARI_VERSION_NUM = 1; -const FENGARI_VERSION_RELEASE = "5"; -const FENGARI_VERSION = "Fengari " + FENGARI_VERSION_MAJOR + "." + FENGARI_VERSION_MINOR; -const FENGARI_RELEASE = FENGARI_VERSION + "." + FENGARI_VERSION_RELEASE; -const FENGARI_AUTHORS = "B. Giannangeli, Daurnimator"; -const FENGARI_COPYRIGHT = FENGARI_RELEASE + " Copyright (C) 2017-2019 " + FENGARI_AUTHORS + "\nBased on: " + LUA_COPYRIGHT; +const FENGARI_VERSION_RELEASE = '5'; +const FENGARI_VERSION = 'Fengari ' + FENGARI_VERSION_MAJOR + '.' + FENGARI_VERSION_MINOR; +const FENGARI_RELEASE = FENGARI_VERSION + '.' + FENGARI_VERSION_RELEASE; +const FENGARI_AUTHORS = 'B. Giannangeli, Daurnimator'; +const FENGARI_COPYRIGHT = FENGARI_RELEASE + ' Copyright (C) 2017-2019 ' + FENGARI_AUTHORS + '\nBased on: ' + LUA_COPYRIGHT; const _FENGARI_AUTHORS = FENGARI_AUTHORS; export { _FENGARI_AUTHORS as FENGARI_AUTHORS }; diff --git a/src/fengarilib.js b/src/fengarilib.js index 75d21440..72756548 100644 --- a/src/fengarilib.js +++ b/src/fengarilib.js @@ -1,25 +1,25 @@ import { lua_pushinteger, lua_pushliteral, lua_setfield } from './lua.js'; import { luaL_newlib } from './lauxlib.js'; -import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, to_luastring } from "./fengaricore.js"; +import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, to_luastring } from './fengaricore.js'; const luaopen_fengari = function(L) { luaL_newlib(L, {}); lua_pushliteral(L, FENGARI_AUTHORS); - lua_setfield(L, -2, to_luastring("AUTHORS")); + lua_setfield(L, -2, to_luastring('AUTHORS')); lua_pushliteral(L, FENGARI_COPYRIGHT); - lua_setfield(L, -2, to_luastring("COPYRIGHT")); + lua_setfield(L, -2, to_luastring('COPYRIGHT')); lua_pushliteral(L, FENGARI_RELEASE); - lua_setfield(L, -2, to_luastring("RELEASE")); + lua_setfield(L, -2, to_luastring('RELEASE')); lua_pushliteral(L, FENGARI_VERSION); - lua_setfield(L, -2, to_luastring("VERSION")); + lua_setfield(L, -2, to_luastring('VERSION')); lua_pushliteral(L, FENGARI_VERSION_MAJOR); - lua_setfield(L, -2, to_luastring("VERSION_MAJOR")); + lua_setfield(L, -2, to_luastring('VERSION_MAJOR')); lua_pushliteral(L, FENGARI_VERSION_MINOR); - lua_setfield(L, -2, to_luastring("VERSION_MINOR")); + lua_setfield(L, -2, to_luastring('VERSION_MINOR')); lua_pushinteger(L, FENGARI_VERSION_NUM); - lua_setfield(L, -2, to_luastring("VERSION_NUM")); + lua_setfield(L, -2, to_luastring('VERSION_NUM')); lua_pushliteral(L, FENGARI_VERSION_RELEASE); - lua_setfield(L, -2, to_luastring("VERSION_RELEASE")); + lua_setfield(L, -2, to_luastring('VERSION_RELEASE')); return 1; }; diff --git a/src/lapi.js b/src/lapi.js index 163ee336..d1099c0b 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -34,23 +34,23 @@ const { LUA_TUSERDATA } = constant_types; -const {LUA_OK} = thread_status; +const { LUA_OK } = thread_status; const api_incr_top = function (L) { L.top++; - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); }; const api_checknelems = function (L, n) { - api_check(L, n < (L.top - L.ci.funcOff), "not enough elements in the stack"); + api_check(L, n < (L.top - L.ci.funcOff), 'not enough elements in the stack'); }; const fengari_argcheck = function (c) { - if (!c) throw TypeError("invalid argument"); + if (!c) throw TypeError('invalid argument'); }; const fengari_argcheckinteger = function (n) { - fengari_argcheck(typeof n === "number" && (n | 0) === n); + fengari_argcheck(typeof n === 'number' && (n | 0) === n); }; const isvalid = function (o) { @@ -79,17 +79,17 @@ const index2addr = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), "unacceptable index"); + api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); if (o >= L.top) return luaO_nilobject; else return L.stack[o]; } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, "invalid index"); + api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); return L.stack[L.top + idx]; } else if (idx === LUA_REGISTRYINDEX) { return L.l_G.l_registry; } else { /* upvalues */ idx = LUA_REGISTRYINDEX - idx; - api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); + api_check(L, idx <= MAXUPVAL + 1, 'upvalue index too large'); if (ci.func.ttislcf()) /* light C function? */ return luaO_nilobject; /* it has no upvalues */ else { @@ -103,21 +103,21 @@ const index2addr_ = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), "unacceptable index"); + api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); if (o >= L.top) return null; else return o; } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, "invalid index"); + api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); return L.top + idx; } else { /* registry or upvalue */ - throw Error("attempt to use pseudo-index"); + throw Error('attempt to use pseudo-index'); } }; const lua_checkstack = function (L, n) { let res; let ci = L.ci; - api_check(L, n >= 0, "negative 'n'"); + api_check(L, n >= 0, 'negative \'n\''); if (L.stack_last - L.top > n) /* stack large enough? */ res = true; else { /* no; need to grow stack */ @@ -139,8 +139,8 @@ const lua_checkstack = function (L, n) { const lua_xmove = function (from, to, n) { if (from === to) return; api_checknelems(from, n); - api_check(from, from.l_G === to.l_G, "moving among independent states"); - api_check(from, to.ci.top - to.top >= n, "stack overflow"); + api_check(from, from.l_G === to.l_G, 'moving among independent states'); + api_check(from, to.ci.top - to.top >= n, 'stack overflow'); from.top -= n; for (let i = 0; i < n; i++) { to.stack[to.top] = new _TValue(); @@ -169,17 +169,17 @@ const lua_gettop = function (L) { const lua_pushvalue = function (L, idx) { pushobj2s(L, index2addr(L, idx)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); }; const lua_settop = function (L, idx) { let func = L.ci.funcOff; let newtop; if (idx >= 0) { - api_check(L, idx <= L.stack_last - (func + 1), "new top too large"); + api_check(L, idx <= L.stack_last - (func + 1), 'new top too large'); newtop = func + 1 + idx; } else { - api_check(L, -(idx + 1) <= L.top - (func + 1), "invalid new top"); + api_check(L, -(idx + 1) <= L.top - (func + 1), 'invalid new top'); newtop = L.top + idx + 1; /* 'subtract' index (index is negative) */ } adjust_top(L, newtop); @@ -206,8 +206,8 @@ const lua_rotate = function (L, idx, n) { let t = L.top - 1; let pIdx = index2addr_(L, idx); let p = L.stack[pIdx]; - api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, "index not in the stack"); - api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), "invalid 'n'"); + api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, 'index not in the stack'); + api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), 'invalid \'n\''); let m = n >= 0 ? t - n : pIdx - n - 1; /* end of prefix */ reverse(L, pIdx, m); reverse(L, m + 1, L.top - 1); @@ -243,7 +243,7 @@ const lua_pushnil = function (L) { }; const lua_pushnumber = function (L, n) { - fengari_argcheck(typeof n === "number"); + fengari_argcheck(typeof n === 'number'); L.stack[L.top] = new TValue(LUA_TNUMFLT, n); api_incr_top(L); }; @@ -258,15 +258,15 @@ const lua_pushlstring = function (L, s, len) { fengari_argcheckinteger(len); let ts; if (len === 0) { - s = to_luastring("", true); + s = to_luastring('', true); ts = luaS_bless(L, s); } else { s = from_userstring(s); - api_check(L, s.length >= len, "invalid length to lua_pushlstring"); + api_check(L, s.length >= len, 'invalid length to lua_pushlstring'); ts = luaS_new(L, s.subarray(0, len)); } pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return ts.value; }; @@ -279,7 +279,7 @@ const lua_pushstring = function (L, s) { pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return s; }; @@ -299,24 +299,24 @@ const lua_pushliteral = function (L, s) { L.stack[L.top] = new TValue(LUA_TNIL, null); L.top++; } else { - fengari_argcheck(typeof s === "string"); + fengari_argcheck(typeof s === 'string'); let ts = luaS_newliteral(L, s); pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return s; }; const lua_pushcclosure = function (L, fn, n) { - fengari_argcheck(typeof fn === "function"); + fengari_argcheck(typeof fn === 'function'); fengari_argcheckinteger(n); if (n === 0) L.stack[L.top] = new TValue(LUA_TLCF, fn); else { api_checknelems(L, n); - api_check(L, n <= MAXUPVAL, "upvalue index too large"); + api_check(L, n <= MAXUPVAL, 'upvalue index too large'); let cl = new CClosure(L, fn, n); for (let i = 0; i < n; i++) cl.upvalue[i].setfrom(L.stack[L.top - n + i]); @@ -368,7 +368,7 @@ const auxsetstr = function (L, t, k) { let str = luaS_new(L, from_userstring(k)); api_checknelems(L, 1); pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ delete L.stack[--L.top]; @@ -386,7 +386,7 @@ const lua_setmetatable = function (L, objindex) { if (L.stack[L.top - 1].ttisnil()) mt = null; else { - api_check(L, L.stack[L.top - 1].ttistable(), "table expected"); + api_check(L, L.stack[L.top - 1].ttistable(), 'table expected'); mt = L.stack[L.top - 1].value; } @@ -433,7 +433,7 @@ const lua_seti = function (L, idx, n) { const lua_rawset = function (L, idx) { api_checknelems(L, 2); let o = index2addr(L, idx); - api_check(L, o.ttistable(), "table expected"); + api_check(L, o.ttistable(), 'table expected'); let k = L.stack[L.top - 2]; let v = L.stack[L.top - 1]; luaH_setfrom(L, o.value, k, v); @@ -446,7 +446,7 @@ const lua_rawseti = function (L, idx, n) { fengari_argcheckinteger(n); api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), "table expected"); + api_check(L, o.ttistable(), 'table expected'); luaH_setint(o.value, n, L.stack[L.top - 1]); delete L.stack[--L.top]; }; @@ -454,7 +454,7 @@ const lua_rawseti = function (L, idx, n) { const lua_rawsetp = function (L, idx, p) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), "table expected"); + api_check(L, o.ttistable(), 'table expected'); let k = new TValue(LUA_TLIGHTUSERDATA, p); let v = L.stack[L.top - 1]; luaH_setfrom(L, o.value, k, v); @@ -468,7 +468,7 @@ const lua_rawsetp = function (L, idx, p) { const auxgetstr = function (L, t, k) { let str = luaS_new(L, from_userstring(k)); pushsvalue2s(L, str); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; @@ -476,24 +476,24 @@ const auxgetstr = function (L, t, k) { const lua_rawgeti = function (L, idx, n) { let t = index2addr(L, idx); fengari_argcheckinteger(n); - api_check(L, t.ttistable(), "table expected"); + api_check(L, t.ttistable(), 'table expected'); pushobj2s(L, luaH_getint(t.value, n)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return L.stack[L.top - 1].ttnov(); }; const lua_rawgetp = function (L, idx, p) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), "table expected"); + api_check(L, t.ttistable(), 'table expected'); let k = new TValue(LUA_TLIGHTUSERDATA, p); pushobj2s(L, luaH_get(L, t.value, k)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return L.stack[L.top - 1].ttnov(); }; const lua_rawget = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(t), "table expected"); + api_check(L, t.ttistable(t), 'table expected'); setobj2s(L, L.top - 1, luaH_get(L, t.value, L.stack[L.top - 1])); return L.stack[L.top - 1].ttnov(); }; @@ -523,7 +523,7 @@ const aux_upvalue = function (L, fi, n) { let f = fi.value; if (!(1 <= n && n <= f.nupvalues)) return null; return { - name: to_luastring("", true), + name: to_luastring('', true), val: f.upvalue[n - 1] }; } @@ -533,7 +533,7 @@ const aux_upvalue = function (L, fi, n) { if (!(1 <= n && n <= p.upvalues.length)) return null; let name = p.upvalues[n - 1].name; return { - name: name ? name.getstr() : to_luastring("(*no name)", true), + name: name ? name.getstr() : to_luastring('(*no name)', true), val: f.upvals[n - 1] }; } @@ -547,7 +547,7 @@ const lua_getupvalue = function (L, funcindex, n) { let name = up.name; let val = up.val; pushobj2s(L, val); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); return name; } return null; @@ -601,7 +601,7 @@ const lua_getmetatable = function (L, objindex) { const lua_getuservalue = function (L, idx) { let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), "full userdata expected"); + api_check(L, o.ttisfulluserdata(), 'full userdata expected'); let uv = o.value.uservalue; L.stack[L.top] = new TValue(uv.type, uv.value); api_incr_top(L); @@ -759,7 +759,7 @@ const lua_isproxy = function (p, L) { /* Use 'create_proxy' helper function so that 'L' is not in scope */ const create_proxy = function (G, type, value) { let proxy = function (L) { - api_check(L, L instanceof lua_State && G === L.l_G, "must be from same global state"); + api_check(L, L instanceof lua_State && G === L.l_G, 'must be from same global state'); L.stack[L.top] = new TValue(type, value); api_incr_top(L); }; @@ -785,7 +785,7 @@ const lua_compare = function (L, index1, index2, op) { case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; - default: api_check(L, false, "invalid option"); + default: api_check(L, false, 'invalid option'); } } @@ -812,7 +812,7 @@ const lua_type = function (L, idx) { }; const lua_typename = function (L, t) { - api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); + api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, 'invalid tag'); return ttypename(t); }; @@ -883,7 +883,7 @@ const lua_arith = function (L, op) { else { /* for unary operations, add fake 2nd operand */ api_checknelems(L, 1); pushobj2s(L, L.stack[L.top - 1]); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } /* first operand at top - 2, second at top - 1; result go to top - 2 */ luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); @@ -894,7 +894,7 @@ const lua_arith = function (L, op) { ** 'load' and 'call' functions (run Lua code) */ -const default_chunkname = to_luastring("?"); +const default_chunkname = to_luastring('?'); const lua_load = function (L, reader, data, chunkname, mode) { if (!chunkname) chunkname = default_chunkname; else chunkname = from_userstring(chunkname); @@ -928,20 +928,20 @@ const lua_status = function (L) { const lua_setuservalue = function (L, idx) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), "full userdata expected"); + api_check(L, o.ttisfulluserdata(), 'full userdata expected'); o.value.uservalue.setfrom(L.stack[L.top - 1]); delete L.stack[--L.top]; }; const checkresults = function (L, na, nr) { api_check(L, nr === LUA_MULTRET || (L.ci.top - L.top >= (nr) - (na)), - "results from function overflow current stack size"); + 'results from function overflow current stack size'); }; const lua_callk = function (L, nargs, nresults, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), "cannot use continuations inside hooks"); + api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread"); + api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); checkresults(L, nargs, nresults); let func = L.top - (nargs + 1); if (k !== null && L.nny === 0) { /* need to prepare continuation? */ @@ -961,9 +961,9 @@ const lua_call = function (L, n, r) { }; const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), "cannot use continuations inside hooks"); + api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread"); + api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); checkresults(L, nargs, nresults); let status; let func; @@ -1016,7 +1016,7 @@ const lua_error = function (L) { const lua_next = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), "table expected"); + api_check(L, t.ttistable(), 'table expected'); L.stack[L.top] = new TValue(); let more = luaH_next(L, t.value, L.top - 1); if (more) { @@ -1034,8 +1034,8 @@ const lua_concat = function (L, n) { if (n >= 2) luaV_concat(L, n); else if (n === 0) { - pushsvalue2s(L, luaS_bless(L, to_luastring("", true))); - api_check(L, L.top <= L.ci.top, "stack overflow"); + pushsvalue2s(L, luaS_bless(L, to_luastring('', true))); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } }; @@ -1049,10 +1049,10 @@ const lua_len = function (L, idx) { const getupvalref = function (L, fidx, n) { let fi = index2addr(L, fidx); - api_check(L, fi.ttisLclosure(), "Lua function expected"); + api_check(L, fi.ttisLclosure(), 'Lua function expected'); let f = fi.value; fengari_argcheckinteger(n); - api_check(L, 1 <= n && n <= f.p.upvalues.length, "invalid upvalue index"); + api_check(L, 1 <= n && n <= f.p.upvalues.length, 'invalid upvalue index'); return { f: f, i: n - 1 @@ -1068,11 +1068,11 @@ const lua_upvalueid = function (L, fidx, n) { } case LUA_TCCL: { /* C closure */ let f = fi.value; - api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, "invalid upvalue index"); + api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, 'invalid upvalue index'); return f.upvalue[n - 1]; } default: { - api_check(L, false, "closure expected"); + api_check(L, false, 'closure expected'); return null; } } @@ -1089,17 +1089,17 @@ const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { const lua_gc = function () { }; const lua_getallocf = function () { - console.warn("lua_getallocf is not available"); + console.warn('lua_getallocf is not available'); return 0; }; const lua_setallocf = function () { - console.warn("lua_setallocf is not available"); + console.warn('lua_setallocf is not available'); return 0; }; const lua_getextraspace = function () { - console.warn("lua_getextraspace is not available"); + console.warn('lua_getextraspace is not available'); return 0; }; diff --git a/src/lauxlib.js b/src/lauxlib.js index b92ef8fb..c2dd39db 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -1,23 +1,23 @@ import { LUAL_BUFFERSIZE } from './luaconf.js'; import { LUA_ERRERR, LUA_MULTRET, LUA_REGISTRYINDEX, LUA_SIGNATURE, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_VERSION_NUM, lua_Debug, lua_absindex, lua_atpanic, lua_call, lua_checkstack, lua_concat, lua_copy, lua_createtable, lua_error, lua_getfield, lua_getinfo, lua_getmetatable, lua_getstack, lua_gettop, lua_insert, lua_isinteger, lua_isnil, lua_isnumber, lua_isstring, lua_istable, lua_len, lua_load, lua_newstate, lua_newtable, lua_next, lua_pcall, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawlen, lua_rawseti, lua_remove, lua_setfield, lua_setglobal, lua_setmetatable, lua_settop, lua_toboolean, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_tostring, lua_touserdata, lua_type, lua_typename, lua_version } from './lua.js'; -import { from_userstring, luastring_eq, to_luastring, to_uristring } from "./fengaricore.js"; +import { from_userstring, luastring_eq, to_luastring, to_uristring } from './fengaricore.js'; import fs from 'fs'; /* extra error code for 'luaL_loadfilex' */ const LUA_ERRFILE = LUA_ERRERR + 1; /* key, in the registry, for table of loaded modules */ -const LUA_LOADED_TABLE = to_luastring("_LOADED"); +const LUA_LOADED_TABLE = to_luastring('_LOADED'); /* key, in the registry, for table of preloaded loaders */ -const LUA_PRELOAD_TABLE = to_luastring("_PRELOAD"); +const LUA_PRELOAD_TABLE = to_luastring('_PRELOAD'); -const LUA_FILEHANDLE = to_luastring("FILE*"); +const LUA_FILEHANDLE = to_luastring('FILE*'); const LUAL_NUMSIZES = 4 * 16 + 8; -const __name = to_luastring("__name"); -const __tostring = to_luastring("__tostring"); +const __name = to_luastring('__name'); +const __tostring = to_luastring('__tostring'); const empty = new Uint8Array(0); @@ -49,7 +49,7 @@ const findfield = function (L, objidx, level) { return 1; } else if (findfield(L, objidx, level - 1)) { /* try recursively */ lua_remove(L, -2); /* remove table (but keep name) */ - lua_pushliteral(L, "."); + lua_pushliteral(L, '.'); lua_insert(L, -2); /* place '.' between the two names */ lua_concat(L, 3); return 1; @@ -66,7 +66,7 @@ const findfield = function (L, objidx, level) { */ const pushglobalfuncname = function (L, ar) { let top = lua_gettop(L); - lua_getinfo(L, to_luastring("f"), ar); /* push function */ + lua_getinfo(L, to_luastring('f'), ar); /* push function */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); if (findfield(L, top + 1, 2)) { let name = lua_tostring(L, -1); @@ -88,17 +88,17 @@ const pushglobalfuncname = function (L, ar) { const pushfuncname = function (L, ar) { if (pushglobalfuncname(L, ar)) { /* try first a global name */ - lua_pushfstring(L, to_luastring("function '%s'"), lua_tostring(L, -1)); + lua_pushfstring(L, to_luastring('function \'%s\''), lua_tostring(L, -1)); lua_remove(L, -2); /* remove name */ } else if (ar.namewhat.length !== 0) /* is there a name from code? */ - lua_pushfstring(L, to_luastring("%s '%s'"), ar.namewhat, ar.name); /* use it */ + lua_pushfstring(L, to_luastring('%s \'%s\''), ar.namewhat, ar.name); /* use it */ else if (ar.what && ar.what[0] === 109 /* 'm'.charCodeAt(0) */) /* main? */ - lua_pushliteral(L, "main chunk"); + lua_pushliteral(L, 'main chunk'); else if (ar.what && ar.what[0] === 76 /* 'L'.charCodeAt(0) */) /* for Lua functions, use */ - lua_pushfstring(L, to_luastring("function <%s:%d>"), ar.short_src, ar.linedefined); + lua_pushfstring(L, to_luastring('function <%s:%d>'), ar.short_src, ar.linedefined); else /* nothing left... */ - lua_pushliteral(L, "?"); + lua_pushliteral(L, '?'); }; const lastlevel = function (L) { @@ -122,22 +122,22 @@ const luaL_traceback = function (L, L1, msg, level) { let last = lastlevel(L1); let n1 = last - level > LEVELS1 + LEVELS2 ? LEVELS1 : -1; if (msg) - lua_pushfstring(L, to_luastring("%s\n"), msg); + lua_pushfstring(L, to_luastring('%s\n'), msg); luaL_checkstack(L, 10, null); - lua_pushliteral(L, "stack traceback:"); + lua_pushliteral(L, 'stack traceback:'); while (lua_getstack(L1, level++, ar)) { if (n1-- === 0) { /* too many levels? */ - lua_pushliteral(L, "\n\t..."); /* add a '...' */ + lua_pushliteral(L, '\n\t...'); /* add a '...' */ level = last - LEVELS2 + 1; /* and skip to last ones */ } else { - lua_getinfo(L1, to_luastring("Slnt", true), ar); - lua_pushfstring(L, to_luastring("\n\t%s:"), ar.short_src); + lua_getinfo(L1, to_luastring('Slnt', true), ar); + lua_pushfstring(L, to_luastring('\n\t%s:'), ar.short_src); if (ar.currentline > 0) lua_pushliteral(L, `${ar.currentline}:`); - lua_pushliteral(L, " in "); + lua_pushliteral(L, ' in '); pushfuncname(L, ar); if (ar.istailcall) - lua_pushliteral(L, "\n\t(...tail calls..)"); + lua_pushliteral(L, '\n\t(...tail calls..)'); lua_concat(L, lua_gettop(L) - top); } } @@ -145,7 +145,7 @@ const luaL_traceback = function (L, L1, msg, level) { }; const panic = function (L) { - let msg = "PANIC: unprotected error in call to Lua API (" + lua_tojsstring(L, -1) + ")"; + let msg = 'PANIC: unprotected error in call to Lua API (' + lua_tojsstring(L, -1) + ')'; throw new Error(msg); }; @@ -153,20 +153,20 @@ const luaL_argerror = function (L, arg, extramsg) { let ar = new lua_Debug(); if (!lua_getstack(L, 0, ar)) /* no stack frame? */ - return luaL_error(L, to_luastring("bad argument #%d (%s)"), arg, extramsg); + return luaL_error(L, to_luastring('bad argument #%d (%s)'), arg, extramsg); - lua_getinfo(L, to_luastring("n"), ar); + lua_getinfo(L, to_luastring('n'), ar); - if (luastring_eq(ar.namewhat, to_luastring("method"))) { + if (luastring_eq(ar.namewhat, to_luastring('method'))) { arg--; /* do not count 'self' */ if (arg === 0) /* error is in the self argument itself? */ - return luaL_error(L, to_luastring("calling '%s' on bad self (%s)"), ar.name, extramsg); + return luaL_error(L, to_luastring('calling \'%s\' on bad self (%s)'), ar.name, extramsg); } if (ar.name === null) - ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring("?"); + ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring('?'); - return luaL_error(L, to_luastring("bad argument #%d to '%s' (%s)"), arg, ar.name, extramsg); + return luaL_error(L, to_luastring('bad argument #%d to \'%s\' (%s)'), arg, ar.name, extramsg); }; const typeerror = function (L, arg, tname) { @@ -174,24 +174,24 @@ const typeerror = function (L, arg, tname) { if (luaL_getmetafield(L, arg, __name) === LUA_TSTRING) typearg = lua_tostring(L, -1); else if (lua_type(L, arg) === LUA_TLIGHTUSERDATA) - typearg = to_luastring("light userdata", true); + typearg = to_luastring('light userdata', true); else typearg = luaL_typename(L, arg); - let msg = lua_pushfstring(L, to_luastring("%s expected, got %s"), tname, typearg); + let msg = lua_pushfstring(L, to_luastring('%s expected, got %s'), tname, typearg); return luaL_argerror(L, arg, msg); }; const luaL_where = function (L, level) { let ar = new lua_Debug(); if (lua_getstack(L, level, ar)) { - lua_getinfo(L, to_luastring("Sl", true), ar); + lua_getinfo(L, to_luastring('Sl', true), ar); if (ar.currentline > 0) { - lua_pushfstring(L, to_luastring("%s:%d: "), ar.short_src, ar.currentline); + lua_pushfstring(L, to_luastring('%s:%d: '), ar.short_src, ar.currentline); return; } } - lua_pushstring(L, to_luastring("")); + lua_pushstring(L, to_luastring('')); }; const luaL_error = function (L, fmt, ...argp) { @@ -213,11 +213,11 @@ const luaL_fileresult = function (L, stat, fname, e) { message = e.message; errno = -e.errno; } else { - message = "Success"; /* what strerror(0) returns */ + message = 'Success'; /* what strerror(0) returns */ errno = 0; } if (fname) - lua_pushfstring(L, to_luastring("%s: %s"), fname, to_luastring(message)); + lua_pushfstring(L, to_luastring('%s: %s'), fname, to_luastring(message)); else lua_pushstring(L, to_luastring(message)); lua_pushinteger(L, errno); @@ -230,14 +230,14 @@ const luaL_execresult = function (L, e) { let what, stat; if (e === null) { lua_pushboolean(L, 1); - lua_pushliteral(L, "exit"); + lua_pushliteral(L, 'exit'); lua_pushinteger(L, 0); return 3; } else if (e.status) { - what = "exit"; + what = 'exit'; stat = e.status; } else if (e.signal) { - what = "signal"; + what = 'signal'; stat = e.signal; } else { /* XXX: node seems to have e.errno as a string instead of a number */ @@ -296,7 +296,7 @@ const luaL_checkoption = function (L, arg, def, lst) { for (let i = 0; lst[i]; i++) if (luastring_eq(lst[i], name)) return i; - return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring("invalid option '%s'"), name)); + return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring('invalid option \'%s\''), name)); }; const tag_error = function (L, arg, tag) { @@ -320,7 +320,7 @@ const luaL_argcheck = function (L, cond, arg, extramsg) { const luaL_checkany = function (L, arg) { if (lua_type(L, arg) === LUA_TNONE) - luaL_argerror(L, arg, to_luastring("value expected", true)); + luaL_argerror(L, arg, to_luastring('value expected', true)); }; const luaL_checktype = function (L, arg, t) { @@ -346,7 +346,7 @@ const luaL_optstring = luaL_optlstring; const interror = function (L, arg) { if (lua_isnumber(L, arg)) - luaL_argerror(L, arg, to_luastring("number has no integer representation", true)); + luaL_argerror(L, arg, to_luastring('number has no integer representation', true)); else tag_error(L, arg, LUA_TNUMBER); }; @@ -495,17 +495,17 @@ const luaL_len = function (L, idx) { lua_len(L, idx); let l = lua_tointegerx(L, -1); if (l === false) - luaL_error(L, to_luastring("object length is not an integer", true)); + luaL_error(L, to_luastring('object length is not an integer', true)); lua_pop(L, 1); /* remove object */ return l; }; -const p_I = to_luastring("%I"); -const p_f = to_luastring("%f"); +const p_I = to_luastring('%I'); +const p_f = to_luastring('%f'); const luaL_tolstring = function (L, idx) { if (luaL_callmeta(L, idx, __tostring)) { if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("'__tostring' must return a string")); + luaL_error(L, to_luastring('\'__tostring\' must return a string')); } else { let t = lua_type(L, idx); switch (t) { @@ -520,15 +520,15 @@ const luaL_tolstring = function (L, idx) { lua_pushvalue(L, idx); break; case LUA_TBOOLEAN: - lua_pushliteral(L, (lua_toboolean(L, idx) ? "true" : "false")); + lua_pushliteral(L, (lua_toboolean(L, idx) ? 'true' : 'false')); break; case LUA_TNIL: - lua_pushliteral(L, "nil"); + lua_pushliteral(L, 'nil'); break; default: { let tt = luaL_getmetafield(L, idx, __name); let kind = tt === LUA_TSTRING ? lua_tostring(L, -1) : luaL_typename(L, idx); - lua_pushfstring(L, to_luastring("%s: %p"), kind, lua_topointer(L, idx)); + lua_pushfstring(L, to_luastring('%s: %p'), kind, lua_topointer(L, idx)); if (tt !== LUA_TNIL) lua_remove(L, -2); break; @@ -614,7 +614,7 @@ const luaL_getsubtable = function (L, idx, fname) { ** Returns with only the table at the stack. */ const luaL_setfuncs = function (L, l, nup) { - luaL_checkstack(L, nup, to_luastring("too many upvalues", true)); + luaL_checkstack(L, nup, to_luastring('too many upvalues', true)); for (let lib in l) { /* fill the table with given functions */ for (let i = 0; i < nup; i++) /* copy upvalues to the top */ lua_pushvalue(L, -nup); @@ -634,7 +634,7 @@ const luaL_setfuncs = function (L, l, nup) { const luaL_checkstack = function (L, space, msg) { if (!lua_checkstack(L, space)) { if (msg) - luaL_error(L, to_luastring("stack overflow (%s)"), msg); + luaL_error(L, to_luastring('stack overflow (%s)'), msg); else luaL_error(L, to_luastring('stack overflow', true)); } @@ -688,7 +688,7 @@ const luaL_unref = function (L, t, ref) { const errfile = function (L, what, fnameindex, error) { let serr = error.message; let filename = lua_tostring(L, fnameindex).subarray(1); - lua_pushfstring(L, to_luastring("cannot %s %s: %s"), to_luastring(what), filename, to_luastring(serr)); + lua_pushfstring(L, to_luastring('cannot %s %s: %s'), to_luastring(what), filename, to_luastring(serr)); lua_remove(L, fnameindex); return LUA_ERRFILE; }; @@ -738,7 +738,7 @@ const skipcomment = function (lf) { let luaL_loadfilex; -if (typeof process === "undefined") { +if (typeof process === 'undefined') { class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -772,29 +772,29 @@ if (typeof process === "undefined") { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - throw new Error("Can't read stdin in the browser"); + throw new Error('Can\'t read stdin in the browser'); } else { - lua_pushfstring(L, to_luastring("@%s"), filename); + lua_pushfstring(L, to_luastring('@%s'), filename); let path = to_uristring(filename); let xhr = new XMLHttpRequest(); - xhr.open("GET", path, false); + xhr.open('GET', path, false); /* Synchronous xhr in main thread always returns a js string. Some browsers make console noise if you even attempt to set responseType */ - if (typeof window === "undefined") { - xhr.responseType = "arraybuffer"; + if (typeof window === 'undefined') { + xhr.responseType = 'arraybuffer'; } xhr.send(); if (xhr.status >= 200 && xhr.status <= 299) { - if (typeof xhr.response === "string") { + if (typeof xhr.response === 'string') { lf.f = to_luastring(xhr.response); } else { lf.f = new Uint8Array(xhr.response); } } else { lf.err = xhr.status; - return errfile(L, "open", fnameindex, { message: `${xhr.status}: ${xhr.statusText}` }); + return errfile(L, 'open', fnameindex, { message: `${xhr.status}: ${xhr.statusText}` }); } } let com = skipcomment(lf); @@ -810,7 +810,7 @@ if (typeof process === "undefined") { let readstatus = lf.err; if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, "read", fnameindex, readstatus); + return errfile(L, 'read', fnameindex, readstatus); } lua_remove(L, fnameindex); return status; @@ -863,14 +863,14 @@ if (typeof process === "undefined") { let lf = new LoadF(); let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - lua_pushliteral(L, "=stdin"); + lua_pushliteral(L, '=stdin'); lf.f = process.stdin.fd; } else { - lua_pushfstring(L, to_luastring("@%s"), filename); + lua_pushfstring(L, to_luastring('@%s'), filename); try { - lf.f = fs.openSync(filename, "r"); + lf.f = fs.openSync(filename, 'r'); } catch (e) { - return errfile(L, "open", fnameindex, e); + return errfile(L, 'open', fnameindex, e); } } let com = skipcomment(lf); @@ -887,7 +887,7 @@ if (typeof process === "undefined") { if (filename) try { fs.closeSync(lf.f); } catch (e) { } /* close file (even in case of errors) */ if (readstatus) { lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, "read", fnameindex, readstatus); + return errfile(L, 'read', fnameindex, readstatus); } lua_remove(L, fnameindex); return status; @@ -905,7 +905,7 @@ const luaL_dofile = function (L, filename) { const lua_writestringerror = function () { for (let i = 0; i < arguments.length; i++) { let a = arguments[i]; - if (typeof process === "undefined") { + if (typeof process === 'undefined') { /* split along new lines for separate console.error invocations */ do { /* regexp uses [\d\D] to work around matching new lines @@ -913,7 +913,7 @@ const lua_writestringerror = function () { let r = /([^\n]*)\n?([\d\D]*)/.exec(a); console.error(r[1]); a = r[2]; - } while (a !== ""); + } while (a !== ''); } else { process.stderr.write(a); } @@ -923,11 +923,11 @@ const lua_writestringerror = function () { const luaL_checkversion_ = function (L, ver, sz) { let v = lua_version(L); if (sz != LUAL_NUMSIZES) /* check numeric types */ - luaL_error(L, to_luastring("core and library have incompatible numeric types")); + luaL_error(L, to_luastring('core and library have incompatible numeric types')); if (v != lua_version(null)) - luaL_error(L, to_luastring("multiple Lua VMs detected")); + luaL_error(L, to_luastring('multiple Lua VMs detected')); else if (v !== ver) - luaL_error(L, to_luastring("version mismatch: app. needs %f, Lua core provides %f"), ver, v); + luaL_error(L, to_luastring('version mismatch: app. needs %f, Lua core provides %f'), ver, v); }; /* There is no point in providing this function... */ diff --git a/src/lbaselib.js b/src/lbaselib.js index 31932775..2fd03439 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; import { LUA_MULTRET, LUA_OK, LUA_TFUNCTION, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_VERSION, LUA_YIELD, lua_call, lua_callk, lua_concat, lua_error, lua_getglobal, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnone, lua_isstring, lua_load, lua_next, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcfunction, lua_pushglobaltable, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawequal, lua_rawget, lua_rawlen, lua_rawset, lua_remove, lua_replace, lua_rotate, lua_setfield, lua_setmetatable, lua_settop, lua_setupvalue, lua_stringtonumber, lua_toboolean, lua_tolstring, lua_tostring, lua_type, lua_typename } from './lua.js'; import { luaL_argcheck, luaL_checkany, luaL_checkinteger, luaL_checkoption, luaL_checkstack, luaL_checktype, luaL_error, luaL_getmetafield, luaL_loadbufferx, luaL_loadfile, luaL_loadfilex, luaL_optinteger, luaL_optstring, luaL_setfuncs, luaL_tolstring, luaL_where } from './lauxlib.js'; -import { to_jsstring, to_luastring } from "./fengaricore.js"; +import { to_jsstring, to_luastring } from './fengaricore.js'; let lua_writestring; let lua_writeline; -if (typeof process === "undefined") { - if (typeof TextDecoder === "function") { /* Older browsers don't have TextDecoder */ - let buff = ""; - let decoder = new TextDecoder("utf-8"); +if (typeof process === 'undefined') { + if (typeof TextDecoder === 'function') { /* Older browsers don't have TextDecoder */ + let buff = ''; + let decoder = new TextDecoder('utf-8'); lua_writestring = function(s) { buff += decoder.decode(s, {stream: true}); }; @@ -17,7 +17,7 @@ if (typeof process === "undefined") { lua_writeline = function() { buff += decoder.decode(empty); console.log(buff); - buff = ""; + buff = ''; }; } else { let buff = []; @@ -43,20 +43,20 @@ if (typeof process === "undefined") { process.stdout.write(Buffer.from(s)); }; lua_writeline = function() { - process.stdout.write("\n"); + process.stdout.write('\n'); }; } const luaB_print = function(L) { let n = lua_gettop(L); /* number of arguments */ - lua_getglobal(L, to_luastring("tostring", true)); + lua_getglobal(L, to_luastring('tostring', true)); for (let i = 1; i <= n; i++) { lua_pushvalue(L, -1); /* function to be called */ lua_pushvalue(L, i); /* value to print */ lua_call(L, 1, 1); let s = lua_tolstring(L, -1); if (s === null) - return luaL_error(L, to_luastring("'tostring' must return a string to 'print'")); - if (i > 1) lua_writestring(to_luastring("\t")); + return luaL_error(L, to_luastring('\'tostring\' must return a string to \'print\'')); + if (i > 1) lua_writestring(to_luastring('\t')); lua_writestring(s); lua_pop(L, 1); } @@ -77,16 +77,16 @@ const luaB_getmetatable = function(L) { lua_pushnil(L); return 1; /* no metatable */ } - luaL_getmetafield(L, 1, to_luastring("__metatable", true)); + luaL_getmetafield(L, 1, to_luastring('__metatable', true)); return 1; /* returns either __metatable field (if present) or metatable */ }; const luaB_setmetatable = function(L) { let t = lua_type(L, 2); luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, "nil or table expected"); - if (luaL_getmetafield(L, 1, to_luastring("__metatable", true)) !== LUA_TNIL) - return luaL_error(L, to_luastring("cannot change a protected metatable")); + luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, 'nil or table expected'); + if (luaL_getmetafield(L, 1, to_luastring('__metatable', true)) !== LUA_TNIL) + return luaL_error(L, to_luastring('cannot change a protected metatable')); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; @@ -101,7 +101,7 @@ const luaB_rawequal = function(L) { const luaB_rawlen = function(L) { let t = lua_type(L, 1); - luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, "table or string expected"); + luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, 'table or string expected'); lua_pushinteger(L, lua_rawlen(L, 1)); return 1; }; @@ -124,19 +124,19 @@ const luaB_rawset = function(L) { }; const opts = [ - "stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", - "isrunning" + 'stop', 'restart', 'collect', + 'count', 'step', 'setpause', 'setstepmul', + 'isrunning' ].map((e) => to_luastring(e)); const luaB_collectgarbage = function(L) { - luaL_checkoption(L, 1, "collect", opts); + luaL_checkoption(L, 1, 'collect', opts); luaL_optinteger(L, 2, 0); - luaL_error(L, to_luastring("lua_gc not implemented")); + luaL_error(L, to_luastring('lua_gc not implemented')); }; const luaB_type = function(L) { let t = lua_type(L, 1); - luaL_argcheck(L, t !== LUA_TNONE, 1, "value expected"); + luaL_argcheck(L, t !== LUA_TNONE, 1, 'value expected'); lua_pushstring(L, lua_typename(L, t)); return 1; }; @@ -167,7 +167,7 @@ const luaB_next = function(L) { }; const luaB_pairs = function(L) { - return pairsmeta(L, to_luastring("__pairs", true), 0, luaB_next); + return pairsmeta(L, to_luastring('__pairs', true), 0, luaB_next); }; /* @@ -222,7 +222,7 @@ const luaB_tonumber = function(L) { let base = luaL_checkinteger(L, 2); luaL_checktype(L, 1, LUA_TSTRING); /* no numbers as strings */ let s = lua_tostring(L, 1); - luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + luaL_argcheck(L, 2 <= base && base <= 36, 2, 'base out of range'); let n = b_str2int(s, base); if (n !== null) { lua_pushinteger(L, n); @@ -251,7 +251,7 @@ const luaB_assert = function(L) { else { luaL_checkany(L, 1); /* there must be a condition */ lua_remove(L, 1); /* remove it */ - lua_pushliteral(L, "assertion failed!"); /* default message */ + lua_pushliteral(L, 'assertion failed!'); /* default message */ lua_settop(L, 1); /* leave only message (default if no other one) */ return luaB_error(L); /* call 'error' */ } @@ -266,7 +266,7 @@ const luaB_select = function(L) { let i = luaL_checkinteger(L, 1); if (i < 0) i = n + i; else if (i > n) i = n; - luaL_argcheck(L, 1 <= i, 1, "index out of range"); + luaL_argcheck(L, 1 <= i, 1, 'index out of range'); return n - i; } }; @@ -339,28 +339,28 @@ const RESERVEDSLOT = 5; ** reserved slot inside the stack. */ const generic_reader = function(L, ud) { - luaL_checkstack(L, 2, "too many nested functions"); + luaL_checkstack(L, 2, 'too many nested functions'); lua_pushvalue(L, 1); /* get function */ lua_call(L, 0, 1); /* call it */ if (lua_isnil(L, -1)) { lua_pop(L, 1); /* pop result */ return null; } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("reader function must return a string")); + luaL_error(L, to_luastring('reader function must return a string')); lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ return lua_tostring(L, RESERVEDSLOT); }; const luaB_load = function(L) { let s = lua_tostring(L, 1); - let mode = luaL_optstring(L, 3, "bt"); + let mode = luaL_optstring(L, 3, 'bt'); let env = !lua_isnone(L, 4) ? 4 : 0; /* 'env' index or 0 if no 'env' */ let status; if (s !== null) { /* loading a string? */ let chunkname = luaL_optstring(L, 2, s); status = luaL_loadbufferx(L, s, s.length, chunkname, mode); } else { /* loading from a reader function */ - let chunkname = luaL_optstring(L, 2, "=(load)"); + let chunkname = luaL_optstring(L, 2, '=(load)'); luaL_checktype(L, 1, LUA_TFUNCTION); lua_settop(L, RESERVEDSLOT); /* create reserved slot */ status = lua_load(L, generic_reader, null, chunkname, mode); @@ -390,28 +390,28 @@ const luaB_dofile = function(L) { }; const base_funcs = { - "assert": luaB_assert, - "collectgarbage": luaB_collectgarbage, - "dofile": luaB_dofile, - "error": luaB_error, - "getmetatable": luaB_getmetatable, - "ipairs": luaB_ipairs, - "load": luaB_load, - "loadfile": luaB_loadfile, - "next": luaB_next, - "pairs": luaB_pairs, - "pcall": luaB_pcall, - "print": luaB_print, - "rawequal": luaB_rawequal, - "rawget": luaB_rawget, - "rawlen": luaB_rawlen, - "rawset": luaB_rawset, - "select": luaB_select, - "setmetatable": luaB_setmetatable, - "tonumber": luaB_tonumber, - "tostring": luaB_tostring, - "type": luaB_type, - "xpcall": luaB_xpcall + 'assert': luaB_assert, + 'collectgarbage': luaB_collectgarbage, + 'dofile': luaB_dofile, + 'error': luaB_error, + 'getmetatable': luaB_getmetatable, + 'ipairs': luaB_ipairs, + 'load': luaB_load, + 'loadfile': luaB_loadfile, + 'next': luaB_next, + 'pairs': luaB_pairs, + 'pcall': luaB_pcall, + 'print': luaB_print, + 'rawequal': luaB_rawequal, + 'rawget': luaB_rawget, + 'rawlen': luaB_rawlen, + 'rawset': luaB_rawset, + 'select': luaB_select, + 'setmetatable': luaB_setmetatable, + 'tonumber': luaB_tonumber, + 'tostring': luaB_tostring, + 'type': luaB_type, + 'xpcall': luaB_xpcall }; const luaopen_base = function(L) { @@ -420,10 +420,10 @@ const luaopen_base = function(L) { luaL_setfuncs(L, base_funcs, 0); /* set global _G */ lua_pushvalue(L, -1); - lua_setfield(L, -2, to_luastring("_G")); + lua_setfield(L, -2, to_luastring('_G')); /* set global _VERSION */ lua_pushliteral(L, LUA_VERSION); - lua_setfield(L, -2, to_luastring("_VERSION")); + lua_setfield(L, -2, to_luastring('_VERSION')); return 1; }; diff --git a/src/lcode.js b/src/lcode.js index c9802728..b203a847 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -1,7 +1,7 @@ -"use strict"; +'use strict'; import { LUA_MULTRET, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPIDIV, LUA_OPMOD, LUA_OPSHL, LUA_OPSHR, LUA_OPUNM, constant_types, to_luastring } from './defs.js'; -import { lua_assert } from "./llimits.js"; +import { lua_assert } from './llimits.js'; import { luaX_syntaxerror } from './llex.js'; import { TValue as _TValue, luaO_arith } from './lobject.js'; import { OpCodesI as _OpCodesI, SETARG_A, SETARG_B, MAXARG_sBx, SETARG_sBx, testTMode, NO_REG, CREATE_ABC, getOpMode, iABC, getBMode, OpArgN, getCMode, MAXARG_A, MAXARG_B, MAXARG_C, iABx, iAsBx, MAXARG_Bx, CREATE_ABx, MAXARG_Ax, CREATE_Ax, ISK, SETARG_C, MAXINDEXRK, RKASK, LFIELDS_PER_FLUSH } from './lopcodes.js'; @@ -143,7 +143,7 @@ const fixjump = function (fs, pc, dest) { let offset = dest - (pc + 1); lua_assert(dest !== NO_JUMP); if (Math.abs(offset) > MAXARG_sBx) - luaX_syntaxerror(fs.ls, to_luastring("control structure too long", true)); + luaX_syntaxerror(fs.ls, to_luastring('control structure too long', true)); SETARG_sBx(jmp, offset); }; @@ -388,7 +388,7 @@ const luaK_checkstack = function (fs, n) { let newstack = fs.freereg + n; if (newstack > fs.f.maxstacksize) { if (newstack >= MAXREGS) - luaX_syntaxerror(fs.ls, to_luastring("function or expression needs too many registers", true)); + luaX_syntaxerror(fs.ls, to_luastring('function or expression needs too many registers', true)); fs.f.maxstacksize = newstack; } }; @@ -1197,7 +1197,7 @@ const luaK_setlist = function (fs, base, nelems, tostore) { codeextraarg(fs, c); } else - luaX_syntaxerror(fs.ls, to_luastring("constructor too long", true)); + luaX_syntaxerror(fs.ls, to_luastring('constructor too long', true)); fs.freereg = base + 1; /* free registers with list values */ }; diff --git a/src/lcorolib.js b/src/lcorolib.js index a44dc071..459dd226 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -1,22 +1,22 @@ -"use strict"; +'use strict'; import { LUA_OK, LUA_TFUNCTION, LUA_TSTRING, LUA_YIELD, lua_Debug, lua_checkstack, lua_concat, lua_error, lua_getstack, lua_gettop, lua_insert, lua_isyieldable, lua_newthread, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushliteral, lua_pushthread, lua_pushvalue, lua_resume, lua_status, lua_tothread, lua_type, lua_upvalueindex, lua_xmove, lua_yield } from './lua.js'; import { luaL_argcheck, luaL_checktype, luaL_newlib, luaL_where } from './lauxlib.js'; const getco = function(L) { let co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "thread expected"); + luaL_argcheck(L, co, 1, 'thread expected'); return co; }; const auxresume = function(L, co, narg) { if (!lua_checkstack(co, narg)) { - lua_pushliteral(L, "too many arguments to resume"); + lua_pushliteral(L, 'too many arguments to resume'); return -1; /* error flag */ } if (lua_status(co) === LUA_OK && lua_gettop(co) === 0) { - lua_pushliteral(L, "cannot resume dead coroutine"); + lua_pushliteral(L, 'cannot resume dead coroutine'); return -1; /* error flag */ } @@ -26,7 +26,7 @@ const auxresume = function(L, co, narg) { let nres = lua_gettop(co); if (!lua_checkstack(L, nres + 1)) { lua_pop(co, nres); /* remove results anyway */ - lua_pushliteral(L, "too many results to resume"); + lua_pushliteral(L, 'too many results to resume'); return -1; /* error flag */ } @@ -88,24 +88,24 @@ const luaB_yield = function(L) { const luaB_costatus = function(L) { let co = getco(L); - if (L === co) lua_pushliteral(L, "running"); + if (L === co) lua_pushliteral(L, 'running'); else { switch (lua_status(co)) { case LUA_YIELD: - lua_pushliteral(L, "suspended"); + lua_pushliteral(L, 'suspended'); break; case LUA_OK: { let ar = new lua_Debug(); if (lua_getstack(co, 0, ar) > 0) /* does it have frames? */ - lua_pushliteral(L, "normal"); /* it is running */ + lua_pushliteral(L, 'normal'); /* it is running */ else if (lua_gettop(co) === 0) - lua_pushliteral(L, "dead"); + lua_pushliteral(L, 'dead'); else - lua_pushliteral(L, "suspended"); /* initial state */ + lua_pushliteral(L, 'suspended'); /* initial state */ break; } default: /* some error occurred */ - lua_pushliteral(L, "dead"); + lua_pushliteral(L, 'dead'); break; } } @@ -124,13 +124,13 @@ const luaB_corunning = function(L) { }; const co_funcs = { - "create": luaB_cocreate, - "isyieldable": luaB_yieldable, - "resume": luaB_coresume, - "running": luaB_corunning, - "status": luaB_costatus, - "wrap": luaB_cowrap, - "yield": luaB_yield + 'create': luaB_cocreate, + 'isyieldable': luaB_yieldable, + 'resume': luaB_coresume, + 'running': luaB_corunning, + 'status': luaB_costatus, + 'wrap': luaB_cowrap, + 'yield': luaB_yield }; const luaopen_coroutine = function(L) { diff --git a/src/ldblib.js b/src/ldblib.js index 13c01d54..2c05b889 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -1,7 +1,7 @@ import { LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_REGISTRYINDEX, LUA_TFUNCTION, LUA_TNIL, LUA_TTABLE, LUA_TUSERDATA, lua_Debug, lua_call, lua_checkstack, lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getmetatable, lua_getstack, lua_getupvalue, lua_getuservalue, lua_insert, lua_iscfunction, lua_isfunction, lua_isnoneornil, lua_isthread, lua_newtable, lua_pcall, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushlightuserdata, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgetp, lua_rawsetp, lua_rotate, lua_setfield, lua_sethook, lua_setlocal, lua_setmetatable, lua_settop, lua_setupvalue, lua_setuservalue, lua_tojsstring, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_upvalueid, lua_upvaluejoin, lua_xmove } from './lua.js'; import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checkstring, luaL_checktype, luaL_error, luaL_loadbuffer, luaL_newlib, luaL_optinteger, luaL_optstring, luaL_traceback, lua_writestringerror } from './lauxlib.js'; import { lua_assert } from './lualib.js'; -import { luastring_indexOf, to_luastring } from "./fengaricore.js"; +import { luastring_indexOf, to_luastring } from './fengaricore.js'; import readlineSync from 'readline-sync'; /* @@ -11,7 +11,7 @@ import readlineSync from 'readline-sync'; */ const checkstack = function(L, L1, n) { if (L !== L1 && !lua_checkstack(L1, n)) - luaL_error(L, to_luastring("stack overflow", true)); + luaL_error(L, to_luastring('stack overflow', true)); }; const db_getregistry = function(L) { @@ -29,7 +29,7 @@ const db_getmetatable = function(L) { const db_setmetatable = function(L) { const t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table expected"); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, 'nil or table expected'); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; /* return 1st argument */ @@ -119,10 +119,10 @@ const db_getinfo = function(L) { let thread = getthread(L); let arg = thread.arg; let L1 = thread.thread; - let options = luaL_optstring(L, arg + 2, "flnStu"); + let options = luaL_optstring(L, arg + 2, 'flnStu'); checkstack(L, L1, 3); if (lua_isfunction(L, arg + 1)) { /* info about a function? */ - options = lua_pushfstring(L, to_luastring(">%s"), options); /* add '>' to 'options' */ + options = lua_pushfstring(L, to_luastring('>%s'), options); /* add '>' to 'options' */ lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ lua_xmove(L, L1, 1); } else { /* stack level */ @@ -133,32 +133,32 @@ const db_getinfo = function(L) { } if (!lua_getinfo(L1, options, ar)) - luaL_argerror(L, arg + 2, "invalid option"); + luaL_argerror(L, arg + 2, 'invalid option'); lua_newtable(L); /* table to collect results */ if (luastring_indexOf(options, 83 /* 'S'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring("source", true), ar.source); - settabss(L, to_luastring("short_src", true), ar.short_src); - settabsi(L, to_luastring("linedefined", true), ar.linedefined); - settabsi(L, to_luastring("lastlinedefined", true), ar.lastlinedefined); - settabss(L, to_luastring("what", true), ar.what); + settabss(L, to_luastring('source', true), ar.source); + settabss(L, to_luastring('short_src', true), ar.short_src); + settabsi(L, to_luastring('linedefined', true), ar.linedefined); + settabsi(L, to_luastring('lastlinedefined', true), ar.lastlinedefined); + settabss(L, to_luastring('what', true), ar.what); } if (luastring_indexOf(options, 108 /* 'l'.charCodeAt(0) */) > -1) - settabsi(L, to_luastring("currentline", true), ar.currentline); + settabsi(L, to_luastring('currentline', true), ar.currentline); if (luastring_indexOf(options, 117 /* 'u'.charCodeAt(0) */) > -1) { - settabsi(L, to_luastring("nups", true), ar.nups); - settabsi(L, to_luastring("nparams", true), ar.nparams); - settabsb(L, to_luastring("isvararg", true), ar.isvararg); + settabsi(L, to_luastring('nups', true), ar.nups); + settabsi(L, to_luastring('nparams', true), ar.nparams); + settabsb(L, to_luastring('isvararg', true), ar.isvararg); } if (luastring_indexOf(options, 110 /* 'n'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring("name", true), ar.name); - settabss(L, to_luastring("namewhat", true), ar.namewhat); + settabss(L, to_luastring('name', true), ar.name); + settabss(L, to_luastring('namewhat', true), ar.namewhat); } if (luastring_indexOf(options, 116 /* 't'.charCodeAt(0) */) > -1) - settabsb(L, to_luastring("istailcall", true), ar.istailcall); + settabsb(L, to_luastring('istailcall', true), ar.istailcall); if (luastring_indexOf(options, 76 /* 'L'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring("activelines", true)); + treatstackoption(L, L1, to_luastring('activelines', true)); if (luastring_indexOf(options, 102 /* 'f'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring("func", true)); + treatstackoption(L, L1, to_luastring('func', true)); return 1; /* return table */ }; @@ -175,7 +175,7 @@ const db_getlocal = function(L) { } else { /* stack-level argument */ let level = luaL_checkinteger(L, arg + 1); if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); + return luaL_argerror(L, arg+1, 'level out of range'); checkstack(L, L1, 1); let name = lua_getlocal(L1, ar, nvar); if (name) { @@ -199,7 +199,7 @@ const db_setlocal = function(L) { let level = luaL_checkinteger(L, arg + 1); let nvar = luaL_checkinteger(L, arg + 2); if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg + 1, "level out of range"); + return luaL_argerror(L, arg + 1, 'level out of range'); luaL_checkany(L, arg + 3); lua_settop(L, arg + 3); checkstack(L, L1, 1); @@ -241,7 +241,7 @@ const db_setupvalue = function(L) { const checkupval = function(L, argf, argnup) { let nup = luaL_checkinteger(L, argnup); /* upvalue index */ luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ - luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, "invalid upvalue index"); + luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, 'invalid upvalue index'); return nup; }; @@ -254,8 +254,8 @@ const db_upvalueid = function(L) { const db_upvaluejoin = function(L) { let n1 = checkupval(L, 1, 2); let n2 = checkupval(L, 3, 4); - luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); - luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, 'Lua function expected'); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, 'Lua function expected'); lua_upvaluejoin(L, 1, n1, 3, n2); return 0; }; @@ -264,9 +264,9 @@ const db_upvaluejoin = function(L) { ** The hook table at registry[HOOKKEY] maps threads to their current ** hook function. (We only need the unique address of 'HOOKKEY'.) */ -const HOOKKEY = to_luastring("__hooks__", true); +const HOOKKEY = to_luastring('__hooks__', true); -const hooknames = ["call", "return", "line", "count", "tail call"].map(e => to_luastring(e)); +const hooknames = ['call', 'return', 'line', 'count', 'tail call'].map(e => to_luastring(e)); /* ** Call hook function registered at hook table for the current @@ -282,7 +282,7 @@ const hookf = function(L, ar) { if (ar.currentline >= 0) lua_pushinteger(L, ar.currentline); /* push current line */ else lua_pushnil(L); - lua_assert(lua_getinfo(L, to_luastring("lS"), ar)); + lua_assert(lua_getinfo(L, to_luastring('lS'), ar)); lua_call(L, 2, 0); /* call hook function */ } }; @@ -349,7 +349,7 @@ const db_gethook = function(L) { if (hook === null) /* no hook? */ lua_pushnil(L); else if (hook !== hookf) /* external hook? */ - lua_pushliteral(L, "external hook"); + lua_pushliteral(L, 'external hook'); else { /* hook table must exist */ lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); let hooktable = lua_touserdata(L, -1); @@ -376,38 +376,38 @@ const db_traceback = function(L) { }; const dblib = { - "gethook": db_gethook, - "getinfo": db_getinfo, - "getlocal": db_getlocal, - "getmetatable": db_getmetatable, - "getregistry": db_getregistry, - "getupvalue": db_getupvalue, - "getuservalue": db_getuservalue, - "sethook": db_sethook, - "setlocal": db_setlocal, - "setmetatable": db_setmetatable, - "setupvalue": db_setupvalue, - "setuservalue": db_setuservalue, - "traceback": db_traceback, - "upvalueid": db_upvalueid, - "upvaluejoin": db_upvaluejoin + 'gethook': db_gethook, + 'getinfo': db_getinfo, + 'getlocal': db_getlocal, + 'getmetatable': db_getmetatable, + 'getregistry': db_getregistry, + 'getupvalue': db_getupvalue, + 'getuservalue': db_getuservalue, + 'sethook': db_sethook, + 'setlocal': db_setlocal, + 'setmetatable': db_setmetatable, + 'setupvalue': db_setupvalue, + 'setuservalue': db_setuservalue, + 'traceback': db_traceback, + 'upvalueid': db_upvalueid, + 'upvaluejoin': db_upvaluejoin }; let getinput; -if (typeof process !== "undefined") { // Only with Node +if (typeof process !== 'undefined') { // Only with Node readlineSync.setDefaultOptions({ prompt: 'lua_debug> ' }); getinput = function() { return readlineSync.prompt(); }; -} else if (typeof window !== "undefined") { +} else if (typeof window !== 'undefined') { /* if in browser use window.prompt. Doesn't work from web workers. See https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt */ getinput = function() { - let input = prompt("lua_debug>", ""); - return (input !== null) ? input : ""; + let input = prompt('lua_debug>', ''); + return (input !== null) ? input : ''; }; } if (getinput) { @@ -415,16 +415,16 @@ if (getinput) { for (;;) { let input = getinput(); - if (input === "cont") + if (input === 'cont') return 0; if (input.length === 0) continue; let buffer = to_luastring(input); - if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring("=(debug command)", true)) + if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring('=(debug command)', true)) || lua_pcall(L, 0, 0, 0)) { - lua_writestringerror(lua_tojsstring(L, -1), "\n"); + lua_writestringerror(lua_tojsstring(L, -1), '\n'); } lua_settop(L, 0); /* remove eventual returns */ } diff --git a/src/ldebug.js b/src/ldebug.js index bcd01de2..9e810dad 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -92,7 +92,7 @@ const lua_getstack = function (L, level, ar) { const upvalname = function (p, uv) { lua_assert(uv < p.upvalues.length); let s = p.upvalues[uv].name; - if (s === null) return to_luastring("?", true); + if (s === null) return to_luastring('?', true); return s.getstr(); }; @@ -103,7 +103,7 @@ const findvararg = function (ci, n) { else { return { pos: ci.funcOff + nparams + n, - name: to_luastring("(*vararg)", true) /* generic name for any vararg */ + name: to_luastring('(*vararg)', true) /* generic name for any vararg */ }; } }; @@ -124,7 +124,7 @@ const findlocal = function (L, ci, n) { if (name === null) { /* no 'standard' name? */ let limit = ci === L.ci ? L.top : ci.next.funcOff; if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - name = to_luastring("(*temporary)", true); /* generic name for any valid slot */ + name = to_luastring('(*temporary)', true); /* generic name for any valid slot */ else return null; /* no name */ } @@ -147,7 +147,7 @@ const lua_getlocal = function (L, ar, n) { if (local) { name = local.name; pushobj2s(L, L.stack[local.pos]); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { name = null; } @@ -173,16 +173,16 @@ const lua_setlocal = function (L, ar, n) { const funcinfo = function (ar, cl) { if (cl === null || cl instanceof CClosure) { - ar.source = to_luastring("=[JS]", true); + ar.source = to_luastring('=[JS]', true); ar.linedefined = -1; ar.lastlinedefined = -1; - ar.what = to_luastring("J", true); + ar.what = to_luastring('J', true); } else { let p = cl.p; - ar.source = p.source ? p.source.getstr() : to_luastring("=?", true); + ar.source = p.source ? p.source.getstr() : to_luastring('=?', true); ar.linedefined = p.linedefined; ar.lastlinedefined = p.lastlinedefined; - ar.what = ar.linedefined === 0 ? to_luastring("main", true) : to_luastring("Lua", true); + ar.what = ar.linedefined === 0 ? to_luastring('main', true) : to_luastring('Lua', true); } ar.short_src = luaO_chunkid(ar.source, LUA_IDSIZE); @@ -211,8 +211,8 @@ const getfuncname = function (L, ci) { if (ci === null) return null; else if (ci.callstatus & CIST_FIN) { /* is this a finalizer? */ - r.name = to_luastring("__gc", true); - r.funcname = to_luastring("metamethod", true); /* report it as such */ + r.name = to_luastring('__gc', true); + r.funcname = to_luastring('metamethod', true); /* report it as such */ return r; } /* calling function is a known Lua function? */ @@ -251,7 +251,7 @@ const auxgetinfo = function (L, what, ar, f, ci) { case 110 /* ('n').charCodeAt(0) */: { let r = getfuncname(L, ci); if (r === null) { - ar.namewhat = to_luastring("", true); + ar.namewhat = to_luastring('', true); ar.name = null; } else { ar.namewhat = r.funcname; @@ -276,7 +276,7 @@ const lua_getinfo = function (L, what, ar) { if (what[0] === 62 /* ('>').charCodeAt(0) */) { ci = null; func = L.stack[L.top - 1]; - api_check(L, func.ttisfunction(), "function expected"); + api_check(L, func.ttisfunction(), 'function expected'); what = what.subarray(1); /* skip the '>' */ L.top--; /* pop function */ } else { @@ -289,7 +289,7 @@ const lua_getinfo = function (L, what, ar) { status = auxgetinfo(L, what, ar, cl, ci); if (luastring_indexOf(what, 102 /* ('f').charCodeAt(0) */) >= 0) { pushobj2s(L, func); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } swapextra(L); @@ -319,7 +319,7 @@ const kname = function (p, pc, c) { } /* else no reasonable name found */ } - r.name = to_luastring("?", true); + r.name = to_luastring('?', true); return r; /* no reasonable name found */ }; @@ -385,7 +385,7 @@ const getobjname = function (p, lastpc, reg) { }; if (r.name) { /* is a local? */ - r.funcname = to_luastring("local", true); + r.funcname = to_luastring('local', true); return r; } @@ -407,12 +407,12 @@ const getobjname = function (p, lastpc, reg) { let t = i.B; /* table index */ let vn = i.opcode === OCi.OP_GETTABLE ? luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); r.name = kname(p, pc, k).name; - r.funcname = (vn && luastring_eq(vn, LUA_ENV)) ? to_luastring("global", true) : to_luastring("field", true); + r.funcname = (vn && luastring_eq(vn, LUA_ENV)) ? to_luastring('global', true) : to_luastring('field', true); return r; } case OCi.OP_GETUPVAL: { r.name = upvalname(p, i.B); - r.funcname = to_luastring("upvalue", true); + r.funcname = to_luastring('upvalue', true); return r; } case OCi.OP_LOADK: @@ -420,7 +420,7 @@ const getobjname = function (p, lastpc, reg) { let b = i.opcode === OCi.OP_LOADK ? i.Bx : p.code[pc + 1].Ax; if (p.k[b].ttisstring()) { r.name = p.k[b].svalue(); - r.funcname = to_luastring("constant", true); + r.funcname = to_luastring('constant', true); return r; } break; @@ -428,7 +428,7 @@ const getobjname = function (p, lastpc, reg) { case OCi.OP_SELF: { let k = i.C; r.name = kname(p, pc, k).name; - r.funcname = to_luastring("method", true); + r.funcname = to_luastring('method', true); return r; } default: break; @@ -457,8 +457,8 @@ const funcnamefromcode = function (L, ci) { let OCi = OpCodesI; if (ci.callstatus & CIST_HOOKED) { - r.name = to_luastring("?", true); - r.funcname = to_luastring("hook", true); + r.name = to_luastring('?', true); + r.funcname = to_luastring('hook', true); return r; } @@ -467,8 +467,8 @@ const funcnamefromcode = function (L, ci) { case OCi.OP_TAILCALL: return getobjname(p, pc, i.A); /* get function name */ case OCi.OP_TFORCALL: - r.name = to_luastring("for iterator", true); - r.funcname = to_luastring("for iterator", true); + r.name = to_luastring('for iterator', true); + r.funcname = to_luastring('for iterator', true); return r; /* other instructions can do calls through metamethods */ case OCi.OP_SELF: @@ -504,7 +504,7 @@ const funcnamefromcode = function (L, ci) { } r.name = L.l_G.tmname[tm].getstr(); - r.funcname = to_luastring("metamethod", true); + r.funcname = to_luastring('metamethod', true); return r; }; @@ -546,12 +546,12 @@ const varinfo = function (L, o) { kind = getobjname(ci.func.value.p, currentpc(ci), stkid - ci.l_base); } - return kind ? luaO_pushfstring(L, to_luastring(" (%s '%s')", true), kind.funcname, kind.name) : to_luastring("", true); + return kind ? luaO_pushfstring(L, to_luastring(' (%s \'%s\')', true), kind.funcname, kind.name) : to_luastring('', true); }; const luaG_typeerror = function (L, o, op) { let t = luaT_objtypename(L, o); - luaG_runerror(L, to_luastring("attempt to %s a %s value%s", true), op, t, varinfo(L, o)); + luaG_runerror(L, to_luastring('attempt to %s a %s value%s', true), op, t, varinfo(L, o)); }; const luaG_concaterror = function (L, p1, p2) { @@ -572,9 +572,9 @@ const luaG_ordererror = function (L, p1, p2) { let t1 = luaT_objtypename(L, p1); let t2 = luaT_objtypename(L, p2); if (luastring_eq(t1, t2)) - luaG_runerror(L, to_luastring("attempt to compare two %s values", true), t1); + luaG_runerror(L, to_luastring('attempt to compare two %s values', true), t1); else - luaG_runerror(L, to_luastring("attempt to compare %s with %s", true), t1, t2); + luaG_runerror(L, to_luastring('attempt to compare %s with %s', true), t1, t2); }; /* add src:line information to 'msg' */ @@ -583,9 +583,9 @@ const luaG_addinfo = function (L, msg, src, line) { if (src) buff = luaO_chunkid(src.getstr(), LUA_IDSIZE); else - buff = to_luastring("?", true); + buff = to_luastring('?', true); - return luaO_pushfstring(L, to_luastring("%s:%d: %s", true), buff, line, msg); + return luaO_pushfstring(L, to_luastring('%s:%d: %s', true), buff, line, msg); }; const luaG_runerror = function (L, fmt, ...argp) { @@ -614,7 +614,7 @@ const luaG_tointerror = function (L, p1, p2) { let temp = tointeger(p1); if (temp === false) p2 = p1; - luaG_runerror(L, to_luastring("number%s has no integer representation", true), varinfo(L, p2)); + luaG_runerror(L, to_luastring('number%s has no integer representation', true), varinfo(L, p2)); }; const luaG_traceexec = function (L) { diff --git a/src/ldo.js b/src/ldo.js index d2b29c03..db7b73c1 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -49,11 +49,11 @@ const seterrorobj = function (L, errcode, oldtop) { switch (errcode) { case LUA_ERRMEM: { - setsvalue2s(L, oldtop, luaS_newliteral(L, "not enough memory")); + setsvalue2s(L, oldtop, luaS_newliteral(L, 'not enough memory')); break; } case LUA_ERRERR: { - setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + setsvalue2s(L, oldtop, luaS_newliteral(L, 'error in error handling')); break; } default: { @@ -85,7 +85,7 @@ const luaD_growstack = function (L, n) { if (newsize < needed) newsize = needed; if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ luaD_reallocstack(L, ERRORSTACKSIZE); - luaG_runerror(L, to_luastring("stack overflow", true)); + luaG_runerror(L, to_luastring('stack overflow', true)); } else luaD_reallocstack(L, newsize); @@ -150,8 +150,8 @@ const luaD_precall = function (L, off, nresults) { if (L.hookmask & LUA_MASKCALL) luaD_hook(L, LUA_HOOKCALL, -1); let n = f(L); /* do the actual call */ - if (typeof n !== "number" || n < 0 || (n | 0) !== n) - throw Error("invalid return value from JS function (expected integer)"); + if (typeof n !== 'number' || n < 0 || (n | 0) !== n) + throw Error('invalid return value from JS function (expected integer)'); api_checknelems(L, n); luaD_poscall(L, ci, L.top - n, n); @@ -315,7 +315,7 @@ const adjust_varargs = function (L, p, actual) { const tryfuncTM = function (L, off, func) { let tm = luaT_gettmbyobj(L, func, TMS.TM_CALL); if (!tm.ttisfunction(tm)) - luaG_typeerror(L, func, to_luastring("call", true)); + luaG_typeerror(L, func, to_luastring('call', true)); /* Open a hole inside the stack at 'func' */ pushobj2s(L, L.stack[L.top - 1]); /* push top of stack again */ for (let p = L.top - 2; p > off; p--) @@ -332,7 +332,7 @@ const tryfuncTM = function (L, off, func) { */ const stackerror = function (L) { if (L.nCcalls === LUAI_MAXCCALLS) - luaG_runerror(L, to_luastring("JS stack overflow", true)); + luaG_runerror(L, to_luastring('JS stack overflow', true)); else if (L.nCcalls >= LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)) luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ }; @@ -516,7 +516,7 @@ const resume_error = function (L, msg, narg) { let ts = luaS_newliteral(L, msg); if (narg === 0) { pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, "stack overflow"); + api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { /* remove args from the stack */ for (let i = 1; i < narg; i++) @@ -566,13 +566,13 @@ const lua_resume = function (L, from, nargs) { if (L.status === LUA_OK) { /* may be starting a coroutine */ if (L.ci !== L.base_ci) /* not in base level? */ - return resume_error(L, "cannot resume non-suspended coroutine", nargs); + return resume_error(L, 'cannot resume non-suspended coroutine', nargs); } else if (L.status !== LUA_YIELD) - return resume_error(L, "cannot resume dead coroutine", nargs); + return resume_error(L, 'cannot resume dead coroutine', nargs); L.nCcalls = from ? from.nCcalls + 1 : 1; if (L.nCcalls >= LUAI_MAXCCALLS) - return resume_error(L, "JS stack overflow", nargs); + return resume_error(L, 'JS stack overflow', nargs); L.nny = 0; /* allow yields */ @@ -611,15 +611,15 @@ const lua_yieldk = function (L, nresults, ctx, k) { if (L.nny > 0) { if (L !== L.l_G.mainthread) - luaG_runerror(L, to_luastring("attempt to yield across a JS-call boundary", true)); + luaG_runerror(L, to_luastring('attempt to yield across a JS-call boundary', true)); else - luaG_runerror(L, to_luastring("attempt to yield from outside a coroutine", true)); + luaG_runerror(L, to_luastring('attempt to yield from outside a coroutine', true)); } L.status = LUA_YIELD; ci.extra = ci.funcOff; /* save current 'func' */ if (ci.callstatus & CIST_LUA) /* inside a hook? */ - api_check(L, k === null, "hooks cannot continue after yielding"); + api_check(L, k === null, 'hooks cannot continue after yielding'); else { ci.c_k = k; if (k !== null) /* is there a continuation? */ @@ -685,7 +685,7 @@ class SParser { const checkmode = function (L, mode, x) { if (mode && luastring_indexOf(mode, x[0]) === -1) { luaO_pushfstring(L, - to_luastring("attempt to load a %s chunk (mode is '%s')"), x, mode); + to_luastring('attempt to load a %s chunk (mode is \'%s\')'), x, mode); luaD_throw(L, LUA_ERRSYNTAX); } }; @@ -694,10 +694,10 @@ const f_parser = function (L, p) { let cl; let c = p.z.zgetc(); /* read first character */ if (c === LUA_SIGNATURE[0]) { - checkmode(L, p.mode, to_luastring("binary", true)); + checkmode(L, p.mode, to_luastring('binary', true)); cl = luaU_undump(L, p.z, p.name); } else { - checkmode(L, p.mode, to_luastring("text", true)); + checkmode(L, p.mode, to_luastring('text', true)); cl = luaY_parser(L, p.z, p.buff, p.dyd, p.name, c); } diff --git a/src/ldump.js b/src/ldump.js index bfa1ae10..07115747 100644 --- a/src/ldump.js +++ b/src/ldump.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; import { LUA_SIGNATURE, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, constant_types, luastring_of } from './defs.js'; diff --git a/src/linit.js b/src/linit.js index bf857715..7528a1c3 100644 --- a/src/linit.js +++ b/src/linit.js @@ -1,6 +1,6 @@ import { lua_pop } from './lua.js'; import { luaL_requiref } from './lauxlib.js'; -import { to_luastring } from "./fengaricore.js"; +import { to_luastring } from './fengaricore.js'; import { luaopen_fengari } from './fengarilib.js'; import { luaopen_base } from './lbaselib.js'; import { luaopen_coroutine } from './lcorolib.js'; @@ -13,16 +13,16 @@ import { luaopen_string } from './lstrlib.js'; import { luaopen_table } from './ltablib.js'; import { luaopen_utf8 } from './lutf8lib.js'; -const LUA_COLIBNAME = "coroutine"; -const LUA_TABLIBNAME = "table"; -const LUA_IOLIBNAME = "io"; -const LUA_OSLIBNAME = "os"; -const LUA_STRLIBNAME = "string"; -const LUA_MATHLIBNAME = "math"; -const LUA_UTF8LIBNAME = "utf8"; -const LUA_DBLIBNAME = "debug"; -const LUA_LOADLIBNAME = "package"; -const LUA_FENGARILIBNAME = "fengari"; +const LUA_COLIBNAME = 'coroutine'; +const LUA_TABLIBNAME = 'table'; +const LUA_IOLIBNAME = 'io'; +const LUA_OSLIBNAME = 'os'; +const LUA_STRLIBNAME = 'string'; +const LUA_MATHLIBNAME = 'math'; +const LUA_UTF8LIBNAME = 'utf8'; +const LUA_DBLIBNAME = 'debug'; +const LUA_LOADLIBNAME = 'package'; +const LUA_FENGARILIBNAME = 'fengari'; const loadedlibs = {}; @@ -37,7 +37,7 @@ const luaL_openlibs = function(L) { const _luaL_openlibs = luaL_openlibs; export { _luaL_openlibs as luaL_openlibs }; -loadedlibs["_G"] = luaopen_base, +loadedlibs['_G'] = luaopen_base, loadedlibs[LUA_LOADLIBNAME] = luaopen_package; loadedlibs[LUA_COLIBNAME] = luaopen_coroutine; loadedlibs[LUA_TABLIBNAME] = luaopen_table; @@ -46,7 +46,7 @@ loadedlibs[LUA_STRLIBNAME] = luaopen_string; loadedlibs[LUA_MATHLIBNAME] = luaopen_math; loadedlibs[LUA_UTF8LIBNAME] = luaopen_utf8; loadedlibs[LUA_DBLIBNAME] = luaopen_debug; -if (typeof process !== "undefined") +if (typeof process !== 'undefined') loadedlibs[LUA_IOLIBNAME] = luaopen_io; /* Extension: fengari library */ diff --git a/src/liolib.js b/src/liolib.js index 3cc06d65..b16650b0 100644 --- a/src/liolib.js +++ b/src/liolib.js @@ -2,12 +2,12 @@ import { writeSync } from 'fs'; import { LUA_REGISTRYINDEX, lua_getfield, lua_gettop, lua_isnone, lua_isnoneornil, lua_newuserdata, lua_pop, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, lua_setfield, lua_tostring, lua_touserdata } from './lua.js'; import { LUA_FILEHANDLE, luaL_checkany, luaL_checklstring, luaL_checkudata, luaL_error, luaL_fileresult, luaL_newlib, luaL_newmetatable, luaL_setfuncs, luaL_setmetatable, luaL_testudata } from './lauxlib.js'; import { lua_assert } from './lualib.js'; -import { to_luastring } from "./fengaricore.js"; +import { to_luastring } from './fengaricore.js'; -const IO_PREFIX = "_IO_"; +const IO_PREFIX = '_IO_'; const IOPREF_LEN = IO_PREFIX.length; -const IO_INPUT = to_luastring(IO_PREFIX + "input"); -const IO_OUTPUT = to_luastring(IO_PREFIX + "output"); +const IO_INPUT = to_luastring(IO_PREFIX + 'input'); +const IO_OUTPUT = to_luastring(IO_PREFIX + 'output'); const tolstream = function(L) { return luaL_checkudata(L, 1, LUA_FILEHANDLE); @@ -23,16 +23,16 @@ const io_type = function(L) { if (p === null) lua_pushnil(L); /* not a file */ else if (isclosed(p)) - lua_pushliteral(L, "closed file"); + lua_pushliteral(L, 'closed file'); else - lua_pushliteral(L, "file"); + lua_pushliteral(L, 'file'); return 1; }; const f_tostring = function(L) { let p = tolstream(L); if (isclosed(p)) - lua_pushliteral(L, "file (closed)"); + lua_pushliteral(L, 'file (closed)'); else lua_pushstring(L, to_luastring(`file (${p.f.toString()})`)); return 1; @@ -41,7 +41,7 @@ const f_tostring = function(L) { const tofile = function(L) { let p = tolstream(L); if (isclosed(p)) - luaL_error(L, to_luastring("attempt to use a closed file")); + luaL_error(L, to_luastring('attempt to use a closed file')); lua_assert(p.f); return p.f; }; @@ -72,7 +72,7 @@ const getiofile = function(L, findex) { lua_getfield(L, LUA_REGISTRYINDEX, findex); let p = lua_touserdata(L, -1); if (isclosed(p)) - luaL_error(L, to_luastring("standard %s file is closed"), findex.subarray(IOPREF_LEN)); + luaL_error(L, to_luastring('standard %s file is closed'), findex.subarray(IOPREF_LEN)); return p.f; }; @@ -80,7 +80,7 @@ const g_iofile = function(L, f, mode) { if (!lua_isnoneornil(L, 1)) { let filename = lua_tostring(L, 1); if (filename) - luaL_error(L, to_luastring("opening files not yet implemented")); + luaL_error(L, to_luastring('opening files not yet implemented')); else { tofile(L); /* check that it's a valid file handle */ lua_pushvalue(L, 1); @@ -93,11 +93,11 @@ const g_iofile = function(L, f, mode) { }; const io_input = function(L) { - return g_iofile(L, IO_INPUT, "r"); + return g_iofile(L, IO_INPUT, 'r'); }; const io_output = function(L) { - return g_iofile(L, IO_OUTPUT, "w"); + return g_iofile(L, IO_OUTPUT, 'w'); }; /* node <= 6 doesn't support passing a Uint8Array to fs.writeSync */ @@ -145,25 +145,25 @@ const f_flush = function (L) { }; const iolib = { - "close": io_close, - "flush": io_flush, - "input": io_input, - "output": io_output, - "type": io_type, - "write": io_write + 'close': io_close, + 'flush': io_flush, + 'input': io_input, + 'output': io_output, + 'type': io_type, + 'write': io_write }; const flib = { - "close": io_close, - "flush": f_flush, - "write": f_write, - "__tostring": f_tostring + 'close': io_close, + 'flush': f_flush, + 'write': f_write, + '__tostring': f_tostring }; const createmeta = function(L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, to_luastring("__index", true)); /* metatable.__index = metatable */ + lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = metatable */ luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ lua_pop(L, 1); /* pop new metatable */ }; @@ -172,7 +172,7 @@ const io_noclose = function(L) { let p = tolstream(L); p.closef = io_noclose; lua_pushnil(L); - lua_pushliteral(L, "cannot close standard file"); + lua_pushliteral(L, 'cannot close standard file'); return 2; }; @@ -191,9 +191,9 @@ const luaopen_io = function(L) { luaL_newlib(L, iolib); createmeta(L); /* create (and set) default files */ - createstdfile(L, process.stdin, IO_INPUT, to_luastring("stdin")); - createstdfile(L, process.stdout, IO_OUTPUT, to_luastring("stdout")); - createstdfile(L, process.stderr, null, to_luastring("stderr")); + createstdfile(L, process.stdin, IO_INPUT, to_luastring('stdin')); + createstdfile(L, process.stdout, IO_OUTPUT, to_luastring('stdout')); + createstdfile(L, process.stderr, null, to_luastring('stderr')); return 1; }; diff --git a/src/llex.js b/src/llex.js index 30e69b3a..87c4236f 100644 --- a/src/llex.js +++ b/src/llex.js @@ -13,7 +13,7 @@ const { LUA_ERRSYNTAX } = thread_status; const FIRST_RESERVED = 257; -const LUA_ENV = to_luastring("_ENV", true); +const LUA_ENV = to_luastring('_ENV', true); /* terminal symbols denoted by reserved words */ const TK_AND = FIRST_RESERVED; @@ -56,53 +56,53 @@ const TK_NAME = FIRST_RESERVED + 35; const TK_STRING = FIRST_RESERVED + 36; const RESERVED = { - "TK_AND": TK_AND, - "TK_BREAK": TK_BREAK, - "TK_DO": TK_DO, - "TK_ELSE": TK_ELSE, - "TK_ELSEIF": TK_ELSEIF, - "TK_END": TK_END, - "TK_FALSE": TK_FALSE, - "TK_FOR": TK_FOR, - "TK_FUNCTION": TK_FUNCTION, - "TK_GOTO": TK_GOTO, - "TK_IF": TK_IF, - "TK_IN": TK_IN, - "TK_LOCAL": TK_LOCAL, - "TK_NIL": TK_NIL, - "TK_NOT": TK_NOT, - "TK_OR": TK_OR, - "TK_REPEAT": TK_REPEAT, - "TK_RETURN": TK_RETURN, - "TK_THEN": TK_THEN, - "TK_TRUE": TK_TRUE, - "TK_UNTIL": TK_UNTIL, - "TK_WHILE": TK_WHILE, - "TK_IDIV": TK_IDIV, - "TK_CONCAT": TK_CONCAT, - "TK_DOTS": TK_DOTS, - "TK_EQ": TK_EQ, - "TK_GE": TK_GE, - "TK_LE": TK_LE, - "TK_NE": TK_NE, - "TK_SHL": TK_SHL, - "TK_SHR": TK_SHR, - "TK_DBCOLON": TK_DBCOLON, - "TK_EOS": TK_EOS, - "TK_FLT": TK_FLT, - "TK_INT": TK_INT, - "TK_NAME": TK_NAME, - "TK_STRING": TK_STRING + 'TK_AND': TK_AND, + 'TK_BREAK': TK_BREAK, + 'TK_DO': TK_DO, + 'TK_ELSE': TK_ELSE, + 'TK_ELSEIF': TK_ELSEIF, + 'TK_END': TK_END, + 'TK_FALSE': TK_FALSE, + 'TK_FOR': TK_FOR, + 'TK_FUNCTION': TK_FUNCTION, + 'TK_GOTO': TK_GOTO, + 'TK_IF': TK_IF, + 'TK_IN': TK_IN, + 'TK_LOCAL': TK_LOCAL, + 'TK_NIL': TK_NIL, + 'TK_NOT': TK_NOT, + 'TK_OR': TK_OR, + 'TK_REPEAT': TK_REPEAT, + 'TK_RETURN': TK_RETURN, + 'TK_THEN': TK_THEN, + 'TK_TRUE': TK_TRUE, + 'TK_UNTIL': TK_UNTIL, + 'TK_WHILE': TK_WHILE, + 'TK_IDIV': TK_IDIV, + 'TK_CONCAT': TK_CONCAT, + 'TK_DOTS': TK_DOTS, + 'TK_EQ': TK_EQ, + 'TK_GE': TK_GE, + 'TK_LE': TK_LE, + 'TK_NE': TK_NE, + 'TK_SHL': TK_SHL, + 'TK_SHR': TK_SHR, + 'TK_DBCOLON': TK_DBCOLON, + 'TK_EOS': TK_EOS, + 'TK_FLT': TK_FLT, + 'TK_INT': TK_INT, + 'TK_NAME': TK_NAME, + 'TK_STRING': TK_STRING }; const luaX_tokens = [ - "and", "break", "do", "else", "elseif", - "end", "false", "for", "function", "goto", "if", - "in", "local", "nil", "not", "or", "repeat", - "return", "then", "true", "until", "while", - "//", "..", "...", "==", ">=", "<=", "~=", - "<<", ">>", "::", "", - "", "", "", "" + 'and', 'break', 'do', 'else', 'elseif', + 'end', 'false', 'for', 'function', 'goto', 'if', + 'in', 'local', 'nil', 'not', 'or', 'repeat', + 'return', 'then', 'true', 'until', 'while', + '//', '..', '...', '==', '>=', '<=', '~=', + '<<', '>>', '::', '', + '', '', '', '' ].map((e, i) => to_luastring(e)); class SemInfo { @@ -144,7 +144,7 @@ const save = function (ls, c) { let b = ls.buff; if (b.n + 1 > b.buffer.length) { if (b.buffer.length >= MAX_INT / 2) - lexerror(ls, to_luastring("lexical element too long", true), 0); + lexerror(ls, to_luastring('lexical element too long', true), 0); let newsize = b.buffer.length * 2; luaZ_resizebuffer(ls.L, b, newsize); } @@ -153,11 +153,11 @@ const save = function (ls, c) { const luaX_token2str = function (ls, token) { if (token < FIRST_RESERVED) { /* single-byte symbols? */ - return luaO_pushfstring(ls.L, to_luastring("'%c'", true), token); + return luaO_pushfstring(ls.L, to_luastring('\'%c\'', true), token); } else { let s = luaX_tokens[token - FIRST_RESERVED]; if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ - return luaO_pushfstring(ls.L, to_luastring("'%s'", true), s); + return luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), s); else /* names, strings, and numerals */ return s; } @@ -207,7 +207,7 @@ const inclinenumber = function (ls) { if (currIsNewline(ls) && ls.current !== old) next(ls); /* skip '\n\r' or '\r\n' */ if (++ls.linenumber >= MAX_INT) - lexerror(ls, to_luastring("chunk has too many lines", true), 0); + lexerror(ls, to_luastring('chunk has too many lines', true), 0); }; const luaX_setinput = function (L, ls, z, source, firstchar) { @@ -253,16 +253,16 @@ const check_next2 = function (ls, set) { }; const read_numeral = function (ls, seminfo) { - let expo = "Ee"; + let expo = 'Ee'; let first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); - if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, "xX")) /* hexadecimal? */ - expo = "Pp"; + if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, 'xX')) /* hexadecimal? */ + expo = 'Pp'; for (; ;) { if (check_next2(ls, expo)) /* exponent part? */ - check_next2(ls, "-+"); /* optional exponent sign */ + check_next2(ls, '-+'); /* optional exponent sign */ if (lisxdigit(ls.current)) save_and_next(ls); else if (ls.current === 46 /* ('.').charCodeAt(0) */) @@ -274,7 +274,7 @@ const read_numeral = function (ls, seminfo) { let obj = new TValue(); if (luaO_str2num(luaZ_buffer(ls.buff), obj) === 0) /* format error? */ - lexerror(ls, to_luastring("malformed number", true), TK_FLT); + lexerror(ls, to_luastring('malformed number', true), TK_FLT); if (obj.ttisinteger()) { seminfo.i = obj.value; return TK_INT; @@ -290,7 +290,7 @@ const txtToken = function (ls, token) { case TK_NAME: case TK_STRING: case TK_FLT: case TK_INT: // save(ls, 0); - return luaO_pushfstring(ls.L, to_luastring("'%s'", true), luaZ_buffer(ls.buff)); + return luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), luaZ_buffer(ls.buff)); default: return luaX_token2str(ls, token); } @@ -299,7 +299,7 @@ const txtToken = function (ls, token) { const lexerror = function (ls, msg, token) { msg = luaG_addinfo(ls.L, msg, ls.source, ls.linenumber); if (token) - luaO_pushfstring(ls.L, to_luastring("%s near %s"), msg, txtToken(ls, token)); + luaO_pushfstring(ls.L, to_luastring('%s near %s'), msg, txtToken(ls, token)); luaD_throw(ls.L, LUA_ERRSYNTAX); }; @@ -335,7 +335,7 @@ const read_long_string = function (ls, seminfo, sep) { for (; !skip;) { switch (ls.current) { case EOZ: { /* error */ - let what = seminfo ? "string" : "comment"; + let what = seminfo ? 'string' : 'comment'; let msg = `unfinished long ${what} (starting at line ${line})`; lexerror(ls, to_luastring(msg), TK_EOS); break; @@ -375,7 +375,7 @@ const esccheck = function (ls, c, msg) { const gethexa = function (ls) { save_and_next(ls); - esccheck(ls, lisxdigit(ls.current), to_luastring("hexadecimal digit expected", true)); + esccheck(ls, lisxdigit(ls.current), to_luastring('hexadecimal digit expected', true)); return luaO_hexavalue(ls.current); }; @@ -389,17 +389,17 @@ const readhexaesc = function (ls) { const readutf8desc = function (ls) { let i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ save_and_next(ls); /* skip 'u' */ - esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring("missing '{'", true)); + esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring('missing \'{\'', true)); let r = gethexa(ls); /* must have at least one digit */ save_and_next(ls); while (lisxdigit(ls.current)) { i++; r = (r << 4) + luaO_hexavalue(ls.current); - esccheck(ls, r <= 0x10FFFF, to_luastring("UTF-8 value too large", true)); + esccheck(ls, r <= 0x10FFFF, to_luastring('UTF-8 value too large', true)); save_and_next(ls); } - esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring("missing '}'", true)); + esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring('missing \'}\'', true)); next(ls); /* skip '}' */ luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */ return r; @@ -419,7 +419,7 @@ const readdecesc = function (ls) { r = 10 * r + ls.current - 48 /* ('0').charCodeAt(0) */; save_and_next(ls); } - esccheck(ls, r <= 255, to_luastring("decimal escape too large", true)); + esccheck(ls, r <= 255, to_luastring('decimal escape too large', true)); luaZ_buffremove(ls.buff, i); /* remove read digits from buffer */ return r; }; @@ -430,11 +430,11 @@ const read_string = function (ls, del, seminfo) { while (ls.current !== del) { switch (ls.current) { case EOZ: - lexerror(ls, to_luastring("unfinished string", true), TK_EOS); + lexerror(ls, to_luastring('unfinished string', true), TK_EOS); break; case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: - lexerror(ls, to_luastring("unfinished string", true), TK_STRING); + lexerror(ls, to_luastring('unfinished string', true), TK_STRING); break; case 92 /* ('\\').charCodeAt(0) */: { /* escape sequences */ save_and_next(ls); /* keep '\\' for error messages */ @@ -468,7 +468,7 @@ const read_string = function (ls, del, seminfo) { will = 'no_save'; break; } default: { - esccheck(ls, lisdigit(ls.current), to_luastring("invalid escape sequence", true)); + esccheck(ls, lisdigit(ls.current), to_luastring('invalid escape sequence', true)); c = readdecesc(ls); /* digital escape '\ddd' */ will = 'only_save'; break; } @@ -504,7 +504,7 @@ const isreserved = function (w) { const llex = function (ls, seminfo) { luaZ_resetbuffer(ls.buff); for (; ;) { - lua_assert(typeof ls.current == "number"); /* fengari addition */ + lua_assert(typeof ls.current == 'number'); /* fengari addition */ switch (ls.current) { case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: { /* line breaks */ @@ -544,7 +544,7 @@ const llex = function (ls, seminfo) { read_long_string(ls, seminfo, sep); return TK_STRING; } else if (sep !== -1) /* '[=...' missing second bracket */ - lexerror(ls, to_luastring("invalid long string delimiter", true), TK_STRING); + lexerror(ls, to_luastring('invalid long string delimiter', true), TK_STRING); return 91 /* ('[').charCodeAt(0) */; } case 61 /* ('=').charCodeAt(0) */: { diff --git a/src/llimits.js b/src/llimits.js index 8ec38bdc..cce5e61f 100644 --- a/src/llimits.js +++ b/src/llimits.js @@ -1,5 +1,5 @@ const lua_assert = function (c) { - if (!c) throw Error("assertion failed"); + if (!c) throw Error('assertion failed'); }; const _lua_assert = lua_assert; export { _lua_assert as lua_assert }; diff --git a/src/lmathlib.js b/src/lmathlib.js index d71550d2..fe095cc7 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,7 +1,7 @@ import { LUA_OPLT, LUA_TNUMBER, lua_compare, lua_gettop, lua_isinteger, lua_isnoneornil, lua_pushboolean, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushvalue, lua_setfield, lua_settop, lua_tointeger, lua_tointegerx, lua_type } from './lua.js'; import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checknumber, luaL_error, luaL_newlib, luaL_optnumber } from './lauxlib.js'; import { LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger } from './luaconf.js'; -import { to_luastring } from "./fengaricore.js"; +import { to_luastring } from './fengaricore.js'; let rand_state; /* use same parameters as glibc LCG */ @@ -33,13 +33,13 @@ const math_random = function (L) { up = luaL_checkinteger(L, 2); break; } - default: return luaL_error(L, "wrong number of arguments"); + default: return luaL_error(L, 'wrong number of arguments'); } /* random integer in the interval [low, up] */ - luaL_argcheck(L, low <= up, 1, "interval is empty"); + luaL_argcheck(L, low <= up, 1, 'interval is empty'); luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, - "interval too large"); + 'interval too large'); r *= (up - low) + 1; lua_pushinteger(L, Math.floor(r) + low); @@ -180,7 +180,7 @@ const math_rad = function (L) { const math_min = function (L) { let n = lua_gettop(L); /* number of arguments */ let imin = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, "value expected"); + luaL_argcheck(L, n >= 1, 1, 'value expected'); for (let i = 2; i <= n; i++) { if (lua_compare(L, i, imin, LUA_OPLT)) imin = i; @@ -192,7 +192,7 @@ const math_min = function (L) { const math_max = function (L) { let n = lua_gettop(L); /* number of arguments */ let imax = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, "value expected"); + luaL_argcheck(L, n >= 1, 1, 'value expected'); for (let i = 2; i <= n; i++) { if (lua_compare(L, imax, i, LUA_OPLT)) imax = i; @@ -204,9 +204,9 @@ const math_max = function (L) { const math_type = function (L) { if (lua_type(L, 1) === LUA_TNUMBER) { if (lua_isinteger(L, 1)) - lua_pushliteral(L, "integer"); + lua_pushliteral(L, 'integer'); else - lua_pushliteral(L, "float"); + lua_pushliteral(L, 'float'); } else { luaL_checkany(L, 1); lua_pushnil(L); @@ -219,7 +219,7 @@ const math_fmod = function (L) { let d = lua_tointeger(L, 2); /* no special case needed for -1 in javascript */ if (d === 0) { - luaL_argerror(L, 2, "zero"); + luaL_argerror(L, 2, 'zero'); } else lua_pushinteger(L, (lua_tointeger(L, 1) % d) | 0); } else { @@ -244,41 +244,41 @@ const math_modf = function (L) { }; const mathlib = { - "abs": math_abs, - "acos": math_acos, - "asin": math_asin, - "atan": math_atan, - "ceil": math_ceil, - "cos": math_cos, - "deg": math_deg, - "exp": math_exp, - "floor": math_floor, - "fmod": math_fmod, - "log": math_log, - "max": math_max, - "min": math_min, - "modf": math_modf, - "rad": math_rad, - "random": math_random, - "randomseed": math_randomseed, - "sin": math_sin, - "sqrt": math_sqrt, - "tan": math_tan, - "tointeger": math_toint, - "type": math_type, - "ult": math_ult + 'abs': math_abs, + 'acos': math_acos, + 'asin': math_asin, + 'atan': math_atan, + 'ceil': math_ceil, + 'cos': math_cos, + 'deg': math_deg, + 'exp': math_exp, + 'floor': math_floor, + 'fmod': math_fmod, + 'log': math_log, + 'max': math_max, + 'min': math_min, + 'modf': math_modf, + 'rad': math_rad, + 'random': math_random, + 'randomseed': math_randomseed, + 'sin': math_sin, + 'sqrt': math_sqrt, + 'tan': math_tan, + 'tointeger': math_toint, + 'type': math_type, + 'ult': math_ult }; const luaopen_math = function (L) { luaL_newlib(L, mathlib); lua_pushnumber(L, Math.PI); - lua_setfield(L, -2, to_luastring("pi", true)); + lua_setfield(L, -2, to_luastring('pi', true)); lua_pushnumber(L, Infinity); - lua_setfield(L, -2, to_luastring("huge", true)); + lua_setfield(L, -2, to_luastring('huge', true)); lua_pushinteger(L, LUA_MAXINTEGER); - lua_setfield(L, -2, to_luastring("maxinteger", true)); + lua_setfield(L, -2, to_luastring('maxinteger', true)); lua_pushinteger(L, LUA_MININTEGER); - lua_setfield(L, -2, to_luastring("mininteger", true)); + lua_setfield(L, -2, to_luastring('mininteger', true)); return 1; }; diff --git a/src/loadlib.js b/src/loadlib.js index 4b6aaf48..cd09ecdb 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -2,16 +2,16 @@ import { LUA_DIRSEP, LUA_EXEC_DIR, LUA_JSPATH_DEFAULT, LUA_PATH_DEFAULT, LUA_PAT import { LUA_OK, LUA_REGISTRYINDEX, LUA_TNIL, LUA_TTABLE, lua_callk, lua_createtable, lua_getfield, lua_insert, lua_isfunction, lua_isnil, lua_isstring, lua_newtable, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgeti, lua_rawgetp, lua_rawseti, lua_rawsetp, lua_remove, lua_setfield, lua_setmetatable, lua_settop, lua_toboolean, lua_tostring, lua_touserdata, lua_upvalueindex } from './lua.js'; import { LUA_LOADED_TABLE, LUA_PRELOAD_TABLE, luaL_Buffer, luaL_addvalue, luaL_buffinit, luaL_checkstring, luaL_error, luaL_getsubtable, luaL_gsub, luaL_len, luaL_loadfile, luaL_newlib, luaL_optstring, luaL_pushresult, luaL_setfuncs } from './lauxlib.js'; import { LUA_VERSUFFIX } from './lualib.js'; -import { luastring_indexOf, to_jsstring, to_luastring, to_uristring } from "./fengaricore.js"; +import { luastring_indexOf, to_jsstring, to_luastring, to_uristring } from './fengaricore.js'; import * as fengari from './fengari.js'; import pathlib from 'path'; import fs from 'fs'; const global_env = (function () { - if (typeof process !== "undefined") { + if (typeof process !== 'undefined') { /* node */ return global; - } else if (typeof window !== "undefined") { + } else if (typeof window !== 'undefined') { /* browser window */ return window; } else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { @@ -23,11 +23,11 @@ const global_env = (function () { } })(); -const JSLIBS = to_luastring("__JSLIBS__"); -const LUA_PATH_VAR = "LUA_PATH"; -const LUA_JSPATH_VAR = "LUA_JSPATH"; +const JSLIBS = to_luastring('__JSLIBS__'); +const LUA_PATH_VAR = 'LUA_PATH'; +const LUA_JSPATH_VAR = 'LUA_JSPATH'; -const LUA_IGMARK = "-"; +const LUA_IGMARK = '-'; /* ** LUA_CSUBSEP is the character that replaces dots in submodule names @@ -39,13 +39,13 @@ const LUA_CSUBSEP = LUA_DIRSEP; const LUA_LSUBSEP = LUA_DIRSEP; /* prefix for open functions in JS libraries */ -const LUA_POF = to_luastring("luaopen_"); +const LUA_POF = to_luastring('luaopen_'); /* separator for open functions in JS libraries */ -const LUA_OFSEP = to_luastring("_"); -const LIB_FAIL = "open"; +const LUA_OFSEP = to_luastring('_'); +const LIB_FAIL = 'open'; -const AUXMARK = to_luastring("\x01"); +const AUXMARK = to_luastring('\x01'); /* @@ -55,11 +55,11 @@ const AUXMARK = to_luastring("\x01"); ** error string in the stack. */ let lsys_load; -if (typeof process === "undefined") { +if (typeof process === 'undefined') { lsys_load = function (L, path, seeglb) { path = to_uristring(path); let xhr = new XMLHttpRequest(); - xhr.open("GET", path, false); + xhr.open('GET', path, false); xhr.send(); if (xhr.status < 200 || xhr.status >= 300) { @@ -70,16 +70,16 @@ if (typeof process === "undefined") { let code = xhr.response; /* Add sourceURL comment to get path in debugger+tracebacks */ if (!/\/\/[#@] sourceURL=/.test(code)) - code += " //# sourceURL=" + path; + code += ' //# sourceURL=' + path; let func; try { - func = Function("fengari", code); + func = Function('fengari', code); } catch (e) { lua_pushstring(L, to_luastring(`${e.name}: ${e.message}`)); return null; } let res = func(fengari); - if (typeof res === "function" || (typeof res === "object" && res !== null)) { + if (typeof res === 'function' || (typeof res === 'object' && res !== null)) { return res; } else if (res === void 0) { /* assume library added symbols to global environment */ return global_env; @@ -113,7 +113,7 @@ const lsys_sym = function (L, lib, sym) { if (f && typeof f === 'function') return f; else { - lua_pushfstring(L, to_luastring("undefined symbol: %s"), sym); + lua_pushfstring(L, to_luastring('undefined symbol: %s'), sym); return null; } }; @@ -122,14 +122,14 @@ const lsys_sym = function (L, lib, sym) { ** return registry.LUA_NOENV as a boolean */ const noenv = function (L) { - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("LUA_NOENV")); + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('LUA_NOENV')); let b = lua_toboolean(L, -1); lua_pop(L, 1); /* remove value */ return b; }; let readable; -if (typeof process !== "undefined") { // Only with Node +if (typeof process !== 'undefined') { // Only with Node readable = function (filename) { try { let fd = fs.openSync(filename, 'r'); @@ -144,7 +144,7 @@ if (typeof process !== "undefined") { // Only with Node path = to_uristring(path); let xhr = new XMLHttpRequest(); /* Following GET request done by searcher_Web will be cached */ - xhr.open("GET", path, false); + xhr.open('GET', path, false); xhr.send(); return xhr.status >= 200 && xhr.status <= 299; @@ -196,13 +196,13 @@ const ll_loadlib = function (L) { else { /* error; error message is on stack top */ lua_pushnil(L); lua_insert(L, -2); - lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : "init"); + lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : 'init'); return 3; /* return nil, error message, and where */ } }; const env = (function () { - if (typeof process !== "undefined") { + if (typeof process !== 'undefined') { /* node */ return process.env; } else { @@ -279,7 +279,7 @@ const searchpath = function (L, name, path, sep, dirsep) { lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pushfstring(L, to_luastring("\n\tno file '%s'"), filename); + lua_pushfstring(L, to_luastring('\n\tno file \'%s\''), filename); lua_remove(L, -2); /* remove file name */ luaL_addvalue(msg); } @@ -292,7 +292,7 @@ const ll_searchpath = function (L) { L, luaL_checkstring(L, 1), luaL_checkstring(L, 2), - luaL_optstring(L, 3, "."), + luaL_optstring(L, 3, '.'), luaL_optstring(L, 4, LUA_DIRSEP) ); if (f !== null) return 1; @@ -307,8 +307,8 @@ const findfile = function (L, name, pname, dirsep) { lua_getfield(L, lua_upvalueindex(1), pname); let path = lua_tostring(L, -1); if (path === null) - luaL_error(L, to_luastring("'package.%s' must be a string"), pname); - return searchpath(L, name, path, to_luastring("."), dirsep); + luaL_error(L, to_luastring('\'package.%s\' must be a string'), pname); + return searchpath(L, name, path, to_luastring('.'), dirsep); }; const checkload = function (L, stat, filename) { @@ -316,13 +316,13 @@ const checkload = function (L, stat, filename) { lua_pushstring(L, filename); /* will be 2nd argument to module */ return 2; /* return open function and file name */ } else - return luaL_error(L, to_luastring("error loading module '%s' from file '%s':\n\t%s"), + return luaL_error(L, to_luastring('error loading module \'%s\' from file \'%s\':\n\t%s'), lua_tostring(L, 1), filename, lua_tostring(L, -1)); }; const searcher_Lua = function (L) { let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring("path", true), to_luastring(LUA_LSUBSEP, true)); + let filename = findfile(L, name, to_luastring('path', true), to_luastring(LUA_LSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, luaL_loadfile(L, filename) === LUA_OK, filename); }; @@ -337,22 +337,22 @@ const searcher_Lua = function (L) { */ const loadfunc = function (L, filename, modname) { let openfunc; - modname = luaL_gsub(L, modname, to_luastring("."), LUA_OFSEP); + modname = luaL_gsub(L, modname, to_luastring('.'), LUA_OFSEP); let mark = luastring_indexOf(modname, LUA_IGMARK.charCodeAt(0)); if (mark >= 0) { openfunc = lua_pushlstring(L, modname, mark); - openfunc = lua_pushfstring(L, to_luastring("%s%s"), LUA_POF, openfunc); + openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, openfunc); let stat = lookforfunc(L, filename, openfunc); if (stat !== ERRFUNC) return stat; modname = mark + 1; /* else go ahead and try old-style name */ } - openfunc = lua_pushfstring(L, to_luastring("%s%s"), LUA_POF, modname); + openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, modname); return lookforfunc(L, filename, openfunc); }; const searcher_C = function (L) { let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring("jspath", true), to_luastring(LUA_CSUBSEP, true)); + let filename = findfile(L, name, to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, (loadfunc(L, filename, name) === 0), filename); }; @@ -363,13 +363,13 @@ const searcher_Croot = function (L) { let stat; if (p < 0) return 0; /* is root */ lua_pushlstring(L, name, p); - let filename = findfile(L, lua_tostring(L, -1), to_luastring("jspath", true), to_luastring(LUA_CSUBSEP, true)); + let filename = findfile(L, lua_tostring(L, -1), to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* root not found */ if ((stat = loadfunc(L, filename, name)) !== 0) { if (stat != ERRFUNC) return checkload(L, 0, filename); /* real error */ else { /* open function not found */ - lua_pushfstring(L, to_luastring("\n\tno module '%s' in file '%s'"), name, filename); + lua_pushfstring(L, to_luastring('\n\tno module \'%s\' in file \'%s\''), name, filename); return 1; } } @@ -381,7 +381,7 @@ const searcher_preload = function (L) { let name = luaL_checkstring(L, 1); lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); if (lua_getfield(L, -1, name) === LUA_TNIL) /* not found? */ - lua_pushfstring(L, to_luastring("\n\tno field package.preload['%s']"), name); + lua_pushfstring(L, to_luastring('\n\tno field package.preload[\'%s\']'), name); return 1; }; @@ -389,8 +389,8 @@ const findloader = function (L, name, ctx, k) { let msg = new luaL_Buffer(); /* to build error message */ luaL_buffinit(L, msg); /* push 'package.searchers' to index 3 in the stack */ - if (lua_getfield(L, lua_upvalueindex(1), to_luastring("searchers", true)) !== LUA_TTABLE) - luaL_error(L, to_luastring("'package.searchers' must be a table")); + if (lua_getfield(L, lua_upvalueindex(1), to_luastring('searchers', true)) !== LUA_TTABLE) + luaL_error(L, to_luastring('\'package.searchers\' must be a table')); let ctx2 = { name: name, i: 1, msg: msg, ctx: ctx, k: k }; return findloader_cont(L, LUA_OK, ctx2); }; @@ -402,7 +402,7 @@ const findloader_cont = function (L, status, ctx) { if (lua_rawgeti(L, 3, ctx.i) === LUA_TNIL) { /* no more searchers? */ lua_pop(L, 1); /* remove nil */ luaL_pushresult(ctx.msg); /* create error message */ - luaL_error(L, to_luastring("module '%s' not found:%s"), ctx.name, lua_tostring(L, -1)); + luaL_error(L, to_luastring('module \'%s\' not found:%s'), ctx.name, lua_tostring(L, -1)); } lua_pushstring(L, ctx.name); lua_callk(L, 1, 2, ctx, findloader_cont); /* call it */ @@ -455,12 +455,12 @@ const ll_require_cont2 = function (L, status, ctx) { }; const pk_funcs = { - "loadlib": ll_loadlib, - "searchpath": ll_searchpath + 'loadlib': ll_loadlib, + 'searchpath': ll_searchpath }; const ll_funcs = { - "require": ll_require + 'require': ll_require }; const createsearcherstable = function (L) { @@ -473,7 +473,7 @@ const createsearcherstable = function (L) { lua_pushcclosure(L, searchers[i], 1); lua_rawseti(L, -2, i + 1); } - lua_setfield(L, -2, to_luastring("searchers", true)); /* put it in field 'searchers' */ + lua_setfield(L, -2, to_luastring('searchers', true)); /* put it in field 'searchers' */ }; /* @@ -492,18 +492,18 @@ const luaopen_package = function (L) { luaL_newlib(L, pk_funcs); /* create 'package' table */ createsearcherstable(L); /* set paths */ - setpath(L, to_luastring("path", true), LUA_PATH_VAR, LUA_PATH_DEFAULT); - setpath(L, to_luastring("jspath", true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); + setpath(L, to_luastring('path', true), LUA_PATH_VAR, LUA_PATH_DEFAULT); + setpath(L, to_luastring('jspath', true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); /* store config information */ - lua_pushliteral(L, LUA_DIRSEP + "\n" + LUA_PATH_SEP + "\n" + LUA_PATH_MARK + "\n" + - LUA_EXEC_DIR + "\n" + LUA_IGMARK + "\n"); - lua_setfield(L, -2, to_luastring("config", true)); + lua_pushliteral(L, LUA_DIRSEP + '\n' + LUA_PATH_SEP + '\n' + LUA_PATH_MARK + '\n' + + LUA_EXEC_DIR + '\n' + LUA_IGMARK + '\n'); + lua_setfield(L, -2, to_luastring('config', true)); /* set field 'loaded' */ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - lua_setfield(L, -2, to_luastring("loaded", true)); + lua_setfield(L, -2, to_luastring('loaded', true)); /* set field 'preload' */ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - lua_setfield(L, -2, to_luastring("preload", true)); + lua_setfield(L, -2, to_luastring('preload', true)); lua_pushglobaltable(L); lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ diff --git a/src/lobject.js b/src/lobject.js index 31f522a3..abe34f9f 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -7,7 +7,7 @@ import { luaS_bless, luaS_new } from './lstring.js'; import { Table } from './ltable.js'; import { LUA_COMPAT_FLOATSTRING, ldexp, lua_integer2str, lua_number2str } from './luaconf.js'; import { luaV_concat, luaV_imul, luaV_mod, luaV_div, luaV_shiftl, tointeger, tonumber } from './lvm.js'; -import { MAX_INT, luai_nummod, lua_assert } from "./llimits.js"; +import { MAX_INT, luai_nummod, lua_assert } from './llimits.js'; import { luaT_trybinTM, TMS } from './ltm.js'; const { @@ -307,9 +307,9 @@ class LocVar { } } -const RETS = to_luastring("..."); -const PRE = to_luastring("[string \""); -const POS = to_luastring("\"]"); +const RETS = to_luastring('...'); +const PRE = to_luastring('[string "'); +const POS = to_luastring('"]'); const luaO_chunkid = function (source, bufflen) { let l = source.length; @@ -468,11 +468,11 @@ const SIGILS = [ 78 /* ("N").charCodeAt(0) */ ]; const modes = { - [46]: ".", - [120]: "x", - [88]: "x", - [110]: "n", - [78]: "n" + [46]: '.', + [120]: 'x', + [88]: 'x', + [110]: 'n', + [78]: 'n' }; const l_str2d = function (s) { let l = s.length; @@ -577,7 +577,7 @@ const luaO_pushvfstring = function (L, fmt, argp) { switch (fmt[e + 1]) { case 115 /* ('s').charCodeAt(0) */: { let s = argp[a++]; - if (s === null) s = to_luastring("(null)", true); + if (s === null) s = to_luastring('(null)', true); else { s = from_userstring(s); /* respect null terminator */ @@ -593,7 +593,7 @@ const luaO_pushvfstring = function (L, fmt, argp) { if (lisprint(buff)) pushstr(L, luastring_of(buff)); else - luaO_pushfstring(L, to_luastring("<\\%d>", true), buff); + luaO_pushfstring(L, to_luastring('<\\%d>', true), buff); break; } case 100 /* ('d').charCodeAt(0) */: @@ -614,39 +614,39 @@ const luaO_pushvfstring = function (L, fmt, argp) { v instanceof Udata || v instanceof LClosure || v instanceof CClosure) { - pushstr(L, to_luastring("0x" + v.id.toString(16))); + pushstr(L, to_luastring('0x' + v.id.toString(16))); } else { switch (typeof v) { - case "undefined": - pushstr(L, to_luastring("undefined")); + case 'undefined': + pushstr(L, to_luastring('undefined')); break; - case "number": /* before check object as null is an object */ - pushstr(L, to_luastring("Number(" + v + ")")); + case 'number': /* before check object as null is an object */ + pushstr(L, to_luastring('Number(' + v + ')')); break; - case "string": /* before check object as null is an object */ - pushstr(L, to_luastring("String(" + JSON.stringify(v) + ")")); + case 'string': /* before check object as null is an object */ + pushstr(L, to_luastring('String(' + JSON.stringify(v) + ')')); break; - case "boolean": /* before check object as null is an object */ - pushstr(L, to_luastring(v ? "Boolean(true)" : "Boolean(false)")); + case 'boolean': /* before check object as null is an object */ + pushstr(L, to_luastring(v ? 'Boolean(true)' : 'Boolean(false)')); break; - case "object": + case 'object': if (v === null) { /* null is special */ - pushstr(L, to_luastring("null")); + pushstr(L, to_luastring('null')); break; } /* fall through */ - case "function": { + case 'function': { let id = L.l_G.ids.get(v); if (!id) { id = L.l_G.id_counter++; L.l_G.ids.set(v, id); } - pushstr(L, to_luastring("0x" + id.toString(16))); + pushstr(L, to_luastring('0x' + id.toString(16))); break; } default: /* user provided object. no id available */ - pushstr(L, to_luastring("")); + pushstr(L, to_luastring('')); } } break; @@ -658,10 +658,10 @@ const luaO_pushvfstring = function (L, fmt, argp) { break; } case 37 /* ('%').charCodeAt(0) */: - pushstr(L, to_luastring("%", true)); + pushstr(L, to_luastring('%', true)); break; default: - luaG_runerror(L, to_luastring("invalid option '%%%c' to 'lua_pushfstring'"), fmt[e + 1]); + luaG_runerror(L, to_luastring('invalid option \'%%%c\' to \'lua_pushfstring\''), fmt[e + 1]); } n += 2; i = e + 2; @@ -730,7 +730,7 @@ const numarith = function (L, op, v1, v2) { }; const luaO_arith = function (L, op, p1, p2, p3) { - let res = (typeof p3 === "number") ? L.stack[p3] : p3; /* FIXME */ + let res = (typeof p3 === 'number') ? L.stack[p3] : p3; /* FIXME */ switch (op) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: diff --git a/src/lopcodes.js b/src/lopcodes.js index 50faed38..8396c007 100644 --- a/src/lopcodes.js +++ b/src/lopcodes.js @@ -1,51 +1,51 @@ const OpCodes = [ - "MOVE", - "LOADK", - "LOADKX", - "LOADBOOL", - "LOADNIL", - "GETUPVAL", - "GETTABUP", - "GETTABLE", - "SETTABUP", - "SETUPVAL", - "SETTABLE", - "NEWTABLE", - "SELF", - "ADD", - "SUB", - "MUL", - "MOD", - "POW", - "DIV", - "IDIV", - "BAND", - "BOR", - "BXOR", - "SHL", - "SHR", - "UNM", - "BNOT", - "NOT", - "LEN", - "CONCAT", - "JMP", - "EQ", - "LT", - "LE", - "TEST", - "TESTSET", - "CALL", - "TAILCALL", - "RETURN", - "FORLOOP", - "FORPREP", - "TFORCALL", - "TFORLOOP", - "SETLIST", - "CLOSURE", - "VARARG", - "EXTRAARG" + 'MOVE', + 'LOADK', + 'LOADKX', + 'LOADBOOL', + 'LOADNIL', + 'GETUPVAL', + 'GETTABUP', + 'GETTABLE', + 'SETTABUP', + 'SETUPVAL', + 'SETTABLE', + 'NEWTABLE', + 'SELF', + 'ADD', + 'SUB', + 'MUL', + 'MOD', + 'POW', + 'DIV', + 'IDIV', + 'BAND', + 'BOR', + 'BXOR', + 'SHL', + 'SHR', + 'UNM', + 'BNOT', + 'NOT', + 'LEN', + 'CONCAT', + 'JMP', + 'EQ', + 'LT', + 'LE', + 'TEST', + 'TESTSET', + 'CALL', + 'TAILCALL', + 'RETURN', + 'FORLOOP', + 'FORPREP', + 'TFORCALL', + 'TFORLOOP', + 'SETLIST', + 'CLOSURE', + 'VARARG', + 'EXTRAARG' ]; const OpCodesI = { @@ -308,7 +308,7 @@ const SETARG_sBx = function (i, b) { ** Pre-calculate all possible part of the instruction */ const fullins = function (ins) { - if (typeof ins === "number") { + if (typeof ins === 'number') { return { code: ins, opcode: (ins >> POS_OP) & MASK1(SIZE_OP, 0), diff --git a/src/loslib.js b/src/loslib.js index 62c2e187..4dae7b7f 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -1,11 +1,11 @@ -"use strict"; +'use strict'; import fs from 'fs'; import tmp from 'tmp'; import child_process from 'child_process'; import { LUA_TNIL, LUA_TTABLE, lua_close, lua_createtable, lua_getfield, lua_isboolean, lua_isnoneornil, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushstring, lua_setfield, lua_settop, lua_toboolean, lua_tointegerx } from './lua.js'; import { luaL_Buffer, luaL_addchar, luaL_addstring, luaL_argerror, luaL_buffinit, luaL_checkinteger, luaL_checkoption, luaL_checkstring, luaL_checktype, luaL_error, luaL_execresult, luaL_fileresult, luaL_newlib, luaL_optinteger, luaL_optlstring, luaL_optstring, luaL_pushresult } from './lauxlib.js'; -import { luastring_eq, to_jsstring, to_luastring } from "./fengaricore.js"; +import { luastring_eq, to_jsstring, to_luastring } from './fengaricore.js'; /* options for ANSI C 89 (only 1-char options) */ // const L_STRFTIMEC89 = to_luastring("aAbBcdHIjmMpSUwWxXyYZ%"); @@ -29,7 +29,7 @@ import { luastring_eq, to_jsstring, to_luastring } from "./fengaricore.js"; - %l: TZ extension: space-padded 12-hour - %P: GNU extension: lower-case am/pm */ -const LUA_STRFTIMEOPTIONS = to_luastring("aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%"); +const LUA_STRFTIMEOPTIONS = to_luastring('aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%'); const setfield = function(L, key, value) { @@ -38,14 +38,14 @@ const setfield = function(L, key, value) { }; const setallfields = function(L, time, utc) { - setfield(L, "sec", utc ? time.getUTCSeconds() : time.getSeconds()); - setfield(L, "min", utc ? time.getUTCMinutes() : time.getMinutes()); - setfield(L, "hour", utc ? time.getUTCHours() : time.getHours()); - setfield(L, "day", utc ? time.getUTCDate() : time.getDate()); - setfield(L, "month", (utc ? time.getUTCMonth() : time.getMonth()) + 1); - setfield(L, "year", utc ? time.getUTCFullYear() : time.getFullYear()); - setfield(L, "wday", (utc ? time.getUTCDay() : time.getDay()) + 1); - setfield(L, "yday", Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); + setfield(L, 'sec', utc ? time.getUTCSeconds() : time.getSeconds()); + setfield(L, 'min', utc ? time.getUTCMinutes() : time.getMinutes()); + setfield(L, 'hour', utc ? time.getUTCHours() : time.getHours()); + setfield(L, 'day', utc ? time.getUTCDate() : time.getDate()); + setfield(L, 'month', (utc ? time.getUTCMonth() : time.getMonth()) + 1); + setfield(L, 'year', utc ? time.getUTCFullYear() : time.getFullYear()); + setfield(L, 'wday', (utc ? time.getUTCDay() : time.getDay()) + 1); + setfield(L, 'yday', Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); // setboolfield(L, "isdst", time.get); }; @@ -56,14 +56,14 @@ const getfield = function(L, key, d, delta) { let res = lua_tointegerx(L, -1); if (res === false) { /* field is not an integer? */ if (t !== LUA_TNIL) /* some other value? */ - return luaL_error(L, to_luastring("field '%s' is not an integer"), key); + return luaL_error(L, to_luastring('field \'%s\' is not an integer'), key); else if (d < 0) /* absent field; no default? */ - return luaL_error(L, to_luastring("field '%s' missing in date table"), key); + return luaL_error(L, to_luastring('field \'%s\' missing in date table'), key); res = d; } else { if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) - return luaL_error(L, to_luastring("field '%s' is out-of-bound"), key); + return luaL_error(L, to_luastring('field \'%s\' is out-of-bound'), key); res -= delta; } lua_pop(L, 1); @@ -72,23 +72,23 @@ const getfield = function(L, key, d, delta) { const locale = { - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ].map((s) => to_luastring(s)), - shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].map((s) => to_luastring(s)), - months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"].map((s) => to_luastring(s)), - shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map((s) => to_luastring(s)), - AM: to_luastring("AM"), - PM: to_luastring("PM"), - am: to_luastring("am"), - pm: to_luastring("pm"), + days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ].map((s) => to_luastring(s)), + shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((s) => to_luastring(s)), + months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].map((s) => to_luastring(s)), + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'].map((s) => to_luastring(s)), + AM: to_luastring('AM'), + PM: to_luastring('PM'), + am: to_luastring('am'), + pm: to_luastring('pm'), formats: { - c: to_luastring("%a %b %e %H:%M:%S %Y"), - D: to_luastring("%m/%d/%y"), - F: to_luastring("%Y-%m-%d"), - R: to_luastring("%H:%M"), - r: to_luastring("%I:%M:%S %p"), - T: to_luastring("%H:%M:%S"), - X: to_luastring("%T"), - x: to_luastring("%D") + c: to_luastring('%a %b %e %H:%M:%S %Y'), + D: to_luastring('%m/%d/%y'), + F: to_luastring('%Y-%m-%d'), + R: to_luastring('%H:%M'), + r: to_luastring('%I:%M:%S %p'), + T: to_luastring('%H:%M:%S'), + X: to_luastring('%T'), + x: to_luastring('%D') } }; @@ -189,12 +189,12 @@ const strftime = function(L, b, s, date) { // '00' case 85 /* U */: - push_pad_2(b, week_number(date, "sunday"), 48 /* 0 */); + push_pad_2(b, week_number(date, 'sunday'), 48 /* 0 */); break; // '00' case 87 /* W */: - push_pad_2(b, week_number(date, "monday"), 48 /* 0 */); + push_pad_2(b, week_number(date, 'monday'), 48 /* 0 */); break; // '16:00:00' @@ -347,7 +347,7 @@ const checkoption = function(L, conv, i) { } } luaL_argerror(L, 1, - lua_pushfstring(L, to_luastring("invalid conversion specifier '%%%s'"), conv)); + lua_pushfstring(L, to_luastring('invalid conversion specifier \'%%%s\''), conv)); }; /* maximum size for an individual 'strftime' item */ @@ -355,7 +355,7 @@ const checkoption = function(L, conv, i) { const os_date = function(L) { - let s = luaL_optlstring(L, 1, "%c"); + let s = luaL_optlstring(L, 1, '%c'); let stm = lua_isnoneornil(L, 2) ? new Date() : new Date(l_checktime(L, 2) * 1000); let utc = false; let i = 0; @@ -363,12 +363,12 @@ const os_date = function(L) { utc = true; i++; /* skip '!' */ } - if (s[i] === "*".charCodeAt(0) && s[i+1] === "t".charCodeAt(0)) { + if (s[i] === '*'.charCodeAt(0) && s[i+1] === 't'.charCodeAt(0)) { lua_createtable(L, 0, 9); /* 9 = number of fields */ setallfields(L, stm, utc); } else { let cc = new Uint8Array(4); - cc[0] = "%".charCodeAt(0); + cc[0] = '%'.charCodeAt(0); let b = new luaL_Buffer(); luaL_buffinit(L, b); strftime(L, b, s, stm); @@ -385,12 +385,12 @@ const os_time = function(L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ t = new Date( - getfield(L, "year", -1, 0), - getfield(L, "month", -1, 1), - getfield(L, "day", -1, 0), - getfield(L, "hour", 12, 0), - getfield(L, "min", 0, 0), - getfield(L, "sec", 0, 0) + getfield(L, 'year', -1, 0), + getfield(L, 'month', -1, 1), + getfield(L, 'day', -1, 0), + getfield(L, 'hour', 12, 0), + getfield(L, 'min', 0, 0), + getfield(L, 'sec', 0, 0) ); setallfields(L, t); } @@ -412,12 +412,12 @@ const os_difftime = function(L) { return 1; }; -const catnames = ["all", "collate", "ctype", "monetary", "numeric", "time"].map((lc) => to_luastring(lc)); -const C = to_luastring("C"); -const POSIX = to_luastring("POSIX"); +const catnames = ['all', 'collate', 'ctype', 'monetary', 'numeric', 'time'].map((lc) => to_luastring(lc)); +const C = to_luastring('C'); +const POSIX = to_luastring('POSIX'); const os_setlocale = function(L) { const l = luaL_optstring(L, 1, null); - luaL_checkoption(L, 2, "all", catnames); + luaL_checkoption(L, 2, 'all', catnames); /* It is not possible to set the JS-VM wide locale, so we say that we only know the C locale. The "POSIX" locale is defined in IEEE Std 1003.1-2017 Section 7.2 as equivalent to "C" */ @@ -431,13 +431,13 @@ const os_setlocale = function(L) { }; const syslib = { - "date": os_date, - "difftime": os_difftime, - "setlocale": os_setlocale, - "time": os_time + 'date': os_date, + 'difftime': os_difftime, + 'setlocale': os_setlocale, + 'time': os_time }; -if (typeof process === "undefined") { +if (typeof process === 'undefined') { syslib.clock = function(L) { lua_pushnumber(L, performance.now()/1000); return 1; @@ -509,7 +509,7 @@ if (typeof process === "undefined") { syslib.tmpname = function(L) { let name = lua_tmpname(); if (!name) - return luaL_error(L, to_luastring("unable to generate a unique filename")); + return luaL_error(L, to_luastring('unable to generate a unique filename')); lua_pushstring(L, to_luastring(name)); return 1; }; diff --git a/src/lparser.js b/src/lparser.js index 151ff58a..18e23028 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -206,16 +206,16 @@ const semerror = function (ls, msg) { }; const error_expected = function (ls, token) { - luaX_syntaxerror(ls, luaO_pushfstring(ls.L, to_luastring("%s expected", true), luaX_token2str(ls, token))); + luaX_syntaxerror(ls, luaO_pushfstring(ls.L, to_luastring('%s expected', true), luaX_token2str(ls, token))); }; const errorlimit = function (fs, limit, what) { let L = fs.ls.L; let line = fs.f.linedefined; let where = (line === 0) - ? to_luastring("main function", true) - : luaO_pushfstring(L, to_luastring("function at line %d", true), line); - let msg = luaO_pushfstring(L, to_luastring("too many %s (limit is %d) in %s", true), + ? to_luastring('main function', true) + : luaO_pushfstring(L, to_luastring('function at line %d', true), line); + let msg = luaO_pushfstring(L, to_luastring('too many %s (limit is %d) in %s', true), what, limit, where); luaX_syntaxerror(fs.ls, msg); }; @@ -254,7 +254,7 @@ const check_match = function (ls, what, who, where) { error_expected(ls, what); else luaX_syntaxerror(ls, luaO_pushfstring(ls.L, - to_luastring("%s expected (to close %s at line %d)"), + to_luastring('%s expected (to close %s at line %d)'), luaX_token2str(ls, what), luaX_token2str(ls, who), where)); } }; @@ -292,7 +292,7 @@ const new_localvar = function (ls, name) { let fs = ls.fs; let dyd = ls.dyd; let reg = registerlocalvar(ls, name); - checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring("local variables", true)); + checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring('local variables', true)); dyd.actvar.arr[dyd.actvar.n] = new Vardesc(); dyd.actvar.arr[dyd.actvar.n].idx = reg; dyd.actvar.n++; @@ -332,7 +332,7 @@ const searchupvalue = function (fs, name) { const newupvalue = function (fs, name, v) { let f = fs.f; - checklimit(fs, fs.nups + 1, MAXUPVAL, to_luastring("upvalues", true)); + checklimit(fs, fs.nups + 1, MAXUPVAL, to_luastring('upvalues', true)); f.upvalues[fs.nups] = { instack: v.k === expkind.VLOCAL, idx: v.u.info, @@ -424,7 +424,7 @@ const adjust_assign = function (ls, nvars, nexps, e) { const enterlevel = function (ls) { let L = ls.L; ++L.nCcalls; - checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true)); + checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); }; const leavelevel = function (ls) { @@ -439,7 +439,7 @@ const closegoto = function (ls, g, label) { if (gt.nactvar < label.nactvar) { let vname = getlocvar(fs, gt.nactvar).varname; let msg = luaO_pushfstring(ls.L, - to_luastring(" at line %d jumps into the scope of local '%s'"), + to_luastring(' at line %d jumps into the scope of local \'%s\''), gt.name.getstr(), gt.line, vname.getstr()); semerror(ls, msg); } @@ -534,7 +534,7 @@ const enterblock = function (fs, bl, isloop) { ** create a label named 'break' to resolve break statements */ const breaklabel = function (ls) { - let n = luaS_newliteral(ls.L, "break"); + let n = luaS_newliteral(ls.L, 'break'); let l = newlabelentry(ls, ls.dyd.label, n, 0, ls.fs.pc); findgotos(ls, ls.dyd.label.arr[l]); }; @@ -545,8 +545,8 @@ const breaklabel = function (ls) { */ const undefgoto = function (ls, gt) { let msg = isreserved(gt.name) - ? "<%s> at line %d not inside a loop" - : "no visible label '%s' for at line %d"; + ? '<%s> at line %d not inside a loop' + : 'no visible label \'%s\' for at line %d'; msg = luaO_pushfstring(ls.L, to_luastring(msg), gt.name.getstr(), gt.line); semerror(ls, msg); }; @@ -692,7 +692,7 @@ const recfield = function (ls, cc) { let val = new expdesc(); if (ls.t.token === R.TK_NAME) { - checklimit(fs, cc.nh, MAX_INT, to_luastring("items in a constructor", true)); + checklimit(fs, cc.nh, MAX_INT, to_luastring('items in a constructor', true)); checkname(ls, key); } else /* ls->t.token === '[' */ yindex(ls, key); @@ -730,7 +730,7 @@ const lastlistfield = function (fs, cc) { const listfield = function (ls, cc) { /* listfield -> exp */ expr(ls, cc.v); - checklimit(ls.fs, cc.na, MAX_INT, to_luastring("items in a constructor", true)); + checklimit(ls.fs, cc.na, MAX_INT, to_luastring('items in a constructor', true)); cc.na++; cc.tostore++; }; @@ -802,7 +802,7 @@ const parlist = function (ls) { f.is_vararg = true; /* declared vararg */ break; } - default: luaX_syntaxerror(ls, to_luastring(" or '...' expected", true)); + default: luaX_syntaxerror(ls, to_luastring(' or \'...\' expected', true)); } } while (!f.is_vararg && testnext(ls, 44 /* (',').charCodeAt(0) */)); } @@ -820,7 +820,7 @@ const body = function (ls, e, ismethod, line) { open_func(ls, new_fs, bl); checknext(ls, 40 /* ('(').charCodeAt(0) */); if (ismethod) { - new_localvarliteral(ls, "self"); /* create 'self' parameter */ + new_localvarliteral(ls, 'self'); /* create 'self' parameter */ adjustlocalvars(ls, 1); } parlist(ls); @@ -869,7 +869,7 @@ const funcargs = function (ls, f, line) { break; } default: { - luaX_syntaxerror(ls, to_luastring("function arguments expected", true)); + luaX_syntaxerror(ls, to_luastring('function arguments expected', true)); } } lua_assert(f.k === expkind.VNONRELOC); @@ -909,7 +909,7 @@ const primaryexp = function (ls, v) { return; } default: { - luaX_syntaxerror(ls, to_luastring("unexpected symbol", true)); + luaX_syntaxerror(ls, to_luastring('unexpected symbol', true)); } } }; @@ -983,7 +983,7 @@ const simpleexp = function (ls, v) { } case R.TK_DOTS: { /* vararg */ let fs = ls.fs; - check_condition(ls, fs.f.is_vararg, to_luastring("cannot use '...' outside a vararg function", true)); + check_condition(ls, fs.f.is_vararg, to_luastring('cannot use \'...\' outside a vararg function', true)); init_exp(v, expkind.VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } @@ -1155,14 +1155,14 @@ const check_conflict = function (ls, lh, v) { const assignment = function (ls, lh, nvars) { let e = new expdesc(); - check_condition(ls, vkisvar(lh.v.k), to_luastring("syntax error", true)); + check_condition(ls, vkisvar(lh.v.k), to_luastring('syntax error', true)); if (testnext(ls, 44 /* (',').charCodeAt(0) */)) { /* assignment -> ',' suffixedexp assignment */ let nv = new LHS_assign(); nv.prev = lh; suffixedexp(ls, nv.v); if (nv.v.k !== expkind.VINDEXED) check_conflict(ls, lh, nv.v); - checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true)); + checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); assignment(ls, nv, nvars + 1); } else { /* assignment -> '=' explist */ checknext(ls, 61 /* ('=').charCodeAt(0) */); @@ -1195,7 +1195,7 @@ const gotostat = function (ls, pc) { label = str_checkname(ls); else { luaX_next(ls); /* skip break */ - label = luaS_newliteral(ls.L, "break"); + label = luaS_newliteral(ls.L, 'break'); } let g = newlabelentry(ls, ls.dyd.gt, label, line, pc); findlabel(ls, g); /* close it if label already defined */ @@ -1206,7 +1206,7 @@ const checkrepeated = function (fs, ll, label) { for (let i = fs.bl.firstlabel; i < ll.n; i++) { if (eqstr(label, ll.arr[i].name)) { let msg = luaO_pushfstring(fs.ls.L, - to_luastring("label '%s' already defined on line %d", true), + to_luastring('label \'%s\' already defined on line %d', true), label.getstr(), ll.arr[i].line); semerror(fs.ls, msg); } @@ -1309,9 +1309,9 @@ const fornum = function (ls, varname, line) { /* fornum -> NAME = exp1,exp1[,exp1] forbody */ let fs = ls.fs; let base = fs.freereg; - new_localvarliteral(ls, "(for index)"); - new_localvarliteral(ls, "(for limit)"); - new_localvarliteral(ls, "(for step)"); + new_localvarliteral(ls, '(for index)'); + new_localvarliteral(ls, '(for limit)'); + new_localvarliteral(ls, '(for step)'); new_localvar(ls, varname); checknext(ls, 61 /* ('=').charCodeAt(0) */); exp1(ls); /* initial value */ @@ -1333,9 +1333,9 @@ const forlist = function (ls, indexname) { let nvars = 4; /* gen, state, control, plus at least one declared var */ let base = fs.freereg; /* create control variables */ - new_localvarliteral(ls, "(for generator)"); - new_localvarliteral(ls, "(for state)"); - new_localvarliteral(ls, "(for control)"); + new_localvarliteral(ls, '(for generator)'); + new_localvarliteral(ls, '(for state)'); + new_localvarliteral(ls, '(for control)'); /* create declared variables */ new_localvar(ls, indexname); while (testnext(ls, 44 /* (',').charCodeAt(0) */)) { @@ -1359,7 +1359,7 @@ const forstat = function (ls, line) { switch (ls.t.token) { case 61 /* ('=').charCodeAt(0) */: fornum(ls, varname, line); break; case 44 /* (',').charCodeAt(0) */: case R.TK_IN: forlist(ls, varname); break; - default: luaX_syntaxerror(ls, to_luastring("'=' or 'in' expected", true)); + default: luaX_syntaxerror(ls, to_luastring('\'=\' or \'in\' expected', true)); } check_match(ls, R.TK_END, R.TK_FOR, line); leaveblock(fs); /* loop scope ('break' jumps to this point) */ @@ -1477,7 +1477,7 @@ const exprstat = function (ls) { assignment(ls, v, 1); } else { /* stat -> func */ - check_condition(ls, v.v.k === expkind.VCALL, to_luastring("syntax error", true)); + check_condition(ls, v.v.k === expkind.VCALL, to_luastring('syntax error', true)); SETARG_C(getinstruction(fs, v.v), 1); /* call statement uses no results */ } }; diff --git a/src/lstring.js b/src/lstring.js index 5f1bcae6..0417dde7 100644 --- a/src/lstring.js +++ b/src/lstring.js @@ -1,5 +1,5 @@ import { is_luastring, luastring_eq, luastring_from, to_luastring } from './defs.js'; -import { lua_assert } from "./llimits.js"; +import { lua_assert } from './llimits.js'; class TString { @@ -29,7 +29,7 @@ const luaS_eqlngstr = function (a, b) { const luaS_hash = function (str) { lua_assert(is_luastring(str)); let len = str.length; - let s = "|"; + let s = '|'; for (let i = 0; i < len; i++) s += str[i].toString(16); return s; diff --git a/src/lstrlib.js b/src/lstrlib.js index 212ffe07..91e1e232 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -4,7 +4,7 @@ import { LUA_INTEGER_FMT, LUA_INTEGER_FRMLEN, LUA_MININTEGER, LUA_NUMBER_FMT, LU import { LUA_TBOOLEAN, LUA_TFUNCTION, LUA_TNIL, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, lua_call, lua_createtable, lua_dump, lua_gettable, lua_gettop, lua_isinteger, lua_isstring, lua_pop, lua_pushcclosure, lua_pushinteger, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushvalue, lua_remove, lua_setfield, lua_setmetatable, lua_settop, lua_toboolean, lua_tointeger, lua_tonumber, lua_tostring, lua_touserdata, lua_type, lua_upvalueindex } from './lua.js'; import { luaL_Buffer, luaL_addchar, luaL_addlstring, luaL_addsize, luaL_addstring, luaL_addvalue, luaL_argcheck, luaL_argerror, luaL_buffinit, luaL_buffinitsize, luaL_checkinteger, luaL_checknumber, luaL_checkstack, luaL_checkstring, luaL_checktype, luaL_error, luaL_newlib, luaL_optinteger, luaL_optstring, luaL_prepbuffsize, luaL_pushresult, luaL_pushresultsize, luaL_tolstring, luaL_typename } from './lauxlib.js'; import { lua_assert } from './lualib.js'; -import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from "./fengaricore.js"; +import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from './fengaricore.js'; const sL_ESC = '%'; const L_ESC = sL_ESC.charCodeAt(0); @@ -41,7 +41,7 @@ const str_sub = function (L) { if (end > l) end = l; if (start <= end) lua_pushstring(L, s.subarray(start - 1, (start - 1) + (end - start + 1))); - else lua_pushliteral(L, ""); + else lua_pushliteral(L, ''); return 1; }; @@ -56,7 +56,7 @@ const str_char = function (L) { let p = luaL_buffinitsize(L, b, n); for (let i = 1; i <= n; i++) { let c = luaL_checkinteger(L, i); - luaL_argcheck(L, c >= 0 && c <= 255, "value out of range"); // Strings are 8-bit clean + luaL_argcheck(L, c >= 0 && c <= 255, 'value out of range'); // Strings are 8-bit clean p[i - 1] = c; } luaL_pushresultsize(b, n); @@ -75,7 +75,7 @@ const str_dump = function (L) { lua_settop(L, 1); luaL_buffinit(L, b); if (lua_dump(L, writer, b, strip) !== 0) - return luaL_error(L, to_luastring("unable to dump given function")); + return luaL_error(L, to_luastring('unable to dump given function')); luaL_pushresult(b); return 1; }; @@ -94,12 +94,12 @@ const num2straux = function (x) { return to_luastring('nan'); else if (x === 0) { /* can be -0... */ /* create "0" or "-0" followed by exponent */ - let zero = sprintf(LUA_NUMBER_FMT + "x0p+0", x); + let zero = sprintf(LUA_NUMBER_FMT + 'x0p+0', x); if (Object.is(x, -0)) - zero = "-" + zero; + zero = '-' + zero; return to_luastring(zero); } else { - let buff = ""; + let buff = ''; let fe = frexp(x); /* 'x' fraction and exponent */ let m = fe[0]; let e = fe[1]; @@ -107,10 +107,10 @@ const num2straux = function (x) { buff += '-'; /* add signal */ m = -m; /* make it positive */ } - buff += "0x"; /* add "0x" */ + buff += '0x'; /* add "0x" */ buff += (m * (1 << L_NBFD)).toString(16); e -= L_NBFD; /* this digit goes before the radix point */ - buff += sprintf("p%+d", e); /* add exponent */ + buff += sprintf('p%+d', e); /* add exponent */ return to_luastring(buff); } }; @@ -124,7 +124,7 @@ const lua_number2strx = function (L, fmt, x) { buff[i] = c & 0xdf; } } else if (fmt[SIZELENMOD] !== 97 /* 'a'.charCodeAt(0) */) - luaL_error(L, to_luastring("modifiers for format '%%a'/'%%A' not implemented")); + luaL_error(L, to_luastring('modifiers for format \'%%a\'/\'%%A\' not implemented')); return buff; }; @@ -139,7 +139,7 @@ const lua_number2strx = function (L, fmt, x) { /* valid flags in a format specification */ -const FLAGS = to_luastring("-+ #0"); +const FLAGS = to_luastring('-+ #0'); /* ** maximum size of each format specification (such as "%-099.99d") @@ -167,10 +167,10 @@ const addquoted = function (b, s, len) { luaL_addchar(b, 92 /* '\\'.charCodeAt(0) */); luaL_addchar(b, s[i]); } else if (iscntrl(s[i])) { - let buff = "" + s[i]; /* stringify */ + let buff = '' + s[i]; /* stringify */ if (isdigit(s[i + 1])) - buff = ("000" + buff).slice(-3); /* pad to 3 digits with leading '0's */ - luaL_addstring(b, to_luastring("\\" + buff)); + buff = ('000' + buff).slice(-3); /* pad to 3 digits with leading '0's */ + luaL_addstring(b, to_luastring('\\' + buff)); } else luaL_addchar(b, s[i]); i++; @@ -205,7 +205,7 @@ const addliteral = function (L, b, arg) { } else { /* integers */ let n = lua_tointeger(L, arg); let format = (n === LUA_MININTEGER) /* corner case? */ - ? "0x%" + LUA_INTEGER_FRMLEN + "x" /* use hexa */ + ? '0x%' + LUA_INTEGER_FRMLEN + 'x' /* use hexa */ : LUA_INTEGER_FMT; /* else use default format */ buff = to_luastring(sprintf(format, n)); } @@ -218,7 +218,7 @@ const addliteral = function (L, b, arg) { break; } default: { - luaL_argerror(L, arg, to_luastring("value has no literal form")); + luaL_argerror(L, arg, to_luastring('value has no literal form')); } } }; @@ -227,7 +227,7 @@ const scanformat = function (L, strfrmt, i, form) { let p = i; while (strfrmt[p] !== 0 && luastring_indexOf(FLAGS, strfrmt[p]) >= 0) p++; /* skip flags */ if (p - i >= FLAGS.length) - luaL_error(L, to_luastring("invalid format (repeated flags)")); + luaL_error(L, to_luastring('invalid format (repeated flags)')); if (isdigit(strfrmt[p])) p++; /* skip width */ if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ if (strfrmt[p] === 46 /* '.'.charCodeAt(0) */) { @@ -236,7 +236,7 @@ const scanformat = function (L, strfrmt, i, form) { if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ } if (isdigit(strfrmt[p])) - luaL_error(L, to_luastring("invalid format (width or precision too long)")); + luaL_error(L, to_luastring('invalid format (width or precision too long)')); form[0] = 37 /* "%".charCodeAt(0) */; for (let j = 0; j < p - i + 1; j++) form[j + 1] = strfrmt[i + j]; @@ -271,7 +271,7 @@ const str_format = function (L) { } else { /* format item */ let form = []; /* to store the format ('%...') */ if (++arg > top) - luaL_argerror(L, arg, to_luastring("no value")); + luaL_argerror(L, arg, to_luastring('no value')); i = scanformat(L, strfrmt, i, form); switch (String.fromCharCode(strfrmt[i++])) { case 'c': { @@ -307,7 +307,7 @@ const str_format = function (L) { if (form.length <= 2 || form[2] === 0) { /* no modifiers? */ luaL_addvalue(b); /* keep entire string */ } else { - luaL_argcheck(L, s.length === strlen(s), arg, "string contains zeros"); + luaL_argcheck(L, s.length === strlen(s), arg, 'string contains zeros'); if (luastring_indexOf(form, 46 /* '.'.charCodeAt(0) */) < 0 && s.length >= 100) { /* no precision and string is too long to be formatted */ luaL_addvalue(b); /* keep entire string */ @@ -320,7 +320,7 @@ const str_format = function (L) { break; } default: { /* also treat cases 'pnLlh' */ - return luaL_error(L, to_luastring("invalid option '%%%c' to 'format'"), strfrmt[i - 1]); + return luaL_error(L, to_luastring('invalid option \'%%%c\' to \'format\''), strfrmt[i - 1]); } } } @@ -390,7 +390,7 @@ const getnum = function (fmt, df) { const getnumlimit = function (h, fmt, df) { let sz = getnum(fmt, df); if (sz > MAXINTSIZE || sz <= 0) - luaL_error(h.L, to_luastring("integral size (%d) out of limits [1,%d]"), sz, MAXINTSIZE); + luaL_error(h.L, to_luastring('integral size (%d) out of limits [1,%d]'), sz, MAXINTSIZE); return sz; }; @@ -421,7 +421,7 @@ const getoption = function (h, fmt) { case 99 /*'c'*/: { r.size = getnum(fmt, -1); if (r.size === -1) - luaL_error(h.L, to_luastring("missing size for format option 'c'")); + luaL_error(h.L, to_luastring('missing size for format option \'c\'')); r.opt = Kchar; return r; } @@ -433,7 +433,7 @@ const getoption = function (h, fmt) { case 62 /*'>'*/: h.islittle = false; break; case 61 /*'='*/: h.islittle = true; break; case 33 /*'!'*/: h.maxalign = getnumlimit(h, fmt, MAXALIGN); break; - default: luaL_error(h.L, to_luastring("invalid format option '%c'"), r.opt); + default: luaL_error(h.L, to_luastring('invalid format option \'%c\''), r.opt); } r.opt = Knop; return r; @@ -461,13 +461,13 @@ const getdetails = function (h, totalsize, fmt) { let align = r.size; /* usually, alignment follows size */ if (r.opt === Kpaddalign) { /* 'X' gets alignment from following option */ if (fmt.off >= fmt.s.length || fmt.s[fmt.off] === 0) - luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'")); + luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); else { let o = getoption(h, fmt); align = o.size; o = o.opt; if (o === Kchar || align === 0) - luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'")); + luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); } } if (align <= 1 || r.opt === Kchar) /* need no alignment? */ @@ -476,7 +476,7 @@ const getdetails = function (h, totalsize, fmt) { if (align > h.maxalign) /* enforce maximum alignment */ align = h.maxalign; if ((align & (align - 1)) !== 0) /* is 'align' not a power of 2? */ - luaL_argerror(h.L, 1, to_luastring("format asks for alignment not power of 2")); + luaL_argerror(h.L, 1, to_luastring('format asks for alignment not power of 2')); r.ntoalign = (align - (totalsize & (align - 1))) & (align - 1); } return r; @@ -527,7 +527,7 @@ const str_pack = function (L) { let n = luaL_checkinteger(L, arg); if (size < SZINT) { /* need overflow check? */ let lim = 1 << (size * 8) - 1; - luaL_argcheck(L, -lim <= n && n < lim, arg, "integer overflow"); + luaL_argcheck(L, -lim <= n && n < lim, arg, 'integer overflow'); } packint(b, n, h.islittle, size, n < 0); break; @@ -535,7 +535,7 @@ const str_pack = function (L) { case Kuint: { /* unsigned integers */ let n = luaL_checkinteger(L, arg); if (size < SZINT) - luaL_argcheck(L, (n >>> 0) < (1 << (size * NB)), arg, "unsigned overflow"); + luaL_argcheck(L, (n >>> 0) < (1 << (size * NB)), arg, 'unsigned overflow'); packint(b, n >>> 0, h.islittle, size, false); break; } @@ -551,7 +551,7 @@ const str_pack = function (L) { case Kchar: { /* fixed-size string */ let s = luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, len <= size, arg, "string longer than given size"); + luaL_argcheck(L, len <= size, arg, 'string longer than given size'); luaL_addlstring(b, s, len); /* add string */ while (len++ < size) /* pad extra space */ luaL_addchar(b, LUAL_PACKPADBYTE); @@ -562,7 +562,7 @@ const str_pack = function (L) { let len = s.length; luaL_argcheck(L, size >= 4 /* sizeof(size_t) */ || len < (1 << (size * NB)), - arg, "string length does not fit in given size"); + arg, 'string length does not fit in given size'); packint(b, len, h.islittle, size, 0); /* pack length */ luaL_addlstring(b, s, len); totalsize += len; @@ -571,7 +571,7 @@ const str_pack = function (L) { case Kzstr: { /* zero-terminated string */ let s = luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, "strings contains zeros"); + luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, 'strings contains zeros'); luaL_addlstring(b, s, len); luaL_addchar(b, 0); /* add zero at the end */ totalsize += len + 1; @@ -629,11 +629,11 @@ const str_rep = function (L) { let s = luaL_checkstring(L, 1); let l = s.length; let n = luaL_checkinteger(L, 2); - let sep = luaL_optstring(L, 3, ""); + let sep = luaL_optstring(L, 3, ''); let lsep = sep.length; - if (n <= 0) lua_pushliteral(L, ""); + if (n <= 0) lua_pushliteral(L, ''); else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */ - return luaL_error(L, to_luastring("resulting string too large")); + return luaL_error(L, to_luastring('resulting string too large')); else { let totallen = n * l + (n - 1) * lsep; let b = new luaL_Buffer(); @@ -663,10 +663,10 @@ const str_byte = function (L) { if (pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) /* arithmetic overflow? */ - return luaL_error(L, "string slice too long"); + return luaL_error(L, 'string slice too long'); let n = (pose - posi) + 1; - luaL_checkstack(L, n, "string slice too long"); + luaL_checkstack(L, n, 'string slice too long'); for (let i = 0; i < n; i++) lua_pushinteger(L, s[posi + i - 1]); return n; @@ -685,12 +685,12 @@ const str_packsize = function (L) { let size = details.size; let ntoalign = details.ntoalign; size += ntoalign; /* total space used by option */ - luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, "format result too large"); + luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, 'format result too large'); totalsize += size; switch (opt) { case Kstring: /* strings with length count */ case Kzstr: /* zero-terminated string */ - luaL_argerror(L, 1, "variable-length format"); + luaL_argerror(L, 1, 'variable-length format'); /* call never return, but to avoid warnings: *//* fall through */ default: break; } @@ -723,7 +723,7 @@ const unpackint = function (L, str, islittle, size, issigned) { let mask = !issigned || res >= 0 ? 0 : MC; for (let i = limit; i < size; i++) { if (str[islittle ? i : size - 1 - i] !== mask) - luaL_error(L, to_luastring("%d-byte integer does not fit into Lua Integer"), size); + luaL_error(L, to_luastring('%d-byte integer does not fit into Lua Integer'), size); } } return res; @@ -750,17 +750,17 @@ const str_unpack = function (L) { let ld = data.length; let pos = posrelat(luaL_optinteger(L, 3, 1), ld) - 1; let n = 0; /* number of results */ - luaL_argcheck(L, pos <= ld && pos >= 0, 3, "initial position out of string"); + luaL_argcheck(L, pos <= ld && pos >= 0, 3, 'initial position out of string'); while (fmt.off < fmt.s.length) { let details = getdetails(h, pos, fmt); let opt = details.opt; let size = details.size; let ntoalign = details.ntoalign; if (/*ntoalign + size > ~pos ||*/ pos + ntoalign + size > ld) - luaL_argerror(L, 2, to_luastring("data string too short")); + luaL_argerror(L, 2, to_luastring('data string too short')); pos += ntoalign; /* skip alignment */ /* stack space for item + next position */ - luaL_checkstack(L, 2, "too many results"); + luaL_checkstack(L, 2, 'too many results'); n++; switch (opt) { case Kint: @@ -780,7 +780,7 @@ const str_unpack = function (L) { } case Kstring: { let len = unpackint(L, data.subarray(pos), h.islittle, size, 0); - luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short"); + luaL_argcheck(L, pos + len + size <= ld, 2, 'data string too short'); lua_pushstring(L, data.subarray(pos + size, pos + size + len)); pos += len; /* skip string */ break; @@ -805,7 +805,7 @@ const str_unpack = function (L) { const CAP_UNFINISHED = -1; const CAP_POSITION = -2; const MAXCCALLS = 200; -const SPECIALS = to_luastring("^$*+?.([%-"); +const SPECIALS = to_luastring('^$*+?.([%-'); class MatchState { constructor(L) { @@ -824,7 +824,7 @@ class MatchState { const check_capture = function (ms, l) { l = l - 49 /* '1'.charCodeAt(0) */; if (l < 0 || l >= ms.level || ms.capture[l].len === CAP_UNFINISHED) - return luaL_error(ms.L, to_luastring("invalid capture index %%%d"), l + 1); + return luaL_error(ms.L, to_luastring('invalid capture index %%%d'), l + 1); return l; }; @@ -832,21 +832,21 @@ const capture_to_close = function (ms) { let level = ms.level; for (level--; level >= 0; level--) if (ms.capture[level].len === CAP_UNFINISHED) return level; - return luaL_error(ms.L, to_luastring("invalid pattern capture")); + return luaL_error(ms.L, to_luastring('invalid pattern capture')); }; const classend = function (ms, p) { switch (ms.p[p++]) { case L_ESC: { if (p === ms.p_end) - luaL_error(ms.L, to_luastring("malformed pattern (ends with '%%')")); + luaL_error(ms.L, to_luastring('malformed pattern (ends with \'%%\')')); return p + 1; } case 91 /* '['.charCodeAt(0) */: { if (ms.p[p] === 94 /* '^'.charCodeAt(0) */) p++; do { /* look for a ']' */ if (p === ms.p_end) - luaL_error(ms.L, to_luastring("malformed pattern (missing ']')")); + luaL_error(ms.L, to_luastring('malformed pattern (missing \']\')')); if (ms.p[p++] === L_ESC && p < ms.p_end) p++; /* skip escapes (e.g. '%]') */ } while (ms.p[p] !== 93 /* ']'.charCodeAt(0) */); @@ -922,7 +922,7 @@ const singlematch = function (ms, s, p, ep) { const matchbalance = function (ms, s, p) { if (p >= ms.p_end - 1) - luaL_error(ms.L, to_luastring("malformed pattern (missing arguments to '%%b'")); + luaL_error(ms.L, to_luastring('malformed pattern (missing arguments to \'%%b\'')); if (ms.src[s] !== ms.p[p]) return null; else { @@ -965,7 +965,7 @@ const min_expand = function (ms, s, p, ep) { const start_capture = function (ms, s, p, what) { let level = ms.level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring("too many captures")); + if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring('too many captures')); ms.capture[level] = ms.capture[level] ? ms.capture[level] : {}; ms.capture[level].init = s; ms.capture[level].len = what; @@ -1003,7 +1003,7 @@ const match = function (ms, s, p) { let gotoinit = true; if (ms.matchdepth-- === 0) - luaL_error(ms.L, to_luastring("pattern too complex")); + luaL_error(ms.L, to_luastring('pattern too complex')); while (gotoinit || gotodefault) { gotoinit = false; @@ -1041,7 +1041,7 @@ const match = function (ms, s, p) { case 102 /* 'f'.charCodeAt(0) */: { /* frontier? */ p += 2; if (ms.p[p] !== 91 /* '['.charCodeAt(0) */) - luaL_error(ms.L, to_luastring("missing '[' after '%%f' in pattern")); + luaL_error(ms.L, to_luastring('missing \'[\' after \'%%f\' in pattern')); let ep = classend(ms, p); /* points to what is next */ let previous = s === ms.src_init ? 0 : ms.src[s - 1]; if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, (s === ms.src_end) ? 0 : ms.src[s], p, ep - 1)) { @@ -1112,10 +1112,10 @@ const push_onecapture = function (ms, i, s, e) { if (i === 0) lua_pushlstring(ms.L, ms.src.subarray(s, e), e - s); /* add whole match */ else - luaL_error(ms.L, to_luastring("invalid capture index %%%d"), i + 1); + luaL_error(ms.L, to_luastring('invalid capture index %%%d'), i + 1); } else { let l = ms.capture[i].len; - if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring("unfinished capture")); + if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring('unfinished capture')); if (l === CAP_POSITION) lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1); else @@ -1125,7 +1125,7 @@ const push_onecapture = function (ms, i, s, e) { const push_captures = function (ms, s, e) { let nlevels = (ms.level === 0 && s != null) ? 1 : ms.level; - luaL_checkstack(ms.L, nlevels, "too many captures"); + luaL_checkstack(ms.L, nlevels, 'too many captures'); for (let i = 0; i < nlevels; i++) push_onecapture(ms, i, s, e); return nlevels; /* number of strings pushed */ @@ -1273,7 +1273,7 @@ const add_s = function (ms, b, s, e) { i++; /* skip ESC */ if (!isdigit(news[i])) { if (news[i] !== L_ESC) - luaL_error(L, to_luastring("invalid use of '%c' in replacement string"), L_ESC); + luaL_error(L, to_luastring('invalid use of \'%c\' in replacement string'), L_ESC); luaL_addchar(b, news[i]); } else if (news[i] === 48 /* '0'.charCodeAt(0) */) luaL_addlstring(b, ms.src.subarray(s, e), e - s); @@ -1310,7 +1310,7 @@ const add_value = function (ms, b, s, e, tr) { lua_pop(L, 1); lua_pushlstring(L, ms.src.subarray(s, e), e - s); /* keep original text */ } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("invalid replacement value (a %s)"), luaL_typename(L, -1)); + luaL_error(L, to_luastring('invalid replacement value (a %s)'), luaL_typename(L, -1)); luaL_addvalue(b); /* add result to accumulator */ }; @@ -1327,7 +1327,7 @@ const str_gsub = function (L) { let ms = new MatchState(L); let b = new luaL_Buffer(); luaL_argcheck(L, tr === LUA_TNUMBER || tr === LUA_TSTRING || tr === LUA_TFUNCTION || tr === LUA_TTABLE, 3, - "string/function/table expected"); + 'string/function/table expected'); luaL_buffinit(L, b); if (anchor) { p = p.subarray(1); lp--; /* skip anchor character */ @@ -1353,33 +1353,33 @@ const str_gsub = function (L) { }; const strlib = { - "byte": str_byte, - "char": str_char, - "dump": str_dump, - "find": str_find, - "format": str_format, - "gmatch": str_gmatch, - "gsub": str_gsub, - "len": str_len, - "lower": str_lower, - "match": str_match, - "pack": str_pack, - "packsize": str_packsize, - "rep": str_rep, - "reverse": str_reverse, - "sub": str_sub, - "unpack": str_unpack, - "upper": str_upper + 'byte': str_byte, + 'char': str_char, + 'dump': str_dump, + 'find': str_find, + 'format': str_format, + 'gmatch': str_gmatch, + 'gsub': str_gsub, + 'len': str_len, + 'lower': str_lower, + 'match': str_match, + 'pack': str_pack, + 'packsize': str_packsize, + 'rep': str_rep, + 'reverse': str_reverse, + 'sub': str_sub, + 'unpack': str_unpack, + 'upper': str_upper }; const createmetatable = function (L) { lua_createtable(L, 0, 1); /* table to be metatable for strings */ - lua_pushliteral(L, ""); /* dummy string */ + lua_pushliteral(L, ''); /* dummy string */ lua_pushvalue(L, -2); /* copy table */ lua_setmetatable(L, -2); /* set table as metatable for strings */ lua_pop(L, 1); /* pop dummy string */ lua_pushvalue(L, -2); /* get string library */ - lua_setfield(L, -2, to_luastring("__index", true)); /* metatable.__index = string */ + lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = string */ lua_pop(L, 1); /* pop metatable */ }; diff --git a/src/ltable.js b/src/ltable.js index db558e01..0600fa24 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -38,10 +38,10 @@ const get_lightuserdata_hash = function (v) { const table_hash = function (L, key) { switch (key.type) { case LUA_TNIL: - return luaG_runerror(L, to_luastring("table index is nil", true)); + return luaG_runerror(L, to_luastring('table index is nil', true)); case LUA_TNUMFLT: if (isNaN(key.value)) - return luaG_runerror(L, to_luastring("table index is NaN", true)); + return luaG_runerror(L, to_luastring('table index is NaN', true)); /* fall through */ case LUA_TNUMINT: /* takes advantage of floats and integers being same in JS */ case LUA_TBOOLEAN: @@ -58,22 +58,22 @@ const table_hash = function (L, key) { case LUA_TLIGHTUSERDATA: { let v = key.value; switch (typeof v) { - case "string": + case 'string': /* possible conflict with LUA_TSTRING. prefix this string with "*" so they don't clash */ - return "*" + v; - case "number": + return '*' + v; + case 'number': /* possible conflict with LUA_TNUMBER. turn into string and prefix with "#" to avoid clash with other strings */ - return "#" + v; - case "boolean": + return '#' + v; + case 'boolean': /* possible conflict with LUA_TBOOLEAN. use strings ?true and ?false instead */ - return v ? "?true" : "?false"; - case "function": + return v ? '?true' : '?false'; + case 'function': /* possible conflict with LUA_TLCF. indirect via a weakmap */ return get_lightuserdata_hash(v); - case "object": + case 'object': /* v could be a lua_State, CClosure, LClosure, Table or Userdata from this state as returned by lua_topointer */ if ((v instanceof lua_State && v.l_G === L.l_G) || v instanceof Table || @@ -89,7 +89,7 @@ const table_hash = function (L, key) { } } default: - throw new Error("unknown key type: " + key.type); + throw new Error('unknown key type: ' + key.type); } }; @@ -164,7 +164,7 @@ const getgeneric = function (t, hash) { }; const luaH_getint = function (t, key) { - lua_assert(typeof key == "number" && (key | 0) === key); + lua_assert(typeof key == 'number' && (key | 0) === key); return getgeneric(t, key); }; @@ -181,7 +181,7 @@ const luaH_get = function (L, t, key) { }; const luaH_setint = function (t, key, value) { - lua_assert(typeof key == "number" && (key | 0) === key && value instanceof TValue); + lua_assert(typeof key == 'number' && (key | 0) === key && value instanceof TValue); let hash = key; /* table_hash known result */ if (value.ttisnil()) { mark_dead(t, hash); @@ -272,7 +272,7 @@ const luaH_next = function (L, table, keyI) { entry = (table.dead_weak && table.dead_weak.get(hash)) || table.dead_strong.get(hash); if (!entry) /* item not in table */ - return luaG_runerror(L, to_luastring("invalid key to 'next'")); + return luaG_runerror(L, to_luastring('invalid key to \'next\'')); /* Iterate until either out of keys, or until finding a non-dead key */ do { entry = entry.n; diff --git a/src/ltablib.js b/src/ltablib.js index 22e5381d..eccbc1b9 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -2,7 +2,7 @@ import { LUA_MAXINTEGER } from './luaconf.js'; import { LUA_OPEQ, LUA_OPLT, LUA_TFUNCTION, LUA_TNIL, LUA_TTABLE, lua_call, lua_checkstack, lua_compare, lua_createtable, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnoneornil, lua_isstring, lua_pop, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawget, lua_setfield, lua_seti, lua_settop, lua_toboolean, lua_type } from './lua.js'; import { luaL_Buffer, luaL_addlstring, luaL_addvalue, luaL_argcheck, luaL_buffinit, luaL_checkinteger, luaL_checktype, luaL_error, luaL_len, luaL_newlib, luaL_opt, luaL_optinteger, luaL_optlstring, luaL_pushresult, luaL_typename } from './lauxlib.js'; import { lua_assert } from './lualib.js'; -import { to_luastring } from "./fengaricore.js"; +import { to_luastring } from './fengaricore.js'; /* ** Operations that an object must define to mimic a table @@ -26,9 +26,9 @@ const checktab = function(L, arg, what) { if (lua_type(L, arg) !== LUA_TTABLE) { /* is it not a table? */ let n = 1; if (lua_getmetatable(L, arg) && /* must have metatable */ - (!(what & TAB_R) || checkfield(L, to_luastring("__index", true), ++n)) && - (!(what & TAB_W) || checkfield(L, to_luastring("__newindex", true), ++n)) && - (!(what & TAB_L) || checkfield(L, to_luastring("__len", true), ++n))) { + (!(what & TAB_R) || checkfield(L, to_luastring('__index', true), ++n)) && + (!(what & TAB_W) || checkfield(L, to_luastring('__newindex', true), ++n)) && + (!(what & TAB_L) || checkfield(L, to_luastring('__len', true), ++n))) { lua_pop(L, n); /* pop metatable and tested metamethods */ } else @@ -44,7 +44,7 @@ const aux_getn = function(L, n, w) { const addfield = function(L, b, i) { lua_geti(L, 1, i); if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring("invalid value (%s) at index %d in table for 'concat'"), + luaL_error(L, to_luastring('invalid value (%s) at index %d in table for \'concat\''), luaL_typename(L, -1), i); luaL_addvalue(b); @@ -59,7 +59,7 @@ const tinsert = function(L) { break; case 3: { pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ - luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); + luaL_argcheck(L, 1 <= pos && pos <= e, 2, 'position out of bounds'); for (let i = e; i > pos; i--) { /* move up elements */ lua_geti(L, 1, i - 1); lua_seti(L, 1, i); /* t[i] = t[i - 1] */ @@ -67,7 +67,7 @@ const tinsert = function(L) { break; } default: { - return luaL_error(L, "wrong number of arguments to 'insert'"); + return luaL_error(L, 'wrong number of arguments to \'insert\''); } } @@ -79,7 +79,7 @@ const tremove = function(L) { let size = aux_getn(L, 1, TAB_RW); let pos = luaL_optinteger(L, 2, size); if (pos !== size) /* validate 'pos' if given */ - luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); + luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, 'position out of bounds'); lua_geti(L, 1, pos); /* result = t[pos] */ for (; pos < size; pos++) { lua_geti(L, 1, pos + 1); @@ -104,9 +104,9 @@ const tmove = function(L) { checktab(L, 1, TAB_R); checktab(L, tt, TAB_W); if (e >= f) { /* otherwise, nothing to move */ - luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, "too many elements to move"); + luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, 'too many elements to move'); let n = e - f + 1; /* number of elements to move */ - luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, "destination wrap around"); + luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, 'destination wrap around'); if (t > e || t <= f || (tt !== 1 && lua_compare(L, 1, tt, LUA_OPEQ) !== 1)) { for (let i = 0; i < n; i++) { @@ -127,7 +127,7 @@ const tmove = function(L) { const tconcat = function(L) { let last = aux_getn(L, 1, TAB_R); - let sep = luaL_optlstring(L, 2, ""); + let sep = luaL_optlstring(L, 2, ''); let lsep = sep.length; let i = luaL_optinteger(L, 3, 1); last = luaL_optinteger(L, 4, last); @@ -155,7 +155,7 @@ const pack = function(L) { for (let i = n; i >= 1; i--) /* assign elements */ lua_seti(L, 1, i); lua_pushinteger(L, n); - lua_setfield(L, 1, to_luastring("n")); /* t.n = number of elements */ + lua_setfield(L, 1, to_luastring('n')); /* t.n = number of elements */ return 1; /* return table */ }; @@ -165,7 +165,7 @@ const unpack = function(L) { if (i > e) return 0; /* empty range */ let n = e - i; /* number of elements minus 1 (avoid overflows) */ if (n >= Number.MAX_SAFE_INTEGER || !lua_checkstack(L, ++n)) - return luaL_error(L, to_luastring("too many results to unpack")); + return luaL_error(L, to_luastring('too many results to unpack')); for (; i < e; i++) /* push arg[i..e - 1] (to avoid overflows) */ lua_geti(L, 1, i); lua_geti(L, 1, e); /* push last element */ @@ -205,14 +205,14 @@ const partition = function(L, lo, up) { /* next loop: repeat ++i while a[i] < P */ while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ - luaL_error(L, to_luastring("invalid order function for sorting")); + luaL_error(L, to_luastring('invalid order function for sorting')); lua_pop(L, 1); /* remove a[i] */ } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) /* j < i but a[j] > P ?? */ - luaL_error(L, to_luastring("invalid order function for sorting")); + luaL_error(L, to_luastring('invalid order function for sorting')); lua_pop(L, 1); /* remove a[j] */ } /* after the loop, a[j] <= P and a[j + 1 .. up] >= P */ @@ -289,7 +289,7 @@ const auxsort = function(L, lo, up, rnd) { const sort = function(L) { let n = aux_getn(L, 1, TAB_RW); if (n > 1) { /* non-trivial interval? */ - luaL_argcheck(L, n < LUA_MAXINTEGER, 1, "array too big"); + luaL_argcheck(L, n < LUA_MAXINTEGER, 1, 'array too big'); if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ luaL_checktype(L, 2, LUA_TFUNCTION); /* must be a function */ lua_settop(L, 2); /* make sure there are two arguments */ @@ -299,13 +299,13 @@ const sort = function(L) { }; const tab_funcs = { - "concat": tconcat, - "insert": tinsert, - "move": tmove, - "pack": pack, - "remove": tremove, - "sort": sort, - "unpack": unpack + 'concat': tconcat, + 'insert': tinsert, + 'move': tmove, + 'pack': pack, + 'remove': tremove, + 'sort': sort, + 'unpack': unpack }; const luaopen_table = function(L) { diff --git a/src/ltm.js b/src/ltm.js index c0002d7f..44c7ffec 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -14,17 +14,17 @@ const { } = constant_types; const luaT_typenames_ = [ - "no value", - "nil", - "boolean", - "userdata", - "number", - "string", - "table", - "function", - "userdata", - "thread", - "proto" /* this last case is used for tests only */ + 'no value', + 'nil', + 'boolean', + 'userdata', + 'number', + 'string', + 'table', + 'function', + 'userdata', + 'thread', + 'proto' /* this last case is used for tests only */ ].map(e => to_luastring(e)); const ttypename = function (t) { @@ -65,30 +65,30 @@ const TMS = { }; const luaT_init = function (L) { - L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring("__index", true)); - L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring("__newindex", true)); - L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring("__gc", true)); - L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring("__mode", true)); - L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring("__len", true)); - L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring("__eq", true)); - L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring("__add", true)); - L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring("__sub", true)); - L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring("__mul", true)); - L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring("__mod", true)); - L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring("__pow", true)); - L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring("__div", true)); - L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring("__idiv", true)); - L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring("__band", true)); - L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring("__bor", true)); - L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring("__bxor", true)); - L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring("__shl", true)); - L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring("__shr", true)); - L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring("__unm", true)); - L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring("__bnot", true)); - L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring("__lt", true)); - L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring("__le", true)); - L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring("__concat", true)); - L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring("__call", true)); + L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring('__index', true)); + L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring('__newindex', true)); + L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring('__gc', true)); + L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring('__mode', true)); + L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring('__len', true)); + L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring('__eq', true)); + L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring('__add', true)); + L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring('__sub', true)); + L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring('__mul', true)); + L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring('__mod', true)); + L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring('__pow', true)); + L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring('__div', true)); + L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring('__idiv', true)); + L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring('__band', true)); + L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring('__bor', true)); + L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring('__bxor', true)); + L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring('__shl', true)); + L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring('__shr', true)); + L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring('__unm', true)); + L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring('__bnot', true)); + L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring('__lt', true)); + L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring('__le', true)); + L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring('__concat', true)); + L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring('__call', true)); }; /* @@ -150,10 +150,10 @@ const luaT_trybinTM = function (L, p1, p2, res, event) { if (n1 !== false && n2 !== false) return luaG_tointerror(L, p1, p2); else - return luaG_opinterror(L, p1, p2, to_luastring("perform bitwise operation on", true)); + return luaG_opinterror(L, p1, p2, to_luastring('perform bitwise operation on', true)); } default: - return luaG_opinterror(L, p1, p2, to_luastring("perform arithmetic on", true)); + return luaG_opinterror(L, p1, p2, to_luastring('perform arithmetic on', true)); } } }; diff --git a/src/lua.js b/src/lua.js index a8eba907..6ef71c2c 100644 --- a/src/lua.js +++ b/src/lua.js @@ -1,10 +1,10 @@ -import { thread_status, constant_types } from "./defs.js"; +import { thread_status, constant_types } from './defs.js'; -export { LUA_AUTHORS, LUA_COPYRIGHT, thread_status, LUA_HOOKCALL, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, constant_types, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RELEASE, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, LUA_SIGNATURE, LUA_VERSION, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, LUA_VERSION_NUM, LUA_VERSION_RELEASE, lua_Debug, lua_upvalueindex } from "./defs.js"; -export { lua_absindex, lua_arith, lua_atpanic, lua_atnativeerror, lua_call, lua_callk, lua_checkstack, lua_compare, lua_concat, lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, lua_getextraspace, lua_getfield, lua_getglobal, lua_geti, lua_getmetatable, lua_gettable, lua_gettop, lua_getupvalue, lua_getuservalue, lua_insert, lua_isboolean, lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isproxy, lua_isstring, lua_istable, lua_isthread, lua_isuserdata, lua_len, lua_load, lua_newtable, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushinteger, lua_pushjsclosure, lua_pushjsfunction, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, lua_replace, lua_rotate, lua_setallocf, lua_setfield, lua_setglobal, lua_seti, lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, lua_setuservalue, lua_status, lua_stringtonumber, lua_toboolean, lua_todataview, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, lua_upvalueid, lua_upvaluejoin, lua_version, lua_xmove, lua_tocfunction } from "./lapi.js"; -export { lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getstack, lua_sethook, lua_setlocal } from "./ldebug.js"; -export { lua_isyieldable, lua_resume, lua_yield, lua_yieldk } from "./ldo.js"; -export { lua_close, lua_newstate, lua_newthread } from "./lstate.js"; +export { LUA_AUTHORS, LUA_COPYRIGHT, thread_status, LUA_HOOKCALL, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, constant_types, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RELEASE, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, LUA_SIGNATURE, LUA_VERSION, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, LUA_VERSION_NUM, LUA_VERSION_RELEASE, lua_Debug, lua_upvalueindex } from './defs.js'; +export { lua_absindex, lua_arith, lua_atpanic, lua_atnativeerror, lua_call, lua_callk, lua_checkstack, lua_compare, lua_concat, lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, lua_getextraspace, lua_getfield, lua_getglobal, lua_geti, lua_getmetatable, lua_gettable, lua_gettop, lua_getupvalue, lua_getuservalue, lua_insert, lua_isboolean, lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isproxy, lua_isstring, lua_istable, lua_isthread, lua_isuserdata, lua_len, lua_load, lua_newtable, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushinteger, lua_pushjsclosure, lua_pushjsfunction, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, lua_replace, lua_rotate, lua_setallocf, lua_setfield, lua_setglobal, lua_seti, lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, lua_setuservalue, lua_status, lua_stringtonumber, lua_toboolean, lua_todataview, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, lua_upvalueid, lua_upvaluejoin, lua_version, lua_xmove, lua_tocfunction } from './lapi.js'; +export { lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getstack, lua_sethook, lua_setlocal } from './ldebug.js'; +export { lua_isyieldable, lua_resume, lua_yield, lua_yieldk } from './ldo.js'; +export { lua_close, lua_newstate, lua_newthread } from './lstate.js'; export const LUA_ERRERR = thread_status.LUA_ERRERR; export const LUA_ERRGCMM = thread_status.LUA_ERRGCMM; diff --git a/src/luaconf.js b/src/luaconf.js index e72e26c2..840522c1 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -11,15 +11,15 @@ import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR, to_luastring } from './defs.js'; ** LUA_EXEC_DIR in a Windows path is replaced by the executable's ** directory. */ -const LUA_PATH_SEP = ";"; +const LUA_PATH_SEP = ';'; const _LUA_PATH_SEP = LUA_PATH_SEP; export { _LUA_PATH_SEP as LUA_PATH_SEP }; -const LUA_PATH_MARK = "?"; +const LUA_PATH_MARK = '?'; const _LUA_PATH_MARK = LUA_PATH_MARK; export { _LUA_PATH_MARK as LUA_PATH_MARK }; -const LUA_EXEC_DIR = "!"; +const LUA_EXEC_DIR = '!'; const _LUA_EXEC_DIR = LUA_EXEC_DIR; export { _LUA_EXEC_DIR as LUA_EXEC_DIR }; @@ -32,75 +32,76 @@ export { _LUA_EXEC_DIR as LUA_EXEC_DIR }; ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ -const LUA_VDIR = LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR; +const LUA_VDIR = LUA_VERSION_MAJOR + '.' + LUA_VERSION_MINOR; const _LUA_VDIR = LUA_VDIR; export { _LUA_VDIR as LUA_VDIR }; -export let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT, LUA_ROOT, LUA_ROOT2, LUA_LDIR2, LUA_JSDIR2; +export let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT, LUA_ROOT; -if (typeof process === "undefined") { - LUA_DIRSEP = "/"; +if (typeof process === 'undefined') { + LUA_DIRSEP = '/'; - LUA_LDIR = "./lua/" + LUA_VDIR + "/"; + LUA_LDIR = './lua/' + LUA_VDIR + '/'; LUA_JSDIR = LUA_LDIR; LUA_PATH_DEFAULT = to_luastring( - LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + + LUA_LDIR + '?.lua;' + LUA_LDIR + '?/init.lua;' + /* LUA_JSDIR excluded as it is equal to LUA_LDIR */ - "./?.lua;./?/init.lua" + './?.lua;./?/init.lua' ); LUA_JSPATH_DEFAULT = to_luastring( - LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;./?.js" + LUA_JSDIR + '?.js;' + LUA_JSDIR + 'loadall.js;./?.js' ); } else if (platform() === 'win32') { - LUA_DIRSEP = "\\"; + LUA_DIRSEP = '\\'; /* ** In Windows, any exclamation mark ('!') in the path is replaced by the ** path of the directory of the executable file of the current process. */ - LUA_LDIR = "!\\lua\\"; + LUA_LDIR = '!\\lua\\'; - LUA_JSDIR = "!\\"; + LUA_JSDIR = '!\\'; - LUA_SHRDIR = "!\\..\\share\\lua\\" + LUA_VDIR + "\\"; + LUA_SHRDIR = '!\\..\\share\\lua\\' + LUA_VDIR + '\\'; LUA_PATH_DEFAULT = to_luastring( - LUA_LDIR + "?.lua;" + LUA_LDIR + "?\\init.lua;" + - LUA_JSDIR + "?.lua;" + LUA_JSDIR + "?\\init.lua;" + - LUA_SHRDIR + "?.lua;" + LUA_SHRDIR + "?\\init.lua;" + - ".\\?.lua;.\\?\\init.lua" + LUA_LDIR + '?.lua;' + LUA_LDIR + '?\\init.lua;' + + LUA_JSDIR + '?.lua;' + LUA_JSDIR + '?\\init.lua;' + + LUA_SHRDIR + '?.lua;' + LUA_SHRDIR + '?\\init.lua;' + + '.\\?.lua;.\\?\\init.lua' ); LUA_JSPATH_DEFAULT = to_luastring( - LUA_JSDIR + "?.js;" + - LUA_JSDIR + "..\\share\\lua\\" + LUA_VDIR + "\\?.js;" + - LUA_JSDIR + "loadall.js;.\\?.js" + LUA_JSDIR + '?.js;' + + LUA_JSDIR + '..\\share\\lua\\' + LUA_VDIR + '\\?.js;' + + LUA_JSDIR + 'loadall.js;.\\?.js' ); } else { - LUA_DIRSEP = "/"; + LUA_DIRSEP = '/'; - LUA_ROOT = "/usr/local/"; + LUA_ROOT = '/usr/local/'; + const LUA_ROOT2 = '/usr/'; - LUA_LDIR = LUA_ROOT + "share/lua/" + LUA_VDIR + "/"; - LUA_LDIR2 = LUA_ROOT2 + "share/lua/" + LUA_VDIR + "/"; + LUA_LDIR = LUA_ROOT + 'share/lua/' + LUA_VDIR + '/'; + const LUA_LDIR2 = LUA_ROOT2 + 'share/lua/' + LUA_VDIR + '/'; LUA_JSDIR = LUA_LDIR; - LUA_JSDIR2 = LUA_LDIR2; + const LUA_JSDIR2 = LUA_LDIR2; LUA_PATH_DEFAULT = to_luastring( - LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + - LUA_LDIR2 + "?.lua;" + LUA_LDIR2 + "?/init.lua;" + + LUA_LDIR + '?.lua;' + LUA_LDIR + '?/init.lua;' + + LUA_LDIR2 + '?.lua;' + LUA_LDIR2 + '?/init.lua;' + /* LUA_JSDIR(2) excluded as it is equal to LUA_LDIR(2) */ - "./?.lua;./?/init.lua" + './?.lua;./?/init.lua' ); LUA_JSPATH_DEFAULT = to_luastring( - LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;" + - LUA_JSDIR2 + "?.js;" + LUA_JSDIR2 + "loadall.js;" + - "./?.js" + LUA_JSDIR + '?.js;' + LUA_JSDIR + 'loadall.js;' + + LUA_JSDIR2 + '?.js;' + LUA_JSDIR2 + 'loadall.js;' + + './?.js' ); } @@ -134,11 +135,11 @@ const lua_numbertointeger = function (n) { return n >= LUA_MININTEGER && n < -LUA_MININTEGER ? n : false; }; -const LUA_INTEGER_FRMLEN = ""; -const LUA_NUMBER_FRMLEN = ""; +const LUA_INTEGER_FRMLEN = ''; +const LUA_NUMBER_FRMLEN = ''; const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; -const LUA_NUMBER_FMT = "%.14g"; +const LUA_NUMBER_FMT = '%.14g'; const lua_getlocaledecpoint = function () { /* we hard-code the decimal point to '.' as a user cannot change the diff --git a/src/lualib.js b/src/lualib.js index e5a1e609..a592c1a2 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,65 +1,65 @@ export { luaL_openlibs } from './linit.js'; -import { luaopen_io } from "./liolib.js"; +import { luaopen_io } from './liolib.js'; export { luaopen_io }; -export { luaopen_table } from "./ltablib.js"; -export { luaopen_coroutine } from "./lcorolib.js"; -export { luaopen_os } from "./loslib.js"; -export { luaopen_string } from "./lstrlib.js"; -export { luaopen_utf8 } from "./lutf8lib.js"; -export { luaopen_math } from "./lmathlib.js"; -export { luaopen_debug } from "./ldblib.js"; -export { luaopen_package } from "./loadlib.js"; -export { luaopen_fengari } from "./fengarilib.js"; -import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR } from "./lua.js"; +export { luaopen_table } from './ltablib.js'; +export { luaopen_coroutine } from './lcorolib.js'; +export { luaopen_os } from './loslib.js'; +export { luaopen_string } from './lstrlib.js'; +export { luaopen_utf8 } from './lutf8lib.js'; +export { luaopen_math } from './lmathlib.js'; +export { luaopen_debug } from './ldblib.js'; +export { luaopen_package } from './loadlib.js'; +export { luaopen_fengari } from './fengarilib.js'; +import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR } from './lua.js'; -const LUA_VERSUFFIX = "_" + LUA_VERSION_MAJOR + "_" + LUA_VERSION_MINOR; +const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; const _LUA_VERSUFFIX = LUA_VERSUFFIX; export { _LUA_VERSUFFIX as LUA_VERSUFFIX }; -export function lua_assert(c) { } +export function lua_assert(_c) { } -export { luaopen_base } from "./lbaselib.js"; +export { luaopen_base } from './lbaselib.js'; -const LUA_COLIBNAME = "coroutine"; +const LUA_COLIBNAME = 'coroutine'; const _LUA_COLIBNAME = LUA_COLIBNAME; export { _LUA_COLIBNAME as LUA_COLIBNAME }; -const LUA_TABLIBNAME = "table"; +const LUA_TABLIBNAME = 'table'; const _LUA_TABLIBNAME = LUA_TABLIBNAME; export { _LUA_TABLIBNAME as LUA_TABLIBNAME }; -export const LUA_IOLIBNAME = "io"; +export const LUA_IOLIBNAME = 'io'; -const LUA_OSLIBNAME = "os"; +const LUA_OSLIBNAME = 'os'; const _LUA_OSLIBNAME = LUA_OSLIBNAME; export { _LUA_OSLIBNAME as LUA_OSLIBNAME }; -const LUA_STRLIBNAME = "string"; +const LUA_STRLIBNAME = 'string'; const _LUA_STRLIBNAME = LUA_STRLIBNAME; export { _LUA_STRLIBNAME as LUA_STRLIBNAME }; -const LUA_UTF8LIBNAME = "utf8"; +const LUA_UTF8LIBNAME = 'utf8'; const _LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; export { _LUA_UTF8LIBNAME as LUA_UTF8LIBNAME }; -const LUA_BITLIBNAME = "bit32"; +const LUA_BITLIBNAME = 'bit32'; const _LUA_BITLIBNAME = LUA_BITLIBNAME; export { _LUA_BITLIBNAME as LUA_BITLIBNAME }; // module.exports.luaopen_bit32 = require("./lbitlib.js").luaopen_bit32; -const LUA_MATHLIBNAME = "math"; +const LUA_MATHLIBNAME = 'math'; const _LUA_MATHLIBNAME = LUA_MATHLIBNAME; export { _LUA_MATHLIBNAME as LUA_MATHLIBNAME }; -const LUA_DBLIBNAME = "debug"; +const LUA_DBLIBNAME = 'debug'; const _LUA_DBLIBNAME = LUA_DBLIBNAME; export { _LUA_DBLIBNAME as LUA_DBLIBNAME }; -const LUA_LOADLIBNAME = "package"; +const LUA_LOADLIBNAME = 'package'; const _LUA_LOADLIBNAME = LUA_LOADLIBNAME; export { _LUA_LOADLIBNAME as LUA_LOADLIBNAME }; -const LUA_FENGARILIBNAME = "fengari"; +const LUA_FENGARILIBNAME = 'fengari'; const _LUA_FENGARILIBNAME = LUA_FENGARILIBNAME; export { _LUA_FENGARILIBNAME as LUA_FENGARILIBNAME }; diff --git a/src/lundump.js b/src/lundump.js index f7dce294..307e509f 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -3,7 +3,7 @@ import { luaD_throw, luaD_inctop } from './ldo.js'; import { Proto, luaF_newLclosure } from './lfunc.js'; import { TValue, luaO_pushfstring } from './lobject.js'; import { MAXARG_sBx, POS_A, POS_Ax, POS_B, POS_Bx, POS_C, POS_OP, SIZE_A, SIZE_Ax, SIZE_B, SIZE_Bx, SIZE_C, SIZE_OP } from './lopcodes.js'; -import { lua_assert } from "./llimits.js"; +import { lua_assert } from './llimits.js'; import { luaS_bless } from './lstring.js'; import { luaZ_read, ZIO } from './lzio.js'; @@ -29,13 +29,13 @@ class BytecodeParser { this.integerSize = 4; this.numberSize = 8; - lua_assert(Z instanceof ZIO, "BytecodeParser only operates on a ZIO"); + lua_assert(Z instanceof ZIO, 'BytecodeParser only operates on a ZIO'); lua_assert(is_luastring(name)); if (name[0] === 64 /* ('@').charCodeAt(0) */ || name[0] === 61 /* ('=').charCodeAt(0) */) this.name = name.subarray(1); else if (name[0] == LUA_SIGNATURE[0]) - this.name = to_luastring("binary string", true); + this.name = to_luastring('binary string', true); else this.name = name; @@ -53,31 +53,31 @@ class BytecodeParser { read(size) { let u8 = new Uint8Array(size); if (luaZ_read(this.Z, u8, 0, size) !== 0) - this.error("truncated"); + this.error('truncated'); return u8; } LoadByte() { if (luaZ_read(this.Z, this.u8, 0, 1) !== 0) - this.error("truncated"); + this.error('truncated'); return this.u8[0]; } LoadInt() { if (luaZ_read(this.Z, this.u8, 0, this.intSize) !== 0) - this.error("truncated"); + this.error('truncated'); return this.dv.getInt32(0, true); } LoadNumber() { if (luaZ_read(this.Z, this.u8, 0, this.numberSize) !== 0) - this.error("truncated"); + this.error('truncated'); return this.dv.getFloat64(0, true); } LoadInteger() { if (luaZ_read(this.Z, this.u8, 0, this.integerSize) !== 0) - this.error("truncated"); + this.error('truncated'); return this.dv.getInt32(0, true); } @@ -105,7 +105,7 @@ class BytecodeParser { for (let i = 0; i < n; i++) { if (luaZ_read(this.Z, this.u8, 0, this.instructionSize) !== 0) - this.error("truncated"); + this.error('truncated'); let ins = this.dv.getUint32(0, true); f.code[i] = { code: ins, @@ -213,15 +213,15 @@ class BytecodeParser { } checkHeader() { - this.checkliteral(LUA_SIGNATURE.subarray(1), "not a"); /* 1st char already checked */ + this.checkliteral(LUA_SIGNATURE.subarray(1), 'not a'); /* 1st char already checked */ if (this.LoadByte() !== 0x53) - this.error("version mismatch in"); + this.error('version mismatch in'); if (this.LoadByte() !== 0) - this.error("format mismatch in"); + this.error('format mismatch in'); - this.checkliteral(LUAC_DATA, "corrupted"); + this.checkliteral(LUAC_DATA, 'corrupted'); this.intSize = this.LoadByte(); this.size_tSize = this.LoadByte(); @@ -229,22 +229,22 @@ class BytecodeParser { this.integerSize = this.LoadByte(); this.numberSize = this.LoadByte(); - this.checksize(this.intSize, 4, "int"); - this.checksize(this.size_tSize, 4, "size_t"); - this.checksize(this.instructionSize, 4, "instruction"); - this.checksize(this.integerSize, 4, "integer"); - this.checksize(this.numberSize, 8, "number"); + this.checksize(this.intSize, 4, 'int'); + this.checksize(this.size_tSize, 4, 'size_t'); + this.checksize(this.instructionSize, 4, 'instruction'); + this.checksize(this.integerSize, 4, 'integer'); + this.checksize(this.numberSize, 8, 'number'); if (this.LoadInteger() !== 0x5678) - this.error("endianness mismatch in"); + this.error('endianness mismatch in'); if (this.LoadNumber() !== 370.5) - this.error("float format mismatch in"); + this.error('float format mismatch in'); } error(why) { - luaO_pushfstring(this.L, to_luastring("%s: %s precompiled chunk"), this.name, to_luastring(why)); + luaO_pushfstring(this.L, to_luastring('%s: %s precompiled chunk'), this.name, to_luastring(why)); luaD_throw(this.L, LUA_ERRSYNTAX); } diff --git a/src/lutf8lib.js b/src/lutf8lib.js index 21b88541..0fc339af 100644 --- a/src/lutf8lib.js +++ b/src/lutf8lib.js @@ -1,6 +1,6 @@ import { lua_gettop, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_setfield, lua_tointeger } from './lua.js'; import { luaL_Buffer, luaL_addvalue, luaL_argcheck, luaL_buffinit, luaL_checkinteger, luaL_checkstack, luaL_checkstring, luaL_error, luaL_newlib, luaL_optinteger, luaL_pushresult } from './lauxlib.js'; -import { luastring_of, to_luastring } from "./fengaricore.js"; +import { luastring_of, to_luastring } from './fengaricore.js'; const MAXUNICODE = 0x10FFFF; @@ -58,8 +58,8 @@ const utflen = function(L) { let posi = u_posrelat(luaL_optinteger(L, 2, 1), len); let posj = u_posrelat(luaL_optinteger(L, 3, -1), len); - luaL_argcheck(L, 1 <= posi && --posi <= len, 2, "initial position out of string"); - luaL_argcheck(L, --posj < len, 3, "final position out of string"); + luaL_argcheck(L, 1 <= posi && --posi <= len, 2, 'initial position out of string'); + luaL_argcheck(L, --posj < len, 3, 'final position out of string'); while (posi <= posj) { let dec = utf8_decode(s, posi); @@ -75,10 +75,10 @@ const utflen = function(L) { return 1; }; -const p_U = to_luastring("%U"); +const p_U = to_luastring('%U'); const pushutfchar = function(L, arg) { let code = luaL_checkinteger(L, arg); - luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); + luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, 'value out of range'); lua_pushfstring(L, p_U, code); }; @@ -111,14 +111,14 @@ const byteoffset = function(L) { let posi = n >= 0 ? 1 : s.length + 1; posi = u_posrelat(luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, "position out of range"); + luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, 'position out of range'); if (n === 0) { /* find beginning of current byte sequence */ while (posi > 0 && iscont(s[posi])) posi--; } else { if (iscont(s[posi])) - luaL_error(L, "initial position is a continuation byte"); + luaL_error(L, 'initial position is a continuation byte'); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ @@ -155,19 +155,19 @@ const codepoint = function(L) { let posi = u_posrelat(luaL_optinteger(L, 2, 1), s.length); let pose = u_posrelat(luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, posi >= 1, 2, "out of range"); - luaL_argcheck(L, pose <= s.length, 3, "out of range"); + luaL_argcheck(L, posi >= 1, 2, 'out of range'); + luaL_argcheck(L, pose <= s.length, 3, 'out of range'); if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) - return luaL_error(L, "string slice too long"); + return luaL_error(L, 'string slice too long'); let n = (pose - posi) + 1; - luaL_checkstack(L, n, "string slice too long"); + luaL_checkstack(L, n, 'string slice too long'); n = 0; for (posi -= 1; posi < pose;) { let dec = utf8_decode(s, posi); if (dec === null) - return luaL_error(L, "invalid UTF-8 code"); + return luaL_error(L, 'invalid UTF-8 code'); lua_pushinteger(L, dec.code); posi = dec.pos; n++; @@ -192,7 +192,7 @@ const iter_aux = function(L) { else { let dec = utf8_decode(s, n); if (dec === null || iscont(s[dec.pos])) - return luaL_error(L, to_luastring("invalid UTF-8 code")); + return luaL_error(L, to_luastring('invalid UTF-8 code')); lua_pushinteger(L, n + 1); lua_pushinteger(L, dec.code); return 2; @@ -208,11 +208,11 @@ const iter_codes = function(L) { }; const funcs = { - "char": utfchar, - "codepoint": codepoint, - "codes": iter_codes, - "len": utflen, - "offset": byteoffset + 'char': utfchar, + 'codepoint': codepoint, + 'codes': iter_codes, + 'len': utflen, + 'offset': byteoffset }; /* pattern to match a single UTF-8 character */ @@ -221,7 +221,7 @@ const UTF8PATT = luastring_of(91, 0, 45, 127, 194, 45, 244, 93, 91, 128, 45, 191 const luaopen_utf8 = function(L) { luaL_newlib(L, funcs); lua_pushstring(L, UTF8PATT); - lua_setfield(L, -2, to_luastring("charpattern", true)); + lua_setfield(L, -2, to_luastring('charpattern', true)); return 1; }; diff --git a/src/lvm.js b/src/lvm.js index 9a9e0ca5..22c3345e 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -585,13 +585,13 @@ const luaV_execute = function (L) { } else { /* try making all values floats */ let nlimit, nstep, ninit; if ((nlimit = tonumber(plimit)) === false) - luaG_runerror(L, to_luastring("'for' limit must be a number", true)); + luaG_runerror(L, to_luastring('\'for\' limit must be a number', true)); L.stack[ra + 1].setfltvalue(nlimit); if ((nstep = tonumber(pstep)) === false) - luaG_runerror(L, to_luastring("'for' step must be a number", true)); + luaG_runerror(L, to_luastring('\'for\' step must be a number', true)); L.stack[ra + 2].setfltvalue(nstep); if ((ninit = tonumber(init)) === false) - luaG_runerror(L, to_luastring("'for' initial value must be a number", true)); + luaG_runerror(L, to_luastring('\'for\' initial value must be a number', true)); L.stack[ra].setfltvalue(ninit - nstep); } @@ -670,7 +670,7 @@ const luaV_execute = function (L) { break; } case OP_EXTRAARG: { - throw Error("invalid opcode"); + throw Error('invalid opcode'); } } } @@ -895,7 +895,7 @@ const luaV_objlen = function (L, ra, rb) { default: { tm = luaT_gettmbyobj(L, rb, TMS.TM_LEN); if (tm.ttisnil()) - luaG_typeerror(L, rb, to_luastring("get length of", true)); + luaG_typeerror(L, rb, to_luastring('get length of', true)); break; } } @@ -918,14 +918,14 @@ const luaV_imul = Math.imul || function (a, b) { const luaV_div = function (L, m, n) { if (n === 0) - luaG_runerror(L, to_luastring("attempt to divide by zero")); + luaG_runerror(L, to_luastring('attempt to divide by zero')); return Math.floor(m / n) | 0; }; // % semantic on negative numbers is different in js const luaV_mod = function (L, m, n) { if (n === 0) - luaG_runerror(L, to_luastring("attempt to perform 'n%%0'")); + luaG_runerror(L, to_luastring('attempt to perform \'n%%0\'')); return (m - Math.floor(m / n) * n) | 0; }; @@ -1085,7 +1085,7 @@ const luaV_gettable = function (L, t, key, ra) { t = tm; /* else try to access 'tm[key]' */ } - luaG_runerror(L, to_luastring("'__index' chain too long; possible loop", true)); + luaG_runerror(L, to_luastring('\'__index\' chain too long; possible loop', true)); }; const settable = function (L, t, key, val) { @@ -1112,7 +1112,7 @@ const settable = function (L, t, key, val) { t = tm; /* else repeat assignment over 'tm' */ } - luaG_runerror(L, to_luastring("'__newindex' chain too long; possible loop", true)); + luaG_runerror(L, to_luastring('\'__newindex\' chain too long; possible loop', true)); }; diff --git a/src/lzio.js b/src/lzio.js index 8a0c318b..d528647d 100644 --- a/src/lzio.js +++ b/src/lzio.js @@ -1,4 +1,4 @@ -import { lua_assert } from "./llimits.js"; +import { lua_assert } from './llimits.js'; class MBuffer { constructor() { @@ -29,7 +29,7 @@ const luaZ_resizebuffer = function(L, buff, size) { class ZIO { constructor(L, reader, data) { this.L = L; /* Lua state (for reader) */ - lua_assert(typeof reader == "function", "ZIO requires a reader"); + lua_assert(typeof reader == 'function', 'ZIO requires a reader'); this.reader = reader; /* reader function */ this.data = data; /* additional data */ this.n = 0; /* bytes still unread */ @@ -48,7 +48,7 @@ const luaZ_fill = function(z) { let buff = z.reader(z.L, z.data); if (buff === null) return EOZ; - lua_assert(buff instanceof Uint8Array, "Should only load binary of array of bytes"); + lua_assert(buff instanceof Uint8Array, 'Should only load binary of array of bytes'); let size = buff.length; if (size === 0) return EOZ; From e1d75598e4a81dee1d615332295cfcc13ffcd13e Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Tue, 2 Jun 2026 09:51:28 +0000 Subject: [PATCH 06/11] Update configs and add packages --- jest.config.cjs | 2 +- package.json | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/jest.config.cjs b/jest.config.cjs index 9fc662d6..eb0667a9 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -175,7 +175,7 @@ const config = { // A map from regular expressions to paths to transformers transform: { - "^.+\\.jsx$": "babel-jest", + "^.+\\.js$": "babel-jest", }, // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation diff --git a/package.json b/package.json index 85db196f..0a22a1c9 100644 --- a/package.json +++ b/package.json @@ -23,24 +23,29 @@ ], "contributors": [ "Benoit Giannangeli", - "Daurnimator " + "Daurnimator ", + "Dave Roberts " ], "license": "MIT", "bugs": { - "url": "https://github.com/fengari-lua/fengari/issues" + "url": "https://github.com/droberts-ctrlo/fengari/issues" }, - "homepage": "https://github.com/fengari-lua/fengari#readme", + "homepage": "https://github.com/droberts-ctrlo/fengari#readme", "devDependencies": { "@babel/core": "^7.29.7", "@babel/preset-env": "^7.29.7", + "@eslint/js": "^10.0.1", + "@stylistic/eslint-plugin": "^5.10.0", "babel-jest": "^30.4.1", "eslint": "^5.15.1", + "globals": "^17.6.0", "jest": "^24.5.0" }, "dependencies": { - "readline-sync": "^1.4.10", - "sprintf-js": "^1.1.3", - "tmp": "^0.2.5" + "eslint": "^10.0.0", + "readline-sync": "^1.4.9", + "sprintf-js": "^1.1.2", + "tmp": "^0.0.33" }, "sideEffects": false } From 583e3995157031ca1e61cfa6a56b42ad83328b08 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Tue, 2 Jun 2026 14:10:05 +0000 Subject: [PATCH 07/11] Corrected packages --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0a22a1c9..99476215 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fengari", "version": "0.1.6", - "description": "A Lua VM written in JS ES6 targeting the browser", + "description": "A Lua VM written in JS modules targeting the browser", "main": "src/fengari.js", "type": "module", "directories": { @@ -15,7 +15,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/fengari-lua/fengari.git" + "url": "git+https://github.com/droberts-ctrlo/fengari.git" }, "keywords": [ "lua", @@ -37,12 +37,12 @@ "@eslint/js": "^10.0.1", "@stylistic/eslint-plugin": "^5.10.0", "babel-jest": "^30.4.1", - "eslint": "^5.15.1", + "@stylistic/eslint-plugin": "^5.10.0", + "eslint": "^10.0.0", "globals": "^17.6.0", "jest": "^24.5.0" }, "dependencies": { - "eslint": "^10.0.0", "readline-sync": "^1.4.9", "sprintf-js": "^1.1.2", "tmp": "^0.0.33" From 7e887d95c2a30fa625d755b71baa17cc3aeb2267 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 4 Jun 2026 12:03:19 +0100 Subject: [PATCH 08/11] Update files, eslint run, and iteration complete --- LICENSE | 3 +- NEWS | 4 + README.md | 8 +- eslint.config.js | 8 +- jest.config.cjs | 3 +- src/common.js | 2 +- src/fengari.js | 20 +- src/fengaricore.js | 33 +- src/fengarilib.js | 45 +- src/lapi.js | 841 ++--- src/lauxlib.js | 762 ++--- src/lbaselib.js | 317 +- src/lcode.js | 531 ++- src/lcorolib.js | 107 +- src/ldblib.js | 306 +- src/ldebug.js | 373 +- src/ldo.js | 377 +- src/ldump.js | 19 +- src/lfunc.js | 40 +- src/linit.js | 58 +- src/liolib.js | 113 +- src/ljstype.js | 29 +- src/llex.js | 209 +- src/llimits.js | 28 +- src/lmathlib.js | 175 +- src/loadlib.js | 330 +- src/lobject.js | 314 +- src/lopcodes.js | 241 +- src/loslib.js | 223 +- src/lparser.js | 405 ++- src/lstate.js | 96 +- src/lstring.js | 49 +- src/lstrlib.js | 481 ++- src/ltable.js | 123 +- src/ltablib.js | 203 +- src/ltm.js | 153 +- src/lua.js | 39 +- src/luaconf.js | 99 +- src/lualib.js | 45 +- src/lundump.js | 89 +- src/lutf8lib.js | 103 +- src/lvm.js | 402 +-- src/lzio.js | 37 +- test/defs.test.js | 46 +- test/lapi.test.js | 146 +- test/lauxlib.test.js | 10 +- test/lbaselib.test.js | 56 +- test/lcorolib.test.js | 16 +- test/ldblib.test.js | 44 +- test/ldebug.test.js | 30 +- test/lexparse.test.js | 194 +- test/lmathlib.test.js | 32 +- test/load.test.js | 32 +- test/loadlib.test.js | 16 +- test/loslib.test.js | 22 +- test/lstrlib.test.js | 114 +- test/ltablib.test.js | 20 +- test/ltm.test.js | 80 +- test/lua.test.js | 10 +- test/lutf8lib.test.js | 22 +- test/lvm.test.js | 94 +- test/manual-tests/debug-cli.js | 2 +- test/test-suite/api.test.js | 194 +- test/test-suite/attrib.test.js | 30 +- test/test-suite/bitwise.test.js | 34 +- test/test-suite/calls.test.js | 66 +- test/test-suite/closure.test.js | 34 +- test/test-suite/code.test.js | 58 +- test/test-suite/constructs.test.js | 16 +- test/test-suite/coroutine.test.js | 146 +- test/test-suite/db.test.js | 114 +- test/test-suite/errors.test.js | 144 +- test/test-suite/events.test.js | 54 +- test/test-suite/goto.test.js | 26 +- test/test-suite/literals.test.js | 62 +- test/test-suite/locals.test.js | 12 +- test/test-suite/ltests.js | 301 +- test/test-suite/math.test.js | 152 +- test/test-suite/nextvar.test.js | 104 +- test/test-suite/pm.test.js | 78 +- test/test-suite/sort.test.js | 50 +- test/test-suite/strings.test.js | 48 +- test/test-suite/tpack.test.js | 66 +- test/test-suite/utf8.test.js | 38 +- test/test-suite/vararg.test.js | 18 +- test/tests.js | 15 +- yarn.lock | 5093 +++++++++++++++++++++++++++- 87 files changed, 9930 insertions(+), 5852 deletions(-) diff --git a/LICENSE b/LICENSE index 137f9f97..839ac1ba 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,8 @@ MIT License Copyright © 2017-2019 Benoit Giannangeli -Copyright © 2017-2025 Daurnimator +Copyright © 2017-2024 Daurnimator +Copyright © 2026 CtrlO Ltd Copyright © 1994–2017 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/NEWS b/NEWS index ecd45e10..c9635b6c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +0.1.6 - 2026-06-04 + + - Move across to ES modules + 0.1.5 - 2025-12-26 - Add os.setlocale that only understands the C locale diff --git a/README.md b/README.md index 0415ddf7..fdfdf365 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ [![Build Status](https://github.com/fengari-lua/fengari/actions/workflows/ci.yaml/badge.svg)](https://github.com/fengari-lua/fengari/actions/workflows/ci.yaml?query=event%3Apush) -[![npm](https://img.shields.io/npm/v/fengari.svg)](https://npmjs.com/package/fengari) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![#fengari on libera.chat](https://img.shields.io/badge/chat-%23fengari-brightgreen)](https://web.libera.chat/?channels=#fengari)

Fengari @@ -10,13 +8,13 @@ # Fengari -🌙 φεγγάρι - The Lua VM written in JS ES6 for Node and the browser +🌙 φεγγάρι - The Lua VM written in JS ES for Node and the browser This repository contains the core fengari code (which is a port of the Lua C library) which includes parser, virtual machine and base libraries. However it is rare to use this repository directly. -- To use fengari in a web browser as easily as you might use JavaScript, see [fengari-web](https://github.com/fengari-lua/fengari-web) -- [fengari-interop](https://github.com/fengari-lua/fengari-interop) is a lua library that makes interoperating with JavaScript objects simple, it is already included in fengari-web. +- To use fengari in a web browser as easily as you might use JavaScript, see [fengari-web](https://github.com/droberts-ctrlo/fengari-web) +- [fengari-interop](https://github.com/droberts-ctrlo/fengari-interop) is a lua library that makes interoperating with JavaScript objects simple, it is already included in fengari-web. - For a clone of the `lua` command line tool, but running under node.js, see [fengari-node-cli](https://github.com/fengari-lua/fengari-node-cli) ### The JS API diff --git a/eslint.config.js b/eslint.config.js index c58eb459..fb227fe8 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,11 +5,12 @@ import stylistic from "@stylistic/eslint-plugin"; export default defineConfig([ { ignores: ["dist", "node_modules", "*.config.*"] }, - { files: ["**/*.js"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: { ...globals.node, ...globals.browser, ...globals.worker } } }, - { files: ["**/*.test.js"], languageOptions: { globals: { ...globals.node, ...globals.browser, ...globals.worker, ...globals.jest } } }, + { files: ["**/src/*.js"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: { ...globals.node, ...globals.browser, ...globals.worker } } }, + { files: ["**/test/*.test.js"], languageOptions: { globals: { ...globals.node, ...globals.browser, ...globals.worker, ...globals.jest } } }, { plugins: {'@stylistic': stylistic} }, { rules: { + "@stylistic/semi": "error", "@typescript-eslint/no-explicit-any": "off", '@stylistic/quotes': ['error', 'single'], '@stylistic/no-extra-semi': 'error', @@ -17,7 +18,8 @@ export default defineConfig([ '@stylistic/curly-newline': 'error', '@stylistic/indent': ['error', 4], '@stylistic/comma-dangle': ['error', 'never'], - 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }] + 'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }], + 'no-empty': ['error', { allowEmptyCatch: true }] } } ]); diff --git a/jest.config.cjs b/jest.config.cjs index eb0667a9..a1449799 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -160,8 +160,7 @@ const config = { // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped testPathIgnorePatterns: [ - "/node_modules/", - "/dist/" + "/node_modules/" ], // The regexp pattern or array of patterns that Jest uses to detect test files diff --git a/src/common.js b/src/common.js index 6a6af9bb..70c05ac5 100644 --- a/src/common.js +++ b/src/common.js @@ -1,4 +1,4 @@ -const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); +const conf = (typeof process !== 'undefined' && process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); /* @@ LUAI_MAXSTACK limits the size of the Lua stack. diff --git a/src/fengari.js b/src/fengari.js index cd22878f..0488f5fc 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -1,25 +1,15 @@ /** @license MIT +Copyright © 2017-2026 CtrlO ltd. Copyright © 2017-2019 Benoit Giannangeli Copyright © 2017-2019 Daurnimator Copyright © 1994–2017 Lua.org, PUC-Rio. */ -'use strict'; - export { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, luastring_eq, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring } from './fengaricore.js'; -import * as luaconf from './luaconf.js'; -import * as lua from './lua.js'; -import * as lauxlib from './lauxlib.js'; -import * as lualib from './lualib.js'; - -const _luaconf = luaconf; -export { _luaconf as luaconf }; -const _lua = lua; -export { _lua as lua }; -const _lauxlib = lauxlib; -export { _lauxlib as lauxlib }; -const _lualib = lualib; -export { _lualib as lualib }; +export * as luaconf from './luaconf.js'; +export * as lua from './lua.js'; +export * as lauxlib from './lauxlib.js'; +export * as lualib from './lualib.js'; diff --git a/src/fengaricore.js b/src/fengaricore.js index 34f766f5..5f2d70e3 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -10,28 +10,11 @@ import { LUA_COPYRIGHT } from './defs.js'; export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from './defs.js'; -const FENGARI_VERSION_MAJOR = '0'; -const FENGARI_VERSION_MINOR = '1'; -const FENGARI_VERSION_NUM = 1; -const FENGARI_VERSION_RELEASE = '5'; -const FENGARI_VERSION = 'Fengari ' + FENGARI_VERSION_MAJOR + '.' + FENGARI_VERSION_MINOR; -const FENGARI_RELEASE = FENGARI_VERSION + '.' + FENGARI_VERSION_RELEASE; -const FENGARI_AUTHORS = 'B. Giannangeli, Daurnimator'; -const FENGARI_COPYRIGHT = FENGARI_RELEASE + ' Copyright (C) 2017-2019 ' + FENGARI_AUTHORS + '\nBased on: ' + LUA_COPYRIGHT; - -const _FENGARI_AUTHORS = FENGARI_AUTHORS; -export { _FENGARI_AUTHORS as FENGARI_AUTHORS }; -const _FENGARI_COPYRIGHT = FENGARI_COPYRIGHT; -export { _FENGARI_COPYRIGHT as FENGARI_COPYRIGHT }; -const _FENGARI_RELEASE = FENGARI_RELEASE; -export { _FENGARI_RELEASE as FENGARI_RELEASE }; -const _FENGARI_VERSION = FENGARI_VERSION; -export { _FENGARI_VERSION as FENGARI_VERSION }; -const _FENGARI_VERSION_MAJOR = FENGARI_VERSION_MAJOR; -export { _FENGARI_VERSION_MAJOR as FENGARI_VERSION_MAJOR }; -const _FENGARI_VERSION_MINOR = FENGARI_VERSION_MINOR; -export { _FENGARI_VERSION_MINOR as FENGARI_VERSION_MINOR }; -const _FENGARI_VERSION_NUM = FENGARI_VERSION_NUM; -export { _FENGARI_VERSION_NUM as FENGARI_VERSION_NUM }; -const _FENGARI_VERSION_RELEASE = FENGARI_VERSION_RELEASE; -export { _FENGARI_VERSION_RELEASE as FENGARI_VERSION_RELEASE }; +export const FENGARI_VERSION_MAJOR = '0'; +export const FENGARI_VERSION_MINOR = '1'; +export const FENGARI_VERSION_NUM = 1; +export const FENGARI_VERSION_RELEASE = '5'; +export const FENGARI_VERSION = 'Fengari ' + FENGARI_VERSION_MAJOR + '.' + FENGARI_VERSION_MINOR; +export const FENGARI_RELEASE = FENGARI_VERSION + '.' + FENGARI_VERSION_RELEASE; +export const FENGARI_AUTHORS = 'B. Giannangeli, Daurnimator'; +export const FENGARI_COPYRIGHT = FENGARI_RELEASE + ' Copyright (C) 2017-2019 ' + FENGARI_AUTHORS + '\nBased on: ' + LUA_COPYRIGHT; diff --git a/src/fengarilib.js b/src/fengarilib.js index 72756548..aa6ee806 100644 --- a/src/fengarilib.js +++ b/src/fengarilib.js @@ -1,27 +1,24 @@ -import { lua_pushinteger, lua_pushliteral, lua_setfield } from './lua.js'; -import { luaL_newlib } from './lauxlib.js'; -import { FENGARI_AUTHORS, FENGARI_COPYRIGHT, FENGARI_RELEASE, FENGARI_VERSION, FENGARI_VERSION_MAJOR, FENGARI_VERSION_MINOR, FENGARI_VERSION_NUM, FENGARI_VERSION_RELEASE, to_luastring } from './fengaricore.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as fengaricore from './fengaricore.js'; -const luaopen_fengari = function(L) { - luaL_newlib(L, {}); - lua_pushliteral(L, FENGARI_AUTHORS); - lua_setfield(L, -2, to_luastring('AUTHORS')); - lua_pushliteral(L, FENGARI_COPYRIGHT); - lua_setfield(L, -2, to_luastring('COPYRIGHT')); - lua_pushliteral(L, FENGARI_RELEASE); - lua_setfield(L, -2, to_luastring('RELEASE')); - lua_pushliteral(L, FENGARI_VERSION); - lua_setfield(L, -2, to_luastring('VERSION')); - lua_pushliteral(L, FENGARI_VERSION_MAJOR); - lua_setfield(L, -2, to_luastring('VERSION_MAJOR')); - lua_pushliteral(L, FENGARI_VERSION_MINOR); - lua_setfield(L, -2, to_luastring('VERSION_MINOR')); - lua_pushinteger(L, FENGARI_VERSION_NUM); - lua_setfield(L, -2, to_luastring('VERSION_NUM')); - lua_pushliteral(L, FENGARI_VERSION_RELEASE); - lua_setfield(L, -2, to_luastring('VERSION_RELEASE')); +export const luaopen_fengari = function(L) { + lauxlib.luaL_newlib(L, {}); + lua.lua_pushliteral(L, fengaricore.FENGARI_AUTHORS); + lua.lua_setfield(L, -2, fengaricore.to_luastring('AUTHORS')); + lua.lua_pushliteral(L, fengaricore.FENGARI_COPYRIGHT); + lua.lua_setfield(L, -2, fengaricore.to_luastring('COPYRIGHT')); + lua.lua_pushliteral(L, fengaricore.FENGARI_RELEASE); + lua.lua_setfield(L, -2, fengaricore.to_luastring('RELEASE')); + lua.lua_pushliteral(L, fengaricore.FENGARI_VERSION); + lua.lua_setfield(L, -2, fengaricore.to_luastring('VERSION')); + lua.lua_pushliteral(L, fengaricore.FENGARI_VERSION_MAJOR); + lua.lua_setfield(L, -2, fengaricore.to_luastring('VERSION_MAJOR')); + lua.lua_pushliteral(L, fengaricore.FENGARI_VERSION_MINOR); + lua.lua_setfield(L, -2, fengaricore.to_luastring('VERSION_MINOR')); + lua.lua_pushinteger(L, fengaricore.FENGARI_VERSION_NUM); + lua.lua_setfield(L, -2, fengaricore.to_luastring('VERSION_NUM')); + lua.lua_pushliteral(L, fengaricore.FENGARI_VERSION_RELEASE); + lua.lua_setfield(L, -2, fengaricore.to_luastring('VERSION_RELEASE')); return 1; }; - -const _luaopen_fengari = luaopen_fengari; -export { _luaopen_fengari as luaopen_fengari }; diff --git a/src/lapi.js b/src/lapi.js index d1099c0b..2f4e8a4f 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1,21 +1,19 @@ -import { LUA_MULTRET, LUA_OPBNOT, LUA_OPEQ, LUA_OPLE, LUA_OPLT, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS, LUA_VERSION_NUM, constant_types, thread_status, from_userstring, to_luastring } from './defs.js'; -import { api_check } from './llimits.js'; -import { luaG_errormsg } from './ldebug.js'; -import { luaD_growstack, adjust_top, luaD_callnoyield, luaD_protectedparser, luaD_call, luaD_pcall } from './ldo.js'; -import { luaU_dump } from './ldump.js'; -import { MAXUPVAL } from './lfunc.js'; -import { TValue as _TValue, CClosure as _CClosure, luaO_nilobject, setobj2s, pushobj2s, setobjs2s, pushsvalue2s, luaO_pushvfstring, Udata, luaO_tostring, luaO_str2num, luaO_arith } from './lobject.js'; -import { EXTRA_STACK, lua_State, CIST_LUA, CIST_OAH, CIST_YPCALL } from './lstate.js'; -import { luaS_bless, luaS_new, luaS_newliteral } from './lstring.js'; -import { ttypename } from './ltm.js'; -import { LUAI_MAXSTACK } from './common.js'; -import { settable, luaV_gettable, cvt2str, tointeger, tonumber, luaV_equalobj, luaV_lessthan, luaV_lessequal, luaV_concat, luaV_objlen } from './lvm.js'; -import { luaH_getint, luaH_setfrom, invalidateTMcache, luaH_setint, luaH_get, luaH_new, luaH_getn, luaH_next } from './ltable.js'; -import { ZIO } from './lzio.js'; -const TValue = _TValue; -const CClosure = _CClosure; - -const { +import * as defs from './defs.js'; +import * as llimits from './llimits.js'; +import * as ldebug from './ldebug.js'; +import * as ldo from './ldo.js'; +import * as ldump from './ldump.js'; +import * as lfunc from './lfunc.js'; +import * as lobject from './lobject.js'; +import * as lstate from './lstate.js'; +import * as lstring from './lstring.js'; +import * as ltm from './ltm.js'; +import * as common from './common.js'; +import * as lvm from './lvm.js'; +import * as ltable from './ltable.js'; +import * as lzio from './lzio.js'; + +export const { LUA_NUMTAGS, LUA_TBOOLEAN, LUA_TCCL, @@ -32,100 +30,100 @@ const { LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA -} = constant_types; +} = defs.constant_types; -const { LUA_OK } = thread_status; +export const { LUA_OK } = defs.thread_status; -const api_incr_top = function (L) { +export const api_incr_top = function (L) { L.top++; - api_check(L, L.top <= L.ci.top, 'stack overflow'); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); }; -const api_checknelems = function (L, n) { - api_check(L, n < (L.top - L.ci.funcOff), 'not enough elements in the stack'); +export const api_checknelems = function (L, n) { + llimits.api_check(L, n < (L.top - L.ci.funcOff), 'not enough elements in the stack'); }; -const fengari_argcheck = function (c) { +export const fengari_argcheck = function (c) { if (!c) throw TypeError('invalid argument'); }; -const fengari_argcheckinteger = function (n) { +export const fengari_argcheckinteger = function (n) { fengari_argcheck(typeof n === 'number' && (n | 0) === n); }; -const isvalid = function (o) { - return o !== luaO_nilobject; +export const isvalid = function (o) { + return o !== lobject.luaO_nilobject; }; -const lua_version = function (L) { - if (L === null) return LUA_VERSION_NUM; +export const lua_version = function (L) { + if (L === null) return defs.LUA_VERSION_NUM; else return L.l_G.version; }; -const lua_atpanic = function (L, panicf) { +export const lua_atpanic = function (L, panicf) { let old = L.l_G.panic; L.l_G.panic = panicf; return old; }; -const lua_atnativeerror = function (L, errorf) { +export const lua_atnativeerror = function (L, errorf) { let old = L.l_G.atnativeerror; L.l_G.atnativeerror = errorf; return old; }; // Return value for idx on stack -const index2addr = function (L, idx) { +export const index2addr = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); - if (o >= L.top) return luaO_nilobject; + llimits.api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); + if (o >= L.top) return lobject.luaO_nilobject; else return L.stack[o]; - } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); + } else if (idx > defs.LUA_REGISTRYINDEX) { + llimits.api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); return L.stack[L.top + idx]; - } else if (idx === LUA_REGISTRYINDEX) { + } else if (idx === defs.LUA_REGISTRYINDEX) { return L.l_G.l_registry; } else { /* upvalues */ - idx = LUA_REGISTRYINDEX - idx; - api_check(L, idx <= MAXUPVAL + 1, 'upvalue index too large'); + idx = defs.LUA_REGISTRYINDEX - idx; + llimits.api_check(L, idx <= lfunc.MAXUPVAL + 1, 'upvalue index too large'); if (ci.func.ttislcf()) /* light C function? */ - return luaO_nilobject; /* it has no upvalues */ + return lobject.luaO_nilobject; /* it has no upvalues */ else { - return idx <= ci.func.value.nupvalues ? ci.func.value.upvalue[idx - 1] : luaO_nilobject; + return idx <= ci.func.value.nupvalues ? ci.func.value.upvalue[idx - 1] : lobject.luaO_nilobject; } } }; // Like index2addr but returns the index on stack; doesn't allow pseudo indices -const index2addr_ = function (L, idx) { +export const index2addr_ = function (L, idx) { let ci = L.ci; if (idx > 0) { let o = ci.funcOff + idx; - api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); + llimits.api_check(L, idx <= ci.top - (ci.funcOff + 1), 'unacceptable index'); if (o >= L.top) return null; else return o; - } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); + } else if (idx > defs.LUA_REGISTRYINDEX) { + llimits.api_check(L, idx !== 0 && -idx <= L.top, 'invalid index'); return L.top + idx; } else { /* registry or upvalue */ throw Error('attempt to use pseudo-index'); } }; -const lua_checkstack = function (L, n) { +export const lua_checkstack = function (L, n) { let res; let ci = L.ci; - api_check(L, n >= 0, 'negative \'n\''); + llimits.api_check(L, n >= 0, 'negative \'n\''); if (L.stack_last - L.top > n) /* stack large enough? */ res = true; else { /* no; need to grow stack */ - let inuse = L.top + EXTRA_STACK; - if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */ + let inuse = L.top + lstate.EXTRA_STACK; + if (inuse > common.LUAI_MAXSTACK - n) /* can grow without overflow? */ res = false; /* no */ else { /* try to grow stack */ - luaD_growstack(L, n); + ldo.luaD_growstack(L, n); res = true; } } @@ -136,15 +134,15 @@ const lua_checkstack = function (L, n) { return res; }; -const lua_xmove = function (from, to, n) { +export const lua_xmove = function (from, to, n) { if (from === to) return; api_checknelems(from, n); - api_check(from, from.l_G === to.l_G, 'moving among independent states'); - api_check(from, to.ci.top - to.top >= n, 'stack overflow'); + llimits.api_check(from, from.l_G === to.l_G, 'moving among independent states'); + llimits.api_check(from, to.ci.top - to.top >= n, 'stack overflow'); from.top -= n; for (let i = 0; i < n; i++) { - to.stack[to.top] = new _TValue(); - setobj2s(to, to.top, from.stack[from.top + i]); + to.stack[to.top] = new lobject.TValue(); + lobject.setobj2s(to, to.top, from.stack[from.top + i]); delete from.stack[from.top + i]; to.top++; } @@ -157,44 +155,44 @@ const lua_xmove = function (from, to, n) { /* ** convert an acceptable stack index into an absolute index */ -const lua_absindex = function (L, idx) { - return (idx > 0 || idx <= LUA_REGISTRYINDEX) +export const lua_absindex = function (L, idx) { + return (idx > 0 || idx <= defs.LUA_REGISTRYINDEX) ? idx : (L.top - L.ci.funcOff) + idx; }; -const lua_gettop = function (L) { +export const lua_gettop = function (L) { return L.top - (L.ci.funcOff + 1); }; -const lua_pushvalue = function (L, idx) { - pushobj2s(L, index2addr(L, idx)); - api_check(L, L.top <= L.ci.top, 'stack overflow'); +export const lua_pushvalue = function (L, idx) { + lobject.pushobj2s(L, index2addr(L, idx)); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); }; -const lua_settop = function (L, idx) { +export const lua_settop = function (L, idx) { let func = L.ci.funcOff; let newtop; if (idx >= 0) { - api_check(L, idx <= L.stack_last - (func + 1), 'new top too large'); + llimits.api_check(L, idx <= L.stack_last - (func + 1), 'new top too large'); newtop = func + 1 + idx; } else { - api_check(L, -(idx + 1) <= L.top - (func + 1), 'invalid new top'); + llimits.api_check(L, -(idx + 1) <= L.top - (func + 1), 'invalid new top'); newtop = L.top + idx + 1; /* 'subtract' index (index is negative) */ } - adjust_top(L, newtop); + ldo.adjust_top(L, newtop); }; -const lua_pop = function (L, n) { +export const lua_pop = function (L, n) { lua_settop(L, -n - 1); }; -const reverse = function (L, from, to) { +export const reverse = function (L, from, to) { for (; from < to; from++, to--) { let fromtv = L.stack[from]; - let temp = new TValue(fromtv.type, fromtv.value); - setobjs2s(L, from, to); - setobj2s(L, to, temp); + let temp = new lobject.TValue(fromtv.type, fromtv.value); + lobject.setobjs2s(L, from, to); + lobject.setobj2s(L, to, temp); } }; @@ -202,33 +200,33 @@ const reverse = function (L, from, to) { ** Let x = AB, where A is a prefix of length 'n'. Then, ** rotate x n === BA. But BA === (A^r . B^r)^r. */ -const lua_rotate = function (L, idx, n) { +export const lua_rotate = function (L, idx, n) { let t = L.top - 1; let pIdx = index2addr_(L, idx); let p = L.stack[pIdx]; - api_check(L, isvalid(p) && idx > LUA_REGISTRYINDEX, 'index not in the stack'); - api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), 'invalid \'n\''); + llimits.api_check(L, isvalid(p) && idx > defs.LUA_REGISTRYINDEX, 'index not in the stack'); + llimits.api_check(L, (n >= 0 ? n : -n) <= (t - pIdx + 1), 'invalid \'n\''); let m = n >= 0 ? t - n : pIdx - n - 1; /* end of prefix */ reverse(L, pIdx, m); reverse(L, m + 1, L.top - 1); reverse(L, pIdx, L.top - 1); }; -const lua_copy = function (L, fromidx, toidx) { +export const lua_copy = function (L, fromidx, toidx) { let from = index2addr(L, fromidx); index2addr(L, toidx).setfrom(from); }; -const lua_remove = function (L, idx) { +export const lua_remove = function (L, idx) { lua_rotate(L, idx, -1); lua_pop(L, 1); }; -const lua_insert = function (L, idx) { +export const lua_insert = function (L, idx) { lua_rotate(L, idx, 1); }; -const lua_replace = function (L, idx) { +export const lua_replace = function (L, idx) { lua_copy(L, -1, idx); lua_pop(L, 1); }; @@ -237,87 +235,87 @@ const lua_replace = function (L, idx) { ** push functions (JS -> stack) */ -const lua_pushnil = function (L) { - L.stack[L.top] = new TValue(LUA_TNIL, null); +export const lua_pushnil = function (L) { + L.stack[L.top] = new lobject.TValue(LUA_TNIL, null); api_incr_top(L); }; -const lua_pushnumber = function (L, n) { +export const lua_pushnumber = function (L, n) { fengari_argcheck(typeof n === 'number'); - L.stack[L.top] = new TValue(LUA_TNUMFLT, n); + L.stack[L.top] = new lobject.TValue(LUA_TNUMFLT, n); api_incr_top(L); }; -const lua_pushinteger = function (L, n) { +export const lua_pushinteger = function (L, n) { fengari_argcheckinteger(n); - L.stack[L.top] = new TValue(LUA_TNUMINT, n); + L.stack[L.top] = new lobject.TValue(LUA_TNUMINT, n); api_incr_top(L); }; -const lua_pushlstring = function (L, s, len) { +export const lua_pushlstring = function (L, s, len) { fengari_argcheckinteger(len); let ts; if (len === 0) { - s = to_luastring('', true); - ts = luaS_bless(L, s); + s = defs.to_luastring('', true); + ts = lstring.luaS_bless(L, s); } else { - s = from_userstring(s); - api_check(L, s.length >= len, 'invalid length to lua_pushlstring'); - ts = luaS_new(L, s.subarray(0, len)); + s = defs.from_userstring(s); + llimits.api_check(L, s.length >= len, 'invalid length to lua_pushlstring'); + ts = lstring.luaS_new(L, s.subarray(0, len)); } - pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + lobject.pushsvalue2s(L, ts); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); return ts.value; }; -const lua_pushstring = function (L, s) { +export const lua_pushstring = function (L, s) { if (s === undefined || s === null) { - L.stack[L.top] = new TValue(LUA_TNIL, null); + L.stack[L.top] = new lobject.TValue(LUA_TNIL, null); L.top++; } else { - let ts = luaS_new(L, from_userstring(s)); - pushsvalue2s(L, ts); + let ts = lstring.luaS_new(L, defs.from_userstring(s)); + lobject.pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, 'stack overflow'); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); return s; }; -const lua_pushvfstring = function (L, fmt, argp) { - fmt = from_userstring(fmt); - return luaO_pushvfstring(L, fmt, argp); +export const lua_pushvfstring = function (L, fmt, argp) { + fmt = defs.from_userstring(fmt); + return lobject.luaO_pushvfstring(L, fmt, argp); }; -const lua_pushfstring = function (L, fmt, ...argp) { - fmt = from_userstring(fmt); - return luaO_pushvfstring(L, fmt, argp); +export const lua_pushfstring = function (L, fmt, ...argp) { + fmt = defs.from_userstring(fmt); + return lobject.luaO_pushvfstring(L, fmt, argp); }; /* Similar to lua_pushstring, but takes a JS string */ -const lua_pushliteral = function (L, s) { +export const lua_pushliteral = function (L, s) { if (s === undefined || s === null) { - L.stack[L.top] = new TValue(LUA_TNIL, null); + L.stack[L.top] = new lobject.TValue(LUA_TNIL, null); L.top++; } else { fengari_argcheck(typeof s === 'string'); - let ts = luaS_newliteral(L, s); - pushsvalue2s(L, ts); + let ts = lstring.luaS_newliteral(L, s); + lobject.pushsvalue2s(L, ts); s = ts.getstr(); /* internal copy */ } - api_check(L, L.top <= L.ci.top, 'stack overflow'); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); return s; }; -const lua_pushcclosure = function (L, fn, n) { +export const lua_pushcclosure = function (L, fn, n) { fengari_argcheck(typeof fn === 'function'); fengari_argcheckinteger(n); if (n === 0) - L.stack[L.top] = new TValue(LUA_TLCF, fn); + L.stack[L.top] = new lobject.TValue(LUA_TLCF, fn); else { api_checknelems(L, n); - api_check(L, n <= MAXUPVAL, 'upvalue index too large'); - let cl = new CClosure(L, fn, n); + llimits.api_check(L, n <= lfunc.MAXUPVAL, 'upvalue index too large'); + let cl = new lobject.CClosure(L, fn, n); for (let i = 0; i < n; i++) cl.upvalue[i].setfrom(L.stack[L.top - n + i]); for (let i = 1; i < n; i++) @@ -329,32 +327,32 @@ const lua_pushcclosure = function (L, fn, n) { api_incr_top(L); }; -const lua_pushjsclosure = lua_pushcclosure; +export const lua_pushjsclosure = lua_pushcclosure; -const lua_pushcfunction = function (L, fn) { +export const lua_pushcfunction = function (L, fn) { lua_pushcclosure(L, fn, 0); }; -const lua_pushjsfunction = lua_pushcfunction; +export const lua_pushjsfunction = lua_pushcfunction; -const lua_pushboolean = function (L, b) { - L.stack[L.top] = new TValue(LUA_TBOOLEAN, !!b); +export const lua_pushboolean = function (L, b) { + L.stack[L.top] = new lobject.TValue(LUA_TBOOLEAN, !!b); api_incr_top(L); }; -const lua_pushlightuserdata = function (L, p) { - L.stack[L.top] = new TValue(LUA_TLIGHTUSERDATA, p); +export const lua_pushlightuserdata = function (L, p) { + L.stack[L.top] = new lobject.TValue(LUA_TLIGHTUSERDATA, p); api_incr_top(L); }; -const lua_pushthread = function (L) { - L.stack[L.top] = new TValue(LUA_TTHREAD, L); +export const lua_pushthread = function (L) { + L.stack[L.top] = new lobject.TValue(LUA_TTHREAD, L); api_incr_top(L); return L.l_G.mainthread === L; }; -const lua_pushglobaltable = function (L) { - lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); +export const lua_pushglobaltable = function (L) { + lua_rawgeti(L, defs.LUA_REGISTRYINDEX, defs.LUA_RIDX_GLOBALS); }; /* @@ -364,29 +362,29 @@ const lua_pushglobaltable = function (L) { /* ** t[k] = value at the top of the stack (where 'k' is a string) */ -const auxsetstr = function (L, t, k) { - let str = luaS_new(L, from_userstring(k)); +export const auxsetstr = function (L, t, k) { + let str = lstring.luaS_new(L, defs.from_userstring(k)); api_checknelems(L, 1); - pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ - api_check(L, L.top <= L.ci.top, 'stack overflow'); - settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); + lobject.pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); + lvm.settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_setglobal = function (L, name) { - auxsetstr(L, luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS), name); +export const lua_setglobal = function (L, name) { + auxsetstr(L, ltable.luaH_getint(L.l_G.l_registry.value, defs.LUA_RIDX_GLOBALS), name); }; -const lua_setmetatable = function (L, objindex) { +export const lua_setmetatable = function (L, objindex) { api_checknelems(L, 1); let mt; let obj = index2addr(L, objindex); if (L.stack[L.top - 1].ttisnil()) mt = null; else { - api_check(L, L.stack[L.top - 1].ttistable(), 'table expected'); + llimits.api_check(L, L.stack[L.top - 1].ttistable(), 'table expected'); mt = L.stack[L.top - 1].value; } @@ -406,58 +404,58 @@ const lua_setmetatable = function (L, objindex) { return true; }; -const lua_settable = function (L, idx) { +export const lua_settable = function (L, idx) { api_checknelems(L, 2); let t = index2addr(L, idx); - settable(L, t, L.stack[L.top - 2], L.stack[L.top - 1]); + lvm.settable(L, t, L.stack[L.top - 2], L.stack[L.top - 1]); delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_setfield = function (L, idx, k) { +export const lua_setfield = function (L, idx, k) { auxsetstr(L, index2addr(L, idx), k); }; -const lua_seti = function (L, idx, n) { +export const lua_seti = function (L, idx, n) { fengari_argcheckinteger(n); api_checknelems(L, 1); let t = index2addr(L, idx); - L.stack[L.top] = new TValue(LUA_TNUMINT, n); + L.stack[L.top] = new lobject.TValue(LUA_TNUMINT, n); api_incr_top(L); - settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); + lvm.settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_rawset = function (L, idx) { +export const lua_rawset = function (L, idx) { api_checknelems(L, 2); let o = index2addr(L, idx); - api_check(L, o.ttistable(), 'table expected'); + llimits.api_check(L, o.ttistable(), 'table expected'); let k = L.stack[L.top - 2]; let v = L.stack[L.top - 1]; - luaH_setfrom(L, o.value, k, v); - invalidateTMcache(o.value); + ltable.luaH_setfrom(L, o.value, k, v); + ltable.invalidateTMcache(o.value); delete L.stack[--L.top]; delete L.stack[--L.top]; }; -const lua_rawseti = function (L, idx, n) { +export const lua_rawseti = function (L, idx, n) { fengari_argcheckinteger(n); api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), 'table expected'); - luaH_setint(o.value, n, L.stack[L.top - 1]); + llimits.api_check(L, o.ttistable(), 'table expected'); + ltable.luaH_setint(o.value, n, L.stack[L.top - 1]); delete L.stack[--L.top]; }; -const lua_rawsetp = function (L, idx, p) { +export const lua_rawsetp = function (L, idx, p) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttistable(), 'table expected'); - let k = new TValue(LUA_TLIGHTUSERDATA, p); + llimits.api_check(L, o.ttistable(), 'table expected'); + let k = new lobject.TValue(LUA_TLIGHTUSERDATA, p); let v = L.stack[L.top - 1]; - luaH_setfrom(L, o.value, k, v); + ltable.luaH_setfrom(L, o.value, k, v); delete L.stack[--L.top]; }; @@ -465,65 +463,65 @@ const lua_rawsetp = function (L, idx, p) { ** get functions (Lua -> stack) */ -const auxgetstr = function (L, t, k) { - let str = luaS_new(L, from_userstring(k)); - pushsvalue2s(L, str); - api_check(L, L.top <= L.ci.top, 'stack overflow'); - luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); +export const auxgetstr = function (L, t, k) { + let str = lstring.luaS_new(L, defs.from_userstring(k)); + lobject.pushsvalue2s(L, str); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); + lvm.luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; -const lua_rawgeti = function (L, idx, n) { +export const lua_rawgeti = function (L, idx, n) { let t = index2addr(L, idx); fengari_argcheckinteger(n); - api_check(L, t.ttistable(), 'table expected'); - pushobj2s(L, luaH_getint(t.value, n)); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + llimits.api_check(L, t.ttistable(), 'table expected'); + lobject.pushobj2s(L, ltable.luaH_getint(t.value, n)); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); return L.stack[L.top - 1].ttnov(); }; -const lua_rawgetp = function (L, idx, p) { +export const lua_rawgetp = function (L, idx, p) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), 'table expected'); - let k = new TValue(LUA_TLIGHTUSERDATA, p); - pushobj2s(L, luaH_get(L, t.value, k)); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + llimits.api_check(L, t.ttistable(), 'table expected'); + let k = new lobject.TValue(LUA_TLIGHTUSERDATA, p); + lobject.pushobj2s(L, ltable.luaH_get(L, t.value, k)); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); return L.stack[L.top - 1].ttnov(); }; -const lua_rawget = function (L, idx) { +export const lua_rawget = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(t), 'table expected'); - setobj2s(L, L.top - 1, luaH_get(L, t.value, L.stack[L.top - 1])); + llimits.api_check(L, t.ttistable(t), 'table expected'); + lobject.setobj2s(L, L.top - 1, ltable.luaH_get(L, t.value, L.stack[L.top - 1])); return L.stack[L.top - 1].ttnov(); }; // narray and nrec are mostly useless for this implementation -const lua_createtable = function (L, narray, nrec) { - let t = new _TValue(LUA_TTABLE, luaH_new(L)); +export const lua_createtable = function (L, _narray, _nrec) { + let t = new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L)); L.stack[L.top] = t; api_incr_top(L); }; -const luaS_newudata = function (L, size) { - return new Udata(L, size); +export const luaS_newudata = function (L, size) { + return new lobject.Udata(L, size); }; -const lua_newuserdata = function (L, size) { +export const lua_newuserdata = function (L, size) { let u = luaS_newudata(L, size); - L.stack[L.top] = new _TValue(LUA_TUSERDATA, u); + L.stack[L.top] = new lobject.TValue(LUA_TUSERDATA, u); api_incr_top(L); return u.data; }; -const aux_upvalue = function (L, fi, n) { +export const aux_upvalue = function (L, fi, n) { fengari_argcheckinteger(n); switch (fi.ttype()) { case LUA_TCCL: { /* C closure */ let f = fi.value; if (!(1 <= n && n <= f.nupvalues)) return null; return { - name: to_luastring('', true), + name: defs.to_luastring('', true), val: f.upvalue[n - 1] }; } @@ -533,7 +531,7 @@ const aux_upvalue = function (L, fi, n) { if (!(1 <= n && n <= p.upvalues.length)) return null; let name = p.upvalues[n - 1].name; return { - name: name ? name.getstr() : to_luastring('(*no name)', true), + name: name ? name.getstr() : defs.to_luastring('(*no name)', true), val: f.upvals[n - 1] }; } @@ -541,19 +539,19 @@ const aux_upvalue = function (L, fi, n) { } }; -const lua_getupvalue = function (L, funcindex, n) { +export const lua_getupvalue = function (L, funcindex, n) { let up = aux_upvalue(L, index2addr(L, funcindex), n); if (up) { let name = up.name; let val = up.val; - pushobj2s(L, val); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + lobject.pushobj2s(L, val); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); return name; } return null; }; -const lua_setupvalue = function (L, funcindex, n) { +export const lua_setupvalue = function (L, funcindex, n) { let fi = index2addr(L, funcindex); api_checknelems(L, 1); let aux = aux_upvalue(L, fi, n); @@ -567,16 +565,16 @@ const lua_setupvalue = function (L, funcindex, n) { return null; }; -const lua_newtable = function (L) { +export const lua_newtable = function (L) { lua_createtable(L, 0, 0); }; -const lua_register = function (L, n, f) { +export const lua_register = function (L, n, f) { lua_pushcfunction(L, f); lua_setglobal(L, n); }; -const lua_getmetatable = function (L, objindex) { +export const lua_getmetatable = function (L, objindex) { let obj = index2addr(L, objindex); let mt; let res = false; @@ -591,7 +589,7 @@ const lua_getmetatable = function (L, objindex) { } if (mt !== null && mt !== undefined) { - L.stack[L.top] = new TValue(LUA_TTABLE, mt); + L.stack[L.top] = new lobject.TValue(LUA_TTABLE, mt); api_incr_top(L); res = true; } @@ -599,79 +597,79 @@ const lua_getmetatable = function (L, objindex) { return res; }; -const lua_getuservalue = function (L, idx) { +export const lua_getuservalue = function (L, idx) { let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), 'full userdata expected'); + llimits.api_check(L, o.ttisfulluserdata(), 'full userdata expected'); let uv = o.value.uservalue; - L.stack[L.top] = new TValue(uv.type, uv.value); + L.stack[L.top] = new lobject.TValue(uv.type, uv.value); api_incr_top(L); return L.stack[L.top - 1].ttnov(); }; -const lua_gettable = function (L, idx) { +export const lua_gettable = function (L, idx) { let t = index2addr(L, idx); - luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); + lvm.luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; -const lua_getfield = function (L, idx, k) { +export const lua_getfield = function (L, idx, k) { return auxgetstr(L, index2addr(L, idx), k); }; -const lua_geti = function (L, idx, n) { +export const lua_geti = function (L, idx, n) { let t = index2addr(L, idx); fengari_argcheckinteger(n); - L.stack[L.top] = new TValue(LUA_TNUMINT, n); + L.stack[L.top] = new lobject.TValue(LUA_TNUMINT, n); api_incr_top(L); - luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); + lvm.luaV_gettable(L, t, L.stack[L.top - 1], L.top - 1); return L.stack[L.top - 1].ttnov(); }; -const lua_getglobal = function (L, name) { - return auxgetstr(L, luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS), name); +export const lua_getglobal = function (L, name) { + return auxgetstr(L, ltable.luaH_getint(L.l_G.l_registry.value, defs.LUA_RIDX_GLOBALS), name); }; /* ** access functions (stack -> JS) */ -const lua_toboolean = function (L, idx) { +export const lua_toboolean = function (L, idx) { let o = index2addr(L, idx); return !o.l_isfalse(); }; -const lua_tolstring = function (L, idx) { +export const lua_tolstring = function (L, idx) { let o = index2addr(L, idx); if (!o.ttisstring()) { - if (!cvt2str(o)) { /* not convertible? */ + if (!lvm.cvt2str(o)) { /* not convertible? */ return null; } - luaO_tostring(L, o); + lobject.luaO_tostring(L, o); } return o.svalue(); }; -const lua_tostring = lua_tolstring; +export const lua_tostring = lua_tolstring; -const lua_tojsstring = function (L, idx) { +export const lua_tojsstring = function (L, idx) { let o = index2addr(L, idx); if (!o.ttisstring()) { - if (!cvt2str(o)) { /* not convertible? */ + if (!lvm.cvt2str(o)) { /* not convertible? */ return null; } - luaO_tostring(L, o); + lobject.luaO_tostring(L, o); } return o.jsstring(); }; -const lua_todataview = function (L, idx) { +export const lua_todataview = function (L, idx) { let u8 = lua_tolstring(L, idx); return new DataView(u8.buffer, u8.byteOffset, u8.byteLength); }; -const lua_rawlen = function (L, idx) { +export const lua_rawlen = function (L, idx) { let o = index2addr(L, idx); switch (o.ttype()) { case LUA_TSHRSTR: @@ -680,37 +678,37 @@ const lua_rawlen = function (L, idx) { case LUA_TUSERDATA: return o.value.len; case LUA_TTABLE: - return luaH_getn(o.value); + return ltable.luaH_getn(o.value); default: return 0; } }; -const lua_tocfunction = function (L, idx) { +export const lua_tocfunction = function (L, idx) { let o = index2addr(L, idx); if (o.ttislcf() || o.ttisCclosure()) return o.value; else return null; /* not a C function */ }; -const lua_tointeger = function (L, idx) { +export const lua_tointeger = function (L, idx) { let n = lua_tointegerx(L, idx); return n === false ? 0 : n; }; -const lua_tointegerx = function (L, idx) { - return tointeger(index2addr(L, idx)); +export const lua_tointegerx = function (L, idx) { + return lvm.tointeger(index2addr(L, idx)); }; -const lua_tonumber = function (L, idx) { +export const lua_tonumber = function (L, idx) { let n = lua_tonumberx(L, idx); return n === false ? 0 : n; }; -const lua_tonumberx = function (L, idx) { - return tonumber(index2addr(L, idx)); +export const lua_tonumberx = function (L, idx) { + return lvm.tonumber(index2addr(L, idx)); }; -const lua_touserdata = function (L, idx) { +export const lua_touserdata = function (L, idx) { let o = index2addr(L, idx); switch (o.ttnov()) { case LUA_TUSERDATA: @@ -721,12 +719,12 @@ const lua_touserdata = function (L, idx) { } }; -const lua_tothread = function (L, idx) { +export const lua_tothread = function (L, idx) { let o = index2addr(L, idx); return o.ttisthread() ? o.value : null; }; -const lua_topointer = function (L, idx) { +export const lua_topointer = function (L, idx) { let o = index2addr(L, idx); switch (o.ttype()) { case LUA_TTABLE: @@ -746,10 +744,10 @@ const lua_topointer = function (L, idx) { /* A proxy is a function that the same lua value to the given lua state. */ /* Having a weakmap of created proxies was only way I could think of to provide an 'isproxy' function */ -const seen = new WeakMap(); +export const seen = new WeakMap(); /* is the passed object a proxy? is it from the given state? (if passed) */ -const lua_isproxy = function (p, L) { +export const lua_isproxy = function (p, L) { let G = seen.get(p); if (!G) return false; @@ -757,24 +755,24 @@ const lua_isproxy = function (p, L) { }; /* Use 'create_proxy' helper function so that 'L' is not in scope */ -const create_proxy = function (G, type, value) { +export const create_proxy = function (G, type, value) { let proxy = function (L) { - api_check(L, L instanceof lua_State && G === L.l_G, 'must be from same global state'); - L.stack[L.top] = new TValue(type, value); + llimits.api_check(L, L instanceof lstate.lua_State && G === L.l_G, 'must be from same global state'); + L.stack[L.top] = new lobject.TValue(type, value); api_incr_top(L); }; seen.set(proxy, G); return proxy; }; -const lua_toproxy = function (L, idx) { +export const lua_toproxy = function (L, idx) { let tv = index2addr(L, idx); /* pass broken down tv incase it is an upvalue index */ return create_proxy(L.l_G, tv.type, tv.value); }; -const lua_compare = function (L, index1, index2, op) { +export const lua_compare = function (L, index1, index2, op) { let o1 = index2addr(L, index1); let o2 = index2addr(L, index2); @@ -782,19 +780,19 @@ const lua_compare = function (L, index1, index2, op) { if (isvalid(o1) && isvalid(o2)) { switch (op) { - case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; - case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; - case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; - default: api_check(L, false, 'invalid option'); + case defs.LUA_OPEQ: i = lvm.luaV_equalobj(L, o1, o2); break; + case defs.LUA_OPLT: i = lvm.luaV_lessthan(L, o1, o2); break; + case defs.LUA_OPLE: i = lvm.luaV_lessequal(L, o1, o2); break; + default: llimits.api_check(L, false, 'invalid option'); } } return i; }; -const lua_stringtonumber = function (L, s) { - let tv = new TValue(); - let sz = luaO_str2num(s, tv); +export const lua_stringtonumber = function (L, s) { + let tv = new lobject.TValue(); + let sz = lobject.luaO_str2num(s, tv); if (sz !== 0) { L.stack[L.top] = tv; api_incr_top(L); @@ -802,91 +800,91 @@ const lua_stringtonumber = function (L, s) { return sz; }; -const f_call = function (L, ud) { - luaD_callnoyield(L, ud.funcOff, ud.nresults); +export const f_call = function (L, ud) { + ldo.luaD_callnoyield(L, ud.funcOff, ud.nresults); }; -const lua_type = function (L, idx) { +export const lua_type = function (L, idx) { let o = index2addr(L, idx); return isvalid(o) ? o.ttnov() : LUA_TNONE; }; -const lua_typename = function (L, t) { - api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, 'invalid tag'); - return ttypename(t); +export const lua_typename = function (L, t) { + llimits.api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, 'invalid tag'); + return ltm.ttypename(t); }; -const lua_iscfunction = function (L, idx) { +export const lua_iscfunction = function (L, idx) { let o = index2addr(L, idx); return o.ttislcf(o) || o.ttisCclosure(); }; -const lua_isnil = function (L, n) { +export const lua_isnil = function (L, n) { return lua_type(L, n) === LUA_TNIL; }; -const lua_isboolean = function (L, n) { +export const lua_isboolean = function (L, n) { return lua_type(L, n) === LUA_TBOOLEAN; }; -const lua_isnone = function (L, n) { +export const lua_isnone = function (L, n) { return lua_type(L, n) === LUA_TNONE; }; -const lua_isnoneornil = function (L, n) { +export const lua_isnoneornil = function (L, n) { return lua_type(L, n) <= 0; }; -const lua_istable = function (L, idx) { +export const lua_istable = function (L, idx) { return index2addr(L, idx).ttistable(); }; -const lua_isinteger = function (L, idx) { +export const lua_isinteger = function (L, idx) { return index2addr(L, idx).ttisinteger(); }; -const lua_isnumber = function (L, idx) { - return tonumber(index2addr(L, idx)) !== false; +export const lua_isnumber = function (L, idx) { + return lvm.tonumber(index2addr(L, idx)) !== false; }; -const lua_isstring = function (L, idx) { +export const lua_isstring = function (L, idx) { let o = index2addr(L, idx); - return o.ttisstring() || cvt2str(o); + return o.ttisstring() || lvm.cvt2str(o); }; -const lua_isuserdata = function (L, idx) { +export const lua_isuserdata = function (L, idx) { let o = index2addr(L, idx); return o.ttisfulluserdata(o) || o.ttislightuserdata(); }; -const lua_isthread = function (L, idx) { +export const lua_isthread = function (L, idx) { return lua_type(L, idx) === LUA_TTHREAD; }; -const lua_isfunction = function (L, idx) { +export const lua_isfunction = function (L, idx) { return lua_type(L, idx) === LUA_TFUNCTION; }; -const lua_islightuserdata = function (L, idx) { +export const lua_islightuserdata = function (L, idx) { return lua_type(L, idx) === LUA_TLIGHTUSERDATA; }; -const lua_rawequal = function (L, index1, index2) { +export const lua_rawequal = function (L, index1, index2) { let o1 = index2addr(L, index1); let o2 = index2addr(L, index2); - return isvalid(o1) && isvalid(o2) ? luaV_equalobj(null, o1, o2) : 0; + return isvalid(o1) && isvalid(o2) ? lvm.luaV_equalobj(null, o1, o2) : 0; }; -const lua_arith = function (L, op) { - if (op !== LUA_OPUNM && op !== LUA_OPBNOT) +export const lua_arith = function (L, op) { + if (op !== defs.LUA_OPUNM && op !== defs.LUA_OPBNOT) api_checknelems(L, 2); /* all other operations expect two operands */ else { /* for unary operations, add fake 2nd operand */ api_checknelems(L, 1); - pushobj2s(L, L.stack[L.top - 1]); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + lobject.pushobj2s(L, L.stack[L.top - 1]); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); } /* first operand at top - 2, second at top - 1; result go to top - 2 */ - luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); + lobject.luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); delete L.stack[--L.top]; /* remove second operand */ }; @@ -894,18 +892,18 @@ const lua_arith = function (L, op) { ** 'load' and 'call' functions (run Lua code) */ -const default_chunkname = to_luastring('?'); -const lua_load = function (L, reader, data, chunkname, mode) { +export const default_chunkname = defs.to_luastring('?'); +export const lua_load = function (L, reader, data, chunkname, mode) { if (!chunkname) chunkname = default_chunkname; - else chunkname = from_userstring(chunkname); - if (mode !== null) mode = from_userstring(mode); - let z = new ZIO(L, reader, data); - let status = luaD_protectedparser(L, z, chunkname, mode); + else chunkname = defs.from_userstring(chunkname); + if (mode !== null) mode = defs.from_userstring(mode); + let z = new lzio.ZIO(L, reader, data); + let status = ldo.luaD_protectedparser(L, z, chunkname, mode); if (status === LUA_OK) { /* no errors? */ let f = L.stack[L.top - 1].value; /* get newly created function */ if (f.nupvalues >= 1) { /* does it have an upvalue? */ /* get global table from registry */ - let gt = luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS); + let gt = ltable.luaH_getint(L.l_G.l_registry.value, defs.LUA_RIDX_GLOBALS); /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ f.upvals[0].setfrom(gt); } @@ -913,57 +911,57 @@ const lua_load = function (L, reader, data, chunkname, mode) { return status; }; -const lua_dump = function (L, writer, data, strip) { +export const lua_dump = function (L, writer, data, strip) { api_checknelems(L, 1); let o = L.stack[L.top - 1]; if (o.ttisLclosure()) - return luaU_dump(L, o.value.p, writer, data, strip); + return ldump.luaU_dump(L, o.value.p, writer, data, strip); return 1; }; -const lua_status = function (L) { +export const lua_status = function (L) { return L.status; }; -const lua_setuservalue = function (L, idx) { +export const lua_setuservalue = function (L, idx) { api_checknelems(L, 1); let o = index2addr(L, idx); - api_check(L, o.ttisfulluserdata(), 'full userdata expected'); + llimits.api_check(L, o.ttisfulluserdata(), 'full userdata expected'); o.value.uservalue.setfrom(L.stack[L.top - 1]); delete L.stack[--L.top]; }; -const checkresults = function (L, na, nr) { - api_check(L, nr === LUA_MULTRET || (L.ci.top - L.top >= (nr) - (na)), +export const checkresults = function (L, na, nr) { + llimits.api_check(L, nr === defs.LUA_MULTRET || (L.ci.top - L.top >= (nr) - (na)), 'results from function overflow current stack size'); }; -const lua_callk = function (L, nargs, nresults, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); +export const lua_callk = function (L, nargs, nresults, ctx, k) { + llimits.api_check(L, k === null || !(L.ci.callstatus & lstate.CIST_LUA), 'cannot use continuations inside hooks'); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); + llimits.api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); checkresults(L, nargs, nresults); let func = L.top - (nargs + 1); if (k !== null && L.nny === 0) { /* need to prepare continuation? */ L.ci.c_k = k; L.ci.c_ctx = ctx; - luaD_call(L, func, nresults); + ldo.luaD_call(L, func, nresults); } else { /* no continuation or no yieldable */ - luaD_callnoyield(L, func, nresults); + ldo.luaD_callnoyield(L, func, nresults); } - if (nresults === LUA_MULTRET && L.ci.top < L.top) + if (nresults === defs.LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top; }; -const lua_call = function (L, n, r) { +export const lua_call = function (L, n, r) { lua_callk(L, n, r, 0, null); }; -const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { - api_check(L, k === null || !(L.ci.callstatus & CIST_LUA), 'cannot use continuations inside hooks'); +export const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { + llimits.api_check(L, k === null || !(L.ci.callstatus & lstate.CIST_LUA), 'cannot use continuations inside hooks'); api_checknelems(L, nargs + 1); - api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); + llimits.api_check(L, L.status === LUA_OK, 'cannot do calls on non-normal thread'); checkresults(L, nargs, nresults); let status; let func; @@ -978,7 +976,7 @@ const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { funcOff: funcOff, nresults: nresults /* do a 'conventional' protected call */ }; - status = luaD_pcall(L, f_call, c, funcOff, func); + status = ldo.luaD_pcall(L, f_call, c, funcOff, func); } else { /* prepare continuation (call is already protected by 'resume') */ let ci = L.ci; ci.c_k = k; /* prepare continuation (call is already protected by 'resume') */ @@ -987,21 +985,21 @@ const lua_pcallk = function (L, nargs, nresults, errfunc, ctx, k) { ci.extra = funcOff; ci.c_old_errfunc = L.errfunc; L.errfunc = func; - ci.callstatus &= ~CIST_OAH | L.allowhook; - ci.callstatus |= CIST_YPCALL; /* function can do error recovery */ - luaD_call(L, funcOff, nresults); /* do the call */ - ci.callstatus &= ~CIST_YPCALL; + ci.callstatus &= ~lstate.CIST_OAH | L.allowhook; + ci.callstatus |= lstate.CIST_YPCALL; /* function can do error recovery */ + ldo.luaD_call(L, funcOff, nresults); /* do the call */ + ci.callstatus &= ~lstate.CIST_YPCALL; L.errfunc = ci.c_old_errfunc; status = LUA_OK; } - if (nresults === LUA_MULTRET && L.ci.top < L.top) + if (nresults === defs.LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top; return status; }; -const lua_pcall = function (L, n, r, f) { +export const lua_pcall = function (L, n, r, f) { return lua_pcallk(L, n, r, f, 0, null); }; @@ -1009,16 +1007,16 @@ const lua_pcall = function (L, n, r, f) { ** miscellaneous functions */ -const lua_error = function (L) { +export const lua_error = function (L) { api_checknelems(L, 1); - luaG_errormsg(L); + ldebug.luaG_errormsg(L); }; -const lua_next = function (L, idx) { +export const lua_next = function (L, idx) { let t = index2addr(L, idx); - api_check(L, t.ttistable(), 'table expected'); - L.stack[L.top] = new TValue(); - let more = luaH_next(L, t.value, L.top - 1); + llimits.api_check(L, t.ttistable(), 'table expected'); + L.stack[L.top] = new lobject.TValue(); + let more = ltable.luaH_next(L, t.value, L.top - 1); if (more) { api_incr_top(L); return 1; @@ -1029,37 +1027,37 @@ const lua_next = function (L, idx) { } }; -const lua_concat = function (L, n) { +export const lua_concat = function (L, n) { api_checknelems(L, n); if (n >= 2) - luaV_concat(L, n); + lvm.luaV_concat(L, n); else if (n === 0) { - pushsvalue2s(L, luaS_bless(L, to_luastring('', true))); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + lobject.pushsvalue2s(L, lstring.luaS_bless(L, defs.to_luastring('', true))); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); } }; -const lua_len = function (L, idx) { +export const lua_len = function (L, idx) { let t = index2addr(L, idx); - let tv = new TValue(); - luaV_objlen(L, tv, t); + let tv = new lobject.TValue(); + lvm.luaV_objlen(L, tv, t); L.stack[L.top] = tv; api_incr_top(L); }; -const getupvalref = function (L, fidx, n) { +export const getupvalref = function (L, fidx, n) { let fi = index2addr(L, fidx); - api_check(L, fi.ttisLclosure(), 'Lua function expected'); + llimits.api_check(L, fi.ttisLclosure(), 'Lua function expected'); let f = fi.value; fengari_argcheckinteger(n); - api_check(L, 1 <= n && n <= f.p.upvalues.length, 'invalid upvalue index'); + llimits.api_check(L, 1 <= n && n <= f.p.upvalues.length, 'invalid upvalue index'); return { f: f, i: n - 1 }; }; -const lua_upvalueid = function (L, fidx, n) { +export const lua_upvalueid = function (L, fidx, n) { let fi = index2addr(L, fidx); switch (fi.ttype()) { case LUA_TLCL: { /* lua closure */ @@ -1068,17 +1066,17 @@ const lua_upvalueid = function (L, fidx, n) { } case LUA_TCCL: { /* C closure */ let f = fi.value; - api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, 'invalid upvalue index'); + llimits.api_check(L, (n | 0) === n && n > 0 && n <= f.nupvalues, 'invalid upvalue index'); return f.upvalue[n - 1]; } default: { - api_check(L, false, 'closure expected'); + llimits.api_check(L, false, 'closure expected'); return null; } } }; -const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { +export const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { let ref1 = getupvalref(L, fidx1, n1); let ref2 = getupvalref(L, fidx2, n2); let up2 = ref2.f.upvals[ref2.i]; @@ -1086,238 +1084,19 @@ const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { }; // This functions are only there for compatibility purposes -const lua_gc = function () { }; +export const lua_gc = function () { }; -const lua_getallocf = function () { +export const lua_getallocf = function () { console.warn('lua_getallocf is not available'); return 0; }; -const lua_setallocf = function () { +export const lua_setallocf = function () { console.warn('lua_setallocf is not available'); return 0; }; -const lua_getextraspace = function () { +export const lua_getextraspace = function () { console.warn('lua_getextraspace is not available'); return 0; }; - -const _api_incr_top = api_incr_top; -export { _api_incr_top as api_incr_top }; -const _api_checknelems = api_checknelems; -export { _api_checknelems as api_checknelems }; -const _lua_absindex = lua_absindex; -export { _lua_absindex as lua_absindex }; -const _lua_arith = lua_arith; -export { _lua_arith as lua_arith }; -const _lua_atpanic = lua_atpanic; -export { _lua_atpanic as lua_atpanic }; -const _lua_atnativeerror = lua_atnativeerror; -export { _lua_atnativeerror as lua_atnativeerror }; -const _lua_call = lua_call; -export { _lua_call as lua_call }; -const _lua_callk = lua_callk; -export { _lua_callk as lua_callk }; -const _lua_checkstack = lua_checkstack; -export { _lua_checkstack as lua_checkstack }; -const _lua_compare = lua_compare; -export { _lua_compare as lua_compare }; -const _lua_concat = lua_concat; -export { _lua_concat as lua_concat }; -const _lua_copy = lua_copy; -export { _lua_copy as lua_copy }; -const _lua_createtable = lua_createtable; -export { _lua_createtable as lua_createtable }; -const _lua_dump = lua_dump; -export { _lua_dump as lua_dump }; -const _lua_error = lua_error; -export { _lua_error as lua_error }; -const _lua_gc = lua_gc; -export { _lua_gc as lua_gc }; -const _lua_getallocf = lua_getallocf; -export { _lua_getallocf as lua_getallocf }; -const _lua_getextraspace = lua_getextraspace; -export { _lua_getextraspace as lua_getextraspace }; -const _lua_getfield = lua_getfield; -export { _lua_getfield as lua_getfield }; -const _lua_getglobal = lua_getglobal; -export { _lua_getglobal as lua_getglobal }; -const _lua_geti = lua_geti; -export { _lua_geti as lua_geti }; -const _lua_getmetatable = lua_getmetatable; -export { _lua_getmetatable as lua_getmetatable }; -const _lua_gettable = lua_gettable; -export { _lua_gettable as lua_gettable }; -const _lua_gettop = lua_gettop; -export { _lua_gettop as lua_gettop }; -const _lua_getupvalue = lua_getupvalue; -export { _lua_getupvalue as lua_getupvalue }; -const _lua_getuservalue = lua_getuservalue; -export { _lua_getuservalue as lua_getuservalue }; -const _lua_insert = lua_insert; -export { _lua_insert as lua_insert }; -const _lua_isboolean = lua_isboolean; -export { _lua_isboolean as lua_isboolean }; -const _lua_iscfunction = lua_iscfunction; -export { _lua_iscfunction as lua_iscfunction }; -const _lua_isfunction = lua_isfunction; -export { _lua_isfunction as lua_isfunction }; -const _lua_isinteger = lua_isinteger; -export { _lua_isinteger as lua_isinteger }; -const _lua_islightuserdata = lua_islightuserdata; -export { _lua_islightuserdata as lua_islightuserdata }; -const _lua_isnil = lua_isnil; -export { _lua_isnil as lua_isnil }; -const _lua_isnone = lua_isnone; -export { _lua_isnone as lua_isnone }; -const _lua_isnoneornil = lua_isnoneornil; -export { _lua_isnoneornil as lua_isnoneornil }; -const _lua_isnumber = lua_isnumber; -export { _lua_isnumber as lua_isnumber }; -const _lua_isproxy = lua_isproxy; -export { _lua_isproxy as lua_isproxy }; -const _lua_isstring = lua_isstring; -export { _lua_isstring as lua_isstring }; -const _lua_istable = lua_istable; -export { _lua_istable as lua_istable }; -const _lua_isthread = lua_isthread; -export { _lua_isthread as lua_isthread }; -const _lua_isuserdata = lua_isuserdata; -export { _lua_isuserdata as lua_isuserdata }; -const _lua_len = lua_len; -export { _lua_len as lua_len }; -const _lua_load = lua_load; -export { _lua_load as lua_load }; -const _lua_newtable = lua_newtable; -export { _lua_newtable as lua_newtable }; -const _lua_newuserdata = lua_newuserdata; -export { _lua_newuserdata as lua_newuserdata }; -const _lua_next = lua_next; -export { _lua_next as lua_next }; -const _lua_pcall = lua_pcall; -export { _lua_pcall as lua_pcall }; -const _lua_pcallk = lua_pcallk; -export { _lua_pcallk as lua_pcallk }; -const _lua_pop = lua_pop; -export { _lua_pop as lua_pop }; -const _lua_pushboolean = lua_pushboolean; -export { _lua_pushboolean as lua_pushboolean }; -const _lua_pushcclosure = lua_pushcclosure; -export { _lua_pushcclosure as lua_pushcclosure }; -const _lua_pushcfunction = lua_pushcfunction; -export { _lua_pushcfunction as lua_pushcfunction }; -const _lua_pushfstring = lua_pushfstring; -export { _lua_pushfstring as lua_pushfstring }; -const _lua_pushglobaltable = lua_pushglobaltable; -export { _lua_pushglobaltable as lua_pushglobaltable }; -const _lua_pushinteger = lua_pushinteger; -export { _lua_pushinteger as lua_pushinteger }; -const _lua_pushjsclosure = lua_pushjsclosure; -export { _lua_pushjsclosure as lua_pushjsclosure }; -const _lua_pushjsfunction = lua_pushjsfunction; -export { _lua_pushjsfunction as lua_pushjsfunction }; -const _lua_pushlightuserdata = lua_pushlightuserdata; -export { _lua_pushlightuserdata as lua_pushlightuserdata }; -const _lua_pushliteral = lua_pushliteral; -export { _lua_pushliteral as lua_pushliteral }; -const _lua_pushlstring = lua_pushlstring; -export { _lua_pushlstring as lua_pushlstring }; -const _lua_pushnil = lua_pushnil; -export { _lua_pushnil as lua_pushnil }; -const _lua_pushnumber = lua_pushnumber; -export { _lua_pushnumber as lua_pushnumber }; -const _lua_pushstring = lua_pushstring; -export { _lua_pushstring as lua_pushstring }; -const _lua_pushthread = lua_pushthread; -export { _lua_pushthread as lua_pushthread }; -const _lua_pushvalue = lua_pushvalue; -export { _lua_pushvalue as lua_pushvalue }; -const _lua_pushvfstring = lua_pushvfstring; -export { _lua_pushvfstring as lua_pushvfstring }; -const _lua_rawequal = lua_rawequal; -export { _lua_rawequal as lua_rawequal }; -const _lua_rawget = lua_rawget; -export { _lua_rawget as lua_rawget }; -const _lua_rawgeti = lua_rawgeti; -export { _lua_rawgeti as lua_rawgeti }; -const _lua_rawgetp = lua_rawgetp; -export { _lua_rawgetp as lua_rawgetp }; -const _lua_rawlen = lua_rawlen; -export { _lua_rawlen as lua_rawlen }; -const _lua_rawset = lua_rawset; -export { _lua_rawset as lua_rawset }; -const _lua_rawseti = lua_rawseti; -export { _lua_rawseti as lua_rawseti }; -const _lua_rawsetp = lua_rawsetp; -export { _lua_rawsetp as lua_rawsetp }; -const _lua_register = lua_register; -export { _lua_register as lua_register }; -const _lua_remove = lua_remove; -export { _lua_remove as lua_remove }; -const _lua_replace = lua_replace; -export { _lua_replace as lua_replace }; -const _lua_rotate = lua_rotate; -export { _lua_rotate as lua_rotate }; -const _lua_setallocf = lua_setallocf; -export { _lua_setallocf as lua_setallocf }; -const _lua_setfield = lua_setfield; -export { _lua_setfield as lua_setfield }; -const _lua_setglobal = lua_setglobal; -export { _lua_setglobal as lua_setglobal }; -const _lua_seti = lua_seti; -export { _lua_seti as lua_seti }; -const _lua_setmetatable = lua_setmetatable; -export { _lua_setmetatable as lua_setmetatable }; -const _lua_settable = lua_settable; -export { _lua_settable as lua_settable }; -const _lua_settop = lua_settop; -export { _lua_settop as lua_settop }; -const _lua_setupvalue = lua_setupvalue; -export { _lua_setupvalue as lua_setupvalue }; -const _lua_setuservalue = lua_setuservalue; -export { _lua_setuservalue as lua_setuservalue }; -const _lua_status = lua_status; -export { _lua_status as lua_status }; -const _lua_stringtonumber = lua_stringtonumber; -export { _lua_stringtonumber as lua_stringtonumber }; -const _lua_toboolean = lua_toboolean; -export { _lua_toboolean as lua_toboolean }; -const _lua_tocfunction = lua_tocfunction; -export { _lua_tocfunction as lua_tocfunction }; -const _lua_todataview = lua_todataview; -export { _lua_todataview as lua_todataview }; -const _lua_tointeger = lua_tointeger; -export { _lua_tointeger as lua_tointeger }; -const _lua_tointegerx = lua_tointegerx; -export { _lua_tointegerx as lua_tointegerx }; -const _lua_tojsstring = lua_tojsstring; -export { _lua_tojsstring as lua_tojsstring }; -const _lua_tolstring = lua_tolstring; -export { _lua_tolstring as lua_tolstring }; -const _lua_tonumber = lua_tonumber; -export { _lua_tonumber as lua_tonumber }; -const _lua_tonumberx = lua_tonumberx; -export { _lua_tonumberx as lua_tonumberx }; -const _lua_topointer = lua_topointer; -export { _lua_topointer as lua_topointer }; -const _lua_toproxy = lua_toproxy; -export { _lua_toproxy as lua_toproxy }; -const _lua_tostring = lua_tostring; -export { _lua_tostring as lua_tostring }; -const _lua_tothread = lua_tothread; -export { _lua_tothread as lua_tothread }; -const _lua_touserdata = lua_touserdata; -export { _lua_touserdata as lua_touserdata }; -const _lua_type = lua_type; -export { _lua_type as lua_type }; -const _lua_typename = lua_typename; -export { _lua_typename as lua_typename }; -const _lua_upvalueid = lua_upvalueid; -export { _lua_upvalueid as lua_upvalueid }; -const _lua_upvaluejoin = lua_upvaluejoin; -export { _lua_upvaluejoin as lua_upvaluejoin }; -const _lua_version = lua_version; -export { _lua_version as lua_version }; -const _lua_xmove = lua_xmove; -export { _lua_xmove as lua_xmove }; diff --git a/src/lauxlib.js b/src/lauxlib.js index c2dd39db..8aa7b9a0 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -1,27 +1,28 @@ -import { LUAL_BUFFERSIZE } from './luaconf.js'; -import { LUA_ERRERR, LUA_MULTRET, LUA_REGISTRYINDEX, LUA_SIGNATURE, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_VERSION_NUM, lua_Debug, lua_absindex, lua_atpanic, lua_call, lua_checkstack, lua_concat, lua_copy, lua_createtable, lua_error, lua_getfield, lua_getinfo, lua_getmetatable, lua_getstack, lua_gettop, lua_insert, lua_isinteger, lua_isnil, lua_isnumber, lua_isstring, lua_istable, lua_len, lua_load, lua_newstate, lua_newtable, lua_next, lua_pcall, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawlen, lua_rawseti, lua_remove, lua_setfield, lua_setglobal, lua_setmetatable, lua_settop, lua_toboolean, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_tostring, lua_touserdata, lua_type, lua_typename, lua_version } from './lua.js'; -import { from_userstring, luastring_eq, to_luastring, to_uristring } from './fengaricore.js'; -import fs from 'fs'; +import * as luaconf from './luaconf.js'; +import * as lua from './lua.js'; +import * as fengaricore from './fengaricore.js'; + +const fs = typeof process === 'undefined' ? null : require('fs'); /* Only used in node env */ /* extra error code for 'luaL_loadfilex' */ -const LUA_ERRFILE = LUA_ERRERR + 1; +export const LUA_ERRFILE = lua.LUA_ERRERR + 1; /* key, in the registry, for table of loaded modules */ -const LUA_LOADED_TABLE = to_luastring('_LOADED'); +export const LUA_LOADED_TABLE = fengaricore.to_luastring('_LOADED'); /* key, in the registry, for table of preloaded loaders */ -const LUA_PRELOAD_TABLE = to_luastring('_PRELOAD'); +export const LUA_PRELOAD_TABLE = fengaricore.to_luastring('_PRELOAD'); -const LUA_FILEHANDLE = to_luastring('FILE*'); +export const LUA_FILEHANDLE = fengaricore.to_luastring('FILE*'); -const LUAL_NUMSIZES = 4 * 16 + 8; +export const LUAL_NUMSIZES = 4 * 16 + 8; -const __name = to_luastring('__name'); -const __tostring = to_luastring('__tostring'); +export const __name = fengaricore.to_luastring('__name'); +export const __tostring = fengaricore.to_luastring('__tostring'); -const empty = new Uint8Array(0); +export const empty = new Uint8Array(0); -class luaL_Buffer { +export class luaL_Buffer { constructor() { this.L = null; this.b = empty; @@ -29,33 +30,33 @@ class luaL_Buffer { } } -const LEVELS1 = 10; /* size of the first part of the stack */ -const LEVELS2 = 11; /* size of the second part of the stack */ +export const LEVELS1 = 10; /* size of the first part of the stack */ +export const LEVELS2 = 11; /* size of the second part of the stack */ /* ** search for 'objidx' in table at index -1. ** return 1 + string at top if find a good name. */ -const findfield = function (L, objidx, level) { - if (level === 0 || !lua_istable(L, -1)) +export const findfield = function (L, objidx, level) { + if (level === 0 || !lua.lua_istable(L, -1)) return 0; /* not found */ - lua_pushnil(L); /* start 'next' loop */ + lua.lua_pushnil(L); /* start 'next' loop */ - while (lua_next(L, -2)) { /* for each pair in table */ - if (lua_type(L, -2) === LUA_TSTRING) { /* ignore non-string keys */ - if (lua_rawequal(L, objidx, -1)) { /* found object? */ - lua_pop(L, 1); /* remove value (but keep name) */ + while (lua.lua_next(L, -2)) { /* for each pair in table */ + if (lua.lua_type(L, -2) === lua.LUA_TSTRING) { /* ignore non-string keys */ + if (lua.lua_rawequal(L, objidx, -1)) { /* found object? */ + lua.lua_pop(L, 1); /* remove value (but keep name) */ return 1; } else if (findfield(L, objidx, level - 1)) { /* try recursively */ - lua_remove(L, -2); /* remove table (but keep name) */ - lua_pushliteral(L, '.'); - lua_insert(L, -2); /* place '.' between the two names */ - lua_concat(L, 3); + lua.lua_remove(L, -2); /* remove table (but keep name) */ + lua.lua_pushliteral(L, '.'); + lua.lua_insert(L, -2); /* place '.' between the two names */ + lua.lua_concat(L, 3); return 1; } } - lua_pop(L, 1); /* remove value */ + lua.lua_pop(L, 1); /* remove value */ } return 0; /* not found */ @@ -64,150 +65,150 @@ const findfield = function (L, objidx, level) { /* ** Search for a name for a function in all loaded modules */ -const pushglobalfuncname = function (L, ar) { - let top = lua_gettop(L); - lua_getinfo(L, to_luastring('f'), ar); /* push function */ - lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); +export const pushglobalfuncname = function (L, ar) { + let top = lua.lua_gettop(L); + lua.lua_getinfo(L, fengaricore.to_luastring('f'), ar); /* push function */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, LUA_LOADED_TABLE); if (findfield(L, top + 1, 2)) { - let name = lua_tostring(L, -1); + let name = lua.lua_tostring(L, -1); if (name[0] === 95 /* '_'.charCodeAt(0) */ && name[1] === 71 /* 'G'.charCodeAt(0) */ && name[2] === 46 /* '.'.charCodeAt(0) */ ) { /* name start with '_G.'? */ - lua_pushstring(L, name.subarray(3)); /* push name without prefix */ - lua_remove(L, -2); /* remove original name */ + lua.lua_pushstring(L, name.subarray(3)); /* push name without prefix */ + lua.lua_remove(L, -2); /* remove original name */ } - lua_copy(L, -1, top + 1); /* move name to proper place */ - lua_pop(L, 2); /* remove pushed values */ + lua.lua_copy(L, -1, top + 1); /* move name to proper place */ + lua.lua_pop(L, 2); /* remove pushed values */ return 1; } else { - lua_settop(L, top); /* remove function and global table */ + lua.lua_settop(L, top); /* remove function and global table */ return 0; } }; -const pushfuncname = function (L, ar) { +export const pushfuncname = function (L, ar) { if (pushglobalfuncname(L, ar)) { /* try first a global name */ - lua_pushfstring(L, to_luastring('function \'%s\''), lua_tostring(L, -1)); - lua_remove(L, -2); /* remove name */ + lua.lua_pushfstring(L, fengaricore.to_luastring('function \'%s\''), lua.lua_tostring(L, -1)); + lua.lua_remove(L, -2); /* remove name */ } else if (ar.namewhat.length !== 0) /* is there a name from code? */ - lua_pushfstring(L, to_luastring('%s \'%s\''), ar.namewhat, ar.name); /* use it */ + lua.lua_pushfstring(L, fengaricore.to_luastring('%s \'%s\''), ar.namewhat, ar.name); /* use it */ else if (ar.what && ar.what[0] === 109 /* 'm'.charCodeAt(0) */) /* main? */ - lua_pushliteral(L, 'main chunk'); + lua.lua_pushliteral(L, 'main chunk'); else if (ar.what && ar.what[0] === 76 /* 'L'.charCodeAt(0) */) /* for Lua functions, use */ - lua_pushfstring(L, to_luastring('function <%s:%d>'), ar.short_src, ar.linedefined); + lua.lua_pushfstring(L, fengaricore.to_luastring('function <%s:%d>'), ar.short_src, ar.linedefined); else /* nothing left... */ - lua_pushliteral(L, '?'); + lua.lua_pushliteral(L, '?'); }; -const lastlevel = function (L) { - let ar = new lua_Debug(); +export const lastlevel = function (L) { + let ar = new lua.lua_Debug(); let li = 1; let le = 1; /* find an upper bound */ - while (lua_getstack(L, le, ar)) { li = le; le *= 2; } + while (lua.lua_getstack(L, le, ar)) { li = le; le *= 2; } /* do a binary search */ while (li < le) { let m = Math.floor((li + le) / 2); - if (lua_getstack(L, m, ar)) li = m + 1; + if (lua.lua_getstack(L, m, ar)) li = m + 1; else le = m; } return le - 1; }; -const luaL_traceback = function (L, L1, msg, level) { - let ar = new lua_Debug(); - let top = lua_gettop(L); +export const luaL_traceback = function (L, L1, msg, level) { + let ar = new lua.lua_Debug(); + let top = lua.lua_gettop(L); let last = lastlevel(L1); let n1 = last - level > LEVELS1 + LEVELS2 ? LEVELS1 : -1; if (msg) - lua_pushfstring(L, to_luastring('%s\n'), msg); + lua.lua_pushfstring(L, fengaricore.to_luastring('%s\n'), msg); luaL_checkstack(L, 10, null); - lua_pushliteral(L, 'stack traceback:'); - while (lua_getstack(L1, level++, ar)) { + lua.lua_pushliteral(L, 'stack traceback:'); + while (lua.lua_getstack(L1, level++, ar)) { if (n1-- === 0) { /* too many levels? */ - lua_pushliteral(L, '\n\t...'); /* add a '...' */ + lua.lua_pushliteral(L, '\n\t...'); /* add a '...' */ level = last - LEVELS2 + 1; /* and skip to last ones */ } else { - lua_getinfo(L1, to_luastring('Slnt', true), ar); - lua_pushfstring(L, to_luastring('\n\t%s:'), ar.short_src); + lua.lua_getinfo(L1, fengaricore.to_luastring('Slnt', true), ar); + lua.lua_pushfstring(L, fengaricore.to_luastring('\n\t%s:'), ar.short_src); if (ar.currentline > 0) - lua_pushliteral(L, `${ar.currentline}:`); - lua_pushliteral(L, ' in '); + lua.lua_pushliteral(L, `${ar.currentline}:`); + lua.lua_pushliteral(L, ' in '); pushfuncname(L, ar); if (ar.istailcall) - lua_pushliteral(L, '\n\t(...tail calls..)'); - lua_concat(L, lua_gettop(L) - top); + lua.lua_pushliteral(L, '\n\t(...tail calls..)'); + lua.lua_concat(L, lua.lua_gettop(L) - top); } } - lua_concat(L, lua_gettop(L) - top); + lua.lua_concat(L, lua.lua_gettop(L) - top); }; -const panic = function (L) { - let msg = 'PANIC: unprotected error in call to Lua API (' + lua_tojsstring(L, -1) + ')'; +export const panic = function (L) { + let msg = 'PANIC: unprotected error in call to Lua API (' + lua.lua_tojsstring(L, -1) + ')'; throw new Error(msg); }; -const luaL_argerror = function (L, arg, extramsg) { - let ar = new lua_Debug(); +export const luaL_argerror = function (L, arg, extramsg) { + let ar = new lua.lua_Debug(); - if (!lua_getstack(L, 0, ar)) /* no stack frame? */ - return luaL_error(L, to_luastring('bad argument #%d (%s)'), arg, extramsg); + if (!lua.lua_getstack(L, 0, ar)) /* no stack frame? */ + return luaL_error(L, fengaricore.to_luastring('bad argument #%d (%s)'), arg, extramsg); - lua_getinfo(L, to_luastring('n'), ar); + lua.lua_getinfo(L, fengaricore.to_luastring('n'), ar); - if (luastring_eq(ar.namewhat, to_luastring('method'))) { + if (fengaricore.luastring_eq(ar.namewhat, fengaricore.to_luastring('method'))) { arg--; /* do not count 'self' */ if (arg === 0) /* error is in the self argument itself? */ - return luaL_error(L, to_luastring('calling \'%s\' on bad self (%s)'), ar.name, extramsg); + return luaL_error(L, fengaricore.to_luastring('calling \'%s\' on bad self (%s)'), ar.name, extramsg); } if (ar.name === null) - ar.name = pushglobalfuncname(L, ar) ? lua_tostring(L, -1) : to_luastring('?'); + ar.name = pushglobalfuncname(L, ar) ? lua.lua_tostring(L, -1) : fengaricore.to_luastring('?'); - return luaL_error(L, to_luastring('bad argument #%d to \'%s\' (%s)'), arg, ar.name, extramsg); + return luaL_error(L, fengaricore.to_luastring('bad argument #%d to \'%s\' (%s)'), arg, ar.name, extramsg); }; -const typeerror = function (L, arg, tname) { +export const typeerror = function (L, arg, tname) { let typearg; - if (luaL_getmetafield(L, arg, __name) === LUA_TSTRING) - typearg = lua_tostring(L, -1); - else if (lua_type(L, arg) === LUA_TLIGHTUSERDATA) - typearg = to_luastring('light userdata', true); + if (luaL_getmetafield(L, arg, __name) === lua.LUA_TSTRING) + typearg = lua.lua_tostring(L, -1); + else if (lua.lua_type(L, arg) === lua.LUA_TLIGHTUSERDATA) + typearg = fengaricore.to_luastring('light userdata', true); else typearg = luaL_typename(L, arg); - let msg = lua_pushfstring(L, to_luastring('%s expected, got %s'), tname, typearg); + let msg = lua.lua_pushfstring(L, fengaricore.to_luastring('%s expected, got %s'), tname, typearg); return luaL_argerror(L, arg, msg); }; -const luaL_where = function (L, level) { - let ar = new lua_Debug(); - if (lua_getstack(L, level, ar)) { - lua_getinfo(L, to_luastring('Sl', true), ar); +export const luaL_where = function (L, level) { + let ar = new lua.lua_Debug(); + if (lua.lua_getstack(L, level, ar)) { + lua.lua_getinfo(L, fengaricore.to_luastring('Sl', true), ar); if (ar.currentline > 0) { - lua_pushfstring(L, to_luastring('%s:%d: '), ar.short_src, ar.currentline); + lua.lua_pushfstring(L, fengaricore.to_luastring('%s:%d: '), ar.short_src, ar.currentline); return; } } - lua_pushstring(L, to_luastring('')); + lua.lua_pushstring(L, fengaricore.to_luastring('')); }; -const luaL_error = function (L, fmt, ...argp) { +export const luaL_error = function (L, fmt, ...argp) { luaL_where(L, 1); - lua_pushvfstring(L, fmt, argp); - lua_concat(L, 2); - return lua_error(L); + lua.lua_pushvfstring(L, fmt, argp); + lua.lua_concat(L, 2); + return lua.lua_error(L); }; /* Unlike normal lua, we pass in an error object */ -const luaL_fileresult = function (L, stat, fname, e) { +export const luaL_fileresult = function (L, stat, fname, e) { if (stat) { - lua_pushboolean(L, 1); + lua.lua_pushboolean(L, 1); return 1; } else { - lua_pushnil(L); + lua.lua_pushnil(L); let message, errno; if (e) { message = e.message; @@ -217,21 +218,21 @@ const luaL_fileresult = function (L, stat, fname, e) { errno = 0; } if (fname) - lua_pushfstring(L, to_luastring('%s: %s'), fname, to_luastring(message)); + lua.lua_pushfstring(L, fengaricore.to_luastring('%s: %s'), fname, fengaricore.to_luastring(message)); else - lua_pushstring(L, to_luastring(message)); - lua_pushinteger(L, errno); + lua.lua_pushstring(L, fengaricore.to_luastring(message)); + lua.lua_pushinteger(L, errno); return 3; } }; /* Unlike normal lua, we pass in an error object */ -const luaL_execresult = function (L, e) { +export const luaL_execresult = function (L, e) { let what, stat; if (e === null) { - lua_pushboolean(L, 1); - lua_pushliteral(L, 'exit'); - lua_pushinteger(L, 0); + lua.lua_pushboolean(L, 1); + lua.lua_pushliteral(L, 'exit'); + lua.lua_pushinteger(L, 0); return 3; } else if (e.status) { what = 'exit'; @@ -243,137 +244,137 @@ const luaL_execresult = function (L, e) { /* XXX: node seems to have e.errno as a string instead of a number */ return luaL_fileresult(L, 0, null, e); } - lua_pushnil(L); - lua_pushliteral(L, what); - lua_pushinteger(L, stat); + lua.lua_pushnil(L); + lua.lua_pushliteral(L, what); + lua.lua_pushinteger(L, stat); return 3; }; -const luaL_getmetatable = function (L, n) { - return lua_getfield(L, LUA_REGISTRYINDEX, n); +export const luaL_getmetatable = function (L, n) { + return lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, n); }; -const luaL_newmetatable = function (L, tname) { - if (luaL_getmetatable(L, tname) !== LUA_TNIL) /* name already in use? */ +export const luaL_newmetatable = function (L, tname) { + if (luaL_getmetatable(L, tname) !== lua.LUA_TNIL) /* name already in use? */ return 0; /* leave previous value on top, but return 0 */ - lua_pop(L, 1); - lua_createtable(L, 0, 2); /* create metatable */ - lua_pushstring(L, tname); - lua_setfield(L, -2, __name); /* metatable.__name = tname */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + lua.lua_pop(L, 1); + lua.lua_createtable(L, 0, 2); /* create metatable */ + lua.lua_pushstring(L, tname); + lua.lua_setfield(L, -2, __name); /* metatable.__name = tname */ + lua.lua_pushvalue(L, -1); + lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ return 1; }; -const luaL_setmetatable = function (L, tname) { +export const luaL_setmetatable = function (L, tname) { luaL_getmetatable(L, tname); - lua_setmetatable(L, -2); + lua.lua_setmetatable(L, -2); }; -const luaL_testudata = function (L, ud, tname) { - let p = lua_touserdata(L, ud); +export const luaL_testudata = function (L, ud, tname) { + let p = lua.lua_touserdata(L, ud); if (p !== null) { /* value is a userdata? */ - if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + if (lua.lua_getmetatable(L, ud)) { /* does it have a metatable? */ luaL_getmetatable(L, tname); /* get correct metatable */ - if (!lua_rawequal(L, -1, -2)) /* not the same? */ + if (!lua.lua_rawequal(L, -1, -2)) /* not the same? */ p = null; /* value is a userdata with wrong metatable */ - lua_pop(L, 2); /* remove both metatables */ + lua.lua_pop(L, 2); /* remove both metatables */ return p; } } return null; /* value is not a userdata with a metatable */ }; -const luaL_checkudata = function (L, ud, tname) { +export const luaL_checkudata = function (L, ud, tname) { let p = luaL_testudata(L, ud, tname); if (p === null) typeerror(L, ud, tname); return p; }; -const luaL_checkoption = function (L, arg, def, lst) { +export const luaL_checkoption = function (L, arg, def, lst) { let name = def !== null ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); for (let i = 0; lst[i]; i++) - if (luastring_eq(lst[i], name)) + if (fengaricore.luastring_eq(lst[i], name)) return i; - return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring('invalid option \'%s\''), name)); + return luaL_argerror(L, arg, lua.lua_pushfstring(L, fengaricore.to_luastring('invalid option \'%s\''), name)); }; -const tag_error = function (L, arg, tag) { - typeerror(L, arg, lua_typename(L, tag)); +export const tag_error = function (L, arg, tag) { + typeerror(L, arg, lua.lua_typename(L, tag)); }; -const luaL_newstate = function () { - let L = lua_newstate(); - if (L) lua_atpanic(L, panic); +export const luaL_newstate = function () { + let L = lua.lua_newstate(); + if (L) lua.lua_atpanic(L, panic); return L; }; -const luaL_typename = function (L, i) { - return lua_typename(L, lua_type(L, i)); +export const luaL_typename = function (L, i) { + return lua.lua_typename(L, lua.lua_type(L, i)); }; -const luaL_argcheck = function (L, cond, arg, extramsg) { +export const luaL_argcheck = function (L, cond, arg, extramsg) { if (!cond) luaL_argerror(L, arg, extramsg); }; -const luaL_checkany = function (L, arg) { - if (lua_type(L, arg) === LUA_TNONE) - luaL_argerror(L, arg, to_luastring('value expected', true)); +export const luaL_checkany = function (L, arg) { + if (lua.lua_type(L, arg) === lua.LUA_TNONE) + luaL_argerror(L, arg, fengaricore.to_luastring('value expected', true)); }; -const luaL_checktype = function (L, arg, t) { - if (lua_type(L, arg) !== t) +export const luaL_checktype = function (L, arg, t) { + if (lua.lua_type(L, arg) !== t) tag_error(L, arg, t); }; -const luaL_checklstring = function (L, arg) { - let s = lua_tolstring(L, arg); - if (s === null || s === undefined) tag_error(L, arg, LUA_TSTRING); +export const luaL_checklstring = function (L, arg) { + let s = lua.lua_tolstring(L, arg); + if (s === null || s === undefined) tag_error(L, arg, lua.LUA_TSTRING); return s; }; -const luaL_checkstring = luaL_checklstring; +export const luaL_checkstring = luaL_checklstring; -const luaL_optlstring = function (L, arg, def) { - if (lua_type(L, arg) <= 0) { - return def === null ? null : from_userstring(def); +export const luaL_optlstring = function (L, arg, def) { + if (lua.lua_type(L, arg) <= 0) { + return def === null ? null : fengaricore.from_userstring(def); } else return luaL_checklstring(L, arg); }; -const luaL_optstring = luaL_optlstring; +export const luaL_optstring = luaL_optlstring; -const interror = function (L, arg) { - if (lua_isnumber(L, arg)) - luaL_argerror(L, arg, to_luastring('number has no integer representation', true)); +export const interror = function (L, arg) { + if (lua.lua_isnumber(L, arg)) + luaL_argerror(L, arg, fengaricore.to_luastring('number has no integer representation', true)); else - tag_error(L, arg, LUA_TNUMBER); + tag_error(L, arg, lua.LUA_TNUMBER); }; -const luaL_checknumber = function (L, arg) { - let d = lua_tonumberx(L, arg); +export const luaL_checknumber = function (L, arg) { + let d = lua.lua_tonumberx(L, arg); if (d === false) - tag_error(L, arg, LUA_TNUMBER); + tag_error(L, arg, lua.LUA_TNUMBER); return d; }; -const luaL_optnumber = function (L, arg, def) { +export const luaL_optnumber = function (L, arg, def) { return luaL_opt(L, luaL_checknumber, arg, def); }; -const luaL_checkinteger = function (L, arg) { - let d = lua_tointegerx(L, arg); +export const luaL_checkinteger = function (L, arg) { + let d = lua.lua_tointegerx(L, arg); if (d === false) interror(L, arg); return d; }; -const luaL_optinteger = function (L, arg, def) { +export const luaL_optinteger = function (L, arg, def) { return luaL_opt(L, luaL_checkinteger, arg, def); }; -const luaL_prepbuffsize = function (B, sz) { +export const luaL_prepbuffsize = function (B, sz) { let newend = B.n + sz; if (B.b.length < newend) { let newsize = Math.max(B.b.length * 2, newend); /* double buffer size */ @@ -384,159 +385,159 @@ const luaL_prepbuffsize = function (B, sz) { return B.b.subarray(B.n, newend); }; -const luaL_buffinit = function (L, B) { +export const luaL_buffinit = function (L, B) { B.L = L; B.b = empty; }; -const luaL_buffinitsize = function (L, B, sz) { +export const luaL_buffinitsize = function (L, B, sz) { luaL_buffinit(L, B); return luaL_prepbuffsize(B, sz); }; -const luaL_prepbuffer = function (B) { - return luaL_prepbuffsize(B, LUAL_BUFFERSIZE); +export const luaL_prepbuffer = function (B) { + return luaL_prepbuffsize(B, luaconf.LUAL_BUFFERSIZE); }; -const luaL_addlstring = function (B, s, l) { +export const luaL_addlstring = function (B, s, l) { if (l > 0) { - s = from_userstring(s); + s = fengaricore.from_userstring(s); let b = luaL_prepbuffsize(B, l); b.set(s.subarray(0, l)); luaL_addsize(B, l); } }; -const luaL_addstring = function (B, s) { - s = from_userstring(s); +export const luaL_addstring = function (B, s) { + s = fengaricore.from_userstring(s); luaL_addlstring(B, s, s.length); }; -const luaL_pushresult = function (B) { - lua_pushlstring(B.L, B.b, B.n); +export const luaL_pushresult = function (B) { + lua.lua_pushlstring(B.L, B.b, B.n); /* delete old buffer */ B.n = 0; B.b = empty; }; -const luaL_addchar = function (B, c) { +export const luaL_addchar = function (B, c) { luaL_prepbuffsize(B, 1); B.b[B.n++] = c; }; -const luaL_addsize = function (B, s) { +export const luaL_addsize = function (B, s) { B.n += s; }; -const luaL_pushresultsize = function (B, sz) { +export const luaL_pushresultsize = function (B, sz) { luaL_addsize(B, sz); luaL_pushresult(B); }; -const luaL_addvalue = function (B) { +export const luaL_addvalue = function (B) { let L = B.L; - let s = lua_tostring(L, -1); + let s = lua.lua_tostring(L, -1); luaL_addlstring(B, s, s.length); - lua_pop(L, 1); /* remove value */ + lua.lua_pop(L, 1); /* remove value */ }; -const luaL_opt = function (L, f, n, d) { - return lua_type(L, n) <= 0 ? d : f(L, n); +export const luaL_opt = function (L, f, n, d) { + return lua.lua_type(L, n) <= 0 ? d : f(L, n); }; -const getS = function (L, ud) { +export const getS = function (L, ud) { let s = ud.string; ud.string = null; return s; }; -const luaL_loadbufferx = function (L, buff, size, name, mode) { - return lua_load(L, getS, { string: buff }, name, mode); +export const luaL_loadbufferx = function (L, buff, size, name, mode) { + return lua.lua_load(L, getS, { string: buff }, name, mode); }; -const luaL_loadbuffer = function (L, s, sz, n) { +export const luaL_loadbuffer = function (L, s, sz, n) { return luaL_loadbufferx(L, s, sz, n, null); }; -const luaL_loadstring = function (L, s) { +export const luaL_loadstring = function (L, s) { return luaL_loadbuffer(L, s, s.length, s); }; -const luaL_dostring = function (L, s) { - return (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)); +export const luaL_dostring = function (L, s) { + return (luaL_loadstring(L, s) || lua.lua_pcall(L, 0, lua.LUA_MULTRET, 0)); }; -const luaL_getmetafield = function (L, obj, event) { - if (!lua_getmetatable(L, obj)) /* no metatable? */ - return LUA_TNIL; +export const luaL_getmetafield = function (L, obj, event) { + if (!lua.lua_getmetatable(L, obj)) /* no metatable? */ + return lua.LUA_TNIL; else { - lua_pushstring(L, event); - let tt = lua_rawget(L, -2); - if (tt === LUA_TNIL) /* is metafield nil? */ - lua_pop(L, 2); /* remove metatable and metafield */ + lua.lua_pushstring(L, event); + let tt = lua.lua_rawget(L, -2); + if (tt === lua.LUA_TNIL) /* is metafield nil? */ + lua.lua_pop(L, 2); /* remove metatable and metafield */ else - lua_remove(L, -2); /* remove only metatable */ + lua.lua_remove(L, -2); /* remove only metatable */ return tt; /* return metafield type */ } }; -const luaL_callmeta = function (L, obj, event) { - obj = lua_absindex(L, obj); - if (luaL_getmetafield(L, obj, event) === LUA_TNIL) +export const luaL_callmeta = function (L, obj, event) { + obj = lua.lua_absindex(L, obj); + if (luaL_getmetafield(L, obj, event) === lua.LUA_TNIL) return false; - lua_pushvalue(L, obj); - lua_call(L, 1, 1); + lua.lua_pushvalue(L, obj); + lua.lua_call(L, 1, 1); return true; }; -const luaL_len = function (L, idx) { - lua_len(L, idx); - let l = lua_tointegerx(L, -1); +export const luaL_len = function (L, idx) { + lua.lua_len(L, idx); + let l = lua.lua_tointegerx(L, -1); if (l === false) - luaL_error(L, to_luastring('object length is not an integer', true)); - lua_pop(L, 1); /* remove object */ + luaL_error(L, fengaricore.to_luastring('object length is not an integer', true)); + lua.lua_pop(L, 1); /* remove object */ return l; }; -const p_I = to_luastring('%I'); -const p_f = to_luastring('%f'); -const luaL_tolstring = function (L, idx) { +export const p_I = fengaricore.to_luastring('%I'); +export const p_f = fengaricore.to_luastring('%f'); +export const luaL_tolstring = function (L, idx) { if (luaL_callmeta(L, idx, __tostring)) { - if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('\'__tostring\' must return a string')); + if (!lua.lua_isstring(L, -1)) + luaL_error(L, fengaricore.to_luastring('\'__tostring\' must return a string')); } else { - let t = lua_type(L, idx); + let t = lua.lua_type(L, idx); switch (t) { - case LUA_TNUMBER: { - if (lua_isinteger(L, idx)) - lua_pushfstring(L, p_I, lua_tointeger(L, idx)); + case lua.LUA_TNUMBER: { + if (lua.lua_isinteger(L, idx)) + lua.lua_pushfstring(L, p_I, lua.lua_tointeger(L, idx)); else - lua_pushfstring(L, p_f, lua_tonumber(L, idx)); + lua.lua_pushfstring(L, p_f, lua.lua_tonumber(L, idx)); break; } - case LUA_TSTRING: - lua_pushvalue(L, idx); + case lua.LUA_TSTRING: + lua.lua_pushvalue(L, idx); break; - case LUA_TBOOLEAN: - lua_pushliteral(L, (lua_toboolean(L, idx) ? 'true' : 'false')); + case lua.LUA_TBOOLEAN: + lua.lua_pushliteral(L, (lua.lua_toboolean(L, idx) ? 'true' : 'false')); break; - case LUA_TNIL: - lua_pushliteral(L, 'nil'); + case lua.LUA_TNIL: + lua.lua_pushliteral(L, 'nil'); break; default: { let tt = luaL_getmetafield(L, idx, __name); - let kind = tt === LUA_TSTRING ? lua_tostring(L, -1) : luaL_typename(L, idx); - lua_pushfstring(L, to_luastring('%s: %p'), kind, lua_topointer(L, idx)); - if (tt !== LUA_TNIL) - lua_remove(L, -2); + let kind = tt === lua.LUA_TSTRING ? lua.lua_tostring(L, -1) : luaL_typename(L, idx); + lua.lua_pushfstring(L, fengaricore.to_luastring('%s: %p'), kind, lua.lua_topointer(L, idx)); + if (tt !== lua.LUA_TNIL) + lua.lua_remove(L, -2); break; } } } - return lua_tolstring(L, -1); + return lua.lua_tolstring(L, -1); }; /* @@ -545,25 +546,25 @@ const luaL_tolstring = function (L, idx) { ** if 'glb' is true, also registers the result in the global table. ** Leaves resulting module on the top. */ -const luaL_requiref = function (L, modname, openf, glb) { - luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - lua_getfield(L, -1, modname); /* LOADED[modname] */ - if (!lua_toboolean(L, -1)) { /* package not already loaded? */ - lua_pop(L, 1); /* remove field */ - lua_pushcfunction(L, openf); - lua_pushstring(L, modname); /* argument to open function */ - lua_call(L, 1, 1); /* call 'openf' to open module */ - lua_pushvalue(L, -1); /* make copy of module (call result) */ - lua_setfield(L, -3, modname); /* LOADED[modname] = module */ +export const luaL_requiref = function (L, modname, openf, glb) { + luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + lua.lua_getfield(L, -1, modname); /* LOADED[modname] */ + if (!lua.lua_toboolean(L, -1)) { /* package not already loaded? */ + lua.lua_pop(L, 1); /* remove field */ + lua.lua_pushcfunction(L, openf); + lua.lua_pushstring(L, modname); /* argument to open function */ + lua.lua_call(L, 1, 1); /* call 'openf' to open module */ + lua.lua_pushvalue(L, -1); /* make copy of module (call result) */ + lua.lua_setfield(L, -3, modname); /* LOADED[modname] = module */ } - lua_remove(L, -2); /* remove LOADED table */ + lua.lua_remove(L, -2); /* remove LOADED table */ if (glb) { - lua_pushvalue(L, -1); /* copy of module */ - lua_setglobal(L, modname); /* _G[modname] = module */ + lua.lua_pushvalue(L, -1); /* copy of module */ + lua.lua_setglobal(L, modname); /* _G[modname] = module */ } }; -const find_subarray = function (arr, subarr, from_index) { +export const find_subarray = function (arr, subarr, from_index) { var i = from_index >>> 0, sl = subarr.length, l = arr.length + 1 - sl; @@ -577,7 +578,7 @@ const find_subarray = function (arr, subarr, from_index) { return -1; }; -const luaL_gsub = function (L, s, p, r) { +export const luaL_gsub = function (L, s, p, r) { let wild; let b = new luaL_Buffer(); luaL_buffinit(L, b); @@ -588,22 +589,22 @@ const luaL_gsub = function (L, s, p, r) { } luaL_addstring(b, s); /* push last suffix */ luaL_pushresult(b); - return lua_tostring(L, -1); + return lua.lua_tostring(L, -1); }; /* ** ensure that stack[idx][fname] has a table and push that table ** into the stack */ -const luaL_getsubtable = function (L, idx, fname) { - if (lua_getfield(L, idx, fname) === LUA_TTABLE) +export const luaL_getsubtable = function (L, idx, fname) { + if (lua.lua_getfield(L, idx, fname) === lua.LUA_TTABLE) return true; /* table already there */ else { - lua_pop(L, 1); /* remove previous result */ - idx = lua_absindex(L, idx); - lua_newtable(L); - lua_pushvalue(L, -1); /* copy to be left at top */ - lua_setfield(L, idx, fname); /* assign new table to field */ + lua.lua_pop(L, 1); /* remove previous result */ + idx = lua.lua_absindex(L, idx); + lua.lua_newtable(L); + lua.lua_pushvalue(L, -1); /* copy to be left at top */ + lua.lua_setfield(L, idx, fname); /* assign new table to field */ return false; /* false, because did not find table there */ } }; @@ -613,15 +614,15 @@ const luaL_getsubtable = function (L, idx, fname) { ** function gets the 'nup' elements at the top as upvalues. ** Returns with only the table at the stack. */ -const luaL_setfuncs = function (L, l, nup) { - luaL_checkstack(L, nup, to_luastring('too many upvalues', true)); +export const luaL_setfuncs = function (L, l, nup) { + luaL_checkstack(L, nup, fengaricore.to_luastring('too many upvalues', true)); for (let lib in l) { /* fill the table with given functions */ for (let i = 0; i < nup; i++) /* copy upvalues to the top */ - lua_pushvalue(L, -nup); - lua_pushcclosure(L, l[lib], nup); /* closure with those upvalues */ - lua_setfield(L, -(nup + 2), to_luastring(lib)); + lua.lua_pushvalue(L, -nup); + lua.lua_pushcclosure(L, l[lib], nup); /* closure with those upvalues */ + lua.lua_setfield(L, -(nup + 2), fengaricore.to_luastring(lib)); } - lua_pop(L, nup); /* remove upvalues */ + lua.lua_pop(L, nup); /* remove upvalues */ }; /* @@ -631,72 +632,72 @@ const luaL_setfuncs = function (L, l, nup) { ** this extra space, Lua will generate the same 'stack overflow' error, ** but without 'msg'.) */ -const luaL_checkstack = function (L, space, msg) { - if (!lua_checkstack(L, space)) { +export const luaL_checkstack = function (L, space, msg) { + if (!lua.lua_checkstack(L, space)) { if (msg) - luaL_error(L, to_luastring('stack overflow (%s)'), msg); + luaL_error(L, fengaricore.to_luastring('stack overflow (%s)'), msg); else - luaL_error(L, to_luastring('stack overflow', true)); + luaL_error(L, fengaricore.to_luastring('stack overflow', true)); } }; -const luaL_newlibtable = function (L) { - lua_createtable(L); +export const luaL_newlibtable = function (L) { + lua.lua_createtable(L); }; -const luaL_newlib = function (L, l) { - lua_createtable(L); +export const luaL_newlib = function (L, l) { + lua.lua_createtable(L); luaL_setfuncs(L, l, 0); }; /* predefined references */ -const LUA_NOREF = -2; -const LUA_REFNIL = -1; +export const LUA_NOREF = -2; +export const LUA_REFNIL = -1; -const luaL_ref = function (L, t) { +export const luaL_ref = function (L, t) { let ref; - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ + if (lua.lua_isnil(L, -1)) { + lua.lua_pop(L, 1); /* remove from stack */ return LUA_REFNIL; /* 'nil' has a unique fixed reference */ } - t = lua_absindex(L, t); - lua_rawgeti(L, t, 0); /* get first free element */ - ref = lua_tointeger(L, -1); /* ref = t[freelist] */ - lua_pop(L, 1); /* remove it from stack */ + t = lua.lua_absindex(L, t); + lua.lua_rawgeti(L, t, 0); /* get first free element */ + ref = lua.lua_tointeger(L, -1); /* ref = t[freelist] */ + lua.lua_pop(L, 1); /* remove it from stack */ if (ref !== 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, 0); /* (t[freelist] = t[ref]) */ + lua.lua_rawgeti(L, t, ref); /* remove it from list */ + lua.lua_rawseti(L, t, 0); /* (t[freelist] = t[ref]) */ } else /* no free elements */ - ref = lua_rawlen(L, t) + 1; /* get a new reference */ - lua_rawseti(L, t, ref); + ref = lua.lua_rawlen(L, t) + 1; /* get a new reference */ + lua.lua_rawseti(L, t, ref); return ref; }; -const luaL_unref = function (L, t, ref) { +export const luaL_unref = function (L, t, ref) { if (ref >= 0) { - t = lua_absindex(L, t); - lua_rawgeti(L, t, 0); - lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ - lua_pushinteger(L, ref); - lua_rawseti(L, t, 0); /* t[freelist] = ref */ + t = lua.lua_absindex(L, t); + lua.lua_rawgeti(L, t, 0); + lua.lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ + lua.lua_pushinteger(L, ref); + lua.lua_rawseti(L, t, 0); /* t[freelist] = ref */ } }; -const errfile = function (L, what, fnameindex, error) { +export const errfile = function (L, what, fnameindex, error) { let serr = error.message; - let filename = lua_tostring(L, fnameindex).subarray(1); - lua_pushfstring(L, to_luastring('cannot %s %s: %s'), to_luastring(what), filename, to_luastring(serr)); - lua_remove(L, fnameindex); + let filename = lua.lua_tostring(L, fnameindex).subarray(1); + lua.lua_pushfstring(L, fengaricore.to_luastring('cannot %s %s: %s'), fengaricore.to_luastring(what), filename, fengaricore.to_luastring(serr)); + lua.lua_remove(L, fnameindex); return LUA_ERRFILE; }; let getc; -const utf8_bom = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ -const skipBOM = function (lf) { +export const utf8_bom = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ +export const skipBOM = function (lf) { lf.n = 0; let c; let p = 0; @@ -717,7 +718,7 @@ const skipBOM = function (lf) { ** first "valid" character of the file (after the optional BOM and ** a first-line comment). */ -const skipcomment = function (lf) { +export const skipcomment = function (lf) { let c = skipBOM(lf); if (c === 35 /* '#'.charCodeAt(0) */) { /* first line is a comment (Unix exec. file)? */ do { /* skip first line */ @@ -736,7 +737,7 @@ const skipcomment = function (lf) { } }; -let luaL_loadfilex; +export let luaL_loadfilex; if (typeof process === 'undefined') { class LoadF { @@ -770,12 +771,12 @@ if (typeof process === 'undefined') { luaL_loadfilex = function (L, filename, mode) { let lf = new LoadF(); - let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + let fnameindex = lua.lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { throw new Error('Can\'t read stdin in the browser'); } else { - lua_pushfstring(L, to_luastring('@%s'), filename); - let path = to_uristring(filename); + lua.lua_pushfstring(L, fengaricore.to_luastring('@%s'), filename); + let path = fengaricore.to_uristring(filename); let xhr = new XMLHttpRequest(); xhr.open('GET', path, false); /* @@ -788,7 +789,7 @@ if (typeof process === 'undefined') { xhr.send(); if (xhr.status >= 200 && xhr.status <= 299) { if (typeof xhr.response === 'string') { - lf.f = to_luastring(xhr.response); + lf.f = fengaricore.to_luastring(xhr.response); } else { lf.f = new Uint8Array(xhr.response); } @@ -799,20 +800,20 @@ if (typeof process === 'undefined') { } let com = skipcomment(lf); /* check for signature first, as we don't want to add line number corrections in binary case */ - if (com.c === LUA_SIGNATURE[0] && filename) { /* binary file? */ + if (com.c === lua.LUA_SIGNATURE[0] && filename) { /* binary file? */ /* no need to re-open */ } else if (com.skipped) { /* read initial portion */ lf.buff[lf.n++] = 10 /* '\n'.charCodeAt(0) */; /* add line to correct line numbers */ } if (com.c !== null) lf.buff[lf.n++] = com.c; /* 'c' is the first character of the stream */ - let status = lua_load(L, getF, lf, lua_tostring(L, -1), mode); + let status = lua.lua_load(L, getF, lf, lua.lua_tostring(L, -1), mode); let readstatus = lf.err; if (readstatus) { - lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ + lua.lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ return errfile(L, 'read', fnameindex, readstatus); } - lua_remove(L, fnameindex); + lua.lua_remove(L, fnameindex); return status; }; } else { @@ -828,7 +829,7 @@ if (typeof process === 'undefined') { const getF = function (L, ud) { let lf = ud; - let bytes = 0; + let bytes; if (lf.n > 0) { /* are there pre-read characters to be read? */ bytes = lf.n; /* return them (chars already in buffer) */ lf.n = 0; /* no more pre-read characters */ @@ -861,12 +862,12 @@ if (typeof process === 'undefined') { luaL_loadfilex = function (L, filename, mode) { let lf = new LoadF(); - let fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + let fnameindex = lua.lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { - lua_pushliteral(L, '=stdin'); + lua.lua_pushliteral(L, '=stdin'); lf.f = process.stdin.fd; } else { - lua_pushfstring(L, to_luastring('@%s'), filename); + lua.lua_pushfstring(L, fengaricore.to_luastring('@%s'), filename); try { lf.f = fs.openSync(filename, 'r'); } catch (e) { @@ -875,34 +876,34 @@ if (typeof process === 'undefined') { } let com = skipcomment(lf); /* check for signature first, as we don't want to add line number corrections in binary case */ - if (com.c === LUA_SIGNATURE[0] && filename) { /* binary file? */ + if (com.c === lua.LUA_SIGNATURE[0] && filename) { /* binary file? */ /* no need to re-open */ } else if (com.skipped) { /* read initial portion */ lf.buff[lf.n++] = 10 /* '\n'.charCodeAt(0) */; /* add line to correct line numbers */ } if (com.c !== null) lf.buff[lf.n++] = com.c; /* 'c' is the first character of the stream */ - let status = lua_load(L, getF, lf, lua_tostring(L, -1), mode); + let status = lua.lua_load(L, getF, lf, lua.lua_tostring(L, -1), mode); let readstatus = lf.err; if (filename) try { fs.closeSync(lf.f); } catch (e) { } /* close file (even in case of errors) */ if (readstatus) { - lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ + lua.lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ return errfile(L, 'read', fnameindex, readstatus); } - lua_remove(L, fnameindex); + lua.lua_remove(L, fnameindex); return status; }; } -const luaL_loadfile = function (L, filename) { +export const luaL_loadfile = function (L, filename) { return luaL_loadfilex(L, filename, null); }; -const luaL_dofile = function (L, filename) { - return (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0)); +export const luaL_dofile = function (L, filename) { + return (luaL_loadfile(L, filename) || lua.lua_pcall(L, 0, lua.LUA_MULTRET, 0)); }; -const lua_writestringerror = function () { +export const lua_writestringerror = function () { for (let i = 0; i < arguments.length; i++) { let a = arguments[i]; if (typeof process === 'undefined') { @@ -920,152 +921,17 @@ const lua_writestringerror = function () { } }; -const luaL_checkversion_ = function (L, ver, sz) { - let v = lua_version(L); +export const luaL_checkversion_ = function (L, ver, sz) { + let v = lua.lua_version(L); if (sz != LUAL_NUMSIZES) /* check numeric types */ - luaL_error(L, to_luastring('core and library have incompatible numeric types')); - if (v != lua_version(null)) - luaL_error(L, to_luastring('multiple Lua VMs detected')); + luaL_error(L, fengaricore.to_luastring('core and library have incompatible numeric types')); + if (v != lua.lua_version(null)) + luaL_error(L, fengaricore.to_luastring('multiple Lua VMs detected')); else if (v !== ver) - luaL_error(L, to_luastring('version mismatch: app. needs %f, Lua core provides %f'), ver, v); + luaL_error(L, fengaricore.to_luastring('version mismatch: app. needs %f, Lua core provides %f'), ver, v); }; /* There is no point in providing this function... */ -const luaL_checkversion = function (L) { - luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES); -}; - -const _LUA_ERRFILE = LUA_ERRFILE; -export { _LUA_ERRFILE as LUA_ERRFILE }; -const _LUA_FILEHANDLE = LUA_FILEHANDLE; -export { _LUA_FILEHANDLE as LUA_FILEHANDLE }; -const _LUA_LOADED_TABLE = LUA_LOADED_TABLE; -export { _LUA_LOADED_TABLE as LUA_LOADED_TABLE }; -const _LUA_NOREF = LUA_NOREF; -export { _LUA_NOREF as LUA_NOREF }; -const _LUA_PRELOAD_TABLE = LUA_PRELOAD_TABLE; -export { _LUA_PRELOAD_TABLE as LUA_PRELOAD_TABLE }; -const _LUA_REFNIL = LUA_REFNIL; -export { _LUA_REFNIL as LUA_REFNIL }; -const _luaL_Buffer = luaL_Buffer; -export { _luaL_Buffer as luaL_Buffer }; -const _luaL_addchar = luaL_addchar; -export { _luaL_addchar as luaL_addchar }; -const _luaL_addlstring = luaL_addlstring; -export { _luaL_addlstring as luaL_addlstring }; -const _luaL_addsize = luaL_addsize; -export { _luaL_addsize as luaL_addsize }; -const _luaL_addstring = luaL_addstring; -export { _luaL_addstring as luaL_addstring }; -const _luaL_addvalue = luaL_addvalue; -export { _luaL_addvalue as luaL_addvalue }; -const _luaL_argcheck = luaL_argcheck; -export { _luaL_argcheck as luaL_argcheck }; -const _luaL_argerror = luaL_argerror; -export { _luaL_argerror as luaL_argerror }; -const _luaL_buffinit = luaL_buffinit; -export { _luaL_buffinit as luaL_buffinit }; -const _luaL_buffinitsize = luaL_buffinitsize; -export { _luaL_buffinitsize as luaL_buffinitsize }; -const _luaL_callmeta = luaL_callmeta; -export { _luaL_callmeta as luaL_callmeta }; -const _luaL_checkany = luaL_checkany; -export { _luaL_checkany as luaL_checkany }; -const _luaL_checkinteger = luaL_checkinteger; -export { _luaL_checkinteger as luaL_checkinteger }; -const _luaL_checklstring = luaL_checklstring; -export { _luaL_checklstring as luaL_checklstring }; -const _luaL_checknumber = luaL_checknumber; -export { _luaL_checknumber as luaL_checknumber }; -const _luaL_checkoption = luaL_checkoption; -export { _luaL_checkoption as luaL_checkoption }; -const _luaL_checkstack = luaL_checkstack; -export { _luaL_checkstack as luaL_checkstack }; -const _luaL_checkstring = luaL_checkstring; -export { _luaL_checkstring as luaL_checkstring }; -const _luaL_checktype = luaL_checktype; -export { _luaL_checktype as luaL_checktype }; -const _luaL_checkudata = luaL_checkudata; -export { _luaL_checkudata as luaL_checkudata }; -const _luaL_checkversion = luaL_checkversion; -export { _luaL_checkversion as luaL_checkversion }; -const _luaL_checkversion_ = luaL_checkversion_; -export { _luaL_checkversion_ as luaL_checkversion_ }; -const _luaL_dofile = luaL_dofile; -export { _luaL_dofile as luaL_dofile }; -const _luaL_dostring = luaL_dostring; -export { _luaL_dostring as luaL_dostring }; -const _luaL_error = luaL_error; -export { _luaL_error as luaL_error }; -const _luaL_execresult = luaL_execresult; -export { _luaL_execresult as luaL_execresult }; -const _luaL_fileresult = luaL_fileresult; -export { _luaL_fileresult as luaL_fileresult }; -const _luaL_getmetafield = luaL_getmetafield; -export { _luaL_getmetafield as luaL_getmetafield }; -const _luaL_getmetatable = luaL_getmetatable; -export { _luaL_getmetatable as luaL_getmetatable }; -const _luaL_getsubtable = luaL_getsubtable; -export { _luaL_getsubtable as luaL_getsubtable }; -const _luaL_gsub = luaL_gsub; -export { _luaL_gsub as luaL_gsub }; -const _luaL_len = luaL_len; -export { _luaL_len as luaL_len }; -const _luaL_loadbuffer = luaL_loadbuffer; -export { _luaL_loadbuffer as luaL_loadbuffer }; -const _luaL_loadbufferx = luaL_loadbufferx; -export { _luaL_loadbufferx as luaL_loadbufferx }; -const _luaL_loadfile = luaL_loadfile; -export { _luaL_loadfile as luaL_loadfile }; -const _luaL_loadfilex = luaL_loadfilex; -export { _luaL_loadfilex as luaL_loadfilex }; -const _luaL_loadstring = luaL_loadstring; -export { _luaL_loadstring as luaL_loadstring }; -const _luaL_newlib = luaL_newlib; -export { _luaL_newlib as luaL_newlib }; -const _luaL_newlibtable = luaL_newlibtable; -export { _luaL_newlibtable as luaL_newlibtable }; -const _luaL_newmetatable = luaL_newmetatable; -export { _luaL_newmetatable as luaL_newmetatable }; -const _luaL_newstate = luaL_newstate; -export { _luaL_newstate as luaL_newstate }; -const _luaL_opt = luaL_opt; -export { _luaL_opt as luaL_opt }; -const _luaL_optinteger = luaL_optinteger; -export { _luaL_optinteger as luaL_optinteger }; -const _luaL_optlstring = luaL_optlstring; -export { _luaL_optlstring as luaL_optlstring }; -const _luaL_optnumber = luaL_optnumber; -export { _luaL_optnumber as luaL_optnumber }; -const _luaL_optstring = luaL_optstring; -export { _luaL_optstring as luaL_optstring }; -const _luaL_prepbuffer = luaL_prepbuffer; -export { _luaL_prepbuffer as luaL_prepbuffer }; -const _luaL_prepbuffsize = luaL_prepbuffsize; -export { _luaL_prepbuffsize as luaL_prepbuffsize }; -const _luaL_pushresult = luaL_pushresult; -export { _luaL_pushresult as luaL_pushresult }; -const _luaL_pushresultsize = luaL_pushresultsize; -export { _luaL_pushresultsize as luaL_pushresultsize }; -const _luaL_ref = luaL_ref; -export { _luaL_ref as luaL_ref }; -const _luaL_requiref = luaL_requiref; -export { _luaL_requiref as luaL_requiref }; -const _luaL_setfuncs = luaL_setfuncs; -export { _luaL_setfuncs as luaL_setfuncs }; -const _luaL_setmetatable = luaL_setmetatable; -export { _luaL_setmetatable as luaL_setmetatable }; -const _luaL_testudata = luaL_testudata; -export { _luaL_testudata as luaL_testudata }; -const _luaL_tolstring = luaL_tolstring; -export { _luaL_tolstring as luaL_tolstring }; -const _luaL_traceback = luaL_traceback; -export { _luaL_traceback as luaL_traceback }; -const _luaL_typename = luaL_typename; -export { _luaL_typename as luaL_typename }; -const _luaL_unref = luaL_unref; -export { _luaL_unref as luaL_unref }; -const _luaL_where = luaL_where; -export { _luaL_where as luaL_where }; -const _lua_writestringerror = lua_writestringerror; -export { _lua_writestringerror as lua_writestringerror }; +export const luaL_checkversion = function (L) { + luaL_checkversion_(L, lua.LUA_VERSION_NUM, LUAL_NUMSIZES); +}; diff --git a/src/lbaselib.js b/src/lbaselib.js index 2fd03439..ae0f23a1 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -1,8 +1,6 @@ -'use strict'; - -import { LUA_MULTRET, LUA_OK, LUA_TFUNCTION, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_VERSION, LUA_YIELD, lua_call, lua_callk, lua_concat, lua_error, lua_getglobal, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnone, lua_isstring, lua_load, lua_next, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcfunction, lua_pushglobaltable, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawequal, lua_rawget, lua_rawlen, lua_rawset, lua_remove, lua_replace, lua_rotate, lua_setfield, lua_setmetatable, lua_settop, lua_setupvalue, lua_stringtonumber, lua_toboolean, lua_tolstring, lua_tostring, lua_type, lua_typename } from './lua.js'; -import { luaL_argcheck, luaL_checkany, luaL_checkinteger, luaL_checkoption, luaL_checkstack, luaL_checktype, luaL_error, luaL_getmetafield, luaL_loadbufferx, luaL_loadfile, luaL_loadfilex, luaL_optinteger, luaL_optstring, luaL_setfuncs, luaL_tolstring, luaL_where } from './lauxlib.js'; -import { to_jsstring, to_luastring } from './fengaricore.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as fengaricore from './fengaricore.js'; let lua_writestring; let lua_writeline; @@ -24,7 +22,7 @@ if (typeof process === 'undefined') { lua_writestring = function(s) { try { /* If the string is valid utf8, then we can use to_jsstring */ - s = to_jsstring(s); + s = fengaricore.to_jsstring(s); } catch (e) { /* otherwise push copy of raw array */ let copy = new Uint8Array(s.length); @@ -47,79 +45,79 @@ if (typeof process === 'undefined') { }; } const luaB_print = function(L) { - let n = lua_gettop(L); /* number of arguments */ - lua_getglobal(L, to_luastring('tostring', true)); + let n = lua.lua_gettop(L); /* number of arguments */ + lua.lua_getglobal(L, fengaricore.to_luastring('tostring', true)); for (let i = 1; i <= n; i++) { - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - let s = lua_tolstring(L, -1); + lua.lua_pushvalue(L, -1); /* function to be called */ + lua.lua_pushvalue(L, i); /* value to print */ + lua.lua_call(L, 1, 1); + let s = lua.lua_tolstring(L, -1); if (s === null) - return luaL_error(L, to_luastring('\'tostring\' must return a string to \'print\'')); - if (i > 1) lua_writestring(to_luastring('\t')); + return lauxlib.luaL_error(L, fengaricore.to_luastring('\'tostring\' must return a string to \'print\'')); + if (i > 1) lua_writestring(fengaricore.to_luastring('\t')); lua_writestring(s); - lua_pop(L, 1); + lua.lua_pop(L, 1); } lua_writeline(); return 0; }; const luaB_tostring = function(L) { - luaL_checkany(L, 1); - luaL_tolstring(L, 1); + lauxlib.luaL_checkany(L, 1); + lauxlib.luaL_tolstring(L, 1); return 1; }; const luaB_getmetatable = function(L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); + lauxlib.luaL_checkany(L, 1); + if (!lua.lua_getmetatable(L, 1)) { + lua.lua_pushnil(L); return 1; /* no metatable */ } - luaL_getmetafield(L, 1, to_luastring('__metatable', true)); + lauxlib.luaL_getmetafield(L, 1, fengaricore.to_luastring('__metatable', true)); return 1; /* returns either __metatable field (if present) or metatable */ }; const luaB_setmetatable = function(L) { - let t = lua_type(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t === LUA_TNIL || t === LUA_TTABLE, 2, 'nil or table expected'); - if (luaL_getmetafield(L, 1, to_luastring('__metatable', true)) !== LUA_TNIL) - return luaL_error(L, to_luastring('cannot change a protected metatable')); - lua_settop(L, 2); - lua_setmetatable(L, 1); + let t = lua.lua_type(L, 2); + lauxlib.luaL_checktype(L, 1, lua.LUA_TTABLE); + lauxlib.luaL_argcheck(L, t === lua.LUA_TNIL || t === lua.LUA_TTABLE, 2, 'nil or table expected'); + if (lauxlib.luaL_getmetafield(L, 1, fengaricore.to_luastring('__metatable', true)) !== lua.LUA_TNIL) + return lauxlib.luaL_error(L, fengaricore.to_luastring('cannot change a protected metatable')); + lua.lua_settop(L, 2); + lua.lua_setmetatable(L, 1); return 1; }; const luaB_rawequal = function(L) { - luaL_checkany(L, 1); - luaL_checkany(L, 2); - lua_pushboolean(L, lua_rawequal(L, 1, 2)); + lauxlib.luaL_checkany(L, 1); + lauxlib.luaL_checkany(L, 2); + lua.lua_pushboolean(L, lua.lua_rawequal(L, 1, 2)); return 1; }; const luaB_rawlen = function(L) { - let t = lua_type(L, 1); - luaL_argcheck(L, t === LUA_TTABLE || t === LUA_TSTRING, 1, 'table or string expected'); - lua_pushinteger(L, lua_rawlen(L, 1)); + let t = lua.lua_type(L, 1); + lauxlib.luaL_argcheck(L, t === lua.LUA_TTABLE || t === lua.LUA_TSTRING, 1, 'table or string expected'); + lua.lua_pushinteger(L, lua.lua_rawlen(L, 1)); return 1; }; const luaB_rawget = function(L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_rawget(L, 1); + lauxlib.luaL_checktype(L, 1, lua.LUA_TTABLE); + lauxlib.luaL_checkany(L, 2); + lua.lua_settop(L, 2); + lua.lua_rawget(L, 1); return 1; }; const luaB_rawset = function(L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - luaL_checkany(L, 3); - lua_settop(L, 3); - lua_rawset(L, 1); + lauxlib.luaL_checktype(L, 1, lua.LUA_TTABLE); + lauxlib.luaL_checkany(L, 2); + lauxlib.luaL_checkany(L, 3); + lua.lua_settop(L, 3); + lua.lua_rawset(L, 1); return 1; }; @@ -127,56 +125,56 @@ const opts = [ 'stop', 'restart', 'collect', 'count', 'step', 'setpause', 'setstepmul', 'isrunning' -].map((e) => to_luastring(e)); +].map((e) => fengaricore.to_luastring(e)); const luaB_collectgarbage = function(L) { - luaL_checkoption(L, 1, 'collect', opts); - luaL_optinteger(L, 2, 0); - luaL_error(L, to_luastring('lua_gc not implemented')); + lauxlib.luaL_checkoption(L, 1, 'collect', opts); + lauxlib.luaL_optinteger(L, 2, 0); + lauxlib.luaL_error(L, fengaricore.to_luastring('lua_gc not implemented')); }; const luaB_type = function(L) { - let t = lua_type(L, 1); - luaL_argcheck(L, t !== LUA_TNONE, 1, 'value expected'); - lua_pushstring(L, lua_typename(L, t)); + let t = lua.lua_type(L, 1); + lauxlib.luaL_argcheck(L, t !== lua.LUA_TNONE, 1, 'value expected'); + lua.lua_pushstring(L, lua.lua_typename(L, t)); return 1; }; const pairsmeta = function(L, method, iszero, iter) { - luaL_checkany(L, 1); - if (luaL_getmetafield(L, 1, method) === LUA_TNIL) { /* no metamethod? */ - lua_pushcfunction(L, iter); /* will return generator, */ - lua_pushvalue(L, 1); /* state, */ - if (iszero) lua_pushinteger(L, 0); /* and initial value */ - else lua_pushnil(L); + lauxlib.luaL_checkany(L, 1); + if (lauxlib.luaL_getmetafield(L, 1, method) === lua.LUA_TNIL) { /* no metamethod? */ + lua.lua_pushcfunction(L, iter); /* will return generator, */ + lua.lua_pushvalue(L, 1); /* state, */ + if (iszero) lua.lua_pushinteger(L, 0); /* and initial value */ + else lua.lua_pushnil(L); } else { - lua_pushvalue(L, 1); /* argument 'self' to metamethod */ - lua_call(L, 1, 3); /* get 3 values from metamethod */ + lua.lua_pushvalue(L, 1); /* argument 'self' to metamethod */ + lua.lua_call(L, 1, 3); /* get 3 values from metamethod */ } return 3; }; const luaB_next = function(L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 2); /* create a 2nd argument if there isn't one */ - if (lua_next(L, 1)) + lauxlib.luaL_checktype(L, 1, lua.LUA_TTABLE); + lua.lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua.lua_next(L, 1)) return 2; else { - lua_pushnil(L); + lua.lua_pushnil(L); return 1; } }; const luaB_pairs = function(L) { - return pairsmeta(L, to_luastring('__pairs', true), 0, luaB_next); + return pairsmeta(L, fengaricore.to_luastring('__pairs', true), 0, luaB_next); }; /* ** Traversal function for 'ipairs' */ const ipairsaux = function(L) { - let i = luaL_checkinteger(L, 2) + 1; - lua_pushinteger(L, i); - return lua_geti(L, 1, i) === LUA_TNIL ? 1 : 2; + let i = lauxlib.luaL_checkinteger(L, 2) + 1; + lua.lua_pushinteger(L, i); + return lua.lua_geti(L, 1, i) === lua.LUA_TNIL ? 1 : 2; }; /* @@ -187,16 +185,16 @@ const luaB_ipairs = function(L) { // Lua 5.2 // return pairsmeta(L, "__ipairs", 1, ipairsaux); - luaL_checkany(L, 1); - lua_pushcfunction(L, ipairsaux); /* iteration function */ - lua_pushvalue(L, 1); /* state */ - lua_pushinteger(L, 0); /* initial value */ + lauxlib.luaL_checkany(L, 1); + lua.lua_pushcfunction(L, ipairsaux); /* iteration function */ + lua.lua_pushvalue(L, 1); /* state */ + lua.lua_pushinteger(L, 0); /* initial value */ return 3; }; const b_str2int = function(s, base) { try { - s = to_jsstring(s); + s = fengaricore.to_jsstring(s); } catch (e) { return null; } @@ -208,65 +206,65 @@ const b_str2int = function(s, base) { }; const luaB_tonumber = function(L) { - if (lua_type(L, 2) <= 0) { /* standard conversion? */ - luaL_checkany(L, 1); - if (lua_type(L, 1) === LUA_TNUMBER) { /* already a number? */ - lua_settop(L, 1); + if (lua.lua_type(L, 2) <= 0) { /* standard conversion? */ + lauxlib.luaL_checkany(L, 1); + if (lua.lua_type(L, 1) === lua.LUA_TNUMBER) { /* already a number? */ + lua.lua_settop(L, 1); return 1; } else { - let s = lua_tostring(L, 1); - if (s !== null && lua_stringtonumber(L, s) === s.length+1) + let s = lua.lua_tostring(L, 1); + if (s !== null && lua.lua_stringtonumber(L, s) === s.length+1) return 1; /* successful conversion to number */ } } else { - let base = luaL_checkinteger(L, 2); - luaL_checktype(L, 1, LUA_TSTRING); /* no numbers as strings */ - let s = lua_tostring(L, 1); - luaL_argcheck(L, 2 <= base && base <= 36, 2, 'base out of range'); + let base = lauxlib.luaL_checkinteger(L, 2); + lauxlib.luaL_checktype(L, 1, lua.LUA_TSTRING); /* no numbers as strings */ + let s = lua.lua_tostring(L, 1); + lauxlib.luaL_argcheck(L, 2 <= base && base <= 36, 2, 'base out of range'); let n = b_str2int(s, base); if (n !== null) { - lua_pushinteger(L, n); + lua.lua_pushinteger(L, n); return 1; } } - lua_pushnil(L); + lua.lua_pushnil(L); return 1; }; const luaB_error = function(L) { - let level = luaL_optinteger(L, 2, 1); - lua_settop(L, 1); - if (lua_type(L, 1) === LUA_TSTRING && level > 0) { - luaL_where(L, level); /* add extra information */ - lua_pushvalue(L, 1); - lua_concat(L, 2); + let level = lauxlib.luaL_optinteger(L, 2, 1); + lua.lua_settop(L, 1); + if (lua.lua_type(L, 1) === lua.LUA_TSTRING && level > 0) { + lauxlib.luaL_where(L, level); /* add extra information */ + lua.lua_pushvalue(L, 1); + lua.lua_concat(L, 2); } - return lua_error(L); + return lua.lua_error(L); }; const luaB_assert = function(L) { - if (lua_toboolean(L, 1)) /* condition is true? */ - return lua_gettop(L); /* return all arguments */ + if (lua.lua_toboolean(L, 1)) /* condition is true? */ + return lua.lua_gettop(L); /* return all arguments */ else { - luaL_checkany(L, 1); /* there must be a condition */ - lua_remove(L, 1); /* remove it */ - lua_pushliteral(L, 'assertion failed!'); /* default message */ - lua_settop(L, 1); /* leave only message (default if no other one) */ + lauxlib.luaL_checkany(L, 1); /* there must be a condition */ + lua.lua_remove(L, 1); /* remove it */ + lua.lua_pushliteral(L, 'assertion failed!'); /* default message */ + lua.lua_settop(L, 1); /* leave only message (default if no other one) */ return luaB_error(L); /* call 'error' */ } }; const luaB_select = function(L) { - let n = lua_gettop(L); - if (lua_type(L, 1) === LUA_TSTRING && lua_tostring(L, 1)[0] === 35 /* '#'.charCodeAt(0) */) { - lua_pushinteger(L, n - 1); + let n = lua.lua_gettop(L); + if (lua.lua_type(L, 1) === lua.LUA_TSTRING && lua.lua_tostring(L, 1)[0] === 35 /* '#'.charCodeAt(0) */) { + lua.lua_pushinteger(L, n - 1); return 1; } else { - let i = luaL_checkinteger(L, 1); + let i = lauxlib.luaL_checkinteger(L, 1); if (i < 0) i = n + i; else if (i > n) i = n; - luaL_argcheck(L, 1 <= i, 1, 'index out of range'); + lauxlib.luaL_argcheck(L, 1 <= i, 1, 'index out of range'); return n - i; } }; @@ -279,19 +277,19 @@ const luaB_select = function(L) { ** ignored). */ const finishpcall = function(L, status, extra) { - if (status !== LUA_OK && status !== LUA_YIELD) { /* error? */ - lua_pushboolean(L, 0); /* first result (false) */ - lua_pushvalue(L, -2); /* error message */ + if (status !== lua.LUA_OK && status !== lua.LUA_YIELD) { /* error? */ + lua.lua_pushboolean(L, 0); /* first result (false) */ + lua.lua_pushvalue(L, -2); /* error message */ return 2; /* return false, msg */ } else - return lua_gettop(L) - extra; + return lua.lua_gettop(L) - extra; }; const luaB_pcall = function(L) { - luaL_checkany(L, 1); - lua_pushboolean(L, 1); /* first result if no errors */ - lua_insert(L, 1); /* put it in place */ - let status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, finishpcall); + lauxlib.luaL_checkany(L, 1); + lua.lua_pushboolean(L, 1); /* first result if no errors */ + lua.lua_insert(L, 1); /* put it in place */ + let status = lua.lua_pcallk(L, lua.lua_gettop(L) - 2, lua.LUA_MULTRET, 0, 0, finishpcall); return finishpcall(L, status, 0); }; @@ -301,26 +299,26 @@ const luaB_pcall = function(L) { ** 2 to 'finishpcall' to skip the 2 first values when returning results. */ const luaB_xpcall = function(L) { - let n = lua_gettop(L); - luaL_checktype(L, 2, LUA_TFUNCTION); /* check error function */ - lua_pushboolean(L, 1); /* first result */ - lua_pushvalue(L, 1); /* function */ - lua_rotate(L, 3, 2); /* move them below function's arguments */ - let status = lua_pcallk(L, n - 2, LUA_MULTRET, 2, 2, finishpcall); + let n = lua.lua_gettop(L); + lauxlib.luaL_checktype(L, 2, lua.LUA_TFUNCTION); /* check error function */ + lua.lua_pushboolean(L, 1); /* first result */ + lua.lua_pushvalue(L, 1); /* function */ + lua.lua_rotate(L, 3, 2); /* move them below function's arguments */ + let status = lua.lua_pcallk(L, n - 2, lua.LUA_MULTRET, 2, 2, finishpcall); return finishpcall(L, status, 2); }; const load_aux = function(L, status, envidx) { - if (status === LUA_OK) { + if (status === lua.LUA_OK) { if (envidx !== 0) { /* 'env' parameter? */ - lua_pushvalue(L, envidx); /* environment for loaded function */ - if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ - lua_pop(L, 1); /* remove 'env' if not used by previous call */ + lua.lua_pushvalue(L, envidx); /* environment for loaded function */ + if (!lua.lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ + lua.lua_pop(L, 1); /* remove 'env' if not used by previous call */ } return 1; } else { /* error (message is on top of the stack) */ - lua_pushnil(L); - lua_insert(L, -2); /* put before error message */ + lua.lua_pushnil(L); + lua.lua_insert(L, -2); /* put before error message */ return 2; /* return nil plus error message */ } }; @@ -338,54 +336,54 @@ const RESERVEDSLOT = 5; ** stack top. Instead, it keeps its resulting string in a ** reserved slot inside the stack. */ -const generic_reader = function(L, ud) { - luaL_checkstack(L, 2, 'too many nested functions'); - lua_pushvalue(L, 1); /* get function */ - lua_call(L, 0, 1); /* call it */ - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* pop result */ +const generic_reader = function(L, _ud) { + lauxlib.luaL_checkstack(L, 2, 'too many nested functions'); + lua.lua_pushvalue(L, 1); /* get function */ + lua.lua_call(L, 0, 1); /* call it */ + if (lua.lua_isnil(L, -1)) { + lua.lua_pop(L, 1); /* pop result */ return null; - } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('reader function must return a string')); - lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ - return lua_tostring(L, RESERVEDSLOT); + } else if (!lua.lua_isstring(L, -1)) + lauxlib.luaL_error(L, fengaricore.to_luastring('reader function must return a string')); + lua.lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ + return lua.lua_tostring(L, RESERVEDSLOT); }; const luaB_load = function(L) { - let s = lua_tostring(L, 1); - let mode = luaL_optstring(L, 3, 'bt'); - let env = !lua_isnone(L, 4) ? 4 : 0; /* 'env' index or 0 if no 'env' */ + let s = lua.lua_tostring(L, 1); + let mode = lauxlib.luaL_optstring(L, 3, 'bt'); + let env = !lua.lua_isnone(L, 4) ? 4 : 0; /* 'env' index or 0 if no 'env' */ let status; if (s !== null) { /* loading a string? */ - let chunkname = luaL_optstring(L, 2, s); - status = luaL_loadbufferx(L, s, s.length, chunkname, mode); + let chunkname = lauxlib.luaL_optstring(L, 2, s); + status = lauxlib.luaL_loadbufferx(L, s, s.length, chunkname, mode); } else { /* loading from a reader function */ - let chunkname = luaL_optstring(L, 2, '=(load)'); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, RESERVEDSLOT); /* create reserved slot */ - status = lua_load(L, generic_reader, null, chunkname, mode); + let chunkname = lauxlib.luaL_optstring(L, 2, '=(load)'); + lauxlib.luaL_checktype(L, 1, lua.LUA_TFUNCTION); + lua.lua_settop(L, RESERVEDSLOT); /* create reserved slot */ + status = lua.lua_load(L, generic_reader, null, chunkname, mode); } return load_aux(L, status, env); }; const luaB_loadfile = function(L) { - let fname = luaL_optstring(L, 1, null); - let mode = luaL_optstring(L, 2, null); - let env = !lua_isnone(L, 3) ? 3 : 0; /* 'env' index or 0 if no 'env' */ - let status = luaL_loadfilex(L, fname, mode); + let fname = lauxlib.luaL_optstring(L, 1, null); + let mode = lauxlib.luaL_optstring(L, 2, null); + let env = !lua.lua_isnone(L, 3) ? 3 : 0; /* 'env' index or 0 if no 'env' */ + let status = lauxlib.luaL_loadfilex(L, fname, mode); return load_aux(L, status, env); }; -const dofilecont = function(L, d1, d2) { - return lua_gettop(L) - 1; +const dofilecont = function(L, _d1, _d2) { + return lua.lua_gettop(L) - 1; }; const luaB_dofile = function(L) { - let fname = luaL_optstring(L, 1, null); - lua_settop(L, 1); - if (luaL_loadfile(L, fname) !== LUA_OK) - return lua_error(L); - lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); + let fname = lauxlib.luaL_optstring(L, 1, null); + lua.lua_settop(L, 1); + if (lauxlib.luaL_loadfile(L, fname) !== lua.LUA_OK) + return lua.lua_error(L); + lua.lua_callk(L, 0, lua.LUA_MULTRET, 0, dofilecont); return dofilecont(L, 0, 0); }; @@ -414,18 +412,15 @@ const base_funcs = { 'xpcall': luaB_xpcall }; -const luaopen_base = function(L) { +export const luaopen_base = function(L) { /* open lib into global table */ - lua_pushglobaltable(L); - luaL_setfuncs(L, base_funcs, 0); + lua.lua_pushglobaltable(L); + lauxlib.luaL_setfuncs(L, base_funcs, 0); /* set global _G */ - lua_pushvalue(L, -1); - lua_setfield(L, -2, to_luastring('_G')); + lua.lua_pushvalue(L, -1); + lua.lua_setfield(L, -2, fengaricore.to_luastring('_G')); /* set global _VERSION */ - lua_pushliteral(L, LUA_VERSION); - lua_setfield(L, -2, to_luastring('_VERSION')); + lua.lua_pushliteral(L, lua.LUA_VERSION); + lua.lua_setfield(L, -2, fengaricore.to_luastring('_VERSION')); return 1; }; - -const _luaopen_base = luaopen_base; -export { _luaopen_base as luaopen_base }; diff --git a/src/lcode.js b/src/lcode.js index b203a847..a8a11c48 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -1,18 +1,13 @@ -'use strict'; - -import { LUA_MULTRET, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPIDIV, LUA_OPMOD, LUA_OPSHL, LUA_OPSHR, LUA_OPUNM, constant_types, to_luastring } from './defs.js'; -import { lua_assert } from './llimits.js'; -import { luaX_syntaxerror } from './llex.js'; -import { TValue as _TValue, luaO_arith } from './lobject.js'; -import { OpCodesI as _OpCodesI, SETARG_A, SETARG_B, MAXARG_sBx, SETARG_sBx, testTMode, NO_REG, CREATE_ABC, getOpMode, iABC, getBMode, OpArgN, getCMode, MAXARG_A, MAXARG_B, MAXARG_C, iABx, iAsBx, MAXARG_Bx, CREATE_ABx, MAXARG_Ax, CREATE_Ax, ISK, SETARG_C, MAXINDEXRK, RKASK, LFIELDS_PER_FLUSH } from './lopcodes.js'; -import { expkind, vkisinreg, expdesc } from './lparser.js'; -import { luaH_get, luaH_setfrom } from './ltable.js'; -import { tointeger } from './lvm.js'; - -const OpCodesI = _OpCodesI; -const TValue = _TValue; - -const { +import * as defs from './defs.js'; +import * as llimits from './llimits.js'; +import * as llex from './llex.js'; +import * as lobject from './lobject.js'; +import * as lopcodes from './lopcodes.js'; +import * as lparser from './lparser.js'; +import * as ltable from './ltable.js'; +import * as lvm from './lvm.js'; + +export const { LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TLNGSTR, @@ -20,18 +15,18 @@ const { LUA_TNUMFLT, LUA_TNUMINT, LUA_TTABLE -} = constant_types; +} = defs.constant_types; /* Maximum number of registers in a Lua function (must fit in 8 bits) */ -const MAXREGS = 255; +export const MAXREGS = 255; /* ** Marks the end of a patch list. It is an invalid value both as an absolute ** address, and as a list link (would link an element to itself). */ -const NO_JUMP = -1; +export const NO_JUMP = -1; -const BinOpr = { +export const BinOpr = { OPR_ADD: 0, OPR_SUB: 1, OPR_MUL: 2, @@ -56,7 +51,7 @@ const BinOpr = { OPR_NOBINOPR: 21 }; -const UnOpr = { +export const UnOpr = { OPR_MINUS: 0, OPR_BNOT: 1, OPR_NOT: 2, @@ -64,7 +59,7 @@ const UnOpr = { OPR_NOUNOPR: 4 }; -const hasjumps = function (e) { +export const hasjumps = function (e) { return e.t !== e.f; }; @@ -72,19 +67,19 @@ const hasjumps = function (e) { ** If expression is a numeric constant returns either true or a new TValue ** (depending on 'make_tvalue'). Otherwise, returns false. */ -const tonumeral = function (e, make_tvalue) { - let ek = expkind; +export const tonumeral = function (e, make_tvalue) { + let ek = lparser.expkind; if (hasjumps(e)) return false; /* not a numeral */ switch (e.k) { case ek.VKINT: if (make_tvalue) { - return new TValue(LUA_TNUMINT, e.u.ival); + return new lobject.TValue(LUA_TNUMINT, e.u.ival); } return true; case ek.VKFLT: if (make_tvalue) { - return new TValue(LUA_TNUMFLT, e.u.nval); + return new lobject.TValue(LUA_TNUMFLT, e.u.nval); } return true; default: return false; @@ -97,28 +92,28 @@ const tonumeral = function (e, make_tvalue) { ** range of previous instruction instead of emitting a new one. (For ** instance, 'local a; local b' will generate a single opcode.) */ -const luaK_nil = function (fs, from, n) { +export const luaK_nil = function (fs, from, n) { let previous; let l = from + n - 1; /* last register to set nil */ if (fs.pc > fs.lasttarget) { /* no jumps to current position? */ previous = fs.f.code[fs.pc - 1]; - if (previous.opcode === OpCodesI.OP_LOADNIL) { /* previous is LOADNIL? */ + if (previous.opcode === lopcodes.OpCodesI.OP_LOADNIL) { /* previous is LOADNIL? */ let pfrom = previous.A; /* get previous range */ let pl = pfrom + previous.B; if ((pfrom <= from && from <= pl + 1) || (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ if (pl > l) l = pl; /* l = max(l, pl) */ - SETARG_A(previous, from); - SETARG_B(previous, l - from); + lopcodes.SETARG_A(previous, from); + lopcodes.SETARG_B(previous, l - from); return; } } /* else go through */ } - luaK_codeABC(fs, OpCodesI.OP_LOADNIL, from, n - 1, 0); /* else no optimization */ + luaK_codeABC(fs, lopcodes.OpCodesI.OP_LOADNIL, from, n - 1, 0); /* else no optimization */ }; -const getinstruction = function (fs, e) { +export const getinstruction = function (fs, e) { return fs.f.code[e.u.info]; }; @@ -126,7 +121,7 @@ const getinstruction = function (fs, e) { ** Gets the destination address of a jump instruction. Used to traverse ** a list of jumps. */ -const getjump = function (fs, pc) { +export const getjump = function (fs, pc) { let offset = fs.f.code[pc].sBx; if (offset === NO_JUMP) /* point to itself represents end of list */ return NO_JUMP; /* end of list */ @@ -138,19 +133,19 @@ const getjump = function (fs, pc) { ** Fix jump instruction at position 'pc' to jump to 'dest'. ** (Jump addresses are relative in Lua) */ -const fixjump = function (fs, pc, dest) { +export const fixjump = function (fs, pc, dest) { let jmp = fs.f.code[pc]; let offset = dest - (pc + 1); - lua_assert(dest !== NO_JUMP); - if (Math.abs(offset) > MAXARG_sBx) - luaX_syntaxerror(fs.ls, to_luastring('control structure too long', true)); - SETARG_sBx(jmp, offset); + llimits.lua_assert(dest !== NO_JUMP); + if (Math.abs(offset) > lopcodes.MAXARG_sBx) + llex.luaX_syntaxerror(fs.ls, defs.to_luastring('control structure too long', true)); + lopcodes.SETARG_sBx(jmp, offset); }; /* ** Concatenate jump-list 'l2' into jump-list 'l1' */ -const luaK_concat = function (fs, l1, l2) { +export const luaK_concat = function (fs, l1, l2) { if (l2 === NO_JUMP) return l1; /* nothing to concatenate? */ else if (l1 === NO_JUMP) /* no original list? */ l1 = l2; @@ -173,30 +168,30 @@ const luaK_concat = function (fs, l1, l2) { ** this position (kept in 'jpc'), link them all together so that ** 'patchlistaux' will fix all them directly to the final destination. */ -const luaK_jump = function (fs) { +export const luaK_jump = function (fs) { let jpc = fs.jpc; /* save list of jumps to here */ fs.jpc = NO_JUMP; /* no more jumps to here */ - let j = luaK_codeAsBx(fs, OpCodesI.OP_JMP, 0, NO_JUMP); + let j = luaK_codeAsBx(fs, lopcodes.OpCodesI.OP_JMP, 0, NO_JUMP); j = luaK_concat(fs, j, jpc); /* keep them on hold */ return j; }; -const luaK_jumpto = function (fs, t) { +export const luaK_jumpto = function (fs, t) { return luaK_patchlist(fs, luaK_jump(fs), t); }; /* ** Code a 'return' instruction */ -const luaK_ret = function (fs, first, nret) { - luaK_codeABC(fs, OpCodesI.OP_RETURN, first, nret + 1, 0); +export const luaK_ret = function (fs, first, nret) { + luaK_codeABC(fs, lopcodes.OpCodesI.OP_RETURN, first, nret + 1, 0); }; /* ** Code a "conditional jump", that is, a test or comparison opcode ** followed by a jump. Return jump position. */ -const condjump = function (fs, op, A, B, C) { +export const condjump = function (fs, op, A, B, C) { luaK_codeABC(fs, op, A, B, C); return luaK_jump(fs); }; @@ -205,7 +200,7 @@ const condjump = function (fs, op, A, B, C) { ** returns current 'pc' and marks it as a jump target (to avoid wrong ** optimizations with consecutive instructions not in the same basic block). */ -const luaK_getlabel = function (fs) { +export const luaK_getlabel = function (fs) { fs.lasttarget = fs.pc; return fs.pc; }; @@ -215,13 +210,13 @@ const luaK_getlabel = function (fs) { ** jump (that is, its condition), or the jump itself if it is ** unconditional. */ -const getjumpcontroloffset = function (fs, pc) { - if (pc >= 1 && testTMode(fs.f.code[pc - 1].opcode)) +export const getjumpcontroloffset = function (fs, pc) { + if (pc >= 1 && lopcodes.testTMode(fs.f.code[pc - 1].opcode)) return pc - 1; else return pc; }; -const getjumpcontrol = function (fs, pc) { +export const getjumpcontrol = function (fs, pc) { return fs.f.code[getjumpcontroloffset(fs, pc)]; }; @@ -232,17 +227,17 @@ const getjumpcontrol = function (fs, pc) { ** register. Otherwise, change instruction to a simple 'TEST' (produces ** no register value) */ -const patchtestreg = function (fs, node, reg) { +export const patchtestreg = function (fs, node, reg) { let pc = getjumpcontroloffset(fs, node); let i = fs.f.code[pc]; - if (i.opcode !== OpCodesI.OP_TESTSET) + if (i.opcode !== lopcodes.OpCodesI.OP_TESTSET) return false; /* cannot patch other instructions */ - if (reg !== NO_REG && reg !== i.B) - SETARG_A(i, reg); + if (reg !== lopcodes.NO_REG && reg !== i.B) + lopcodes.SETARG_A(i, reg); else { /* no register to put value or register already has the value; change instruction to simple test */ - fs.f.code[pc] = CREATE_ABC(OpCodesI.OP_TEST, i.B, 0, i.C); + fs.f.code[pc] = lopcodes.CREATE_ABC(lopcodes.OpCodesI.OP_TEST, i.B, 0, i.C); } return true; }; @@ -250,9 +245,9 @@ const patchtestreg = function (fs, node, reg) { /* ** Traverse a list of tests ensuring no one produces a value */ -const removevalues = function (fs, list) { +export const removevalues = function (fs, list) { for (; list !== NO_JUMP; list = getjump(fs, list)) - patchtestreg(fs, list, NO_REG); + patchtestreg(fs, list, lopcodes.NO_REG); }; /* @@ -260,7 +255,7 @@ const removevalues = function (fs, list) { ** registers: tests producing values jump to 'vtarget' (and put their ** values in 'reg'), other tests jump to 'dtarget'. */ -const patchlistaux = function (fs, list, vtarget, reg, dtarget) { +export const patchlistaux = function (fs, list, vtarget, reg, dtarget) { while (list !== NO_JUMP) { let next = getjump(fs, list); if (patchtestreg(fs, list, reg)) @@ -276,8 +271,8 @@ const patchlistaux = function (fs, list, vtarget, reg, dtarget) { ** to current position with no values) and reset list of pending ** jumps */ -const dischargejpc = function (fs) { - patchlistaux(fs, fs.jpc, fs.pc, NO_REG, fs.pc); +export const dischargejpc = function (fs) { + patchlistaux(fs, fs.jpc, fs.pc, lopcodes.NO_REG, fs.pc); fs.jpc = NO_JUMP; }; @@ -285,7 +280,7 @@ const dischargejpc = function (fs) { ** Add elements in 'list' to list of pending jumps to "here" ** (current position) */ -const luaK_patchtohere = function (fs, list) { +export const luaK_patchtohere = function (fs, list) { luaK_getlabel(fs); /* mark "here" as a jump target */ fs.jpc = luaK_concat(fs, fs.jpc, list); }; @@ -295,12 +290,12 @@ const luaK_patchtohere = function (fs, list) { ** (The assert means that we cannot fix a jump to a forward address ** because we only know addresses once code is generated.) */ -const luaK_patchlist = function (fs, list, target) { +export const luaK_patchlist = function (fs, list, target) { if (target === fs.pc) /* 'target' is current position? */ luaK_patchtohere(fs, list); /* add list to pending jumps */ else { - lua_assert(target < fs.pc); - patchlistaux(fs, list, target, NO_REG, target); + llimits.lua_assert(target < fs.pc); + patchlistaux(fs, list, target, lopcodes.NO_REG, target); } }; @@ -309,12 +304,12 @@ const luaK_patchlist = function (fs, list, target) { ** (The assertion checks that jumps either were closing nothing ** or were closing higher levels, from inner blocks.) */ -const luaK_patchclose = function (fs, list, level) { +export const luaK_patchclose = function (fs, list, level) { level++; /* argument is +1 to reserve 0 as non-op */ for (; list !== NO_JUMP; list = getjump(fs, list)) { let ins = fs.f.code[list]; - lua_assert(ins.opcode === OpCodesI.OP_JMP && (ins.A === 0 || ins.A >= level)); - SETARG_A(ins, level); + llimits.lua_assert(ins.opcode === lopcodes.OpCodesI.OP_JMP && (ins.A === 0 || ins.A >= level)); + lopcodes.SETARG_A(ins, level); } }; @@ -322,7 +317,7 @@ const luaK_patchclose = function (fs, list, level) { ** Emit instruction 'i', checking for array sizes and saving also its ** line information. Return 'i' position. */ -const luaK_code = function (fs, i) { +export const luaK_code = function (fs, i) { let f = fs.f; dischargejpc(fs); /* 'pc' will change */ /* put new instruction in code array */ @@ -335,34 +330,34 @@ const luaK_code = function (fs, i) { ** Format and emit an 'iABC' instruction. (Assertions check consistency ** of parameters versus opcode.) */ -const luaK_codeABC = function (fs, o, a, b, c) { - lua_assert(getOpMode(o) === iABC); - lua_assert(getBMode(o) !== OpArgN || b === 0); - lua_assert(getCMode(o) !== OpArgN || c === 0); - lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); - return luaK_code(fs, CREATE_ABC(o, a, b, c)); +export const luaK_codeABC = function (fs, o, a, b, c) { + llimits.lua_assert(lopcodes.getOpMode(o) === lopcodes.iABC); + llimits.lua_assert(lopcodes.getBMode(o) !== lopcodes.OpArgN || b === 0); + llimits.lua_assert(lopcodes.getCMode(o) !== lopcodes.OpArgN || c === 0); + llimits.lua_assert(a <= lopcodes.MAXARG_A && b <= lopcodes.MAXARG_B && c <= lopcodes.MAXARG_C); + return luaK_code(fs, lopcodes.CREATE_ABC(o, a, b, c)); }; /* ** Format and emit an 'iABx' instruction. */ -const luaK_codeABx = function (fs, o, a, bc) { - lua_assert(getOpMode(o) === iABx || getOpMode(o) === iAsBx); - lua_assert(getCMode(o) === OpArgN); - lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); - return luaK_code(fs, CREATE_ABx(o, a, bc)); +export const luaK_codeABx = function (fs, o, a, bc) { + llimits.lua_assert(lopcodes.getOpMode(o) === lopcodes.iABx || lopcodes.getOpMode(o) === lopcodes.iAsBx); + llimits.lua_assert(lopcodes.getCMode(o) === lopcodes.OpArgN); + llimits.lua_assert(a <= lopcodes.MAXARG_A && bc <= lopcodes.MAXARG_Bx); + return luaK_code(fs, lopcodes.CREATE_ABx(o, a, bc)); }; -const luaK_codeAsBx = function (fs, o, A, sBx) { - return luaK_codeABx(fs, o, A, (sBx) + MAXARG_sBx); +export const luaK_codeAsBx = function (fs, o, A, sBx) { + return luaK_codeABx(fs, o, A, (sBx) + lopcodes.MAXARG_sBx); }; /* ** Emit an "extra argument" instruction (format 'iAx') */ -const codeextraarg = function (fs, a) { - lua_assert(a <= MAXARG_Ax); - return luaK_code(fs, CREATE_Ax(OpCodesI.OP_EXTRAARG, a)); +export const codeextraarg = function (fs, a) { + llimits.lua_assert(a <= lopcodes.MAXARG_Ax); + return luaK_code(fs, lopcodes.CREATE_Ax(lopcodes.OpCodesI.OP_EXTRAARG, a)); }; /* @@ -370,11 +365,11 @@ const codeextraarg = function (fs, a) { ** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX' ** instruction with "extra argument". */ -const luaK_codek = function (fs, reg, k) { - if (k <= MAXARG_Bx) - return luaK_codeABx(fs, OpCodesI.OP_LOADK, reg, k); +export const luaK_codek = function (fs, reg, k) { + if (k <= lopcodes.MAXARG_Bx) + return luaK_codeABx(fs, lopcodes.OpCodesI.OP_LOADK, reg, k); else { - let p = luaK_codeABx(fs, OpCodesI.OP_LOADKX, reg, 0); + let p = luaK_codeABx(fs, lopcodes.OpCodesI.OP_LOADKX, reg, 0); codeextraarg(fs, k); return p; } @@ -384,11 +379,11 @@ const luaK_codek = function (fs, reg, k) { ** Check register-stack level, keeping track of its maximum size ** in field 'maxstacksize' */ -const luaK_checkstack = function (fs, n) { +export const luaK_checkstack = function (fs, n) { let newstack = fs.freereg + n; if (newstack > fs.f.maxstacksize) { if (newstack >= MAXREGS) - luaX_syntaxerror(fs.ls, to_luastring('function or expression needs too many registers', true)); + llex.luaX_syntaxerror(fs.ls, defs.to_luastring('function or expression needs too many registers', true)); fs.f.maxstacksize = newstack; } }; @@ -396,7 +391,7 @@ const luaK_checkstack = function (fs, n) { /* ** Reserve 'n' registers in register stack */ -const luaK_reserveregs = function (fs, n) { +export const luaK_reserveregs = function (fs, n) { luaK_checkstack(fs, n); fs.freereg += n; }; @@ -405,18 +400,18 @@ const luaK_reserveregs = function (fs, n) { ** Free register 'reg', if it is neither a constant index nor ** a local variable. */ -const freereg = function (fs, reg) { - if (!ISK(reg) && reg >= fs.nactvar) { +export const freereg = function (fs, reg) { + if (!lopcodes.ISK(reg) && reg >= fs.nactvar) { fs.freereg--; - lua_assert(reg === fs.freereg); + llimits.lua_assert(reg === fs.freereg); } }; /* ** Free register used by expression 'e' (if any) */ -const freeexp = function (fs, e) { - if (e.k === expkind.VNONRELOC) +export const freeexp = function (fs, e) { + if (e.k === lparser.expkind.VNONRELOC) freereg(fs, e.u.info); }; @@ -424,9 +419,9 @@ const freeexp = function (fs, e) { ** Free registers used by expressions 'e1' and 'e2' (if any) in proper ** order. */ -const freeexps = function (fs, e1, e2) { - let r1 = (e1.k === expkind.VNONRELOC) ? e1.u.info : -1; - let r2 = (e2.k === expkind.VNONRELOC) ? e2.u.info : -1; +export const freeexps = function (fs, e1, e2) { + let r1 = (e1.k === lparser.expkind.VNONRELOC) ? e1.u.info : -1; + let r2 = (e2.k === lparser.expkind.VNONRELOC) ? e2.u.info : -1; if (r1 > r2) { freereg(fs, r1); freereg(fs, r2); @@ -445,9 +440,9 @@ const freeexps = function (fs, e1, e2) { ** as keys (nil cannot be a key, integer keys can collapse with float ** keys), the caller must provide a useful 'key' for indexing the cache. */ -const addk = function (fs, key, v) { +export const addk = function (fs, key, v) { let f = fs.f; - let idx = luaH_get(fs.L, fs.ls.h, key); /* index scanner table */ + let idx = ltable.luaH_get(fs.L, fs.ls.h, key); /* index scanner table */ if (idx.ttisinteger()) { /* is there an index there? */ let k = idx.value; /* correct value? (warning: must distinguish floats from integers!) */ @@ -456,7 +451,7 @@ const addk = function (fs, key, v) { } /* constant not found; create a new entry */ let k = fs.nk; - luaH_setfrom(fs.L, fs.ls.h, key, new _TValue(LUA_TNUMINT, k)); + ltable.luaH_setfrom(fs.L, fs.ls.h, key, new lobject.TValue(LUA_TNUMINT, k)); f.k[k] = v; fs.nk++; return k; @@ -465,8 +460,8 @@ const addk = function (fs, key, v) { /* ** Add a string to list of constants and return its index. */ -const luaK_stringK = function (fs, s) { - let o = new TValue(LUA_TLNGSTR, s); +export const luaK_stringK = function (fs, s) { + let o = new lobject.TValue(LUA_TLNGSTR, s); return addk(fs, o, o); /* use string itself as key */ }; @@ -476,17 +471,17 @@ const luaK_stringK = function (fs, s) { ** Integers use userdata as keys to avoid collision with floats with ** same value. */ -const luaK_intK = function (fs, n) { - let k = new TValue(LUA_TLIGHTUSERDATA, n); - let o = new TValue(LUA_TNUMINT, n); +export const luaK_intK = function (fs, n) { + let k = new lobject.TValue(LUA_TLIGHTUSERDATA, n); + let o = new lobject.TValue(LUA_TNUMINT, n); return addk(fs, k, o); }; /* ** Add a float to list of constants and return its index. */ -const luaK_numberK = function (fs, r) { - let o = new TValue(LUA_TNUMFLT, r); +export const luaK_numberK = function (fs, r) { + let o = new lobject.TValue(LUA_TNUMFLT, r); return addk(fs, o, o); /* use number itself as key */ }; @@ -494,8 +489,8 @@ const luaK_numberK = function (fs, r) { /* ** Add a boolean to list of constants and return its index. */ -const boolK = function (fs, b) { - let o = new TValue(LUA_TBOOLEAN, b); +export const boolK = function (fs, b) { + let o = new lobject.TValue(LUA_TBOOLEAN, b); return addk(fs, o, o); /* use boolean itself as key */ }; @@ -503,9 +498,9 @@ const boolK = function (fs, b) { /* ** Add nil to list of constants and return its index. */ -const nilK = function (fs) { - let v = new TValue(LUA_TNIL, null); - let k = new TValue(LUA_TTABLE, fs.ls.h); +export const nilK = function (fs) { + let v = new lobject.TValue(LUA_TNIL, null); + let k = new lobject.TValue(LUA_TTABLE, fs.ls.h); /* cannot use nil as key; instead use table itself to represent nil */ return addk(fs, k, v); }; @@ -515,22 +510,22 @@ const nilK = function (fs) { ** Either 'e' is a multi-ret expression (function call or vararg) ** or 'nresults' is LUA_MULTRET (as any expression can satisfy that). */ -const luaK_setreturns = function (fs, e, nresults) { - let ek = expkind; +export const luaK_setreturns = function (fs, e, nresults) { + let ek = lparser.expkind; if (e.k === ek.VCALL) { /* expression is an open function call? */ - SETARG_C(getinstruction(fs, e), nresults + 1); + lopcodes.SETARG_C(getinstruction(fs, e), nresults + 1); } else if (e.k === ek.VVARARG) { let pc = getinstruction(fs, e); - SETARG_B(pc, nresults + 1); - SETARG_A(pc, fs.freereg); + lopcodes.SETARG_B(pc, nresults + 1); + lopcodes.SETARG_A(pc, fs.freereg); luaK_reserveregs(fs, 1); } - else lua_assert(nresults === LUA_MULTRET); + else llimits.lua_assert(nresults === defs.LUA_MULTRET); }; -const luaK_setmultret = function (fs, e) { - luaK_setreturns(fs, e, LUA_MULTRET); +export const luaK_setmultret = function (fs, e) { + luaK_setreturns(fs, e, defs.LUA_MULTRET); }; /* @@ -543,15 +538,15 @@ const luaK_setmultret = function (fs, e) { ** (Calls are created returning one result, so that does not need ** to be fixed.) */ -const luaK_setoneret = function (fs, e) { - let ek = expkind; +export const luaK_setoneret = function (fs, e) { + let ek = lparser.expkind; if (e.k === ek.VCALL) { /* expression is an open function call? */ /* already returns 1 value */ - lua_assert(getinstruction(fs, e).C === 2); + llimits.lua_assert(getinstruction(fs, e).C === 2); e.k = ek.VNONRELOC; /* result has fixed position */ e.u.info = getinstruction(fs, e).A; } else if (e.k === ek.VVARARG) { - SETARG_B(getinstruction(fs, e), 2); + lopcodes.SETARG_B(getinstruction(fs, e), 2); e.k = ek.VRELOCABLE; /* can relocate its simple result */ } }; @@ -559,8 +554,8 @@ const luaK_setoneret = function (fs, e) { /* ** Ensure that expression 'e' is not a variable. */ -const luaK_dischargevars = function (fs, e) { - let ek = expkind; +export const luaK_dischargevars = function (fs, e) { + let ek = lparser.expkind; switch (e.k) { case ek.VLOCAL: { /* already in a register */ @@ -568,7 +563,7 @@ const luaK_dischargevars = function (fs, e) { break; } case ek.VUPVAL: { /* move value to some (pending) register */ - e.u.info = luaK_codeABC(fs, OpCodesI.OP_GETUPVAL, 0, e.u.info, 0); + e.u.info = luaK_codeABC(fs, lopcodes.OpCodesI.OP_GETUPVAL, 0, e.u.info, 0); e.k = ek.VRELOCABLE; break; } @@ -577,10 +572,10 @@ const luaK_dischargevars = function (fs, e) { freereg(fs, e.u.ind.idx); if (e.u.ind.vt === ek.VLOCAL) { /* is 't' in a register? */ freereg(fs, e.u.ind.t); - op = OpCodesI.OP_GETTABLE; + op = lopcodes.OpCodesI.OP_GETTABLE; } else { - lua_assert(e.u.ind.vt === ek.VUPVAL); - op = OpCodesI.OP_GETTABUP; /* 't' is in an upvalue */ + llimits.lua_assert(e.u.ind.vt === ek.VUPVAL); + op = lopcodes.OpCodesI.OP_GETTABUP; /* 't' is in an upvalue */ } e.u.info = luaK_codeABC(fs, op, 0, e.u.ind.t, e.u.ind.idx); e.k = ek.VRELOCABLE; @@ -594,17 +589,17 @@ const luaK_dischargevars = function (fs, e) { } }; -const code_loadbool = function (fs, A, b, jump) { +export const code_loadbool = function (fs, A, b, jump) { luaK_getlabel(fs); /* those instructions may be jump targets */ - return luaK_codeABC(fs, OpCodesI.OP_LOADBOOL, A, b, jump); + return luaK_codeABC(fs, lopcodes.OpCodesI.OP_LOADBOOL, A, b, jump); }; /* ** Ensures expression value is in register 'reg' (and therefore ** 'e' will become a non-relocatable expression). */ -const discharge2reg = function (fs, e, reg) { - let ek = expkind; +export const discharge2reg = function (fs, e, reg) { + let ek = lparser.expkind; luaK_dischargevars(fs, e); switch (e.k) { case ek.VNIL: { @@ -612,7 +607,7 @@ const discharge2reg = function (fs, e, reg) { break; } case ek.VFALSE: case ek.VTRUE: { - luaK_codeABC(fs, OpCodesI.OP_LOADBOOL, reg, e.k === ek.VTRUE, 0); + luaK_codeABC(fs, lopcodes.OpCodesI.OP_LOADBOOL, reg, e.k === ek.VTRUE, 0); break; } case ek.VK: { @@ -629,16 +624,16 @@ const discharge2reg = function (fs, e, reg) { } case ek.VRELOCABLE: { let pc = getinstruction(fs, e); - SETARG_A(pc, reg); /* instruction will put result in 'reg' */ + lopcodes.SETARG_A(pc, reg); /* instruction will put result in 'reg' */ break; } case ek.VNONRELOC: { if (reg !== e.u.info) - luaK_codeABC(fs, OpCodesI.OP_MOVE, reg, e.u.info, 0); + luaK_codeABC(fs, lopcodes.OpCodesI.OP_MOVE, reg, e.u.info, 0); break; } default: { - lua_assert(e.k === ek.VJMP); + llimits.lua_assert(e.k === ek.VJMP); return; /* nothing to do... */ } } @@ -649,8 +644,8 @@ const discharge2reg = function (fs, e, reg) { /* ** Ensures expression value is in any register. */ -const discharge2anyreg = function (fs, e) { - if (e.k !== expkind.VNONRELOC) { /* no fixed register yet? */ +export const discharge2anyreg = function (fs, e) { + if (e.k !== lparser.expkind.VNONRELOC) { /* no fixed register yet? */ luaK_reserveregs(fs, 1); /* get a register */ discharge2reg(fs, e, fs.freereg - 1); /* put value there */ } @@ -660,10 +655,10 @@ const discharge2anyreg = function (fs, e) { ** check whether list has any jump that do not produce a value ** or produce an inverted value */ -const need_value = function (fs, list) { +export const need_value = function (fs, list) { for (; list !== NO_JUMP; list = getjump(fs, list)) { let i = getjumpcontrol(fs, list); - if (i.opcode !== OpCodesI.OP_TESTSET) return true; + if (i.opcode !== lopcodes.OpCodesI.OP_TESTSET) return true; } return false; /* not found */ }; @@ -675,8 +670,8 @@ const need_value = function (fs, list) { ** its final position or to "load" instructions (for those tests ** that do not produce values). */ -const exp2reg = function (fs, e, reg) { - let ek = expkind; +export const exp2reg = function (fs, e, reg) { + let ek = lparser.expkind; discharge2reg(fs, e, reg); if (e.k === ek.VJMP) /* expression itself is a test? */ e.t = luaK_concat(fs, e.t, e.u.info); /* put this jump in 't' list */ @@ -703,7 +698,7 @@ const exp2reg = function (fs, e, reg) { ** Ensures final expression result (including results from its jump ** lists) is in next available register. */ -const luaK_exp2nextreg = function (fs, e) { +export const luaK_exp2nextreg = function (fs, e) { luaK_dischargevars(fs, e); freeexp(fs, e); luaK_reserveregs(fs, 1); @@ -715,9 +710,9 @@ const luaK_exp2nextreg = function (fs, e) { ** Ensures final expression result (including results from its jump ** lists) is in some (any) register and return that register. */ -const luaK_exp2anyreg = function (fs, e) { +export const luaK_exp2anyreg = function (fs, e) { luaK_dischargevars(fs, e); - if (e.k === expkind.VNONRELOC) { /* expression already has a register? */ + if (e.k === lparser.expkind.VNONRELOC) { /* expression already has a register? */ if (!hasjumps(e)) /* no jumps? */ return e.u.info; /* result is already in a register */ if (e.u.info >= fs.nactvar) { /* reg. is not a local? */ @@ -733,8 +728,8 @@ const luaK_exp2anyreg = function (fs, e) { ** Ensures final expression result is either in a register or in an ** upvalue. */ -const luaK_exp2anyregup = function (fs, e) { - if (e.k !== expkind.VUPVAL || hasjumps(e)) +export const luaK_exp2anyregup = function (fs, e) { + if (e.k !== lparser.expkind.VUPVAL || hasjumps(e)) luaK_exp2anyreg(fs, e); }; @@ -742,7 +737,7 @@ const luaK_exp2anyregup = function (fs, e) { ** Ensures final expression result is either in a register or it is ** a constant. */ -const luaK_exp2val = function (fs, e) { +export const luaK_exp2val = function (fs, e) { if (hasjumps(e)) luaK_exp2anyreg(fs, e); else @@ -755,8 +750,8 @@ const luaK_exp2val = function (fs, e) { ** in the range of R/K indices). ** Returns R/K index. */ -const luaK_exp2RK = function (fs, e) { - let ek = expkind; +export const luaK_exp2RK = function (fs, e) { + let ek = lparser.expkind; let vk = false; luaK_exp2val(fs, e); switch (e.k) { /* move constants to 'k' */ @@ -771,8 +766,8 @@ const luaK_exp2RK = function (fs, e) { if (vk) { e.k = ek.VK; - if (e.u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ - return RKASK(e.u.info); + if (e.u.info <= lopcodes.MAXINDEXRK) /* constant fits in 'argC'? */ + return lopcodes.RKASK(e.u.info); } /* not a constant in the right range: put it in a register */ @@ -782,8 +777,8 @@ const luaK_exp2RK = function (fs, e) { /* ** Generate code to store result of expression 'ex' into variable 'var'. */ -const luaK_storevar = function (fs, vr, ex) { - let ek = expkind; +export const luaK_storevar = function (fs, vr, ex) { + let ek = lparser.expkind; switch (vr.k) { case ek.VLOCAL: { freeexp(fs, ex); @@ -792,11 +787,11 @@ const luaK_storevar = function (fs, vr, ex) { } case ek.VUPVAL: { let e = luaK_exp2anyreg(fs, ex); - luaK_codeABC(fs, OpCodesI.OP_SETUPVAL, e, vr.u.info, 0); + luaK_codeABC(fs, lopcodes.OpCodesI.OP_SETUPVAL, e, vr.u.info, 0); break; } case ek.VINDEXED: { - let op = (vr.u.ind.vt === ek.VLOCAL) ? OpCodesI.OP_SETTABLE : OpCodesI.OP_SETTABUP; + let op = (vr.u.ind.vt === ek.VLOCAL) ? lopcodes.OpCodesI.OP_SETTABLE : lopcodes.OpCodesI.OP_SETTABUP; let e = luaK_exp2RK(fs, ex); luaK_codeABC(fs, op, vr.u.ind.t, vr.u.ind.idx, e); break; @@ -809,24 +804,24 @@ const luaK_storevar = function (fs, vr, ex) { /* ** Emit SELF instruction (convert expression 'e' into 'e:key(e,'). */ -const luaK_self = function (fs, e, key) { +export const luaK_self = function (fs, e, key) { luaK_exp2anyreg(fs, e); let ereg = e.u.info; /* register where 'e' was placed */ freeexp(fs, e); e.u.info = fs.freereg; /* base register for op_self */ - e.k = expkind.VNONRELOC; /* self expression has a fixed register */ + e.k = lparser.expkind.VNONRELOC; /* self expression has a fixed register */ luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ - luaK_codeABC(fs, OpCodesI.OP_SELF, e.u.info, ereg, luaK_exp2RK(fs, key)); + luaK_codeABC(fs, lopcodes.OpCodesI.OP_SELF, e.u.info, ereg, luaK_exp2RK(fs, key)); freeexp(fs, key); }; /* ** Negate condition 'e' (where 'e' is a comparison). */ -const negatecondition = function (fs, e) { +export const negatecondition = function (fs, e) { let pc = getjumpcontrol(fs, e.u.info); - lua_assert(testTMode(pc.opcode) && pc.opcode !== OpCodesI.OP_TESTSET && pc.opcode !== OpCodesI.OP_TEST); - SETARG_A(pc, !(pc.A)); + llimits.lua_assert(lopcodes.testTMode(pc.opcode) && pc.opcode !== lopcodes.OpCodesI.OP_TESTSET && pc.opcode !== lopcodes.OpCodesI.OP_TEST); + lopcodes.SETARG_A(pc, !(pc.A)); }; /* @@ -835,25 +830,25 @@ const negatecondition = function (fs, e) { ** Optimize when 'e' is 'not' something, inverting the condition ** and removing the 'not'. */ -const jumponcond = function (fs, e, cond) { - if (e.k === expkind.VRELOCABLE) { +export const jumponcond = function (fs, e, cond) { + if (e.k === lparser.expkind.VRELOCABLE) { let ie = getinstruction(fs, e); - if (ie.opcode === OpCodesI.OP_NOT) { + if (ie.opcode === lopcodes.OpCodesI.OP_NOT) { fs.pc--; /* remove previous OP_NOT */ - return condjump(fs, OpCodesI.OP_TEST, ie.B, 0, !cond); + return condjump(fs, lopcodes.OpCodesI.OP_TEST, ie.B, 0, !cond); } /* else go through */ } discharge2anyreg(fs, e); freeexp(fs, e); - return condjump(fs, OpCodesI.OP_TESTSET, NO_REG, e.u.info, cond); + return condjump(fs, lopcodes.OpCodesI.OP_TESTSET, lopcodes.NO_REG, e.u.info, cond); }; /* ** Emit code to go through if 'e' is true, jump otherwise. */ -const luaK_goiftrue = function (fs, e) { - let ek = expkind; +export const luaK_goiftrue = function (fs, e) { + let ek = lparser.expkind; let pc; /* pc of new jump */ luaK_dischargevars(fs, e); switch (e.k) { @@ -879,8 +874,8 @@ const luaK_goiftrue = function (fs, e) { /* ** Emit code to go through if 'e' is false, jump otherwise. */ -const luaK_goiffalse = function (fs, e) { - let ek = expkind; +export const luaK_goiffalse = function (fs, e) { + let ek = lparser.expkind; let pc; /* pc of new jump */ luaK_dischargevars(fs, e); switch (e.k) { @@ -905,8 +900,8 @@ const luaK_goiffalse = function (fs, e) { /* ** Code 'not e', doing constant folding. */ -const codenot = function (fs, e) { - let ek = expkind; +export const codenot = function (fs, e) { + let ek = lparser.expkind; luaK_dischargevars(fs, e); switch (e.k) { case ek.VNIL: case ek.VFALSE: { @@ -925,7 +920,7 @@ const codenot = function (fs, e) { case ek.VNONRELOC: { discharge2anyreg(fs, e); freeexp(fs, e); - e.u.info = luaK_codeABC(fs, OpCodesI.OP_NOT, 0, e.u.info, 0); + e.u.info = luaK_codeABC(fs, lopcodes.OpCodesI.OP_NOT, 0, e.u.info, 0); e.k = ek.VRELOCABLE; break; } @@ -940,9 +935,9 @@ const codenot = function (fs, e) { ** Create expression 't[k]'. 't' must have its final result already in a ** register or upvalue. */ -const luaK_indexed = function (fs, t, k) { - let ek = expkind; - lua_assert(!hasjumps(t) && (vkisinreg(t.k) || t.k === ek.VUPVAL)); +export const luaK_indexed = function (fs, t, k) { + let ek = lparser.expkind; + llimits.lua_assert(!hasjumps(t) && (lparser.vkisinreg(t.k) || t.k === ek.VUPVAL)); t.u.ind.t = t.u.info; /* register or upvalue index */ t.u.ind.idx = luaK_exp2RK(fs, k); /* R/K index for key */ t.u.ind.vt = (t.k === ek.VUPVAL) ? ek.VUPVAL : ek.VLOCAL; @@ -954,13 +949,13 @@ const luaK_indexed = function (fs, t, k) { ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */ -const validop = function (op, v1, v2) { +export const validop = function (op, v1, v2) { switch (op) { - case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: - case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ - return (tointeger(v1) !== false && tointeger(v2) !== false); + case defs.LUA_OPBAND: case defs.LUA_OPBOR: case defs.LUA_OPBXOR: + case defs.LUA_OPSHL: case defs.LUA_OPSHR: case defs.LUA_OPBNOT: { /* conversion errors */ + return (lvm.tointeger(v1) !== false && lvm.tointeger(v2) !== false); } - case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ + case defs.LUA_OPDIV: case defs.LUA_OPIDIV: case defs.LUA_OPMOD: /* division by 0 */ return (v2.value !== 0); default: return 1; /* everything else is valid */ } @@ -970,13 +965,13 @@ const validop = function (op, v1, v2) { ** Try to "constant-fold" an operation; return 1 iff successful. ** (In this case, 'e1' has the final result.) */ -const constfolding = function (op, e1, e2) { - let ek = expkind; +export const constfolding = function (op, e1, e2) { + let ek = lparser.expkind; let v1, v2; if (!(v1 = tonumeral(e1, true)) || !(v2 = tonumeral(e2, true)) || !validop(op, v1, v2)) return 0; /* non-numeric operands or not safe to fold */ - let res = new TValue(); /* FIXME */ - luaO_arith(null, op, v1, v2, res); /* does operation */ + let res = new lobject.TValue(); /* FIXME */ + lobject.luaO_arith(null, op, v1, v2, res); /* does operation */ if (res.ttisinteger()) { e1.k = ek.VKINT; e1.u.ival = res.value; @@ -996,11 +991,11 @@ const constfolding = function (op, e1, e2) { ** (everything but 'not'). ** Expression to produce final result will be encoded in 'e'. */ -const codeunexpval = function (fs, op, e, line) { +export const codeunexpval = function (fs, op, e, line) { let r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ freeexp(fs, e); e.u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ - e.k = expkind.VRELOCABLE; /* all those operations are relocatable */ + e.k = lparser.expkind.VRELOCABLE; /* all those operations are relocatable */ luaK_fixline(fs, line); }; @@ -1013,12 +1008,12 @@ const codeunexpval = function (fs, op, e, line) { ** in "stack order" (that is, first on 'e2', which may have more ** recent registers to be released). */ -const codebinexpval = function (fs, op, e1, e2, line) { +export const codebinexpval = function (fs, op, e1, e2, line) { let rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */ let rk1 = luaK_exp2RK(fs, e1); freeexps(fs, e1, e2); e1.u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */ - e1.k = expkind.VRELOCABLE; /* all those operations are relocatable */ + e1.k = lparser.expkind.VRELOCABLE; /* all those operations are relocatable */ luaK_fixline(fs, line); }; @@ -1027,14 +1022,14 @@ const codebinexpval = function (fs, op, e1, e2, line) { ** Emit code for comparisons. ** 'e1' was already put in R/K form by 'luaK_infix'. */ -const codecomp = function (fs, opr, e1, e2) { - let ek = expkind; +export const codecomp = function (fs, opr, e1, e2) { + let ek = lparser.expkind; let rk1; if (e1.k === ek.VK) - rk1 = RKASK(e1.u.info); + rk1 = lopcodes.RKASK(e1.u.info); else { - lua_assert(e1.k === ek.VNONRELOC); + llimits.lua_assert(e1.k === ek.VNONRELOC); rk1 = e1.u.info; } @@ -1042,17 +1037,17 @@ const codecomp = function (fs, opr, e1, e2) { freeexps(fs, e1, e2); switch (opr) { case BinOpr.OPR_NE: { /* '(a ~= b)' ==> 'not (a === b)' */ - e1.u.info = condjump(fs, OpCodesI.OP_EQ, 0, rk1, rk2); + e1.u.info = condjump(fs, lopcodes.OpCodesI.OP_EQ, 0, rk1, rk2); break; } case BinOpr.OPR_GT: case BinOpr.OPR_GE: { /* '(a > b)' ==> '(b < a)'; '(a >= b)' ==> '(b <= a)' */ - let op = (opr - BinOpr.OPR_NE) + OpCodesI.OP_EQ; + let op = (opr - BinOpr.OPR_NE) + lopcodes.OpCodesI.OP_EQ; e1.u.info = condjump(fs, op, 1, rk2, rk1); /* invert operands */ break; } default: { /* '==', '<', '<=' use their own opcodes */ - let op = (opr - BinOpr.OPR_EQ) + OpCodesI.OP_EQ; + let op = (opr - BinOpr.OPR_EQ) + lopcodes.OpCodesI.OP_EQ; e1.u.info = condjump(fs, op, 1, rk1, rk2); break; } @@ -1063,19 +1058,19 @@ const codecomp = function (fs, opr, e1, e2) { /* ** Apply prefix operation 'op' to expression 'e'. */ -const luaK_prefix = function (fs, op, e, line) { - let ef = new expdesc(); - ef.k = expkind.VKINT; +export const luaK_prefix = function (fs, op, e, line) { + let ef = new lparser.expdesc(); + ef.k = lparser.expkind.VKINT; ef.u.ival = ef.u.nval = ef.u.info = 0; ef.t = NO_JUMP; ef.f = NO_JUMP; switch (op) { case UnOpr.OPR_MINUS: case UnOpr.OPR_BNOT: /* use 'ef' as fake 2nd operand */ - if (constfolding(op + LUA_OPUNM, e, ef)) + if (constfolding(op + defs.LUA_OPUNM, e, ef)) break; /* FALLTHROUGH */ case UnOpr.OPR_LEN: - codeunexpval(fs, op + OpCodesI.OP_UNM, e, line); + codeunexpval(fs, op + lopcodes.OpCodesI.OP_UNM, e, line); break; case UnOpr.OPR_NOT: codenot(fs, e); break; } @@ -1085,7 +1080,7 @@ const luaK_prefix = function (fs, op, e, line) { ** Process 1st operand 'v' of binary operation 'op' before reading ** 2nd operand. */ -const luaK_infix = function (fs, op, v) { +export const luaK_infix = function (fs, op, v) { switch (op) { case BinOpr.OPR_AND: { luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ @@ -1122,18 +1117,18 @@ const luaK_infix = function (fs, op, v) { ** concatenation is right associative), merge second CONCAT into first ** one. */ -const luaK_posfix = function (fs, op, e1, e2, line) { - let ek = expkind; +export const luaK_posfix = function (fs, op, e1, e2, line) { + let ek = lparser.expkind; switch (op) { case BinOpr.OPR_AND: { - lua_assert(e1.t === NO_JUMP); /* list closed by 'luK_infix' */ + llimits.lua_assert(e1.t === NO_JUMP); /* list closed by 'luK_infix' */ luaK_dischargevars(fs, e2); e2.f = luaK_concat(fs, e2.f, e1.f); e1.to(e2); break; } case BinOpr.OPR_OR: { - lua_assert(e1.f === NO_JUMP); /* list closed by 'luK_infix' */ + llimits.lua_assert(e1.f === NO_JUMP); /* list closed by 'luK_infix' */ luaK_dischargevars(fs, e2); e2.t = luaK_concat(fs, e2.t, e1.t); e1.to(e2); @@ -1142,15 +1137,15 @@ const luaK_posfix = function (fs, op, e1, e2, line) { case BinOpr.OPR_CONCAT: { luaK_exp2val(fs, e2); let ins = getinstruction(fs, e2); - if (e2.k === ek.VRELOCABLE && ins.opcode === OpCodesI.OP_CONCAT) { - lua_assert(e1.u.info === ins.B - 1); + if (e2.k === ek.VRELOCABLE && ins.opcode === lopcodes.OpCodesI.OP_CONCAT) { + llimits.lua_assert(e1.u.info === ins.B - 1); freeexp(fs, e1); - SETARG_B(ins, e1.u.info); + lopcodes.SETARG_B(ins, e1.u.info); e1.k = ek.VRELOCABLE; e1.u.info = e2.u.info; } else { luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ - codebinexpval(fs, OpCodesI.OP_CONCAT, e1, e2, line); + codebinexpval(fs, lopcodes.OpCodesI.OP_CONCAT, e1, e2, line); } break; } @@ -1158,8 +1153,8 @@ const luaK_posfix = function (fs, op, e1, e2, line) { case BinOpr.OPR_IDIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: case BinOpr.OPR_BAND: case BinOpr.OPR_BOR: case BinOpr.OPR_BXOR: case BinOpr.OPR_SHL: case BinOpr.OPR_SHR: { - if (!constfolding(op + LUA_OPADD, e1, e2)) - codebinexpval(fs, op + OpCodesI.OP_ADD, e1, e2, line); + if (!constfolding(op + defs.LUA_OPADD, e1, e2)) + codebinexpval(fs, op + lopcodes.OpCodesI.OP_ADD, e1, e2, line); break; } case BinOpr.OPR_EQ: case BinOpr.OPR_LT: case BinOpr.OPR_LE: @@ -1175,7 +1170,7 @@ const luaK_posfix = function (fs, op, e1, e2, line) { /* ** Change line information associated with current position. */ -const luaK_fixline = function (fs, line) { +export const luaK_fixline = function (fs, line) { fs.f.lineinfo[fs.pc - 1] = line; }; @@ -1186,103 +1181,17 @@ const luaK_fixline = function (fs, line) { ** 'tostore' is number of values (in registers 'base + 1',...) to add to ** table (or LUA_MULTRET to add up to stack top). */ -const luaK_setlist = function (fs, base, nelems, tostore) { - let c = (nelems - 1) / LFIELDS_PER_FLUSH + 1; - let b = (tostore === LUA_MULTRET) ? 0 : tostore; - lua_assert(tostore !== 0 && tostore <= LFIELDS_PER_FLUSH); - if (c <= MAXARG_C) - luaK_codeABC(fs, OpCodesI.OP_SETLIST, base, b, c); - else if (c <= MAXARG_Ax) { - luaK_codeABC(fs, OpCodesI.OP_SETLIST, base, b, 0); +export const luaK_setlist = function (fs, base, nelems, tostore) { + let c = (nelems - 1) / lopcodes.LFIELDS_PER_FLUSH + 1; + let b = (tostore === defs.LUA_MULTRET) ? 0 : tostore; + llimits.lua_assert(tostore !== 0 && tostore <= lopcodes.LFIELDS_PER_FLUSH); + if (c <= lopcodes.MAXARG_C) + luaK_codeABC(fs, lopcodes.OpCodesI.OP_SETLIST, base, b, c); + else if (c <= lopcodes.MAXARG_Ax) { + luaK_codeABC(fs, lopcodes.OpCodesI.OP_SETLIST, base, b, 0); codeextraarg(fs, c); } else - luaX_syntaxerror(fs.ls, to_luastring('constructor too long', true)); + llex.luaX_syntaxerror(fs.ls, defs.to_luastring('constructor too long', true)); fs.freereg = base + 1; /* free registers with list values */ }; - - -const _BinOpr = BinOpr; -export { _BinOpr as BinOpr }; -const _NO_JUMP = NO_JUMP; -export { _NO_JUMP as NO_JUMP }; -const _UnOpr = UnOpr; -export { _UnOpr as UnOpr }; -const _getinstruction = getinstruction; -export { _getinstruction as getinstruction }; -const _luaK_checkstack = luaK_checkstack; -export { _luaK_checkstack as luaK_checkstack }; -const _luaK_code = luaK_code; -export { _luaK_code as luaK_code }; -const _luaK_codeABC = luaK_codeABC; -export { _luaK_codeABC as luaK_codeABC }; -const _luaK_codeABx = luaK_codeABx; -export { _luaK_codeABx as luaK_codeABx }; -const _luaK_codeAsBx = luaK_codeAsBx; -export { _luaK_codeAsBx as luaK_codeAsBx }; -const _luaK_codek = luaK_codek; -export { _luaK_codek as luaK_codek }; -const _luaK_concat = luaK_concat; -export { _luaK_concat as luaK_concat }; -const _luaK_dischargevars = luaK_dischargevars; -export { _luaK_dischargevars as luaK_dischargevars }; -const _luaK_exp2RK = luaK_exp2RK; -export { _luaK_exp2RK as luaK_exp2RK }; -const _luaK_exp2anyreg = luaK_exp2anyreg; -export { _luaK_exp2anyreg as luaK_exp2anyreg }; -const _luaK_exp2anyregup = luaK_exp2anyregup; -export { _luaK_exp2anyregup as luaK_exp2anyregup }; -const _luaK_exp2nextreg = luaK_exp2nextreg; -export { _luaK_exp2nextreg as luaK_exp2nextreg }; -const _luaK_exp2val = luaK_exp2val; -export { _luaK_exp2val as luaK_exp2val }; -const _luaK_fixline = luaK_fixline; -export { _luaK_fixline as luaK_fixline }; -const _luaK_getlabel = luaK_getlabel; -export { _luaK_getlabel as luaK_getlabel }; -const _luaK_goiffalse = luaK_goiffalse; -export { _luaK_goiffalse as luaK_goiffalse }; -const _luaK_goiftrue = luaK_goiftrue; -export { _luaK_goiftrue as luaK_goiftrue }; -const _luaK_indexed = luaK_indexed; -export { _luaK_indexed as luaK_indexed }; -const _luaK_infix = luaK_infix; -export { _luaK_infix as luaK_infix }; -const _luaK_intK = luaK_intK; -export { _luaK_intK as luaK_intK }; -const _luaK_jump = luaK_jump; -export { _luaK_jump as luaK_jump }; -const _luaK_jumpto = luaK_jumpto; -export { _luaK_jumpto as luaK_jumpto }; -const _luaK_nil = luaK_nil; -export { _luaK_nil as luaK_nil }; -const _luaK_numberK = luaK_numberK; -export { _luaK_numberK as luaK_numberK }; -const _luaK_patchclose = luaK_patchclose; -export { _luaK_patchclose as luaK_patchclose }; -const _luaK_patchlist = luaK_patchlist; -export { _luaK_patchlist as luaK_patchlist }; -const _luaK_patchtohere = luaK_patchtohere; -export { _luaK_patchtohere as luaK_patchtohere }; -const _luaK_posfix = luaK_posfix; -export { _luaK_posfix as luaK_posfix }; -const _luaK_prefix = luaK_prefix; -export { _luaK_prefix as luaK_prefix }; -const _luaK_reserveregs = luaK_reserveregs; -export { _luaK_reserveregs as luaK_reserveregs }; -const _luaK_ret = luaK_ret; -export { _luaK_ret as luaK_ret }; -const _luaK_self = luaK_self; -export { _luaK_self as luaK_self }; -const _luaK_setlist = luaK_setlist; -export { _luaK_setlist as luaK_setlist }; -const _luaK_setmultret = luaK_setmultret; -export { _luaK_setmultret as luaK_setmultret }; -const _luaK_setoneret = luaK_setoneret; -export { _luaK_setoneret as luaK_setoneret }; -const _luaK_setreturns = luaK_setreturns; -export { _luaK_setreturns as luaK_setreturns }; -const _luaK_storevar = luaK_storevar; -export { _luaK_storevar as luaK_storevar }; -const _luaK_stringK = luaK_stringK; -export { _luaK_stringK as luaK_stringK }; diff --git a/src/lcorolib.js b/src/lcorolib.js index 459dd226..9988a61c 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -1,111 +1,109 @@ -'use strict'; - -import { LUA_OK, LUA_TFUNCTION, LUA_TSTRING, LUA_YIELD, lua_Debug, lua_checkstack, lua_concat, lua_error, lua_getstack, lua_gettop, lua_insert, lua_isyieldable, lua_newthread, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushliteral, lua_pushthread, lua_pushvalue, lua_resume, lua_status, lua_tothread, lua_type, lua_upvalueindex, lua_xmove, lua_yield } from './lua.js'; -import { luaL_argcheck, luaL_checktype, luaL_newlib, luaL_where } from './lauxlib.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; const getco = function(L) { - let co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, 'thread expected'); + let co = lua.lua_tothread(L, 1); + lauxlib.luaL_argcheck(L, co, 1, 'thread expected'); return co; }; const auxresume = function(L, co, narg) { - if (!lua_checkstack(co, narg)) { - lua_pushliteral(L, 'too many arguments to resume'); + if (!lua.lua_checkstack(co, narg)) { + lua.lua_pushliteral(L, 'too many arguments to resume'); return -1; /* error flag */ } - if (lua_status(co) === LUA_OK && lua_gettop(co) === 0) { - lua_pushliteral(L, 'cannot resume dead coroutine'); + if (lua.lua_status(co) === lua.LUA_OK && lua.lua_gettop(co) === 0) { + lua.lua_pushliteral(L, 'cannot resume dead coroutine'); return -1; /* error flag */ } - lua_xmove(L, co, narg); - let status = lua_resume(co, L, narg); - if (status === LUA_OK || status === LUA_YIELD) { - let nres = lua_gettop(co); - if (!lua_checkstack(L, nres + 1)) { - lua_pop(co, nres); /* remove results anyway */ - lua_pushliteral(L, 'too many results to resume'); + lua.lua_xmove(L, co, narg); + let status = lua.lua_resume(co, L, narg); + if (status === lua.LUA_OK || status === lua.LUA_YIELD) { + let nres = lua.lua_gettop(co); + if (!lua.lua_checkstack(L, nres + 1)) { + lua.lua_pop(co, nres); /* remove results anyway */ + lua.lua_pushliteral(L, 'too many results to resume'); return -1; /* error flag */ } - lua_xmove(co, L, nres); /* move yielded values */ + lua.lua_xmove(co, L, nres); /* move yielded values */ return nres; } else { - lua_xmove(co, L, 1); /* move error message */ + lua.lua_xmove(co, L, 1); /* move error message */ return -1; /* error flag */ } }; const luaB_coresume = function(L) { let co = getco(L); - let r = auxresume(L, co, lua_gettop(L) - 1); + let r = auxresume(L, co, lua.lua_gettop(L) - 1); if (r < 0) { - lua_pushboolean(L, 0); - lua_insert(L, -2); + lua.lua_pushboolean(L, 0); + lua.lua_insert(L, -2); return 2; /* return false + error message */ } else { - lua_pushboolean(L, 1); - lua_insert(L, -(r + 1)); + lua.lua_pushboolean(L, 1); + lua.lua_insert(L, -(r + 1)); return r + 1; /* return true + 'resume' returns */ } }; const luaB_auxwrap = function(L) { - let co = lua_tothread(L, lua_upvalueindex(1)); - let r = auxresume(L, co, lua_gettop(L)); + let co = lua.lua_tothread(L, lua.lua_upvalueindex(1)); + let r = auxresume(L, co, lua.lua_gettop(L)); if (r < 0) { - if (lua_type(L, -1) === LUA_TSTRING) { /* error object is a string? */ - luaL_where(L, 1); /* add extra info */ - lua_insert(L, -2); - lua_concat(L, 2); + if (lua.lua_type(L, -1) === lua.LUA_TSTRING) { /* error object is a string? */ + lauxlib.luaL_where(L, 1); /* add extra info */ + lua.lua_insert(L, -2); + lua.lua_concat(L, 2); } - return lua_error(L); /* propagate error */ + return lua.lua_error(L); /* propagate error */ } return r; }; const luaB_cocreate = function(L) { - luaL_checktype(L, 1, LUA_TFUNCTION); - let NL = lua_newthread(L); - lua_pushvalue(L, 1); /* move function to top */ - lua_xmove(L, NL, 1); /* move function from L to NL */ + lauxlib.luaL_checktype(L, 1, lua.LUA_TFUNCTION); + let NL = lua.lua_newthread(L); + lua.lua_pushvalue(L, 1); /* move function to top */ + lua.lua_xmove(L, NL, 1); /* move function from L to NL */ return 1; }; const luaB_cowrap = function(L) { luaB_cocreate(L); - lua_pushcclosure(L, luaB_auxwrap, 1); + lua.lua_pushcclosure(L, luaB_auxwrap, 1); return 1; }; const luaB_yield = function(L) { - return lua_yield(L, lua_gettop(L)); + return lua.lua_yield(L, lua.lua_gettop(L)); }; const luaB_costatus = function(L) { let co = getco(L); - if (L === co) lua_pushliteral(L, 'running'); + if (L === co) lua.lua_pushliteral(L, 'running'); else { - switch (lua_status(co)) { - case LUA_YIELD: - lua_pushliteral(L, 'suspended'); + switch (lua.lua_status(co)) { + case lua.LUA_YIELD: + lua.lua_pushliteral(L, 'suspended'); break; - case LUA_OK: { - let ar = new lua_Debug(); - if (lua_getstack(co, 0, ar) > 0) /* does it have frames? */ - lua_pushliteral(L, 'normal'); /* it is running */ - else if (lua_gettop(co) === 0) - lua_pushliteral(L, 'dead'); + case lua.LUA_OK: { + let ar = new lua.lua_Debug(); + if (lua.lua_getstack(co, 0, ar) > 0) /* does it have frames? */ + lua.lua_pushliteral(L, 'normal'); /* it is running */ + else if (lua.lua_gettop(co) === 0) + lua.lua_pushliteral(L, 'dead'); else - lua_pushliteral(L, 'suspended'); /* initial state */ + lua.lua_pushliteral(L, 'suspended'); /* initial state */ break; } default: /* some error occurred */ - lua_pushliteral(L, 'dead'); + lua.lua_pushliteral(L, 'dead'); break; } } @@ -114,12 +112,12 @@ const luaB_costatus = function(L) { }; const luaB_yieldable = function(L) { - lua_pushboolean(L, lua_isyieldable(L)); + lua.lua_pushboolean(L, lua.lua_isyieldable(L)); return 1; }; const luaB_corunning = function(L) { - lua_pushboolean(L, lua_pushthread(L)); + lua.lua_pushboolean(L, lua.lua_pushthread(L)); return 2; }; @@ -133,10 +131,7 @@ const co_funcs = { 'yield': luaB_yield }; -const luaopen_coroutine = function(L) { - luaL_newlib(L, co_funcs); +export const luaopen_coroutine = function(L) { + lauxlib.luaL_newlib(L, co_funcs); return 1; }; - -const _luaopen_coroutine = luaopen_coroutine; -export { _luaopen_coroutine as luaopen_coroutine }; diff --git a/src/ldblib.js b/src/ldblib.js index 2c05b889..5c1dbbc8 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -1,8 +1,13 @@ -import { LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_REGISTRYINDEX, LUA_TFUNCTION, LUA_TNIL, LUA_TTABLE, LUA_TUSERDATA, lua_Debug, lua_call, lua_checkstack, lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getlocal, lua_getmetatable, lua_getstack, lua_getupvalue, lua_getuservalue, lua_insert, lua_iscfunction, lua_isfunction, lua_isnoneornil, lua_isthread, lua_newtable, lua_pcall, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushlightuserdata, lua_pushliteral, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgetp, lua_rawsetp, lua_rotate, lua_setfield, lua_sethook, lua_setlocal, lua_setmetatable, lua_settop, lua_setupvalue, lua_setuservalue, lua_tojsstring, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_upvalueid, lua_upvaluejoin, lua_xmove } from './lua.js'; -import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checkstring, luaL_checktype, luaL_error, luaL_loadbuffer, luaL_newlib, luaL_optinteger, luaL_optstring, luaL_traceback, lua_writestringerror } from './lauxlib.js'; -import { lua_assert } from './lualib.js'; -import { luastring_indexOf, to_luastring } from './fengaricore.js'; -import readlineSync from 'readline-sync'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as lualib from './lualib.js'; +import * as fengaricore from './fengaricore.js'; + +let readlineSync; + +if (typeof process !== 'undefined') { // Only with Node + readlineSync = require('readline-sync'); +} /* ** If L1 != L, L1 can be in any state, and therefore there are no @@ -10,45 +15,45 @@ import readlineSync from 'readline-sync'; ** checked. */ const checkstack = function(L, L1, n) { - if (L !== L1 && !lua_checkstack(L1, n)) - luaL_error(L, to_luastring('stack overflow', true)); + if (L !== L1 && !lua.lua_checkstack(L1, n)) + lauxlib.luaL_error(L, fengaricore.to_luastring('stack overflow', true)); }; const db_getregistry = function(L) { - lua_pushvalue(L, LUA_REGISTRYINDEX); + lua.lua_pushvalue(L, lua.LUA_REGISTRYINDEX); return 1; }; const db_getmetatable = function(L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); /* no metatable */ + lauxlib.luaL_checkany(L, 1); + if (!lua.lua_getmetatable(L, 1)) { + lua.lua_pushnil(L); /* no metatable */ } return 1; }; const db_setmetatable = function(L) { - const t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, 'nil or table expected'); - lua_settop(L, 2); - lua_setmetatable(L, 1); + const t = lua.lua_type(L, 2); + lauxlib.luaL_argcheck(L, t == lua.LUA_TNIL || t == lua.LUA_TTABLE, 2, 'nil or table expected'); + lua.lua_settop(L, 2); + lua.lua_setmetatable(L, 1); return 1; /* return 1st argument */ }; const db_getuservalue = function(L) { - if (lua_type(L, 1) !== LUA_TUSERDATA) - lua_pushnil(L); + if (lua.lua_type(L, 1) !== lua.LUA_TUSERDATA) + lua.lua_pushnil(L); else - lua_getuservalue(L, 1); + lua.lua_getuservalue(L, 1); return 1; }; const db_setuservalue = function(L) { - luaL_checktype(L, 1, LUA_TUSERDATA); - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_setuservalue(L, 1); + lauxlib.luaL_checktype(L, 1, lua.LUA_TUSERDATA); + lauxlib.luaL_checkany(L, 2); + lua.lua_settop(L, 2); + lua.lua_setuservalue(L, 1); return 1; }; @@ -59,10 +64,10 @@ const db_setuservalue = function(L) { ** access their other arguments) */ const getthread = function(L) { - if (lua_isthread(L, 1)) { + if (lua.lua_isthread(L, 1)) { return { arg: 1, - thread: lua_tothread(L, 1) + thread: lua.lua_tothread(L, 1) }; } else { return { @@ -78,18 +83,18 @@ const getthread = function(L) { ** value can be a string, an int, or a boolean. */ const settabss = function(L, k, v) { - lua_pushstring(L, v); - lua_setfield(L, -2, k); + lua.lua_pushstring(L, v); + lua.lua_setfield(L, -2, k); }; const settabsi = function(L, k, v) { - lua_pushinteger(L, v); - lua_setfield(L, -2, k); + lua.lua_pushinteger(L, v); + lua.lua_setfield(L, -2, k); }; const settabsb = function(L, k, v) { - lua_pushboolean(L, v); - lua_setfield(L, -2, k); + lua.lua_pushboolean(L, v); + lua.lua_setfield(L, -2, k); }; @@ -102,10 +107,10 @@ const settabsb = function(L, k, v) { */ const treatstackoption = function(L, L1, fname) { if (L == L1) - lua_rotate(L, -2, 1); /* exchange object and table */ + lua.lua_rotate(L, -2, 1); /* exchange object and table */ else - lua_xmove(L1, L, 1); /* move object to the "main" stack */ - lua_setfield(L, -2, fname); /* put object into table */ + lua.lua_xmove(L1, L, 1); /* move object to the "main" stack */ + lua.lua_setfield(L, -2, fname); /* put object into table */ }; /* @@ -115,50 +120,50 @@ const treatstackoption = function(L, L1, fname) { ** 'lua_getinfo'. */ const db_getinfo = function(L) { - let ar = new lua_Debug(); + let ar = new lua.lua_Debug(); let thread = getthread(L); let arg = thread.arg; let L1 = thread.thread; - let options = luaL_optstring(L, arg + 2, 'flnStu'); + let options = lauxlib.luaL_optstring(L, arg + 2, 'flnStu'); checkstack(L, L1, 3); - if (lua_isfunction(L, arg + 1)) { /* info about a function? */ - options = lua_pushfstring(L, to_luastring('>%s'), options); /* add '>' to 'options' */ - lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ - lua_xmove(L, L1, 1); + if (lua.lua_isfunction(L, arg + 1)) { /* info about a function? */ + options = lua.lua_pushfstring(L, fengaricore.to_luastring('>%s'), options); /* add '>' to 'options' */ + lua.lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ + lua.lua_xmove(L, L1, 1); } else { /* stack level */ - if (!lua_getstack(L1, luaL_checkinteger(L, arg + 1), ar)) { - lua_pushnil(L); /* level out of range */ + if (!lua.lua_getstack(L1, lauxlib.luaL_checkinteger(L, arg + 1), ar)) { + lua.lua_pushnil(L); /* level out of range */ return 1; } } - if (!lua_getinfo(L1, options, ar)) - luaL_argerror(L, arg + 2, 'invalid option'); - lua_newtable(L); /* table to collect results */ - if (luastring_indexOf(options, 83 /* 'S'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring('source', true), ar.source); - settabss(L, to_luastring('short_src', true), ar.short_src); - settabsi(L, to_luastring('linedefined', true), ar.linedefined); - settabsi(L, to_luastring('lastlinedefined', true), ar.lastlinedefined); - settabss(L, to_luastring('what', true), ar.what); + if (!lua.lua_getinfo(L1, options, ar)) + lauxlib.luaL_argerror(L, arg + 2, 'invalid option'); + lua.lua_newtable(L); /* table to collect results */ + if (fengaricore.luastring_indexOf(options, 83 /* 'S'.charCodeAt(0) */) > -1) { + settabss(L, fengaricore.to_luastring('source', true), ar.source); + settabss(L, fengaricore.to_luastring('short_src', true), ar.short_src); + settabsi(L, fengaricore.to_luastring('linedefined', true), ar.linedefined); + settabsi(L, fengaricore.to_luastring('lastlinedefined', true), ar.lastlinedefined); + settabss(L, fengaricore.to_luastring('what', true), ar.what); } - if (luastring_indexOf(options, 108 /* 'l'.charCodeAt(0) */) > -1) - settabsi(L, to_luastring('currentline', true), ar.currentline); - if (luastring_indexOf(options, 117 /* 'u'.charCodeAt(0) */) > -1) { - settabsi(L, to_luastring('nups', true), ar.nups); - settabsi(L, to_luastring('nparams', true), ar.nparams); - settabsb(L, to_luastring('isvararg', true), ar.isvararg); + if (fengaricore.luastring_indexOf(options, 108 /* 'l'.charCodeAt(0) */) > -1) + settabsi(L, fengaricore.to_luastring('currentline', true), ar.currentline); + if (fengaricore.luastring_indexOf(options, 117 /* 'u'.charCodeAt(0) */) > -1) { + settabsi(L, fengaricore.to_luastring('nups', true), ar.nups); + settabsi(L, fengaricore.to_luastring('nparams', true), ar.nparams); + settabsb(L, fengaricore.to_luastring('isvararg', true), ar.isvararg); } - if (luastring_indexOf(options, 110 /* 'n'.charCodeAt(0) */) > -1) { - settabss(L, to_luastring('name', true), ar.name); - settabss(L, to_luastring('namewhat', true), ar.namewhat); + if (fengaricore.luastring_indexOf(options, 110 /* 'n'.charCodeAt(0) */) > -1) { + settabss(L, fengaricore.to_luastring('name', true), ar.name); + settabss(L, fengaricore.to_luastring('namewhat', true), ar.namewhat); } - if (luastring_indexOf(options, 116 /* 't'.charCodeAt(0) */) > -1) - settabsb(L, to_luastring('istailcall', true), ar.istailcall); - if (luastring_indexOf(options, 76 /* 'L'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring('activelines', true)); - if (luastring_indexOf(options, 102 /* 'f'.charCodeAt(0) */) > -1) - treatstackoption(L, L1, to_luastring('func', true)); + if (fengaricore.luastring_indexOf(options, 116 /* 't'.charCodeAt(0) */) > -1) + settabsb(L, fengaricore.to_luastring('istailcall', true), ar.istailcall); + if (fengaricore.luastring_indexOf(options, 76 /* 'L'.charCodeAt(0) */) > -1) + treatstackoption(L, L1, fengaricore.to_luastring('activelines', true)); + if (fengaricore.luastring_indexOf(options, 102 /* 'f'.charCodeAt(0) */) > -1) + treatstackoption(L, L1, fengaricore.to_luastring('func', true)); return 1; /* return table */ }; @@ -166,26 +171,26 @@ const db_getlocal = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; - let ar = new lua_Debug(); - let nvar = luaL_checkinteger(L, arg + 2); /* local-variable index */ - if (lua_isfunction(L, arg + 1)) { - lua_pushvalue(L, arg + 1); /* push function */ - lua_pushstring(L, lua_getlocal(L, null, nvar)); /* push local name */ + let ar = new lua.lua_Debug(); + let nvar = lauxlib.luaL_checkinteger(L, arg + 2); /* local-variable index */ + if (lua.lua_isfunction(L, arg + 1)) { + lua.lua_pushvalue(L, arg + 1); /* push function */ + lua.lua_pushstring(L, lua.lua_getlocal(L, null, nvar)); /* push local name */ return 1; /* return only name (there is no value) */ } else { /* stack-level argument */ - let level = luaL_checkinteger(L, arg + 1); - if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg+1, 'level out of range'); + let level = lauxlib.luaL_checkinteger(L, arg + 1); + if (!lua.lua_getstack(L1, level, ar)) /* out of range? */ + return lauxlib.luaL_argerror(L, arg+1, 'level out of range'); checkstack(L, L1, 1); - let name = lua_getlocal(L1, ar, nvar); + let name = lua.lua_getlocal(L1, ar, nvar); if (name) { - lua_xmove(L1, L, 1); /* move local value */ - lua_pushstring(L, name); /* push name */ - lua_rotate(L, -2, 1); /* re-order */ + lua.lua_xmove(L1, L, 1); /* move local value */ + lua.lua_pushstring(L, name); /* push name */ + lua.lua_rotate(L, -2, 1); /* re-order */ return 2; } else { - lua_pushnil(L); /* no name (nor value) */ + lua.lua_pushnil(L); /* no name (nor value) */ return 1; } } @@ -195,19 +200,19 @@ const db_setlocal = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; - let ar = new lua_Debug(); - let level = luaL_checkinteger(L, arg + 1); - let nvar = luaL_checkinteger(L, arg + 2); - if (!lua_getstack(L1, level, ar)) /* out of range? */ - return luaL_argerror(L, arg + 1, 'level out of range'); - luaL_checkany(L, arg + 3); - lua_settop(L, arg + 3); + let ar = new lua.lua_Debug(); + let level = lauxlib.luaL_checkinteger(L, arg + 1); + let nvar = lauxlib.luaL_checkinteger(L, arg + 2); + if (!lua.lua_getstack(L1, level, ar)) /* out of range? */ + return lauxlib.luaL_argerror(L, arg + 1, 'level out of range'); + lauxlib.luaL_checkany(L, arg + 3); + lua.lua_settop(L, arg + 3); checkstack(L, L1, 1); - lua_xmove(L, L1, 1); - let name = lua_setlocal(L1, ar, nvar); + lua.lua_xmove(L, L1, 1); + let name = lua.lua_setlocal(L1, ar, nvar); if (name === null) - lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ - lua_pushstring(L, name); + lua.lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ + lua.lua_pushstring(L, name); return 1; }; @@ -215,12 +220,12 @@ const db_setlocal = function(L) { ** get (if 'get' is true) or set an upvalue from a closure */ const auxupvalue = function(L, get) { - let n = luaL_checkinteger(L, 2); /* upvalue index */ - luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ - let name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + let n = lauxlib.luaL_checkinteger(L, 2); /* upvalue index */ + lauxlib.luaL_checktype(L, 1, lua.LUA_TFUNCTION); /* closure */ + let name = get ? lua.lua_getupvalue(L, 1, n) : lua.lua_setupvalue(L, 1, n); if (name === null) return 0; - lua_pushstring(L, name); - lua_insert(L, -(get+1)); /* no-op if get is false */ + lua.lua_pushstring(L, name); + lua.lua_insert(L, -(get+1)); /* no-op if get is false */ return get + 1; }; @@ -230,7 +235,7 @@ const db_getupvalue = function(L) { }; const db_setupvalue = function(L) { - luaL_checkany(L, 3); + lauxlib.luaL_checkany(L, 3); return auxupvalue(L, 0); }; @@ -239,24 +244,24 @@ const db_setupvalue = function(L) { ** returns its index */ const checkupval = function(L, argf, argnup) { - let nup = luaL_checkinteger(L, argnup); /* upvalue index */ - luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ - luaL_argcheck(L, (lua_getupvalue(L, argf, nup) !== null), argnup, 'invalid upvalue index'); + let nup = lauxlib.luaL_checkinteger(L, argnup); /* upvalue index */ + lauxlib.luaL_checktype(L, argf, lua.LUA_TFUNCTION); /* closure */ + lauxlib.luaL_argcheck(L, (lua.lua_getupvalue(L, argf, nup) !== null), argnup, 'invalid upvalue index'); return nup; }; const db_upvalueid = function(L) { let n = checkupval(L, 1, 2); - lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); + lua.lua_pushlightuserdata(L, lua.lua_upvalueid(L, 1, n)); return 1; }; const db_upvaluejoin = function(L) { let n1 = checkupval(L, 1, 2); let n2 = checkupval(L, 3, 4); - luaL_argcheck(L, !lua_iscfunction(L, 1), 1, 'Lua function expected'); - luaL_argcheck(L, !lua_iscfunction(L, 3), 3, 'Lua function expected'); - lua_upvaluejoin(L, 1, n1, 3, n2); + lauxlib.luaL_argcheck(L, !lua.lua_iscfunction(L, 1), 1, 'Lua function expected'); + lauxlib.luaL_argcheck(L, !lua.lua_iscfunction(L, 3), 3, 'Lua function expected'); + lua.lua_upvaluejoin(L, 1, n1, 3, n2); return 0; }; @@ -264,26 +269,26 @@ const db_upvaluejoin = function(L) { ** The hook table at registry[HOOKKEY] maps threads to their current ** hook function. (We only need the unique address of 'HOOKKEY'.) */ -const HOOKKEY = to_luastring('__hooks__', true); +const HOOKKEY = fengaricore.to_luastring('__hooks__', true); -const hooknames = ['call', 'return', 'line', 'count', 'tail call'].map(e => to_luastring(e)); +const hooknames = ['call', 'return', 'line', 'count', 'tail call'].map(e => fengaricore.to_luastring(e)); /* ** Call hook function registered at hook table for the current ** thread (if there is one) */ const hookf = function(L, ar) { - lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); - let hooktable = lua_touserdata(L, -1); + lua.lua_rawgetp(L, lua.LUA_REGISTRYINDEX, HOOKKEY); + let hooktable = lua.lua_touserdata(L, -1); let proxy = hooktable.get(L); if (proxy) { /* is there a hook function? */ proxy(L); - lua_pushstring(L, hooknames[ar.event]); /* push event name */ + lua.lua_pushstring(L, hooknames[ar.event]); /* push event name */ if (ar.currentline >= 0) - lua_pushinteger(L, ar.currentline); /* push current line */ - else lua_pushnil(L); - lua_assert(lua_getinfo(L, to_luastring('lS'), ar)); - lua_call(L, 2, 0); /* call hook function */ + lua.lua_pushinteger(L, ar.currentline); /* push current line */ + else lua.lua_pushnil(L); + lualib.lua_assert(lua.lua_getinfo(L, fengaricore.to_luastring('lS'), ar)); + lua.lua_call(L, 2, 0); /* call hook function */ } }; @@ -292,10 +297,10 @@ const hookf = function(L, ar) { */ const makemask = function(smask, count) { let mask = 0; - if (luastring_indexOf(smask, 99 /* 'c'.charCodeAt(0) */) > -1) mask |= LUA_MASKCALL; - if (luastring_indexOf(smask, 114 /* 'r'.charCodeAt(0) */) > -1) mask |= LUA_MASKRET; - if (luastring_indexOf(smask, 108 /* 'l'.charCodeAt(0) */) > -1) mask |= LUA_MASKLINE; - if (count > 0) mask |= LUA_MASKCOUNT; + if (fengaricore.luastring_indexOf(smask, 99 /* 'c'.charCodeAt(0) */) > -1) mask |= lua.LUA_MASKCALL; + if (fengaricore.luastring_indexOf(smask, 114 /* 'r'.charCodeAt(0) */) > -1) mask |= lua.LUA_MASKRET; + if (fengaricore.luastring_indexOf(smask, 108 /* 'l'.charCodeAt(0) */) > -1) mask |= lua.LUA_MASKLINE; + if (count > 0) mask |= lua.LUA_MASKCOUNT; return mask; }; @@ -304,9 +309,9 @@ const makemask = function(smask, count) { */ const unmakemask = function(mask, smask) { let i = 0; - if (mask & LUA_MASKCALL) smask[i++] = 99 /* 'c'.charCodeAt(0) */; - if (mask & LUA_MASKRET) smask[i++] = 114 /* 'r'.charCodeAt(0) */; - if (mask & LUA_MASKLINE) smask[i++] = 108 /* 'l'.charCodeAt(0) */; + if (mask & lua.LUA_MASKCALL) smask[i++] = 99 /* 'c'.charCodeAt(0) */; + if (mask & lua.LUA_MASKRET) smask[i++] = 114 /* 'r'.charCodeAt(0) */; + if (mask & lua.LUA_MASKLINE) smask[i++] = 108 /* 'l'.charCodeAt(0) */; return smask.subarray(0, i); }; @@ -315,28 +320,28 @@ const db_sethook = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; - if (lua_isnoneornil(L, arg+1)) { /* no hook? */ - lua_settop(L, arg+1); + if (lua.lua_isnoneornil(L, arg+1)) { /* no hook? */ + lua.lua_settop(L, arg+1); func = null; mask = 0; count = 0; /* turn off hooks */ } else { - const smask = luaL_checkstring(L, arg + 2); - luaL_checktype(L, arg+1, LUA_TFUNCTION); - count = luaL_optinteger(L, arg + 3, 0); + const smask = lauxlib.luaL_checkstring(L, arg + 2); + lauxlib.luaL_checktype(L, arg+1, lua.LUA_TFUNCTION); + count = lauxlib.luaL_optinteger(L, arg + 3, 0); func = hookf; mask = makemask(smask, count); } /* as weak tables are not supported; use a JS weak-map */ let hooktable; - if (lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY) === LUA_TNIL) { + if (lua.lua_rawgetp(L, lua.LUA_REGISTRYINDEX, HOOKKEY) === lua.LUA_TNIL) { hooktable = new WeakMap(); - lua_pushlightuserdata(L, hooktable); - lua_rawsetp(L, LUA_REGISTRYINDEX, HOOKKEY); /* set it in position */ + lua.lua_pushlightuserdata(L, hooktable); + lua.lua_rawsetp(L, lua.LUA_REGISTRYINDEX, HOOKKEY); /* set it in position */ } else { - hooktable = lua_touserdata(L, -1); + hooktable = lua.lua_touserdata(L, -1); } - let proxy = lua_toproxy(L, arg + 1); /* value (hook function) */ + let proxy = lua.lua_toproxy(L, arg + 1); /* value (hook function) */ hooktable.set(L1, proxy); - lua_sethook(L1, func, mask, count); + lua.lua_sethook(L1, func, mask, count); return 0; }; @@ -344,20 +349,20 @@ const db_gethook = function(L) { let thread = getthread(L); let L1 = thread.thread; let buff = new Uint8Array(5); - let mask = lua_gethookmask(L1); - let hook = lua_gethook(L1); + let mask = lua.lua_gethookmask(L1); + let hook = lua.lua_gethook(L1); if (hook === null) /* no hook? */ - lua_pushnil(L); + lua.lua_pushnil(L); else if (hook !== hookf) /* external hook? */ - lua_pushliteral(L, 'external hook'); + lua.lua_pushliteral(L, 'external hook'); else { /* hook table must exist */ - lua_rawgetp(L, LUA_REGISTRYINDEX, HOOKKEY); - let hooktable = lua_touserdata(L, -1); + lua.lua_rawgetp(L, lua.LUA_REGISTRYINDEX, HOOKKEY); + let hooktable = lua.lua_touserdata(L, -1); let proxy = hooktable.get(L1); proxy(L); } - lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */ - lua_pushinteger(L, lua_gethookcount(L1)); /* 3rd result = count */ + lua.lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */ + lua.lua_pushinteger(L, lua.lua_gethookcount(L1)); /* 3rd result = count */ return 3; }; @@ -365,12 +370,12 @@ const db_traceback = function(L) { let thread = getthread(L); let L1 = thread.thread; let arg = thread.arg; - let msg = lua_tostring(L, arg + 1); - if (msg === null && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ - lua_pushvalue(L, arg + 1); /* return it untouched */ + let msg = lua.lua_tostring(L, arg + 1); + if (msg === null && !lua.lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ + lua.lua_pushvalue(L, arg + 1); /* return it untouched */ else { - let level = luaL_optinteger(L, arg + 2, L === L1 ? 1 : 0); - luaL_traceback(L, L1, msg, level); + let level = lauxlib.luaL_optinteger(L, arg + 2, L === L1 ? 1 : 0); + lauxlib.luaL_traceback(L, L1, msg, level); } return 1; }; @@ -421,20 +426,17 @@ if (getinput) { if (input.length === 0) continue; - let buffer = to_luastring(input); - if (luaL_loadbuffer(L, buffer, buffer.length, to_luastring('=(debug command)', true)) - || lua_pcall(L, 0, 0, 0)) { - lua_writestringerror(lua_tojsstring(L, -1), '\n'); + let buffer = fengaricore.to_luastring(input); + if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, fengaricore.to_luastring('=(debug command)', true)) + || lua.lua_pcall(L, 0, 0, 0)) { + lauxlib.lua_writestringerror(lua.lua_tojsstring(L, -1), '\n'); } - lua_settop(L, 0); /* remove eventual returns */ + lua.lua_settop(L, 0); /* remove eventual returns */ } }; } -const luaopen_debug = function(L) { - luaL_newlib(L, dblib); +export const luaopen_debug = function(L) { + lauxlib.luaL_newlib(L, dblib); return 1; }; - -const _luaopen_debug = luaopen_debug; -export { _luaopen_debug as luaopen_debug }; diff --git a/src/ldebug.js b/src/ldebug.js index 9e810dad..ba524d25 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -1,34 +1,34 @@ -import { LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_MASKCOUNT, LUA_MASKLINE, constant_types, thread_status, from_userstring, luastring_eq, luastring_indexOf, to_luastring } from './defs.js'; -import { api_check, lua_assert } from './llimits.js'; -import { LUA_IDSIZE } from './luaconf.js'; -import { api_incr_top } from './lapi.js'; -import { luaD_callnoyield, luaD_throw, luaD_hook } from './ldo.js'; -import { luaF_getlocalname } from './lfunc.js'; -import { LUA_ENV } from './llex.js'; -import { pushobj2s, setobjs2s, CClosure, luaO_chunkid, TValue, luaO_pushfstring, luaO_pushvfstring } from './lobject.js'; -import { ISK, INDEXK, OpCodesI, testAMode } from './lopcodes.js'; -import { CIST_LUA, CIST_FIN, CIST_TAIL, CIST_HOOKED, CIST_HOOKYIELD } from './lstate.js'; -import { luaH_new, luaH_setint } from './ltable.js'; -import { TMS, luaT_objtypename } from './ltm.js'; -import { cvt2str, tonumber, tointeger } from './lvm.js'; - -const { +import * as defs from './defs.js'; +import * as llimits from './llimits.js'; +import * as luaconf from './luaconf.js'; +import * as lapi from './lapi.js'; +import * as ldo from './ldo.js'; +import * as lfunc from './lfunc.js'; +import * as llex from './llex.js'; +import * as lobject from './lobject.js'; +import * as lopcodes from './lopcodes.js'; +import * as lstate from './lstate.js'; +import * as ltable from './ltable.js'; +import * as ltm from './ltm.js'; +import * as lvm from './lvm.js'; + +export const { LUA_TBOOLEAN, LUA_TNIL, LUA_TTABLE -} = constant_types; +} = defs.constant_types; -const { +export const { LUA_ERRRUN, LUA_YIELD -} = thread_status; +} = defs.thread_status; -const currentpc = function (ci) { - lua_assert(ci.callstatus & CIST_LUA); +export const currentpc = function (ci) { + llimits.lua_assert(ci.callstatus & lstate.CIST_LUA); return ci.l_savedpc - 1; }; -const currentline = function (ci) { +export const currentline = function (ci) { return ci.func.value.p.lineinfo.length !== 0 ? ci.func.value.p.lineinfo[currentpc(ci)] : -1; }; @@ -38,7 +38,7 @@ const currentline = function (ci) { ** purposes. (It exchanges 'func' and 'extra'; so, when called again, ** after debugging, it also "re-restores" ** 'func' to its altered value. */ -const swapextra = function (L) { +export const swapextra = function (L) { if (L.status === LUA_YIELD) { let ci = L.ci; /* get function that yielded */ let temp = ci.funcOff; /* exchange its 'func' and 'extra' values */ @@ -48,12 +48,12 @@ const swapextra = function (L) { } }; -const lua_sethook = function (L, func, mask, count) { +export const lua_sethook = function (L, func, mask, count) { if (func === null || mask === 0) { /* turn off hooks? */ mask = 0; func = null; } - if (L.ci.callstatus & CIST_LUA) + if (L.ci.callstatus & lstate.CIST_LUA) L.oldpc = L.ci.l_savedpc; L.hook = func; L.basehookcount = count; @@ -61,21 +61,21 @@ const lua_sethook = function (L, func, mask, count) { L.hookmask = mask; }; -const lua_gethook = function (L) { +export const lua_gethook = function (L) { return L.hook; }; -const lua_gethookmask = function (L) { +export const lua_gethookmask = function (L) { return L.hookmask; }; -const lua_gethookcount = function (L) { +export const lua_gethookcount = function (L) { return L.basehookcount; }; -const lua_getstack = function (L, level, ar) { +export const lua_getstack = function (L, level, ar) { let ci; let status; if (level < 0) return 0; /* invalid (negative) level */ @@ -89,34 +89,34 @@ const lua_getstack = function (L, level, ar) { return status; }; -const upvalname = function (p, uv) { - lua_assert(uv < p.upvalues.length); +export const upvalname = function (p, uv) { + llimits.lua_assert(uv < p.upvalues.length); let s = p.upvalues[uv].name; - if (s === null) return to_luastring('?', true); + if (s === null) return defs.to_luastring('?', true); return s.getstr(); }; -const findvararg = function (ci, n) { +export const findvararg = function (ci, n) { let nparams = ci.func.value.p.numparams; if (n >= ci.l_base - ci.funcOff - nparams) return null; /* no such vararg */ else { return { pos: ci.funcOff + nparams + n, - name: to_luastring('(*vararg)', true) /* generic name for any vararg */ + name: defs.to_luastring('(*vararg)', true) /* generic name for any vararg */ }; } }; -const findlocal = function (L, ci, n) { +export const findlocal = function (L, ci, n) { let base, name = null; - if (ci.callstatus & CIST_LUA) { + if (ci.callstatus & lstate.CIST_LUA) { if (n < 0) /* access to vararg values? */ return findvararg(ci, -n); else { base = ci.l_base; - name = luaF_getlocalname(ci.func.value.p, n, currentpc(ci)); + name = lfunc.luaF_getlocalname(ci.func.value.p, n, currentpc(ci)); } } else base = ci.funcOff + 1; @@ -124,7 +124,7 @@ const findlocal = function (L, ci, n) { if (name === null) { /* no 'standard' name? */ let limit = ci === L.ci ? L.top : ci.next.funcOff; if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - name = to_luastring('(*temporary)', true); /* generic name for any valid slot */ + name = defs.to_luastring('(*temporary)', true); /* generic name for any valid slot */ else return null; /* no name */ } @@ -134,20 +134,20 @@ const findlocal = function (L, ci, n) { }; }; -const lua_getlocal = function (L, ar, n) { +export const lua_getlocal = function (L, ar, n) { let name; swapextra(L); if (ar === null) { /* information about non-active function? */ if (!L.stack[L.top - 1].ttisLclosure()) /* not a Lua function? */ name = null; else /* consider live variables at function start (parameters) */ - name = luaF_getlocalname(L.stack[L.top - 1].value.p, n, 0); + name = lfunc.luaF_getlocalname(L.stack[L.top - 1].value.p, n, 0); } else { /* active function; get information through 'ar' */ let local = findlocal(L, ar.i_ci, n); if (local) { name = local.name; - pushobj2s(L, L.stack[local.pos]); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + lobject.pushobj2s(L, L.stack[local.pos]); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { name = null; } @@ -156,13 +156,13 @@ const lua_getlocal = function (L, ar, n) { return name; }; -const lua_setlocal = function (L, ar, n) { +export const lua_setlocal = function (L, ar, n) { let name; swapextra(L); let local = findlocal(L, ar.i_ci, n); if (local) { name = local.name; - setobjs2s(L, local.pos, L.top - 1); + lobject.setobjs2s(L, local.pos, L.top - 1); delete L.stack[--L.top]; /* pop value */ } else { name = null; @@ -171,57 +171,57 @@ const lua_setlocal = function (L, ar, n) { return name; }; -const funcinfo = function (ar, cl) { - if (cl === null || cl instanceof CClosure) { - ar.source = to_luastring('=[JS]', true); +export const funcinfo = function (ar, cl) { + if (cl === null || cl instanceof lobject.CClosure) { + ar.source = defs.to_luastring('=[JS]', true); ar.linedefined = -1; ar.lastlinedefined = -1; - ar.what = to_luastring('J', true); + ar.what = defs.to_luastring('J', true); } else { let p = cl.p; - ar.source = p.source ? p.source.getstr() : to_luastring('=?', true); + ar.source = p.source ? p.source.getstr() : defs.to_luastring('=?', true); ar.linedefined = p.linedefined; ar.lastlinedefined = p.lastlinedefined; - ar.what = ar.linedefined === 0 ? to_luastring('main', true) : to_luastring('Lua', true); + ar.what = ar.linedefined === 0 ? defs.to_luastring('main', true) : defs.to_luastring('Lua', true); } - ar.short_src = luaO_chunkid(ar.source, LUA_IDSIZE); + ar.short_src = lobject.luaO_chunkid(ar.source, luaconf.LUA_IDSIZE); }; -const collectvalidlines = function (L, f) { - if (f === null || f instanceof CClosure) { - L.stack[L.top] = new TValue(LUA_TNIL, null); - api_incr_top(L); +export const collectvalidlines = function (L, f) { + if (f === null || f instanceof lobject.CClosure) { + L.stack[L.top] = new lobject.TValue(LUA_TNIL, null); + lapi.api_incr_top(L); } else { let lineinfo = f.p.lineinfo; - let t = luaH_new(L); - L.stack[L.top] = new TValue(LUA_TTABLE, t); - api_incr_top(L); - let v = new TValue(LUA_TBOOLEAN, true); + let t = ltable.luaH_new(L); + L.stack[L.top] = new lobject.TValue(LUA_TTABLE, t); + lapi.api_incr_top(L); + let v = new lobject.TValue(LUA_TBOOLEAN, true); for (let i = 0; i < lineinfo.length; i++) - luaH_setint(t, lineinfo[i], v); + ltable.luaH_setint(t, lineinfo[i], v); } }; -const getfuncname = function (L, ci) { +export const getfuncname = function (L, ci) { let r = { name: null, funcname: null }; if (ci === null) return null; - else if (ci.callstatus & CIST_FIN) { /* is this a finalizer? */ - r.name = to_luastring('__gc', true); - r.funcname = to_luastring('metamethod', true); /* report it as such */ + else if (ci.callstatus & lstate.CIST_FIN) { /* is this a finalizer? */ + r.name = defs.to_luastring('__gc', true); + r.funcname = defs.to_luastring('metamethod', true); /* report it as such */ return r; } /* calling function is a known Lua function? */ - else if (!(ci.callstatus & CIST_TAIL) && ci.previous.callstatus & CIST_LUA) + else if (!(ci.callstatus & lstate.CIST_TAIL) && ci.previous.callstatus & lstate.CIST_LUA) return funcnamefromcode(L, ci.previous); else return null; /* no way to find a name */ }; -const auxgetinfo = function (L, what, ar, f, ci) { +export const auxgetinfo = function (L, what, ar, f, ci) { let status = 1; for (; what.length > 0; what = what.subarray(1)) { switch (what[0]) { @@ -230,12 +230,12 @@ const auxgetinfo = function (L, what, ar, f, ci) { break; } case 108 /* ('l').charCodeAt(0) */: { - ar.currentline = ci && ci.callstatus & CIST_LUA ? currentline(ci) : -1; + ar.currentline = ci && ci.callstatus & lstate.CIST_LUA ? currentline(ci) : -1; break; } case 117 /* ('u').charCodeAt(0) */: { ar.nups = f === null ? 0 : f.nupvalues; - if (f === null || f instanceof CClosure) { + if (f === null || f instanceof lobject.CClosure) { ar.isvararg = true; ar.nparams = 0; } else { @@ -245,13 +245,13 @@ const auxgetinfo = function (L, what, ar, f, ci) { break; } case 116 /* ('t').charCodeAt(0) */: { - ar.istailcall = ci ? ci.callstatus & CIST_TAIL : 0; + ar.istailcall = ci ? ci.callstatus & lstate.CIST_TAIL : 0; break; } case 110 /* ('n').charCodeAt(0) */: { let r = getfuncname(L, ci); if (r === null) { - ar.namewhat = to_luastring('', true); + ar.namewhat = defs.to_luastring('', true); ar.name = null; } else { ar.namewhat = r.funcname; @@ -269,44 +269,44 @@ const auxgetinfo = function (L, what, ar, f, ci) { return status; }; -const lua_getinfo = function (L, what, ar) { - what = from_userstring(what); +export const lua_getinfo = function (L, what, ar) { + what = defs.from_userstring(what); let status, cl, ci, func; swapextra(L); if (what[0] === 62 /* ('>').charCodeAt(0) */) { ci = null; func = L.stack[L.top - 1]; - api_check(L, func.ttisfunction(), 'function expected'); + llimits.api_check(L, func.ttisfunction(), 'function expected'); what = what.subarray(1); /* skip the '>' */ L.top--; /* pop function */ } else { ci = ar.i_ci; func = ci.func; - lua_assert(ci.func.ttisfunction()); + llimits.lua_assert(ci.func.ttisfunction()); } cl = func.ttisclosure() ? func.value : null; status = auxgetinfo(L, what, ar, cl, ci); - if (luastring_indexOf(what, 102 /* ('f').charCodeAt(0) */) >= 0) { - pushobj2s(L, func); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + if (defs.luastring_indexOf(what, 102 /* ('f').charCodeAt(0) */) >= 0) { + lobject.pushobj2s(L, func); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); } swapextra(L); - if (luastring_indexOf(what, 76 /* ('L').charCodeAt(0) */) >= 0) + if (defs.luastring_indexOf(what, 76 /* ('L').charCodeAt(0) */) >= 0) collectvalidlines(L, cl); return status; }; -const kname = function (p, pc, c) { +export const kname = function (p, pc, c) { let r = { name: null, funcname: null }; - if (ISK(c)) { /* is 'c' a constant? */ - let kvalue = p.k[INDEXK(c)]; + if (lopcodes.ISK(c)) { /* is 'c' a constant? */ + let kvalue = p.k[lopcodes.INDEXK(c)]; if (kvalue.ttisstring()) { /* literal constant? */ r.name = kvalue.svalue(); /* it is its own name */ return r; @@ -319,11 +319,11 @@ const kname = function (p, pc, c) { } /* else no reasonable name found */ } - r.name = to_luastring('?', true); + r.name = defs.to_luastring('?', true); return r; /* no reasonable name found */ }; -const filterpc = function (pc, jmptarget) { +export const filterpc = function (pc, jmptarget) { if (pc < jmptarget) /* is code conditional (inside a jump)? */ return -1; /* cannot know who sets that register */ else return pc; /* current position sets that register */ @@ -332,10 +332,10 @@ const filterpc = function (pc, jmptarget) { /* ** try to find last instruction before 'lastpc' that modified register 'reg' */ -const findsetreg = function (p, lastpc, reg) { +export const findsetreg = function (p, lastpc, reg) { let setreg = -1; /* keep last instruction that changed 'reg' */ let jmptarget = 0; /* any code before this address is conditional */ - let OCi = OpCodesI; + let OCi = lopcodes.OpCodesI; for (let pc = 0; pc < lastpc; pc++) { let i = p.code[pc]; let a = i.A; @@ -368,7 +368,7 @@ const findsetreg = function (p, lastpc, reg) { break; } default: - if (testAMode(i.opcode) && reg === a) + if (lopcodes.testAMode(i.opcode) && reg === a) setreg = filterpc(pc, jmptarget); break; } @@ -378,20 +378,20 @@ const findsetreg = function (p, lastpc, reg) { }; -const getobjname = function (p, lastpc, reg) { +export const getobjname = function (p, lastpc, reg) { let r = { - name: luaF_getlocalname(p, reg + 1, lastpc), + name: lfunc.luaF_getlocalname(p, reg + 1, lastpc), funcname: null }; if (r.name) { /* is a local? */ - r.funcname = to_luastring('local', true); + r.funcname = defs.to_luastring('local', true); return r; } /* else try symbolic execution */ let pc = findsetreg(p, lastpc, reg); - let OCi = OpCodesI; + let OCi = lopcodes.OpCodesI; if (pc !== -1) { /* could find instruction? */ let i = p.code[pc]; switch (i.opcode) { @@ -405,14 +405,14 @@ const getobjname = function (p, lastpc, reg) { case OCi.OP_GETTABLE: { let k = i.C; /* key index */ let t = i.B; /* table index */ - let vn = i.opcode === OCi.OP_GETTABLE ? luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); + let vn = i.opcode === OCi.OP_GETTABLE ? lfunc.luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); r.name = kname(p, pc, k).name; - r.funcname = (vn && luastring_eq(vn, LUA_ENV)) ? to_luastring('global', true) : to_luastring('field', true); + r.funcname = (vn && defs.luastring_eq(vn, llex.LUA_ENV)) ? defs.to_luastring('global', true) : defs.to_luastring('field', true); return r; } case OCi.OP_GETUPVAL: { r.name = upvalname(p, i.B); - r.funcname = to_luastring('upvalue', true); + r.funcname = defs.to_luastring('upvalue', true); return r; } case OCi.OP_LOADK: @@ -420,7 +420,7 @@ const getobjname = function (p, lastpc, reg) { let b = i.opcode === OCi.OP_LOADK ? i.Bx : p.code[pc + 1].Ax; if (p.k[b].ttisstring()) { r.name = p.k[b].svalue(); - r.funcname = to_luastring('constant', true); + r.funcname = defs.to_luastring('constant', true); return r; } break; @@ -428,7 +428,7 @@ const getobjname = function (p, lastpc, reg) { case OCi.OP_SELF: { let k = i.C; r.name = kname(p, pc, k).name; - r.funcname = to_luastring('method', true); + r.funcname = defs.to_luastring('method', true); return r; } default: break; @@ -444,21 +444,21 @@ const getobjname = function (p, lastpc, reg) { ** Returns what the name is (e.g., "for iterator", "method", ** "metamethod") and sets '*name' to point to the name. */ -const funcnamefromcode = function (L, ci) { +export const funcnamefromcode = function (L, ci) { let r = { name: null, funcname: null }; - let tm = 0; /* (initial value avoids warnings) */ + let tm; /* (initial value avoids warnings) */ let p = ci.func.value.p; /* calling function */ let pc = currentpc(ci); /* calling instruction index */ let i = p.code[pc]; /* calling instruction */ - let OCi = OpCodesI; + let OCi = lopcodes.OpCodesI; - if (ci.callstatus & CIST_HOOKED) { - r.name = to_luastring('?', true); - r.funcname = to_luastring('hook', true); + if (ci.callstatus & lstate.CIST_HOOKED) { + r.name = defs.to_luastring('?', true); + r.funcname = defs.to_luastring('hook', true); return r; } @@ -467,48 +467,48 @@ const funcnamefromcode = function (L, ci) { case OCi.OP_TAILCALL: return getobjname(p, pc, i.A); /* get function name */ case OCi.OP_TFORCALL: - r.name = to_luastring('for iterator', true); - r.funcname = to_luastring('for iterator', true); + r.name = defs.to_luastring('for iterator', true); + r.funcname = defs.to_luastring('for iterator', true); return r; /* other instructions can do calls through metamethods */ case OCi.OP_SELF: case OCi.OP_GETTABUP: case OCi.OP_GETTABLE: - tm = TMS.TM_INDEX; + tm = ltm.TMS.TM_INDEX; break; case OCi.OP_SETTABUP: case OCi.OP_SETTABLE: - tm = TMS.TM_NEWINDEX; + tm = ltm.TMS.TM_NEWINDEX; break; - case OCi.OP_ADD: tm = TMS.TM_ADD; break; - case OCi.OP_SUB: tm = TMS.TM_SUB; break; - case OCi.OP_MUL: tm = TMS.TM_MUL; break; - case OCi.OP_MOD: tm = TMS.TM_MOD; break; - case OCi.OP_POW: tm = TMS.TM_POW; break; - case OCi.OP_DIV: tm = TMS.TM_DIV; break; - case OCi.OP_IDIV: tm = TMS.TM_IDIV; break; - case OCi.OP_BAND: tm = TMS.TM_BAND; break; - case OCi.OP_BOR: tm = TMS.TM_BOR; break; - case OCi.OP_BXOR: tm = TMS.TM_BXOR; break; - case OCi.OP_SHL: tm = TMS.TM_SHL; break; - case OCi.OP_SHR: tm = TMS.TM_SHR; break; - case OCi.OP_UNM: tm = TMS.TM_UNM; break; - case OCi.OP_BNOT: tm = TMS.TM_BNOT; break; - case OCi.OP_LEN: tm = TMS.TM_LEN; break; - case OCi.OP_CONCAT: tm = TMS.TM_CONCAT; break; - case OCi.OP_EQ: tm = TMS.TM_EQ; break; - case OCi.OP_LT: tm = TMS.TM_LT; break; - case OCi.OP_LE: tm = TMS.TM_LE; break; + case OCi.OP_ADD: tm = ltm.TMS.TM_ADD; break; + case OCi.OP_SUB: tm = ltm.TMS.TM_SUB; break; + case OCi.OP_MUL: tm = ltm.TMS.TM_MUL; break; + case OCi.OP_MOD: tm = ltm.TMS.TM_MOD; break; + case OCi.OP_POW: tm = ltm.TMS.TM_POW; break; + case OCi.OP_DIV: tm = ltm.TMS.TM_DIV; break; + case OCi.OP_IDIV: tm = ltm.TMS.TM_IDIV; break; + case OCi.OP_BAND: tm = ltm.TMS.TM_BAND; break; + case OCi.OP_BOR: tm = ltm.TMS.TM_BOR; break; + case OCi.OP_BXOR: tm = ltm.TMS.TM_BXOR; break; + case OCi.OP_SHL: tm = ltm.TMS.TM_SHL; break; + case OCi.OP_SHR: tm = ltm.TMS.TM_SHR; break; + case OCi.OP_UNM: tm = ltm.TMS.TM_UNM; break; + case OCi.OP_BNOT: tm = ltm.TMS.TM_BNOT; break; + case OCi.OP_LEN: tm = ltm.TMS.TM_LEN; break; + case OCi.OP_CONCAT: tm = ltm.TMS.TM_CONCAT; break; + case OCi.OP_EQ: tm = ltm.TMS.TM_EQ; break; + case OCi.OP_LT: tm = ltm.TMS.TM_LT; break; + case OCi.OP_LE: tm = ltm.TMS.TM_LE; break; default: return null; /* cannot find a reasonable name */ } r.name = L.l_G.tmname[tm].getstr(); - r.funcname = to_luastring('metamethod', true); + r.funcname = defs.to_luastring('metamethod', true); return r; }; -const isinstack = function (L, ci, o) { +export const isinstack = function (L, ci, o) { for (let i = ci.l_base; i < ci.top; i++) { if (L.stack[i] === o) return i; @@ -522,13 +522,13 @@ const isinstack = function (L, ci, o) { ** with instructions OP_GETTABUP/OP_SETTABUP, which operate directly on ** upvalues.) */ -const getupvalname = function (L, ci, o) { +export const getupvalname = function (L, ci, o) { let c = ci.func.value; for (let i = 0; i < c.nupvalues; i++) { if (c.upvals[i] === o) { return { name: upvalname(c.p, i), - funcname: to_luastring('upvalue', true) + funcname: defs.to_luastring('upvalue', true) }; } } @@ -536,153 +536,118 @@ const getupvalname = function (L, ci, o) { return null; }; -const varinfo = function (L, o) { +export const varinfo = function (L, o) { let ci = L.ci; let kind = null; - if (ci.callstatus & CIST_LUA) { + if (ci.callstatus & lstate.CIST_LUA) { kind = getupvalname(L, ci, o); /* check whether 'o' is an upvalue */ let stkid = isinstack(L, ci, o); if (!kind && stkid) /* no? try a register */ kind = getobjname(ci.func.value.p, currentpc(ci), stkid - ci.l_base); } - return kind ? luaO_pushfstring(L, to_luastring(' (%s \'%s\')', true), kind.funcname, kind.name) : to_luastring('', true); + return kind ? lobject.luaO_pushfstring(L, defs.to_luastring(' (%s \'%s\')', true), kind.funcname, kind.name) : defs.to_luastring('', true); }; -const luaG_typeerror = function (L, o, op) { - let t = luaT_objtypename(L, o); - luaG_runerror(L, to_luastring('attempt to %s a %s value%s', true), op, t, varinfo(L, o)); +export const luaG_typeerror = function (L, o, op) { + let t = ltm.luaT_objtypename(L, o); + luaG_runerror(L, defs.to_luastring('attempt to %s a %s value%s', true), op, t, varinfo(L, o)); }; -const luaG_concaterror = function (L, p1, p2) { - if (p1.ttisstring() || cvt2str(p1)) p1 = p2; - luaG_typeerror(L, p1, to_luastring('concatenate', true)); +export const luaG_concaterror = function (L, p1, p2) { + if (p1.ttisstring() || lvm.cvt2str(p1)) p1 = p2; + luaG_typeerror(L, p1, defs.to_luastring('concatenate', true)); }; /* ** Error when both values are convertible to numbers, but not to integers */ -const luaG_opinterror = function (L, p1, p2, msg) { - if (tonumber(p1) === false) +export const luaG_opinterror = function (L, p1, p2, msg) { + if (lvm.tonumber(p1) === false) p2 = p1; luaG_typeerror(L, p2, msg); }; -const luaG_ordererror = function (L, p1, p2) { - let t1 = luaT_objtypename(L, p1); - let t2 = luaT_objtypename(L, p2); - if (luastring_eq(t1, t2)) - luaG_runerror(L, to_luastring('attempt to compare two %s values', true), t1); +export const luaG_ordererror = function (L, p1, p2) { + let t1 = ltm.luaT_objtypename(L, p1); + let t2 = ltm.luaT_objtypename(L, p2); + if (defs.luastring_eq(t1, t2)) + luaG_runerror(L, defs.to_luastring('attempt to compare two %s values', true), t1); else - luaG_runerror(L, to_luastring('attempt to compare %s with %s', true), t1, t2); + luaG_runerror(L, defs.to_luastring('attempt to compare %s with %s', true), t1, t2); }; /* add src:line information to 'msg' */ -const luaG_addinfo = function (L, msg, src, line) { +export const luaG_addinfo = function (L, msg, src, line) { let buff; if (src) - buff = luaO_chunkid(src.getstr(), LUA_IDSIZE); + buff = lobject.luaO_chunkid(src.getstr(), luaconf.LUA_IDSIZE); else - buff = to_luastring('?', true); + buff = defs.to_luastring('?', true); - return luaO_pushfstring(L, to_luastring('%s:%d: %s', true), buff, line, msg); + return lobject.luaO_pushfstring(L, defs.to_luastring('%s:%d: %s', true), buff, line, msg); }; -const luaG_runerror = function (L, fmt, ...argp) { +export const luaG_runerror = function (L, fmt, ...argp) { let ci = L.ci; - let msg = luaO_pushvfstring(L, fmt, argp); - if (ci.callstatus & CIST_LUA) /* if Lua function, add source:line information */ + let msg = lobject.luaO_pushvfstring(L, fmt, argp); + if (ci.callstatus & lstate.CIST_LUA) /* if Lua function, add source:line information */ luaG_addinfo(L, msg, ci.func.value.p.source, currentline(ci)); luaG_errormsg(L); }; -const luaG_errormsg = function (L) { +export const luaG_errormsg = function (L) { if (L.errfunc !== 0) { /* is there an error handling function? */ let errfunc = L.errfunc; - pushobj2s(L, L.stack[L.top - 1]); /* move argument */ - setobjs2s(L, L.top - 2, errfunc); /* push function */ - luaD_callnoyield(L, L.top - 2, 1); + lobject.pushobj2s(L, L.stack[L.top - 1]); /* move argument */ + lobject.setobjs2s(L, L.top - 2, errfunc); /* push function */ + ldo.luaD_callnoyield(L, L.top - 2, 1); } - luaD_throw(L, LUA_ERRRUN); + ldo.luaD_throw(L, LUA_ERRRUN); }; /* ** Error when both values are convertible to numbers, but not to integers */ -const luaG_tointerror = function (L, p1, p2) { - let temp = tointeger(p1); +export const luaG_tointerror = function (L, p1, p2) { + let temp = lvm.tointeger(p1); if (temp === false) p2 = p1; - luaG_runerror(L, to_luastring('number%s has no integer representation', true), varinfo(L, p2)); + luaG_runerror(L, defs.to_luastring('number%s has no integer representation', true), varinfo(L, p2)); }; -const luaG_traceexec = function (L) { +export const luaG_traceexec = function (L) { let ci = L.ci; let mask = L.hookmask; - let counthook = (--L.hookcount === 0 && (mask & LUA_MASKCOUNT)); + let counthook = (--L.hookcount === 0 && (mask & defs.LUA_MASKCOUNT)); if (counthook) L.hookcount = L.basehookcount; /* reset count */ - else if (!(mask & LUA_MASKLINE)) + else if (!(mask & defs.LUA_MASKLINE)) return; /* no line hook and count != 0; nothing to be done */ - if (ci.callstatus & CIST_HOOKYIELD) { /* called hook last time? */ - ci.callstatus &= ~CIST_HOOKYIELD; /* erase mark */ + if (ci.callstatus & lstate.CIST_HOOKYIELD) { /* called hook last time? */ + ci.callstatus &= ~lstate.CIST_HOOKYIELD; /* erase mark */ return; /* do not call hook again (VM yielded, so it did not move) */ } if (counthook) - luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ - if (mask & LUA_MASKLINE) { + ldo.luaD_hook(L, defs.LUA_HOOKCOUNT, -1); /* call count hook */ + if (mask & defs.LUA_MASKLINE) { let p = ci.func.value.p; let npc = ci.l_savedpc - 1; // pcRel(ci.u.l.savedpc, p); let newline = p.lineinfo.length !== 0 ? p.lineinfo[npc] : -1; if (npc === 0 || /* call linehook when enter a new function, */ ci.l_savedpc <= L.oldpc || /* when jump back (loop), or when */ newline !== (p.lineinfo.length !== 0 ? p.lineinfo[L.oldpc - 1] : -1)) /* enter a new line */ - luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ + ldo.luaD_hook(L, defs.LUA_HOOKLINE, newline); /* call line hook */ } L.oldpc = ci.l_savedpc; if (L.status === LUA_YIELD) { /* did hook yield? */ if (counthook) L.hookcount = 1; /* undo decrement to zero */ ci.l_savedpc--; /* undo increment (resume will increment it again) */ - ci.callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ + ci.callstatus |= lstate.CIST_HOOKYIELD; /* mark that it yielded */ ci.funcOff = L.top - 1; /* protect stack below results */ ci.func = L.stack[ci.funcOff]; - luaD_throw(L, LUA_YIELD); + ldo.luaD_throw(L, LUA_YIELD); } }; - -const _luaG_addinfo = luaG_addinfo; -export { _luaG_addinfo as luaG_addinfo }; -const _luaG_concaterror = luaG_concaterror; -export { _luaG_concaterror as luaG_concaterror }; -const _luaG_errormsg = luaG_errormsg; -export { _luaG_errormsg as luaG_errormsg }; -const _luaG_opinterror = luaG_opinterror; -export { _luaG_opinterror as luaG_opinterror }; -const _luaG_ordererror = luaG_ordererror; -export { _luaG_ordererror as luaG_ordererror }; -const _luaG_runerror = luaG_runerror; -export { _luaG_runerror as luaG_runerror }; -const _luaG_tointerror = luaG_tointerror; -export { _luaG_tointerror as luaG_tointerror }; -const _luaG_traceexec = luaG_traceexec; -export { _luaG_traceexec as luaG_traceexec }; -const _luaG_typeerror = luaG_typeerror; -export { _luaG_typeerror as luaG_typeerror }; -const _lua_gethook = lua_gethook; -export { _lua_gethook as lua_gethook }; -const _lua_gethookcount = lua_gethookcount; -export { _lua_gethookcount as lua_gethookcount }; -const _lua_gethookmask = lua_gethookmask; -export { _lua_gethookmask as lua_gethookmask }; -const _lua_getinfo = lua_getinfo; -export { _lua_getinfo as lua_getinfo }; -const _lua_getlocal = lua_getlocal; -export { _lua_getlocal as lua_getlocal }; -const _lua_getstack = lua_getstack; -export { _lua_getstack as lua_getstack }; -const _lua_sethook = lua_sethook; -export { _lua_sethook as lua_sethook }; -const _lua_setlocal = lua_setlocal; -export { _lua_setlocal as lua_setlocal }; diff --git a/src/ldo.js b/src/ldo.js index db7b73c1..95956c3c 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -1,63 +1,63 @@ -import { LUA_HOOKCALL, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, LUA_SIGNATURE, constant_types, thread_status, lua_Debug, luastring_indexOf, to_luastring } from './defs.js'; -import { api_checknelems, lua_pushcfunction, lua_pushlightuserdata } from './lapi.js'; -import { luaG_runerror, luaG_typeerror } from './ldebug.js'; -import { luaF_close, luaF_initupvals } from './lfunc.js'; -import { api_check, lua_assert, LUAI_MAXCCALLS } from './llimits.js'; -import { TValue, setsvalue2s, setobjs2s, pushobj2s, setobj2s, pushsvalue2s, luaO_pushfstring } from './lobject.js'; -import { OpCodesI } from './lopcodes.js'; -import { Dyndata, luaY_parser } from './lparser.js'; -import { EXTRA_STACK, luaE_freeCI, luaE_extendCI, CIST_LUA, CIST_HOOKED, CIST_TAIL, CIST_YPCALL, CIST_OAH } from './lstate.js'; -import { luaS_newliteral } from './lstring.js'; -import { luaT_gettmbyobj, TMS } from './ltm.js'; -import { LUAI_MAXSTACK } from './common.js'; -import { luaU_undump } from './lundump.js'; -import { luaV_execute, luaV_finishOp } from './lvm.js'; -import { MBuffer } from './lzio.js'; - -const { +import * as defs from './defs.js'; +import * as lapi from './lapi.js'; +import * as ldebug from './ldebug.js'; +import * as lfunc from './lfunc.js'; +import * as llimits from './llimits.js'; +import * as lobject from './lobject.js'; +import * as lopcodes from './lopcodes.js'; +import * as lparser from './lparser.js'; +import * as lstate from './lstate.js'; +import * as lstring from './lstring.js'; +import * as ltm from './ltm.js'; +import * as common from './common.js'; +import * as lundump from './lundump.js'; +import * as lvm from './lvm.js'; +import * as lzio from './lzio.js'; + +export const { LUA_TCCL, LUA_TLCF, LUA_TLCL, LUA_TNIL -} = constant_types; +} = defs.constant_types; -const { +export const { LUA_ERRMEM, LUA_ERRERR, LUA_ERRRUN, LUA_ERRSYNTAX, LUA_OK, LUA_YIELD -} = thread_status; +} = defs.thread_status; -const adjust_top = function (L, newtop) { +export const adjust_top = function (L, newtop) { if (L.top < newtop) { while (L.top < newtop) - L.stack[L.top++] = new TValue(LUA_TNIL, null); + L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); } else { while (L.top > newtop) delete L.stack[--L.top]; } }; -const seterrorobj = function (L, errcode, oldtop) { +export const seterrorobj = function (L, errcode, oldtop) { let current_top = L.top; /* extend stack so that L.stack[oldtop] is sure to exist */ while (L.top < oldtop + 1) - L.stack[L.top++] = new TValue(LUA_TNIL, null); + L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); switch (errcode) { case LUA_ERRMEM: { - setsvalue2s(L, oldtop, luaS_newliteral(L, 'not enough memory')); + lobject.setsvalue2s(L, oldtop, lstring.luaS_newliteral(L, 'not enough memory')); break; } case LUA_ERRERR: { - setsvalue2s(L, oldtop, luaS_newliteral(L, 'error in error handling')); + lobject.setsvalue2s(L, oldtop, lstring.luaS_newliteral(L, 'error in error handling')); break; } default: { - setobjs2s(L, oldtop, current_top - 1); + lobject.setobjs2s(L, oldtop, current_top - 1); } } @@ -65,63 +65,63 @@ const seterrorobj = function (L, errcode, oldtop) { delete L.stack[--L.top]; }; -const ERRORSTACKSIZE = LUAI_MAXSTACK + 200; +export const ERRORSTACKSIZE = common.LUAI_MAXSTACK + 200; -const luaD_reallocstack = function (L, newsize) { - lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); - lua_assert(L.stack_last == L.stack.length - EXTRA_STACK); +export const luaD_reallocstack = function (L, newsize) { + llimits.lua_assert(newsize <= common.LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); + llimits.lua_assert(L.stack_last == L.stack.length - lstate.EXTRA_STACK); L.stack.length = newsize; - L.stack_last = newsize - EXTRA_STACK; + L.stack_last = newsize - lstate.EXTRA_STACK; }; -const luaD_growstack = function (L, n) { +export const luaD_growstack = function (L, n) { let size = L.stack.length; - if (size > LUAI_MAXSTACK) + if (size > common.LUAI_MAXSTACK) luaD_throw(L, LUA_ERRERR); else { - let needed = L.top + n + EXTRA_STACK; + let needed = L.top + n + lstate.EXTRA_STACK; let newsize = 2 * size; - if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; + if (newsize > common.LUAI_MAXSTACK) newsize = common.LUAI_MAXSTACK; if (newsize < needed) newsize = needed; - if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ + if (newsize > common.LUAI_MAXSTACK) { /* stack overflow? */ luaD_reallocstack(L, ERRORSTACKSIZE); - luaG_runerror(L, to_luastring('stack overflow', true)); + ldebug.luaG_runerror(L, defs.to_luastring('stack overflow', true)); } else luaD_reallocstack(L, newsize); } }; -const luaD_checkstack = function (L, n) { +export const luaD_checkstack = function (L, n) { if (L.stack_last - L.top <= n) luaD_growstack(L, n); }; -const stackinuse = function (L) { +export const stackinuse = function (L) { let lim = L.top; for (let ci = L.ci; ci !== null; ci = ci.previous) { if (lim < ci.top) lim = ci.top; } - lua_assert(lim <= L.stack_last); + llimits.lua_assert(lim <= L.stack_last); return lim + 1; /* part of stack in use */ }; -const luaD_shrinkstack = function (L) { +export const luaD_shrinkstack = function (L) { let inuse = stackinuse(L); - let goodsize = inuse + Math.floor(inuse / 8) + 2 * EXTRA_STACK; - if (goodsize > LUAI_MAXSTACK) - goodsize = LUAI_MAXSTACK; /* respect stack limit */ - if (L.stack.length > LUAI_MAXSTACK) /* had been handling stack overflow? */ - luaE_freeCI(L); /* free all CIs (list grew because of an error) */ + let goodsize = inuse + Math.floor(inuse / 8) + 2 * lstate.EXTRA_STACK; + if (goodsize > common.LUAI_MAXSTACK) + goodsize = common.LUAI_MAXSTACK; /* respect stack limit */ + if (L.stack.length > common.LUAI_MAXSTACK) /* had been handling stack overflow? */ + lstate.luaE_freeCI(L); /* free all CIs (list grew because of an error) */ /* if thread is currently not handling a stack overflow and its good size is smaller than current size, shrink its stack */ - if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && goodsize < L.stack.length) + if (inuse <= (common.LUAI_MAXSTACK - lstate.EXTRA_STACK) && goodsize < L.stack.length) luaD_reallocstack(L, goodsize); }; -const luaD_inctop = function (L) { +export const luaD_inctop = function (L) { luaD_checkstack(L, 1); - L.stack[L.top++] = new TValue(LUA_TNIL, null); + L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); }; /* @@ -131,7 +131,7 @@ const luaD_inctop = function (L) { ** the execution ('luaV_execute') to the caller, to allow stackless ** calls.) Returns true iff function has been executed (JS function). */ -const luaD_precall = function (L, off, nresults) { +export const luaD_precall = function (L, off, nresults) { let func = L.stack[off]; switch (func.type) { @@ -139,20 +139,20 @@ const luaD_precall = function (L, off, nresults) { case LUA_TLCF: { let f = func.type === LUA_TCCL ? func.value.f : func.value; - luaD_checkstack(L, LUA_MINSTACK); - let ci = luaE_extendCI(L); + luaD_checkstack(L, defs.LUA_MINSTACK); + let ci = lstate.luaE_extendCI(L); ci.funcOff = off; ci.nresults = nresults; ci.func = func; - ci.top = L.top + LUA_MINSTACK; - lua_assert(ci.top <= L.stack_last); + ci.top = L.top + defs.LUA_MINSTACK; + llimits.lua_assert(ci.top <= L.stack_last); ci.callstatus = 0; - if (L.hookmask & LUA_MASKCALL) - luaD_hook(L, LUA_HOOKCALL, -1); + if (L.hookmask & defs.LUA_MASKCALL) + luaD_hook(L, defs.LUA_HOOKCALL, -1); let n = f(L); /* do the actual call */ if (typeof n !== 'number' || n < 0 || (n | 0) !== n) throw Error('invalid return value from JS function (expected integer)'); - api_checknelems(L, n); + lapi.api_checknelems(L, n); luaD_poscall(L, ci, L.top - n, n); @@ -168,11 +168,11 @@ const luaD_precall = function (L, off, nresults) { base = adjust_varargs(L, p, n); } else { for (; n < p.numparams; n++) - L.stack[L.top++] = new TValue(LUA_TNIL, null); // complete missing arguments + L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); // complete missing arguments base = off + 1; } - let ci = luaE_extendCI(L); + let ci = lstate.luaE_extendCI(L); ci.funcOff = off; ci.nresults = nresults; ci.func = func; @@ -181,8 +181,8 @@ const luaD_precall = function (L, off, nresults) { adjust_top(L, ci.top); ci.l_code = p.code; ci.l_savedpc = 0; - ci.callstatus = CIST_LUA; - if (L.hookmask & LUA_MASKCALL) + ci.callstatus = lstate.CIST_LUA; + if (L.hookmask & defs.LUA_MASKCALL) callhook(L, ci); return false; } @@ -193,12 +193,12 @@ const luaD_precall = function (L, off, nresults) { } }; -const luaD_poscall = function (L, ci, firstResult, nres) { +export const luaD_poscall = function (L, ci, firstResult, nres) { let wanted = ci.nresults; - if (L.hookmask & (LUA_MASKRET | LUA_MASKLINE)) { - if (L.hookmask & LUA_MASKRET) - luaD_hook(L, LUA_HOOKRET, -1); + if (L.hookmask & (defs.LUA_MASKRET | defs.LUA_MASKLINE)) { + if (L.hookmask & defs.LUA_MASKRET) + luaD_hook(L, defs.LUA_HOOKRET, -1); L.oldpc = ci.previous.l_savedpc; /* 'oldpc' for caller function */ } @@ -208,7 +208,7 @@ const luaD_poscall = function (L, ci, firstResult, nres) { return moveresults(L, firstResult, res, nres, wanted); }; -const moveresults = function (L, firstResult, res, nres, wanted) { +export const moveresults = function (L, firstResult, res, nres, wanted) { switch (wanted) { case 0: break; @@ -216,13 +216,13 @@ const moveresults = function (L, firstResult, res, nres, wanted) { if (nres === 0) L.stack[res].setnilvalue(); else { - setobjs2s(L, res, firstResult); /* move it to proper place */ + lobject.setobjs2s(L, res, firstResult); /* move it to proper place */ } break; } - case LUA_MULTRET: { + case defs.LUA_MULTRET: { for (let i = 0; i < nres; i++) - setobjs2s(L, res + i, firstResult + i); + lobject.setobjs2s(L, res + i, firstResult + i); for (let i = L.top; i >= (res + nres); i--) delete L.stack[i]; L.top = res + nres; @@ -232,13 +232,13 @@ const moveresults = function (L, firstResult, res, nres, wanted) { let i; if (wanted <= nres) { for (i = 0; i < wanted; i++) - setobjs2s(L, res + i, firstResult + i); + lobject.setobjs2s(L, res + i, firstResult + i); } else { for (i = 0; i < nres; i++) - setobjs2s(L, res + i, firstResult + i); + lobject.setobjs2s(L, res + i, firstResult + i); for (; i < wanted; i++) { if (res + i >= L.top) - L.stack[res + i] = new TValue(LUA_TNIL, null); + L.stack[res + i] = new lobject.TValue(LUA_TNIL, null); else L.stack[res + i].setnilvalue(); } @@ -258,43 +258,43 @@ const moveresults = function (L, firstResult, res, nres, wanted) { ** called. (Both 'L->hook' and 'L->hookmask', which triggers this ** function, can be changed asynchronously by signals.) */ -const luaD_hook = function (L, event, line) { +export const luaD_hook = function (L, event, line) { let hook = L.hook; if (hook && L.allowhook) { /* make sure there is a hook */ let ci = L.ci; let top = L.top; let ci_top = ci.top; - let ar = new lua_Debug(); + let ar = new defs.lua_Debug(); ar.event = event; ar.currentline = line; ar.i_ci = ci; - luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - ci.top = L.top + LUA_MINSTACK; - lua_assert(ci.top <= L.stack_last); + luaD_checkstack(L, defs.LUA_MINSTACK); /* ensure minimum stack size */ + ci.top = L.top + defs.LUA_MINSTACK; + llimits.lua_assert(ci.top <= L.stack_last); L.allowhook = 0; /* cannot call hooks inside a hook */ - ci.callstatus |= CIST_HOOKED; + ci.callstatus |= lstate.CIST_HOOKED; hook(L, ar); - lua_assert(!L.allowhook); + llimits.lua_assert(!L.allowhook); L.allowhook = 1; ci.top = ci_top; adjust_top(L, top); - ci.callstatus &= ~CIST_HOOKED; + ci.callstatus &= ~lstate.CIST_HOOKED; } }; -const callhook = function (L, ci) { - let hook = LUA_HOOKCALL; +export const callhook = function (L, ci) { + let hook = defs.LUA_HOOKCALL; ci.l_savedpc++; /* hooks assume 'pc' is already incremented */ - if ((ci.previous.callstatus & CIST_LUA) && - ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == OpCodesI.OP_TAILCALL) { - ci.callstatus |= CIST_TAIL; - hook = LUA_HOOKTAILCALL; + if ((ci.previous.callstatus & lstate.CIST_LUA) && + ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == lopcodes.OpCodesI.OP_TAILCALL) { + ci.callstatus |= lstate.CIST_TAIL; + hook = defs.LUA_HOOKTAILCALL; } luaD_hook(L, hook, -1); ci.l_savedpc--; /* correct 'pc' */ }; -const adjust_varargs = function (L, p, actual) { +export const adjust_varargs = function (L, p, actual) { let nfixargs = p.numparams; /* move fixed parameters to final position */ let fixed = L.top - actual; /* first fixed argument */ @@ -302,25 +302,25 @@ const adjust_varargs = function (L, p, actual) { let i; for (i = 0; i < nfixargs && i < actual; i++) { - pushobj2s(L, L.stack[fixed + i]); + lobject.pushobj2s(L, L.stack[fixed + i]); L.stack[fixed + i].setnilvalue(); } for (; i < nfixargs; i++) - L.stack[L.top++] = new TValue(LUA_TNIL, null); + L.stack[L.top++] = new lobject.TValue(LUA_TNIL, null); return base; }; -const tryfuncTM = function (L, off, func) { - let tm = luaT_gettmbyobj(L, func, TMS.TM_CALL); +export const tryfuncTM = function (L, off, func) { + let tm = ltm.luaT_gettmbyobj(L, func, ltm.TMS.TM_CALL); if (!tm.ttisfunction(tm)) - luaG_typeerror(L, func, to_luastring('call', true)); + ldebug.luaG_typeerror(L, func, defs.to_luastring('call', true)); /* Open a hole inside the stack at 'func' */ - pushobj2s(L, L.stack[L.top - 1]); /* push top of stack again */ + lobject.pushobj2s(L, L.stack[L.top - 1]); /* push top of stack again */ for (let p = L.top - 2; p > off; p--) - setobjs2s(L, p, p - 1); /* move other items up one */ - setobj2s(L, off, tm); /* tag method is the new function to be called */ + lobject.setobjs2s(L, p, p - 1); /* move other items up one */ + lobject.setobj2s(L, off, tm); /* tag method is the new function to be called */ }; /* @@ -330,10 +330,10 @@ const tryfuncTM = function (L, off, func) { ** smaller than 9/8 of LUAI_MAXCCALLS, does not report an error (to ** allow overflow handling to work) */ -const stackerror = function (L) { - if (L.nCcalls === LUAI_MAXCCALLS) - luaG_runerror(L, to_luastring('JS stack overflow', true)); - else if (L.nCcalls >= LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)) +export const stackerror = function (L) { + if (L.nCcalls === llimits.LUAI_MAXCCALLS) + ldebug.luaG_runerror(L, defs.to_luastring('JS stack overflow', true)); + else if (L.nCcalls >= llimits.LUAI_MAXCCALLS + (llimits.LUAI_MAXCCALLS >> 3)) luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ }; @@ -343,15 +343,15 @@ const stackerror = function (L) { ** When returns, all the results are on the stack, starting at the original ** function position. */ -const luaD_call = function (L, off, nResults) { - if (++L.nCcalls >= LUAI_MAXCCALLS) +export const luaD_call = function (L, off, nResults) { + if (++L.nCcalls >= llimits.LUAI_MAXCCALLS) stackerror(L); if (!luaD_precall(L, off, nResults)) - luaV_execute(L); + lvm.luaV_execute(L); L.nCcalls--; }; -const luaD_throw = function (L, errcode) { +export const luaD_throw = function (L, errcode) { if (L.errorJmp) { /* thread has an error handler? */ L.errorJmp.status = errcode; /* set status */ throw L.errorJmp; @@ -374,7 +374,7 @@ const luaD_throw = function (L, errcode) { } }; -const luaD_rawrunprotected = function (L, f, ud) { +export const luaD_rawrunprotected = function (L, f, ud) { let oldnCcalls = L.nCcalls; let lj = { status: LUA_OK, @@ -393,16 +393,16 @@ const luaD_rawrunprotected = function (L, f, ud) { try { lj.status = LUA_OK; - lua_pushcfunction(L, atnativeerror); - lua_pushlightuserdata(L, e); + lapi.lua_pushcfunction(L, atnativeerror); + lapi.lua_pushlightuserdata(L, e); luaD_callnoyield(L, L.top - 2, 1); /* Now run the message handler (if it exists) */ /* copy of luaG_errormsg without the throw */ if (L.errfunc !== 0) { /* is there an error handling function? */ let errfunc = L.errfunc; - pushobj2s(L, L.stack[L.top - 1]); /* move argument */ - setobjs2s(L, L.top - 2, errfunc); /* push function */ + lobject.pushobj2s(L, L.stack[L.top - 1]); /* move argument */ + lobject.setobjs2s(L, L.top - 2, errfunc); /* push function */ luaD_callnoyield(L, L.top - 2, 1); } @@ -430,25 +430,25 @@ const luaD_rawrunprotected = function (L, f, ud) { ** Completes the execution of an interrupted C function, calling its ** continuation function. */ -const finishCcall = function (L, status) { +export const finishCcall = function (L, status) { let ci = L.ci; /* must have a continuation and must be able to call it */ - lua_assert(ci.c_k !== null && L.nny === 0); + llimits.lua_assert(ci.c_k !== null && L.nny === 0); /* error status can only happen in a protected call */ - lua_assert(ci.callstatus & CIST_YPCALL || status === LUA_YIELD); + llimits.lua_assert(ci.callstatus & lstate.CIST_YPCALL || status === LUA_YIELD); - if (ci.callstatus & CIST_YPCALL) { /* was inside a pcall? */ - ci.callstatus &= ~CIST_YPCALL; /* continuation is also inside it */ + if (ci.callstatus & lstate.CIST_YPCALL) { /* was inside a pcall? */ + ci.callstatus &= ~lstate.CIST_YPCALL; /* continuation is also inside it */ L.errfunc = ci.c_old_errfunc; /* with the same error function */ } /* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already handled */ - if (ci.nresults === LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top; + if (ci.nresults === defs.LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top; let c_k = ci.c_k; /* don't want to call as method */ let n = c_k(L, status, ci.c_ctx); /* call continuation function */ - api_checknelems(L, n); + lapi.api_checknelems(L, n); luaD_poscall(L, ci, L.top - n, n); /* finish 'luaD_precall' */ }; @@ -460,16 +460,16 @@ const finishCcall = function (L, status) { ** be passed to the first continuation function (otherwise the default ** status is LUA_YIELD). */ -const unroll = function (L, ud) { +export const unroll = function (L, ud) { if (ud !== null) /* error status? */ finishCcall(L, ud); /* finish 'lua_pcallk' callee */ while (L.ci !== L.base_ci) { /* something in the stack */ - if (!(L.ci.callstatus & CIST_LUA)) /* C function? */ + if (!(L.ci.callstatus & lstate.CIST_LUA)) /* C function? */ finishCcall(L, LUA_YIELD); /* complete its execution */ else { /* Lua function */ - luaV_finishOp(L); /* finish interrupted instruction */ - luaV_execute(L); /* execute down to higher C 'boundary' */ + lvm.luaV_finishOp(L); /* finish interrupted instruction */ + lvm.luaV_execute(L); /* execute down to higher C 'boundary' */ } } }; @@ -478,9 +478,9 @@ const unroll = function (L, ud) { ** Try to find a suspended protected call (a "recover point") for the ** given thread. */ -const findpcall = function (L) { +export const findpcall = function (L) { for (let ci = L.ci; ci !== null; ci = ci.previous) { /* search for a pcall */ - if (ci.callstatus & CIST_YPCALL) + if (ci.callstatus & lstate.CIST_YPCALL) return ci; } @@ -492,15 +492,15 @@ const findpcall = function (L) { ** there is one) and completes the execution of the interrupted ** 'luaD_pcall'. If there is no recover point, returns zero. */ -const recover = function (L, status) { +export const recover = function (L, status) { let ci = findpcall(L); if (ci === null) return 0; /* no recovery point */ /* "finish" luaD_pcall */ let oldtop = ci.extra; - luaF_close(L, oldtop); + lfunc.luaF_close(L, oldtop); seterrorobj(L, status, oldtop); L.ci = ci; - L.allowhook = ci.callstatus & CIST_OAH; /* restore original 'allowhook' */ + L.allowhook = ci.callstatus & lstate.CIST_OAH; /* restore original 'allowhook' */ L.nny = 0; /* should be zero to be yieldable */ luaD_shrinkstack(L); L.errfunc = ci.c_old_errfunc; @@ -512,16 +512,16 @@ const recover = function (L, status) { ** of the coroutine itself. (Such errors should not be handled by any ** coroutine error handler and should not kill the coroutine.) */ -const resume_error = function (L, msg, narg) { - let ts = luaS_newliteral(L, msg); +export const resume_error = function (L, msg, narg) { + let ts = lstring.luaS_newliteral(L, msg); if (narg === 0) { - pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, 'stack overflow'); + lobject.pushsvalue2s(L, ts); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { /* remove args from the stack */ for (let i = 1; i < narg; i++) delete L.stack[--L.top]; - setsvalue2s(L, L.top - 1, ts); /* push error message */ + lobject.setsvalue2s(L, L.top - 1, ts); /* push error message */ } return LUA_ERRRUN; }; @@ -533,24 +533,24 @@ const resume_error = function (L, msg, narg) { ** function), plus erroneous cases: non-suspended coroutine or dead ** coroutine. */ -const resume = function (L, n) { +export const resume = function (L, n) { let firstArg = L.top - n; /* first argument */ let ci = L.ci; if (L.status === LUA_OK) { /* starting a coroutine? */ - if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ - luaV_execute(L); /* call it */ + if (!luaD_precall(L, firstArg - 1, defs.LUA_MULTRET)) /* Lua function? */ + lvm.luaV_execute(L); /* call it */ } else { /* resuming from previous yield */ - lua_assert(L.status === LUA_YIELD); + llimits.lua_assert(L.status === LUA_YIELD); L.status = LUA_OK; /* mark that it is running (again) */ ci.funcOff = ci.extra; ci.func = L.stack[ci.funcOff]; - if (ci.callstatus & CIST_LUA) /* yielded inside a hook? */ - luaV_execute(L); /* just continue running Lua code */ + if (ci.callstatus & lstate.CIST_LUA) /* yielded inside a hook? */ + lvm.luaV_execute(L); /* just continue running Lua code */ else { /* 'common' yield */ if (ci.c_k !== null) { /* does it have a continuation function? */ n = ci.c_k(L, LUA_YIELD, ci.c_ctx); /* call continuation */ - api_checknelems(L, n); + lapi.api_checknelems(L, n); firstArg = L.top - n; /* yield results come from continuation */ } @@ -561,7 +561,7 @@ const resume = function (L, n) { } }; -const lua_resume = function (L, from, nargs) { +export const lua_resume = function (L, from, nargs) { let oldnny = L.nny; /* save "number of non-yieldable" calls */ if (L.status === LUA_OK) { /* may be starting a coroutine */ @@ -571,12 +571,12 @@ const lua_resume = function (L, from, nargs) { return resume_error(L, 'cannot resume dead coroutine', nargs); L.nCcalls = from ? from.nCcalls + 1 : 1; - if (L.nCcalls >= LUAI_MAXCCALLS) + if (L.nCcalls >= llimits.LUAI_MAXCCALLS) return resume_error(L, 'JS stack overflow', nargs); L.nny = 0; /* allow yields */ - api_checknelems(L, L.status === LUA_OK ? nargs + 1 : nargs); + lapi.api_checknelems(L, L.status === LUA_OK ? nargs + 1 : nargs); let status = luaD_rawrunprotected(L, resume, nargs); if (status === -1) /* error calling 'lua_resume'? */ @@ -592,34 +592,34 @@ const lua_resume = function (L, from, nargs) { seterrorobj(L, status, L.top); /* push error message */ L.ci.top = L.top; } else - lua_assert(status === L.status); /* normal end or yield */ + llimits.lua_assert(status === L.status); /* normal end or yield */ } L.nny = oldnny; /* restore 'nny' */ L.nCcalls--; - lua_assert(L.nCcalls === (from ? from.nCcalls : 0)); + llimits.lua_assert(L.nCcalls === (from ? from.nCcalls : 0)); return status; }; -const lua_isyieldable = function (L) { +export const lua_isyieldable = function (L) { return L.nny === 0; }; -const lua_yieldk = function (L, nresults, ctx, k) { +export const lua_yieldk = function (L, nresults, ctx, k) { let ci = L.ci; - api_checknelems(L, nresults); + lapi.api_checknelems(L, nresults); if (L.nny > 0) { if (L !== L.l_G.mainthread) - luaG_runerror(L, to_luastring('attempt to yield across a JS-call boundary', true)); + ldebug.luaG_runerror(L, defs.to_luastring('attempt to yield across a JS-call boundary', true)); else - luaG_runerror(L, to_luastring('attempt to yield from outside a coroutine', true)); + ldebug.luaG_runerror(L, defs.to_luastring('attempt to yield from outside a coroutine', true)); } L.status = LUA_YIELD; ci.extra = ci.funcOff; /* save current 'func' */ - if (ci.callstatus & CIST_LUA) /* inside a hook? */ - api_check(L, k === null, 'hooks cannot continue after yielding'); + if (ci.callstatus & lstate.CIST_LUA) /* inside a hook? */ + llimits.api_check(L, k === null, 'hooks cannot continue after yielding'); else { ci.c_k = k; if (k !== null) /* is there a continuation? */ @@ -629,15 +629,15 @@ const lua_yieldk = function (L, nresults, ctx, k) { luaD_throw(L, LUA_YIELD); } - lua_assert(ci.callstatus & CIST_HOOKED); /* must be inside a hook */ + llimits.lua_assert(ci.callstatus & lstate.CIST_HOOKED); /* must be inside a hook */ return 0; /* return to 'luaD_hook' */ }; -const lua_yield = function (L, n) { +export const lua_yield = function (L, n) { lua_yieldk(L, n, 0, null); }; -const luaD_pcall = function (L, func, u, old_top, ef) { +export const luaD_pcall = function (L, func, u, old_top, ef) { let old_ci = L.ci; let old_allowhooks = L.allowhook; let old_nny = L.nny; @@ -647,7 +647,7 @@ const luaD_pcall = function (L, func, u, old_top, ef) { let status = luaD_rawrunprotected(L, func, u); if (status !== LUA_OK) { - luaF_close(L, old_top); + lfunc.luaF_close(L, old_top); seterrorobj(L, status, old_top); L.ci = old_ci; L.allowhook = old_allowhooks; @@ -663,7 +663,7 @@ const luaD_pcall = function (L, func, u, old_top, ef) { /* ** Similar to 'luaD_call', but does not allow yields during the call */ -const luaD_callnoyield = function (L, off, nResults) { +export const luaD_callnoyield = function (L, off, nResults) { L.nny++; luaD_call(L, off, nResults); L.nny--; @@ -672,80 +672,43 @@ const luaD_callnoyield = function (L, off, nResults) { /* ** Execute a protected parser. */ -class SParser { +export class SParser { constructor(z, name, mode) { /* data to 'f_parser' */ this.z = z; - this.buff = new MBuffer(); /* dynamic structure used by the scanner */ - this.dyd = new Dyndata(); /* dynamic structures used by the parser */ + this.buff = new lzio.MBuffer(); /* dynamic structure used by the scanner */ + this.dyd = new lparser.Dyndata(); /* dynamic structures used by the parser */ this.mode = mode; this.name = name; } } -const checkmode = function (L, mode, x) { - if (mode && luastring_indexOf(mode, x[0]) === -1) { - luaO_pushfstring(L, - to_luastring('attempt to load a %s chunk (mode is \'%s\')'), x, mode); +export const checkmode = function (L, mode, x) { + if (mode && defs.luastring_indexOf(mode, x[0]) === -1) { + lobject.luaO_pushfstring(L, + defs.to_luastring('attempt to load a %s chunk (mode is \'%s\')'), x, mode); luaD_throw(L, LUA_ERRSYNTAX); } }; -const f_parser = function (L, p) { +export const f_parser = function (L, p) { let cl; let c = p.z.zgetc(); /* read first character */ - if (c === LUA_SIGNATURE[0]) { - checkmode(L, p.mode, to_luastring('binary', true)); - cl = luaU_undump(L, p.z, p.name); + if (c === defs.LUA_SIGNATURE[0]) { + checkmode(L, p.mode, defs.to_luastring('binary', true)); + cl = lundump.luaU_undump(L, p.z, p.name); } else { - checkmode(L, p.mode, to_luastring('text', true)); - cl = luaY_parser(L, p.z, p.buff, p.dyd, p.name, c); + checkmode(L, p.mode, defs.to_luastring('text', true)); + cl = lparser.luaY_parser(L, p.z, p.buff, p.dyd, p.name, c); } - lua_assert(cl.nupvalues === cl.p.upvalues.length); - luaF_initupvals(L, cl); + llimits.lua_assert(cl.nupvalues === cl.p.upvalues.length); + lfunc.luaF_initupvals(L, cl); }; -const luaD_protectedparser = function (L, z, name, mode) { +export const luaD_protectedparser = function (L, z, name, mode) { let p = new SParser(z, name, mode); L.nny++; /* cannot yield during parsing */ let status = luaD_pcall(L, f_parser, p, L.top, L.errfunc); L.nny--; return status; }; - -const _adjust_top = adjust_top; -export { _adjust_top as adjust_top }; -const _luaD_call = luaD_call; -export { _luaD_call as luaD_call }; -const _luaD_callnoyield = luaD_callnoyield; -export { _luaD_callnoyield as luaD_callnoyield }; -const _luaD_checkstack = luaD_checkstack; -export { _luaD_checkstack as luaD_checkstack }; -const _luaD_growstack = luaD_growstack; -export { _luaD_growstack as luaD_growstack }; -const _luaD_hook = luaD_hook; -export { _luaD_hook as luaD_hook }; -const _luaD_inctop = luaD_inctop; -export { _luaD_inctop as luaD_inctop }; -const _luaD_pcall = luaD_pcall; -export { _luaD_pcall as luaD_pcall }; -const _luaD_poscall = luaD_poscall; -export { _luaD_poscall as luaD_poscall }; -const _luaD_precall = luaD_precall; -export { _luaD_precall as luaD_precall }; -const _luaD_protectedparser = luaD_protectedparser; -export { _luaD_protectedparser as luaD_protectedparser }; -const _luaD_rawrunprotected = luaD_rawrunprotected; -export { _luaD_rawrunprotected as luaD_rawrunprotected }; -const _luaD_reallocstack = luaD_reallocstack; -export { _luaD_reallocstack as luaD_reallocstack }; -const _luaD_throw = luaD_throw; -export { _luaD_throw as luaD_throw }; -const _lua_isyieldable = lua_isyieldable; -export { _lua_isyieldable as lua_isyieldable }; -const _lua_resume = lua_resume; -export { _lua_resume as lua_resume }; -const _lua_yield = lua_yield; -export { _lua_yield as lua_yield }; -const _lua_yieldk = lua_yieldk; -export { _lua_yieldk as lua_yieldk }; diff --git a/src/ldump.js b/src/ldump.js index 07115747..d600a78c 100644 --- a/src/ldump.js +++ b/src/ldump.js @@ -1,6 +1,4 @@ -'use strict'; - -import { LUA_SIGNATURE, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, constant_types, luastring_of } from './defs.js'; +import * as defs from './defs.js'; const { LUA_TBOOLEAN, @@ -9,12 +7,12 @@ const { LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR -} = constant_types; +} = defs.constant_types; -const LUAC_DATA = luastring_of(25, 147, 13, 10, 26, 10); +const LUAC_DATA = defs.luastring_of(25, 147, 13, 10, 26, 10); const LUAC_INT = 0x5678; const LUAC_NUM = 370.5; -const LUAC_VERSION = Number(LUA_VERSION_MAJOR) * 16 + Number(LUA_VERSION_MINOR); +const LUAC_VERSION = Number(defs.LUA_VERSION_MAJOR) * 16 + Number(defs.LUA_VERSION_MINOR); const LUAC_FORMAT = 0; /* this is the official format */ class DumpState { @@ -33,7 +31,7 @@ const DumpBlock = function (b, size, D) { }; const DumpByte = function (y, D) { - DumpBlock(luastring_of(y), 1, D); + DumpBlock(defs.luastring_of(y), 1, D); }; const DumpInt = function (x, D) { @@ -162,7 +160,7 @@ const DumpFunction = function (f, psource, D) { }; const DumpHeader = function (D) { - DumpBlock(LUA_SIGNATURE, LUA_SIGNATURE.length, D); + DumpBlock(defs.LUA_SIGNATURE, defs.LUA_SIGNATURE.length, D); DumpByte(LUAC_VERSION, D); DumpByte(LUAC_FORMAT, D); DumpBlock(LUAC_DATA, LUAC_DATA.length, D); @@ -178,7 +176,7 @@ const DumpHeader = function (D) { /* ** dump Lua function as precompiled chunk */ -const luaU_dump = function (L, f, w, data, strip) { +export const luaU_dump = function (L, f, w, data, strip) { let D = new DumpState(); D.L = L; D.writer = w; @@ -190,6 +188,3 @@ const luaU_dump = function (L, f, w, data, strip) { DumpFunction(f, null, D); return D.status; }; - -const _luaU_dump = luaU_dump; -export { _luaU_dump as luaU_dump }; diff --git a/src/lfunc.js b/src/lfunc.js index 09a08dc4..7269491c 100644 --- a/src/lfunc.js +++ b/src/lfunc.js @@ -1,9 +1,9 @@ -import { constant_types } from './defs.js'; -import { LClosure, TValue } from './lobject.js'; +import * as defs from './defs.js'; +import * as lobject from './lobject.js'; -const { LUA_TNIL } = constant_types; +const { LUA_TNIL } = defs.constant_types; -class Proto { +export class Proto { constructor(L) { this.id = L.l_G.id_counter++; this.k = []; // constants used by the function @@ -22,37 +22,37 @@ class Proto { } } -const luaF_newLclosure = function(L, n) { - return new LClosure(L, n); +export const luaF_newLclosure = function (L, n) { + return new lobject.LClosure(L, n); }; -const luaF_findupval = function(L, level) { +export const luaF_findupval = function (L, level) { return L.stack[level]; }; -const luaF_close = function(L, level) { +export const luaF_close = function (L, level) { /* Create new TValues on stack; * any closures will keep referencing old TValues */ - for (let i=level; i 6 ? - (s) => s : // identity function - (s) => Buffer.from(s.buffer, s.byteOffset, s.byteLength); +const prepare_string_for_write = (s) => Buffer.from(s.buffer, s.byteOffset, s.byteLength); const g_write = function(L, f, arg) { - let nargs = lua_gettop(L) - arg; + let nargs = lua.lua_gettop(L) - arg; let status = true; let err; for (; nargs--; arg++) { - let s = luaL_checklstring(L, arg); + let s = lauxlib.luaL_checklstring(L, arg); try { - status = status && (writeSync(f.fd, prepare_string_for_write(s), 0, s.length) === s.length); + status = status && ((prepare_string_for_write(s).write()) === s.length); } catch (e) { status = false; err = e; } } if (status) return 1; /* file handle already on stack top */ - else return luaL_fileresult(L, status, null, err); + else return lauxlib.luaL_fileresult(L, status, null, err); }; const io_write = function(L) { @@ -128,20 +124,20 @@ const io_write = function(L) { const f_write = function(L) { let f = tofile(L); - lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ + lua.lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ return g_write(L, f, 2); }; const io_flush = function (L) { /* stub, as node doesn't have synchronized buffered IO */ getiofile(L, IO_OUTPUT); - return luaL_fileresult(L, true, null, null); + return lauxlib.luaL_fileresult(L, true, null, null); }; const f_flush = function (L) { /* stub, as node doesn't have synchronized buffered IO */ tofile(L); - return luaL_fileresult(L, true, null, null); + return lauxlib.luaL_fileresult(L, true, null, null); }; const iolib = { @@ -161,18 +157,18 @@ const flib = { }; const createmeta = function(L) { - luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = metatable */ - luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ - lua_pop(L, 1); /* pop new metatable */ + lauxlib.luaL_newmetatable(L, lauxlib.LUA_FILEHANDLE); /* create metatable for file handles */ + lua.lua_pushvalue(L, -1); /* push metatable */ + lua.lua_setfield(L, -2, fengaricore.to_luastring('__index', true)); /* metatable.__index = metatable */ + lauxlib.luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ + lua.lua_pop(L, 1); /* pop new metatable */ }; const io_noclose = function(L) { let p = tolstream(L); p.closef = io_noclose; - lua_pushnil(L); - lua_pushliteral(L, 'cannot close standard file'); + lua.lua_pushnil(L); + lua.lua_pushliteral(L, 'cannot close standard file'); return 2; }; @@ -181,21 +177,18 @@ const createstdfile = function(L, f, k, fname) { p.f = f; p.closef = io_noclose; if (k !== null) { - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */ + lua.lua_pushvalue(L, -1); + lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, k); /* add file to registry */ } - lua_setfield(L, -2, fname); /* add file to module */ + lua.lua_setfield(L, -2, fname); /* add file to module */ }; -const luaopen_io = function(L) { - luaL_newlib(L, iolib); +export const luaopen_io = function(L) { + lauxlib.luaL_newlib(L, iolib); createmeta(L); /* create (and set) default files */ - createstdfile(L, process.stdin, IO_INPUT, to_luastring('stdin')); - createstdfile(L, process.stdout, IO_OUTPUT, to_luastring('stdout')); - createstdfile(L, process.stderr, null, to_luastring('stderr')); + createstdfile(L, process.stdin, IO_INPUT, fengaricore.to_luastring('stdin')); + createstdfile(L, process.stdout, IO_OUTPUT, fengaricore.to_luastring('stdout')); + createstdfile(L, process.stderr, null, fengaricore.to_luastring('stderr')); return 1; }; - -const _luaopen_io = luaopen_io; -export { _luaopen_io as luaopen_io }; diff --git a/src/ljstype.js b/src/ljstype.js index 9f835894..13058480 100644 --- a/src/ljstype.js +++ b/src/ljstype.js @@ -1,6 +1,6 @@ -import { luastring_of } from './defs.js'; +import * as defs from './defs.js'; -const luai_ctype_ = luastring_of( +const luai_ctype_ = defs.luastring_of( 0x00, /* EOZ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, @@ -42,39 +42,26 @@ const PRINTBIT = 2; const SPACEBIT = 3; const XDIGITBIT = 4; -const lisdigit = function(c) { +export const lisdigit = function(c) { return (luai_ctype_[c+1] & (1<=', '<=', '~=', '<<', '>>', '::', '', '', '', '', '' -].map((e, i) => to_luastring(e)); +].map((e, _i) => defs.to_luastring(e)); class SemInfo { constructor() { @@ -122,7 +122,7 @@ class Token { /* state of the lexer plus state of the parser when shared by all functions */ -class LexState { +export class LexState { constructor() { this.current = NaN; /* current character (charint) */ this.linenumber = NaN; /* input line counter */ @@ -143,21 +143,21 @@ class LexState { const save = function (ls, c) { let b = ls.buff; if (b.n + 1 > b.buffer.length) { - if (b.buffer.length >= MAX_INT / 2) - lexerror(ls, to_luastring('lexical element too long', true), 0); + if (b.buffer.length >= llimits.MAX_INT / 2) + lexerror(ls, defs.to_luastring('lexical element too long', true), 0); let newsize = b.buffer.length * 2; - luaZ_resizebuffer(ls.L, b, newsize); + lzio.luaZ_resizebuffer(ls.L, b, newsize); } b.buffer[b.n++] = c < 0 ? 255 + c + 1 : c; }; -const luaX_token2str = function (ls, token) { +export const luaX_token2str = function (ls, token) { if (token < FIRST_RESERVED) { /* single-byte symbols? */ - return luaO_pushfstring(ls.L, to_luastring('\'%c\'', true), token); + return lobject.luaO_pushfstring(ls.L, defs.to_luastring('\'%c\'', true), token); } else { let s = luaX_tokens[token - FIRST_RESERVED]; if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ - return luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), s); + return lobject.luaO_pushfstring(ls.L, defs.to_luastring('\'%s\'', true), s); else /* names, strings, and numerals */ return s; } @@ -181,15 +181,15 @@ const save_and_next = function (ls) { ** it will not be collected until the end of the compilation ** (by that time it should be anchored somewhere) */ -const TVtrue = new TValue(LUA_TBOOLEAN, true); -const luaX_newstring = function (ls, str) { +const TVtrue = new lobject.TValue(LUA_TBOOLEAN, true); +export const luaX_newstring = function (ls, str) { let L = ls.L; - let ts = luaS_new(L, str); + let ts = lstring.luaS_new(L, str); /* HACK: Workaround lack of ltable 'keyfromval' */ - let tpair = ls.h.strong.get(luaS_hashlongstr(ts)); + let tpair = ls.h.strong.get(lstring.luaS_hashlongstr(ts)); if (!tpair) { /* not in use yet? */ - let key = new TValue(LUA_TLNGSTR, ts); - luaH_setfrom(L, ls.h, key, TVtrue); + let key = new lobject.TValue(LUA_TLNGSTR, ts); + ltable.luaH_setfrom(L, ls.h, key, TVtrue); } else { /* string already present */ ts = tpair.key.tsvalue(); /* re-use value previously stored */ } @@ -202,15 +202,15 @@ const luaX_newstring = function (ls, str) { */ const inclinenumber = function (ls) { let old = ls.current; - lua_assert(currIsNewline(ls)); + llimits.lua_assert(currIsNewline(ls)); next(ls); /* skip '\n' or '\r' */ if (currIsNewline(ls) && ls.current !== old) next(ls); /* skip '\n\r' or '\r\n' */ - if (++ls.linenumber >= MAX_INT) - lexerror(ls, to_luastring('chunk has too many lines', true), 0); + if (++ls.linenumber >= llimits.MAX_INT) + lexerror(ls, defs.to_luastring('chunk has too many lines', true), 0); }; -const luaX_setinput = function (L, ls, z, source, firstchar) { +export const luaX_setinput = function (L, ls, z, source, firstchar) { ls.t = { token: 0, seminfo: new SemInfo() @@ -226,8 +226,8 @@ const luaX_setinput = function (L, ls, z, source, firstchar) { ls.linenumber = 1; ls.lastline = 1; ls.source = source; - ls.envn = luaS_bless(L, LUA_ENV); - luaZ_resizebuffer(L, ls.buff, LUA_MINBUFFER); /* initialize buffer */ + ls.envn = lstring.luaS_bless(L, LUA_ENV); + lzio.luaZ_resizebuffer(L, ls.buff, llimits.LUA_MINBUFFER); /* initialize buffer */ }; const check_next1 = function (ls, c) { @@ -255,7 +255,7 @@ const check_next2 = function (ls, set) { const read_numeral = function (ls, seminfo) { let expo = 'Ee'; let first = ls.current; - lua_assert(lisdigit(ls.current)); + llimits.lua_assert(ljstype.lisdigit(ls.current)); save_and_next(ls); if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, 'xX')) /* hexadecimal? */ expo = 'Pp'; @@ -263,7 +263,7 @@ const read_numeral = function (ls, seminfo) { for (; ;) { if (check_next2(ls, expo)) /* exponent part? */ check_next2(ls, '-+'); /* optional exponent sign */ - if (lisxdigit(ls.current)) + if (ljstype.lisxdigit(ls.current)) save_and_next(ls); else if (ls.current === 46 /* ('.').charCodeAt(0) */) save_and_next(ls); @@ -272,14 +272,14 @@ const read_numeral = function (ls, seminfo) { // save(ls, 0); - let obj = new TValue(); - if (luaO_str2num(luaZ_buffer(ls.buff), obj) === 0) /* format error? */ - lexerror(ls, to_luastring('malformed number', true), TK_FLT); + let obj = new lobject.TValue(); + if (lobject.luaO_str2num(lzio.luaZ_buffer(ls.buff), obj) === 0) /* format error? */ + lexerror(ls, defs.to_luastring('malformed number', true), TK_FLT); if (obj.ttisinteger()) { seminfo.i = obj.value; return TK_INT; } else { - lua_assert(obj.ttisfloat()); + llimits.lua_assert(obj.ttisfloat()); seminfo.r = obj.value; return TK_FLT; } @@ -290,20 +290,20 @@ const txtToken = function (ls, token) { case TK_NAME: case TK_STRING: case TK_FLT: case TK_INT: // save(ls, 0); - return luaO_pushfstring(ls.L, to_luastring('\'%s\'', true), luaZ_buffer(ls.buff)); + return lobject.luaO_pushfstring(ls.L, defs.to_luastring('\'%s\'', true), lzio.luaZ_buffer(ls.buff)); default: return luaX_token2str(ls, token); } }; const lexerror = function (ls, msg, token) { - msg = luaG_addinfo(ls.L, msg, ls.source, ls.linenumber); + msg = ldebug.luaG_addinfo(ls.L, msg, ls.source, ls.linenumber); if (token) - luaO_pushfstring(ls.L, to_luastring('%s near %s'), msg, txtToken(ls, token)); - luaD_throw(ls.L, LUA_ERRSYNTAX); + lobject.luaO_pushfstring(ls.L, defs.to_luastring('%s near %s'), msg, txtToken(ls, token)); + ldo.luaD_throw(ls.L, LUA_ERRSYNTAX); }; -const luaX_syntaxerror = function (ls, msg) { +export const luaX_syntaxerror = function (ls, msg) { lexerror(ls, msg, ls.t.token); }; @@ -315,7 +315,7 @@ const luaX_syntaxerror = function (ls, msg) { const skip_sep = function (ls) { let count = 0; let s = ls.current; - lua_assert(s === 91 /* ('[').charCodeAt(0) */ || s === 93 /* (']').charCodeAt(0) */); + llimits.lua_assert(s === 91 /* ('[').charCodeAt(0) */ || s === 93 /* (']').charCodeAt(0) */); save_and_next(ls); while (ls.current === 61 /* ('=').charCodeAt(0) */) { save_and_next(ls); @@ -334,10 +334,10 @@ const read_long_string = function (ls, seminfo, sep) { let skip = false; for (; !skip;) { switch (ls.current) { - case EOZ: { /* error */ + case lzio.EOZ: { /* error */ let what = seminfo ? 'string' : 'comment'; let msg = `unfinished long ${what} (starting at line ${line})`; - lexerror(ls, to_luastring(msg), TK_EOS); + lexerror(ls, defs.to_luastring(msg), TK_EOS); break; } case 93 /* (']').charCodeAt(0) */: { @@ -351,7 +351,7 @@ const read_long_string = function (ls, seminfo, sep) { case 13 /* ('\r').charCodeAt(0) */: { save(ls, 10 /* ('\n').charCodeAt(0) */); inclinenumber(ls); - if (!seminfo) luaZ_resetbuffer(ls.buff); + if (!seminfo) lzio.luaZ_resetbuffer(ls.buff); break; } default: { @@ -367,7 +367,7 @@ const read_long_string = function (ls, seminfo, sep) { const esccheck = function (ls, c, msg) { if (!c) { - if (ls.current !== EOZ) + if (ls.current !== lzio.EOZ) save_and_next(ls); /* add current to buffer for error message */ lexerror(ls, msg, TK_STRING); } @@ -375,52 +375,52 @@ const esccheck = function (ls, c, msg) { const gethexa = function (ls) { save_and_next(ls); - esccheck(ls, lisxdigit(ls.current), to_luastring('hexadecimal digit expected', true)); - return luaO_hexavalue(ls.current); + esccheck(ls, ljstype.lisxdigit(ls.current), defs.to_luastring('hexadecimal digit expected', true)); + return lobject.luaO_hexavalue(ls.current); }; const readhexaesc = function (ls) { let r = gethexa(ls); r = (r << 4) + gethexa(ls); - luaZ_buffremove(ls.buff, 2); /* remove saved chars from buffer */ + lzio.luaZ_buffremove(ls.buff, 2); /* remove saved chars from buffer */ return r; }; const readutf8desc = function (ls) { let i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ save_and_next(ls); /* skip 'u' */ - esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring('missing \'{\'', true)); + esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, defs.to_luastring('missing \'{\'', true)); let r = gethexa(ls); /* must have at least one digit */ save_and_next(ls); - while (lisxdigit(ls.current)) { + while (ljstype.lisxdigit(ls.current)) { i++; - r = (r << 4) + luaO_hexavalue(ls.current); - esccheck(ls, r <= 0x10FFFF, to_luastring('UTF-8 value too large', true)); + r = (r << 4) + lobject.luaO_hexavalue(ls.current); + esccheck(ls, r <= 0x10FFFF, defs.to_luastring('UTF-8 value too large', true)); save_and_next(ls); } - esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring('missing \'}\'', true)); + esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, defs.to_luastring('missing \'}\'', true)); next(ls); /* skip '}' */ - luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */ + lzio.luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */ return r; }; const utf8esc = function (ls) { - let buff = new Uint8Array(UTF8BUFFSZ); - let n = luaO_utf8esc(buff, readutf8desc(ls)); + let buff = new Uint8Array(lobject.UTF8BUFFSZ); + let n = lobject.luaO_utf8esc(buff, readutf8desc(ls)); for (; n > 0; n--) /* add 'buff' to string */ - save(ls, buff[UTF8BUFFSZ - n]); + save(ls, buff[lobject.UTF8BUFFSZ - n]); }; const readdecesc = function (ls) { let r = 0; /* result accumulator */ let i; - for (i = 0; i < 3 && lisdigit(ls.current); i++) { /* read up to 3 digits */ + for (i = 0; i < 3 && ljstype.lisdigit(ls.current); i++) { /* read up to 3 digits */ r = 10 * r + ls.current - 48 /* ('0').charCodeAt(0) */; save_and_next(ls); } - esccheck(ls, r <= 255, to_luastring('decimal escape too large', true)); - luaZ_buffremove(ls.buff, i); /* remove read digits from buffer */ + esccheck(ls, r <= 255, defs.to_luastring('decimal escape too large', true)); + lzio.luaZ_buffremove(ls.buff, i); /* remove read digits from buffer */ return r; }; @@ -429,12 +429,12 @@ const read_string = function (ls, del, seminfo) { while (ls.current !== del) { switch (ls.current) { - case EOZ: - lexerror(ls, to_luastring('unfinished string', true), TK_EOS); + case lzio.EOZ: + lexerror(ls, defs.to_luastring('unfinished string', true), TK_EOS); break; case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: - lexerror(ls, to_luastring('unfinished string', true), TK_STRING); + lexerror(ls, defs.to_luastring('unfinished string', true), TK_STRING); break; case 92 /* ('\\').charCodeAt(0) */: { /* escape sequences */ save_and_next(ls); /* keep '\\' for error messages */ @@ -457,18 +457,18 @@ const read_string = function (ls, del, seminfo) { case 34 /* ('"').charCodeAt(0) */: case 39 /* ('\'').charCodeAt(0) */: c = ls.current; will = 'read_save'; break; - case EOZ: will = 'no_save'; break; /* will raise an error next loop */ + case lzio.EOZ: will = 'no_save'; break; /* will raise an error next loop */ case 122 /* ('z').charCodeAt(0) */: { /* zap following span of spaces */ - luaZ_buffremove(ls.buff, 1); /* remove '\\' */ + lzio.luaZ_buffremove(ls.buff, 1); /* remove '\\' */ next(ls); /* skip the 'z' */ - while (lisspace(ls.current)) { + while (ljstype.lisspace(ls.current)) { if (currIsNewline(ls)) inclinenumber(ls); else next(ls); } will = 'no_save'; break; } default: { - esccheck(ls, lisdigit(ls.current), to_luastring('invalid escape sequence', true)); + esccheck(ls, ljstype.lisdigit(ls.current), defs.to_luastring('invalid escape sequence', true)); c = readdecesc(ls); /* digital escape '\ddd' */ will = 'only_save'; break; } @@ -478,7 +478,7 @@ const read_string = function (ls, del, seminfo) { next(ls); if (will === 'read_save' || will === 'only_save') { - luaZ_buffremove(ls.buff, 1); /* remove '\\' */ + lzio.luaZ_buffremove(ls.buff, 1); /* remove '\\' */ save(ls, c); } @@ -494,17 +494,17 @@ const read_string = function (ls, del, seminfo) { }; const token_to_index = Object.create(null); /* don't want to return true for e.g. 'hasOwnProperty' */ -luaX_tokens.forEach((e, i) => token_to_index[luaS_hash(e)] = i); +luaX_tokens.forEach((e, i) => token_to_index[lstring.luaS_hash(e)] = i); -const isreserved = function (w) { - let kidx = token_to_index[luaS_hashlongstr(w)]; +export const isreserved = function (w) { + let kidx = token_to_index[lstring.luaS_hashlongstr(w)]; return kidx !== void 0 && kidx <= 22; }; const llex = function (ls, seminfo) { - luaZ_resetbuffer(ls.buff); + lzio.luaZ_resetbuffer(ls.buff); for (; ;) { - lua_assert(typeof ls.current == 'number'); /* fengari addition */ + llimits.lua_assert(typeof ls.current == 'number'); /* fengari addition */ switch (ls.current) { case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: { /* line breaks */ @@ -525,16 +525,16 @@ const llex = function (ls, seminfo) { next(ls); if (ls.current === 91 /* ('[').charCodeAt(0) */) { /* long comment? */ let sep = skip_sep(ls); - luaZ_resetbuffer(ls.buff); /* 'skip_sep' may dirty the buffer */ + lzio.luaZ_resetbuffer(ls.buff); /* 'skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, null, sep); /* skip long comment */ - luaZ_resetbuffer(ls.buff); /* previous call may dirty the buff. */ + lzio.luaZ_resetbuffer(ls.buff); /* previous call may dirty the buff. */ break; } } /* else short comment */ - while (!currIsNewline(ls) && ls.current !== EOZ) + while (!currIsNewline(ls) && ls.current !== lzio.EOZ) next(ls); /* skip until end of line (or end of file) */ break; } @@ -544,7 +544,7 @@ const llex = function (ls, seminfo) { read_long_string(ls, seminfo, sep); return TK_STRING; } else if (sep !== -1) /* '[=...' missing second bracket */ - lexerror(ls, to_luastring('invalid long string delimiter', true), TK_STRING); + lexerror(ls, defs.to_luastring('invalid long string delimiter', true), TK_STRING); return 91 /* ('[').charCodeAt(0) */; } case 61 /* ('=').charCodeAt(0) */: { @@ -591,24 +591,24 @@ const llex = function (ls, seminfo) { return TK_DOTS; /* '...' */ else return TK_CONCAT; /* '..' */ } - else if (!lisdigit(ls.current)) return 46 /* ('.').charCodeAt(0) */; + else if (!ljstype.lisdigit(ls.current)) return 46 /* ('.').charCodeAt(0) */; else return read_numeral(ls, seminfo); } case 48 /* ('0').charCodeAt(0) */: case 49 /* ('1').charCodeAt(0) */: case 50 /* ('2').charCodeAt(0) */: case 51 /* ('3').charCodeAt(0) */: case 52 /* ('4').charCodeAt(0) */: case 53 /* ('5').charCodeAt(0) */: case 54 /* ('6').charCodeAt(0) */: case 55 /* ('7').charCodeAt(0) */: case 56 /* ('8').charCodeAt(0) */: case 57 /* ('9').charCodeAt(0) */: { return read_numeral(ls, seminfo); } - case EOZ: { + case lzio.EOZ: { return TK_EOS; } default: { - if (lislalpha(ls.current)) { /* identifier or reserved word? */ + if (ljstype.lislalpha(ls.current)) { /* identifier or reserved word? */ do { save_and_next(ls); - } while (lislalnum(ls.current)); - let ts = luaX_newstring(ls, luaZ_buffer(ls.buff)); + } while (ljstype.lislalnum(ls.current)); + let ts = luaX_newstring(ls, lzio.luaZ_buffer(ls.buff)); seminfo.ts = ts; - let kidx = token_to_index[luaS_hashlongstr(ts)]; + let kidx = token_to_index[lstring.luaS_hashlongstr(ts)]; if (kidx !== void 0 && kidx <= 22) /* reserved word? */ return kidx + FIRST_RESERVED; else @@ -623,7 +623,7 @@ const llex = function (ls, seminfo) { } }; -const luaX_next = function (ls) { +export const luaX_next = function (ls) { ls.lastline = ls.linenumber; if (ls.lookahead.token !== TK_EOS) { /* is there a look-ahead token? */ ls.t.token = ls.lookahead.token; /* use this one */ @@ -635,33 +635,8 @@ const luaX_next = function (ls) { ls.t.token = llex(ls, ls.t.seminfo); /* read next token */ }; -const luaX_lookahead = function (ls) { - lua_assert(ls.lookahead.token === TK_EOS); +export const luaX_lookahead = function (ls) { + llimits.lua_assert(ls.lookahead.token === TK_EOS); ls.lookahead.token = llex(ls, ls.lookahead.seminfo); return ls.lookahead.token; }; - -const _FIRST_RESERVED = FIRST_RESERVED; -export { _FIRST_RESERVED as FIRST_RESERVED }; -const _LUA_ENV = LUA_ENV; -export { _LUA_ENV as LUA_ENV }; -const _LexState = LexState; -export { _LexState as LexState }; -const _RESERVED = RESERVED; -export { _RESERVED as RESERVED }; -const _isreserved = isreserved; -export { _isreserved as isreserved }; -const _luaX_lookahead = luaX_lookahead; -export { _luaX_lookahead as luaX_lookahead }; -const _luaX_newstring = luaX_newstring; -export { _luaX_newstring as luaX_newstring }; -const _luaX_next = luaX_next; -export { _luaX_next as luaX_next }; -const _luaX_setinput = luaX_setinput; -export { _luaX_setinput as luaX_setinput }; -const _luaX_syntaxerror = luaX_syntaxerror; -export { _luaX_syntaxerror as luaX_syntaxerror }; -const _luaX_token2str = luaX_token2str; -export { _luaX_token2str as luaX_token2str }; -const _luaX_tokens = luaX_tokens; -export { _luaX_tokens as luaX_tokens }; diff --git a/src/llimits.js b/src/llimits.js index cce5e61f..22564c0a 100644 --- a/src/llimits.js +++ b/src/llimits.js @@ -1,37 +1,23 @@ -const lua_assert = function (c) { +export const lua_assert = function (c) { if (!c) throw Error('assertion failed'); }; -const _lua_assert = lua_assert; -export { _lua_assert as lua_assert }; -const api_check = function (l, e, msg) { +export const api_check = function (l, e, msg) { if (!e) throw Error(msg); }; -const _api_check = api_check; -export { _api_check as api_check }; -const LUAI_MAXCCALLS = 200; -const _LUAI_MAXCCALLS = LUAI_MAXCCALLS; -export { _LUAI_MAXCCALLS as LUAI_MAXCCALLS }; +export const LUAI_MAXCCALLS = 200; /* minimum size for string buffer */ -const LUA_MINBUFFER = 32; -const _LUA_MINBUFFER = LUA_MINBUFFER; -export { _LUA_MINBUFFER as LUA_MINBUFFER }; +export const LUA_MINBUFFER = 32; -const luai_nummod = function (L, a, b) { +export const luai_nummod = function (L, a, b) { let m = a % b; if ((m * b) < 0) m += b; return m; }; -const _luai_nummod = luai_nummod; -export { _luai_nummod as luai_nummod }; // If later integers are more than 32bit, LUA_MAXINTEGER will then be != MAX_INT -const MAX_INT = 2147483647; -const _MAX_INT = MAX_INT; -export { _MAX_INT as MAX_INT }; -const MIN_INT = -2147483648; -const _MIN_INT = MIN_INT; -export { _MIN_INT as MIN_INT }; +export const MAX_INT = 2147483647; +export const MIN_INT = -2147483648; diff --git a/src/lmathlib.js b/src/lmathlib.js index fe095cc7..b2d69626 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,7 +1,7 @@ -import { LUA_OPLT, LUA_TNUMBER, lua_compare, lua_gettop, lua_isinteger, lua_isnoneornil, lua_pushboolean, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushvalue, lua_setfield, lua_settop, lua_tointeger, lua_tointegerx, lua_type } from './lua.js'; -import { luaL_argcheck, luaL_argerror, luaL_checkany, luaL_checkinteger, luaL_checknumber, luaL_error, luaL_newlib, luaL_optnumber } from './lauxlib.js'; -import { LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger } from './luaconf.js'; -import { to_luastring } from './fengaricore.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as luaconf from './luaconf.js'; +import * as fengaricore from './fengaricore.js'; let rand_state; /* use same parameters as glibc LCG */ @@ -19,138 +19,138 @@ const math_random = function (L) { let low, up; /* use Math.random until randomseed is called */ let r = (rand_state === void 0) ? Math.random() : (l_rand() / 0x80000000); - switch (lua_gettop(L)) { /* check number of arguments */ + switch (lua.lua_gettop(L)) { /* check number of arguments */ case 0: - lua_pushnumber(L, r); /* Number between 0 and 1 */ + lua.lua_pushnumber(L, r); /* Number between 0 and 1 */ return 1; case 1: { low = 1; - up = luaL_checkinteger(L, 1); + up = lauxlib.luaL_checkinteger(L, 1); break; } case 2: { - low = luaL_checkinteger(L, 1); - up = luaL_checkinteger(L, 2); + low = lauxlib.luaL_checkinteger(L, 1); + up = lauxlib.luaL_checkinteger(L, 2); break; } - default: return luaL_error(L, 'wrong number of arguments'); + default: return lauxlib.luaL_error(L, 'wrong number of arguments'); } /* random integer in the interval [low, up] */ - luaL_argcheck(L, low <= up, 1, 'interval is empty'); - luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, + lauxlib.luaL_argcheck(L, low <= up, 1, 'interval is empty'); + lauxlib.luaL_argcheck(L, low >= 0 || up <= luaconf.LUA_MAXINTEGER + low, 1, 'interval too large'); r *= (up - low) + 1; - lua_pushinteger(L, Math.floor(r) + low); + lua.lua_pushinteger(L, Math.floor(r) + low); return 1; }; const math_randomseed = function (L) { - l_srand(luaL_checknumber(L, 1)); + l_srand(lauxlib.luaL_checknumber(L, 1)); l_rand(); /* discard first value to avoid undesirable correlations */ return 0; }; const math_abs = function (L) { - if (lua_isinteger(L, 1)) { - let n = lua_tointeger(L, 1); + if (lua.lua_isinteger(L, 1)) { + let n = lua.lua_tointeger(L, 1); if (n < 0) n = (-n) | 0; - lua_pushinteger(L, n); + lua.lua_pushinteger(L, n); } else - lua_pushnumber(L, Math.abs(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.abs(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_sin = function (L) { - lua_pushnumber(L, Math.sin(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.sin(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_cos = function (L) { - lua_pushnumber(L, Math.cos(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.cos(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_tan = function (L) { - lua_pushnumber(L, Math.tan(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.tan(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_asin = function (L) { - lua_pushnumber(L, Math.asin(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.asin(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_acos = function (L) { - lua_pushnumber(L, Math.acos(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.acos(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_atan = function (L) { - let y = luaL_checknumber(L, 1); - let x = luaL_optnumber(L, 2, 1); - lua_pushnumber(L, Math.atan2(y, x)); + let y = lauxlib.luaL_checknumber(L, 1); + let x = lauxlib.luaL_optnumber(L, 2, 1); + lua.lua_pushnumber(L, Math.atan2(y, x)); return 1; }; const math_toint = function (L) { - let n = lua_tointegerx(L, 1); + let n = lua.lua_tointegerx(L, 1); if (n !== false) - lua_pushinteger(L, n); + lua.lua_pushinteger(L, n); else { - luaL_checkany(L, 1); - lua_pushnil(L); /* value is not convertible to integer */ + lauxlib.luaL_checkany(L, 1); + lua.lua_pushnil(L); /* value is not convertible to integer */ } return 1; }; const pushnumint = function (L, d) { - let n = lua_numbertointeger(d); + let n = luaconf.lua_numbertointeger(d); if (n !== false) /* does 'd' fit in an integer? */ - lua_pushinteger(L, n); /* result is integer */ + lua.lua_pushinteger(L, n); /* result is integer */ else - lua_pushnumber(L, d); /* result is float */ + lua.lua_pushnumber(L, d); /* result is float */ }; const math_floor = function (L) { - if (lua_isinteger(L, 1)) - lua_settop(L, 1); + if (lua.lua_isinteger(L, 1)) + lua.lua_settop(L, 1); else - pushnumint(L, Math.floor(luaL_checknumber(L, 1))); + pushnumint(L, Math.floor(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_ceil = function (L) { - if (lua_isinteger(L, 1)) - lua_settop(L, 1); + if (lua.lua_isinteger(L, 1)) + lua.lua_settop(L, 1); else - pushnumint(L, Math.ceil(luaL_checknumber(L, 1))); + pushnumint(L, Math.ceil(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_sqrt = function (L) { - lua_pushnumber(L, Math.sqrt(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.sqrt(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_ult = function (L) { - let a = luaL_checkinteger(L, 1); - let b = luaL_checkinteger(L, 2); - lua_pushboolean(L, (a >= 0) ? (b < 0 || a < b) : (b < 0 && a < b)); + let a = lauxlib.luaL_checkinteger(L, 1); + let b = lauxlib.luaL_checkinteger(L, 2); + lua.lua_pushboolean(L, (a >= 0) ? (b < 0 || a < b) : (b < 0 && a < b)); return 1; }; const math_log = function (L) { - let x = luaL_checknumber(L, 1); + let x = lauxlib.luaL_checknumber(L, 1); let res; - if (lua_isnoneornil(L, 2)) + if (lua.lua_isnoneornil(L, 2)) res = Math.log(x); else { - let base = luaL_checknumber(L, 2); + let base = lauxlib.luaL_checknumber(L, 2); if (base === 2) res = Math.log2(x); else if (base === 10) @@ -158,87 +158,87 @@ const math_log = function (L) { else res = Math.log(x) / Math.log(base); } - lua_pushnumber(L, res); + lua.lua_pushnumber(L, res); return 1; }; const math_exp = function (L) { - lua_pushnumber(L, Math.exp(luaL_checknumber(L, 1))); + lua.lua_pushnumber(L, Math.exp(lauxlib.luaL_checknumber(L, 1))); return 1; }; const math_deg = function (L) { - lua_pushnumber(L, luaL_checknumber(L, 1) * (180 / Math.PI)); + lua.lua_pushnumber(L, lauxlib.luaL_checknumber(L, 1) * (180 / Math.PI)); return 1; }; const math_rad = function (L) { - lua_pushnumber(L, luaL_checknumber(L, 1) * (Math.PI / 180)); + lua.lua_pushnumber(L, lauxlib.luaL_checknumber(L, 1) * (Math.PI / 180)); return 1; }; const math_min = function (L) { - let n = lua_gettop(L); /* number of arguments */ + let n = lua.lua_gettop(L); /* number of arguments */ let imin = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, 'value expected'); + lauxlib.luaL_argcheck(L, n >= 1, 1, 'value expected'); for (let i = 2; i <= n; i++) { - if (lua_compare(L, i, imin, LUA_OPLT)) + if (lua.lua_compare(L, i, imin, lua.LUA_OPLT)) imin = i; } - lua_pushvalue(L, imin); + lua.lua_pushvalue(L, imin); return 1; }; const math_max = function (L) { - let n = lua_gettop(L); /* number of arguments */ + let n = lua.lua_gettop(L); /* number of arguments */ let imax = 1; /* index of current minimum value */ - luaL_argcheck(L, n >= 1, 1, 'value expected'); + lauxlib.luaL_argcheck(L, n >= 1, 1, 'value expected'); for (let i = 2; i <= n; i++) { - if (lua_compare(L, imax, i, LUA_OPLT)) + if (lua.lua_compare(L, imax, i, lua.LUA_OPLT)) imax = i; } - lua_pushvalue(L, imax); + lua.lua_pushvalue(L, imax); return 1; }; const math_type = function (L) { - if (lua_type(L, 1) === LUA_TNUMBER) { - if (lua_isinteger(L, 1)) - lua_pushliteral(L, 'integer'); + if (lua.lua_type(L, 1) === lua.LUA_TNUMBER) { + if (lua.lua_isinteger(L, 1)) + lua.lua_pushliteral(L, 'integer'); else - lua_pushliteral(L, 'float'); + lua.lua_pushliteral(L, 'float'); } else { - luaL_checkany(L, 1); - lua_pushnil(L); + lauxlib.luaL_checkany(L, 1); + lua.lua_pushnil(L); } return 1; }; const math_fmod = function (L) { - if (lua_isinteger(L, 1) && lua_isinteger(L, 2)) { - let d = lua_tointeger(L, 2); + if (lua.lua_isinteger(L, 1) && lua.lua_isinteger(L, 2)) { + let d = lua.lua_tointeger(L, 2); /* no special case needed for -1 in javascript */ if (d === 0) { - luaL_argerror(L, 2, 'zero'); + lauxlib.luaL_argerror(L, 2, 'zero'); } else - lua_pushinteger(L, (lua_tointeger(L, 1) % d) | 0); + lua.lua_pushinteger(L, (lua.lua_tointeger(L, 1) % d) | 0); } else { - let a = luaL_checknumber(L, 1); - let b = luaL_checknumber(L, 2); - lua_pushnumber(L, a % b); + let a = lauxlib.luaL_checknumber(L, 1); + let b = lauxlib.luaL_checknumber(L, 2); + lua.lua_pushnumber(L, a % b); } return 1; }; const math_modf = function (L) { - if (lua_isinteger(L, 1)) { - lua_settop(L, 1); /* number is its own integer part */ - lua_pushnumber(L, 0); /* no fractional part */ + if (lua.lua_isinteger(L, 1)) { + lua.lua_settop(L, 1); /* number is its own integer part */ + lua.lua_pushnumber(L, 0); /* no fractional part */ } else { - let n = luaL_checknumber(L, 1); + let n = lauxlib.luaL_checknumber(L, 1); let ip = n < 0 ? Math.ceil(n) : Math.floor(n); pushnumint(L, ip); - lua_pushnumber(L, n === ip ? 0 : n - ip); + lua.lua_pushnumber(L, n === ip ? 0 : n - ip); } return 2; }; @@ -269,18 +269,15 @@ const mathlib = { 'ult': math_ult }; -const luaopen_math = function (L) { - luaL_newlib(L, mathlib); - lua_pushnumber(L, Math.PI); - lua_setfield(L, -2, to_luastring('pi', true)); - lua_pushnumber(L, Infinity); - lua_setfield(L, -2, to_luastring('huge', true)); - lua_pushinteger(L, LUA_MAXINTEGER); - lua_setfield(L, -2, to_luastring('maxinteger', true)); - lua_pushinteger(L, LUA_MININTEGER); - lua_setfield(L, -2, to_luastring('mininteger', true)); +export const luaopen_math = function (L) { + lauxlib.luaL_newlib(L, mathlib); + lua.lua_pushnumber(L, Math.PI); + lua.lua_setfield(L, -2, fengaricore.to_luastring('pi', true)); + lua.lua_pushnumber(L, Infinity); + lua.lua_setfield(L, -2, fengaricore.to_luastring('huge', true)); + lua.lua_pushinteger(L, luaconf.LUA_MAXINTEGER); + lua.lua_setfield(L, -2, fengaricore.to_luastring('maxinteger', true)); + lua.lua_pushinteger(L, luaconf.LUA_MININTEGER); + lua.lua_setfield(L, -2, fengaricore.to_luastring('mininteger', true)); return 1; }; - -const _luaopen_math = luaopen_math; -export { _luaopen_math as luaopen_math }; diff --git a/src/loadlib.js b/src/loadlib.js index cd09ecdb..ad7c92da 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -1,11 +1,18 @@ -import { LUA_DIRSEP, LUA_EXEC_DIR, LUA_JSPATH_DEFAULT, LUA_PATH_DEFAULT, LUA_PATH_MARK, LUA_PATH_SEP } from './luaconf.js'; -import { LUA_OK, LUA_REGISTRYINDEX, LUA_TNIL, LUA_TTABLE, lua_callk, lua_createtable, lua_getfield, lua_insert, lua_isfunction, lua_isnil, lua_isstring, lua_newtable, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawgeti, lua_rawgetp, lua_rawseti, lua_rawsetp, lua_remove, lua_setfield, lua_setmetatable, lua_settop, lua_toboolean, lua_tostring, lua_touserdata, lua_upvalueindex } from './lua.js'; -import { LUA_LOADED_TABLE, LUA_PRELOAD_TABLE, luaL_Buffer, luaL_addvalue, luaL_buffinit, luaL_checkstring, luaL_error, luaL_getsubtable, luaL_gsub, luaL_len, luaL_loadfile, luaL_newlib, luaL_optstring, luaL_pushresult, luaL_setfuncs } from './lauxlib.js'; -import { LUA_VERSUFFIX } from './lualib.js'; -import { luastring_indexOf, to_jsstring, to_luastring, to_uristring } from './fengaricore.js'; +import * as luaconf from './luaconf.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as lualib from './lualib.js'; +import * as fengaricore from './fengaricore.js'; import * as fengari from './fengari.js'; -import pathlib from 'path'; -import fs from 'fs'; + +const pathlib = (typeof process !== 'undefined') ? require('path') : null; + +let fs = undefined; + +if (typeof process !== 'undefined') { + /* node */ + fs = require('fs'); +} const global_env = (function () { if (typeof process !== 'undefined') { @@ -23,7 +30,7 @@ const global_env = (function () { } })(); -const JSLIBS = to_luastring('__JSLIBS__'); +const JSLIBS = fengaricore.to_luastring('__JSLIBS__'); const LUA_PATH_VAR = 'LUA_PATH'; const LUA_JSPATH_VAR = 'LUA_JSPATH'; @@ -35,17 +42,17 @@ const LUA_IGMARK = '-'; ** LUA_LSUBSEP is the character that replaces dots in submodule names ** when searching for a Lua loader. */ -const LUA_CSUBSEP = LUA_DIRSEP; -const LUA_LSUBSEP = LUA_DIRSEP; +const LUA_CSUBSEP = luaconf.LUA_DIRSEP; +const LUA_LSUBSEP = luaconf.LUA_DIRSEP; /* prefix for open functions in JS libraries */ -const LUA_POF = to_luastring('luaopen_'); +const LUA_POF = fengaricore.to_luastring('luaopen_'); /* separator for open functions in JS libraries */ -const LUA_OFSEP = to_luastring('_'); +const LUA_OFSEP = fengaricore.to_luastring('_'); const LIB_FAIL = 'open'; -const AUXMARK = to_luastring('\x01'); +const AUXMARK = fengaricore.to_luastring('\x01'); /* @@ -56,14 +63,14 @@ const AUXMARK = to_luastring('\x01'); */ let lsys_load; if (typeof process === 'undefined') { - lsys_load = function (L, path, seeglb) { - path = to_uristring(path); + lsys_load = function (L, path, _seeglb) { + path = fengaricore.to_uristring(path); let xhr = new XMLHttpRequest(); xhr.open('GET', path, false); xhr.send(); if (xhr.status < 200 || xhr.status >= 300) { - lua_pushstring(L, to_luastring(`${xhr.status}: ${xhr.statusText}`)); + lua.lua_pushstring(L, fengaricore.to_luastring(`${xhr.status}: ${xhr.statusText}`)); return null; } @@ -75,7 +82,7 @@ if (typeof process === 'undefined') { try { func = Function('fengari', code); } catch (e) { - lua_pushstring(L, to_luastring(`${e.name}: ${e.message}`)); + lua.lua_pushstring(L, fengaricore.to_luastring(`${e.name}: ${e.message}`)); return null; } let res = func(fengari); @@ -84,19 +91,19 @@ if (typeof process === 'undefined') { } else if (res === void 0) { /* assume library added symbols to global environment */ return global_env; } else { - lua_pushstring(L, to_luastring(`library returned unexpected type (${typeof res})`)); + lua.lua_pushstring(L, fengaricore.to_luastring(`library returned unexpected type (${typeof res})`)); return null; } }; } else { - lsys_load = function (L, path, seeglb) { - path = to_jsstring(path); + lsys_load = function (L, path, _seeglb) { + path = fengaricore.to_jsstring(path); /* relative paths should be relative to cwd, not this js file */ path = pathlib.resolve(process.cwd(), path); try { return require(path); } catch (e) { - lua_pushstring(L, to_luastring(e.message)); + lua.lua_pushstring(L, fengaricore.to_luastring(e.message)); return null; } }; @@ -108,12 +115,12 @@ if (typeof process === 'undefined') { ** error string in the stack. */ const lsys_sym = function (L, lib, sym) { - let f = lib[to_jsstring(sym)]; + let f = lib[fengaricore.to_jsstring(sym)]; if (f && typeof f === 'function') return f; else { - lua_pushfstring(L, to_luastring('undefined symbol: %s'), sym); + lua.lua_pushfstring(L, fengaricore.to_luastring('undefined symbol: %s'), sym); return null; } }; @@ -122,9 +129,9 @@ const lsys_sym = function (L, lib, sym) { ** return registry.LUA_NOENV as a boolean */ const noenv = function (L) { - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('LUA_NOENV')); - let b = lua_toboolean(L, -1); - lua_pop(L, 1); /* remove value */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, fengaricore.to_luastring('LUA_NOENV')); + let b = lua.lua_toboolean(L, -1); + lua.lua_pop(L, 1); /* remove value */ return b; }; @@ -141,8 +148,8 @@ if (typeof process !== 'undefined') { // Only with Node }; } else { readable = function (path) { - path = to_uristring(path); - let xhr = new XMLHttpRequest(); + path = fengaricore.to_uristring(path); + let xhr = new XMLHttpRequest(); // use fetch? /* Following GET request done by searcher_Web will be cached */ xhr.open('GET', path, false); xhr.send(); @@ -175,28 +182,28 @@ const lookforfunc = function (L, path, sym) { addtojslib(L, path, reg); } if (sym[0] === '*'.charCodeAt(0)) { /* loading only library (no function)? */ - lua_pushboolean(L, 1); /* return 'true' */ + lua.lua_pushboolean(L, 1); /* return 'true' */ return 0; /* no errors */ } else { let f = lsys_sym(L, reg, sym); if (f === null) return ERRFUNC; /* unable to find function */ - lua_pushcfunction(L, f); /* else create new function */ + lua.lua_pushcfunction(L, f); /* else create new function */ return 0; /* no errors */ } }; const ll_loadlib = function (L) { - let path = luaL_checkstring(L, 1); - let init = luaL_checkstring(L, 2); + let path = lauxlib.luaL_checkstring(L, 1); + let init = lauxlib.luaL_checkstring(L, 2); let stat = lookforfunc(L, path, init); if (stat === 0) /* no errors? */ return 1; /* return the loaded function */ else { /* error; error message is on stack top */ - lua_pushnil(L); - lua_insert(L, -2); - lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : 'init'); + lua.lua_pushnil(L); + lua.lua_insert(L, -2); + lua.lua_pushliteral(L, (stat === ERRLIB) ? LIB_FAIL : 'init'); return 3; /* return nil, error message, and where */ } }; @@ -214,36 +221,36 @@ const env = (function () { ** Set a path */ const setpath = function (L, fieldname, envname, dft) { - let nver = `${envname}${LUA_VERSUFFIX}`; - lua_pushstring(L, to_luastring(nver)); + let nver = `${envname}${lualib.LUA_VERSUFFIX}`; + lua.lua_pushstring(L, fengaricore.to_luastring(nver)); let path = env[nver]; /* use versioned name */ if (path === undefined) /* no environment variable? */ path = env[envname]; /* try unversioned name */ if (path === undefined || noenv(L)) /* no environment variable? */ - lua_pushstring(L, dft); /* use default */ + lua.lua_pushstring(L, dft); /* use default */ else { /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ - path = luaL_gsub( + path = lauxlib.luaL_gsub( L, - to_luastring(path), - to_luastring(LUA_PATH_SEP + LUA_PATH_SEP, true), - to_luastring(LUA_PATH_SEP + to_jsstring(AUXMARK) + LUA_PATH_SEP, true) + fengaricore.to_luastring(path), + fengaricore.to_luastring(luaconf.LUA_PATH_SEP + luaconf.LUA_PATH_SEP, true), + fengaricore.to_luastring(luaconf.LUA_PATH_SEP + fengaricore.to_jsstring(AUXMARK) + luaconf.LUA_PATH_SEP, true) ); - luaL_gsub(L, path, AUXMARK, dft); - lua_remove(L, -2); /* remove result from 1st 'gsub' */ + lauxlib.luaL_gsub(L, path, AUXMARK, dft); + lua.lua_remove(L, -2); /* remove result from 1st 'gsub' */ } - lua_setfield(L, -3, fieldname); /* package[fieldname] = path value */ - lua_pop(L, 1); /* pop versioned variable name */ + lua.lua_setfield(L, -3, fieldname); /* package[fieldname] = path value */ + lua.lua_pop(L, 1); /* pop versioned variable name */ }; /* ** return registry.JSLIBS[path] */ const checkjslib = function (L, path) { - lua_rawgetp(L, LUA_REGISTRYINDEX, JSLIBS); - lua_getfield(L, -1, path); - let plib = lua_touserdata(L, -1); /* plib = JSLIBS[path] */ - lua_pop(L, 2); /* pop JSLIBS table and 'plib' */ + lua.lua_rawgetp(L, lua.LUA_REGISTRYINDEX, JSLIBS); + lua.lua_getfield(L, -1, path); + let plib = lua.lua_touserdata(L, -1); /* plib = JSLIBS[path] */ + lua.lua_pop(L, 2); /* pop JSLIBS table and 'plib' */ return plib; }; @@ -252,79 +259,79 @@ const checkjslib = function (L, path) { ** registry.JSLIBS[#JSLIBS + 1] = plib -- also keep a list of all libraries */ const addtojslib = function (L, path, plib) { - lua_rawgetp(L, LUA_REGISTRYINDEX, JSLIBS); - lua_pushlightuserdata(L, plib); - lua_pushvalue(L, -1); - lua_setfield(L, -3, path); /* JSLIBS[path] = plib */ - lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* JSLIBS[#JSLIBS + 1] = plib */ - lua_pop(L, 1); /* pop JSLIBS table */ + lua.lua_rawgetp(L, lua.LUA_REGISTRYINDEX, JSLIBS); + lua.lua_pushlightuserdata(L, plib); + lua.lua_pushvalue(L, -1); + lua.lua_setfield(L, -3, path); /* JSLIBS[path] = plib */ + lua.lua_rawseti(L, -2, lauxlib.luaL_len(L, -2) + 1); /* JSLIBS[#JSLIBS + 1] = plib */ + lua.lua_pop(L, 1); /* pop JSLIBS table */ }; const pushnexttemplate = function (L, path) { - while (path[0] === LUA_PATH_SEP.charCodeAt(0)) path = path.subarray(1); /* skip separators */ + while (path[0] === luaconf.LUA_PATH_SEP.charCodeAt(0)) path = path.subarray(1); /* skip separators */ if (path.length === 0) return null; /* no more templates */ - let l = luastring_indexOf(path, LUA_PATH_SEP.charCodeAt(0)); /* find next separator */ + let l = fengaricore.luastring_indexOf(path, luaconf.LUA_PATH_SEP.charCodeAt(0)); /* find next separator */ if (l < 0) l = path.length; - lua_pushlstring(L, path, l); /* template */ + lua.lua_pushlstring(L, path, l); /* template */ return path.subarray(l); }; const searchpath = function (L, name, path, sep, dirsep) { - let msg = new luaL_Buffer(); /* to build error message */ - luaL_buffinit(L, msg); + let msg = new lauxlib.luaL_Buffer(); /* to build error message */ + lauxlib.luaL_buffinit(L, msg); if (sep[0] !== 0) /* non-empty separator? */ - name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ + name = lauxlib.luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ while ((path = pushnexttemplate(L, path)) !== null) { - let filename = luaL_gsub(L, lua_tostring(L, -1), to_luastring(LUA_PATH_MARK, true), name); - lua_remove(L, -2); /* remove path template */ + let filename = lauxlib.luaL_gsub(L, lua.lua_tostring(L, -1), fengaricore.to_luastring(luaconf.LUA_PATH_MARK, true), name); + lua.lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pushfstring(L, to_luastring('\n\tno file \'%s\''), filename); - lua_remove(L, -2); /* remove file name */ - luaL_addvalue(msg); + lua.lua_pushfstring(L, fengaricore.to_luastring('\n\tno file \'%s\''), filename); + lua.lua_remove(L, -2); /* remove file name */ + lauxlib.luaL_addvalue(msg); } - luaL_pushresult(msg); /* create error message */ + lauxlib.luaL_pushresult(msg); /* create error message */ return null; /* not found */ }; const ll_searchpath = function (L) { let f = searchpath( L, - luaL_checkstring(L, 1), - luaL_checkstring(L, 2), - luaL_optstring(L, 3, '.'), - luaL_optstring(L, 4, LUA_DIRSEP) + lauxlib.luaL_checkstring(L, 1), + lauxlib.luaL_checkstring(L, 2), + lauxlib.luaL_optstring(L, 3, '.'), + lauxlib.luaL_optstring(L, 4, luaconf.LUA_DIRSEP) ); if (f !== null) return 1; else { /* error message is on top of the stack */ - lua_pushnil(L); - lua_insert(L, -2); + lua.lua_pushnil(L); + lua.lua_insert(L, -2); return 2; /* return nil + error message */ } }; const findfile = function (L, name, pname, dirsep) { - lua_getfield(L, lua_upvalueindex(1), pname); - let path = lua_tostring(L, -1); + lua.lua_getfield(L, lua.lua_upvalueindex(1), pname); + let path = lua.lua_tostring(L, -1); if (path === null) - luaL_error(L, to_luastring('\'package.%s\' must be a string'), pname); - return searchpath(L, name, path, to_luastring('.'), dirsep); + lauxlib.luaL_error(L, fengaricore.to_luastring('\'package.%s\' must be a string'), pname); + return searchpath(L, name, path, fengaricore.to_luastring('.'), dirsep); }; const checkload = function (L, stat, filename) { if (stat) { /* module loaded successfully? */ - lua_pushstring(L, filename); /* will be 2nd argument to module */ + lua.lua_pushstring(L, filename); /* will be 2nd argument to module */ return 2; /* return open function and file name */ } else - return luaL_error(L, to_luastring('error loading module \'%s\' from file \'%s\':\n\t%s'), - lua_tostring(L, 1), filename, lua_tostring(L, -1)); + return lauxlib.luaL_error(L, fengaricore.to_luastring('error loading module \'%s\' from file \'%s\':\n\t%s'), + lua.lua_tostring(L, 1), filename, lua.lua_tostring(L, -1)); }; const searcher_Lua = function (L) { - let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring('path', true), to_luastring(LUA_LSUBSEP, true)); + let name = lauxlib.luaL_checkstring(L, 1); + let filename = findfile(L, name, fengaricore.to_luastring('path', true), fengaricore.to_luastring(LUA_LSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ - return checkload(L, luaL_loadfile(L, filename) === LUA_OK, filename); + return checkload(L, lauxlib.luaL_loadfile(L, filename) === lua.LUA_OK, filename); }; /* @@ -337,119 +344,119 @@ const searcher_Lua = function (L) { */ const loadfunc = function (L, filename, modname) { let openfunc; - modname = luaL_gsub(L, modname, to_luastring('.'), LUA_OFSEP); - let mark = luastring_indexOf(modname, LUA_IGMARK.charCodeAt(0)); + modname = lauxlib.luaL_gsub(L, modname, fengaricore.to_luastring('.'), LUA_OFSEP); + let mark = fengaricore.luastring_indexOf(modname, LUA_IGMARK.charCodeAt(0)); if (mark >= 0) { - openfunc = lua_pushlstring(L, modname, mark); - openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, openfunc); + openfunc = lua.lua_pushlstring(L, modname, mark); + openfunc = lua.lua_pushfstring(L, fengaricore.to_luastring('%s%s'), LUA_POF, openfunc); let stat = lookforfunc(L, filename, openfunc); if (stat !== ERRFUNC) return stat; modname = mark + 1; /* else go ahead and try old-style name */ } - openfunc = lua_pushfstring(L, to_luastring('%s%s'), LUA_POF, modname); + openfunc = lua.lua_pushfstring(L, fengaricore.to_luastring('%s%s'), LUA_POF, modname); return lookforfunc(L, filename, openfunc); }; const searcher_C = function (L) { - let name = luaL_checkstring(L, 1); - let filename = findfile(L, name, to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); + let name = lauxlib.luaL_checkstring(L, 1); + let filename = findfile(L, name, fengaricore.to_luastring('jspath', true), fengaricore.to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* module not found in this path */ return checkload(L, (loadfunc(L, filename, name) === 0), filename); }; const searcher_Croot = function (L) { - let name = luaL_checkstring(L, 1); - let p = luastring_indexOf(name, '.'.charCodeAt(0)); + let name = lauxlib.luaL_checkstring(L, 1); + let p = fengaricore.luastring_indexOf(name, '.'.charCodeAt(0)); let stat; if (p < 0) return 0; /* is root */ - lua_pushlstring(L, name, p); - let filename = findfile(L, lua_tostring(L, -1), to_luastring('jspath', true), to_luastring(LUA_CSUBSEP, true)); + lua.lua_pushlstring(L, name, p); + let filename = findfile(L, lua.lua_tostring(L, -1), fengaricore.to_luastring('jspath', true), fengaricore.to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* root not found */ if ((stat = loadfunc(L, filename, name)) !== 0) { if (stat != ERRFUNC) return checkload(L, 0, filename); /* real error */ else { /* open function not found */ - lua_pushfstring(L, to_luastring('\n\tno module \'%s\' in file \'%s\''), name, filename); + lua.lua_pushfstring(L, fengaricore.to_luastring('\n\tno module \'%s\' in file \'%s\''), name, filename); return 1; } } - lua_pushstring(L, filename); /* will be 2nd argument to module */ + lua.lua_pushstring(L, filename); /* will be 2nd argument to module */ return 2; }; const searcher_preload = function (L) { - let name = luaL_checkstring(L, 1); - lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - if (lua_getfield(L, -1, name) === LUA_TNIL) /* not found? */ - lua_pushfstring(L, to_luastring('\n\tno field package.preload[\'%s\']'), name); + let name = lauxlib.luaL_checkstring(L, 1); + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE); + if (lua.lua_getfield(L, -1, name) === lua.LUA_TNIL) /* not found? */ + lua.lua_pushfstring(L, fengaricore.to_luastring('\n\tno field package.preload[\'%s\']'), name); return 1; }; const findloader = function (L, name, ctx, k) { - let msg = new luaL_Buffer(); /* to build error message */ - luaL_buffinit(L, msg); + let msg = new lauxlib.luaL_Buffer(); /* to build error message */ + lauxlib.luaL_buffinit(L, msg); /* push 'package.searchers' to index 3 in the stack */ - if (lua_getfield(L, lua_upvalueindex(1), to_luastring('searchers', true)) !== LUA_TTABLE) - luaL_error(L, to_luastring('\'package.searchers\' must be a table')); + if (lua.lua_getfield(L, lua.lua_upvalueindex(1), fengaricore.to_luastring('searchers', true)) !== lua.LUA_TTABLE) + lauxlib.luaL_error(L, fengaricore.to_luastring('\'package.searchers\' must be a table')); let ctx2 = { name: name, i: 1, msg: msg, ctx: ctx, k: k }; - return findloader_cont(L, LUA_OK, ctx2); + return findloader_cont(L, lua.LUA_OK, ctx2); }; const findloader_cont = function (L, status, ctx) { /* iterate over available searchers to find a loader */ for (; ; ctx.i++) { - if (status === LUA_OK) { - if (lua_rawgeti(L, 3, ctx.i) === LUA_TNIL) { /* no more searchers? */ - lua_pop(L, 1); /* remove nil */ - luaL_pushresult(ctx.msg); /* create error message */ - luaL_error(L, to_luastring('module \'%s\' not found:%s'), ctx.name, lua_tostring(L, -1)); + if (status === lua.LUA_OK) { + if (lua.lua_rawgeti(L, 3, ctx.i) === lua.LUA_TNIL) { /* no more searchers? */ + lua.lua_pop(L, 1); /* remove nil */ + lauxlib.luaL_pushresult(ctx.msg); /* create error message */ + lauxlib.luaL_error(L, fengaricore.to_luastring('module \'%s\' not found:%s'), ctx.name, lua.lua_tostring(L, -1)); } - lua_pushstring(L, ctx.name); - lua_callk(L, 1, 2, ctx, findloader_cont); /* call it */ + lua.lua_pushstring(L, ctx.name); + lua.lua_callk(L, 1, 2, ctx, findloader_cont); /* call it */ } else { - status = LUA_OK; + status = lua.LUA_OK; } - if (lua_isfunction(L, -2)) /* did it find a loader? */ + if (lua.lua_isfunction(L, -2)) /* did it find a loader? */ break; /* module loader found */ - else if (lua_isstring(L, -2)) { /* searcher returned error message? */ - lua_pop(L, 1); /* remove extra return */ - luaL_addvalue(ctx.msg); /* concatenate error message */ + else if (lua.lua_isstring(L, -2)) { /* searcher returned error message? */ + lua.lua_pop(L, 1); /* remove extra return */ + lauxlib.luaL_addvalue(ctx.msg); /* concatenate error message */ } else - lua_pop(L, 2); /* remove both returns */ + lua.lua_pop(L, 2); /* remove both returns */ } - return ctx.k(L, LUA_OK, ctx.ctx); + return ctx.k(L, lua.LUA_OK, ctx.ctx); }; const ll_require = function (L) { - let name = luaL_checkstring(L, 1); - lua_settop(L, 1); /* LOADED table will be at index 2 */ - lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - lua_getfield(L, 2, name); /* LOADED[name] */ - if (lua_toboolean(L, -1)) /* is it there? */ + let name = lauxlib.luaL_checkstring(L, 1); + lua.lua_settop(L, 1); /* LOADED table will be at index 2 */ + lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_LOADED_TABLE); + lua.lua_getfield(L, 2, name); /* LOADED[name] */ + if (lua.lua_toboolean(L, -1)) /* is it there? */ return 1; /* package is already loaded */ /* else must load package */ - lua_pop(L, 1); /* remove 'getfield' result */ + lua.lua_pop(L, 1); /* remove 'getfield' result */ let ctx = name; return findloader(L, name, ctx, ll_require_cont); }; const ll_require_cont = function (L, status, ctx) { let name = ctx; - lua_pushstring(L, name); /* pass name as argument to module loader */ - lua_insert(L, -2); /* name is 1st argument (before search data) */ - lua_callk(L, 2, 1, ctx, ll_require_cont2); - return ll_require_cont2(L, LUA_OK, ctx); /* run loader to load module */ + lua.lua_pushstring(L, name); /* pass name as argument to module loader */ + lua.lua_insert(L, -2); /* name is 1st argument (before search data) */ + lua.lua_callk(L, 2, 1, ctx, ll_require_cont2); + return ll_require_cont2(L, lua.LUA_OK, ctx); /* run loader to load module */ }; const ll_require_cont2 = function (L, status, ctx) { let name = ctx; - if (!lua_isnil(L, -1)) /* non-nil return? */ - lua_setfield(L, 2, name); /* LOADED[name] = returned value */ - if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */ - lua_pushboolean(L, 1); /* use true as result */ - lua_pushvalue(L, -1); /* extra copy to be returned */ - lua_setfield(L, 2, name); /* LOADED[name] = true */ + if (!lua.lua_isnil(L, -1)) /* non-nil return? */ + lua.lua_setfield(L, 2, name); /* LOADED[name] = returned value */ + if (lua.lua_getfield(L, 2, name) == lua.LUA_TNIL) { /* module set no value? */ + lua.lua_pushboolean(L, 1); /* use true as result */ + lua.lua_pushvalue(L, -1); /* extra copy to be returned */ + lua.lua_setfield(L, 2, name); /* LOADED[name] = true */ } return 1; }; @@ -466,14 +473,14 @@ const ll_funcs = { const createsearcherstable = function (L) { let searchers = [searcher_preload, searcher_Lua, searcher_C, searcher_Croot, null]; /* create 'searchers' table */ - lua_createtable(L); + lua.lua_createtable(L); /* fill it with predefined searchers */ for (let i = 0; searchers[i]; i++) { - lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ - lua_pushcclosure(L, searchers[i], 1); - lua_rawseti(L, -2, i + 1); + lua.lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ + lua.lua_pushcclosure(L, searchers[i], 1); + lua.lua_rawseti(L, -2, i + 1); } - lua_setfield(L, -2, to_luastring('searchers', true)); /* put it in field 'searchers' */ + lua.lua_setfield(L, -2, fengaricore.to_luastring('searchers', true)); /* put it in field 'searchers' */ }; /* @@ -481,35 +488,32 @@ const createsearcherstable = function (L) { ** setting a finalizer to close all libraries when closing state. */ const createjslibstable = function (L) { - lua_newtable(L); /* create JSLIBS table */ - lua_createtable(L, 0, 1); /* create metatable for JSLIBS */ - lua_setmetatable(L, -2); - lua_rawsetp(L, LUA_REGISTRYINDEX, JSLIBS); /* set JSLIBS table in registry */ + lua.lua_newtable(L); /* create JSLIBS table */ + lua.lua_createtable(L, 0, 1); /* create metatable for JSLIBS */ + lua.lua_setmetatable(L, -2); + lua.lua_rawsetp(L, lua.LUA_REGISTRYINDEX, JSLIBS); /* set JSLIBS table in registry */ }; -const luaopen_package = function (L) { +export const luaopen_package = function (L) { createjslibstable(L); - luaL_newlib(L, pk_funcs); /* create 'package' table */ + lauxlib.luaL_newlib(L, pk_funcs); /* create 'package' table */ createsearcherstable(L); /* set paths */ - setpath(L, to_luastring('path', true), LUA_PATH_VAR, LUA_PATH_DEFAULT); - setpath(L, to_luastring('jspath', true), LUA_JSPATH_VAR, LUA_JSPATH_DEFAULT); + setpath(L, fengaricore.to_luastring('path', true), LUA_PATH_VAR, luaconf.LUA_PATH_DEFAULT); + setpath(L, fengaricore.to_luastring('jspath', true), LUA_JSPATH_VAR, luaconf.LUA_JSPATH_DEFAULT); /* store config information */ - lua_pushliteral(L, LUA_DIRSEP + '\n' + LUA_PATH_SEP + '\n' + LUA_PATH_MARK + '\n' + - LUA_EXEC_DIR + '\n' + LUA_IGMARK + '\n'); - lua_setfield(L, -2, to_luastring('config', true)); + lua.lua_pushliteral(L, luaconf.LUA_DIRSEP + '\n' + luaconf.LUA_PATH_SEP + '\n' + luaconf.LUA_PATH_MARK + '\n' + + luaconf.LUA_EXEC_DIR + '\n' + LUA_IGMARK + '\n'); + lua.lua_setfield(L, -2, fengaricore.to_luastring('config', true)); /* set field 'loaded' */ - luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - lua_setfield(L, -2, to_luastring('loaded', true)); + lauxlib.luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_LOADED_TABLE); + lua.lua_setfield(L, -2, fengaricore.to_luastring('loaded', true)); /* set field 'preload' */ - luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - lua_setfield(L, -2, to_luastring('preload', true)); - lua_pushglobaltable(L); - lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ - luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ - lua_pop(L, 1); /* pop global table */ + lauxlib.luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE); + lua.lua_setfield(L, -2, fengaricore.to_luastring('preload', true)); + lua.lua_pushglobaltable(L); + lua.lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ + lauxlib.luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ + lua.lua_pop(L, 1); /* pop global table */ return 1; /* return 'package' table */ }; - -const _luaopen_package = luaopen_package; -export { _luaopen_package as luaopen_package }; diff --git a/src/lobject.js b/src/lobject.js index abe34f9f..933daa33 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -1,16 +1,16 @@ -import { LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPIDIV, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, constant_types, from_userstring, luastring_indexOf, luastring_of, to_jsstring, to_luastring } from './defs.js'; -import { lisdigit, lisprint, lisspace, lisxdigit } from './ljstype.js'; -import { luaG_runerror } from './ldebug.js'; -import { luaD_inctop, luaD_checkstack } from './ldo.js'; -import { lua_State } from './lstate.js'; -import { luaS_bless, luaS_new } from './lstring.js'; -import { Table } from './ltable.js'; -import { LUA_COMPAT_FLOATSTRING, ldexp, lua_integer2str, lua_number2str } from './luaconf.js'; -import { luaV_concat, luaV_imul, luaV_mod, luaV_div, luaV_shiftl, tointeger, tonumber } from './lvm.js'; -import { MAX_INT, luai_nummod, lua_assert } from './llimits.js'; -import { luaT_trybinTM, TMS } from './ltm.js'; - -const { +import * as defs from './defs.js'; +import * as ljstype from './ljstype.js'; +import * as ldebug from './ldebug.js'; +import * as ldo from './ldo.js'; +import * as lstate from './lstate.js'; +import * as lstring from './lstring.js'; +import * as ltable from './ltable.js'; +import * as luaconf from './luaconf.js'; +import * as lvm from './lvm.js'; +import * as llimits from './llimits.js'; +import * as ltm from './ltm.js'; + +export const { LUA_NUMTAGS, LUA_TBOOLEAN, LUA_TCCL, @@ -28,12 +28,12 @@ const { LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA -} = constant_types; +} = defs.constant_types; -const LUA_TPROTO = LUA_NUMTAGS; -const LUA_TDEADKEY = LUA_NUMTAGS + 1; +export const LUA_TPROTO = LUA_NUMTAGS; +export const LUA_TDEADKEY = LUA_NUMTAGS + 1; -class TValue { +export class TValue { constructor(type, value) { this.type = type; @@ -140,7 +140,7 @@ class TValue { } chgfltvalue(x) { - lua_assert(this.type == LUA_TNUMFLT); + llimits.lua_assert(this.type == LUA_TNUMFLT); this.value = x; } @@ -150,7 +150,7 @@ class TValue { } chgivalue(x) { - lua_assert(this.type == LUA_TNUMINT); + llimits.lua_assert(this.type == LUA_TNUMINT); this.value = x; } @@ -215,7 +215,7 @@ class TValue { } tsvalue() { - lua_assert(this.ttisstring()); + llimits.lua_assert(this.ttisstring()); return this.value; } @@ -228,34 +228,34 @@ class TValue { } jsstring(from, to) { - return to_jsstring(this.svalue(), from, to, true); + return defs.to_jsstring(this.svalue(), from, to, true); } } -const pushobj2s = function (L, tv) { +export const pushobj2s = function (L, tv) { L.stack[L.top++] = new TValue(tv.type, tv.value); }; -const pushsvalue2s = function (L, ts) { +export const pushsvalue2s = function (L, ts) { L.stack[L.top++] = new TValue(LUA_TLNGSTR, ts); }; /* from stack to (same) stack */ -const setobjs2s = function (L, newidx, oldidx) { +export const setobjs2s = function (L, newidx, oldidx) { L.stack[newidx].setfrom(L.stack[oldidx]); }; /* to stack (not from same stack) */ -const setobj2s = function (L, newidx, oldtv) { +export const setobj2s = function (L, newidx, oldtv) { L.stack[newidx].setfrom(oldtv); }; -const setsvalue2s = function (L, newidx, ts) { +export const setsvalue2s = function (L, newidx, ts) { L.stack[newidx].setsvalue(ts); }; const luaO_nilobject = new TValue(LUA_TNIL, null); Object.freeze(luaO_nilobject); -const _luaO_nilobject = luaO_nilobject; -export { _luaO_nilobject as luaO_nilobject }; -class LClosure { +export { luaO_nilobject }; + +export class LClosure { constructor(L, n) { this.id = L.l_G.id_counter++; @@ -267,7 +267,7 @@ class LClosure { } -class CClosure { +export class CClosure { constructor(L, f, n) { this.id = L.l_G.id_counter++; @@ -282,7 +282,7 @@ class CClosure { } -class Udata { +export class Udata { constructor(L, size) { this.id = L.l_G.id_counter++; @@ -299,7 +299,7 @@ class Udata { ** Description of a local variable for function prototypes ** (used for debug information) */ -class LocVar { +export class LocVar { constructor() { this.varname = null; this.startpc = NaN; /* first point where variable is active */ @@ -307,11 +307,11 @@ class LocVar { } } -const RETS = to_luastring('...'); -const PRE = to_luastring('[string "'); -const POS = to_luastring('"]'); +export const RETS = defs.to_luastring('...'); +export const PRE = defs.to_luastring('[string "'); +export const POS = defs.to_luastring('"]'); -const luaO_chunkid = function (source, bufflen) { +export const luaO_chunkid = function (source, bufflen) { let l = source.length; let out; if (source[0] === 61 /* ('=').charCodeAt(0) */) { /* 'literal' source */ @@ -334,7 +334,7 @@ const luaO_chunkid = function (source, bufflen) { } } else { /* string; format as [string "source"] */ out = new Uint8Array(bufflen); - let nli = luastring_indexOf(source, 10 /* ('\n').charCodeAt(0) */); /* find first new line (if any) */ + let nli = defs.luastring_indexOf(source, 10 /* ('\n').charCodeAt(0) */); /* find first new line (if any) */ out.set(PRE); /* add prefix */ let out_i = PRE.length; bufflen -= PRE.length + RETS.length + POS.length; /* save space for prefix+suffix */ @@ -356,16 +356,16 @@ const luaO_chunkid = function (source, bufflen) { return out; }; -const luaO_hexavalue = function (c) { - if (lisdigit(c)) return c - 48; +export const luaO_hexavalue = function (c) { + if (ljstype.lisdigit(c)) return c - 48; else return (c & 0xdf) - 55; }; -const UTF8BUFFSZ = 8; +export const UTF8BUFFSZ = 8; -const luaO_utf8esc = function (buff, x) { +export const luaO_utf8esc = function (buff, x) { let n = 1; /* number of bytes put in buffer (backwards) */ - lua_assert(x <= 0x10FFFF); + llimits.lua_assert(x <= 0x10FFFF); if (x < 0x80) /* ascii? */ buff[UTF8BUFFSZ - 1] = x; else { /* need continuation bytes */ @@ -382,13 +382,13 @@ const luaO_utf8esc = function (buff, x) { /* maximum number of significant digits to read (to avoid overflows even with single floats) */ -const MAXSIGDIG = 30; +export const MAXSIGDIG = 30; /* ** convert an hexadecimal numeric string to a number, following ** C99 specification for 'strtod' */ -const lua_strx2number = function (s) { +export const lua_strx2number = function (s) { let i = 0; let r = 0.0; /* result (accumulator) */ let sigdig = 0; /* number of significant digits */ @@ -396,7 +396,7 @@ const lua_strx2number = function (s) { let e = 0; /* exponent correction */ let neg; /* 1 if number is negative */ let hasdot = false; /* true after seen a dot */ - while (lisspace(s[i])) i++; /* skip initial spaces */ + while (ljstype.lisspace(s[i])) i++; /* skip initial spaces */ if ((neg = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++; /* check signal */ else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++; if (!(s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i + 1] === 120 /* ('x').charCodeAt(0) */ || s[i + 1] === 88 /* ('X').charCodeAt(0) */))) /* check '0x' */ @@ -405,7 +405,7 @@ const lua_strx2number = function (s) { if (s[i] === 46 /* ('.').charCodeAt(0) i.e. dot/lua_getlocaledecpoint(); */) { if (hasdot) break; /* second dot? stop loop */ else hasdot = true; - } else if (lisxdigit(s[i])) { + } else if (ljstype.lisxdigit(s[i])) { if (sigdig === 0 && s[i] === 48 /* ('0').charCodeAt(0) */) /* non-significant digit (zero)? */ nosigdig++; else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ @@ -424,23 +424,23 @@ const lua_strx2number = function (s) { i++; /* skip 'p' */ if ((neg1 = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++; /* signal */ else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++; - if (!lisdigit(s[i])) + if (!ljstype.lisdigit(s[i])) return null; /* invalid; must have at least one digit */ - while (lisdigit(s[i])) /* read exponent */ + while (ljstype.lisdigit(s[i])) /* read exponent */ exp1 = exp1 * 10 + s[i++] - 48 /* ('0').charCodeAt(0) */; if (neg1) exp1 = -exp1; e += exp1; } if (neg) r = -r; return { - n: ldexp(r, e), + n: luaconf.ldexp(r, e), i: i }; }; -const lua_str2number = function (s) { +export const lua_str2number = function (s) { try { - s = to_jsstring(s); + s = defs.to_jsstring(s); } catch (e) { return null; } @@ -453,28 +453,28 @@ const lua_str2number = function (s) { return !isNaN(flt) ? { n: flt, i: r[0].length } : null; }; -const l_str2dloc = function (s, mode) { +export const l_str2dloc = function (s, mode) { let result = mode === 'x' ? lua_strx2number(s) : lua_str2number(s); /* try to convert */ if (result === null) return null; - while (lisspace(s[result.i])) result.i++; /* skip trailing spaces */ + while (ljstype.lisspace(s[result.i])) result.i++; /* skip trailing spaces */ return (result.i === s.length || s[result.i] === 0) ? result : null; /* OK if no trailing characters */ }; -const SIGILS = [ +export const SIGILS = [ 46 /* (".").charCodeAt(0) */, 120 /* ("x").charCodeAt(0) */, 88 /* ("X").charCodeAt(0) */, 110 /* ("n").charCodeAt(0) */, 78 /* ("N").charCodeAt(0) */ ]; -const modes = { +export const modes = { [46]: '.', [120]: 'x', [88]: 'x', [110]: 'n', [78]: 'n' }; -const l_str2d = function (s) { +export const l_str2d = function (s) { let l = s.length; let pmode = 0; for (let i = 0; i < l; i++) { @@ -494,26 +494,26 @@ const l_str2d = function (s) { return end; }; -const MAXBY10 = Math.floor(MAX_INT / 10); -const MAXLASTD = MAX_INT % 10; +export const MAXBY10 = Math.floor(llimits.MAX_INT / 10); +export const MAXLASTD = llimits.MAX_INT % 10; -const l_str2int = function (s) { +export const l_str2int = function (s) { let i = 0; let a = 0; let empty = true; let neg; - while (lisspace(s[i])) i++; /* skip initial spaces */ + while (ljstype.lisspace(s[i])) i++; /* skip initial spaces */ if ((neg = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++; else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++; if (s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i + 1] === 120 /* ('x').charCodeAt(0) */ || s[i + 1] === 88 /* ('X').charCodeAt(0) */)) { /* hex? */ i += 2; /* skip '0x' */ - for (; i < s.length && lisxdigit(s[i]); i++) { + for (; i < s.length && ljstype.lisxdigit(s[i]); i++) { a = (a * 16 + luaO_hexavalue(s[i])) | 0; empty = false; } } else { /* decimal */ - for (; i < s.length && lisdigit(s[i]); i++) { + for (; i < s.length && ljstype.lisdigit(s[i]); i++) { let d = s[i] - 48 /* ('0').charCodeAt(0) */; if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */ return null; /* do not accept it (as integer) */ @@ -521,7 +521,7 @@ const l_str2int = function (s) { empty = false; } } - while (i < s.length && lisspace(s[i])) i++; /* skip trailing spaces */ + while (i < s.length && ljstype.lisspace(s[i])) i++; /* skip trailing spaces */ if (empty || (i !== s.length && s[i] !== 0)) return null; /* something wrong in the numeral */ else { return { @@ -531,7 +531,7 @@ const l_str2int = function (s) { } }; -const luaO_str2num = function (s, o) { +export const luaO_str2num = function (s, o) { let s2i = l_str2int(s); if (s2i !== null) { /* try as an integer */ o.setivalue(s2i.n); @@ -546,42 +546,42 @@ const luaO_str2num = function (s, o) { } }; -const luaO_tostring = function (L, obj) { +export const luaO_tostring = function (L, obj) { let buff; if (obj.ttisinteger()) - buff = to_luastring(lua_integer2str(obj.value)); + buff = defs.to_luastring(luaconf.lua_integer2str(obj.value)); else { - let str = lua_number2str(obj.value); - if (!LUA_COMPAT_FLOATSTRING && /^[-0123456789]+$/.test(str)) { /* looks like an int? */ + let str = luaconf.lua_number2str(obj.value); + if (!luaconf.LUA_COMPAT_FLOATSTRING && /^[-0123456789]+$/.test(str)) { /* looks like an int? */ str += '.0'; /* adds '.0' to result: lua_getlocaledecpoint removed as optimisation */ } - buff = to_luastring(str); + buff = defs.to_luastring(str); } - obj.setsvalue(luaS_bless(L, buff)); + obj.setsvalue(lstring.luaS_bless(L, buff)); }; -const pushstr = function (L, str) { - luaD_inctop(L); - setsvalue2s(L, L.top - 1, luaS_new(L, str)); +export const pushstr = function (L, str) { + ldo.luaD_inctop(L); + setsvalue2s(L, L.top - 1, lstring.luaS_new(L, str)); }; -const luaO_pushvfstring = function (L, fmt, argp) { +export const luaO_pushvfstring = function (L, fmt, argp) { let n = 0; let i = 0; let a = 0; let e; for (; ;) { - e = luastring_indexOf(fmt, 37 /* ('%').charCodeAt(0) */, i); + e = defs.luastring_indexOf(fmt, 37 /* ('%').charCodeAt(0) */, i); if (e == -1) break; pushstr(L, fmt.subarray(i, e)); switch (fmt[e + 1]) { case 115 /* ('s').charCodeAt(0) */: { let s = argp[a++]; - if (s === null) s = to_luastring('(null)', true); + if (s === null) s = defs.to_luastring('(null)', true); else { - s = from_userstring(s); + s = defs.from_userstring(s); /* respect null terminator */ - let i = luastring_indexOf(s, 0); + let i = defs.luastring_indexOf(s, 0); if (i !== -1) s = s.subarray(0, i); } @@ -590,48 +590,48 @@ const luaO_pushvfstring = function (L, fmt, argp) { } case 99 /* ('c').charCodeAt(0) */: { let buff = argp[a++]; - if (lisprint(buff)) - pushstr(L, luastring_of(buff)); + if (ljstype.lisprint(buff)) + pushstr(L, defs.luastring_of(buff)); else - luaO_pushfstring(L, to_luastring('<\\%d>', true), buff); + luaO_pushfstring(L, defs.to_luastring('<\\%d>', true), buff); break; } case 100 /* ('d').charCodeAt(0) */: case 73 /* ('I').charCodeAt(0) */: - luaD_inctop(L); + ldo.luaD_inctop(L); L.stack[L.top - 1].setivalue(argp[a++]); luaO_tostring(L, L.stack[L.top - 1]); break; case 102 /* ('f').charCodeAt(0) */: - luaD_inctop(L); + ldo.luaD_inctop(L); L.stack[L.top - 1].setfltvalue(argp[a++]); luaO_tostring(L, L.stack[L.top - 1]); break; case 112 /* ('p').charCodeAt(0) */: { let v = argp[a++]; - if (v instanceof lua_State || - v instanceof Table || + if (v instanceof lstate.lua_State || + v instanceof ltable.Table || v instanceof Udata || v instanceof LClosure || v instanceof CClosure) { - pushstr(L, to_luastring('0x' + v.id.toString(16))); + pushstr(L, defs.to_luastring('0x' + v.id.toString(16))); } else { switch (typeof v) { case 'undefined': - pushstr(L, to_luastring('undefined')); + pushstr(L, defs.to_luastring('undefined')); break; case 'number': /* before check object as null is an object */ - pushstr(L, to_luastring('Number(' + v + ')')); + pushstr(L, defs.to_luastring('Number(' + v + ')')); break; case 'string': /* before check object as null is an object */ - pushstr(L, to_luastring('String(' + JSON.stringify(v) + ')')); + pushstr(L, defs.to_luastring('String(' + JSON.stringify(v) + ')')); break; case 'boolean': /* before check object as null is an object */ - pushstr(L, to_luastring(v ? 'Boolean(true)' : 'Boolean(false)')); + pushstr(L, defs.to_luastring(v ? 'Boolean(true)' : 'Boolean(false)')); break; case 'object': if (v === null) { /* null is special */ - pushstr(L, to_luastring('null')); + pushstr(L, defs.to_luastring('null')); break; } /* fall through */ @@ -641,12 +641,12 @@ const luaO_pushvfstring = function (L, fmt, argp) { id = L.l_G.id_counter++; L.l_G.ids.set(v, id); } - pushstr(L, to_luastring('0x' + id.toString(16))); + pushstr(L, defs.to_luastring('0x' + id.toString(16))); break; } default: /* user provided object. no id available */ - pushstr(L, to_luastring('')); + pushstr(L, defs.to_luastring('')); } } break; @@ -658,21 +658,21 @@ const luaO_pushvfstring = function (L, fmt, argp) { break; } case 37 /* ('%').charCodeAt(0) */: - pushstr(L, to_luastring('%', true)); + pushstr(L, defs.to_luastring('%', true)); break; default: - luaG_runerror(L, to_luastring('invalid option \'%%%c\' to \'lua_pushfstring\''), fmt[e + 1]); + ldebug.luaG_runerror(L, defs.to_luastring('invalid option \'%%%c\' to \'lua_pushfstring\''), fmt[e + 1]); } n += 2; i = e + 2; } - luaD_checkstack(L, 1); + ldo.luaD_checkstack(L, 1); pushstr(L, fmt.subarray(i)); - if (n > 0) luaV_concat(L, n + 1); + if (n > 0) lvm.luaV_concat(L, n + 1); return L.stack[L.top - 1].svalue(); }; -const luaO_pushfstring = function (L, fmt, ...argp) { +export const luaO_pushfstring = function (L, fmt, ...argp) { return luaO_pushvfstring(L, fmt, argp); }; @@ -682,7 +682,7 @@ const luaO_pushfstring = function (L, fmt, ...argp) { ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if ** eeeee !== 0 and (xxx) otherwise. */ -const luaO_int2fb = function (x) { +export const luaO_int2fb = function (x) { let e = 0; /* exponent */ if (x < 8) return x; while (x >= (8 << 4)) { /* coarse steps */ @@ -696,56 +696,56 @@ const luaO_int2fb = function (x) { return ((e + 1) << 3) | (x - 8); }; -const intarith = function (L, op, v1, v2) { +export const intarith = function (L, op, v1, v2) { switch (op) { - case LUA_OPADD: return (v1 + v2) | 0; - case LUA_OPSUB: return (v1 - v2) | 0; - case LUA_OPMUL: return luaV_imul(v1, v2); - case LUA_OPMOD: return luaV_mod(L, v1, v2); - case LUA_OPIDIV: return luaV_div(L, v1, v2); - case LUA_OPBAND: return (v1 & v2); - case LUA_OPBOR: return (v1 | v2); - case LUA_OPBXOR: return (v1 ^ v2); - case LUA_OPSHL: return luaV_shiftl(v1, v2); - case LUA_OPSHR: return luaV_shiftl(v1, -v2); - case LUA_OPUNM: return (0 - v1) | 0; - case LUA_OPBNOT: return (~0 ^ v1); - default: lua_assert(0); + case defs.LUA_OPADD: return (v1 + v2) | 0; + case defs.LUA_OPSUB: return (v1 - v2) | 0; + case defs.LUA_OPMUL: return lvm.luaV_imul(v1, v2); + case defs.LUA_OPMOD: return lvm.luaV_mod(L, v1, v2); + case defs.LUA_OPIDIV: return lvm.luaV_div(L, v1, v2); + case defs.LUA_OPBAND: return (v1 & v2); + case defs.LUA_OPBOR: return (v1 | v2); + case defs.LUA_OPBXOR: return (v1 ^ v2); + case defs.LUA_OPSHL: return lvm.luaV_shiftl(v1, v2); + case defs.LUA_OPSHR: return lvm.luaV_shiftl(v1, -v2); + case defs.LUA_OPUNM: return (0 - v1) | 0; + case defs.LUA_OPBNOT: return (~0 ^ v1); + default: llimits.lua_assert(0); } }; -const numarith = function (L, op, v1, v2) { +export const numarith = function (L, op, v1, v2) { switch (op) { - case LUA_OPADD: return v1 + v2; - case LUA_OPSUB: return v1 - v2; - case LUA_OPMUL: return v1 * v2; - case LUA_OPDIV: return v1 / v2; - case LUA_OPPOW: return Math.pow(v1, v2); - case LUA_OPIDIV: return Math.floor(v1 / v2); - case LUA_OPUNM: return -v1; - case LUA_OPMOD: return luai_nummod(L, v1, v2); - default: lua_assert(0); + case defs.LUA_OPADD: return v1 + v2; + case defs.LUA_OPSUB: return v1 - v2; + case defs.LUA_OPMUL: return v1 * v2; + case defs.LUA_OPDIV: return v1 / v2; + case defs.LUA_OPPOW: return Math.pow(v1, v2); + case defs.LUA_OPIDIV: return Math.floor(v1 / v2); + case defs.LUA_OPUNM: return -v1; + case defs.LUA_OPMOD: return llimits.luai_nummod(L, v1, v2); + default: llimits.lua_assert(0); } }; -const luaO_arith = function (L, op, p1, p2, p3) { +export const luaO_arith = function (L, op, p1, p2, p3) { let res = (typeof p3 === 'number') ? L.stack[p3] : p3; /* FIXME */ switch (op) { - case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: - case LUA_OPSHL: case LUA_OPSHR: - case LUA_OPBNOT: { /* operate only on integers */ + case defs.LUA_OPBAND: case defs.LUA_OPBOR: case defs.LUA_OPBXOR: + case defs.LUA_OPSHL: case defs.LUA_OPSHR: + case defs.LUA_OPBNOT: { /* operate only on integers */ let i1, i2; - if ((i1 = tointeger(p1)) !== false && (i2 = tointeger(p2)) !== false) { + if ((i1 = lvm.tointeger(p1)) !== false && (i2 = lvm.tointeger(p2)) !== false) { res.setivalue(intarith(L, op, i1, i2)); return; } else break; /* go to the end */ } - case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */ + case defs.LUA_OPDIV: case defs.LUA_OPPOW: { /* operate only on floats */ let n1, n2; - if ((n1 = tonumber(p1)) !== false && (n2 = tonumber(p2)) !== false) { + if ((n1 = lvm.tonumber(p1)) !== false && (n2 = lvm.tonumber(p2)) !== false) { res.setfltvalue(numarith(L, op, n1, n2)); return; } @@ -757,7 +757,7 @@ const luaO_arith = function (L, op, p1, p2, p3) { res.setivalue(intarith(L, op, p1.value, p2.value)); return; } - else if ((n1 = tonumber(p1)) !== false && (n2 = tonumber(p2)) !== false) { + else if ((n1 = lvm.tonumber(p1)) !== false && (n2 = lvm.tonumber(p2)) !== false) { res.setfltvalue(numarith(L, op, n1, n2)); return; } @@ -765,54 +765,6 @@ const luaO_arith = function (L, op, p1, p2, p3) { } } /* could not perform raw operation; try metamethod */ - lua_assert(L !== null); /* should not fail when folding (compile time) */ - luaT_trybinTM(L, p1, p2, p3, (op - LUA_OPADD) + TMS.TM_ADD); + llimits.lua_assert(L !== null); /* should not fail when folding (compile time) */ + ltm.luaT_trybinTM(L, p1, p2, p3, (op - defs.LUA_OPADD) + ltm.TMS.TM_ADD); }; - - -const _CClosure = CClosure; -export { _CClosure as CClosure }; -const _LClosure = LClosure; -export { _LClosure as LClosure }; -const _LUA_TDEADKEY = LUA_TDEADKEY; -export { _LUA_TDEADKEY as LUA_TDEADKEY }; -const _LUA_TPROTO = LUA_TPROTO; -export { _LUA_TPROTO as LUA_TPROTO }; -const _LocVar = LocVar; -export { _LocVar as LocVar }; -const _TValue = TValue; -export { _TValue as TValue }; -const _Udata = Udata; -export { _Udata as Udata }; -const _UTF8BUFFSZ = UTF8BUFFSZ; -export { _UTF8BUFFSZ as UTF8BUFFSZ }; -const _luaO_arith = luaO_arith; -export { _luaO_arith as luaO_arith }; -const _luaO_chunkid = luaO_chunkid; -export { _luaO_chunkid as luaO_chunkid }; -const _luaO_hexavalue = luaO_hexavalue; -export { _luaO_hexavalue as luaO_hexavalue }; -const _luaO_int2fb = luaO_int2fb; -export { _luaO_int2fb as luaO_int2fb }; -const _luaO_pushfstring = luaO_pushfstring; -export { _luaO_pushfstring as luaO_pushfstring }; -const _luaO_pushvfstring = luaO_pushvfstring; -export { _luaO_pushvfstring as luaO_pushvfstring }; -const _luaO_str2num = luaO_str2num; -export { _luaO_str2num as luaO_str2num }; -const _luaO_tostring = luaO_tostring; -export { _luaO_tostring as luaO_tostring }; -const _luaO_utf8esc = luaO_utf8esc; -export { _luaO_utf8esc as luaO_utf8esc }; -const _numarith = numarith; -export { _numarith as numarith }; -const _pushobj2s = pushobj2s; -export { _pushobj2s as pushobj2s }; -const _pushsvalue2s = pushsvalue2s; -export { _pushsvalue2s as pushsvalue2s }; -const _setobjs2s = setobjs2s; -export { _setobjs2s as setobjs2s }; -const _setobj2s = setobj2s; -export { _setobj2s as setobj2s }; -const _setsvalue2s = setsvalue2s; -export { _setsvalue2s as setsvalue2s }; diff --git a/src/lopcodes.js b/src/lopcodes.js index 8396c007..ce36dbed 100644 --- a/src/lopcodes.js +++ b/src/lopcodes.js @@ -1,4 +1,4 @@ -const OpCodes = [ +export const OpCodes = [ 'MOVE', 'LOADK', 'LOADKX', @@ -48,7 +48,7 @@ const OpCodes = [ 'EXTRAARG' ]; -const OpCodesI = { +export const OpCodesI = { OP_MOVE: 0, OP_LOADK: 1, OP_LOADKX: 2, @@ -106,18 +106,18 @@ const OpCodesI = { ** bit 6: instruction set register A ** bit 7: operator is a test (next instruction must be a jump) */ -const OpArgN = 0; /* argument is not used */ -const OpArgU = 1; /* argument is used */ -const OpArgR = 2; /* argument is a register or a jump offset */ -const OpArgK = 3; /* argument is a constant or register/constant */ +export const OpArgN = 0; /* argument is not used */ +export const OpArgU = 1; /* argument is used */ +export const OpArgR = 2; /* argument is a register or a jump offset */ +export const OpArgK = 3; /* argument is a constant or register/constant */ /* basic instruction format */ -const iABC = 0; -const iABx = 1; -const iAsBx = 2; -const iAx = 3; +export const iABC = 0; +export const iABx = 1; +export const iAsBx = 2; +export const iAx = 3; -const luaP_opmodes = [ +export const luaP_opmodes = [ 0 << 7 | 1 << 6 | OpArgR << 4 | OpArgN << 2 | iABC, /* OP_MOVE */ 0 << 7 | 1 << 6 | OpArgK << 4 | OpArgN << 2 | iABx, /* OP_LOADK */ 0 << 7 | 1 << 6 | OpArgN << 4 | OpArgN << 2 | iABx, /* OP_LOADKX */ @@ -167,147 +167,147 @@ const luaP_opmodes = [ 0 << 7 | 0 << 6 | OpArgU << 4 | OpArgU << 2 | iAx /* OP_EXTRAARG */ ]; -const getOpMode = function (m) { +export const getOpMode = function (m) { return luaP_opmodes[m] & 3; }; -const getBMode = function (m) { +export const getBMode = function (m) { return (luaP_opmodes[m] >> 4) & 3; }; -const getCMode = function (m) { +export const getCMode = function (m) { return (luaP_opmodes[m] >> 2) & 3; }; -const testAMode = function (m) { +export const testAMode = function (m) { return luaP_opmodes[m] & (1 << 6); }; -const testTMode = function (m) { +export const testTMode = function (m) { return luaP_opmodes[m] & (1 << 7); }; -const SIZE_C = 9; -const SIZE_B = 9; -const SIZE_Bx = (SIZE_C + SIZE_B); -const SIZE_A = 8; -const SIZE_Ax = (SIZE_C + SIZE_B + SIZE_A); -const SIZE_OP = 6; -const POS_OP = 0; -const POS_A = (POS_OP + SIZE_OP); -const POS_C = (POS_A + SIZE_A); -const POS_B = (POS_C + SIZE_C); -const POS_Bx = POS_C; -const POS_Ax = POS_A; -const MAXARG_Bx = ((1 << SIZE_Bx) - 1); -const MAXARG_sBx = (MAXARG_Bx >> 1); /* 'sBx' is signed */ -const MAXARG_Ax = ((1 << SIZE_Ax) - 1); -const MAXARG_A = ((1 << SIZE_A) - 1); -const MAXARG_B = ((1 << SIZE_B) - 1); -const MAXARG_C = ((1 << SIZE_C) - 1); +export const SIZE_C = 9; +export const SIZE_B = 9; +export const SIZE_Bx = (SIZE_C + SIZE_B); +export const SIZE_A = 8; +export const SIZE_Ax = (SIZE_C + SIZE_B + SIZE_A); +export const SIZE_OP = 6; +export const POS_OP = 0; +export const POS_A = (POS_OP + SIZE_OP); +export const POS_C = (POS_A + SIZE_A); +export const POS_B = (POS_C + SIZE_C); +export const POS_Bx = POS_C; +export const POS_Ax = POS_A; +export const MAXARG_Bx = ((1 << SIZE_Bx) - 1); +export const MAXARG_sBx = (MAXARG_Bx >> 1); /* 'sBx' is signed */ +export const MAXARG_Ax = ((1 << SIZE_Ax) - 1); +export const MAXARG_A = ((1 << SIZE_A) - 1); +export const MAXARG_B = ((1 << SIZE_B) - 1); +export const MAXARG_C = ((1 << SIZE_C) - 1); /* this bit 1 means constant (0 means register) */ -const BITRK = (1 << (SIZE_B - 1)); +export const BITRK = (1 << (SIZE_B - 1)); -const MAXINDEXRK = (BITRK - 1); +export const MAXINDEXRK = (BITRK - 1); /* ** invalid register that fits in 8 bits */ -const NO_REG = MAXARG_A; +export const NO_REG = MAXARG_A; /* test whether value is a constant */ -const ISK = function (x) { +export const ISK = function (x) { return x & BITRK; }; /* gets the index of the constant */ -const INDEXK = function (r) { +export const INDEXK = function (r) { return r & ~BITRK; }; /* code a constant index as a RK value */ -const RKASK = function (x) { +export const RKASK = function (x) { return x | BITRK; }; /* creates a mask with 'n' 1 bits at position 'p' */ -const MASK1 = function (n, p) { +export const MASK1 = function (n, p) { return ((~((~0) << (n))) << (p)); }; /* creates a mask with 'n' 0 bits at position 'p' */ -const MASK0 = function (n, p) { +export const MASK0 = function (n, p) { return (~MASK1(n, p)); }; -const GET_OPCODE = function (i) { +export const GET_OPCODE = function (i) { return i.opcode; }; -const SET_OPCODE = function (i, o) { +export const SET_OPCODE = function (i, o) { i.code = (i.code & MASK0(SIZE_OP, POS_OP)) | ((o << POS_OP) & MASK1(SIZE_OP, POS_OP)); return fullins(i); }; -const setarg = function (i, v, pos, size) { +export const setarg = function (i, v, pos, size) { i.code = (i.code & MASK0(size, pos)) | ((v << pos) & MASK1(size, pos)); return fullins(i); }; -const GETARG_A = function (i) { +export const GETARG_A = function (i) { return i.A; }; -const SETARG_A = function (i, v) { +export const SETARG_A = function (i, v) { return setarg(i, v, POS_A, SIZE_A); }; -const GETARG_B = function (i) { +export const GETARG_B = function (i) { return i.B; }; -const SETARG_B = function (i, v) { +export const SETARG_B = function (i, v) { return setarg(i, v, POS_B, SIZE_B); }; -const GETARG_C = function (i) { +export const GETARG_C = function (i) { return i.C; }; -const SETARG_C = function (i, v) { +export const SETARG_C = function (i, v) { return setarg(i, v, POS_C, SIZE_C); }; -const GETARG_Bx = function (i) { +export const GETARG_Bx = function (i) { return i.Bx; }; -const SETARG_Bx = function (i, v) { +export const SETARG_Bx = function (i, v) { return setarg(i, v, POS_Bx, SIZE_Bx); }; -const GETARG_Ax = function (i) { +export const GETARG_Ax = function (i) { return i.Ax; }; -const SETARG_Ax = function (i, v) { +export const SETARG_Ax = function (i, v) { return setarg(i, v, POS_Ax, SIZE_Ax); }; -const GETARG_sBx = function (i) { +export const GETARG_sBx = function (i) { return i.sBx; }; -const SETARG_sBx = function (i, b) { +export const SETARG_sBx = function (i, b) { return SETARG_Bx(i, b + MAXARG_sBx); }; /* ** Pre-calculate all possible part of the instruction */ -const fullins = function (ins) { +export const fullins = function (ins) { if (typeof ins === 'number') { return { code: ins, @@ -332,134 +332,17 @@ const fullins = function (ins) { } }; -const CREATE_ABC = function (o, a, b, c) { +export const CREATE_ABC = function (o, a, b, c) { return fullins(o << POS_OP | a << POS_A | b << POS_B | c << POS_C); }; -const CREATE_ABx = function (o, a, bc) { +export const CREATE_ABx = function (o, a, bc) { return fullins(o << POS_OP | a << POS_A | bc << POS_Bx); }; -const CREATE_Ax = function (o, a) { +export const CREATE_Ax = function (o, a) { return fullins(o << POS_OP | a << POS_Ax); }; /* number of list items to accumulate before a SETLIST instruction */ -const LFIELDS_PER_FLUSH = 50; - -const _BITRK = BITRK; -export { _BITRK as BITRK }; -const _CREATE_ABC = CREATE_ABC; -export { _CREATE_ABC as CREATE_ABC }; -const _CREATE_ABx = CREATE_ABx; -export { _CREATE_ABx as CREATE_ABx }; -const _CREATE_Ax = CREATE_Ax; -export { _CREATE_Ax as CREATE_Ax }; -const _GET_OPCODE = GET_OPCODE; -export { _GET_OPCODE as GET_OPCODE }; -const _GETARG_A = GETARG_A; -export { _GETARG_A as GETARG_A }; -const _GETARG_B = GETARG_B; -export { _GETARG_B as GETARG_B }; -const _GETARG_C = GETARG_C; -export { _GETARG_C as GETARG_C }; -const _GETARG_Bx = GETARG_Bx; -export { _GETARG_Bx as GETARG_Bx }; -const _GETARG_Ax = GETARG_Ax; -export { _GETARG_Ax as GETARG_Ax }; -const _GETARG_sBx = GETARG_sBx; -export { _GETARG_sBx as GETARG_sBx }; -const _INDEXK = INDEXK; -export { _INDEXK as INDEXK }; -const _ISK = ISK; -export { _ISK as ISK }; -const _LFIELDS_PER_FLUSH = LFIELDS_PER_FLUSH; -export { _LFIELDS_PER_FLUSH as LFIELDS_PER_FLUSH }; -const _MAXARG_A = MAXARG_A; -export { _MAXARG_A as MAXARG_A }; -const _MAXARG_Ax = MAXARG_Ax; -export { _MAXARG_Ax as MAXARG_Ax }; -const _MAXARG_B = MAXARG_B; -export { _MAXARG_B as MAXARG_B }; -const _MAXARG_Bx = MAXARG_Bx; -export { _MAXARG_Bx as MAXARG_Bx }; -const _MAXARG_C = MAXARG_C; -export { _MAXARG_C as MAXARG_C }; -const _MAXARG_sBx = MAXARG_sBx; -export { _MAXARG_sBx as MAXARG_sBx }; -const _MAXINDEXRK = MAXINDEXRK; -export { _MAXINDEXRK as MAXINDEXRK }; -const _NO_REG = NO_REG; -export { _NO_REG as NO_REG }; -const _OpArgK = OpArgK; -export { _OpArgK as OpArgK }; -const _OpArgN = OpArgN; -export { _OpArgN as OpArgN }; -const _OpArgR = OpArgR; -export { _OpArgR as OpArgR }; -const _OpArgU = OpArgU; -export { _OpArgU as OpArgU }; -const _OpCodes = OpCodes; -export { _OpCodes as OpCodes }; -const _OpCodesI = OpCodesI; -export { _OpCodesI as OpCodesI }; -const _POS_A = POS_A; -export { _POS_A as POS_A }; -const _POS_Ax = POS_Ax; -export { _POS_Ax as POS_Ax }; -const _POS_B = POS_B; -export { _POS_B as POS_B }; -const _POS_Bx = POS_Bx; -export { _POS_Bx as POS_Bx }; -const _POS_C = POS_C; -export { _POS_C as POS_C }; -const _POS_OP = POS_OP; -export { _POS_OP as POS_OP }; -const _RKASK = RKASK; -export { _RKASK as RKASK }; -const _SETARG_A = SETARG_A; -export { _SETARG_A as SETARG_A }; -const _SETARG_Ax = SETARG_Ax; -export { _SETARG_Ax as SETARG_Ax }; -const _SETARG_B = SETARG_B; -export { _SETARG_B as SETARG_B }; -const _SETARG_Bx = SETARG_Bx; -export { _SETARG_Bx as SETARG_Bx }; -const _SETARG_C = SETARG_C; -export { _SETARG_C as SETARG_C }; -const _SETARG_sBx = SETARG_sBx; -export { _SETARG_sBx as SETARG_sBx }; -const _SET_OPCODE = SET_OPCODE; -export { _SET_OPCODE as SET_OPCODE }; -const _SIZE_A = SIZE_A; -export { _SIZE_A as SIZE_A }; -const _SIZE_Ax = SIZE_Ax; -export { _SIZE_Ax as SIZE_Ax }; -const _SIZE_B = SIZE_B; -export { _SIZE_B as SIZE_B }; -const _SIZE_Bx = SIZE_Bx; -export { _SIZE_Bx as SIZE_Bx }; -const _SIZE_C = SIZE_C; -export { _SIZE_C as SIZE_C }; -const _SIZE_OP = SIZE_OP; -export { _SIZE_OP as SIZE_OP }; -const _fullins = fullins; -export { _fullins as fullins }; -const _getBMode = getBMode; -export { _getBMode as getBMode }; -const _getCMode = getCMode; -export { _getCMode as getCMode }; -const _getOpMode = getOpMode; -export { _getOpMode as getOpMode }; -const _iABC = iABC; -export { _iABC as iABC }; -const _iABx = iABx; -export { _iABx as iABx }; -const _iAsBx = iAsBx; -export { _iAsBx as iAsBx }; -const _iAx = iAx; -export { _iAx as iAx }; -const _testAMode = testAMode; -export { _testAMode as testAMode }; -const _testTMode = testTMode; -export { _testTMode as testTMode }; +export const LFIELDS_PER_FLUSH = 50; diff --git a/src/loslib.js b/src/loslib.js index 4dae7b7f..a2e59d34 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -1,11 +1,17 @@ -'use strict'; - -import fs from 'fs'; -import tmp from 'tmp'; -import child_process from 'child_process'; -import { LUA_TNIL, LUA_TTABLE, lua_close, lua_createtable, lua_getfield, lua_isboolean, lua_isnoneornil, lua_pop, lua_pushboolean, lua_pushfstring, lua_pushinteger, lua_pushliteral, lua_pushnil, lua_pushnumber, lua_pushstring, lua_setfield, lua_settop, lua_toboolean, lua_tointegerx } from './lua.js'; -import { luaL_Buffer, luaL_addchar, luaL_addstring, luaL_argerror, luaL_buffinit, luaL_checkinteger, luaL_checkoption, luaL_checkstring, luaL_checktype, luaL_error, luaL_execresult, luaL_fileresult, luaL_newlib, luaL_optinteger, luaL_optlstring, luaL_optstring, luaL_pushresult } from './lauxlib.js'; -import { luastring_eq, to_jsstring, to_luastring } from './fengaricore.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as fengaricore from './fengaricore.js'; + +let child_process = undefined; +let tmp = undefined; +let fs = undefined; + +if (typeof process !== 'undefined') { + // Hacky but these are only used in node env + child_process = require('child_process'); + tmp = require('tmp'); + fs = require('fs'); +} /* options for ANSI C 89 (only 1-char options) */ // const L_STRFTIMEC89 = to_luastring("aAbBcdHIjmMpSUwWxXyYZ%"); @@ -29,12 +35,12 @@ import { luastring_eq, to_jsstring, to_luastring } from './fengaricore.js'; - %l: TZ extension: space-padded 12-hour - %P: GNU extension: lower-case am/pm */ -const LUA_STRFTIMEOPTIONS = to_luastring('aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%'); +const LUA_STRFTIMEOPTIONS = fengaricore.to_luastring('aAbBcCdDeFhHIjklmMnpPrRStTuUwWxXyYzZ%'); const setfield = function(L, key, value) { - lua_pushinteger(L, value); - lua_setfield(L, -2, to_luastring(key, true)); + lua.lua_pushinteger(L, value); + lua.lua_setfield(L, -2, fengaricore.to_luastring(key, true)); }; const setallfields = function(L, time, utc) { @@ -52,43 +58,43 @@ const setallfields = function(L, time, utc) { const L_MAXDATEFIELD = (Number.MAX_SAFE_INTEGER / 2); const getfield = function(L, key, d, delta) { - let t = lua_getfield(L, -1, to_luastring(key, true)); /* get field and its type */ - let res = lua_tointegerx(L, -1); + let t = lua.lua_getfield(L, -1, fengaricore.to_luastring(key, true)); /* get field and its type */ + let res = lua.lua_tointegerx(L, -1); if (res === false) { /* field is not an integer? */ - if (t !== LUA_TNIL) /* some other value? */ - return luaL_error(L, to_luastring('field \'%s\' is not an integer'), key); + if (t !== lua.LUA_TNIL) /* some other value? */ + return lauxlib.luaL_error(L, fengaricore.to_luastring('field \'%s\' is not an integer'), key); else if (d < 0) /* absent field; no default? */ - return luaL_error(L, to_luastring('field \'%s\' missing in date table'), key); + return lauxlib.luaL_error(L, fengaricore.to_luastring('field \'%s\' missing in date table'), key); res = d; } else { if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) - return luaL_error(L, to_luastring('field \'%s\' is out-of-bound'), key); + return lauxlib.luaL_error(L, fengaricore.to_luastring('field \'%s\' is out-of-bound'), key); res -= delta; } - lua_pop(L, 1); + lua.lua_pop(L, 1); return res; }; const locale = { - days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ].map((s) => to_luastring(s)), - shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((s) => to_luastring(s)), - months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].map((s) => to_luastring(s)), - shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'].map((s) => to_luastring(s)), - AM: to_luastring('AM'), - PM: to_luastring('PM'), - am: to_luastring('am'), - pm: to_luastring('pm'), + days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ].map((s) => fengaricore.to_luastring(s)), + shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((s) => fengaricore.to_luastring(s)), + months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].map((s) => fengaricore.to_luastring(s)), + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'].map((s) => fengaricore.to_luastring(s)), + AM: fengaricore.to_luastring('AM'), + PM: fengaricore.to_luastring('PM'), + am: fengaricore.to_luastring('am'), + pm: fengaricore.to_luastring('pm'), formats: { - c: to_luastring('%a %b %e %H:%M:%S %Y'), - D: to_luastring('%m/%d/%y'), - F: to_luastring('%Y-%m-%d'), - R: to_luastring('%H:%M'), - r: to_luastring('%I:%M:%S %p'), - T: to_luastring('%H:%M:%S'), - X: to_luastring('%T'), - x: to_luastring('%D') + c: fengaricore.to_luastring('%a %b %e %H:%M:%S %Y'), + D: fengaricore.to_luastring('%m/%d/%y'), + F: fengaricore.to_luastring('%Y-%m-%d'), + R: fengaricore.to_luastring('%H:%M'), + r: fengaricore.to_luastring('%I:%M:%S %p'), + T: fengaricore.to_luastring('%H:%M:%S'), + X: fengaricore.to_luastring('%T'), + x: fengaricore.to_luastring('%D') } }; @@ -108,15 +114,15 @@ const week_number = function(date, start_of_week) { const push_pad_2 = function(b, n, pad) { if (n < 10) - luaL_addchar(b, pad); - luaL_addstring(b, to_luastring(String(n))); + lauxlib.luaL_addchar(b, pad); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(String(n))); }; const strftime = function(L, b, s, date) { let i = 0; while (i < s.length) { if (s[i] !== 37 /* % */) { /* not a conversion specifier? */ - luaL_addchar(b, s[i++]); + lauxlib.luaL_addchar(b, s[i++]); } else { i++; /* skip '%' */ let len = checkoption(L, s, i); @@ -124,17 +130,17 @@ const strftime = function(L, b, s, date) { switch(s[i]) { // '%' case 37 /* % */: - luaL_addchar(b, 37); + lauxlib.luaL_addchar(b, 37); break; // 'Thursday' case 65 /* A */: - luaL_addstring(b, locale.days[date.getDay()]); + lauxlib.luaL_addstring(b, locale.days[date.getDay()]); break; // 'January' case 66 /* B */: - luaL_addstring(b, locale.months[date.getMonth()]); + lauxlib.luaL_addstring(b, locale.months[date.getMonth()]); break; // '19' @@ -169,7 +175,7 @@ const strftime = function(L, b, s, date) { // 'am' case 80 /* P */: - luaL_addstring(b, date.getHours() < 12 ? locale.am : locale.pm); + lauxlib.luaL_addstring(b, date.getHours() < 12 ? locale.am : locale.pm); break; // '00:00' @@ -204,26 +210,26 @@ const strftime = function(L, b, s, date) { // '1970' case 89 /* Y */: - luaL_addstring(b, to_luastring(String(date.getFullYear()))); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(String(date.getFullYear()))); break; // 'GMT' case 90 /* Z */: { let tzString = date.toString().match(/\(([\w\s]+)\)/); if (tzString) - luaL_addstring(b, to_luastring(tzString[1])); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(tzString[1])); break; } // 'Thu' case 97 /* a */: - luaL_addstring(b, locale.shortDays[date.getDay()]); + lauxlib.luaL_addstring(b, locale.shortDays[date.getDay()]); break; // 'Jan' case 98 /* b */: case 104 /* h */: - luaL_addstring(b, locale.shortMonths[date.getMonth()]); + lauxlib.luaL_addstring(b, locale.shortMonths[date.getMonth()]); break; // '' @@ -246,10 +252,10 @@ const strftime = function(L, b, s, date) { let yday = Math.floor((date - new Date(date.getFullYear(), 0, 1)) / 86400000); if (yday < 100) { if (yday < 10) - luaL_addchar(b, 48 /* 0 */); - luaL_addchar(b, 48 /* 0 */); + lauxlib.luaL_addchar(b, 48 /* 0 */); + lauxlib.luaL_addchar(b, 48 /* 0 */); } - luaL_addstring(b, to_luastring(String(yday))); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(String(yday))); break; } @@ -270,12 +276,12 @@ const strftime = function(L, b, s, date) { // '\n' case 110 /* n */: - luaL_addchar(b, 10); + lauxlib.luaL_addchar(b, 10); break; // 'AM' case 112 /* p */: - luaL_addstring(b, date.getHours() < 12 ? locale.AM : locale.PM); + lauxlib.luaL_addstring(b, date.getHours() < 12 ? locale.AM : locale.PM); break; // '12:00:00 AM' @@ -285,24 +291,24 @@ const strftime = function(L, b, s, date) { // '0' case 115 /* s */: - luaL_addstring(b, to_luastring(String(Math.floor(date / 1000)))); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(String(Math.floor(date / 1000)))); break; // '\t' case 116 /* t */: - luaL_addchar(b, 8); + lauxlib.luaL_addchar(b, 8); break; // '4' case 117 /* u */: { let day = date.getDay(); - luaL_addstring(b, to_luastring(String(day === 0 ? 7 : day))); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(String(day === 0 ? 7 : day))); break; } // '4' case 119 /* w */: - luaL_addstring(b, to_luastring(String(date.getDay()))); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(String(date.getDay()))); break; // '12/31/69' @@ -319,10 +325,10 @@ const strftime = function(L, b, s, date) { case 122 /* z */: { let off = date.getTimezoneOffset(); if (off > 0) { - luaL_addchar(b, 45 /* - */); + lauxlib.luaL_addchar(b, 45 /* - */); } else { off = -off; - luaL_addchar(b, 43 /* + */); + lauxlib.luaL_addchar(b, 43 /* + */); } push_pad_2(b, Math.floor(off/60), 48 /* 0 */); push_pad_2(b, off % 60, 48 /* 0 */); @@ -342,12 +348,12 @@ const checkoption = function(L, conv, i) { for (; o < option.length && oplen <= (conv.length - i); o += oplen) { if (option[o] === '|'.charCodeAt(0)) /* next block? */ oplen++; /* will check options with next length (+1) */ - else if (luastring_eq(conv.subarray(i, i+oplen), option.subarray(o, o+oplen))) { /* match? */ + else if (fengaricore.luastring_eq(conv.subarray(i, i+oplen), option.subarray(o, o+oplen))) { /* match? */ return oplen; /* return length */ } } - luaL_argerror(L, 1, - lua_pushfstring(L, to_luastring('invalid conversion specifier \'%%%s\''), conv)); + lauxlib.luaL_argerror(L, 1, + lua.lua_pushfstring(L, fengaricore.to_luastring('invalid conversion specifier \'%%%s\''), conv)); }; /* maximum size for an individual 'strftime' item */ @@ -355,8 +361,8 @@ const checkoption = function(L, conv, i) { const os_date = function(L) { - let s = luaL_optlstring(L, 1, '%c'); - let stm = lua_isnoneornil(L, 2) ? new Date() : new Date(l_checktime(L, 2) * 1000); + let s = lauxlib.luaL_optlstring(L, 1, '%c'); + let stm = lua.lua_isnoneornil(L, 2) ? new Date() : new Date(l_checktime(L, 2) * 1000); let utc = false; let i = 0; if (s[i] === '!'.charCodeAt(0)) { /* UTC? */ @@ -364,26 +370,26 @@ const os_date = function(L) { i++; /* skip '!' */ } if (s[i] === '*'.charCodeAt(0) && s[i+1] === 't'.charCodeAt(0)) { - lua_createtable(L, 0, 9); /* 9 = number of fields */ + lua.lua_createtable(L, 0, 9); /* 9 = number of fields */ setallfields(L, stm, utc); } else { let cc = new Uint8Array(4); cc[0] = '%'.charCodeAt(0); - let b = new luaL_Buffer(); - luaL_buffinit(L, b); + let b = new lauxlib.luaL_Buffer(); + lauxlib.luaL_buffinit(L, b); strftime(L, b, s, stm); - luaL_pushresult(b); + lauxlib.luaL_pushresult(b); } return 1; }; const os_time = function(L) { let t; - if (lua_isnoneornil(L, 1)) /* called without args? */ + if (lua.lua_isnoneornil(L, 1)) /* called without args? */ t = new Date(); /* get current time */ else { - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 1); /* make sure table is at the top */ + lauxlib.luaL_checktype(L, 1, lua.LUA_TTABLE); + lua.lua_settop(L, 1); /* make sure table is at the top */ t = new Date( getfield(L, 'year', -1, 0), getfield(L, 'month', -1, 1), @@ -395,12 +401,12 @@ const os_time = function(L) { setallfields(L, t); } - lua_pushinteger(L, Math.floor(t / 1000)); + lua.lua_pushinteger(L, Math.floor(t / 1000)); return 1; }; const l_checktime = function(L, arg) { - let t = luaL_checkinteger(L, arg); + let t = lauxlib.luaL_checkinteger(L, arg); // luaL_argcheck(L, t, arg, "time out-of-bounds"); return t; }; @@ -408,24 +414,24 @@ const l_checktime = function(L, arg) { const os_difftime = function(L) { let t1 = l_checktime(L, 1); let t2 = l_checktime(L, 2); - lua_pushnumber(L, t1 - t2); + lua.lua_pushnumber(L, t1 - t2); return 1; }; -const catnames = ['all', 'collate', 'ctype', 'monetary', 'numeric', 'time'].map((lc) => to_luastring(lc)); -const C = to_luastring('C'); -const POSIX = to_luastring('POSIX'); +const catnames = ['all', 'collate', 'ctype', 'monetary', 'numeric', 'time'].map((lc) => fengaricore.to_luastring(lc)); +const C = fengaricore.to_luastring('C'); +const POSIX = fengaricore.to_luastring('POSIX'); const os_setlocale = function(L) { - const l = luaL_optstring(L, 1, null); - luaL_checkoption(L, 2, 'all', catnames); + const l = lauxlib.luaL_optstring(L, 1, null); + lauxlib.luaL_checkoption(L, 2, 'all', catnames); /* It is not possible to set the JS-VM wide locale, so we say that we only know the C locale. The "POSIX" locale is defined in IEEE Std 1003.1-2017 Section 7.2 as equivalent to "C" */ - lua_pushstring(L, ( + lua.lua_pushstring(L, ( l === null /* passing nil returns the current locale; which is "C" */ || l.length == 0 /* empty string resets to the default locale; which is "C" */ - || luastring_eq(l, C) /* user passed "C" */ - || luastring_eq(l, POSIX) /* user passed "POSIX", equivalent to "C" */ + || fengaricore.luastring_eq(l, C) /* user passed "C" */ + || fengaricore.luastring_eq(l, POSIX) /* user passed "POSIX", equivalent to "C" */ ) ? C : null); return 1; }; @@ -439,7 +445,7 @@ const syslib = { if (typeof process === 'undefined') { syslib.clock = function(L) { - lua_pushnumber(L, performance.now()/1000); + lua.lua_pushnumber(L, performance.now()/1000); return 1; }; } else { @@ -447,29 +453,29 @@ if (typeof process === 'undefined') { syslib.exit = function(L) { let status; - if (lua_isboolean(L, 1)) - status = (lua_toboolean(L, 1) ? 0 : 1); + if (lua.lua_isboolean(L, 1)) + status = (lua.lua_toboolean(L, 1) ? 0 : 1); else - status = luaL_optinteger(L, 1, 0); - if (lua_toboolean(L, 2)) - lua_close(L); + status = lauxlib.luaL_optinteger(L, 1, 0); + if (lua.lua_toboolean(L, 2)) + lua.lua_close(L); if (L) process.exit(status); /* 'if' to avoid warnings for unreachable 'return' */ return 0; }; syslib.getenv = function(L) { - let key = luaL_checkstring(L, 1); - key = to_jsstring(key); /* https://github.com/nodejs/node/issues/16961 */ + let key = lauxlib.luaL_checkstring(L, 1); + key = fengaricore.to_jsstring(key); /* https://github.com/nodejs/node/issues/16961 */ if (Object.prototype.hasOwnProperty.call(process.env, key)) { - lua_pushliteral(L, process.env[key]); + lua.lua_pushliteral(L, process.env[key]); } else { - lua_pushnil(L); + lua.lua_pushnil(L); } return 1; }; syslib.clock = function(L) { - lua_pushnumber(L, process.uptime()); + lua.lua_pushnumber(L, process.uptime()); return 1; }; @@ -478,7 +484,7 @@ if (typeof process === 'undefined') { }; syslib.remove = function(L) { - let filename = luaL_checkstring(L, 1); + let filename = lauxlib.luaL_checkstring(L, 1); try { fs.unlinkSync(filename); } catch (e) { @@ -486,38 +492,38 @@ if (typeof process === 'undefined') { try { fs.rmdirSync(filename); } catch (e) { - return luaL_fileresult(L, false, filename, e); + return lauxlib.luaL_fileresult(L, false, filename, e); } } else { - return luaL_fileresult(L, false, filename, e); + return lauxlib.luaL_fileresult(L, false, filename, e); } } - return luaL_fileresult(L, true); + return lauxlib.luaL_fileresult(L, true); }; syslib.rename = function(L) { - let fromname = luaL_checkstring(L, 1); - let toname = luaL_checkstring(L, 2); + let fromname = lauxlib.luaL_checkstring(L, 1); + let toname = lauxlib.luaL_checkstring(L, 2); try { fs.renameSync(fromname, toname); } catch (e) { - return luaL_fileresult(L, false, false, e); + return lauxlib.luaL_fileresult(L, false, false, e); } - return luaL_fileresult(L, true); + return lauxlib.luaL_fileresult(L, true); }; syslib.tmpname = function(L) { let name = lua_tmpname(); if (!name) - return luaL_error(L, to_luastring('unable to generate a unique filename')); - lua_pushstring(L, to_luastring(name)); + return lauxlib.luaL_error(L, fengaricore.to_luastring('unable to generate a unique filename')); + lua.lua_pushstring(L, fengaricore.to_luastring(name)); return 1; }; syslib.execute = function(L) { - let cmd = luaL_optstring(L, 1, null); + let cmd = lauxlib.luaL_optstring(L, 1, null); if (cmd !== null) { - cmd = to_jsstring(cmd); + cmd = fengaricore.to_jsstring(cmd); try { child_process.execSync( cmd, @@ -526,25 +532,22 @@ if (typeof process === 'undefined') { } ); } catch (e) { - return luaL_execresult(L, e); + return lauxlib.luaL_execresult(L, e); } - return luaL_execresult(L, null); + return lauxlib.luaL_execresult(L, null); } else { /* Assume a shell is available. If it's good enough for musl it's good enough for us. http://git.musl-libc.org/cgit/musl/tree/src/process/system.c?id=ac45692a53a1b8d2ede329d91652d43c1fb5dc8d#n22 */ - lua_pushboolean(L, 1); + lua.lua_pushboolean(L, 1); return 1; } }; } -const luaopen_os = function(L) { - luaL_newlib(L, syslib); +export const luaopen_os = function(L) { + lauxlib.luaL_newlib(L, syslib); return 1; }; - -const _luaopen_os = luaopen_os; -export { _luaopen_os as luaopen_os }; diff --git a/src/lparser.js b/src/lparser.js index 18e23028..748b04e5 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1,13 +1,13 @@ -import { LUA_MULTRET, to_luastring } from './defs.js'; -import { BinOpr, UnOpr, NO_JUMP, getinstruction, luaK_checkstack, luaK_codeABC, luaK_codeABx, luaK_codeAsBx, luaK_codek, luaK_concat, luaK_dischargevars, luaK_exp2RK, luaK_exp2anyreg, luaK_exp2anyregup, luaK_exp2nextreg, luaK_exp2val, luaK_fixline, luaK_getlabel, luaK_goiffalse, luaK_goiftrue, luaK_indexed, luaK_infix, luaK_intK, luaK_jump, luaK_jumpto, luaK_nil, luaK_patchclose, luaK_patchlist, luaK_patchtohere, luaK_posfix, luaK_prefix, luaK_reserveregs, luaK_ret, luaK_self, luaK_setlist, luaK_setmultret, luaK_setoneret, luaK_setreturns, luaK_storevar, luaK_stringK } from './lcode.js'; -import { luaD_inctop } from './ldo.js'; -import { Proto as _Proto, MAXUPVAL, luaF_newLclosure } from './lfunc.js'; -import { RESERVED, luaX_syntaxerror, luaX_token2str, luaX_next, luaX_newstring, isreserved, luaX_lookahead, LexState, luaX_setinput } from './llex.js'; -import { LUAI_MAXCCALLS, MAX_INT, lua_assert } from './llimits.js'; -import { luaO_pushfstring, LocVar, luaO_int2fb } from './lobject.js'; -import { OpCodesI, LFIELDS_PER_FLUSH, SETARG_B, SETARG_C, SET_OPCODE } from './lopcodes.js'; -import { luaS_eqlngstr, luaS_new, luaS_newliteral } from './lstring.js'; -import { luaH_new } from './ltable.js'; +import * as defs from './defs.js'; +import * as lcode from './lcode.js'; +import * as ldo from './ldo.js'; +import * as lfunc from './lfunc.js'; +import * as llex from './llex.js'; +import * as llimits from './llimits.js'; +import * as lobject from './lobject.js'; +import * as lopcodes from './lopcodes.js'; +import * as lstring from './lstring.js'; +import * as ltable from './ltable.js'; const { OPR_ADD, @@ -32,7 +32,7 @@ const { OPR_SHL, OPR_SHR, OPR_SUB -} = BinOpr; +} = lcode.BinOpr; const { OPR_BNOT, @@ -40,7 +40,7 @@ const { OPR_MINUS, OPR_NOT, OPR_NOUNOPR -} = UnOpr; +} = lcode.UnOpr; const { OP_CALL, @@ -55,10 +55,9 @@ const { OP_TFORCALL, OP_TFORLOOP, OP_VARARG -} = OpCodesI; +} = lopcodes.OpCodesI; -const Proto = _Proto; -const R = RESERVED; +const R = llex.RESERVED; const MAXVARS = 200; @@ -68,7 +67,7 @@ const hasmultret = function (k) { const eqstr = function (a, b) { /* TODO: use plain equality as strings are cached */ - return luaS_eqlngstr(a, b); + return lstring.luaS_eqlngstr(a, b); }; class BlockCnt { @@ -82,7 +81,7 @@ class BlockCnt { } } -const expkind = { +export const expkind = { VVOID: 0, /* when 'expdesc' describes the last expression a list, this kind means an empty list (so, no expression) */ VNIL: 1, /* constant nil */ @@ -111,11 +110,11 @@ const vkisvar = function (k) { return expkind.VLOCAL <= k && k <= expkind.VINDEXED; }; -const vkisinreg = function (k) { +export const vkisinreg = function (k) { return k === expkind.VNONRELOC || k === expkind.VLOCAL; }; -class expdesc { +export class expdesc { constructor() { this.k = NaN; this.u = { @@ -188,7 +187,7 @@ class Labellist { } /* dynamic structures used by the parser */ -class Dyndata { +export class Dyndata { constructor() { this.actvar = { /* list of active local variables */ arr: [], @@ -202,22 +201,22 @@ class Dyndata { const semerror = function (ls, msg) { ls.t.token = 0; /* remove "near " from final message */ - luaX_syntaxerror(ls, msg); + llex.luaX_syntaxerror(ls, msg); }; const error_expected = function (ls, token) { - luaX_syntaxerror(ls, luaO_pushfstring(ls.L, to_luastring('%s expected', true), luaX_token2str(ls, token))); + llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, defs.to_luastring('%s expected', true), llex.luaX_token2str(ls, token))); }; const errorlimit = function (fs, limit, what) { let L = fs.ls.L; let line = fs.f.linedefined; let where = (line === 0) - ? to_luastring('main function', true) - : luaO_pushfstring(L, to_luastring('function at line %d', true), line); - let msg = luaO_pushfstring(L, to_luastring('too many %s (limit is %d) in %s', true), + ? defs.to_luastring('main function', true) + : lobject.luaO_pushfstring(L, defs.to_luastring('function at line %d', true), line); + let msg = lobject.luaO_pushfstring(L, defs.to_luastring('too many %s (limit is %d) in %s', true), what, limit, where); - luaX_syntaxerror(fs.ls, msg); + llex.luaX_syntaxerror(fs.ls, msg); }; const checklimit = function (fs, v, l, what) { @@ -226,7 +225,7 @@ const checklimit = function (fs, v, l, what) { const testnext = function (ls, c) { if (ls.t.token === c) { - luaX_next(ls); + llex.luaX_next(ls); return true; } @@ -240,12 +239,12 @@ const check = function (ls, c) { const checknext = function (ls, c) { check(ls, c); - luaX_next(ls); + llex.luaX_next(ls); }; const check_condition = function (ls, c, msg) { if (!c) - luaX_syntaxerror(ls, msg); + llex.luaX_syntaxerror(ls, msg); }; const check_match = function (ls, what, who, where) { @@ -253,27 +252,27 @@ const check_match = function (ls, what, who, where) { if (where === ls.linenumber) error_expected(ls, what); else - luaX_syntaxerror(ls, luaO_pushfstring(ls.L, - to_luastring('%s expected (to close %s at line %d)'), - luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + llex.luaX_syntaxerror(ls, lobject.luaO_pushfstring(ls.L, + defs.to_luastring('%s expected (to close %s at line %d)'), + llex.luaX_token2str(ls, what), llex.luaX_token2str(ls, who), where)); } }; const str_checkname = function (ls) { check(ls, R.TK_NAME); let ts = ls.t.seminfo.ts; - luaX_next(ls); + llex.luaX_next(ls); return ts; }; const init_exp = function (e, k, i) { - e.f = e.t = NO_JUMP; + e.f = e.t = lcode.NO_JUMP; e.k = k; e.u.info = i; }; const codestring = function (ls, e, s) { - init_exp(e, expkind.VK, luaK_stringK(ls.fs, s)); + init_exp(e, expkind.VK, lcode.luaK_stringK(ls.fs, s)); }; const checkname = function (ls, e) { @@ -283,7 +282,7 @@ const checkname = function (ls, e) { const registerlocalvar = function (ls, varname) { let fs = ls.fs; let f = fs.f; - f.locvars[fs.nlocvars] = new LocVar(); + f.locvars[fs.nlocvars] = new lobject.LocVar(); f.locvars[fs.nlocvars].varname = varname; return fs.nlocvars++; }; @@ -292,19 +291,19 @@ const new_localvar = function (ls, name) { let fs = ls.fs; let dyd = ls.dyd; let reg = registerlocalvar(ls, name); - checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, to_luastring('local variables', true)); + checklimit(fs, dyd.actvar.n + 1 - fs.firstlocal, MAXVARS, defs.to_luastring('local variables', true)); dyd.actvar.arr[dyd.actvar.n] = new Vardesc(); dyd.actvar.arr[dyd.actvar.n].idx = reg; dyd.actvar.n++; }; const new_localvarliteral = function (ls, name) { - new_localvar(ls, luaX_newstring(ls, to_luastring(name, true))); + new_localvar(ls, llex.luaX_newstring(ls, defs.to_luastring(name, true))); }; const getlocvar = function (fs, i) { let idx = fs.ls.dyd.actvar.arr[fs.firstlocal + i].idx; - lua_assert(idx < fs.nlocvars); + llimits.lua_assert(idx < fs.nlocvars); return fs.f.locvars[idx]; }; @@ -332,7 +331,7 @@ const searchupvalue = function (fs, name) { const newupvalue = function (fs, name, v) { let f = fs.f; - checklimit(fs, fs.nups + 1, MAXUPVAL, to_luastring('upvalues', true)); + checklimit(fs, fs.nups + 1, lfunc.MAXUPVAL, defs.to_luastring('upvalues', true)); f.upvalues[fs.nups] = { instack: v.k === expkind.VLOCAL, idx: v.u.info, @@ -395,9 +394,9 @@ const singlevar = function (ls, vr) { if (vr.k === expkind.VVOID) { /* is global name? */ let key = new expdesc(); singlevaraux(fs, ls.envn, vr, 1); /* get environment variable */ - lua_assert(vr.k !== expkind.VVOID); /* this one must exist */ + llimits.lua_assert(vr.k !== expkind.VVOID); /* this one must exist */ codestring(ls, key, varname); /* key is variable name */ - luaK_indexed(fs, vr, key); /* env[varname] */ + lcode.luaK_indexed(fs, vr, key); /* env[varname] */ } }; @@ -407,14 +406,14 @@ const adjust_assign = function (ls, nvars, nexps, e) { if (hasmultret(e.k)) { extra++; /* includes call itself */ if (extra < 0) extra = 0; - luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ - if (extra > 1) luaK_reserveregs(fs, extra - 1); + lcode.luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) lcode.luaK_reserveregs(fs, extra - 1); } else { - if (e.k !== expkind.VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (e.k !== expkind.VVOID) lcode.luaK_exp2nextreg(fs, e); /* close last expression */ if (extra > 0) { let reg = fs.freereg; - luaK_reserveregs(fs, extra); - luaK_nil(fs, reg, extra); + lcode.luaK_reserveregs(fs, extra); + lcode.luaK_nil(fs, reg, extra); } } if (nexps > nvars) @@ -424,7 +423,7 @@ const adjust_assign = function (ls, nvars, nexps, e) { const enterlevel = function (ls) { let L = ls.L; ++L.nCcalls; - checklimit(ls.fs, L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); + checklimit(ls.fs, L.nCcalls, llimits.LUAI_MAXCCALLS, defs.to_luastring('JS levels', true)); }; const leavelevel = function (ls) { @@ -435,15 +434,15 @@ const closegoto = function (ls, g, label) { let fs = ls.fs; let gl = ls.dyd.gt; let gt = gl.arr[g]; - lua_assert(eqstr(gt.name, label.name)); + llimits.lua_assert(eqstr(gt.name, label.name)); if (gt.nactvar < label.nactvar) { let vname = getlocvar(fs, gt.nactvar).varname; - let msg = luaO_pushfstring(ls.L, - to_luastring(' at line %d jumps into the scope of local \'%s\''), + let msg = lobject.luaO_pushfstring(ls.L, + defs.to_luastring(' at line %d jumps into the scope of local \'%s\''), gt.name.getstr(), gt.line, vname.getstr()); semerror(ls, msg); } - luaK_patchlist(fs, gt.pc, label.pc); + lcode.luaK_patchlist(fs, gt.pc, label.pc); /* remove goto from pending list */ for (let i = g; i < gl.n - 1; i++) gl.arr[i] = gl.arr[i + 1]; @@ -462,7 +461,7 @@ const findlabel = function (ls, g) { let lb = dyd.label.arr[i]; if (eqstr(lb.name, gt.name)) { /* correct label? */ if (gt.nactvar > lb.nactvar && (bl.upval || dyd.label.n > bl.firstlabel)) - luaK_patchclose(ls.fs, gt.pc, lb.nactvar); + lcode.luaK_patchclose(ls.fs, gt.pc, lb.nactvar); closegoto(ls, g, lb); /* close it */ return true; } @@ -511,7 +510,7 @@ const movegotosout = function (fs, bl) { let gt = gl.arr[i]; if (gt.nactvar > bl.nactvar) { if (bl.upval) - luaK_patchclose(fs, gt.pc, bl.nactvar); + lcode.luaK_patchclose(fs, gt.pc, bl.nactvar); gt.nactvar = bl.nactvar; } if (!findlabel(fs.ls, i)) @@ -527,14 +526,14 @@ const enterblock = function (fs, bl, isloop) { bl.upval = 0; bl.previous = fs.bl; fs.bl = bl; - lua_assert(fs.freereg === fs.nactvar); + llimits.lua_assert(fs.freereg === fs.nactvar); }; /* ** create a label named 'break' to resolve break statements */ const breaklabel = function (ls) { - let n = luaS_newliteral(ls.L, 'break'); + let n = lstring.luaS_newliteral(ls.L, 'break'); let l = newlabelentry(ls, ls.dyd.label, n, 0, ls.fs.pc); findgotos(ls, ls.dyd.label.arr[l]); }; @@ -544,10 +543,10 @@ const breaklabel = function (ls) { ** message when label name is a reserved word (which can only be 'break') */ const undefgoto = function (ls, gt) { - let msg = isreserved(gt.name) + let msg = llex.isreserved(gt.name) ? '<%s> at line %d not inside a loop' : 'no visible label \'%s\' for at line %d'; - msg = luaO_pushfstring(ls.L, to_luastring(msg), gt.name.getstr(), gt.line); + msg = lobject.luaO_pushfstring(ls.L, defs.to_luastring(msg), gt.name.getstr(), gt.line); semerror(ls, msg); }; @@ -556,7 +555,7 @@ const undefgoto = function (ls, gt) { */ const addprototype = function (ls) { let L = ls.L; - let clp = new Proto(L); + let clp = new lfunc.Proto(L); let fs = ls.fs; let f = fs.f; /* prototype of current function */ f.p[fs.np++] = clp; @@ -568,8 +567,8 @@ const addprototype = function (ls) { */ const codeclosure = function (ls, v) { let fs = ls.fs.prev; - init_exp(v, expkind.VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs.np - 1)); - luaK_exp2nextreg(fs, v); /* fix it at the last register */ + init_exp(v, expkind.VRELOCABLE, lcode.luaK_codeABx(fs, OP_CLOSURE, 0, fs.np - 1)); + lcode.luaK_exp2nextreg(fs, v); /* fix it at the last register */ }; const open_func = function (ls, fs, bl) { @@ -578,7 +577,7 @@ const open_func = function (ls, fs, bl) { ls.fs = fs; fs.pc = 0; fs.lasttarget = 0; - fs.jpc = NO_JUMP; + fs.jpc = lcode.NO_JUMP; fs.freereg = 0; fs.nk = 0; fs.np = 0; @@ -598,9 +597,9 @@ const leaveblock = function (fs) { let ls = fs.ls; if (bl.previous && bl.upval) { /* create a 'jump to here' to close upvalues */ - let j = luaK_jump(fs); - luaK_patchclose(fs, j, bl.nactvar); - luaK_patchtohere(fs, j); + let j = lcode.luaK_jump(fs); + lcode.luaK_patchclose(fs, j, bl.nactvar); + lcode.luaK_patchtohere(fs, j); } if (bl.isloop) @@ -608,7 +607,7 @@ const leaveblock = function (fs) { fs.bl = bl.previous; removevars(fs, bl.nactvar); - lua_assert(bl.nactvar === fs.nactvar); + llimits.lua_assert(bl.nactvar === fs.nactvar); fs.freereg = fs.nactvar; /* free registers */ ls.dyd.label.n = bl.firstlabel; /* remove local labels */ if (bl.previous) /* inner block? */ @@ -619,9 +618,9 @@ const leaveblock = function (fs) { const close_func = function (ls) { let fs = ls.fs; - luaK_ret(fs, 0, 0); /* final return */ + lcode.luaK_ret(fs, 0, 0); /* final return */ leaveblock(fs); - lua_assert(fs.bl === null); + llimits.lua_assert(fs.bl === null); ls.fs = fs.prev; }; @@ -654,17 +653,17 @@ const fieldsel = function (ls, v) { /* fieldsel -> ['.' | ':'] NAME */ let fs = ls.fs; let key = new expdesc(); - luaK_exp2anyregup(fs, v); - luaX_next(ls); /* skip the dot or colon */ + lcode.luaK_exp2anyregup(fs, v); + llex.luaX_next(ls); /* skip the dot or colon */ checkname(ls, key); - luaK_indexed(fs, v, key); + lcode.luaK_indexed(fs, v, key); }; const yindex = function (ls, v) { /* index -> '[' expr ']' */ - luaX_next(ls); /* skip the '[' */ + llex.luaX_next(ls); /* skip the '[' */ expr(ls, v); - luaK_exp2val(ls.fs, v); + lcode.luaK_exp2val(ls.fs, v); checknext(ls, 93 /* (']').charCodeAt(0) */); }; @@ -692,24 +691,24 @@ const recfield = function (ls, cc) { let val = new expdesc(); if (ls.t.token === R.TK_NAME) { - checklimit(fs, cc.nh, MAX_INT, to_luastring('items in a constructor', true)); + checklimit(fs, cc.nh, llimits.MAX_INT, defs.to_luastring('items in a constructor', true)); checkname(ls, key); } else /* ls->t.token === '[' */ yindex(ls, key); cc.nh++; checknext(ls, 61 /* ('=').charCodeAt(0) */); - let rkkey = luaK_exp2RK(fs, key); + let rkkey = lcode.luaK_exp2RK(fs, key); expr(ls, val); - luaK_codeABC(fs, OP_SETTABLE, cc.t.u.info, rkkey, luaK_exp2RK(fs, val)); + lcode.luaK_codeABC(fs, OP_SETTABLE, cc.t.u.info, rkkey, lcode.luaK_exp2RK(fs, val)); fs.freereg = reg; /* free registers */ }; const closelistfield = function (fs, cc) { if (cc.v.k === expkind.VVOID) return; /* there is no list item */ - luaK_exp2nextreg(fs, cc.v); + lcode.luaK_exp2nextreg(fs, cc.v); cc.v.k = expkind.VVOID; - if (cc.tostore === LFIELDS_PER_FLUSH) { - luaK_setlist(fs, cc.t.u.info, cc.na, cc.tostore); /* flush */ + if (cc.tostore === lopcodes.LFIELDS_PER_FLUSH) { + lcode.luaK_setlist(fs, cc.t.u.info, cc.na, cc.tostore); /* flush */ cc.tostore = 0; /* no more items pending */ } }; @@ -717,20 +716,20 @@ const closelistfield = function (fs, cc) { const lastlistfield = function (fs, cc) { if (cc.tostore === 0) return; if (hasmultret(cc.v.k)) { - luaK_setmultret(fs, cc.v); - luaK_setlist(fs, cc.t.u.info, cc.na, LUA_MULTRET); + lcode.luaK_setmultret(fs, cc.v); + lcode.luaK_setlist(fs, cc.t.u.info, cc.na, defs.LUA_MULTRET); cc.na--; /* do not count last expression (unknown number of elements) */ } else { if (cc.v.k !== expkind.VVOID) - luaK_exp2nextreg(fs, cc.v); - luaK_setlist(fs, cc.t.u.info, cc.na, cc.tostore); + lcode.luaK_exp2nextreg(fs, cc.v); + lcode.luaK_setlist(fs, cc.t.u.info, cc.na, cc.tostore); } }; const listfield = function (ls, cc) { /* listfield -> exp */ expr(ls, cc.v); - checklimit(ls.fs, cc.na, MAX_INT, to_luastring('items in a constructor', true)); + checklimit(ls.fs, cc.na, llimits.MAX_INT, defs.to_luastring('items in a constructor', true)); cc.na++; cc.tostore++; }; @@ -739,7 +738,7 @@ const field = function (ls, cc) { /* field -> listfield | recfield */ switch (ls.t.token) { case R.TK_NAME: { /* may be 'listfield' or 'recfield' */ - if (luaX_lookahead(ls) !== 61 /* ('=').charCodeAt(0) */) /* expression? */ + if (llex.luaX_lookahead(ls) !== 61 /* ('=').charCodeAt(0) */) /* expression? */ listfield(ls, cc); else recfield(ls, cc); @@ -761,24 +760,24 @@ const constructor = function (ls, t) { sep -> ',' | ';' */ let fs = ls.fs; let line = ls.linenumber; - let pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + let pc = lcode.luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); let cc = new ConsControl(); cc.na = cc.nh = cc.tostore = 0; cc.t = t; init_exp(t, expkind.VRELOCABLE, pc); init_exp(cc.v, expkind.VVOID, 0); /* no value (yet) */ - luaK_exp2nextreg(ls.fs, t); /* fix it at stack top */ + lcode.luaK_exp2nextreg(ls.fs, t); /* fix it at stack top */ checknext(ls, 123 /* ('{').charCodeAt(0) */); do { - lua_assert(cc.v.k === expkind.VVOID || cc.tostore > 0); + llimits.lua_assert(cc.v.k === expkind.VVOID || cc.tostore > 0); if (ls.t.token === 125 /* ('}').charCodeAt(0) */) break; closelistfield(fs, cc); field(ls, cc); } while (testnext(ls, 44 /* (',').charCodeAt(0) */) || testnext(ls, 59 /* (';').charCodeAt(0) */)); check_match(ls, 125 /* ('}').charCodeAt(0) */, 123 /* ('{').charCodeAt(0) */, line); lastlistfield(fs, cc); - SETARG_B(fs.f.code[pc], luaO_int2fb(cc.na)); /* set initial array size */ - SETARG_C(fs.f.code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ + lopcodes.SETARG_B(fs.f.code[pc], lobject.luaO_int2fb(cc.na)); /* set initial array size */ + lopcodes.SETARG_C(fs.f.code[pc], lobject.luaO_int2fb(cc.nh)); /* set initial table size */ }; /* }====================================================================== */ @@ -798,17 +797,17 @@ const parlist = function (ls) { break; } case R.TK_DOTS: { /* param -> '...' */ - luaX_next(ls); + llex.luaX_next(ls); f.is_vararg = true; /* declared vararg */ break; } - default: luaX_syntaxerror(ls, to_luastring(' or \'...\' expected', true)); + default: llex.luaX_syntaxerror(ls, defs.to_luastring(' or \'...\' expected', true)); } } while (!f.is_vararg && testnext(ls, 44 /* (',').charCodeAt(0) */)); } adjustlocalvars(ls, nparams); f.numparams = fs.nactvar; - luaK_reserveregs(fs, fs.nactvar); /* reserve register for parameters */ + lcode.luaK_reserveregs(fs, fs.nactvar); /* reserve register for parameters */ }; const body = function (ls, e, ismethod, line) { @@ -837,7 +836,7 @@ const explist = function (ls, v) { let n = 1; /* at least one expression */ expr(ls, v); while (testnext(ls, 44 /* (',').charCodeAt(0) */)) { - luaK_exp2nextreg(ls.fs, v); + lcode.luaK_exp2nextreg(ls.fs, v); expr(ls, v); n++; } @@ -849,12 +848,12 @@ const funcargs = function (ls, f, line) { let args = new expdesc(); switch (ls.t.token) { case 40 /* ('(').charCodeAt(0) */: { /* funcargs -> '(' [ explist ] ')' */ - luaX_next(ls); + llex.luaX_next(ls); if (ls.t.token === 41 /* (')').charCodeAt(0) */) /* arg list is empty? */ args.k = expkind.VVOID; else { explist(ls, args); - luaK_setmultret(fs, args); + lcode.luaK_setmultret(fs, args); } check_match(ls, 41 /* (')').charCodeAt(0) */, 40 /* ('(').charCodeAt(0) */, line); break; @@ -865,25 +864,25 @@ const funcargs = function (ls, f, line) { } case R.TK_STRING: { /* funcargs -> STRING */ codestring(ls, args, ls.t.seminfo.ts); - luaX_next(ls); /* must use 'seminfo' before 'next' */ + llex.luaX_next(ls); /* must use 'seminfo' before 'next' */ break; } default: { - luaX_syntaxerror(ls, to_luastring('function arguments expected', true)); + llex.luaX_syntaxerror(ls, defs.to_luastring('function arguments expected', true)); } } - lua_assert(f.k === expkind.VNONRELOC); + llimits.lua_assert(f.k === expkind.VNONRELOC); let nparams; let base = f.u.info; /* base register for call */ if (hasmultret(args.k)) - nparams = LUA_MULTRET; /* open call */ + nparams = defs.LUA_MULTRET; /* open call */ else { if (args.k !== expkind.VVOID) - luaK_exp2nextreg(fs, args); /* close last argument */ + lcode.luaK_exp2nextreg(fs, args); /* close last argument */ nparams = fs.freereg - (base + 1); } - init_exp(f, expkind.VCALL, luaK_codeABC(fs, OP_CALL, base, nparams + 1, 2)); - luaK_fixline(fs, line); + init_exp(f, expkind.VCALL, lcode.luaK_codeABC(fs, OP_CALL, base, nparams + 1, 2)); + lcode.luaK_fixline(fs, line); fs.freereg = base + 1; /* call remove function and arguments and leaves (unless changed) one result */ }; @@ -898,10 +897,10 @@ const primaryexp = function (ls, v) { switch (ls.t.token) { case 40 /* ('(').charCodeAt(0) */: { let line = ls.linenumber; - luaX_next(ls); + llex.luaX_next(ls); expr(ls, v); check_match(ls, 41 /* (')').charCodeAt(0) */, 40 /* ('(').charCodeAt(0) */, line); - luaK_dischargevars(ls.fs, v); + lcode.luaK_dischargevars(ls.fs, v); return; } case R.TK_NAME: { @@ -909,7 +908,7 @@ const primaryexp = function (ls, v) { return; } default: { - luaX_syntaxerror(ls, to_luastring('unexpected symbol', true)); + llex.luaX_syntaxerror(ls, defs.to_luastring('unexpected symbol', true)); } } }; @@ -928,21 +927,21 @@ const suffixedexp = function (ls, v) { } case 91 /* ('[').charCodeAt(0) */: { /* '[' exp1 ']' */ let key = new expdesc(); - luaK_exp2anyregup(fs, v); + lcode.luaK_exp2anyregup(fs, v); yindex(ls, key); - luaK_indexed(fs, v, key); + lcode.luaK_indexed(fs, v, key); break; } case 58 /* (':').charCodeAt(0) */: { /* ':' NAME funcargs */ let key = new expdesc(); - luaX_next(ls); + llex.luaX_next(ls); checkname(ls, key); - luaK_self(fs, v, key); + lcode.luaK_self(fs, v, key); funcargs(ls, v, line); break; } case 40 /* ('(').charCodeAt(0) */: case R.TK_STRING: case 123 /* ('{').charCodeAt(0) */: { /* funcargs */ - luaK_exp2nextreg(fs, v); + lcode.luaK_exp2nextreg(fs, v); funcargs(ls, v, line); break; } @@ -983,8 +982,8 @@ const simpleexp = function (ls, v) { } case R.TK_DOTS: { /* vararg */ let fs = ls.fs; - check_condition(ls, fs.f.is_vararg, to_luastring('cannot use \'...\' outside a vararg function', true)); - init_exp(v, expkind.VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + check_condition(ls, fs.f.is_vararg, defs.to_luastring('cannot use \'...\' outside a vararg function', true)); + init_exp(v, expkind.VVARARG, lcode.luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } case 123 /* ('{').charCodeAt(0) */: { /* constructor */ @@ -992,7 +991,7 @@ const simpleexp = function (ls, v) { return; } case R.TK_FUNCTION: { - luaX_next(ls); + llex.luaX_next(ls); body(ls, v, 0, ls.linenumber); return; } @@ -1001,7 +1000,7 @@ const simpleexp = function (ls, v) { return; } } - luaX_next(ls); + llex.luaX_next(ls); }; const getunopr = function (op) { @@ -1065,9 +1064,9 @@ const subexpr = function (ls, v, limit) { let uop = getunopr(ls.t.token); if (uop !== OPR_NOUNOPR) { let line = ls.linenumber; - luaX_next(ls); + llex.luaX_next(ls); subexpr(ls, v, UNARY_PRIORITY); - luaK_prefix(ls.fs, uop, v, line); + lcode.luaK_prefix(ls.fs, uop, v, line); } else simpleexp(ls, v); /* expand while operators have priorities higher than 'limit' */ @@ -1075,11 +1074,11 @@ const subexpr = function (ls, v, limit) { while (op !== OPR_NOBINOPR && priority[op].left > limit) { let v2 = new expdesc(); let line = ls.linenumber; - luaX_next(ls); - luaK_infix(ls.fs, op, v); + llex.luaX_next(ls); + lcode.luaK_infix(ls.fs, op, v); /* read sub-expression with higher priority */ let nextop = subexpr(ls, v2, priority[op].right); - luaK_posfix(ls.fs, op, v, v2, line); + lcode.luaK_posfix(ls.fs, op, v, v2, line); op = nextop; } leavelevel(ls); @@ -1148,21 +1147,21 @@ const check_conflict = function (ls, lh, v) { if (conflict) { /* copy upvalue/local value to a temporary (in position 'extra') */ let op = v.k === expkind.VLOCAL ? OP_MOVE : OP_GETUPVAL; - luaK_codeABC(fs, op, extra, v.u.info, 0); - luaK_reserveregs(fs, 1); + lcode.luaK_codeABC(fs, op, extra, v.u.info, 0); + lcode.luaK_reserveregs(fs, 1); } }; const assignment = function (ls, lh, nvars) { let e = new expdesc(); - check_condition(ls, vkisvar(lh.v.k), to_luastring('syntax error', true)); + check_condition(ls, vkisvar(lh.v.k), defs.to_luastring('syntax error', true)); if (testnext(ls, 44 /* (',').charCodeAt(0) */)) { /* assignment -> ',' suffixedexp assignment */ let nv = new LHS_assign(); nv.prev = lh; suffixedexp(ls, nv.v); if (nv.v.k !== expkind.VINDEXED) check_conflict(ls, lh, nv.v); - checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring('JS levels', true)); + checklimit(ls.fs, nvars + ls.L.nCcalls, llimits.LUAI_MAXCCALLS, defs.to_luastring('JS levels', true)); assignment(ls, nv, nvars + 1); } else { /* assignment -> '=' explist */ checknext(ls, 61 /* ('=').charCodeAt(0) */); @@ -1170,13 +1169,13 @@ const assignment = function (ls, lh, nvars) { if (nexps !== nvars) adjust_assign(ls, nvars, nexps, e); else { - luaK_setoneret(ls.fs, e); /* close last expression */ - luaK_storevar(ls.fs, lh.v, e); + lcode.luaK_setoneret(ls.fs, e); /* close last expression */ + lcode.luaK_storevar(ls.fs, lh.v, e); return; /* avoid default */ } } init_exp(e, expkind.VNONRELOC, ls.fs.freereg - 1); /* default assignment */ - luaK_storevar(ls.fs, lh.v, e); + lcode.luaK_storevar(ls.fs, lh.v, e); }; const cond = function (ls) { @@ -1184,7 +1183,7 @@ const cond = function (ls) { let v = new expdesc(); expr(ls, v); /* read condition */ if (v.k === expkind.VNIL) v.k = expkind.VFALSE; /* 'falses' are all equal here */ - luaK_goiftrue(ls.fs, v); + lcode.luaK_goiftrue(ls.fs, v); return v.f; }; @@ -1194,8 +1193,8 @@ const gotostat = function (ls, pc) { if (testnext(ls, R.TK_GOTO)) label = str_checkname(ls); else { - luaX_next(ls); /* skip break */ - label = luaS_newliteral(ls.L, 'break'); + llex.luaX_next(ls); /* skip break */ + label = lstring.luaS_newliteral(ls.L, 'break'); } let g = newlabelentry(ls, ls.dyd.gt, label, line, pc); findlabel(ls, g); /* close it if label already defined */ @@ -1205,8 +1204,8 @@ const gotostat = function (ls, pc) { const checkrepeated = function (fs, ll, label) { for (let i = fs.bl.firstlabel; i < ll.n; i++) { if (eqstr(label, ll.arr[i].name)) { - let msg = luaO_pushfstring(fs.ls.L, - to_luastring('label \'%s\' already defined on line %d', true), + let msg = lobject.luaO_pushfstring(fs.ls.L, + defs.to_luastring('label \'%s\' already defined on line %d', true), label.getstr(), ll.arr[i].line); semerror(fs.ls, msg); } @@ -1227,7 +1226,7 @@ const labelstat = function (ls, label, line) { checkrepeated(fs, ll, label); /* check for repeated labels */ checknext(ls, R.TK_DBCOLON); /* skip double colon */ /* create new entry for this label */ - l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs)); + l = newlabelentry(ls, ll, label, line, lcode.luaK_getlabel(fs)); skipnoopstat(ls); /* skip other no-op statements */ if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ /* assume that locals are already out of scope */ @@ -1240,42 +1239,42 @@ const whilestat = function (ls, line) { /* whilestat -> WHILE cond DO block END */ let fs = ls.fs; let bl = new BlockCnt(); - luaX_next(ls); /* skip WHILE */ - let whileinit = luaK_getlabel(fs); + llex.luaX_next(ls); /* skip WHILE */ + let whileinit = lcode.luaK_getlabel(fs); let condexit = cond(ls); enterblock(fs, bl, 1); checknext(ls, R.TK_DO); block(ls); - luaK_jumpto(fs, whileinit); + lcode.luaK_jumpto(fs, whileinit); check_match(ls, R.TK_END, R.TK_WHILE, line); leaveblock(fs); - luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ + lcode.luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ }; const repeatstat = function (ls, line) { /* repeatstat -> REPEAT block UNTIL cond */ let fs = ls.fs; - let repeat_init = luaK_getlabel(fs); + let repeat_init = lcode.luaK_getlabel(fs); let bl1 = new BlockCnt(); let bl2 = new BlockCnt(); enterblock(fs, bl1, 1); /* loop block */ enterblock(fs, bl2, 0); /* scope block */ - luaX_next(ls); /* skip REPEAT */ + llex.luaX_next(ls); /* skip REPEAT */ statlist(ls); check_match(ls, R.TK_UNTIL, R.TK_REPEAT, line); let condexit = cond(ls); /* read condition (inside scope block) */ if (bl2.upval) /* upvalues? */ - luaK_patchclose(fs, condexit, bl2.nactvar); + lcode.luaK_patchclose(fs, condexit, bl2.nactvar); leaveblock(fs); /* finish scope */ - luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ + lcode.luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ leaveblock(fs); /* finish loop */ }; const exp1 = function (ls) { let e = new expdesc(); expr(ls, e); - luaK_exp2nextreg(ls.fs, e); - lua_assert(e.k === expkind.VNONRELOC); + lcode.luaK_exp2nextreg(ls.fs, e); + llimits.lua_assert(e.k === expkind.VNONRELOC); let reg = e.u.info; return reg; }; @@ -1287,22 +1286,22 @@ const forbody = function (ls, base, line, nvars, isnum) { let endfor; adjustlocalvars(ls, 3); /* control variables */ checknext(ls, R.TK_DO); - let prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + let prep = isnum ? lcode.luaK_codeAsBx(fs, OP_FORPREP, base, lcode.NO_JUMP) : lcode.luaK_jump(fs); enterblock(fs, bl, 0); /* scope for declared variables */ adjustlocalvars(ls, nvars); - luaK_reserveregs(fs, nvars); + lcode.luaK_reserveregs(fs, nvars); block(ls); leaveblock(fs); /* end of scope for declared variables */ - luaK_patchtohere(fs, prep); + lcode.luaK_patchtohere(fs, prep); if (isnum) /* end of scope for declared variables */ - endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); + endfor = lcode.luaK_codeAsBx(fs, OP_FORLOOP, base, lcode.NO_JUMP); else { /* generic for */ - luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); - luaK_fixline(fs, line); - endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); + lcode.luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); + lcode.luaK_fixline(fs, line); + endfor = lcode.luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, lcode.NO_JUMP); } - luaK_patchlist(fs, endfor, prep + 1); - luaK_fixline(fs, line); + lcode.luaK_patchlist(fs, endfor, prep + 1); + lcode.luaK_fixline(fs, line); }; const fornum = function (ls, varname, line) { @@ -1320,8 +1319,8 @@ const fornum = function (ls, varname, line) { if (testnext(ls, 44 /* (',').charCodeAt(0) */)) exp1(ls); /* optional step */ else { /* default step = 1 */ - luaK_codek(fs, fs.freereg, luaK_intK(fs, 1)); - luaK_reserveregs(fs, 1); + lcode.luaK_codek(fs, fs.freereg, lcode.luaK_intK(fs, 1)); + lcode.luaK_reserveregs(fs, 1); } forbody(ls, base, line, 1, 1); }; @@ -1345,7 +1344,7 @@ const forlist = function (ls, indexname) { checknext(ls, R.TK_IN); let line = ls.linenumber; adjust_assign(ls, 3, explist(ls, e), e); - luaK_checkstack(fs, 3); /* extra space to call generator */ + lcode.luaK_checkstack(fs, 3); /* extra space to call generator */ forbody(ls, base, line, nvars - 3, 0); }; @@ -1354,12 +1353,12 @@ const forstat = function (ls, line) { let fs = ls.fs; let bl = new BlockCnt(); enterblock(fs, bl, 1); /* scope for loop and control variables */ - luaX_next(ls); /* skip 'for' */ + llex.luaX_next(ls); /* skip 'for' */ let varname = str_checkname(ls); /* first variable name */ switch (ls.t.token) { case 61 /* ('=').charCodeAt(0) */: fornum(ls, varname, line); break; case 44 /* (',').charCodeAt(0) */: case R.TK_IN: forlist(ls, varname); break; - default: luaX_syntaxerror(ls, to_luastring('\'=\' or \'in\' expected', true)); + default: llex.luaX_syntaxerror(ls, defs.to_luastring('\'=\' or \'in\' expected', true)); } check_match(ls, R.TK_END, R.TK_FOR, line); leaveblock(fs); /* loop scope ('break' jumps to this point) */ @@ -1372,12 +1371,12 @@ const test_then_block = function (ls, escapelist) { let v = new expdesc(); let jf; /* instruction to skip 'then' code (if condition is false) */ - luaX_next(ls); /* skip IF or ELSEIF */ + llex.luaX_next(ls); /* skip IF or ELSEIF */ expr(ls, v); /* read condition */ checknext(ls, R.TK_THEN); if (ls.t.token === R.TK_GOTO || ls.t.token === R.TK_BREAK) { - luaK_goiffalse(ls.fs, v); /* will jump to label if condition is true */ + lcode.luaK_goiffalse(ls.fs, v); /* will jump to label if condition is true */ enterblock(fs, bl, false); /* must enter block before 'goto' */ gotostat(ls, v.t); /* handle goto/break */ while (testnext(ls, 59 /* (';').charCodeAt(0) */)); /* skip colons */ @@ -1385,9 +1384,9 @@ const test_then_block = function (ls, escapelist) { leaveblock(fs); return escapelist; /* and that is it */ } else /* must skip over 'then' part if condition is false */ - jf = luaK_jump(fs); + jf = lcode.luaK_jump(fs); } else { /* regular case (not goto/break) */ - luaK_goiftrue(ls.fs, v); /* skip over block if condition is false */ + lcode.luaK_goiftrue(ls.fs, v); /* skip over block if condition is false */ enterblock(fs, bl, false); jf = v.f; } @@ -1395,8 +1394,8 @@ const test_then_block = function (ls, escapelist) { statlist(ls); /* 'then' part */ leaveblock(fs); if (ls.t.token === R.TK_ELSE || ls.t.token === R.TK_ELSEIF) /* followed by 'else'/'elseif'? */ - escapelist = luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */ - luaK_patchtohere(fs, jf); + escapelist = lcode.luaK_concat(fs, escapelist, lcode.luaK_jump(fs)); /* must jump over it */ + lcode.luaK_patchtohere(fs, jf); return escapelist; }; @@ -1404,14 +1403,14 @@ const test_then_block = function (ls, escapelist) { const ifstat = function (ls, line) { /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ let fs = ls.fs; - let escapelist = NO_JUMP; /* exit list for finished parts */ + let escapelist = lcode.NO_JUMP; /* exit list for finished parts */ escapelist = test_then_block(ls, escapelist); /* IF cond THEN block */ while (ls.t.token === R.TK_ELSEIF) escapelist = test_then_block(ls, escapelist); /* ELSEIF cond THEN block */ if (testnext(ls, R.TK_ELSE)) block(ls); /* 'else' part */ check_match(ls, R.TK_END, R.TK_IF, line); - luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ + lcode.luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ }; const localfunc = function (ls) { @@ -1460,11 +1459,11 @@ const funcstat = function (ls, line) { /* funcstat -> FUNCTION funcname body */ let v = new expdesc(); let b = new expdesc(); - luaX_next(ls); /* skip FUNCTION */ + llex.luaX_next(ls); /* skip FUNCTION */ let ismethod = funcname(ls, v); body(ls, b, ismethod, line); - luaK_storevar(ls.fs, v, b); - luaK_fixline(ls.fs, line); /* definition "happens" in the first line */ + lcode.luaK_storevar(ls.fs, v, b); + lcode.luaK_fixline(ls.fs, line); /* definition "happens" in the first line */ }; const exprstat = function (ls) { @@ -1477,8 +1476,8 @@ const exprstat = function (ls) { assignment(ls, v, 1); } else { /* stat -> func */ - check_condition(ls, v.v.k === expkind.VCALL, to_luastring('syntax error', true)); - SETARG_C(getinstruction(fs, v.v), 1); /* call statement uses no results */ + check_condition(ls, v.v.k === expkind.VCALL, defs.to_luastring('syntax error', true)); + lopcodes.SETARG_C(lcode.getinstruction(fs, v.v), 1); /* call statement uses no results */ } }; @@ -1492,24 +1491,24 @@ const retstat = function (ls) { else { nret = explist(ls, e); /* optional return values */ if (hasmultret(e.k)) { - luaK_setmultret(fs, e); + lcode.luaK_setmultret(fs, e); if (e.k === expkind.VCALL && nret === 1) { /* tail call? */ - SET_OPCODE(getinstruction(fs, e), OP_TAILCALL); - lua_assert(getinstruction(fs, e).A === fs.nactvar); + lopcodes.SET_OPCODE(lcode.getinstruction(fs, e), OP_TAILCALL); + llimits.lua_assert(lcode.getinstruction(fs, e).A === fs.nactvar); } first = fs.nactvar; - nret = LUA_MULTRET; /* return all values */ + nret = defs.LUA_MULTRET; /* return all values */ } else { if (nret === 1) /* only one single value? */ - first = luaK_exp2anyreg(fs, e); + first = lcode.luaK_exp2anyreg(fs, e); else { - luaK_exp2nextreg(fs, e); /* values must go to the stack */ + lcode.luaK_exp2nextreg(fs, e); /* values must go to the stack */ first = fs.nactvar; /* return all active values */ - lua_assert(nret === fs.freereg - first); + llimits.lua_assert(nret === fs.freereg - first); } } } - luaK_ret(fs, first, nret); + lcode.luaK_ret(fs, first, nret); testnext(ls, 59 /* (';').charCodeAt(0) */); /* skip optional semicolon */ }; @@ -1518,7 +1517,7 @@ const statement = function (ls) { enterlevel(ls); switch (ls.t.token) { case 59 /* (';').charCodeAt(0) */: { /* stat -> ';' (empty statement) */ - luaX_next(ls); /* skip ';' */ + llex.luaX_next(ls); /* skip ';' */ break; } case R.TK_IF: { /* stat -> ifstat */ @@ -1530,7 +1529,7 @@ const statement = function (ls) { break; } case R.TK_DO: { /* stat -> DO block END */ - luaX_next(ls); /* skip DO */ + llex.luaX_next(ls); /* skip DO */ block(ls); check_match(ls, R.TK_END, R.TK_DO, line); break; @@ -1548,7 +1547,7 @@ const statement = function (ls) { break; } case R.TK_LOCAL: { /* stat -> localstat */ - luaX_next(ls); /* skip LOCAL */ + llex.luaX_next(ls); /* skip LOCAL */ if (testnext(ls, R.TK_FUNCTION)) /* local function? */ localfunc(ls); else @@ -1556,18 +1555,18 @@ const statement = function (ls) { break; } case R.TK_DBCOLON: { /* stat -> label */ - luaX_next(ls); /* skip double colon */ + llex.luaX_next(ls); /* skip double colon */ labelstat(ls, str_checkname(ls), line); break; } case R.TK_RETURN: { /* skip double colon */ - luaX_next(ls); /* skip RETURN */ + llex.luaX_next(ls); /* skip RETURN */ retstat(ls); break; } case R.TK_BREAK: /* stat -> breakstat */ case R.TK_GOTO: { /* stat -> 'goto' NAME */ - gotostat(ls, luaK_jump(ls.fs)); + gotostat(ls, lcode.luaK_jump(ls.fs)); break; } default: { /* stat -> func | assignment */ @@ -1575,7 +1574,7 @@ const statement = function (ls) { break; } } - lua_assert(ls.fs.f.maxstacksize >= ls.fs.freereg && ls.fs.freereg >= ls.fs.nactvar); + llimits.lua_assert(ls.fs.f.maxstacksize >= ls.fs.freereg && ls.fs.freereg >= ls.fs.nactvar); ls.fs.freereg = ls.fs.nactvar; /* free registers */ leavelevel(ls); }; @@ -1591,43 +1590,31 @@ const mainfunc = function (ls, fs) { fs.f.is_vararg = true; /* main function is always declared vararg */ init_exp(v, expkind.VLOCAL, 0); /* create and... */ newupvalue(fs, ls.envn, v); /* ...set environment upvalue */ - luaX_next(ls); /* read first token */ + llex.luaX_next(ls); /* read first token */ statlist(ls); /* parse main body */ check(ls, R.TK_EOS); close_func(ls); }; -const luaY_parser = function (L, z, buff, dyd, name, firstchar) { - let lexstate = new LexState(); +export const luaY_parser = function (L, z, buff, dyd, name, firstchar) { + let lexstate = new llex.LexState(); let funcstate = new FuncState(); - let cl = luaF_newLclosure(L, 1); /* create main closure */ - luaD_inctop(L); + let cl = lfunc.luaF_newLclosure(L, 1); /* create main closure */ + ldo.luaD_inctop(L); L.stack[L.top - 1].setclLvalue(cl); - lexstate.h = luaH_new(L); /* create table for scanner */ - luaD_inctop(L); + lexstate.h = ltable.luaH_new(L); /* create table for scanner */ + ldo.luaD_inctop(L); L.stack[L.top - 1].sethvalue(lexstate.h); - funcstate.f = cl.p = new Proto(L); - funcstate.f.source = luaS_new(L, name); + funcstate.f = cl.p = new lfunc.Proto(L); + funcstate.f.source = lstring.luaS_new(L, name); lexstate.buff = buff; lexstate.dyd = dyd; dyd.actvar.n = dyd.gt.n = dyd.label.n = 0; - luaX_setinput(L, lexstate, z, funcstate.f.source, firstchar); + llex.luaX_setinput(L, lexstate, z, funcstate.f.source, firstchar); mainfunc(lexstate, funcstate); - lua_assert(!funcstate.prev && funcstate.nups === 1 && !lexstate.fs); + llimits.lua_assert(!funcstate.prev && funcstate.nups === 1 && !lexstate.fs); /* all scopes should be correctly finished */ - lua_assert(dyd.actvar.n === 0 && dyd.gt.n === 0 && dyd.label.n === 0); + llimits.lua_assert(dyd.actvar.n === 0 && dyd.gt.n === 0 && dyd.label.n === 0); delete L.stack[--L.top]; /* remove scanner's table */ return cl; /* closure is on the stack, too */ }; - - -const _Dyndata = Dyndata; -export { _Dyndata as Dyndata }; -const _expkind = expkind; -export { _expkind as expkind }; -const _expdesc = expdesc; -export { _expdesc as expdesc }; -const _luaY_parser = luaY_parser; -export { _luaY_parser as luaY_parser }; -const _vkisinreg = vkisinreg; -export { _vkisinreg as vkisinreg }; diff --git a/src/lstate.js b/src/lstate.js index 261a510f..96de669f 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -1,26 +1,26 @@ -import { LUA_MINSTACK, LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD, constant_types, thread_status } from './defs.js'; -import { TValue } from './lobject.js'; -import { luaD_rawrunprotected } from './ldo.js'; -import { lua_version, api_incr_top } from './lapi.js'; -import { luaH_new, luaH_setint } from './ltable.js'; -import { TMS, luaT_init } from './ltm.js'; - -const { +import * as defs from './defs.js'; +import * as lobject from './lobject.js'; +import * as ldo from './ldo.js'; +import * as lapi from './lapi.js'; +import * as ltable from './ltable.js'; +import * as ltm from './ltm.js'; + +export const { LUA_NUMTAGS, LUA_TNIL, LUA_TTABLE, LUA_TTHREAD -} = constant_types; +} = defs.constant_types; -const { +export const { LUA_OK -} = thread_status; +} = defs.thread_status; -const EXTRA_STACK = 5; +export const EXTRA_STACK = 5; -const BASIC_STACK_SIZE = 2 * LUA_MINSTACK; +export const BASIC_STACK_SIZE = 2 * defs.LUA_MINSTACK; -class CallInfo { +export class CallInfo { constructor() { this.func = null; @@ -44,7 +44,7 @@ class CallInfo { } -class lua_State { +export class lua_State { constructor(g) { this.id = g.id_counter++; @@ -72,24 +72,24 @@ class lua_State { } -class global_State { +export class global_State { constructor() { this.id_counter = 1; /* used to give objects unique ids */ this.ids = new WeakMap(); this.mainthread = null; - this.l_registry = new TValue(LUA_TNIL, null); + this.l_registry = new lobject.TValue(LUA_TNIL, null); this.panic = null; this.atnativeerror = null; this.version = null; - this.tmname = new Array(TMS.TM_N); + this.tmname = new Array(ltm.TMS.TM_N); this.mt = new Array(LUA_NUMTAGS); } } -const luaE_extendCI = function (L) { +export const luaE_extendCI = function (L) { let ci = new CallInfo(); L.ci.next = ci; ci.previous = L.ci; @@ -98,12 +98,12 @@ const luaE_extendCI = function (L) { return ci; }; -const luaE_freeCI = function (L) { +export const luaE_freeCI = function (L) { let ci = L.ci; ci.next = null; }; -const stack_init = function (L1, L) { +export const stack_init = function (L1, _L) { L1.stack = new Array(BASIC_STACK_SIZE); L1.top = 0; L1.stack_last = BASIC_STACK_SIZE - EXTRA_STACK; @@ -113,12 +113,12 @@ const stack_init = function (L1, L) { ci.callstatus = 0; ci.funcOff = L1.top; ci.func = L1.stack[L1.top]; - L1.stack[L1.top++] = new TValue(LUA_TNIL, null); - ci.top = L1.top + LUA_MINSTACK; + L1.stack[L1.top++] = new lobject.TValue(LUA_TNIL, null); + ci.top = L1.top + defs.LUA_MINSTACK; L1.ci = ci; }; -const freestack = function (L) { +export const freestack = function (L) { L.ci = L.base_ci; luaE_freeCI(L); L.stack = null; @@ -127,30 +127,30 @@ const freestack = function (L) { /* ** Create registry table and its predefined values */ -const init_registry = function (L, g) { - let registry = luaH_new(L); +export const init_registry = function (L, g) { + let registry = ltable.luaH_new(L); g.l_registry.sethvalue(registry); - luaH_setint(registry, LUA_RIDX_MAINTHREAD, new TValue(LUA_TTHREAD, L)); - luaH_setint(registry, LUA_RIDX_GLOBALS, new TValue(LUA_TTABLE, luaH_new(L))); + ltable.luaH_setint(registry, defs.LUA_RIDX_MAINTHREAD, new lobject.TValue(LUA_TTHREAD, L)); + ltable.luaH_setint(registry, defs.LUA_RIDX_GLOBALS, new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L))); }; /* ** open parts of the state that may cause memory-allocation errors. ** ('g->version' !== NULL flags that the state was completely build) */ -const f_luaopen = function (L) { +export const f_luaopen = function (L) { let g = L.l_G; stack_init(L, L); init_registry(L, g); - luaT_init(L); - g.version = lua_version(null); + ltm.luaT_init(L); + g.version = lapi.lua_version(null); }; -const lua_newthread = function (L) { +export const lua_newthread = function (L) { let g = L.l_G; let L1 = new lua_State(g); - L.stack[L.top] = new TValue(LUA_TTHREAD, L1); - api_incr_top(L); + L.stack[L.top] = new lobject.TValue(LUA_TTHREAD, L1); + lapi.api_incr_top(L); L1.hookmask = L.hookmask; L1.basehookcount = L.basehookcount; L1.hook = L.hook; @@ -159,35 +159,31 @@ const lua_newthread = function (L) { return L1; }; -const luaE_freethread = function (L, L1) { +export const luaE_freethread = function (L, L1) { freestack(L1); }; -const lua_newstate = function () { +export const lua_newstate = function () { let g = new global_State(); let L = new lua_State(g); g.mainthread = L; - if (luaD_rawrunprotected(L, f_luaopen, null) !== LUA_OK) { + if (ldo.luaD_rawrunprotected(L, f_luaopen, null) !== LUA_OK) { L = null; } return L; }; -const close_state = function (L) { +export const close_state = function (L) { freestack(L); }; -const lua_close = function (L) { +export const lua_close = function (L) { L = L.l_G.mainthread; /* only the main thread can be closed */ close_state(L); }; -const _lua_State = lua_State; -export { _lua_State as lua_State }; -const _CallInfo = CallInfo; -export { _CallInfo as CallInfo }; export const CIST_OAH = (1 << 0); /* original value of 'allowhook' */ export const CIST_LUA = (1 << 1); /* call is running a Lua function */ export const CIST_HOOKED = (1 << 2); /* call is running a debug hook */ @@ -197,17 +193,3 @@ export const CIST_TAIL = (1 << 5); /* call was tail called */ export const CIST_HOOKYIELD = (1 << 6); /* last hook called yielded */ export const CIST_LEQ = (1 << 7); /* using __lt for __le */ export const CIST_FIN = (1 << 8); /* call is running a finalizer */ -const _EXTRA_STACK = EXTRA_STACK; -export { _EXTRA_STACK as EXTRA_STACK }; -const _lua_close = lua_close; -export { _lua_close as lua_close }; -const _lua_newstate = lua_newstate; -export { _lua_newstate as lua_newstate }; -const _lua_newthread = lua_newthread; -export { _lua_newthread as lua_newthread }; -const _luaE_extendCI = luaE_extendCI; -export { _luaE_extendCI as luaE_extendCI }; -const _luaE_freeCI = luaE_freeCI; -export { _luaE_freeCI as luaE_freeCI }; -const _luaE_freethread = luaE_freethread; -export { _luaE_freethread as luaE_freethread }; diff --git a/src/lstring.js b/src/lstring.js index 0417dde7..f2215357 100644 --- a/src/lstring.js +++ b/src/lstring.js @@ -1,7 +1,7 @@ -import { is_luastring, luastring_eq, luastring_from, to_luastring } from './defs.js'; -import { lua_assert } from './llimits.js'; +import * as defs from './defs.js'; +import * as llimits from './llimits.js'; -class TString { +export class TString { constructor(L, str) { this.hash = null; @@ -18,16 +18,16 @@ class TString { } -const luaS_eqlngstr = function (a, b) { - lua_assert(a instanceof TString); - lua_assert(b instanceof TString); - return a == b || luastring_eq(a.realstring, b.realstring); +export const luaS_eqlngstr = function (a, b) { + llimits.lua_assert(a instanceof TString); + llimits.lua_assert(b instanceof TString); + return a == b || defs.luastring_eq(a.realstring, b.realstring); }; /* converts strings (arrays) to a consistent map key make sure this doesn't conflict with any of the anti-collision strategies in ltable */ -const luaS_hash = function (str) { - lua_assert(is_luastring(str)); +export const luaS_hash = function (str) { + llimits.lua_assert(defs.is_luastring(str)); let len = str.length; let s = '|'; for (let i = 0; i < len; i++) @@ -35,8 +35,8 @@ const luaS_hash = function (str) { return s; }; -const luaS_hashlongstr = function (ts) { - lua_assert(ts instanceof TString); +export const luaS_hashlongstr = function (ts) { + llimits.lua_assert(ts instanceof TString); if (ts.hash === null) { ts.hash = luaS_hash(ts.getstr()); } @@ -44,32 +44,17 @@ const luaS_hashlongstr = function (ts) { }; /* variant that takes ownership of array */ -const luaS_bless = function (L, str) { - lua_assert(str instanceof Uint8Array); +export const luaS_bless = function (L, str) { + llimits.lua_assert(str instanceof Uint8Array); return new TString(L, str); }; /* makes a copy */ -const luaS_new = function (L, str) { - return luaS_bless(L, luastring_from(str)); +export const luaS_new = function (L, str) { + return luaS_bless(L, defs.luastring_from(str)); }; /* takes a js string */ -const luaS_newliteral = function (L, str) { - return luaS_bless(L, to_luastring(str)); +export const luaS_newliteral = function (L, str) { + return luaS_bless(L, defs.to_luastring(str)); }; - -const _luaS_eqlngstr = luaS_eqlngstr; -export { _luaS_eqlngstr as luaS_eqlngstr }; -const _luaS_hash = luaS_hash; -export { _luaS_hash as luaS_hash }; -const _luaS_hashlongstr = luaS_hashlongstr; -export { _luaS_hashlongstr as luaS_hashlongstr }; -const _luaS_bless = luaS_bless; -export { _luaS_bless as luaS_bless }; -const _luaS_new = luaS_new; -export { _luaS_new as luaS_new }; -const _luaS_newliteral = luaS_newliteral; -export { _luaS_newliteral as luaS_newliteral }; -const _TString = TString; -export { _TString as TString }; diff --git a/src/lstrlib.js b/src/lstrlib.js index 91e1e232..369834be 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -1,10 +1,10 @@ import { sprintf } from 'sprintf-js'; -import { LUA_INTEGER_FMT, LUA_INTEGER_FRMLEN, LUA_MININTEGER, LUA_NUMBER_FMT, LUA_NUMBER_FRMLEN, frexp, lua_getlocaledecpoint } from './luaconf.js'; -import { LUA_TBOOLEAN, LUA_TFUNCTION, LUA_TNIL, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, lua_call, lua_createtable, lua_dump, lua_gettable, lua_gettop, lua_isinteger, lua_isstring, lua_pop, lua_pushcclosure, lua_pushinteger, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushvalue, lua_remove, lua_setfield, lua_setmetatable, lua_settop, lua_toboolean, lua_tointeger, lua_tonumber, lua_tostring, lua_touserdata, lua_type, lua_upvalueindex } from './lua.js'; -import { luaL_Buffer, luaL_addchar, luaL_addlstring, luaL_addsize, luaL_addstring, luaL_addvalue, luaL_argcheck, luaL_argerror, luaL_buffinit, luaL_buffinitsize, luaL_checkinteger, luaL_checknumber, luaL_checkstack, luaL_checkstring, luaL_checktype, luaL_error, luaL_newlib, luaL_optinteger, luaL_optstring, luaL_prepbuffsize, luaL_pushresult, luaL_pushresultsize, luaL_tolstring, luaL_typename } from './lauxlib.js'; -import { lua_assert } from './lualib.js'; -import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from './fengaricore.js'; +import * as luaconf from './luaconf.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as lualib from './lualib.js'; +import * as fengaricore from './fengaricore.js'; const sL_ESC = '%'; const L_ESC = sL_ESC.charCodeAt(0); @@ -21,7 +21,7 @@ const MAXSIZE = 2147483647; /* Give natural (i.e. strings end at the first \0) length of a string represented by an array of bytes */ const strlen = function (s) { - let len = luastring_indexOf(s, 0); + let len = fengaricore.luastring_indexOf(s, 0); return len > -1 ? len : s.length; }; @@ -33,74 +33,74 @@ const posrelat = function (pos, len) { }; const str_sub = function (L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let l = s.length; - let start = posrelat(luaL_checkinteger(L, 2), l); - let end = posrelat(luaL_optinteger(L, 3, -1), l); + let start = posrelat(lauxlib.luaL_checkinteger(L, 2), l); + let end = posrelat(lauxlib.luaL_optinteger(L, 3, -1), l); if (start < 1) start = 1; if (end > l) end = l; if (start <= end) - lua_pushstring(L, s.subarray(start - 1, (start - 1) + (end - start + 1))); - else lua_pushliteral(L, ''); + lua.lua_pushstring(L, s.subarray(start - 1, (start - 1) + (end - start + 1))); + else lua.lua_pushliteral(L, ''); return 1; }; const str_len = function (L) { - lua_pushinteger(L, luaL_checkstring(L, 1).length); + lua.lua_pushinteger(L, lauxlib.luaL_checkstring(L, 1).length); return 1; }; const str_char = function (L) { - let n = lua_gettop(L); /* number of arguments */ - let b = new luaL_Buffer(); - let p = luaL_buffinitsize(L, b, n); + let n = lua.lua_gettop(L); /* number of arguments */ + let b = new lauxlib.luaL_Buffer(); + let p = lauxlib.luaL_buffinitsize(L, b, n); for (let i = 1; i <= n; i++) { - let c = luaL_checkinteger(L, i); - luaL_argcheck(L, c >= 0 && c <= 255, 'value out of range'); // Strings are 8-bit clean + let c = lauxlib.luaL_checkinteger(L, i); + lauxlib.luaL_argcheck(L, c >= 0 && c <= 255, 'value out of range'); // Strings are 8-bit clean p[i - 1] = c; } - luaL_pushresultsize(b, n); + lauxlib.luaL_pushresultsize(b, n); return 1; }; const writer = function (L, b, size, B) { - luaL_addlstring(B, b, size); + lauxlib.luaL_addlstring(B, b, size); return 0; }; const str_dump = function (L) { - let b = new luaL_Buffer(); - let strip = lua_toboolean(L, 2); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, 1); - luaL_buffinit(L, b); - if (lua_dump(L, writer, b, strip) !== 0) - return luaL_error(L, to_luastring('unable to dump given function')); - luaL_pushresult(b); + let b = new lauxlib.luaL_Buffer(); + let strip = lua.lua_toboolean(L, 2); + lauxlib.luaL_checktype(L, 1, lua.LUA_TFUNCTION); + lua.lua_settop(L, 1); + lauxlib.luaL_buffinit(L, b); + if (lua.lua_dump(L, writer, b, strip) !== 0) + return lauxlib.luaL_error(L, fengaricore.to_luastring('unable to dump given function')); + lauxlib.luaL_pushresult(b); return 1; }; -const SIZELENMOD = LUA_NUMBER_FRMLEN.length + 1; +const SIZELENMOD = luaconf.LUA_NUMBER_FRMLEN.length + 1; const L_NBFD = 1; const num2straux = function (x) { /* if 'inf' or 'NaN', format it like '%g' */ if (Object.is(x, Infinity)) - return to_luastring('inf'); + return fengaricore.to_luastring('inf'); else if (Object.is(x, -Infinity)) - return to_luastring('-inf'); + return fengaricore.to_luastring('-inf'); else if (Number.isNaN(x)) - return to_luastring('nan'); + return fengaricore.to_luastring('nan'); else if (x === 0) { /* can be -0... */ /* create "0" or "-0" followed by exponent */ - let zero = sprintf(LUA_NUMBER_FMT + 'x0p+0', x); + let zero = sprintf(luaconf.LUA_NUMBER_FMT + 'x0p+0', x); if (Object.is(x, -0)) zero = '-' + zero; - return to_luastring(zero); + return fengaricore.to_luastring(zero); } else { let buff = ''; - let fe = frexp(x); /* 'x' fraction and exponent */ + let fe = luaconf.frexp(x); /* 'x' fraction and exponent */ let m = fe[0]; let e = fe[1]; if (m < 0) { /* is number negative? */ @@ -111,7 +111,7 @@ const num2straux = function (x) { buff += (m * (1 << L_NBFD)).toString(16); e -= L_NBFD; /* this digit goes before the radix point */ buff += sprintf('p%+d', e); /* add exponent */ - return to_luastring(buff); + return fengaricore.to_luastring(buff); } }; @@ -124,7 +124,7 @@ const lua_number2strx = function (L, fmt, x) { buff[i] = c & 0xdf; } } else if (fmt[SIZELENMOD] !== 97 /* 'a'.charCodeAt(0) */) - luaL_error(L, to_luastring('modifiers for format \'%%a\'/\'%%A\' not implemented')); + lauxlib.luaL_error(L, fengaricore.to_luastring('modifiers for format \'%%a\'/\'%%A\' not implemented')); return buff; }; @@ -139,7 +139,7 @@ const lua_number2strx = function (L, fmt, x) { /* valid flags in a format specification */ -const FLAGS = to_luastring('-+ #0'); +const FLAGS = fengaricore.to_luastring('-+ #0'); /* ** maximum size of each format specification (such as "%-099.99d") @@ -158,76 +158,76 @@ const isspace = e => e === 32 || (e >= 9 && e <= 13); const isxdigit = e => (48 <= e && e <= 57) || (65 <= e && e <= 70) || (97 <= e && e <= 102); const addquoted = function (b, s, len) { - luaL_addchar(b, 34 /* '"'.charCodeAt(0) */); + lauxlib.luaL_addchar(b, 34 /* '"'.charCodeAt(0) */); let i = 0; while (len--) { if (s[i] === 34 /* '"'.charCodeAt(0) */ || s[i] === 92 /* '\\'.charCodeAt(0) */ || s[i] === 10 /* '\n'.charCodeAt(0) */) { - luaL_addchar(b, 92 /* '\\'.charCodeAt(0) */); - luaL_addchar(b, s[i]); + lauxlib.luaL_addchar(b, 92 /* '\\'.charCodeAt(0) */); + lauxlib.luaL_addchar(b, s[i]); } else if (iscntrl(s[i])) { let buff = '' + s[i]; /* stringify */ if (isdigit(s[i + 1])) buff = ('000' + buff).slice(-3); /* pad to 3 digits with leading '0's */ - luaL_addstring(b, to_luastring('\\' + buff)); + lauxlib.luaL_addstring(b, fengaricore.to_luastring('\\' + buff)); } else - luaL_addchar(b, s[i]); + lauxlib.luaL_addchar(b, s[i]); i++; } - luaL_addchar(b, 34 /* '"'.charCodeAt(0) */); + lauxlib.luaL_addchar(b, 34 /* '"'.charCodeAt(0) */); }; /* ** Ensures the 'buff' string uses a dot as the radix character. */ const checkdp = function (buff) { - if (luastring_indexOf(buff, 46 /* ('.').charCodeAt(0) */) < 0) { /* no dot? */ - let point = lua_getlocaledecpoint(); /* try locale point */ - let ppoint = luastring_indexOf(buff, point); + if (fengaricore.luastring_indexOf(buff, 46 /* ('.').charCodeAt(0) */) < 0) { /* no dot? */ + let point = luaconf.lua_getlocaledecpoint(); /* try locale point */ + let ppoint = fengaricore.luastring_indexOf(buff, point); if (ppoint) buff[ppoint] = 46 /* ('.').charCodeAt(0) */; /* change it to a dot */ } }; const addliteral = function (L, b, arg) { - switch (lua_type(L, arg)) { - case LUA_TSTRING: { - let s = lua_tostring(L, arg); + switch (lua.lua_type(L, arg)) { + case lua.LUA_TSTRING: { + let s = lua.lua_tostring(L, arg); addquoted(b, s, s.length); break; } - case LUA_TNUMBER: { + case lua.LUA_TNUMBER: { let buff; - if (!lua_isinteger(L, arg)) { /* float? */ - let n = lua_tonumber(L, arg); /* write as hexa ('%a') */ - buff = lua_number2strx(L, to_luastring(`%${LUA_INTEGER_FRMLEN}a`), n); + if (!lua.lua_isinteger(L, arg)) { /* float? */ + let n = lua.lua_tonumber(L, arg); /* write as hexa ('%a') */ + buff = lua_number2strx(L, fengaricore.to_luastring(`%${luaconf.LUA_INTEGER_FRMLEN}a`), n); checkdp(buff); /* ensure it uses a dot */ } else { /* integers */ - let n = lua_tointeger(L, arg); - let format = (n === LUA_MININTEGER) /* corner case? */ - ? '0x%' + LUA_INTEGER_FRMLEN + 'x' /* use hexa */ - : LUA_INTEGER_FMT; /* else use default format */ - buff = to_luastring(sprintf(format, n)); + let n = lua.lua_tointeger(L, arg); + let format = (n === luaconf.LUA_MININTEGER) /* corner case? */ + ? '0x%' + luaconf.LUA_INTEGER_FRMLEN + 'x' /* use hexa */ + : luaconf.LUA_INTEGER_FMT; /* else use default format */ + buff = fengaricore.to_luastring(sprintf(format, n)); } - luaL_addstring(b, buff); + lauxlib.luaL_addstring(b, buff); break; } - case LUA_TNIL: case LUA_TBOOLEAN: { - luaL_tolstring(L, arg); - luaL_addvalue(b); + case lua.LUA_TNIL: case lua.LUA_TBOOLEAN: { + lauxlib.luaL_tolstring(L, arg); + lauxlib.luaL_addvalue(b); break; } default: { - luaL_argerror(L, arg, to_luastring('value has no literal form')); + lauxlib.luaL_argerror(L, arg, fengaricore.to_luastring('value has no literal form')); } } }; const scanformat = function (L, strfrmt, i, form) { let p = i; - while (strfrmt[p] !== 0 && luastring_indexOf(FLAGS, strfrmt[p]) >= 0) p++; /* skip flags */ + while (strfrmt[p] !== 0 && fengaricore.luastring_indexOf(FLAGS, strfrmt[p]) >= 0) p++; /* skip flags */ if (p - i >= FLAGS.length) - luaL_error(L, to_luastring('invalid format (repeated flags)')); + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid format (repeated flags)')); if (isdigit(strfrmt[p])) p++; /* skip width */ if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ if (strfrmt[p] === 46 /* '.'.charCodeAt(0) */) { @@ -236,7 +236,7 @@ const scanformat = function (L, strfrmt, i, form) { if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */ } if (isdigit(strfrmt[p])) - luaL_error(L, to_luastring('invalid format (width or precision too long)')); + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid format (width or precision too long)')); form[0] = 37 /* "%".charCodeAt(0) */; for (let j = 0; j < p - i + 1; j++) form[j + 1] = strfrmt[i + j]; @@ -257,45 +257,45 @@ const addlenmod = function (form, lenmod) { }; const str_format = function (L) { - let top = lua_gettop(L); + let top = lua.lua_gettop(L); let arg = 1; - let strfrmt = luaL_checkstring(L, arg); + let strfrmt = lauxlib.luaL_checkstring(L, arg); let i = 0; - let b = new luaL_Buffer(); - luaL_buffinit(L, b); + let b = new lauxlib.luaL_Buffer(); + lauxlib.luaL_buffinit(L, b); while (i < strfrmt.length) { if (strfrmt[i] !== L_ESC) { - luaL_addchar(b, strfrmt[i++]); + lauxlib.luaL_addchar(b, strfrmt[i++]); } else if (strfrmt[++i] === L_ESC) { - luaL_addchar(b, strfrmt[i++]); /* %% */ + lauxlib.luaL_addchar(b, strfrmt[i++]); /* %% */ } else { /* format item */ let form = []; /* to store the format ('%...') */ if (++arg > top) - luaL_argerror(L, arg, to_luastring('no value')); + lauxlib.luaL_argerror(L, arg, fengaricore.to_luastring('no value')); i = scanformat(L, strfrmt, i, form); switch (String.fromCharCode(strfrmt[i++])) { case 'c': { // sprintf(String.fromCharCode(...form), luaL_checkinteger(L, arg)); - luaL_addchar(b, luaL_checkinteger(L, arg)); + lauxlib.luaL_addchar(b, lauxlib.luaL_checkinteger(L, arg)); break; } case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': { - let n = luaL_checkinteger(L, arg); - addlenmod(form, to_luastring(LUA_INTEGER_FRMLEN, true)); - luaL_addstring(b, to_luastring(sprintf(String.fromCharCode(...form), n))); + let n = lauxlib.luaL_checkinteger(L, arg); + addlenmod(form, fengaricore.to_luastring(luaconf.LUA_INTEGER_FRMLEN, true)); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(sprintf(String.fromCharCode(...form), n))); break; } case 'a': case 'A': { - addlenmod(form, to_luastring(LUA_INTEGER_FRMLEN, true)); - luaL_addstring(b, lua_number2strx(L, form, luaL_checknumber(L, arg))); + addlenmod(form, fengaricore.to_luastring(luaconf.LUA_INTEGER_FRMLEN, true)); + lauxlib.luaL_addstring(b, lua_number2strx(L, form, lauxlib.luaL_checknumber(L, arg))); break; } case 'e': case 'E': case 'f': case 'g': case 'G': { - let n = luaL_checknumber(L, arg); - addlenmod(form, to_luastring(LUA_INTEGER_FRMLEN, true)); - luaL_addstring(b, to_luastring(sprintf(String.fromCharCode(...form), n))); + let n = lauxlib.luaL_checknumber(L, arg); + addlenmod(form, fengaricore.to_luastring(luaconf.LUA_INTEGER_FRMLEN, true)); + lauxlib.luaL_addstring(b, fengaricore.to_luastring(sprintf(String.fromCharCode(...form), n))); break; } case 'q': { @@ -303,29 +303,29 @@ const str_format = function (L) { break; } case 's': { - let s = luaL_tolstring(L, arg); + let s = lauxlib.luaL_tolstring(L, arg); if (form.length <= 2 || form[2] === 0) { /* no modifiers? */ - luaL_addvalue(b); /* keep entire string */ + lauxlib.luaL_addvalue(b); /* keep entire string */ } else { - luaL_argcheck(L, s.length === strlen(s), arg, 'string contains zeros'); - if (luastring_indexOf(form, 46 /* '.'.charCodeAt(0) */) < 0 && s.length >= 100) { + lauxlib.luaL_argcheck(L, s.length === strlen(s), arg, 'string contains zeros'); + if (fengaricore.luastring_indexOf(form, 46 /* '.'.charCodeAt(0) */) < 0 && s.length >= 100) { /* no precision and string is too long to be formatted */ - luaL_addvalue(b); /* keep entire string */ + lauxlib.luaL_addvalue(b); /* keep entire string */ } else { /* format the string into 'buff' */ // TODO: will fail if s is not valid UTF-8 - luaL_addstring(b, to_luastring(sprintf(String.fromCharCode(...form), to_jsstring(s)))); - lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ + lauxlib.luaL_addstring(b, fengaricore.to_luastring(sprintf(String.fromCharCode(...form), fengaricore.to_jsstring(s)))); + lua.lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ } } break; } default: { /* also treat cases 'pnLlh' */ - return luaL_error(L, to_luastring('invalid option \'%%%c\' to \'format\''), strfrmt[i - 1]); + return lauxlib.luaL_error(L, fengaricore.to_luastring('invalid option \'%%%c\' to \'format\''), strfrmt[i - 1]); } } } } - luaL_pushresult(b); + lauxlib.luaL_pushresult(b); return 1; }; @@ -390,7 +390,7 @@ const getnum = function (fmt, df) { const getnumlimit = function (h, fmt, df) { let sz = getnum(fmt, df); if (sz > MAXINTSIZE || sz <= 0) - luaL_error(h.L, to_luastring('integral size (%d) out of limits [1,%d]'), sz, MAXINTSIZE); + lauxlib.luaL_error(h.L, fengaricore.to_luastring('integral size (%d) out of limits [1,%d]'), sz, MAXINTSIZE); return sz; }; @@ -421,7 +421,7 @@ const getoption = function (h, fmt) { case 99 /*'c'*/: { r.size = getnum(fmt, -1); if (r.size === -1) - luaL_error(h.L, to_luastring('missing size for format option \'c\'')); + lauxlib.luaL_error(h.L, fengaricore.to_luastring('missing size for format option \'c\'')); r.opt = Kchar; return r; } @@ -433,7 +433,7 @@ const getoption = function (h, fmt) { case 62 /*'>'*/: h.islittle = false; break; case 61 /*'='*/: h.islittle = true; break; case 33 /*'!'*/: h.maxalign = getnumlimit(h, fmt, MAXALIGN); break; - default: luaL_error(h.L, to_luastring('invalid format option \'%c\''), r.opt); + default: lauxlib.luaL_error(h.L, fengaricore.to_luastring('invalid format option \'%c\''), r.opt); } r.opt = Knop; return r; @@ -461,13 +461,13 @@ const getdetails = function (h, totalsize, fmt) { let align = r.size; /* usually, alignment follows size */ if (r.opt === Kpaddalign) { /* 'X' gets alignment from following option */ if (fmt.off >= fmt.s.length || fmt.s[fmt.off] === 0) - luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); + lauxlib.luaL_argerror(h.L, 1, fengaricore.to_luastring('invalid next option for option \'X\'')); else { let o = getoption(h, fmt); align = o.size; o = o.opt; if (o === Kchar || align === 0) - luaL_argerror(h.L, 1, to_luastring('invalid next option for option \'X\'')); + lauxlib.luaL_argerror(h.L, 1, fengaricore.to_luastring('invalid next option for option \'X\'')); } } if (align <= 1 || r.opt === Kchar) /* need no alignment? */ @@ -476,7 +476,7 @@ const getdetails = function (h, totalsize, fmt) { if (align > h.maxalign) /* enforce maximum alignment */ align = h.maxalign; if ((align & (align - 1)) !== 0) /* is 'align' not a power of 2? */ - luaL_argerror(h.L, 1, to_luastring('format asks for alignment not power of 2')); + lauxlib.luaL_argerror(h.L, 1, fengaricore.to_luastring('format asks for alignment not power of 2')); r.ntoalign = (align - (totalsize & (align - 1))) & (align - 1); } return r; @@ -489,7 +489,7 @@ const getdetails = function (h, totalsize, fmt) { ** bytes if necessary (by default they would be zeros). */ const packint = function (b, n, islittle, size, neg) { - let buff = luaL_prepbuffsize(b, size); + let buff = lauxlib.luaL_prepbuffsize(b, size); buff[islittle ? 0 : size - 1] = n & MC; /* first byte */ for (let i = 1; i < size; i++) { n >>= NB; @@ -499,20 +499,20 @@ const packint = function (b, n, islittle, size, neg) { for (let i = SZINT; i < size; i++) /* correct extra bytes */ buff[islittle ? i : size - 1 - i] = MC; } - luaL_addsize(b, size); /* add result to buffer */ + lauxlib.luaL_addsize(b, size); /* add result to buffer */ }; const str_pack = function (L) { - let b = new luaL_Buffer(); + let b = new lauxlib.luaL_Buffer(); let h = new Header(L); let fmt = { - s: luaL_checkstring(L, 1), /* format string */ + s: lauxlib.luaL_checkstring(L, 1), /* format string */ off: 0 }; let arg = 1; /* current argument to pack */ let totalsize = 0; /* accumulate total size of result */ - lua_pushnil(L); /* mark to separate arguments from string buffer */ - luaL_buffinit(L, b); + lua.lua_pushnil(L); /* mark to separate arguments from string buffer */ + lauxlib.luaL_buffinit(L, b); while (fmt.off < fmt.s.length) { let details = getdetails(h, totalsize, fmt); let opt = details.opt; @@ -520,85 +520,85 @@ const str_pack = function (L) { let ntoalign = details.ntoalign; totalsize += ntoalign + size; while (ntoalign-- > 0) - luaL_addchar(b, LUAL_PACKPADBYTE); /* fill alignment */ + lauxlib.luaL_addchar(b, LUAL_PACKPADBYTE); /* fill alignment */ arg++; switch (opt) { case Kint: { /* signed integers */ - let n = luaL_checkinteger(L, arg); + let n = lauxlib.luaL_checkinteger(L, arg); if (size < SZINT) { /* need overflow check? */ let lim = 1 << (size * 8) - 1; - luaL_argcheck(L, -lim <= n && n < lim, arg, 'integer overflow'); + lauxlib.luaL_argcheck(L, -lim <= n && n < lim, arg, 'integer overflow'); } packint(b, n, h.islittle, size, n < 0); break; } case Kuint: { /* unsigned integers */ - let n = luaL_checkinteger(L, arg); + let n = lauxlib.luaL_checkinteger(L, arg); if (size < SZINT) - luaL_argcheck(L, (n >>> 0) < (1 << (size * NB)), arg, 'unsigned overflow'); + lauxlib.luaL_argcheck(L, (n >>> 0) < (1 << (size * NB)), arg, 'unsigned overflow'); packint(b, n >>> 0, h.islittle, size, false); break; } case Kfloat: { /* floating-point options */ - let buff = luaL_prepbuffsize(b, size); - let n = luaL_checknumber(L, arg); /* get argument */ + let buff = lauxlib.luaL_prepbuffsize(b, size); + let n = lauxlib.luaL_checknumber(L, arg); /* get argument */ let dv = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); if (size === 4) dv.setFloat32(0, n, h.islittle); else dv.setFloat64(0, n, h.islittle); - luaL_addsize(b, size); + lauxlib.luaL_addsize(b, size); break; } case Kchar: { /* fixed-size string */ - let s = luaL_checkstring(L, arg); + let s = lauxlib.luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, len <= size, arg, 'string longer than given size'); - luaL_addlstring(b, s, len); /* add string */ + lauxlib.luaL_argcheck(L, len <= size, arg, 'string longer than given size'); + lauxlib.luaL_addlstring(b, s, len); /* add string */ while (len++ < size) /* pad extra space */ - luaL_addchar(b, LUAL_PACKPADBYTE); + lauxlib.luaL_addchar(b, LUAL_PACKPADBYTE); break; } case Kstring: { /* strings with length count */ - let s = luaL_checkstring(L, arg); + let s = lauxlib.luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, + lauxlib.luaL_argcheck(L, size >= 4 /* sizeof(size_t) */ || len < (1 << (size * NB)), arg, 'string length does not fit in given size'); packint(b, len, h.islittle, size, 0); /* pack length */ - luaL_addlstring(b, s, len); + lauxlib.luaL_addlstring(b, s, len); totalsize += len; break; } case Kzstr: { /* zero-terminated string */ - let s = luaL_checkstring(L, arg); + let s = lauxlib.luaL_checkstring(L, arg); let len = s.length; - luaL_argcheck(L, luastring_indexOf(s, 0) < 0, arg, 'strings contains zeros'); - luaL_addlstring(b, s, len); - luaL_addchar(b, 0); /* add zero at the end */ + lauxlib.luaL_argcheck(L, fengaricore.luastring_indexOf(s, 0) < 0, arg, 'strings contains zeros'); + lauxlib.luaL_addlstring(b, s, len); + lauxlib.luaL_addchar(b, 0); /* add zero at the end */ totalsize += len + 1; break; } - case Kpadding: luaL_addchar(b, LUAL_PACKPADBYTE); /* fall through */ + case Kpadding: lauxlib.luaL_addchar(b, LUAL_PACKPADBYTE); /* fall through */ case Kpaddalign: case Knop: arg--; /* undo increment */ break; } } - luaL_pushresult(b); + lauxlib.luaL_pushresult(b); return 1; }; const str_reverse = function (L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let l = s.length; let r = new Uint8Array(l); for (let i = 0; i < l; i++) r[i] = s[l - 1 - i]; - lua_pushstring(L, r); + lua.lua_pushstring(L, r); return 1; }; const str_lower = function (L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let l = s.length; let r = new Uint8Array(l); for (let i = 0; i < l; i++) { @@ -607,12 +607,12 @@ const str_lower = function (L) { c = c | 0x20; r[i] = c; } - lua_pushstring(L, r); + lua.lua_pushstring(L, r); return 1; }; const str_upper = function (L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let l = s.length; let r = new Uint8Array(l); for (let i = 0; i < l; i++) { @@ -621,23 +621,23 @@ const str_upper = function (L) { c = c & 0xdf; r[i] = c; } - lua_pushstring(L, r); + lua.lua_pushstring(L, r); return 1; }; const str_rep = function (L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let l = s.length; - let n = luaL_checkinteger(L, 2); - let sep = luaL_optstring(L, 3, ''); + let n = lauxlib.luaL_checkinteger(L, 2); + let sep = lauxlib.luaL_optstring(L, 3, ''); let lsep = sep.length; - if (n <= 0) lua_pushliteral(L, ''); + if (n <= 0) lua.lua_pushliteral(L, ''); else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */ - return luaL_error(L, to_luastring('resulting string too large')); + return lauxlib.luaL_error(L, fengaricore.to_luastring('resulting string too large')); else { let totallen = n * l + (n - 1) * lsep; - let b = new luaL_Buffer(); - let p = luaL_buffinitsize(L, b, totallen); + let b = new lauxlib.luaL_Buffer(); + let p = lauxlib.luaL_buffinitsize(L, b, totallen); let pi = 0; while (n-- > 1) { /* first n-1 copies (followed by separator) */ p.set(s, pi); @@ -648,34 +648,34 @@ const str_rep = function (L) { } } p.set(s, pi); /* last copy (not followed by separator) */ - luaL_pushresultsize(b, totallen); + lauxlib.luaL_pushresultsize(b, totallen); } return 1; }; const str_byte = function (L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let l = s.length; - let posi = posrelat(luaL_optinteger(L, 2, 1), l); - let pose = posrelat(luaL_optinteger(L, 3, posi), l); + let posi = posrelat(lauxlib.luaL_optinteger(L, 2, 1), l); + let pose = posrelat(lauxlib.luaL_optinteger(L, 3, posi), l); if (posi < 1) posi = 1; if (pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) /* arithmetic overflow? */ - return luaL_error(L, 'string slice too long'); + return lauxlib.luaL_error(L, 'string slice too long'); let n = (pose - posi) + 1; - luaL_checkstack(L, n, 'string slice too long'); + lauxlib.luaL_checkstack(L, n, 'string slice too long'); for (let i = 0; i < n; i++) - lua_pushinteger(L, s[posi + i - 1]); + lua.lua_pushinteger(L, s[posi + i - 1]); return n; }; const str_packsize = function (L) { let h = new Header(L); let fmt = { - s: luaL_checkstring(L, 1), + s: lauxlib.luaL_checkstring(L, 1), off: 0 }; let totalsize = 0; /* accumulate total size of result */ @@ -685,17 +685,17 @@ const str_packsize = function (L) { let size = details.size; let ntoalign = details.ntoalign; size += ntoalign; /* total space used by option */ - luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, 'format result too large'); + lauxlib.luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, 'format result too large'); totalsize += size; switch (opt) { case Kstring: /* strings with length count */ case Kzstr: /* zero-terminated string */ - luaL_argerror(L, 1, 'variable-length format'); + lauxlib.luaL_argerror(L, 1, 'variable-length format'); /* call never return, but to avoid warnings: *//* fall through */ default: break; } } - lua_pushinteger(L, totalsize); + lua.lua_pushinteger(L, totalsize); return 1; }; @@ -723,14 +723,14 @@ const unpackint = function (L, str, islittle, size, issigned) { let mask = !issigned || res >= 0 ? 0 : MC; for (let i = limit; i < size; i++) { if (str[islittle ? i : size - 1 - i] !== mask) - luaL_error(L, to_luastring('%d-byte integer does not fit into Lua Integer'), size); + lauxlib.luaL_error(L, fengaricore.to_luastring('%d-byte integer does not fit into Lua Integer'), size); } } return res; }; const unpacknum = function (L, b, islittle, size) { - lua_assert(b.length >= size); + lualib.lua_assert(b.length >= size); let dv = new DataView(new ArrayBuffer(size)); for (let i = 0; i < size; i++) @@ -743,52 +743,52 @@ const unpacknum = function (L, b, islittle, size) { const str_unpack = function (L) { let h = new Header(L); let fmt = { - s: luaL_checkstring(L, 1), + s: lauxlib.luaL_checkstring(L, 1), off: 0 }; - let data = luaL_checkstring(L, 2); + let data = lauxlib.luaL_checkstring(L, 2); let ld = data.length; - let pos = posrelat(luaL_optinteger(L, 3, 1), ld) - 1; + let pos = posrelat(lauxlib.luaL_optinteger(L, 3, 1), ld) - 1; let n = 0; /* number of results */ - luaL_argcheck(L, pos <= ld && pos >= 0, 3, 'initial position out of string'); + lauxlib.luaL_argcheck(L, pos <= ld && pos >= 0, 3, 'initial position out of string'); while (fmt.off < fmt.s.length) { let details = getdetails(h, pos, fmt); let opt = details.opt; let size = details.size; let ntoalign = details.ntoalign; if (/*ntoalign + size > ~pos ||*/ pos + ntoalign + size > ld) - luaL_argerror(L, 2, to_luastring('data string too short')); + lauxlib.luaL_argerror(L, 2, fengaricore.to_luastring('data string too short')); pos += ntoalign; /* skip alignment */ /* stack space for item + next position */ - luaL_checkstack(L, 2, 'too many results'); + lauxlib.luaL_checkstack(L, 2, 'too many results'); n++; switch (opt) { case Kint: case Kuint: { let res = unpackint(L, data.subarray(pos), h.islittle, size, opt === Kint); - lua_pushinteger(L, res); + lua.lua_pushinteger(L, res); break; } case Kfloat: { let res = unpacknum(L, data.subarray(pos), h.islittle, size); - lua_pushnumber(L, res); + lua.lua_pushnumber(L, res); break; } case Kchar: { - lua_pushstring(L, data.subarray(pos, pos + size)); + lua.lua_pushstring(L, data.subarray(pos, pos + size)); break; } case Kstring: { let len = unpackint(L, data.subarray(pos), h.islittle, size, 0); - luaL_argcheck(L, pos + len + size <= ld, 2, 'data string too short'); - lua_pushstring(L, data.subarray(pos + size, pos + size + len)); + lauxlib.luaL_argcheck(L, pos + len + size <= ld, 2, 'data string too short'); + lua.lua_pushstring(L, data.subarray(pos + size, pos + size + len)); pos += len; /* skip string */ break; } case Kzstr: { - let e = luastring_indexOf(data, 0, pos); + let e = fengaricore.luastring_indexOf(data, 0, pos); if (e === -1) e = data.length - pos; - lua_pushstring(L, data.subarray(pos, e)); + lua.lua_pushstring(L, data.subarray(pos, e)); pos = e + 1; /* skip string plus final '\0' */ break; } @@ -798,14 +798,14 @@ const str_unpack = function (L) { } pos += size; } - lua_pushinteger(L, pos + 1); /* next position */ + lua.lua_pushinteger(L, pos + 1); /* next position */ return n + 1; }; const CAP_UNFINISHED = -1; const CAP_POSITION = -2; const MAXCCALLS = 200; -const SPECIALS = to_luastring('^$*+?.([%-'); +const SPECIALS = fengaricore.to_luastring('^$*+?.([%-'); class MatchState { constructor(L) { @@ -824,7 +824,7 @@ class MatchState { const check_capture = function (ms, l) { l = l - 49 /* '1'.charCodeAt(0) */; if (l < 0 || l >= ms.level || ms.capture[l].len === CAP_UNFINISHED) - return luaL_error(ms.L, to_luastring('invalid capture index %%%d'), l + 1); + return lauxlib.luaL_error(ms.L, fengaricore.to_luastring('invalid capture index %%%d'), l + 1); return l; }; @@ -832,21 +832,21 @@ const capture_to_close = function (ms) { let level = ms.level; for (level--; level >= 0; level--) if (ms.capture[level].len === CAP_UNFINISHED) return level; - return luaL_error(ms.L, to_luastring('invalid pattern capture')); + return lauxlib.luaL_error(ms.L, fengaricore.to_luastring('invalid pattern capture')); }; const classend = function (ms, p) { switch (ms.p[p++]) { case L_ESC: { if (p === ms.p_end) - luaL_error(ms.L, to_luastring('malformed pattern (ends with \'%%\')')); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('malformed pattern (ends with \'%%\')')); return p + 1; } case 91 /* '['.charCodeAt(0) */: { if (ms.p[p] === 94 /* '^'.charCodeAt(0) */) p++; do { /* look for a ']' */ if (p === ms.p_end) - luaL_error(ms.L, to_luastring('malformed pattern (missing \']\')')); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('malformed pattern (missing \']\')')); if (ms.p[p++] === L_ESC && p < ms.p_end) p++; /* skip escapes (e.g. '%]') */ } while (ms.p[p] !== 93 /* ']'.charCodeAt(0) */); @@ -922,7 +922,7 @@ const singlematch = function (ms, s, p, ep) { const matchbalance = function (ms, s, p) { if (p >= ms.p_end - 1) - luaL_error(ms.L, to_luastring('malformed pattern (missing arguments to \'%%b\'')); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('malformed pattern (missing arguments to \'%%b\'')); if (ms.src[s] !== ms.p[p]) return null; else { @@ -965,7 +965,7 @@ const min_expand = function (ms, s, p, ep) { const start_capture = function (ms, s, p, what) { let level = ms.level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring('too many captures')); + if (level >= LUA_MAXCAPTURES) lauxlib.luaL_error(ms.L, fengaricore.to_luastring('too many captures')); ms.capture[level] = ms.capture[level] ? ms.capture[level] : {}; ms.capture[level].init = s; ms.capture[level].len = what; @@ -987,7 +987,7 @@ const end_capture = function (ms, s, p) { /* Compare the elements of arrays 'a' and 'b' to see if they contain the same elements */ const array_cmp = function (a, ai, b, bi, len) { - return luastring_eq(a.subarray(ai, ai + len), b.subarray(bi, bi + len)); + return fengaricore.luastring_eq(a.subarray(ai, ai + len), b.subarray(bi, bi + len)); }; const match_capture = function (ms, s, l) { @@ -1003,7 +1003,7 @@ const match = function (ms, s, p) { let gotoinit = true; if (ms.matchdepth-- === 0) - luaL_error(ms.L, to_luastring('pattern too complex')); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('pattern too complex')); while (gotoinit || gotodefault) { gotoinit = false; @@ -1041,7 +1041,7 @@ const match = function (ms, s, p) { case 102 /* 'f'.charCodeAt(0) */: { /* frontier? */ p += 2; if (ms.p[p] !== 91 /* '['.charCodeAt(0) */) - luaL_error(ms.L, to_luastring('missing \'[\' after \'%%f\' in pattern')); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('missing \'[\' after \'%%f\' in pattern')); let ep = classend(ms, p); /* points to what is next */ let previous = s === ms.src_init ? 0 : ms.src[s - 1]; if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, (s === ms.src_end) ? 0 : ms.src[s], p, ep - 1)) { @@ -1110,22 +1110,22 @@ const match = function (ms, s, p) { const push_onecapture = function (ms, i, s, e) { if (i >= ms.level) { if (i === 0) - lua_pushlstring(ms.L, ms.src.subarray(s, e), e - s); /* add whole match */ + lua.lua_pushlstring(ms.L, ms.src.subarray(s, e), e - s); /* add whole match */ else - luaL_error(ms.L, to_luastring('invalid capture index %%%d'), i + 1); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('invalid capture index %%%d'), i + 1); } else { let l = ms.capture[i].len; - if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring('unfinished capture')); + if (l === CAP_UNFINISHED) lauxlib.luaL_error(ms.L, fengaricore.to_luastring('unfinished capture')); if (l === CAP_POSITION) - lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1); + lua.lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1); else - lua_pushlstring(ms.L, ms.src.subarray(ms.capture[i].init), l); + lua.lua_pushlstring(ms.L, ms.src.subarray(ms.capture[i].init), l); } }; const push_captures = function (ms, s, e) { let nlevels = (ms.level === 0 && s != null) ? 1 : ms.level; - luaL_checkstack(ms.L, nlevels, 'too many captures'); + lauxlib.luaL_checkstack(ms.L, nlevels, 'too many captures'); for (let i = 0; i < nlevels; i++) push_onecapture(ms, i, s, e); return nlevels; /* number of strings pushed */ @@ -1133,7 +1133,7 @@ const push_captures = function (ms, s, e) { const nospecials = function (p, l) { for (let i = 0; i < l; i++) { - if (luastring_indexOf(SPECIALS, p[i]) !== -1) + if (fengaricore.luastring_indexOf(SPECIALS, p[i]) !== -1) return false; } return true; @@ -1151,7 +1151,7 @@ const prepstate = function (ms, L, s, ls, p, lp) { const reprepstate = function (ms) { ms.level = 0; - lua_assert(ms.matchdepth === MAXCCALLS); + lualib.lua_assert(ms.matchdepth === MAXCCALLS); }; const find_subarray = function (arr, subarr, from_index) { @@ -1162,7 +1162,7 @@ const find_subarray = function (arr, subarr, from_index) { return i; for (; (i = arr.indexOf(subarr[0], i)) !== -1; i++) { - if (luastring_eq(arr.subarray(i, i + sl), subarr)) + if (fengaricore.luastring_eq(arr.subarray(i, i + sl), subarr)) return i; } @@ -1170,23 +1170,23 @@ const find_subarray = function (arr, subarr, from_index) { }; const str_find_aux = function (L, find) { - let s = luaL_checkstring(L, 1); - let p = luaL_checkstring(L, 2); + let s = lauxlib.luaL_checkstring(L, 1); + let p = lauxlib.luaL_checkstring(L, 2); let ls = s.length; let lp = p.length; - let init = posrelat(luaL_optinteger(L, 3, 1), ls); + let init = posrelat(lauxlib.luaL_optinteger(L, 3, 1), ls); if (init < 1) init = 1; else if (init > ls + 1) { /* start after string's end? */ - lua_pushnil(L); /* cannot find anything */ + lua.lua_pushnil(L); /* cannot find anything */ return 1; } /* explicit request or no special characters? */ - if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { + if (find && (lua.lua_toboolean(L, 4) || nospecials(p, lp))) { /* do a plain search */ let f = find_subarray(s.subarray(init - 1), p, 0); if (f > -1) { - lua_pushinteger(L, init + f); - lua_pushinteger(L, init + f + lp - 1); + lua.lua_pushinteger(L, init + f); + lua.lua_pushinteger(L, init + f + lp - 1); return 2; } } else { @@ -1202,15 +1202,15 @@ const str_find_aux = function (L, find) { reprepstate(ms); if ((res = match(ms, s1, 0)) !== null) { if (find) { - lua_pushinteger(L, s1 + 1); /* start */ - lua_pushinteger(L, res); /* end */ + lua.lua_pushinteger(L, s1 + 1); /* start */ + lua.lua_pushinteger(L, res); /* end */ return push_captures(ms, null, 0) + 2; } else return push_captures(ms, s1, res); } } while (s1++ < ms.src_end && !anchor); } - lua_pushnil(L); /* not found */ + lua.lua_pushnil(L); /* not found */ return 1; }; @@ -1233,7 +1233,7 @@ class GMatchState { } const gmatch_aux = function (L) { - let gm = lua_touserdata(L, lua_upvalueindex(3)); + let gm = lua.lua_touserdata(L, lua.lua_upvalueindex(3)); gm.ms.L = L; for (let src = gm.src; src <= gm.ms.src_end; src++) { reprepstate(gm.ms); @@ -1247,41 +1247,41 @@ const gmatch_aux = function (L) { }; const str_gmatch = function (L) { - let s = luaL_checkstring(L, 1); - let p = luaL_checkstring(L, 2); + let s = lauxlib.luaL_checkstring(L, 1); + let p = lauxlib.luaL_checkstring(L, 2); let ls = s.length; let lp = p.length; - lua_settop(L, 2); /* keep them on closure to avoid being collected */ + lua.lua_settop(L, 2); /* keep them on closure to avoid being collected */ let gm = new GMatchState(); - lua_pushlightuserdata(L, gm); + lua.lua_pushlightuserdata(L, gm); prepstate(gm.ms, L, s, ls, p, lp); gm.src = 0; gm.p = 0; gm.lastmatch = null; - lua_pushcclosure(L, gmatch_aux, 3); + lua.lua_pushcclosure(L, gmatch_aux, 3); return 1; }; const add_s = function (ms, b, s, e) { let L = ms.L; - let news = lua_tostring(L, 3); + let news = lua.lua_tostring(L, 3); let l = news.length; for (let i = 0; i < l; i++) { if (news[i] !== L_ESC) - luaL_addchar(b, news[i]); + lauxlib.luaL_addchar(b, news[i]); else { i++; /* skip ESC */ if (!isdigit(news[i])) { if (news[i] !== L_ESC) - luaL_error(L, to_luastring('invalid use of \'%c\' in replacement string'), L_ESC); - luaL_addchar(b, news[i]); + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid use of \'%c\' in replacement string'), L_ESC); + lauxlib.luaL_addchar(b, news[i]); } else if (news[i] === 48 /* '0'.charCodeAt(0) */) - luaL_addlstring(b, ms.src.subarray(s, e), e - s); + lauxlib.luaL_addlstring(b, ms.src.subarray(s, e), e - s); else { push_onecapture(ms, news[i] - 49 /* '1'.charCodeAt(0) */, s, e); - luaL_tolstring(L, -1); - lua_remove(L, -2); /* remove original value */ - luaL_addvalue(b); /* add capture to accumulated result */ + lauxlib.luaL_tolstring(L, -1); + lua.lua_remove(L, -2); /* remove original value */ + lauxlib.luaL_addvalue(b); /* add capture to accumulated result */ } } } @@ -1290,15 +1290,15 @@ const add_s = function (ms, b, s, e) { const add_value = function (ms, b, s, e, tr) { let L = ms.L; switch (tr) { - case LUA_TFUNCTION: { - lua_pushvalue(L, 3); + case lua.LUA_TFUNCTION: { + lua.lua_pushvalue(L, 3); let n = push_captures(ms, s, e); - lua_call(L, n, 1); + lua.lua_call(L, n, 1); break; } - case LUA_TTABLE: { + case lua.LUA_TTABLE: { push_onecapture(ms, 0, s, e); - lua_gettable(L, 3); + lua.lua_gettable(L, 3); break; } default: { /* LUA_TNUMBER or LUA_TSTRING */ @@ -1306,29 +1306,29 @@ const add_value = function (ms, b, s, e, tr) { return; } } - if (!lua_toboolean(L, -1)) { /* nil or false? */ - lua_pop(L, 1); - lua_pushlstring(L, ms.src.subarray(s, e), e - s); /* keep original text */ - } else if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('invalid replacement value (a %s)'), luaL_typename(L, -1)); - luaL_addvalue(b); /* add result to accumulator */ + if (!lua.lua_toboolean(L, -1)) { /* nil or false? */ + lua.lua_pop(L, 1); + lua.lua_pushlstring(L, ms.src.subarray(s, e), e - s); /* keep original text */ + } else if (!lua.lua_isstring(L, -1)) + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid replacement value (a %s)'), lauxlib.luaL_typename(L, -1)); + lauxlib.luaL_addvalue(b); /* add result to accumulator */ }; const str_gsub = function (L) { - let src = luaL_checkstring(L, 1); /* subject */ + let src = lauxlib.luaL_checkstring(L, 1); /* subject */ let srcl = src.length; - let p = luaL_checkstring(L, 2); /* pattern */ + let p = lauxlib.luaL_checkstring(L, 2); /* pattern */ let lp = p.length; let lastmatch = null; /* end of last match */ - let tr = lua_type(L, 3); /* replacement type */ - let max_s = luaL_optinteger(L, 4, srcl + 1); /* max replacements */ + let tr = lua.lua_type(L, 3); /* replacement type */ + let max_s = lauxlib.luaL_optinteger(L, 4, srcl + 1); /* max replacements */ let anchor = p[0] === 94 /* '^'.charCodeAt(0) */; let n = 0; /* replacement count */ let ms = new MatchState(L); - let b = new luaL_Buffer(); - luaL_argcheck(L, tr === LUA_TNUMBER || tr === LUA_TSTRING || tr === LUA_TFUNCTION || tr === LUA_TTABLE, 3, + let b = new lauxlib.luaL_Buffer(); + lauxlib.luaL_argcheck(L, tr === lua.LUA_TNUMBER || tr === lua.LUA_TSTRING || tr === lua.LUA_TFUNCTION || tr === lua.LUA_TTABLE, 3, 'string/function/table expected'); - luaL_buffinit(L, b); + lauxlib.luaL_buffinit(L, b); if (anchor) { p = p.subarray(1); lp--; /* skip anchor character */ } @@ -1342,13 +1342,13 @@ const str_gsub = function (L) { add_value(ms, b, src, e, tr); /* add replacement to buffer */ src = lastmatch = e; } else if (src < ms.src_end) /* otherwise, skip one character */ - luaL_addchar(b, ms.src[src++]); + lauxlib.luaL_addchar(b, ms.src[src++]); else break; /* end of subject */ if (anchor) break; } - luaL_addlstring(b, ms.src.subarray(src, ms.src_end), ms.src_end - src); - luaL_pushresult(b); - lua_pushinteger(L, n); /* number of substitutions */ + lauxlib.luaL_addlstring(b, ms.src.subarray(src, ms.src_end), ms.src_end - src); + lauxlib.luaL_pushresult(b); + lua.lua_pushinteger(L, n); /* number of substitutions */ return 2; }; @@ -1373,21 +1373,18 @@ const strlib = { }; const createmetatable = function (L) { - lua_createtable(L, 0, 1); /* table to be metatable for strings */ - lua_pushliteral(L, ''); /* dummy string */ - lua_pushvalue(L, -2); /* copy table */ - lua_setmetatable(L, -2); /* set table as metatable for strings */ - lua_pop(L, 1); /* pop dummy string */ - lua_pushvalue(L, -2); /* get string library */ - lua_setfield(L, -2, to_luastring('__index', true)); /* metatable.__index = string */ - lua_pop(L, 1); /* pop metatable */ + lua.lua_createtable(L, 0, 1); /* table to be metatable for strings */ + lua.lua_pushliteral(L, ''); /* dummy string */ + lua.lua_pushvalue(L, -2); /* copy table */ + lua.lua_setmetatable(L, -2); /* set table as metatable for strings */ + lua.lua_pop(L, 1); /* pop dummy string */ + lua.lua_pushvalue(L, -2); /* get string library */ + lua.lua_setfield(L, -2, fengaricore.to_luastring('__index', true)); /* metatable.__index = string */ + lua.lua_pop(L, 1); /* pop metatable */ }; -const luaopen_string = function (L) { - luaL_newlib(L, strlib); +export const luaopen_string = function (L) { + lauxlib.luaL_newlib(L, strlib); createmetatable(L); return 1; }; - -const _luaopen_string = luaopen_string; -export { _luaopen_string as luaopen_string }; diff --git a/src/ltable.js b/src/ltable.js index 0600fa24..1f5d39ce 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -1,12 +1,12 @@ -import { constant_types, to_luastring } from './defs.js'; -import { LUA_MAXINTEGER } from './luaconf.js'; -import { lua_assert } from './llimits.js'; -import { luaG_runerror } from './ldebug.js'; -import { Udata, LClosure, CClosure, luaO_nilobject, TValue, setobj2s } from './lobject.js'; -import { luaS_hashlongstr, TString } from './lstring.js'; -import { lua_State } from './lstate.js'; +import * as defs from './defs.js'; +import * as luaconf from './luaconf.js'; +import * as llimits from './llimits.js'; +import * as ldebug from './ldebug.js'; +import * as lobject from './lobject.js'; +import * as lstring from './lstring.js'; +import * as lstate from './lstate.js'; -const { +export const { LUA_TBOOLEAN, LUA_TCCL, LUA_TLCF, @@ -20,11 +20,11 @@ const { LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA -} = constant_types; +} = defs.constant_types; /* used to prevent conflicts with lightuserdata keys */ -let lightuserdata_hashes = new WeakMap(); -const get_lightuserdata_hash = function (v) { +export let lightuserdata_hashes = new WeakMap(); +export const get_lightuserdata_hash = function (v) { let hash = lightuserdata_hashes.get(v); if (!hash) { /* Hash should be something unique that is a valid WeakMap key @@ -35,13 +35,13 @@ const get_lightuserdata_hash = function (v) { return hash; }; -const table_hash = function (L, key) { +export const table_hash = function (L, key) { switch (key.type) { case LUA_TNIL: - return luaG_runerror(L, to_luastring('table index is nil', true)); + return ldebug.luaG_runerror(L, defs.to_luastring('table index is nil', true)); case LUA_TNUMFLT: if (isNaN(key.value)) - return luaG_runerror(L, to_luastring('table index is NaN', true)); + return ldebug.luaG_runerror(L, defs.to_luastring('table index is NaN', true)); /* fall through */ case LUA_TNUMINT: /* takes advantage of floats and integers being same in JS */ case LUA_TBOOLEAN: @@ -54,7 +54,7 @@ const table_hash = function (L, key) { return key.value; case LUA_TSHRSTR: case LUA_TLNGSTR: - return luaS_hashlongstr(key.tsvalue()); + return lstring.luaS_hashlongstr(key.tsvalue()); case LUA_TLIGHTUSERDATA: { let v = key.value; switch (typeof v) { @@ -75,11 +75,11 @@ const table_hash = function (L, key) { return get_lightuserdata_hash(v); case 'object': /* v could be a lua_State, CClosure, LClosure, Table or Userdata from this state as returned by lua_topointer */ - if ((v instanceof lua_State && v.l_G === L.l_G) || + if ((v instanceof lstate.lua_State && v.l_G === L.l_G) || v instanceof Table || - v instanceof Udata || - v instanceof LClosure || - v instanceof CClosure) { + v instanceof lobject.Udata || + v instanceof lobject.LClosure || + v instanceof lobject.CClosure) { /* indirect via a weakmap */ return get_lightuserdata_hash(v); } @@ -93,7 +93,7 @@ const table_hash = function (L, key) { } }; -class Table { +export class Table { constructor(L) { this.id = L.l_G.id_counter++; this.strong = new Map(); @@ -106,14 +106,14 @@ class Table { } } -const invalidateTMcache = function (t) { +export const invalidateTMcache = function (t) { t.flags = 0; }; -const add = function (t, hash, key, value) { +export const add = function (t, hash, key, value) { t.dead_strong.clear(); t.dead_weak = void 0; - let prev = null; + let prev; let entry = { key: key, value: value, @@ -126,12 +126,12 @@ const add = function (t, hash, key, value) { t.l = entry; }; -const is_valid_weakmap_key = function (k) { +export const is_valid_weakmap_key = function (k) { return typeof k === 'object' ? k !== null : typeof k === 'function'; }; /* Move out of 'strong' part and into 'dead' part. */ -const mark_dead = function (t, hash) { +export const mark_dead = function (t, hash) { let e = t.strong.get(hash); if (e) { e.key.setdeadvalue(); @@ -154,34 +154,34 @@ const mark_dead = function (t, hash) { } }; -const luaH_new = function (L) { +export const luaH_new = function (L) { return new Table(L); }; -const getgeneric = function (t, hash) { +export const getgeneric = function (t, hash) { let v = t.strong.get(hash); - return v ? v.value : luaO_nilobject; + return v ? v.value : lobject.luaO_nilobject; }; -const luaH_getint = function (t, key) { - lua_assert(typeof key == 'number' && (key | 0) === key); +export const luaH_getint = function (t, key) { + llimits.lua_assert(typeof key == 'number' && (key | 0) === key); return getgeneric(t, key); }; -const luaH_getstr = function (t, key) { - lua_assert(key instanceof TString); - return getgeneric(t, luaS_hashlongstr(key)); +export const luaH_getstr = function (t, key) { + llimits.lua_assert(key instanceof lstring.TString); + return getgeneric(t, lstring.luaS_hashlongstr(key)); }; -const luaH_get = function (L, t, key) { - lua_assert(key instanceof TValue); +export const luaH_get = function (L, t, key) { + llimits.lua_assert(key instanceof lobject.TValue); if (key.ttisnil() || (key.ttisfloat() && isNaN(key.value))) - return luaO_nilobject; + return lobject.luaO_nilobject; return getgeneric(t, table_hash(L, key)); }; -const luaH_setint = function (t, key, value) { - lua_assert(typeof key == 'number' && (key | 0) === key && value instanceof TValue); +export const luaH_setint = function (t, key, value) { + llimits.lua_assert(typeof key == 'number' && (key | 0) === key && value instanceof lobject.TValue); let hash = key; /* table_hash known result */ if (value.ttisnil()) { mark_dead(t, hash); @@ -192,14 +192,14 @@ const luaH_setint = function (t, key, value) { let tv = e.value; tv.setfrom(value); } else { - let k = new TValue(LUA_TNUMINT, key); - let v = new TValue(value.type, value.value); + let k = new lobject.TValue(LUA_TNUMINT, key); + let v = new lobject.TValue(value.type, value.value); add(t, hash, k, v); } }; -const luaH_setfrom = function (L, t, key, value) { - lua_assert(key instanceof TValue); +export const luaH_setfrom = function (L, t, key, value) { + llimits.lua_assert(key instanceof lobject.TValue); let hash = table_hash(L, key); if (value.ttisnil()) { /* delete */ mark_dead(t, hash); @@ -214,11 +214,11 @@ const luaH_setfrom = function (L, t, key, value) { let kv = key.value; if ((key.ttisfloat() && (kv | 0) === kv)) { /* does index fit in an integer? */ /* insert it as an integer */ - k = new TValue(LUA_TNUMINT, kv); + k = new lobject.TValue(LUA_TNUMINT, kv); } else { - k = new TValue(key.type, kv); + k = new lobject.TValue(key.type, kv); } - let v = new TValue(value.type, value.value); + let v = new lobject.TValue(value.type, value.value); add(t, hash, k, v); } }; @@ -227,13 +227,13 @@ const luaH_setfrom = function (L, t, key, value) { ** Try to find a boundary in table 't'. A 'boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). */ -const luaH_getn = function (t) { +export const luaH_getn = function (t) { let i = 0; let j = t.strong.size + 1; /* use known size of Map to kick start search */ /* find 'i' and 'j' such that i is present and j is not */ while (!(luaH_getint(t, j).ttisnil())) { i = j; - if (j > LUA_MAXINTEGER / 2) { /* overflow? */ + if (j > luaconf.LUA_MAXINTEGER / 2) { /* overflow? */ /* table was built with bad purposes: resort to linear search */ i = 1; while (!luaH_getint(t, i).ttisnil()) i++; @@ -250,7 +250,7 @@ const luaH_getn = function (t) { return i; }; -const luaH_next = function (L, table, keyI) { +export const luaH_next = function (L, table, keyI) { let keyO = L.stack[keyI]; let entry; @@ -272,7 +272,7 @@ const luaH_next = function (L, table, keyI) { entry = (table.dead_weak && table.dead_weak.get(hash)) || table.dead_strong.get(hash); if (!entry) /* item not in table */ - return luaG_runerror(L, to_luastring('invalid key to \'next\'')); + return ldebug.luaG_runerror(L, defs.to_luastring('invalid key to \'next\'')); /* Iterate until either out of keys, or until finding a non-dead key */ do { entry = entry.n; @@ -281,28 +281,7 @@ const luaH_next = function (L, table, keyI) { } while (entry.key.ttisdeadkey()); } } - setobj2s(L, keyI, entry.key); - setobj2s(L, keyI + 1, entry.value); + lobject.setobj2s(L, keyI, entry.key); + lobject.setobj2s(L, keyI + 1, entry.value); return true; }; - -const _invalidateTMcache = invalidateTMcache; -export { _invalidateTMcache as invalidateTMcache }; -const _luaH_get = luaH_get; -export { _luaH_get as luaH_get }; -const _luaH_getint = luaH_getint; -export { _luaH_getint as luaH_getint }; -const _luaH_getn = luaH_getn; -export { _luaH_getn as luaH_getn }; -const _luaH_getstr = luaH_getstr; -export { _luaH_getstr as luaH_getstr }; -const _luaH_setfrom = luaH_setfrom; -export { _luaH_setfrom as luaH_setfrom }; -const _luaH_setint = luaH_setint; -export { _luaH_setint as luaH_setint }; -const _luaH_new = luaH_new; -export { _luaH_new as luaH_new }; -const _luaH_next = luaH_next; -export { _luaH_next as luaH_next }; -const _Table = Table; -export { _Table as Table }; diff --git a/src/ltablib.js b/src/ltablib.js index eccbc1b9..6e3b7d81 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -1,8 +1,8 @@ -import { LUA_MAXINTEGER } from './luaconf.js'; -import { LUA_OPEQ, LUA_OPLT, LUA_TFUNCTION, LUA_TNIL, LUA_TTABLE, lua_call, lua_checkstack, lua_compare, lua_createtable, lua_geti, lua_getmetatable, lua_gettop, lua_insert, lua_isnil, lua_isnoneornil, lua_isstring, lua_pop, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_rawget, lua_setfield, lua_seti, lua_settop, lua_toboolean, lua_type } from './lua.js'; -import { luaL_Buffer, luaL_addlstring, luaL_addvalue, luaL_argcheck, luaL_buffinit, luaL_checkinteger, luaL_checktype, luaL_error, luaL_len, luaL_newlib, luaL_opt, luaL_optinteger, luaL_optlstring, luaL_pushresult, luaL_typename } from './lauxlib.js'; -import { lua_assert } from './lualib.js'; -import { to_luastring } from './fengaricore.js'; +import * as luaconf from './luaconf.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as lualib from './lualib.js'; +import * as fengaricore from './fengaricore.js'; /* ** Operations that an object must define to mimic a table @@ -14,8 +14,8 @@ const TAB_L = 4; /* length */ const TAB_RW = (TAB_R | TAB_W); /* read/write */ const checkfield = function(L, key, n) { - lua_pushstring(L, key); - return lua_rawget(L, -n) !== LUA_TNIL; + lua.lua_pushstring(L, key); + return lua.lua_rawget(L, -n) !== lua.LUA_TNIL; }; /* @@ -23,70 +23,70 @@ const checkfield = function(L, key, n) { ** has a metatable with the required metamethods) */ const checktab = function(L, arg, what) { - if (lua_type(L, arg) !== LUA_TTABLE) { /* is it not a table? */ + if (lua.lua_type(L, arg) !== lua.LUA_TTABLE) { /* is it not a table? */ let n = 1; - if (lua_getmetatable(L, arg) && /* must have metatable */ - (!(what & TAB_R) || checkfield(L, to_luastring('__index', true), ++n)) && - (!(what & TAB_W) || checkfield(L, to_luastring('__newindex', true), ++n)) && - (!(what & TAB_L) || checkfield(L, to_luastring('__len', true), ++n))) { - lua_pop(L, n); /* pop metatable and tested metamethods */ + if (lua.lua_getmetatable(L, arg) && /* must have metatable */ + (!(what & TAB_R) || checkfield(L, fengaricore.to_luastring('__index', true), ++n)) && + (!(what & TAB_W) || checkfield(L, fengaricore.to_luastring('__newindex', true), ++n)) && + (!(what & TAB_L) || checkfield(L, fengaricore.to_luastring('__len', true), ++n))) { + lua.lua_pop(L, n); /* pop metatable and tested metamethods */ } else - luaL_checktype(L, arg, LUA_TTABLE); /* force an error */ + lauxlib.luaL_checktype(L, arg, lua.LUA_TTABLE); /* force an error */ } }; const aux_getn = function(L, n, w) { checktab(L, n, w | TAB_L); - return luaL_len(L, n); + return lauxlib.luaL_len(L, n); }; const addfield = function(L, b, i) { - lua_geti(L, 1, i); - if (!lua_isstring(L, -1)) - luaL_error(L, to_luastring('invalid value (%s) at index %d in table for \'concat\''), - luaL_typename(L, -1), i); + lua.lua_geti(L, 1, i); + if (!lua.lua_isstring(L, -1)) + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid value (%s) at index %d in table for \'concat\''), + lauxlib.luaL_typename(L, -1), i); - luaL_addvalue(b); + lauxlib.luaL_addvalue(b); }; const tinsert = function(L) { let e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ let pos; - switch (lua_gettop(L)) { + switch (lua.lua_gettop(L)) { case 2: pos = e; break; case 3: { - pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ - luaL_argcheck(L, 1 <= pos && pos <= e, 2, 'position out of bounds'); + pos = lauxlib.luaL_checkinteger(L, 2); /* 2nd argument is the position */ + lauxlib.luaL_argcheck(L, 1 <= pos && pos <= e, 2, 'position out of bounds'); for (let i = e; i > pos; i--) { /* move up elements */ - lua_geti(L, 1, i - 1); - lua_seti(L, 1, i); /* t[i] = t[i - 1] */ + lua.lua_geti(L, 1, i - 1); + lua.lua_seti(L, 1, i); /* t[i] = t[i - 1] */ } break; } default: { - return luaL_error(L, 'wrong number of arguments to \'insert\''); + return lauxlib.luaL_error(L, 'wrong number of arguments to \'insert\''); } } - lua_seti(L, 1, pos); /* t[pos] = v */ + lua.lua_seti(L, 1, pos); /* t[pos] = v */ return 0; }; const tremove = function(L) { let size = aux_getn(L, 1, TAB_RW); - let pos = luaL_optinteger(L, 2, size); + let pos = lauxlib.luaL_optinteger(L, 2, size); if (pos !== size) /* validate 'pos' if given */ - luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, 'position out of bounds'); - lua_geti(L, 1, pos); /* result = t[pos] */ + lauxlib.luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, 'position out of bounds'); + lua.lua_geti(L, 1, pos); /* result = t[pos] */ for (; pos < size; pos++) { - lua_geti(L, 1, pos + 1); - lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */ + lua.lua_geti(L, 1, pos + 1); + lua.lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */ } - lua_pushnil(L); - lua_seti(L, 1, pos); /* t[pos] = nil */ + lua.lua_pushnil(L); + lua.lua_seti(L, 1, pos); /* t[pos] = nil */ return 1; }; @@ -97,78 +97,78 @@ const tremove = function(L) { ** than origin, or copying to another table. */ const tmove = function(L) { - let f = luaL_checkinteger(L, 2); - let e = luaL_checkinteger(L, 3); - let t = luaL_checkinteger(L, 4); - let tt = !lua_isnoneornil(L, 5) ? 5 : 1; /* destination table */ + let f = lauxlib.luaL_checkinteger(L, 2); + let e = lauxlib.luaL_checkinteger(L, 3); + let t = lauxlib.luaL_checkinteger(L, 4); + let tt = !lua.lua_isnoneornil(L, 5) ? 5 : 1; /* destination table */ checktab(L, 1, TAB_R); checktab(L, tt, TAB_W); if (e >= f) { /* otherwise, nothing to move */ - luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, 'too many elements to move'); + lauxlib.luaL_argcheck(L, f > 0 || e < luaconf.LUA_MAXINTEGER + f, 3, 'too many elements to move'); let n = e - f + 1; /* number of elements to move */ - luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, 'destination wrap around'); + lauxlib.luaL_argcheck(L, t <= luaconf.LUA_MAXINTEGER - n + 1, 4, 'destination wrap around'); - if (t > e || t <= f || (tt !== 1 && lua_compare(L, 1, tt, LUA_OPEQ) !== 1)) { + if (t > e || t <= f || (tt !== 1 && lua.lua_compare(L, 1, tt, lua.LUA_OPEQ) !== 1)) { for (let i = 0; i < n; i++) { - lua_geti(L, 1, f + i); - lua_seti(L, tt, t + i); + lua.lua_geti(L, 1, f + i); + lua.lua_seti(L, tt, t + i); } } else { for (let i = n - 1; i >= 0; i--) { - lua_geti(L, 1, f + i); - lua_seti(L, tt, t + i); + lua.lua_geti(L, 1, f + i); + lua.lua_seti(L, tt, t + i); } } } - lua_pushvalue(L, tt); /* return destination table */ + lua.lua_pushvalue(L, tt); /* return destination table */ return 1; }; const tconcat = function(L) { let last = aux_getn(L, 1, TAB_R); - let sep = luaL_optlstring(L, 2, ''); + let sep = lauxlib.luaL_optlstring(L, 2, ''); let lsep = sep.length; - let i = luaL_optinteger(L, 3, 1); - last = luaL_optinteger(L, 4, last); + let i = lauxlib.luaL_optinteger(L, 3, 1); + last = lauxlib.luaL_optinteger(L, 4, last); - let b = new luaL_Buffer(); - luaL_buffinit(L, b); + let b = new lauxlib.luaL_Buffer(); + lauxlib.luaL_buffinit(L, b); for (; i < last; i++) { addfield(L, b, i); - luaL_addlstring(b, sep, lsep); + lauxlib.luaL_addlstring(b, sep, lsep); } if (i === last) addfield(L, b, i); - luaL_pushresult(b); + lauxlib.luaL_pushresult(b); return 1; }; const pack = function(L) { - let n = lua_gettop(L); /* number of elements to pack */ - lua_createtable(L, n, 1); /* create result table */ - lua_insert(L, 1); /* put it at index 1 */ + let n = lua.lua_gettop(L); /* number of elements to pack */ + lua.lua_createtable(L, n, 1); /* create result table */ + lua.lua_insert(L, 1); /* put it at index 1 */ for (let i = n; i >= 1; i--) /* assign elements */ - lua_seti(L, 1, i); - lua_pushinteger(L, n); - lua_setfield(L, 1, to_luastring('n')); /* t.n = number of elements */ + lua.lua_seti(L, 1, i); + lua.lua_pushinteger(L, n); + lua.lua_setfield(L, 1, fengaricore.to_luastring('n')); /* t.n = number of elements */ return 1; /* return table */ }; const unpack = function(L) { - let i = luaL_optinteger(L, 2, 1); - let e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); + let i = lauxlib.luaL_optinteger(L, 2, 1); + let e = lauxlib.luaL_opt(L, lauxlib.luaL_checkinteger, 3, lauxlib.luaL_len(L, 1)); if (i > e) return 0; /* empty range */ let n = e - i; /* number of elements minus 1 (avoid overflows) */ - if (n >= Number.MAX_SAFE_INTEGER || !lua_checkstack(L, ++n)) - return luaL_error(L, to_luastring('too many results to unpack')); + if (n >= Number.MAX_SAFE_INTEGER || !lua.lua_checkstack(L, ++n)) + return lauxlib.luaL_error(L, fengaricore.to_luastring('too many results to unpack')); for (; i < e; i++) /* push arg[i..e - 1] (to avoid overflows) */ - lua_geti(L, 1, i); - lua_geti(L, 1, e); /* push last element */ + lua.lua_geti(L, 1, i); + lua.lua_geti(L, 1, e); /* push last element */ return n; }; @@ -179,20 +179,20 @@ const l_randomizePivot = function() { const RANLIMIT = 100; const set2 = function(L, i, j) { - lua_seti(L, 1, i); - lua_seti(L, 1, j); + lua.lua_seti(L, 1, i); + lua.lua_seti(L, 1, j); }; const sort_comp = function(L, a, b) { - if (lua_isnil(L, 2)) /* no function? */ - return lua_compare(L, a, b, LUA_OPLT); /* a < b */ + if (lua.lua_isnil(L, 2)) /* no function? */ + return lua.lua_compare(L, a, b, lua.LUA_OPLT); /* a < b */ else { /* function */ - lua_pushvalue(L, 2); /* push function */ - lua_pushvalue(L, a-1); /* -1 to compensate function */ - lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */ - lua_call(L, 2, 1); /* call function */ - let res = lua_toboolean(L, -1); /* get result */ - lua_pop(L, 1); /* pop result */ + lua.lua_pushvalue(L, 2); /* push function */ + lua.lua_pushvalue(L, a-1); /* -1 to compensate function */ + lua.lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */ + lua.lua_call(L, 2, 1); /* call function */ + let res = lua.lua_toboolean(L, -1); /* get result */ + lua.lua_pop(L, 1); /* pop result */ return res; } }; @@ -203,22 +203,22 @@ const partition = function(L, lo, up) { /* loop invariant: a[lo .. i] <= P <= a[j .. up] */ for (;;) { /* next loop: repeat ++i while a[i] < P */ - while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { + while (lua.lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ - luaL_error(L, to_luastring('invalid order function for sorting')); - lua_pop(L, 1); /* remove a[i] */ + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid order function for sorting')); + lua.lua_pop(L, 1); /* remove a[i] */ } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ - while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { + while (lua.lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) /* j < i but a[j] > P ?? */ - luaL_error(L, to_luastring('invalid order function for sorting')); - lua_pop(L, 1); /* remove a[j] */ + lauxlib.luaL_error(L, fengaricore.to_luastring('invalid order function for sorting')); + lua.lua_pop(L, 1); /* remove a[j] */ } /* after the loop, a[j] <= P and a[j + 1 .. up] >= P */ if (j < i) { /* no elements out of place? */ /* a[lo .. i - 1] <= P <= a[j + 1 .. i .. up] */ - lua_pop(L, 1); /* pop a[j] */ + lua.lua_pop(L, 1); /* pop a[j] */ /* swap pivot (a[up - 1]) with a[i] to satisfy pos-condition */ set2(L, up - 1, i); return i; @@ -231,19 +231,19 @@ const partition = function(L, lo, up) { const choosePivot = function(lo, up, rnd) { let r4 = Math.floor((up - lo) / 4); /* range/4 */ let p = rnd % (r4 * 2) + (lo + r4); - lua_assert(lo + r4 <= p && p <= up - r4); + lualib.lua_assert(lo + r4 <= p && p <= up - r4); return p; }; const auxsort = function(L, lo, up, rnd) { while (lo < up) { /* loop for tail recursion */ /* sort elements 'lo', 'p', and 'up' */ - lua_geti(L, 1, lo); - lua_geti(L, 1, up); + lua.lua_geti(L, 1, lo); + lua.lua_geti(L, 1, up); if (sort_comp(L, -1, -2)) /* a[up] < a[lo]? */ set2(L, lo, up); /* swap a[lo] - a[up] */ else - lua_pop(L, 2); /* remove both values */ + lua.lua_pop(L, 2); /* remove both values */ if (up - lo == 1) /* only 2 elements? */ return; /* already sorted */ let p; /* Pivot index */ @@ -251,23 +251,23 @@ const auxsort = function(L, lo, up, rnd) { p = Math.floor((lo + up)/2); /* middle element is a good pivot */ else /* for larger intervals, it is worth a random pivot */ p = choosePivot(lo, up, rnd); - lua_geti(L, 1, p); - lua_geti(L, 1, lo); + lua.lua_geti(L, 1, p); + lua.lua_geti(L, 1, lo); if (sort_comp(L, -2, -1)) /* a[p] < a[lo]? */ set2(L, p, lo); /* swap a[p] - a[lo] */ else { - lua_pop(L, 1); /* remove a[lo] */ - lua_geti(L, 1, up); + lua.lua_pop(L, 1); /* remove a[lo] */ + lua.lua_geti(L, 1, up); if (sort_comp(L, -1, -2)) /* a[up] < a[p]? */ set2(L, p, up); /* swap a[up] - a[p] */ else - lua_pop(L, 2); + lua.lua_pop(L, 2); } if (up - lo == 2) /* only 3 elements? */ return; /* already sorted */ - lua_geti(L, 1, p); /* get middle element (Pivot) */ - lua_pushvalue(L, -1); /* push Pivot */ - lua_geti(L, 1, up - 1); /* push a[up - 1] */ + lua.lua_geti(L, 1, p); /* get middle element (Pivot) */ + lua.lua_pushvalue(L, -1); /* push Pivot */ + lua.lua_geti(L, 1, up - 1); /* push a[up - 1] */ set2(L, p, up - 1); /* swap Pivot (a[p]) with a[up - 1] */ p = partition(L, lo, up); let n; @@ -289,10 +289,10 @@ const auxsort = function(L, lo, up, rnd) { const sort = function(L) { let n = aux_getn(L, 1, TAB_RW); if (n > 1) { /* non-trivial interval? */ - luaL_argcheck(L, n < LUA_MAXINTEGER, 1, 'array too big'); - if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ - luaL_checktype(L, 2, LUA_TFUNCTION); /* must be a function */ - lua_settop(L, 2); /* make sure there are two arguments */ + lauxlib.luaL_argcheck(L, n < luaconf.LUA_MAXINTEGER, 1, 'array too big'); + if (!lua.lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ + lauxlib.luaL_checktype(L, 2, lua.LUA_TFUNCTION); /* must be a function */ + lua.lua_settop(L, 2); /* make sure there are two arguments */ auxsort(L, 1, n, 0); } return 0; @@ -308,10 +308,7 @@ const tab_funcs = { 'unpack': unpack }; -const luaopen_table = function(L) { - luaL_newlib(L, tab_funcs); +export const luaopen_table = function(L) { + lauxlib.luaL_newlib(L, tab_funcs); return 1; }; - -const _luaopen_table = luaopen_table; -export { _luaopen_table as luaopen_table }; diff --git a/src/ltm.js b/src/ltm.js index 44c7ffec..bfaa84fb 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -1,17 +1,17 @@ -import { constant_types, to_luastring } from './defs.js'; -import { lua_assert } from './llimits.js'; -import { pushobj2s, TValue, luaO_nilobject } from './lobject.js'; -import { luaD_call, luaD_callnoyield } from './ldo.js'; -import { CIST_LUA } from './lstate.js'; -import { luaS_bless, luaS_new } from './lstring.js'; -import { luaH_getstr } from './ltable.js'; -import { luaG_concaterror, luaG_tointerror, luaG_opinterror } from './ldebug.js'; -import { tonumber } from './lvm.js'; +import * as defs from './defs.js'; +import * as llimits from './llimits.js'; +import * as lobject from './lobject.js'; +import * as ldo from './ldo.js'; +import * as lstate from './lstate.js'; +import * as lstring from './lstring.js'; +import * as ltable from './ltable.js'; +import * as ldebug from './ldebug.js'; +import * as lvm from './lvm.js'; const { LUA_TTABLE, LUA_TUSERDATA -} = constant_types; +} = defs.constant_types; const luaT_typenames_ = [ 'no value', @@ -25,9 +25,9 @@ const luaT_typenames_ = [ 'userdata', 'thread', 'proto' /* this last case is used for tests only */ -].map(e => to_luastring(e)); +].map(e => defs.to_luastring(e)); -const ttypename = function (t) { +export const ttypename = function (t) { return luaT_typenames_[t + 1]; }; @@ -36,7 +36,7 @@ const ttypename = function (t) { * WARNING: if you change the order of this enumeration, * grep "ORDER TM" and "ORDER OP" */ -const TMS = { +export const TMS = { TM_INDEX: 0, TM_NEWINDEX: 1, TM_GC: 2, @@ -64,63 +64,63 @@ const TMS = { TM_N: 24 /* number of elements in the enum */ }; -const luaT_init = function (L) { - L.l_G.tmname[TMS.TM_INDEX] = new luaS_new(L, to_luastring('__index', true)); - L.l_G.tmname[TMS.TM_NEWINDEX] = new luaS_new(L, to_luastring('__newindex', true)); - L.l_G.tmname[TMS.TM_GC] = new luaS_new(L, to_luastring('__gc', true)); - L.l_G.tmname[TMS.TM_MODE] = new luaS_new(L, to_luastring('__mode', true)); - L.l_G.tmname[TMS.TM_LEN] = new luaS_new(L, to_luastring('__len', true)); - L.l_G.tmname[TMS.TM_EQ] = new luaS_new(L, to_luastring('__eq', true)); - L.l_G.tmname[TMS.TM_ADD] = new luaS_new(L, to_luastring('__add', true)); - L.l_G.tmname[TMS.TM_SUB] = new luaS_new(L, to_luastring('__sub', true)); - L.l_G.tmname[TMS.TM_MUL] = new luaS_new(L, to_luastring('__mul', true)); - L.l_G.tmname[TMS.TM_MOD] = new luaS_new(L, to_luastring('__mod', true)); - L.l_G.tmname[TMS.TM_POW] = new luaS_new(L, to_luastring('__pow', true)); - L.l_G.tmname[TMS.TM_DIV] = new luaS_new(L, to_luastring('__div', true)); - L.l_G.tmname[TMS.TM_IDIV] = new luaS_new(L, to_luastring('__idiv', true)); - L.l_G.tmname[TMS.TM_BAND] = new luaS_new(L, to_luastring('__band', true)); - L.l_G.tmname[TMS.TM_BOR] = new luaS_new(L, to_luastring('__bor', true)); - L.l_G.tmname[TMS.TM_BXOR] = new luaS_new(L, to_luastring('__bxor', true)); - L.l_G.tmname[TMS.TM_SHL] = new luaS_new(L, to_luastring('__shl', true)); - L.l_G.tmname[TMS.TM_SHR] = new luaS_new(L, to_luastring('__shr', true)); - L.l_G.tmname[TMS.TM_UNM] = new luaS_new(L, to_luastring('__unm', true)); - L.l_G.tmname[TMS.TM_BNOT] = new luaS_new(L, to_luastring('__bnot', true)); - L.l_G.tmname[TMS.TM_LT] = new luaS_new(L, to_luastring('__lt', true)); - L.l_G.tmname[TMS.TM_LE] = new luaS_new(L, to_luastring('__le', true)); - L.l_G.tmname[TMS.TM_CONCAT] = new luaS_new(L, to_luastring('__concat', true)); - L.l_G.tmname[TMS.TM_CALL] = new luaS_new(L, to_luastring('__call', true)); +export const luaT_init = function (L) { + L.l_G.tmname[TMS.TM_INDEX] = new lstring.luaS_new(L, defs.to_luastring('__index', true)); + L.l_G.tmname[TMS.TM_NEWINDEX] = new lstring.luaS_new(L, defs.to_luastring('__newindex', true)); + L.l_G.tmname[TMS.TM_GC] = new lstring.luaS_new(L, defs.to_luastring('__gc', true)); + L.l_G.tmname[TMS.TM_MODE] = new lstring.luaS_new(L, defs.to_luastring('__mode', true)); + L.l_G.tmname[TMS.TM_LEN] = new lstring.luaS_new(L, defs.to_luastring('__len', true)); + L.l_G.tmname[TMS.TM_EQ] = new lstring.luaS_new(L, defs.to_luastring('__eq', true)); + L.l_G.tmname[TMS.TM_ADD] = new lstring.luaS_new(L, defs.to_luastring('__add', true)); + L.l_G.tmname[TMS.TM_SUB] = new lstring.luaS_new(L, defs.to_luastring('__sub', true)); + L.l_G.tmname[TMS.TM_MUL] = new lstring.luaS_new(L, defs.to_luastring('__mul', true)); + L.l_G.tmname[TMS.TM_MOD] = new lstring.luaS_new(L, defs.to_luastring('__mod', true)); + L.l_G.tmname[TMS.TM_POW] = new lstring.luaS_new(L, defs.to_luastring('__pow', true)); + L.l_G.tmname[TMS.TM_DIV] = new lstring.luaS_new(L, defs.to_luastring('__div', true)); + L.l_G.tmname[TMS.TM_IDIV] = new lstring.luaS_new(L, defs.to_luastring('__idiv', true)); + L.l_G.tmname[TMS.TM_BAND] = new lstring.luaS_new(L, defs.to_luastring('__band', true)); + L.l_G.tmname[TMS.TM_BOR] = new lstring.luaS_new(L, defs.to_luastring('__bor', true)); + L.l_G.tmname[TMS.TM_BXOR] = new lstring.luaS_new(L, defs.to_luastring('__bxor', true)); + L.l_G.tmname[TMS.TM_SHL] = new lstring.luaS_new(L, defs.to_luastring('__shl', true)); + L.l_G.tmname[TMS.TM_SHR] = new lstring.luaS_new(L, defs.to_luastring('__shr', true)); + L.l_G.tmname[TMS.TM_UNM] = new lstring.luaS_new(L, defs.to_luastring('__unm', true)); + L.l_G.tmname[TMS.TM_BNOT] = new lstring.luaS_new(L, defs.to_luastring('__bnot', true)); + L.l_G.tmname[TMS.TM_LT] = new lstring.luaS_new(L, defs.to_luastring('__lt', true)); + L.l_G.tmname[TMS.TM_LE] = new lstring.luaS_new(L, defs.to_luastring('__le', true)); + L.l_G.tmname[TMS.TM_CONCAT] = new lstring.luaS_new(L, defs.to_luastring('__concat', true)); + L.l_G.tmname[TMS.TM_CALL] = new lstring.luaS_new(L, defs.to_luastring('__call', true)); }; /* ** Return the name of the type of an object. For tables and userdata ** with metatable, use their '__name' metafield, if present. */ -const __name = to_luastring('__name', true); -const luaT_objtypename = function (L, o) { +const __name = defs.to_luastring('__name', true); +export const luaT_objtypename = function (L, o) { let mt; if ((o.ttistable() && (mt = o.value.metatable) !== null) || (o.ttisfulluserdata() && (mt = o.value.metatable) !== null)) { - let name = luaH_getstr(mt, luaS_bless(L, __name)); + let name = ltable.luaH_getstr(mt, lstring.luaS_bless(L, __name)); if (name.ttisstring()) return name.svalue(); } return ttypename(o.ttnov()); }; -const luaT_callTM = function (L, f, p1, p2, p3, hasres) { +export const luaT_callTM = function (L, f, p1, p2, p3, hasres) { let func = L.top; - pushobj2s(L, f); /* push function (assume EXTRA_STACK) */ - pushobj2s(L, p1); /* 1st argument */ - pushobj2s(L, p2); /* 2nd argument */ + lobject.pushobj2s(L, f); /* push function (assume EXTRA_STACK) */ + lobject.pushobj2s(L, p1); /* 1st argument */ + lobject.pushobj2s(L, p2); /* 2nd argument */ if (!hasres) /* no result? 'p3' is third argument */ - pushobj2s(L, p3); /* 3rd argument */ + lobject.pushobj2s(L, p3); /* 3rd argument */ - if (L.ci.callstatus & CIST_LUA) - luaD_call(L, func, hasres); + if (L.ci.callstatus & lstate.CIST_LUA) + ldo.luaD_call(L, func, hasres); else - luaD_callnoyield(L, func, hasres); + ldo.luaD_callnoyield(L, func, hasres); if (hasres) { /* if has result, move it to its place */ let tv = L.stack[L.top - 1]; @@ -129,7 +129,7 @@ const luaT_callTM = function (L, f, p1, p2, p3, hasres) { } }; -const luaT_callbinTM = function (L, p1, p2, res, event) { +export const luaT_callbinTM = function (L, p1, p2, res, event) { let tm = luaT_gettmbyobj(L, p1, event); if (tm.ttisnil()) tm = luaT_gettmbyobj(L, p2, event); @@ -138,42 +138,42 @@ const luaT_callbinTM = function (L, p1, p2, res, event) { return true; }; -const luaT_trybinTM = function (L, p1, p2, res, event) { +export const luaT_trybinTM = function (L, p1, p2, res, event) { if (!luaT_callbinTM(L, p1, p2, res, event)) { switch (event) { case TMS.TM_CONCAT: - return luaG_concaterror(L, p1, p2); + return ldebug.luaG_concaterror(L, p1, p2); case TMS.TM_BAND: case TMS.TM_BOR: case TMS.TM_BXOR: case TMS.TM_SHL: case TMS.TM_SHR: case TMS.TM_BNOT: { - let n1 = tonumber(p1); - let n2 = tonumber(p2); + let n1 = lvm.tonumber(p1); + let n2 = lvm.tonumber(p2); if (n1 !== false && n2 !== false) - return luaG_tointerror(L, p1, p2); + return ldebug.luaG_tointerror(L, p1, p2); else - return luaG_opinterror(L, p1, p2, to_luastring('perform bitwise operation on', true)); + return ldebug.luaG_opinterror(L, p1, p2, defs.to_luastring('perform bitwise operation on', true)); } default: - return luaG_opinterror(L, p1, p2, to_luastring('perform arithmetic on', true)); + return ldebug.luaG_opinterror(L, p1, p2, defs.to_luastring('perform arithmetic on', true)); } } }; -const luaT_callorderTM = function (L, p1, p2, event) { - let res = new TValue(); +export const luaT_callorderTM = function (L, p1, p2, event) { + let res = new lobject.TValue(); if (!luaT_callbinTM(L, p1, p2, res, event)) return null; else return !res.l_isfalse(); }; -const fasttm = function (l, et, e) { +export const fasttm = function (l, et, e) { return et === null ? null : (et.flags & (1 << e)) ? null : luaT_gettm(et, e, l.l_G.tmname[e]); }; -const luaT_gettm = function (events, event, ename) { - const tm = luaH_getstr(events, ename); - lua_assert(event <= TMS.TM_EQ); +export const luaT_gettm = function (events, event, ename) { + const tm = ltable.luaH_getstr(events, ename); + llimits.lua_assert(event <= TMS.TM_EQ); if (tm.ttisnil()) { /* no tag method? */ events.flags |= 1 << event; /* cache this fact */ return null; @@ -181,7 +181,7 @@ const luaT_gettm = function (events, event, ename) { else return tm; }; -const luaT_gettmbyobj = function (L, o, event) { +export const luaT_gettmbyobj = function (L, o, event) { let mt; switch (o.ttnov()) { case LUA_TTABLE: @@ -192,28 +192,5 @@ const luaT_gettmbyobj = function (L, o, event) { mt = L.l_G.mt[o.ttnov()]; } - return mt ? luaH_getstr(mt, L.l_G.tmname[event]) : luaO_nilobject; + return mt ? ltable.luaH_getstr(mt, L.l_G.tmname[event]) : lobject.luaO_nilobject; }; - -const _fasttm = fasttm; -export { _fasttm as fasttm }; -const _TMS = TMS; -export { _TMS as TMS }; -const _luaT_callTM = luaT_callTM; -export { _luaT_callTM as luaT_callTM }; -const _luaT_callbinTM = luaT_callbinTM; -export { _luaT_callbinTM as luaT_callbinTM }; -const _luaT_trybinTM = luaT_trybinTM; -export { _luaT_trybinTM as luaT_trybinTM }; -const _luaT_callorderTM = luaT_callorderTM; -export { _luaT_callorderTM as luaT_callorderTM }; -const _luaT_gettm = luaT_gettm; -export { _luaT_gettm as luaT_gettm }; -const _luaT_gettmbyobj = luaT_gettmbyobj; -export { _luaT_gettmbyobj as luaT_gettmbyobj }; -const _luaT_init = luaT_init; -export { _luaT_init as luaT_init }; -const _luaT_objtypename = luaT_objtypename; -export { _luaT_objtypename as luaT_objtypename }; -const _ttypename = ttypename; -export { _ttypename as ttypename }; diff --git a/src/lua.js b/src/lua.js index 6ef71c2c..ceb11884 100644 --- a/src/lua.js +++ b/src/lua.js @@ -6,22 +6,25 @@ export { lua_gethook, lua_gethookcount, lua_gethookmask, lua_getinfo, lua_getloc export { lua_isyieldable, lua_resume, lua_yield, lua_yieldk } from './ldo.js'; export { lua_close, lua_newstate, lua_newthread } from './lstate.js'; -export const LUA_ERRERR = thread_status.LUA_ERRERR; -export const LUA_ERRGCMM = thread_status.LUA_ERRGCMM; -export const LUA_ERRMEM = thread_status.LUA_ERRMEM; -export const LUA_ERRRUN = thread_status.LUA_ERRRUN; -export const LUA_ERRSYNTAX = thread_status.LUA_ERRSYNTAX; -export const LUA_NUMTAGS = constant_types.LUA_NUMTAGS; -export const LUA_OK = thread_status.LUA_OK; -export const LUA_YIELD = thread_status.LUA_YIELD; +export const { + LUA_ERRERR, + LUA_ERRGCMM, + LUA_ERRMEM, + LUA_ERRRUN, + LUA_ERRSYNTAX, + LUA_OK, + LUA_YIELD +} = thread_status; -export const LUA_TNONE = constant_types.LUA_TNONE; -export const LUA_TNIL = constant_types.LUA_TNIL; -export const LUA_TBOOLEAN = constant_types.LUA_TBOOLEAN; -export const LUA_TLIGHTUSERDATA = constant_types.LUA_TLIGHTUSERDATA; -export const LUA_TNUMBER = constant_types.LUA_TNUMBER; -export const LUA_TSTRING = constant_types.LUA_TSTRING; -export const LUA_TTABLE = constant_types.LUA_TTABLE; -export const LUA_TFUNCTION = constant_types.LUA_TFUNCTION; -export const LUA_TUSERDATA = constant_types.LUA_TUSERDATA; -export const LUA_TTHREAD = constant_types.LUA_TTHREAD; +export const { + LUA_TNONE, + LUA_TNIL, + LUA_TBOOLEAN, + LUA_TLIGHTUSERDATA, + LUA_TNUMBER, + LUA_TSTRING, + LUA_TTABLE, + LUA_TFUNCTION, + LUA_TUSERDATA, + LUA_TTHREAD +} = constant_types; diff --git a/src/luaconf.js b/src/luaconf.js index 840522c1..fd7866cf 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -1,8 +1,12 @@ -import { platform } from 'os'; +import * as defs from './defs.js'; -const conf = (process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); +const platform = () => { + if (typeof process === 'undefined') return 'web'; + if (process.platform === 'win32') return 'win32'; + return 'posix'; +}; -import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR, to_luastring } from './defs.js'; +export const conf = (typeof process !== 'undefined' && process.env.FENGARICONF ? JSON.parse(process.env.FENGARICONF) : {}); /* ** LUA_PATH_SEP is the character that separates templates in a path. @@ -11,17 +15,11 @@ import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR, to_luastring } from './defs.js'; ** LUA_EXEC_DIR in a Windows path is replaced by the executable's ** directory. */ -const LUA_PATH_SEP = ';'; -const _LUA_PATH_SEP = LUA_PATH_SEP; -export { _LUA_PATH_SEP as LUA_PATH_SEP }; +export const LUA_PATH_SEP = ';'; -const LUA_PATH_MARK = '?'; -const _LUA_PATH_MARK = LUA_PATH_MARK; -export { _LUA_PATH_MARK as LUA_PATH_MARK }; +export const LUA_PATH_MARK = '?'; -const LUA_EXEC_DIR = '!'; -const _LUA_EXEC_DIR = LUA_EXEC_DIR; -export { _LUA_EXEC_DIR as LUA_EXEC_DIR }; +export const LUA_EXEC_DIR = '!'; /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @@ -32,9 +30,7 @@ export { _LUA_EXEC_DIR as LUA_EXEC_DIR }; ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ -const LUA_VDIR = LUA_VERSION_MAJOR + '.' + LUA_VERSION_MINOR; -const _LUA_VDIR = LUA_VDIR; -export { _LUA_VDIR as LUA_VDIR }; +export const LUA_VDIR = defs.LUA_VERSION_MAJOR + '.' + defs.LUA_VERSION_MINOR; export let LUA_DIRSEP, LUA_LDIR, LUA_JSDIR, LUA_SHRDIR, LUA_PATH_DEFAULT, LUA_JSPATH_DEFAULT, LUA_ROOT; @@ -45,13 +41,13 @@ if (typeof process === 'undefined') { LUA_JSDIR = LUA_LDIR; - LUA_PATH_DEFAULT = to_luastring( + LUA_PATH_DEFAULT = defs.to_luastring( LUA_LDIR + '?.lua;' + LUA_LDIR + '?/init.lua;' + /* LUA_JSDIR excluded as it is equal to LUA_LDIR */ './?.lua;./?/init.lua' ); - LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = defs.to_luastring( LUA_JSDIR + '?.js;' + LUA_JSDIR + 'loadall.js;./?.js' ); } else if (platform() === 'win32') { @@ -67,14 +63,14 @@ if (typeof process === 'undefined') { LUA_SHRDIR = '!\\..\\share\\lua\\' + LUA_VDIR + '\\'; - LUA_PATH_DEFAULT = to_luastring( + LUA_PATH_DEFAULT = defs.to_luastring( LUA_LDIR + '?.lua;' + LUA_LDIR + '?\\init.lua;' + LUA_JSDIR + '?.lua;' + LUA_JSDIR + '?\\init.lua;' + LUA_SHRDIR + '?.lua;' + LUA_SHRDIR + '?\\init.lua;' + '.\\?.lua;.\\?\\init.lua' ); - LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = defs.to_luastring( LUA_JSDIR + '?.js;' + LUA_JSDIR + '..\\share\\lua\\' + LUA_VDIR + '\\?.js;' + LUA_JSDIR + 'loadall.js;.\\?.js' @@ -91,14 +87,14 @@ if (typeof process === 'undefined') { LUA_JSDIR = LUA_LDIR; const LUA_JSDIR2 = LUA_LDIR2; - LUA_PATH_DEFAULT = to_luastring( + LUA_PATH_DEFAULT = defs.to_luastring( LUA_LDIR + '?.lua;' + LUA_LDIR + '?/init.lua;' + LUA_LDIR2 + '?.lua;' + LUA_LDIR2 + '?/init.lua;' + /* LUA_JSDIR(2) excluded as it is equal to LUA_LDIR(2) */ './?.lua;./?/init.lua' ); - LUA_JSPATH_DEFAULT = to_luastring( + LUA_JSPATH_DEFAULT = defs.to_luastring( LUA_JSDIR + '?.js;' + LUA_JSDIR + 'loadall.js;' + LUA_JSDIR2 + '?.js;' + LUA_JSDIR2 + 'loadall.js;' + './?.js' @@ -111,37 +107,37 @@ if (typeof process === 'undefined') { ** This macro is not on by default even in compatibility mode, ** because this is not really an incompatibility. */ -const LUA_COMPAT_FLOATSTRING = conf.LUA_COMPAT_FLOATSTRING || false; +export const LUA_COMPAT_FLOATSTRING = conf.LUA_COMPAT_FLOATSTRING || false; -const LUA_MAXINTEGER = 2147483647; -const LUA_MININTEGER = -2147483648; +export const LUA_MAXINTEGER = 2147483647; +export const LUA_MININTEGER = -2147483648; /* @@ LUA_IDSIZE gives the maximum size for the description of the source @@ of a function in debug information. ** CHANGE it if you want a different size. */ -const LUA_IDSIZE = conf.LUA_IDSIZE || (60 - 1); /* fengari uses 1 less than lua as we don't embed the null byte */ +export const LUA_IDSIZE = conf.LUA_IDSIZE || (60 - 1); /* fengari uses 1 less than lua as we don't embed the null byte */ -const lua_integer2str = function (n) { +export const lua_integer2str = function (n) { return String(n); /* should match behaviour of LUA_INTEGER_FMT */ }; -const lua_number2str = function (n) { +export const lua_number2str = function (n) { return String(Number(n.toPrecision(14))); /* should match behaviour of LUA_NUMBER_FMT */ }; -const lua_numbertointeger = function (n) { +export const lua_numbertointeger = function (n) { return n >= LUA_MININTEGER && n < -LUA_MININTEGER ? n : false; }; -const LUA_INTEGER_FRMLEN = ''; -const LUA_NUMBER_FRMLEN = ''; +export const LUA_INTEGER_FRMLEN = ''; +export const LUA_NUMBER_FRMLEN = ''; -const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; -const LUA_NUMBER_FMT = '%.14g'; +export const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; +export const LUA_NUMBER_FMT = '%.14g'; -const lua_getlocaledecpoint = function () { +export const lua_getlocaledecpoint = function () { /* we hard-code the decimal point to '.' as a user cannot change the locale in most JS environments, and in that you can, a multi-byte locale is common. @@ -152,10 +148,10 @@ const lua_getlocaledecpoint = function () { /* @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. */ -const LUAL_BUFFERSIZE = conf.LUAL_BUFFERSIZE || 8192; +export const LUAL_BUFFERSIZE = conf.LUAL_BUFFERSIZE || 8192; // See: http://croquetweak.blogspot.fr/2014/08/deconstructing-floats-frexp-and-ldexp.html -const frexp = function (value) { +export const frexp = function (value) { if (value === 0) return [value, 0]; var data = new DataView(new ArrayBuffer(8)); data.setFloat64(0, value); @@ -169,41 +165,10 @@ const frexp = function (value) { return [mantissa, exponent]; }; -const ldexp = function (mantissa, exponent) { +export const ldexp = function (mantissa, exponent) { var steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023)); var result = mantissa; for (var i = 0; i < steps; i++) result *= Math.pow(2, Math.floor((exponent + i) / steps)); return result; }; - -const _LUA_COMPAT_FLOATSTRING = LUA_COMPAT_FLOATSTRING; -export { _LUA_COMPAT_FLOATSTRING as LUA_COMPAT_FLOATSTRING }; -const _LUA_IDSIZE = LUA_IDSIZE; -export { _LUA_IDSIZE as LUA_IDSIZE }; -const _LUA_INTEGER_FMT = LUA_INTEGER_FMT; -export { _LUA_INTEGER_FMT as LUA_INTEGER_FMT }; -const _LUA_INTEGER_FRMLEN = LUA_INTEGER_FRMLEN; -export { _LUA_INTEGER_FRMLEN as LUA_INTEGER_FRMLEN }; -const _LUA_MAXINTEGER = LUA_MAXINTEGER; -export { _LUA_MAXINTEGER as LUA_MAXINTEGER }; -const _LUA_MININTEGER = LUA_MININTEGER; -export { _LUA_MININTEGER as LUA_MININTEGER }; -const _LUA_NUMBER_FMT = LUA_NUMBER_FMT; -export { _LUA_NUMBER_FMT as LUA_NUMBER_FMT }; -const _LUA_NUMBER_FRMLEN = LUA_NUMBER_FRMLEN; -export { _LUA_NUMBER_FRMLEN as LUA_NUMBER_FRMLEN }; -const _LUAL_BUFFERSIZE = LUAL_BUFFERSIZE; -export { _LUAL_BUFFERSIZE as LUAL_BUFFERSIZE }; -const _frexp = frexp; -export { _frexp as frexp }; -const _ldexp = ldexp; -export { _ldexp as ldexp }; -const _lua_getlocaledecpoint = lua_getlocaledecpoint; -export { _lua_getlocaledecpoint as lua_getlocaledecpoint }; -const _lua_integer2str = lua_integer2str; -export { _lua_integer2str as lua_integer2str }; -const _lua_number2str = lua_number2str; -export { _lua_number2str as lua_number2str }; -const _lua_numbertointeger = lua_numbertointeger; -export { _lua_numbertointeger as lua_numbertointeger }; diff --git a/src/lualib.js b/src/lualib.js index a592c1a2..ebae6fb7 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -12,54 +12,31 @@ export { luaopen_package } from './loadlib.js'; export { luaopen_fengari } from './fengarilib.js'; import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR } from './lua.js'; -const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; -const _LUA_VERSUFFIX = LUA_VERSUFFIX; -export { _LUA_VERSUFFIX as LUA_VERSUFFIX }; +export const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; export function lua_assert(_c) { } export { luaopen_base } from './lbaselib.js'; -const LUA_COLIBNAME = 'coroutine'; -const _LUA_COLIBNAME = LUA_COLIBNAME; -export { _LUA_COLIBNAME as LUA_COLIBNAME }; +export const LUA_COLIBNAME = 'coroutine'; -const LUA_TABLIBNAME = 'table'; -const _LUA_TABLIBNAME = LUA_TABLIBNAME; -export { _LUA_TABLIBNAME as LUA_TABLIBNAME }; +export const LUA_TABLIBNAME = 'table'; export const LUA_IOLIBNAME = 'io'; -const LUA_OSLIBNAME = 'os'; -const _LUA_OSLIBNAME = LUA_OSLIBNAME; -export { _LUA_OSLIBNAME as LUA_OSLIBNAME }; +export const LUA_OSLIBNAME = 'os'; -const LUA_STRLIBNAME = 'string'; -const _LUA_STRLIBNAME = LUA_STRLIBNAME; -export { _LUA_STRLIBNAME as LUA_STRLIBNAME }; +export const LUA_STRLIBNAME = 'string'; -const LUA_UTF8LIBNAME = 'utf8'; -const _LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; -export { _LUA_UTF8LIBNAME as LUA_UTF8LIBNAME }; +export const LUA_UTF8LIBNAME = 'utf8'; -const LUA_BITLIBNAME = 'bit32'; -const _LUA_BITLIBNAME = LUA_BITLIBNAME; -export { _LUA_BITLIBNAME as LUA_BITLIBNAME }; +export const LUA_BITLIBNAME = 'bit32'; // module.exports.luaopen_bit32 = require("./lbitlib.js").luaopen_bit32; -const LUA_MATHLIBNAME = 'math'; -const _LUA_MATHLIBNAME = LUA_MATHLIBNAME; -export { _LUA_MATHLIBNAME as LUA_MATHLIBNAME }; +export const LUA_MATHLIBNAME = 'math'; -const LUA_DBLIBNAME = 'debug'; -const _LUA_DBLIBNAME = LUA_DBLIBNAME; -export { _LUA_DBLIBNAME as LUA_DBLIBNAME }; +export const LUA_DBLIBNAME = 'debug'; -const LUA_LOADLIBNAME = 'package'; -const _LUA_LOADLIBNAME = LUA_LOADLIBNAME; -export { _LUA_LOADLIBNAME as LUA_LOADLIBNAME }; - -const LUA_FENGARILIBNAME = 'fengari'; -const _LUA_FENGARILIBNAME = LUA_FENGARILIBNAME; -export { _LUA_FENGARILIBNAME as LUA_FENGARILIBNAME }; +export const LUA_LOADLIBNAME = 'package'; +export const LUA_FENGARILIBNAME = 'fengari'; diff --git a/src/lundump.js b/src/lundump.js index 307e509f..9223cec6 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -1,11 +1,11 @@ -import { LUA_SIGNATURE, constant_types, thread_status, is_luastring, luastring_eq, to_luastring } from './defs.js'; -import { luaD_throw, luaD_inctop } from './ldo.js'; -import { Proto, luaF_newLclosure } from './lfunc.js'; -import { TValue, luaO_pushfstring } from './lobject.js'; -import { MAXARG_sBx, POS_A, POS_Ax, POS_B, POS_Bx, POS_C, POS_OP, SIZE_A, SIZE_Ax, SIZE_B, SIZE_Bx, SIZE_C, SIZE_OP } from './lopcodes.js'; -import { lua_assert } from './llimits.js'; -import { luaS_bless } from './lstring.js'; -import { luaZ_read, ZIO } from './lzio.js'; +import * as defs from './defs.js'; +import * as ldo from './ldo.js'; +import * as lfunc from './lfunc.js'; +import * as lobject from './lobject.js'; +import * as lopcodes from './lopcodes.js'; +import * as llimits from './llimits.js'; +import * as lstring from './lstring.js'; +import * as lzio from './lzio.js'; const { LUA_TBOOLEAN, @@ -14,9 +14,9 @@ const { LUA_TNUMFLT, LUA_TNUMINT, LUA_TSHRSTR -} = constant_types; +} = defs.constant_types; -const { LUA_ERRSYNTAX } = thread_status; +const { LUA_ERRSYNTAX } = defs.thread_status; let LUAC_DATA = [0x19, 0x93, 13, 10, 0x1a, 10]; @@ -29,13 +29,13 @@ class BytecodeParser { this.integerSize = 4; this.numberSize = 8; - lua_assert(Z instanceof ZIO, 'BytecodeParser only operates on a ZIO'); - lua_assert(is_luastring(name)); + llimits.lua_assert(Z instanceof lzio.ZIO, 'BytecodeParser only operates on a ZIO'); + llimits.lua_assert(defs.is_luastring(name)); if (name[0] === 64 /* ('@').charCodeAt(0) */ || name[0] === 61 /* ('=').charCodeAt(0) */) this.name = name.subarray(1); - else if (name[0] == LUA_SIGNATURE[0]) - this.name = to_luastring('binary string', true); + else if (name[0] == defs.LUA_SIGNATURE[0]) + this.name = defs.to_luastring('binary string', true); else this.name = name; @@ -52,31 +52,31 @@ class BytecodeParser { read(size) { let u8 = new Uint8Array(size); - if (luaZ_read(this.Z, u8, 0, size) !== 0) + if (lzio.luaZ_read(this.Z, u8, 0, size) !== 0) this.error('truncated'); return u8; } LoadByte() { - if (luaZ_read(this.Z, this.u8, 0, 1) !== 0) + if (lzio.luaZ_read(this.Z, this.u8, 0, 1) !== 0) this.error('truncated'); return this.u8[0]; } LoadInt() { - if (luaZ_read(this.Z, this.u8, 0, this.intSize) !== 0) + if (lzio.luaZ_read(this.Z, this.u8, 0, this.intSize) !== 0) this.error('truncated'); return this.dv.getInt32(0, true); } LoadNumber() { - if (luaZ_read(this.Z, this.u8, 0, this.numberSize) !== 0) + if (lzio.luaZ_read(this.Z, this.u8, 0, this.numberSize) !== 0) this.error('truncated'); return this.dv.getFloat64(0, true); } LoadInteger() { - if (luaZ_read(this.Z, this.u8, 0, this.integerSize) !== 0) + if (lzio.luaZ_read(this.Z, this.u8, 0, this.integerSize) !== 0) this.error('truncated'); return this.dv.getInt32(0, true); } @@ -91,7 +91,7 @@ class BytecodeParser { size = this.LoadSize_t(); if (size === 0) return null; - return luaS_bless(this.L, this.read(size - 1)); + return lstring.luaS_bless(this.L, this.read(size - 1)); } /* creates a mask with 'n' 1 bits at position 'p' */ @@ -104,18 +104,18 @@ class BytecodeParser { let p = BytecodeParser; for (let i = 0; i < n; i++) { - if (luaZ_read(this.Z, this.u8, 0, this.instructionSize) !== 0) + if (lzio.luaZ_read(this.Z, this.u8, 0, this.instructionSize) !== 0) this.error('truncated'); let ins = this.dv.getUint32(0, true); f.code[i] = { code: ins, - opcode: (ins >> POS_OP) & p.MASK1(SIZE_OP, 0), - A: (ins >> POS_A) & p.MASK1(SIZE_A, 0), - B: (ins >> POS_B) & p.MASK1(SIZE_B, 0), - C: (ins >> POS_C) & p.MASK1(SIZE_C, 0), - Bx: (ins >> POS_Bx) & p.MASK1(SIZE_Bx, 0), - Ax: (ins >> POS_Ax) & p.MASK1(SIZE_Ax, 0), - sBx: ((ins >> POS_Bx) & p.MASK1(SIZE_Bx, 0)) - MAXARG_sBx + opcode: (ins >> lopcodes.POS_OP) & p.MASK1(lopcodes.SIZE_OP, 0), + A: (ins >> lopcodes.POS_A) & p.MASK1(lopcodes.SIZE_A, 0), + B: (ins >> lopcodes.POS_B) & p.MASK1(lopcodes.SIZE_B, 0), + C: (ins >> lopcodes.POS_C) & p.MASK1(lopcodes.SIZE_C, 0), + Bx: (ins >> lopcodes.POS_Bx) & p.MASK1(lopcodes.SIZE_Bx, 0), + Ax: (ins >> lopcodes.POS_Ax) & p.MASK1(lopcodes.SIZE_Ax, 0), + sBx: ((ins >> lopcodes.POS_Bx) & p.MASK1(lopcodes.SIZE_Bx, 0)) - lopcodes.MAXARG_sBx }; } } @@ -128,20 +128,20 @@ class BytecodeParser { switch (t) { case LUA_TNIL: - f.k.push(new TValue(LUA_TNIL, null)); + f.k.push(new lobject.TValue(LUA_TNIL, null)); break; case LUA_TBOOLEAN: - f.k.push(new TValue(LUA_TBOOLEAN, this.LoadByte() !== 0)); + f.k.push(new lobject.TValue(LUA_TBOOLEAN, this.LoadByte() !== 0)); break; case LUA_TNUMFLT: - f.k.push(new TValue(LUA_TNUMFLT, this.LoadNumber())); + f.k.push(new lobject.TValue(LUA_TNUMFLT, this.LoadNumber())); break; case LUA_TNUMINT: - f.k.push(new TValue(LUA_TNUMINT, this.LoadInteger())); + f.k.push(new lobject.TValue(LUA_TNUMINT, this.LoadInteger())); break; case LUA_TSHRSTR: case LUA_TLNGSTR: - f.k.push(new TValue(LUA_TLNGSTR, this.LoadString())); + f.k.push(new lobject.TValue(LUA_TLNGSTR, this.LoadString())); break; default: this.error(`unrecognized constant '${t}'`); @@ -153,7 +153,7 @@ class BytecodeParser { let n = this.LoadInt(); for (let i = 0; i < n; i++) { - f.p[i] = new Proto(this.L); + f.p[i] = new lfunc.Proto(this.L); this.LoadFunction(f.p[i], f.source); } } @@ -208,12 +208,12 @@ class BytecodeParser { checkliteral(s, msg) { let buff = this.read(s.length); - if (!luastring_eq(buff, s)) + if (!defs.luastring_eq(buff, s)) this.error(msg); } checkHeader() { - this.checkliteral(LUA_SIGNATURE.subarray(1), 'not a'); /* 1st char already checked */ + this.checkliteral(defs.LUA_SIGNATURE.subarray(1), 'not a'); /* 1st char already checked */ if (this.LoadByte() !== 0x53) this.error('version mismatch in'); @@ -244,8 +244,8 @@ class BytecodeParser { } error(why) { - luaO_pushfstring(this.L, to_luastring('%s: %s precompiled chunk'), this.name, to_luastring(why)); - luaD_throw(this.L, LUA_ERRSYNTAX); + lobject.luaO_pushfstring(this.L, defs.to_luastring('%s: %s precompiled chunk'), this.name, defs.to_luastring(why)); + ldo.luaD_throw(this.L, LUA_ERRSYNTAX); } checksize(byte, size, tname) { @@ -254,18 +254,15 @@ class BytecodeParser { } } -const luaU_undump = function (L, Z, name) { +export const luaU_undump = function (L, Z, name) { let S = new BytecodeParser(L, Z, name); S.checkHeader(); - let cl = luaF_newLclosure(L, S.LoadByte()); - luaD_inctop(L); + let cl = lfunc.luaF_newLclosure(L, S.LoadByte()); + ldo.luaD_inctop(L); L.stack[L.top - 1].setclLvalue(cl); - cl.p = new Proto(L); + cl.p = new lfunc.Proto(L); S.LoadFunction(cl.p, null); - lua_assert(cl.nupvalues === cl.p.upvalues.length); + llimits.lua_assert(cl.nupvalues === cl.p.upvalues.length); /* luai_verifycode */ return cl; }; - -const _luaU_undump = luaU_undump; -export { _luaU_undump as luaU_undump }; diff --git a/src/lutf8lib.js b/src/lutf8lib.js index 0fc339af..7713c4a8 100644 --- a/src/lutf8lib.js +++ b/src/lutf8lib.js @@ -1,6 +1,6 @@ -import { lua_gettop, lua_pushcfunction, lua_pushfstring, lua_pushinteger, lua_pushnil, lua_pushstring, lua_pushvalue, lua_setfield, lua_tointeger } from './lua.js'; -import { luaL_Buffer, luaL_addvalue, luaL_argcheck, luaL_buffinit, luaL_checkinteger, luaL_checkstack, luaL_checkstring, luaL_error, luaL_newlib, luaL_optinteger, luaL_pushresult } from './lauxlib.js'; -import { luastring_of, to_luastring } from './fengaricore.js'; +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as fengaricore from './fengaricore.js'; const MAXUNICODE = 0x10FFFF; @@ -53,50 +53,50 @@ const utf8_decode = function(s, pos) { */ const utflen = function(L) { let n = 0; - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let len = s.length; - let posi = u_posrelat(luaL_optinteger(L, 2, 1), len); - let posj = u_posrelat(luaL_optinteger(L, 3, -1), len); + let posi = u_posrelat(lauxlib.luaL_optinteger(L, 2, 1), len); + let posj = u_posrelat(lauxlib.luaL_optinteger(L, 3, -1), len); - luaL_argcheck(L, 1 <= posi && --posi <= len, 2, 'initial position out of string'); - luaL_argcheck(L, --posj < len, 3, 'final position out of string'); + lauxlib.luaL_argcheck(L, 1 <= posi && --posi <= len, 2, 'initial position out of string'); + lauxlib.luaL_argcheck(L, --posj < len, 3, 'final position out of string'); while (posi <= posj) { let dec = utf8_decode(s, posi); if (dec === null) { /* conversion error? */ - lua_pushnil(L); /* return nil ... */ - lua_pushinteger(L, posi + 1); /* ... and current position */ + lua.lua_pushnil(L); /* return nil ... */ + lua.lua_pushinteger(L, posi + 1); /* ... and current position */ return 2; } posi = dec.pos; n++; } - lua_pushinteger(L, n); + lua.lua_pushinteger(L, n); return 1; }; -const p_U = to_luastring('%U'); +const p_U = fengaricore.to_luastring('%U'); const pushutfchar = function(L, arg) { - let code = luaL_checkinteger(L, arg); - luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, 'value out of range'); - lua_pushfstring(L, p_U, code); + let code = lauxlib.luaL_checkinteger(L, arg); + lauxlib.luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, 'value out of range'); + lua.lua_pushfstring(L, p_U, code); }; /* ** utfchar(n1, n2, ...) -> char(n1)..char(n2)... */ const utfchar = function(L) { - let n = lua_gettop(L); /* number of arguments */ + let n = lua.lua_gettop(L); /* number of arguments */ if (n === 1) /* optimize common case of single char */ pushutfchar(L, 1); else { - let b = new luaL_Buffer(); - luaL_buffinit(L, b); + let b = new lauxlib.luaL_Buffer(); + lauxlib.luaL_buffinit(L, b); for (let i = 1; i <= n; i++) { pushutfchar(L, i); - luaL_addvalue(b); + lauxlib.luaL_addvalue(b); } - luaL_pushresult(b); + lauxlib.luaL_pushresult(b); } return 1; }; @@ -106,19 +106,19 @@ const utfchar = function(L) { ** position 'i' starts; 0 means character at 'i'. */ const byteoffset = function(L) { - let s = luaL_checkstring(L, 1); - let n = luaL_checkinteger(L, 2); + let s = lauxlib.luaL_checkstring(L, 1); + let n = lauxlib.luaL_checkinteger(L, 2); let posi = n >= 0 ? 1 : s.length + 1; - posi = u_posrelat(luaL_optinteger(L, 3, posi), s.length); + posi = u_posrelat(lauxlib.luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, 'position out of range'); + lauxlib.luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, 'position out of range'); if (n === 0) { /* find beginning of current byte sequence */ while (posi > 0 && iscont(s[posi])) posi--; } else { if (iscont(s[posi])) - luaL_error(L, 'initial position is a continuation byte'); + lauxlib.luaL_error(L, 'initial position is a continuation byte'); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ @@ -139,9 +139,9 @@ const byteoffset = function(L) { } if (n === 0) /* did it find given character? */ - lua_pushinteger(L, posi + 1); + lua.lua_pushinteger(L, posi + 1); else /* no such character */ - lua_pushnil(L); + lua.lua_pushnil(L); return 1; }; @@ -151,24 +151,24 @@ const byteoffset = function(L) { ** that start in the range [i,j] */ const codepoint = function(L) { - let s = luaL_checkstring(L, 1); - let posi = u_posrelat(luaL_optinteger(L, 2, 1), s.length); - let pose = u_posrelat(luaL_optinteger(L, 3, posi), s.length); + let s = lauxlib.luaL_checkstring(L, 1); + let posi = u_posrelat(lauxlib.luaL_optinteger(L, 2, 1), s.length); + let pose = u_posrelat(lauxlib.luaL_optinteger(L, 3, posi), s.length); - luaL_argcheck(L, posi >= 1, 2, 'out of range'); - luaL_argcheck(L, pose <= s.length, 3, 'out of range'); + lauxlib.luaL_argcheck(L, posi >= 1, 2, 'out of range'); + lauxlib.luaL_argcheck(L, pose <= s.length, 3, 'out of range'); if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= Number.MAX_SAFE_INTEGER) - return luaL_error(L, 'string slice too long'); + return lauxlib.luaL_error(L, 'string slice too long'); let n = (pose - posi) + 1; - luaL_checkstack(L, n, 'string slice too long'); + lauxlib.luaL_checkstack(L, n, 'string slice too long'); n = 0; for (posi -= 1; posi < pose;) { let dec = utf8_decode(s, posi); if (dec === null) - return luaL_error(L, 'invalid UTF-8 code'); - lua_pushinteger(L, dec.code); + return lauxlib.luaL_error(L, 'invalid UTF-8 code'); + lua.lua_pushinteger(L, dec.code); posi = dec.pos; n++; } @@ -176,9 +176,9 @@ const codepoint = function(L) { }; const iter_aux = function(L) { - let s = luaL_checkstring(L, 1); + let s = lauxlib.luaL_checkstring(L, 1); let len = s.length; - let n = lua_tointeger(L, 2) - 1; + let n = lua.lua_tointeger(L, 2) - 1; if (n < 0) /* first iteration? */ n = 0; /* start from here */ @@ -192,18 +192,18 @@ const iter_aux = function(L) { else { let dec = utf8_decode(s, n); if (dec === null || iscont(s[dec.pos])) - return luaL_error(L, to_luastring('invalid UTF-8 code')); - lua_pushinteger(L, n + 1); - lua_pushinteger(L, dec.code); + return lauxlib.luaL_error(L, fengaricore.to_luastring('invalid UTF-8 code')); + lua.lua_pushinteger(L, n + 1); + lua.lua_pushinteger(L, dec.code); return 2; } }; const iter_codes = function(L) { - luaL_checkstring(L, 1); - lua_pushcfunction(L, iter_aux); - lua_pushvalue(L, 1); - lua_pushinteger(L, 0); + lauxlib.luaL_checkstring(L, 1); + lua.lua_pushcfunction(L, iter_aux); + lua.lua_pushvalue(L, 1); + lua.lua_pushinteger(L, 0); return 3; }; @@ -216,14 +216,11 @@ const funcs = { }; /* pattern to match a single UTF-8 character */ -const UTF8PATT = luastring_of(91, 0, 45, 127, 194, 45, 244, 93, 91, 128, 45, 191, 93, 42); +const UTF8PATT = fengaricore.luastring_of(91, 0, 45, 127, 194, 45, 244, 93, 91, 128, 45, 191, 93, 42); -const luaopen_utf8 = function(L) { - luaL_newlib(L, funcs); - lua_pushstring(L, UTF8PATT); - lua_setfield(L, -2, to_luastring('charpattern', true)); +export const luaopen_utf8 = function(L) { + lauxlib.luaL_newlib(L, funcs); + lua.lua_pushstring(L, UTF8PATT); + lua.lua_setfield(L, -2, fengaricore.to_luastring('charpattern', true)); return 1; }; - -const _luaopen_utf8 = luaopen_utf8; -export { _luaopen_utf8 as luaopen_utf8 }; diff --git a/src/lvm.js b/src/lvm.js index 22c3345e..024a2da6 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -1,17 +1,17 @@ -import { LUA_MASKLINE, LUA_MASKCOUNT, LUA_MULTRET, constant_types, to_luastring } from './defs.js'; -import { INDEXK, ISK, LFIELDS_PER_FLUSH, OpCodesI } from './lopcodes.js'; -import { LUA_MAXINTEGER, LUA_MININTEGER, lua_numbertointeger } from './luaconf.js'; -import { lua_assert, luai_nummod } from './llimits.js'; -import { setobjs2s, setobj2s, TValue, luaO_str2num, LClosure, luaO_tostring, setsvalue2s } from './lobject.js'; -import { luaF_close, luaF_findupval } from './lfunc.js'; -import { CIST_LEQ, CIST_FRESH, CIST_TAIL, CIST_LUA } from './lstate.js'; -import { luaS_bless, luaS_eqlngstr, luaS_hashlongstr } from './lstring.js'; -import { adjust_top, luaD_precall, luaD_poscall, luaD_call, luaD_checkstack } from './ldo.js'; -import { luaT_trybinTM, TMS, luaT_callorderTM, fasttm, luaT_callTM, luaT_gettmbyobj } from './ltm.js'; -import { luaH_new, luaH_setint, luaH_getn, luaH_get, luaH_setfrom, invalidateTMcache } from './ltable.js'; -import { luaG_traceexec, luaG_runerror, luaG_ordererror, luaG_typeerror } from './ldebug.js'; - -const { +import * as defs from './defs.js'; +import * as lopcodes from './lopcodes.js'; +import * as luaconf from './luaconf.js'; +import * as llimits from './llimits.js'; +import * as lobject from './lobject.js'; +import * as lfunc from './lfunc.js'; +import * as lstate from './lstate.js'; +import * as lstring from './lstring.js'; +import * as ldo from './ldo.js'; +import * as ltm from './ltm.js'; +import * as ltable from './ltable.js'; +import * as ldebug from './ldebug.js'; + +export const { LUA_TBOOLEAN, LUA_TLCF, LUA_TLIGHTUSERDATA, @@ -23,9 +23,9 @@ const { LUA_TSHRSTR, LUA_TTABLE, LUA_TUSERDATA -} = constant_types; +} = defs.constant_types; -const { +export const { OP_ADD, OP_BAND, OP_BNOT, @@ -73,12 +73,12 @@ const { OP_TFORLOOP, OP_UNM, OP_VARARG -} = OpCodesI; +} = lopcodes.OpCodesI; /* ** finish execution of an opcode interrupted by an yield */ -const luaV_finishOp = function (L) { +export const luaV_finishOp = function (L) { let ci = L.ci; let base = ci.l_base; let inst = ci.l_code[ci.l_savedpc - 1]; /* interrupted instruction */ @@ -90,19 +90,19 @@ const luaV_finishOp = function (L) { case OP_MOD: case OP_POW: case OP_UNM: case OP_BNOT: case OP_LEN: case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { - setobjs2s(L, base + inst.A, L.top - 1); + lobject.setobjs2s(L, base + inst.A, L.top - 1); delete L.stack[--L.top]; break; } case OP_LE: case OP_LT: case OP_EQ: { let res = !L.stack[L.top - 1].l_isfalse(); delete L.stack[--L.top]; - if (ci.callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ - lua_assert(op === OP_LE); - ci.callstatus ^= CIST_LEQ; /* clear mark */ + if (ci.callstatus & lstate.CIST_LEQ) { /* "<=" using "<" instead? */ + llimits.lua_assert(op === OP_LE); + ci.callstatus ^= lstate.CIST_LEQ; /* clear mark */ res = !res; /* negate result */ } - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_JMP); + llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_JMP); if (res !== (inst.A ? true : false)) /* condition failed? */ ci.l_savedpc++; /* skip jump instruction */ break; @@ -111,34 +111,34 @@ const luaV_finishOp = function (L) { let top = L.top - 1; /* top when 'luaT_trybinTM' was called */ let b = inst.B; /* first element to concatenate */ let total = top - 1 - (base + b); /* yet to concatenate */ - setobjs2s(L, top - 2, top); /* put TM result in proper position */ + lobject.setobjs2s(L, top - 2, top); /* put TM result in proper position */ if (total > 1) { /* are there elements to concat? */ L.top = top - 1; /* top is one after last element (at top-2) */ luaV_concat(L, total); /* concat them (may yield again) */ } /* move final result to final position */ - setobjs2s(L, ci.l_base + inst.A, L.top - 1); - adjust_top(L, ci.top); /* restore top */ + lobject.setobjs2s(L, ci.l_base + inst.A, L.top - 1); + ldo.adjust_top(L, ci.top); /* restore top */ break; } case OP_TFORCALL: { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_TFORLOOP); - adjust_top(L, ci.top); /* correct top */ + llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_TFORLOOP); + ldo.adjust_top(L, ci.top); /* correct top */ break; } case OP_CALL: { if (inst.C - 1 >= 0) /* nresults >= 0? */ - adjust_top(L, ci.top); /* adjust results */ + ldo.adjust_top(L, ci.top); /* adjust results */ break; } } }; -const RA = function (L, base, i) { +export const RA = function (L, base, i) { return base + i.A; }; -const RB = function (L, base, i) { +export const RB = function (L, base, i) { return base + i.B; }; @@ -146,29 +146,29 @@ const RB = function (L, base, i) { // return base + i.C; // }; -const RKB = function (L, base, k, i) { - return ISK(i.B) ? k[INDEXK(i.B)] : L.stack[base + i.B]; +export const RKB = function (L, base, k, i) { + return lopcodes.ISK(i.B) ? k[lopcodes.INDEXK(i.B)] : L.stack[base + i.B]; }; -const RKC = function (L, base, k, i) { - return ISK(i.C) ? k[INDEXK(i.C)] : L.stack[base + i.C]; +export const RKC = function (L, base, k, i) { + return lopcodes.ISK(i.C) ? k[lopcodes.INDEXK(i.C)] : L.stack[base + i.C]; }; -const luaV_execute = function (L) { +export const luaV_execute = function (L) { let ci = L.ci; - ci.callstatus |= CIST_FRESH; + ci.callstatus |= lstate.CIST_FRESH; newframe: for (; ;) { - lua_assert(ci === L.ci); + llimits.lua_assert(ci === L.ci); let cl = ci.func.value; let k = cl.p.k; let base = ci.l_base; let i = ci.l_code[ci.l_savedpc++]; - if (L.hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) { - luaG_traceexec(L); + if (L.hookmask & (defs.LUA_MASKLINE | defs.LUA_MASKCOUNT)) { + ldebug.luaG_traceexec(L); } let ra = RA(L, base, i); @@ -176,18 +176,18 @@ const luaV_execute = function (L) { switch (opcode) { case OP_MOVE: { - setobjs2s(L, ra, RB(L, base, i)); + lobject.setobjs2s(L, ra, RB(L, base, i)); break; } case OP_LOADK: { let konst = k[i.Bx]; - setobj2s(L, ra, konst); + lobject.setobj2s(L, ra, konst); break; } case OP_LOADKX: { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); + llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); let konst = k[ci.l_code[ci.l_savedpc++].Ax]; - setobj2s(L, ra, konst); + lobject.setobj2s(L, ra, konst); break; } case OP_LOADBOOL: { @@ -205,7 +205,7 @@ const luaV_execute = function (L) { } case OP_GETUPVAL: { let b = i.B; - setobj2s(L, ra, cl.upvals[b]); + lobject.setobj2s(L, ra, cl.upvals[b]); break; } case OP_GETTABUP: { @@ -241,13 +241,13 @@ const luaV_execute = function (L) { break; } case OP_NEWTABLE: { - L.stack[ra].sethvalue(luaH_new(L)); + L.stack[ra].sethvalue(ltable.luaH_new(L)); break; } case OP_SELF: { let rb = RB(L, base, i); let rc = RKC(L, base, k, i); - setobjs2s(L, ra + 1, rb); + lobject.setobjs2s(L, ra + 1, rb); luaV_gettable(L, L.stack[rb], rc, ra); break; } @@ -261,7 +261,7 @@ const luaV_execute = function (L) { } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { L.stack[ra].setfltvalue(numberop1 + numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_ADD); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_ADD); } break; } @@ -275,7 +275,7 @@ const luaV_execute = function (L) { } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { L.stack[ra].setfltvalue(numberop1 - numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_SUB); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SUB); } break; } @@ -289,7 +289,7 @@ const luaV_execute = function (L) { } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { L.stack[ra].setfltvalue(numberop1 * numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_MUL); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MUL); } break; } @@ -301,9 +301,9 @@ const luaV_execute = function (L) { if (op1.ttisinteger() && op2.ttisinteger()) { L.stack[ra].setivalue(luaV_mod(L, op1.value, op2.value)); } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { - L.stack[ra].setfltvalue(luai_nummod(L, numberop1, numberop2)); + L.stack[ra].setfltvalue(llimits.luai_nummod(L, numberop1, numberop2)); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_MOD); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MOD); } break; } @@ -315,7 +315,7 @@ const luaV_execute = function (L) { if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { L.stack[ra].setfltvalue(Math.pow(numberop1, numberop2)); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_POW); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_POW); } break; } @@ -327,7 +327,7 @@ const luaV_execute = function (L) { if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { L.stack[ra].setfltvalue(numberop1 / numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_DIV); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_DIV); } break; } @@ -341,7 +341,7 @@ const luaV_execute = function (L) { } else if ((numberop1 = tonumber(op1)) !== false && (numberop2 = tonumber(op2)) !== false) { L.stack[ra].setfltvalue(Math.floor(numberop1 / numberop2)); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_IDIV); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_IDIV); } break; } @@ -353,7 +353,7 @@ const luaV_execute = function (L) { if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { L.stack[ra].setivalue(numberop1 & numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_BAND); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BAND); } break; } @@ -365,7 +365,7 @@ const luaV_execute = function (L) { if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { L.stack[ra].setivalue(numberop1 | numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_BOR); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BOR); } break; } @@ -377,7 +377,7 @@ const luaV_execute = function (L) { if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { L.stack[ra].setivalue(numberop1 ^ numberop2); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_BXOR); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_BXOR); } break; } @@ -389,7 +389,7 @@ const luaV_execute = function (L) { if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { L.stack[ra].setivalue(luaV_shiftl(numberop1, numberop2)); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_SHL); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHL); } break; } @@ -401,7 +401,7 @@ const luaV_execute = function (L) { if ((numberop1 = tointeger(op1)) !== false && (numberop2 = tointeger(op2)) !== false) { L.stack[ra].setivalue(luaV_shiftl(numberop1, -numberop2)); } else { - luaT_trybinTM(L, op1, op2, L.stack[ra], TMS.TM_SHR); + ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_SHR); } break; } @@ -414,7 +414,7 @@ const luaV_execute = function (L) { } else if ((numberop = tonumber(op)) !== false) { L.stack[ra].setfltvalue(-numberop); } else { - luaT_trybinTM(L, op, op, L.stack[ra], TMS.TM_UNM); + ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_UNM); } break; } @@ -424,7 +424,7 @@ const luaV_execute = function (L) { if (op.ttisinteger()) { L.stack[ra].setivalue(~op.value); } else { - luaT_trybinTM(L, op, op, L.stack[ra], TMS.TM_BNOT); + ltm.luaT_trybinTM(L, op, op, L.stack[ra], ltm.TMS.TM_BNOT); } break; } @@ -443,8 +443,8 @@ const luaV_execute = function (L) { L.top = base + c + 1; /* mark the end of concat operands */ luaV_concat(L, c - b + 1); let rb = base + b; - setobjs2s(L, ra, rb); - adjust_top(L, ci.top); /* restore top */ + lobject.setobjs2s(L, ra, rb); + ldo.adjust_top(L, ci.top); /* restore top */ break; } case OP_JMP: { @@ -485,7 +485,7 @@ const luaV_execute = function (L) { if (i.C ? rb.l_isfalse() : !rb.l_isfalse()) ci.l_savedpc++; else { - setobjs2s(L, ra, rbIdx); + lobject.setobjs2s(L, ra, rbIdx); donextjump(L, ci); } break; @@ -493,10 +493,10 @@ const luaV_execute = function (L) { case OP_CALL: { let b = i.B; let nresults = i.C - 1; - if (b !== 0) adjust_top(L, ra + b); /* else previous instruction set top */ - if (luaD_precall(L, ra, nresults)) { + if (b !== 0) ldo.adjust_top(L, ra + b); /* else previous instruction set top */ + if (ldo.luaD_precall(L, ra, nresults)) { if (nresults >= 0) - adjust_top(L, ci.top); /* adjust results */ + ldo.adjust_top(L, ci.top); /* adjust results */ } else { ci = L.ci; continue newframe; @@ -506,8 +506,8 @@ const luaV_execute = function (L) { } case OP_TAILCALL: { let b = i.B; - if (b !== 0) adjust_top(L, ra + b); /* else previous instruction set top */ - if (luaD_precall(L, ra, LUA_MULTRET)) { // JS function + if (b !== 0) ldo.adjust_top(L, ra + b); /* else previous instruction set top */ + if (ldo.luaD_precall(L, ra, defs.LUA_MULTRET)) { // JS function } else { /* tail call: put called frame (n) in place of caller one (o) */ let nci = L.ci; @@ -516,35 +516,35 @@ const luaV_execute = function (L) { let nfuncOff = nci.funcOff; let ofuncOff = oci.funcOff; let lim = nci.l_base + nfunc.value.p.numparams; - if (cl.p.p.length > 0) luaF_close(L, oci.l_base); + if (cl.p.p.length > 0) lfunc.luaF_close(L, oci.l_base); for (let aux = 0; nfuncOff + aux < lim; aux++) - setobjs2s(L, ofuncOff + aux, nfuncOff + aux); + lobject.setobjs2s(L, ofuncOff + aux, nfuncOff + aux); oci.l_base = ofuncOff + (nci.l_base - nfuncOff); oci.top = ofuncOff + (L.top - nfuncOff); - adjust_top(L, oci.top); /* correct top */ + ldo.adjust_top(L, oci.top); /* correct top */ oci.l_code = nci.l_code; oci.l_savedpc = nci.l_savedpc; - oci.callstatus |= CIST_TAIL; + oci.callstatus |= lstate.CIST_TAIL; oci.next = null; ci = L.ci = oci; - lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); + llimits.lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); continue newframe; } break; } case OP_RETURN: { - if (cl.p.p.length > 0) luaF_close(L, base); - let b = luaD_poscall(L, ci, ra, (i.B !== 0 ? i.B - 1 : L.top - ra)); + if (cl.p.p.length > 0) lfunc.luaF_close(L, base); + let b = ldo.luaD_poscall(L, ci, ra, (i.B !== 0 ? i.B - 1 : L.top - ra)); - if (ci.callstatus & CIST_FRESH) + if (ci.callstatus & lstate.CIST_FRESH) return; /* external invocation: return */ /* invocation via reentry: continue execution */ ci = L.ci; - if (b) adjust_top(L, ci.top); - lua_assert(ci.callstatus & CIST_LUA); - lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); + if (b) ldo.adjust_top(L, ci.top); + llimits.lua_assert(ci.callstatus & lstate.CIST_LUA); + llimits.lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); continue newframe; } case OP_FORLOOP: { @@ -585,13 +585,13 @@ const luaV_execute = function (L) { } else { /* try making all values floats */ let nlimit, nstep, ninit; if ((nlimit = tonumber(plimit)) === false) - luaG_runerror(L, to_luastring('\'for\' limit must be a number', true)); + ldebug.luaG_runerror(L, defs.to_luastring('\'for\' limit must be a number', true)); L.stack[ra + 1].setfltvalue(nlimit); if ((nstep = tonumber(pstep)) === false) - luaG_runerror(L, to_luastring('\'for\' step must be a number', true)); + ldebug.luaG_runerror(L, defs.to_luastring('\'for\' step must be a number', true)); L.stack[ra + 2].setfltvalue(nstep); if ((ninit = tonumber(init)) === false) - luaG_runerror(L, to_luastring('\'for\' initial value must be a number', true)); + ldebug.luaG_runerror(L, defs.to_luastring('\'for\' initial value must be a number', true)); L.stack[ra].setfltvalue(ninit - nstep); } @@ -600,21 +600,21 @@ const luaV_execute = function (L) { } case OP_TFORCALL: { let cb = ra + 3; /* call base */ - setobjs2s(L, cb + 2, ra + 2); - setobjs2s(L, cb + 1, ra + 1); - setobjs2s(L, cb, ra); - adjust_top(L, cb + 3); /* func. + 2 args (state and index) */ - luaD_call(L, cb, i.C); - adjust_top(L, ci.top); + lobject.setobjs2s(L, cb + 2, ra + 2); + lobject.setobjs2s(L, cb + 1, ra + 1); + lobject.setobjs2s(L, cb, ra); + ldo.adjust_top(L, cb + 3); /* func. + 2 args (state and index) */ + ldo.luaD_call(L, cb, i.C); + ldo.adjust_top(L, ci.top); /* go straight to OP_TFORLOOP */ i = ci.l_code[ci.l_savedpc++]; ra = RA(L, base, i); - lua_assert(i.opcode === OP_TFORLOOP); + llimits.lua_assert(i.opcode === OP_TFORLOOP); } /* fall through */ case OP_TFORLOOP: { if (!L.stack[ra + 1].ttisnil()) { /* continue loop? */ - setobjs2s(L, ra, ra + 1); /* save control variable */ + lobject.setobjs2s(L, ra, ra + 1); /* save control variable */ ci.l_savedpc += i.sBx; /* jump back */ } break; @@ -626,17 +626,17 @@ const luaV_execute = function (L) { if (n === 0) n = L.top - ra - 1; if (c === 0) { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); + llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_EXTRAARG); c = ci.l_code[ci.l_savedpc++].Ax; } let h = L.stack[ra].value; - let last = ((c - 1) * LFIELDS_PER_FLUSH) + n; + let last = ((c - 1) * lopcodes.LFIELDS_PER_FLUSH) + n; for (; n > 0; n--) { - luaH_setint(h, last--, L.stack[ra + n]); + ltable.luaH_setint(h, last--, L.stack[ra + n]); } - adjust_top(L, ci.top); /* correct top (in case of previous open call) */ + ldo.adjust_top(L, ci.top); /* correct top (in case of previous open call) */ break; } case OP_CLOSURE: { @@ -658,12 +658,12 @@ const luaV_execute = function (L) { if (b < 0) { b = n; /* get all var. arguments */ - luaD_checkstack(L, n); - adjust_top(L, ra + n); + ldo.luaD_checkstack(L, n); + ldo.adjust_top(L, ra + n); } for (j = 0; j < b && j < n; j++) - setobjs2s(L, ra + j, base - n + j); + lobject.setobjs2s(L, ra + j, base - n + j); for (; j < b; j++) /* complete required results with nil */ L.stack[ra + j].setnilvalue(); @@ -676,31 +676,31 @@ const luaV_execute = function (L) { } }; -const dojump = function (L, ci, i, e) { +export const dojump = function (L, ci, i, e) { let a = i.A; - if (a !== 0) luaF_close(L, ci.l_base + a - 1); + if (a !== 0) lfunc.luaF_close(L, ci.l_base + a - 1); ci.l_savedpc += i.sBx + e; }; -const donextjump = function (L, ci) { +export const donextjump = function (L, ci) { dojump(L, ci, ci.l_code[ci.l_savedpc], 1); }; -const luaV_lessthan = function (L, l, r) { +export const luaV_lessthan = function (L, l, r) { if (l.ttisnumber() && r.ttisnumber()) return LTnum(l, r) ? 1 : 0; else if (l.ttisstring() && r.ttisstring()) return l_strcmp(l.tsvalue(), r.tsvalue()) < 0 ? 1 : 0; else { - let res = luaT_callorderTM(L, l, r, TMS.TM_LT); + let res = ltm.luaT_callorderTM(L, l, r, ltm.TMS.TM_LT); if (res === null) - luaG_ordererror(L, l, r); + ldebug.luaG_ordererror(L, l, r); return res ? 1 : 0; } }; -const luaV_lessequal = function (L, l, r) { +export const luaV_lessequal = function (L, l, r) { let res; if (l.ttisnumber() && r.ttisnumber()) @@ -708,20 +708,20 @@ const luaV_lessequal = function (L, l, r) { else if (l.ttisstring() && r.ttisstring()) return l_strcmp(l.tsvalue(), r.tsvalue()) <= 0 ? 1 : 0; else { - res = luaT_callorderTM(L, l, r, TMS.TM_LE); + res = ltm.luaT_callorderTM(L, l, r, ltm.TMS.TM_LE); if (res !== null) return res ? 1 : 0; } /* try 'lt': */ - L.ci.callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ - res = luaT_callorderTM(L, r, l, TMS.TM_LT); - L.ci.callstatus ^= CIST_LEQ; /* clear mark */ + L.ci.callstatus |= lstate.CIST_LEQ; /* mark it is doing 'lt' for 'le' */ + res = ltm.luaT_callorderTM(L, r, l, ltm.TMS.TM_LT); + L.ci.callstatus ^= lstate.CIST_LEQ; /* clear mark */ if (res === null) - luaG_ordererror(L, l, r); + ldebug.luaG_ordererror(L, l, r); return res ? 0 : 1; /* result is negated */ }; -const luaV_equalobj = function (L, t1, t2) { +export const luaV_equalobj = function (L, t1, t2) { if (t1.ttype() !== t2.ttype()) { /* not the same variant? */ if (t1.ttnov() !== t2.ttnov() || t1.ttnov() !== LUA_TNUMBER) return 0; /* only numbers can be equal with different variants */ @@ -746,16 +746,16 @@ const luaV_equalobj = function (L, t1, t2) { return t1.value === t2.value ? 1 : 0; case LUA_TSHRSTR: case LUA_TLNGSTR: { - return luaS_eqlngstr(t1.tsvalue(), t2.tsvalue()) ? 1 : 0; + return lstring.luaS_eqlngstr(t1.tsvalue(), t2.tsvalue()) ? 1 : 0; } case LUA_TUSERDATA: case LUA_TTABLE: if (t1.value === t2.value) return 1; else if (L === null) return 0; - tm = fasttm(L, t1.value.metatable, TMS.TM_EQ); + tm = ltm.fasttm(L, t1.value.metatable, ltm.TMS.TM_EQ); if (tm === null) - tm = fasttm(L, t2.value.metatable, TMS.TM_EQ); + tm = ltm.fasttm(L, t2.value.metatable, ltm.TMS.TM_EQ); break; default: return t1.value === t2.value ? 1 : 0; @@ -764,16 +764,16 @@ const luaV_equalobj = function (L, t1, t2) { if (tm === null) /* no TM? */ return 0; - let tv = new TValue(); /* doesn't use the stack */ - luaT_callTM(L, tm, t1, t2, tv, 1); + let tv = new lobject.TValue(); /* doesn't use the stack */ + ltm.luaT_callTM(L, tm, t1, t2, tv, 1); return tv.l_isfalse() ? 0 : 1; }; -const luaV_rawequalobj = function (t1, t2) { +export const luaV_rawequalobj = function (t1, t2) { return luaV_equalobj(null, t1, t2); }; -const forlimit = function (obj, step) { +export const forlimit = function (obj, step) { let stopnow = false; let ilimit = luaV_tointeger(obj, step < 0 ? 2 : 1); if (ilimit === false) { @@ -782,10 +782,10 @@ const forlimit = function (obj, step) { return false; if (0 < n) { - ilimit = LUA_MAXINTEGER; + ilimit = luaconf.LUA_MAXINTEGER; if (step < 0) stopnow = true; } else { - ilimit = LUA_MININTEGER; + ilimit = luaconf.LUA_MININTEGER; if (step >= 0) stopnow = true; } } @@ -802,7 +802,7 @@ const forlimit = function (obj, step) { ** mode === 1: takes the floor of the number ** mode === 2: takes the ceil of the number */ -const luaV_tointeger = function (obj, mode) { +export const luaV_tointeger = function (obj, mode) { if (obj.ttisfloat()) { let n = obj.value; let f = Math.floor(n); @@ -814,29 +814,29 @@ const luaV_tointeger = function (obj, mode) { f += 1; /* convert floor to ceil (remember: n !== f) */ } - return lua_numbertointeger(f); + return luaconf.lua_numbertointeger(f); } else if (obj.ttisinteger()) { return obj.value; } else if (cvt2num(obj)) { - let v = new TValue(); - if (luaO_str2num(obj.svalue(), v) === (obj.vslen() + 1)) + let v = new lobject.TValue(); + if (lobject.luaO_str2num(obj.svalue(), v) === (obj.vslen() + 1)) return luaV_tointeger(v, mode); } return false; }; -const tointeger = function (o) { +export const tointeger = function (o) { return o.ttisinteger() ? o.value : luaV_tointeger(o, 0); }; -const tonumber = function (o) { +export const tonumber = function (o) { if (o.ttnov() === LUA_TNUMBER) return o.value; if (cvt2num(o)) { /* string convertible to number? */ - let v = new TValue(); - if (luaO_str2num(o.svalue(), v) === (o.vslen() + 1)) + let v = new lobject.TValue(); + if (lobject.luaO_str2num(o.svalue(), v) === (o.vslen() + 1)) return v.value; } @@ -848,14 +848,14 @@ const tonumber = function (o) { ** As fengari uses javascript numbers for both floats and integers and has ** correct semantics, we can just compare values. */ -const LTnum = function (l, r) { +export const LTnum = function (l, r) { return l.value < r.value; }; /* ** Return 'l <= r', for numbers. */ -const LEnum = function (l, r) { +export const LEnum = function (l, r) { return l.value <= r.value; }; @@ -863,9 +863,9 @@ const LEnum = function (l, r) { ** Compare two strings 'ls' x 'rs', returning an integer smaller-equal- ** -larger than zero if 'ls' is smaller-equal-larger than 'rs'. */ -const l_strcmp = function (ls, rs) { - let l = luaS_hashlongstr(ls); - let r = luaS_hashlongstr(rs); +export const l_strcmp = function (ls, rs) { + let l = lstring.luaS_hashlongstr(ls); + let r = lstring.luaS_hashlongstr(rs); /* In fengari we assume string hash has same collation as byte values */ if (l === r) return 0; @@ -878,14 +878,14 @@ const l_strcmp = function (ls, rs) { /* ** Main operation 'ra' = #rb'. */ -const luaV_objlen = function (L, ra, rb) { +export const luaV_objlen = function (L, ra, rb) { let tm; switch (rb.ttype()) { case LUA_TTABLE: { let h = rb.value; - tm = fasttm(L, h.metatable, TMS.TM_LEN); + tm = ltm.fasttm(L, h.metatable, ltm.TMS.TM_LEN); if (tm !== null) break; /* metamethod? break switch to call it */ - ra.setivalue(luaH_getn(h)); /* else primitive len */ + ra.setivalue(ltable.luaH_getn(h)); /* else primitive len */ return; } case LUA_TSHRSTR: @@ -893,18 +893,18 @@ const luaV_objlen = function (L, ra, rb) { ra.setivalue(rb.vslen()); return; default: { - tm = luaT_gettmbyobj(L, rb, TMS.TM_LEN); + tm = ltm.luaT_gettmbyobj(L, rb, ltm.TMS.TM_LEN); if (tm.ttisnil()) - luaG_typeerror(L, rb, to_luastring('get length of', true)); + ldebug.luaG_typeerror(L, rb, defs.to_luastring('get length of', true)); break; } } - luaT_callTM(L, tm, rb, rb, ra, 1); + ltm.luaT_callTM(L, tm, rb, rb, ra, 1); }; /* Shim taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul */ -const luaV_imul = Math.imul || function (a, b) { +export const luaV_imul = Math.imul || function (a, b) { let aHi = (a >>> 16) & 0xffff; let aLo = a & 0xffff; let bHi = (b >>> 16) & 0xffff; @@ -916,22 +916,22 @@ const luaV_imul = Math.imul || function (a, b) { return ((aLo * bLo) + (((aHi * bLo + aLo * bHi) << 16) >>> 0) | 0); }; -const luaV_div = function (L, m, n) { +export const luaV_div = function (L, m, n) { if (n === 0) - luaG_runerror(L, to_luastring('attempt to divide by zero')); + ldebug.luaG_runerror(L, defs.to_luastring('attempt to divide by zero')); return Math.floor(m / n) | 0; }; // % semantic on negative numbers is different in js -const luaV_mod = function (L, m, n) { +export const luaV_mod = function (L, m, n) { if (n === 0) - luaG_runerror(L, to_luastring('attempt to perform \'n%%0\'')); + ldebug.luaG_runerror(L, defs.to_luastring('attempt to perform \'n%%0\'')); return (m - Math.floor(m / n) * n) | 0; }; -const NBITS = 32; +export const NBITS = 32; -const luaV_shiftl = function (x, y) { +export const luaV_shiftl = function (x, y) { if (y < 0) { /* shift right? */ if (y <= -NBITS) return 0; else return x >>> -y; @@ -947,7 +947,7 @@ const luaV_shiftl = function (x, y) { ** whether there is a cached closure with the same upvalues needed by ** new closure to be created. */ -const getcached = function (p, encup, stack, base) { +export const getcached = function (p, encup, stack, base) { let c = p.cache; if (c !== null) { /* is there a cached closure? */ let uv = p.upvalues; @@ -965,48 +965,48 @@ const getcached = function (p, encup, stack, base) { ** create a new Lua closure, push it in the stack, and initialize ** its upvalues. */ -const pushclosure = function (L, p, encup, base, ra) { +export const pushclosure = function (L, p, encup, base, ra) { let nup = p.upvalues.length; let uv = p.upvalues; - let ncl = new LClosure(L, nup); + let ncl = new lobject.LClosure(L, nup); ncl.p = p; L.stack[ra].setclLvalue(ncl); for (let i = 0; i < nup; i++) { if (uv[i].instack) - ncl.upvals[i] = luaF_findupval(L, base + uv[i].idx); + ncl.upvals[i] = lfunc.luaF_findupval(L, base + uv[i].idx); else ncl.upvals[i] = encup[uv[i].idx]; } p.cache = ncl; /* save it on cache for reuse */ }; -const cvt2str = function (o) { +export const cvt2str = function (o) { return o.ttisnumber(); }; -const cvt2num = function (o) { +export const cvt2num = function (o) { return o.ttisstring(); }; -const tostring = function (L, i) { +export const tostring = function (L, i) { let o = L.stack[i]; if (o.ttisstring()) return true; if (cvt2str(o)) { - luaO_tostring(L, o); + lobject.luaO_tostring(L, o); return true; } return false; }; -const isemptystr = function (o) { +export const isemptystr = function (o) { return o.ttisstring() && o.vslen() === 0; }; /* copy strings in stack from top - n up to top - 1 to buffer */ -const copy2buff = function (L, top, n, buff) { +export const copy2buff = function (L, top, n, buff) { let tl = 0; /* size already copied */ do { let tv = L.stack[top - n]; @@ -1021,18 +1021,18 @@ const copy2buff = function (L, top, n, buff) { ** Main operation for concatenation: concat 'total' values in the stack, ** from 'L->top - total' up to 'L->top - 1'. */ -const luaV_concat = function (L, total) { - lua_assert(total >= 2); +export const luaV_concat = function (L, total) { + llimits.lua_assert(total >= 2); do { let top = L.top; let n = 2; /* number of elements handled in this pass (at least 2) */ if (!(L.stack[top - 2].ttisstring() || cvt2str(L.stack[top - 2])) || !tostring(L, top - 1)) { - luaT_trybinTM(L, L.stack[top - 2], L.stack[top - 1], L.stack[top - 2], TMS.TM_CONCAT); + ltm.luaT_trybinTM(L, L.stack[top - 2], L.stack[top - 1], L.stack[top - 2], ltm.TMS.TM_CONCAT); } else if (isemptystr(L.stack[top - 1])) { tostring(L, top - 2); } else if (isemptystr(L.stack[top - 2])) { - setobjs2s(L, top - 2, top - 1); + lobject.setobjs2s(L, top - 2, top - 1); } else { /* at least two non-empty string values; get as many as possible */ let tl = L.stack[top - 1].vslen(); @@ -1043,8 +1043,8 @@ const luaV_concat = function (L, total) { } let buff = new Uint8Array(tl); copy2buff(L, top, n, buff); - let ts = luaS_bless(L, buff); - setsvalue2s(L, top - n, ts); + let ts = lstring.luaS_bless(L, buff); + lobject.setsvalue2s(L, top - n, ts); } total -= n - 1; /* got 'n' strings to create 1 new */ /* popped 'n' strings and pushed one */ @@ -1053,24 +1053,24 @@ const luaV_concat = function (L, total) { } while (total > 1); /* repeat until only 1 result left */ }; -const MAXTAGLOOP = 2000; +export const MAXTAGLOOP = 2000; -const luaV_gettable = function (L, t, key, ra) { +export const luaV_gettable = function (L, t, key, ra) { for (let loop = 0; loop < MAXTAGLOOP; loop++) { let tm; if (!t.ttistable()) { - tm = luaT_gettmbyobj(L, t, TMS.TM_INDEX); + tm = ltm.luaT_gettmbyobj(L, t, ltm.TMS.TM_INDEX); if (tm.ttisnil()) - luaG_typeerror(L, t, to_luastring('index', true)); /* no metamethod */ + ldebug.luaG_typeerror(L, t, defs.to_luastring('index', true)); /* no metamethod */ /* else will try the metamethod */ } else { - let slot = luaH_get(L, t.value, key); + let slot = ltable.luaH_get(L, t.value, key); if (!slot.ttisnil()) { - setobj2s(L, ra, slot); + lobject.setobj2s(L, ra, slot); return; } else { /* 't' is a table */ - tm = fasttm(L, t.value.metatable, TMS.TM_INDEX); /* table's metamethod */ + tm = ltm.fasttm(L, t.value.metatable, ltm.TMS.TM_INDEX); /* table's metamethod */ if (tm === null) { /* no metamethod? */ L.stack[ra].setnilvalue(); /* result is nil */ return; @@ -1079,78 +1079,38 @@ const luaV_gettable = function (L, t, key, ra) { /* else will try the metamethod */ } if (tm.ttisfunction()) { /* is metamethod a function? */ - luaT_callTM(L, tm, t, key, L.stack[ra], 1); /* call it */ + ltm.luaT_callTM(L, tm, t, key, L.stack[ra], 1); /* call it */ return; } t = tm; /* else try to access 'tm[key]' */ } - luaG_runerror(L, to_luastring('\'__index\' chain too long; possible loop', true)); + ldebug.luaG_runerror(L, defs.to_luastring('\'__index\' chain too long; possible loop', true)); }; -const settable = function (L, t, key, val) { +export const settable = function (L, t, key, val) { for (let loop = 0; loop < MAXTAGLOOP; loop++) { let tm; if (t.ttistable()) { let h = t.value; /* save 't' table */ - let slot = luaH_get(L, h, key); - if (!slot.ttisnil() || (tm = fasttm(L, h.metatable, TMS.TM_NEWINDEX)) === null) { - luaH_setfrom(L, h, key, val); - invalidateTMcache(h); + let slot = ltable.luaH_get(L, h, key); + if (!slot.ttisnil() || (tm = ltm.fasttm(L, h.metatable, ltm.TMS.TM_NEWINDEX)) === null) { + ltable.luaH_setfrom(L, h, key, val); + ltable.invalidateTMcache(h); return; } /* else will try the metamethod */ } else { /* not a table; check metamethod */ - if ((tm = luaT_gettmbyobj(L, t, TMS.TM_NEWINDEX)).ttisnil()) - luaG_typeerror(L, t, to_luastring('index', true)); + if ((tm = ltm.luaT_gettmbyobj(L, t, ltm.TMS.TM_NEWINDEX)).ttisnil()) + ldebug.luaG_typeerror(L, t, defs.to_luastring('index', true)); } /* try the metamethod */ if (tm.ttisfunction()) { - luaT_callTM(L, tm, t, key, val, 0); + ltm.luaT_callTM(L, tm, t, key, val, 0); return; } t = tm; /* else repeat assignment over 'tm' */ } - luaG_runerror(L, to_luastring('\'__newindex\' chain too long; possible loop', true)); + ldebug.luaG_runerror(L, defs.to_luastring('\'__newindex\' chain too long; possible loop', true)); }; - - -const _cvt2str = cvt2str; -export { _cvt2str as cvt2str }; -const _cvt2num = cvt2num; -export { _cvt2num as cvt2num }; -const _luaV_gettable = luaV_gettable; -export { _luaV_gettable as luaV_gettable }; -const _luaV_concat = luaV_concat; -export { _luaV_concat as luaV_concat }; -const _luaV_div = luaV_div; -export { _luaV_div as luaV_div }; -const _luaV_equalobj = luaV_equalobj; -export { _luaV_equalobj as luaV_equalobj }; -const _luaV_execute = luaV_execute; -export { _luaV_execute as luaV_execute }; -const _luaV_finishOp = luaV_finishOp; -export { _luaV_finishOp as luaV_finishOp }; -const _luaV_imul = luaV_imul; -export { _luaV_imul as luaV_imul }; -const _luaV_lessequal = luaV_lessequal; -export { _luaV_lessequal as luaV_lessequal }; -const _luaV_lessthan = luaV_lessthan; -export { _luaV_lessthan as luaV_lessthan }; -const _luaV_mod = luaV_mod; -export { _luaV_mod as luaV_mod }; -const _luaV_objlen = luaV_objlen; -export { _luaV_objlen as luaV_objlen }; -const _luaV_rawequalobj = luaV_rawequalobj; -export { _luaV_rawequalobj as luaV_rawequalobj }; -const _luaV_shiftl = luaV_shiftl; -export { _luaV_shiftl as luaV_shiftl }; -const _luaV_tointeger = luaV_tointeger; -export { _luaV_tointeger as luaV_tointeger }; -const _settable = settable; -export { _settable as settable }; -const _tointeger = tointeger; -export { _tointeger as tointeger }; -const _tonumber = tonumber; -export { _tonumber as tonumber }; diff --git a/src/lzio.js b/src/lzio.js index d528647d..491db5ef 100644 --- a/src/lzio.js +++ b/src/lzio.js @@ -1,32 +1,32 @@ import { lua_assert } from './llimits.js'; -class MBuffer { +export class MBuffer { constructor() { this.buffer = null; this.n = 0; } } -const luaZ_buffer = function(buff) { +export const luaZ_buffer = function(buff) { return buff.buffer.subarray(0, buff.n); }; -const luaZ_buffremove = function(buff, i) { +export const luaZ_buffremove = function(buff, i) { buff.n -= i; }; -const luaZ_resetbuffer = function(buff) { +export const luaZ_resetbuffer = function(buff) { buff.n = 0; }; -const luaZ_resizebuffer = function(L, buff, size) { +export const luaZ_resizebuffer = function(L, buff, size) { let newbuff = new Uint8Array(size); if (buff.buffer) newbuff.set(buff.buffer); buff.buffer = newbuff; }; -class ZIO { +export class ZIO { constructor(L, reader, data) { this.L = L; /* Lua state (for reader) */ lua_assert(typeof reader == 'function', 'ZIO requires a reader'); @@ -42,9 +42,9 @@ class ZIO { } } -const EOZ = -1; +export const EOZ = -1; -const luaZ_fill = function(z) { +export const luaZ_fill = function(z) { let buff = z.reader(z.L, z.data); if (buff === null) return EOZ; @@ -60,7 +60,7 @@ const luaZ_fill = function(z) { /* b should be an array-like that will be set to bytes * b_offset is the offset at which to start filling */ -const luaZ_read = function(z, b, b_offset, n) { +export const luaZ_read = function(z, b, b_offset, n) { while (n) { if (z.n === 0) { /* no bytes in buffer? */ if (luaZ_fill(z) === EOZ) @@ -82,22 +82,3 @@ const luaZ_read = function(z, b, b_offset, n) { return 0; }; - -const _EOZ = EOZ; -export { _EOZ as EOZ }; -const _luaZ_buffer = luaZ_buffer; -export { _luaZ_buffer as luaZ_buffer }; -const _luaZ_buffremove = luaZ_buffremove; -export { _luaZ_buffremove as luaZ_buffremove }; -const _luaZ_fill = luaZ_fill; -export { _luaZ_fill as luaZ_fill }; -const _luaZ_read = luaZ_read; -export { _luaZ_read as luaZ_read }; -const _luaZ_resetbuffer = luaZ_resetbuffer; -export { _luaZ_resetbuffer as luaZ_resetbuffer }; -const _luaZ_resizebuffer = luaZ_resizebuffer; -export { _luaZ_resizebuffer as luaZ_resizebuffer }; -const _MBuffer = MBuffer; -export { _MBuffer as MBuffer }; -const _ZIO = ZIO; -export { _ZIO as ZIO }; diff --git a/test/defs.test.js b/test/defs.test.js index 669fa97f..c487ec88 100644 --- a/test/defs.test.js +++ b/test/defs.test.js @@ -3,38 +3,38 @@ import { luastring_of, to_luastring, to_jsstring } from '../src/defs.js'; const unicode_tests = [ { - description: "Convert normal ascii string", - literal: "foo", - byte_array: luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)) + description: 'Convert normal ascii string', + literal: 'foo', + byte_array: luastring_of('f'.charCodeAt(0), 'o'.charCodeAt(0), 'o'.charCodeAt(0)) }, { - description: "Convert ascii string containing null byte", - literal: "fo\0o", - byte_array: luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)) + description: 'Convert ascii string containing null byte', + literal: 'fo\0o', + byte_array: luastring_of('f'.charCodeAt(0), 'o'.charCodeAt(0), 0, 'o'.charCodeAt(0)) }, { - description: "Convert string with BMP unicode chars", - literal: "Café", + description: 'Convert string with BMP unicode chars', + literal: 'Café', byte_array: luastring_of(67, 97, 102, 195, 169) }, { - description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)", - literal: "", + description: 'Convert string with codepoint in PUA (U+E000 to U+F8FF)', + literal: '', byte_array: luastring_of(239, 163, 191) }, { - description: "Convert string with surrogate pair", - literal: "❤️🍾", + description: 'Convert string with surrogate pair', + literal: '❤️🍾', byte_array: luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190) }, { - description: "Convert string with broken surrogate pair", - literal: "\uD800a", + description: 'Convert string with broken surrogate pair', + literal: '\uD800a', byte_array: luastring_of(237, 160, 128, 97) }, { - description: "Convert string with broken surrogate pair at end of string", - literal: "\uD823", + description: 'Convert string with broken surrogate pair at end of string', + literal: '\uD823', byte_array: luastring_of(237, 160, 163) } ]; @@ -57,37 +57,37 @@ describe('to_jsstring', () => { describe('to_jsstring fails on invalid unicode', () => { - test("non-utf8 char", () => { + test('non-utf8 char', () => { expect(() => to_jsstring(luastring_of(165))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { + test('invalid continuation byte', () => { expect(() => to_jsstring(luastring_of(208, 60))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { + test('invalid continuation byte', () => { expect(() => to_jsstring(luastring_of(225, 60, 145))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { + test('invalid continuation byte', () => { expect(() => to_jsstring(luastring_of(225, 145, 60))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { + test('invalid continuation byte', () => { expect(() => to_jsstring(luastring_of(242, 60, 145, 145))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { + test('invalid continuation byte', () => { expect(() => to_jsstring(luastring_of(242, 145, 60, 145))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { + test('invalid continuation byte', () => { expect(() => to_jsstring(luastring_of(242, 145, 145, 60))) .toThrow(RangeError); }); diff --git a/test/lapi.test.js b/test/lapi.test.js index 62291e4e..59f18525 100644 --- a/test/lapi.test.js +++ b/test/lapi.test.js @@ -1,33 +1,33 @@ -import { toByteCode } from "./tests.js"; +import { toByteCode } from './tests.js'; import { lua_pushnil, lua_pushnumber, lua_tonumber, lua_pushinteger, lua_tointeger, lua_pushliteral, lua_tojsstring, lua_pushboolean, lua_toboolean, lua_pushvalue, lua_pushjsclosure, lua_pushjsfunction, lua_call, lua_pushstring, lua_tostring, lua_upvalueindex, lua_pcall, LUA_OK, lua_pop, lua_load, lua_setglobal, lua_createtable, lua_istable, lua_newtable, lua_settable, lua_gettable, lua_pushcfunction, lua_atnativeerror, lua_touserdata, LUA_ERRRUN, lua_seti, lua_len } from '../src/lua.js'; -import { luaL_newstate, luaL_typename, luaL_loadstring, luaL_error } from "../src/lauxlib.js"; -import { to_luastring } from "../src/fengaricore.js"; +import { luaL_newstate, luaL_typename, luaL_loadstring, luaL_error } from '../src/lauxlib.js'; +import { to_luastring } from '../src/fengaricore.js'; test('luaL_newstate, lua_pushnil, luaL_typename', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_pushnil(L); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("nil")); + .toEqual(to_luastring('nil')); }); test('lua_pushnumber', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_pushnumber(L, 10.5); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("number")); + .toEqual(to_luastring('number')); expect(lua_tonumber(L, -1)) .toBe(10.5); @@ -36,14 +36,14 @@ test('lua_pushnumber', () => { test('lua_pushinteger', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_pushinteger(L, 10); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("number")); + .toEqual(to_luastring('number')); expect(lua_tointeger(L, -1)) .toBe(10); @@ -52,30 +52,30 @@ test('lua_pushinteger', () => { test('lua_pushliteral', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua_pushliteral(L, "hello"); + lua_pushliteral(L, 'hello'); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("string")); + .toEqual(to_luastring('string')); expect(lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_pushboolean', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_pushboolean(L, true); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("boolean")); + .toEqual(to_luastring('boolean')); expect(lua_toboolean(L, -1)) .toBe(true); @@ -84,67 +84,67 @@ test('lua_pushboolean', () => { test('lua_pushvalue', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua_pushliteral(L, "hello"); + lua_pushliteral(L, 'hello'); lua_pushvalue(L, -1); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("string")); + .toEqual(to_luastring('string')); expect(luaL_typename(L, -2)) - .toEqual(to_luastring("string")); + .toEqual(to_luastring('string')); expect(lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); expect(lua_tojsstring(L, -2)) - .toBe("hello"); + .toBe('hello'); }); test('lua_pushjsclosure', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - let fn = function(L) { + let fn = function(_L) { return 0; }; - lua_pushliteral(L, "a value associated to the C closure"); + lua_pushliteral(L, 'a value associated to the C closure'); lua_pushjsclosure(L, fn, 1); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("function")); + .toEqual(to_luastring('function')); }); test('lua_pushjsfunction', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - let fn = function(L) { + let fn = function(_L) { return 0; }; lua_pushjsfunction(L, fn); } expect(luaL_typename(L, -1)) - .toEqual(to_luastring("function")); + .toEqual(to_luastring('function')); }); test('lua_call (calling a light JS function)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { - lua_pushliteral(L, "hello"); + lua_pushliteral(L, 'hello'); return 1; }; lua_pushjsfunction(L, fn); @@ -152,36 +152,36 @@ test('lua_call (calling a light JS function)', () => { } expect(lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_call (calling a JS closure)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { lua_pushstring(L, lua_tostring(L, lua_upvalueindex(1))); return 1; }; - lua_pushliteral(L, "upvalue hello!"); + lua_pushliteral(L, 'upvalue hello!'); lua_pushjsclosure(L, fn, 1); lua_call(L, 0, 1); } expect(lua_tojsstring(L, -1)) - .toBe("upvalue hello!"); + .toBe('upvalue hello!'); }); test('lua_pcall (calling a light JS function)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let fn = function(L) { - lua_pushliteral(L, "hello"); + lua_pushliteral(L, 'hello'); return 1; }; lua_pushjsfunction(L, fn); @@ -189,17 +189,17 @@ test('lua_pcall (calling a light JS function)', () => { } expect(lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_pcall that breaks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - let fn = function(L) { - return "undefined_value"; + let fn = function(_L) { + return 'undefined_value'; }; lua_pushjsfunction(L, fn); expect(lua_pcall(L, 0, 1, 0)).not.toBe(LUA_OK); @@ -209,22 +209,22 @@ test('lua_pcall that breaks', () => { test('lua_pop', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua_pushliteral(L, "hello"); - lua_pushliteral(L, "world"); + lua_pushliteral(L, 'hello'); + lua_pushliteral(L, 'world'); lua_pop(L, 1); } expect(lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_load with no chunkname', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_load(L, function(L, s) { @@ -232,18 +232,18 @@ test('lua_load with no chunkname', () => { s.code = null; return r; }, { - code: to_luastring("return 'hello'") + code: to_luastring('return \'hello\'') }, null, null); lua_call(L, 0, 1); } expect(lua_tojsstring(L, -1)) - .toBe("hello"); + .toBe('hello'); }); test('lua_load and lua_call it', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let luaCode = ` @@ -255,37 +255,37 @@ test('lua_load and lua_call it', () => { let r = s.bc; s.bc = null; return r; - }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary")); + }, {bc: bc}, to_luastring('test-lua_load'), to_luastring('binary')); lua_call(L, 0, 1); } expect(lua_tojsstring(L, -1)) - .toBe("JS > Lua > JS \\o/"); + .toBe('JS > Lua > JS \\o/'); }); test('lua script reads js upvalues', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { let luaCode = ` return js .. " world" `; expect(luaL_loadstring(L, to_luastring(luaCode))).toBe(LUA_OK); - lua_pushliteral(L, "hello"); - lua_setglobal(L, to_luastring("js")); + lua_pushliteral(L, 'hello'); + lua_setglobal(L, to_luastring('js')); lua_call(L, 0, 1); } expect(lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('lua_createtable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_createtable(L, 3, 3); @@ -297,7 +297,7 @@ test('lua_createtable', () => { test('lua_newtable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_newtable(L); @@ -309,32 +309,32 @@ test('lua_newtable', () => { test('lua_settable, lua_gettable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_newtable(L); - lua_pushliteral(L, "key"); - lua_pushliteral(L, "value"); + lua_pushliteral(L, 'key'); + lua_pushliteral(L, 'value'); lua_settable(L, -3); - lua_pushliteral(L, "key"); + lua_pushliteral(L, 'key'); lua_gettable(L, -2); } expect(lua_tojsstring(L, -1)) - .toBe("value"); + .toBe('value'); }); describe('lua_atnativeerror', () => { test('no native error handler', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let errob = {}; - lua_pushcfunction(L, function(L) { + lua_pushcfunction(L, function(_L) { throw errob; }); // without a native error handler pcall should be -1 @@ -343,39 +343,39 @@ describe('lua_atnativeerror', () => { test('native error handler returns string', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let errob = {}; lua_atnativeerror(L, function(L) { let e = lua_touserdata(L, 1); expect(e).toBe(errob); - lua_pushstring(L, to_luastring("runtime error!")); + lua_pushstring(L, to_luastring('runtime error!')); return 1; }); - lua_pushcfunction(L, function(L) { + lua_pushcfunction(L, function(_L) { throw errob; }); expect(lua_pcall(L, 0, 0, 0)).toBe(LUA_ERRRUN); - expect(lua_tojsstring(L, -1)).toBe("runtime error!"); + expect(lua_tojsstring(L, -1)).toBe('runtime error!'); }); test('native error handler rethrows lua error', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let errob = {}; lua_atnativeerror(L, function(L) { let e = lua_touserdata(L, 1); expect(e).toBe(errob); - luaL_error(L, to_luastring("runtime error!")); + luaL_error(L, to_luastring('runtime error!')); }); - lua_pushcfunction(L, function(L) { + lua_pushcfunction(L, function(_L) { throw errob; }); expect(lua_pcall(L, 0, 0, 0)).toBe(LUA_ERRRUN); - expect(lua_tojsstring(L, -1)).toBe("runtime error!"); + expect(lua_tojsstring(L, -1)).toBe('runtime error!'); }); }); @@ -383,7 +383,7 @@ describe('lua_atnativeerror', () => { describe('lua_len', () => { test('table with two potential boundaries', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_createtable(L); @@ -401,7 +401,7 @@ describe('lua_len', () => { test('pathological case', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { lua_createtable(L); diff --git a/test/lauxlib.test.js b/test/lauxlib.test.js index 1f8dd345..ab863e72 100644 --- a/test/lauxlib.test.js +++ b/test/lauxlib.test.js @@ -1,14 +1,14 @@ import { lua_pushstring, LUA_REGISTRYINDEX, lua_rawgeti, lua_tojsstring } from '../src/lua.js'; -import { luaL_newstate, luaL_ref, luaL_unref } from "../src/lauxlib.js"; -import { to_luastring } from "../src/fengaricore.js"; +import { luaL_newstate, luaL_ref, luaL_unref } from '../src/lauxlib.js'; +import { to_luastring } from '../src/fengaricore.js'; test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); { - lua_pushstring(L, to_luastring("hello references!")); + lua_pushstring(L, to_luastring('hello references!')); let r = luaL_ref(L, LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference lua_rawgeti(L, LUA_REGISTRYINDEX, r); // pushes a value associated with the reference @@ -16,5 +16,5 @@ test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { } expect(lua_tojsstring(L, -1)) - .toBe("hello references!"); + .toBe('hello references!'); }); diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js index 12cb0e09..a0627d4d 100644 --- a/test/lbaselib.test.js +++ b/test/lbaselib.test.js @@ -1,12 +1,12 @@ import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_toboolean, lua_pcall, lua_tointeger, lua_topointer, lua_isnil, lua_tonumber } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('print', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` print("hello", "world", 123) @@ -21,7 +21,7 @@ test('print', () => { test('setmetatable, getmetatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -43,7 +43,7 @@ test('setmetatable, getmetatable', () => { } expect(lua_tojsstring(L, -2)) - .toBe("hello"); + .toBe('hello'); expect(lua_istable(L, -1)).toBe(true); }); @@ -51,7 +51,7 @@ test('setmetatable, getmetatable', () => { test('rawequal', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -81,7 +81,7 @@ test('rawequal', () => { test('rawset, rawget', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -106,22 +106,22 @@ test('rawset, rawget', () => { } expect(lua_tojsstring(L, -4)) - .toBe("hello"); + .toBe('hello'); expect(lua_tojsstring(L, -3)) - .toBe("hello"); + .toBe('hello'); expect(lua_tojsstring(L, -2)) - .toBe("bye"); + .toBe('bye'); expect(lua_tojsstring(L, -1)) - .toBe("bye"); + .toBe('bye'); }); test('type', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return type(1), type(true), type("hello"), type({}), type(nil) @@ -133,25 +133,25 @@ test('type', () => { } expect(lua_tojsstring(L, -5)) - .toBe("number"); + .toBe('number'); expect(lua_tojsstring(L, -4)) - .toBe("boolean"); + .toBe('boolean'); expect(lua_tojsstring(L, -3)) - .toBe("string"); + .toBe('string'); expect(lua_tojsstring(L, -2)) - .toBe("table"); + .toBe('table'); expect(lua_tojsstring(L, -1)) - .toBe("nil"); + .toBe('nil'); }); test('error', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` error("you fucked up") @@ -168,7 +168,7 @@ test('error', () => { test('error, protected', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` error("you fucked up") @@ -185,7 +185,7 @@ test('error, protected', () => { test('pcall', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local willFail = function () @@ -206,7 +206,7 @@ test('pcall', () => { test('xpcall', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local willFail = function () @@ -231,7 +231,7 @@ test('xpcall', () => { test('ipairs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, ['yo'] = 'lo'} @@ -255,7 +255,7 @@ test('ipairs', () => { test('select', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return {select('#', 1, 2, 3)}, {select(2, 1, 2, 3)}, {select(-2, 1, 2, 3)} @@ -279,7 +279,7 @@ test('select', () => { test('tonumber', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return tonumber('foo'), @@ -304,7 +304,7 @@ test('tonumber', () => { test('assert', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(1 < 0, "this doesn't makes sense") @@ -321,7 +321,7 @@ test('assert', () => { test('rawlen', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return rawlen({1, 2, 3}), rawlen('hello') @@ -339,7 +339,7 @@ test('rawlen', () => { test('next', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -368,7 +368,7 @@ test('next', () => { test('pairs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -397,7 +397,7 @@ test('pairs', () => { test('pairs with __pairs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 diff --git a/test/lcorolib.test.js b/test/lcorolib.test.js index 8418665a..cb254227 100644 --- a/test/lcorolib.test.js +++ b/test/lcorolib.test.js @@ -2,11 +2,11 @@ import { LUA_OK, lua_call, lua_tonumber, lua_tojsstring, lua_toboolean, lua_toth import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; import { lua_State } from '../src/lstate.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('coroutine.create, coroutine.yield, coroutine.resume', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function (start) @@ -32,7 +32,7 @@ test('coroutine.create, coroutine.yield, coroutine.resume', () => { test('coroutine.status', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function (start) @@ -58,16 +58,16 @@ test('coroutine.status', () => { } expect(lua_tojsstring(L, -2)) - .toBe("suspended"); + .toBe('suspended'); expect(lua_tojsstring(L, -1)) - .toBe("dead"); + .toBe('dead'); }); test('coroutine.isyieldable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function () @@ -91,7 +91,7 @@ test('coroutine.isyieldable', () => { test('coroutine.running', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local running, ismain @@ -117,7 +117,7 @@ test('coroutine.running', () => { test('coroutine.wrap', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.wrap(function (start) diff --git a/test/ldblib.test.js b/test/ldblib.test.js index 879123e7..3a351115 100644 --- a/test/ldblib.test.js +++ b/test/ldblib.test.js @@ -1,11 +1,11 @@ const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const {to_luastring} = require("../src/fengaricore.js"); +const {to_luastring} = require('../src/fengaricore.js'); test('debug.sethook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local result = "" @@ -29,13 +29,13 @@ test('debug.sethook', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("return count line count line count line call count line return count line count line call count line return count line count line call count line return count line "); + .toBe('return count line count line count line call count line return count line count line call count line return count line count line call count line return count line '); }); test('debug.gethook', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local result = "" @@ -59,15 +59,15 @@ test('debug.gethook', () => { } expect(lua.lua_typename(L, lua.lua_type(L, -3))) - .toEqual(to_luastring("function")); - expect(lua.lua_tojsstring(L, -2)).toBe("crl"); + .toEqual(to_luastring('function')); + expect(lua.lua_tojsstring(L, -2)).toBe('crl'); expect(lua.lua_tointeger(L, -1)).toBe(1); }); test('debug.getlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local alocal = "alocal" @@ -95,12 +95,12 @@ test('debug.getlocal', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("alocal alocalanother anotherinfunction infunctionanotherin anotherin"); + .toBe('alocal alocalanother anotherinfunction infunctionanotherin anotherin'); }); test('debug.setlocal', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local alocal = "alocal" @@ -136,7 +136,7 @@ test('debug.setlocal', () => { test('debug.upvalueid', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local upvalue = "upvalue" @@ -159,7 +159,7 @@ test('debug.upvalueid', () => { test('debug.upvaluejoin', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local upvalue1 = "upvalue1" @@ -184,13 +184,13 @@ test('debug.upvaluejoin', () => { } expect(lua.lua_tojsstring(L, -1)) - .toBe("upvalue2"); + .toBe('upvalue2'); }); test('debug.traceback (with a global)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local trace @@ -211,7 +211,7 @@ test('debug.traceback (with a global)', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test")); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('traceback-test')); lua.lua_call(L, 0, -1); } @@ -234,7 +234,7 @@ test('debug.traceback (with a global)', () => { test('debug.traceback (with a upvalue)', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local trace @@ -256,7 +256,7 @@ test('debug.traceback (with a upvalue)', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test")); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('traceback-test')); lua.lua_call(L, 0, -1); } @@ -278,7 +278,7 @@ test('debug.traceback (with a upvalue)', () => { test('debug.getinfo', () => { let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local alocal = function(p1, p2) end @@ -293,16 +293,16 @@ test('debug.getinfo', () => { { lualib.luaL_openlibs(L); luaCode = to_luastring(luaCode); - lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("getinfo-test")); + lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring('getinfo-test')); lua.lua_call(L, 0, -1); } - expect(lua.lua_tojsstring(L, -8)).toBe(`[string "getinfo-test"]`); + expect(lua.lua_tojsstring(L, -8)).toBe('[string "getinfo-test"]'); expect(lua.lua_tointeger(L, -7)).toBe(0); - expect(lua.lua_tojsstring(L, -6)).toBe(`Lua`); + expect(lua.lua_tojsstring(L, -6)).toBe('Lua'); expect(lua.lua_tointeger(L, -5)).toBe(2); - expect(lua.lua_tojsstring(L, -4)).toBe(`[string "getinfo-test"]`); + expect(lua.lua_tojsstring(L, -4)).toBe('[string "getinfo-test"]'); expect(lua.lua_tointeger(L, -3)).toBe(1); - expect(lua.lua_tojsstring(L, -2)).toBe(`Lua`); + expect(lua.lua_tojsstring(L, -2)).toBe('Lua'); expect(lua.lua_tointeger(L, -1)).toBe(0); }); diff --git a/test/ldebug.test.js b/test/ldebug.test.js index 69f98f0e..53000ee8 100644 --- a/test/ldebug.test.js +++ b/test/ldebug.test.js @@ -1,11 +1,11 @@ import { LUA_OK, lua_pcall, lua_tojsstring } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('luaG_typeerror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -18,13 +18,13 @@ test('luaG_typeerror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("attempt to get length of a boolean value (local 'a')"); + .toMatch('attempt to get length of a boolean value (local \'a\')'); }); test('luaG_typeerror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -37,13 +37,13 @@ test('luaG_typeerror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("attempt to index a boolean value (local 'a')"); + .toMatch('attempt to index a boolean value (local \'a\')'); }); test('luaG_typeerror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -56,13 +56,13 @@ test('luaG_typeerror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("attempt to index a boolean value (local 'a')"); + .toMatch('attempt to index a boolean value (local \'a\')'); }); test('luaG_typeerror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -75,13 +75,13 @@ test('luaG_typeerror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("attempt to index a boolean value (local 'a')"); + .toMatch('attempt to index a boolean value (local \'a\')'); }); test('luaG_concaterror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return {} .. 'hello' @@ -93,13 +93,13 @@ test('luaG_concaterror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("attempt to concatenate a table value"); + .toMatch('attempt to concatenate a table value'); }); test('luaG_opinterror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return {} + 'hello' @@ -111,13 +111,13 @@ test('luaG_opinterror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("attempt to perform arithmetic on a table value"); + .toMatch('attempt to perform arithmetic on a table value'); }); test('luaG_tointerror', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return 123.5 & 12 @@ -129,5 +129,5 @@ test('luaG_tointerror', () => { } expect(lua_tojsstring(L, -1)) - .toMatch("number has no integer representation"); + .toMatch('number has no integer representation'); }); diff --git a/test/lexparse.test.js b/test/lexparse.test.js index 5ef59894..f50276a8 100644 --- a/test/lexparse.test.js +++ b/test/lexparse.test.js @@ -1,13 +1,13 @@ import { lua_load, lua_call, lua_tojsstring, lua_type, LUA_TTABLE, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from '../src/lua.js'; import { luaL_newstate } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { luaS_hash } from "../src/lstring.js"; -import { to_luastring } from "../src/fengaricore.js"; +import { luaS_hash } from '../src/lstring.js'; +import { to_luastring } from '../src/fengaricore.js'; // Roughly the same tests as test/lvm.js to cover all opcodes test('LOADK, RETURN', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -15,23 +15,23 @@ test('LOADK, RETURN', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe('hello world'); }); test('MOVE', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -40,23 +40,23 @@ test('MOVE', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe('hello world'); }); test('Binary op', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -65,12 +65,12 @@ test('Binary op', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -82,7 +82,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -91,12 +91,12 @@ test('Unary op, LOADBOOL', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -108,7 +108,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -116,12 +116,12 @@ test('NEWTABLE', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -132,7 +132,7 @@ test('NEWTABLE', () => { test('CALL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -145,12 +145,12 @@ test('CALL', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -160,7 +160,7 @@ test('CALL', () => { test('Multiple return', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -177,12 +177,12 @@ test('Multiple return', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -194,7 +194,7 @@ test('Multiple return', () => { test('TAILCALL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -205,12 +205,12 @@ test('TAILCALL', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -221,7 +221,7 @@ test('TAILCALL', () => { test('VARARG', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (...) @@ -232,12 +232,12 @@ test('VARARG', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -249,7 +249,7 @@ test('VARARG', () => { test('LE, JMP', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -258,12 +258,12 @@ test('LE, JMP', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -274,7 +274,7 @@ test('LE, JMP', () => { test('LT', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -283,12 +283,12 @@ test('LT', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -299,7 +299,7 @@ test('LT', () => { test('EQ', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -308,12 +308,12 @@ test('EQ', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -324,7 +324,7 @@ test('EQ', () => { test('TESTSET (and)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -334,23 +334,23 @@ test('TESTSET (and)', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('TESTSET (or)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -360,23 +360,23 @@ test('TESTSET (or)', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('TEST (false)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -390,23 +390,23 @@ test('TEST (false)', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("goodbye"); + expect(lua_tojsstring(L, -1)).toBe('goodbye'); }); test('FORPREP, FORLOOP (int)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -419,12 +419,12 @@ test('FORPREP, FORLOOP (int)', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -435,7 +435,7 @@ test('FORPREP, FORLOOP (int)', () => { test('FORPREP, FORLOOP (float)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -448,12 +448,12 @@ test('FORPREP, FORLOOP (float)', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -464,7 +464,7 @@ test('FORPREP, FORLOOP (float)', () => { test('SETTABLE, GETTABLE', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -476,26 +476,26 @@ test('SETTABLE, GETTABLE', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SETUPVAL, GETUPVAL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = "hello" @@ -510,23 +510,23 @@ test('SETUPVAL, GETUPVAL', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("world"); + expect(lua_tojsstring(L, -1)).toBe('world'); }); test('SETTABUP, GETTABUP', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -538,26 +538,26 @@ test('SETTABUP, GETTABUP', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SELF', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -571,23 +571,23 @@ test('SELF', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('SETLIST', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -596,12 +596,12 @@ test('SETLIST', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -613,7 +613,7 @@ test('SETLIST', () => { test('Variable SETLIST', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = function () @@ -626,12 +626,12 @@ test('Variable SETLIST', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -642,7 +642,7 @@ test('Variable SETLIST', () => { test('Long SETLIST', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} @@ -651,12 +651,12 @@ test('Long SETLIST', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -668,7 +668,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local iterator = function (t, i) @@ -693,12 +693,12 @@ test('TFORCALL, TFORLOOP', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -709,7 +709,7 @@ test('TFORCALL, TFORLOOP', () => { test('LEN', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[10000] = "foo"} @@ -720,12 +720,12 @@ test('LEN', () => { `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } @@ -738,22 +738,22 @@ test('LEN', () => { test('CONCAT', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return "hello " .. 2 .. " you" `; { luaL_openlibs(L); - let reader = function(L, data) { + let reader = function(_L, _data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; return code ? to_luastring(code) : null; }; - lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); + lua_load(L, reader, luaCode, to_luastring('test'), to_luastring('text')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello 2 you"); + expect(lua_tojsstring(L, -1)).toBe('hello 2 you'); }); diff --git a/test/lmathlib.test.js b/test/lmathlib.test.js index 68fca7dc..db1d5c44 100644 --- a/test/lmathlib.test.js +++ b/test/lmathlib.test.js @@ -1,11 +1,11 @@ import { LUA_OK, lua_call, lua_tointeger, lua_tonumber, lua_tojsstring, lua_toboolean } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.abs(-10), math.abs(-10.5), math.cos(10), math.tan(10), @@ -29,7 +29,7 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', test('math.ceil, math.floor', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.ceil(10.5), math.floor(10.5) @@ -47,7 +47,7 @@ test('math.ceil, math.floor', () => { test('math.deg, math.rad', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.deg(10), math.rad(10) @@ -65,7 +65,7 @@ test('math.deg, math.rad', () => { test('math.log', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.log(10), math.log(10, 2), math.log(10, 10) @@ -85,7 +85,7 @@ test('math.log', () => { /* Node.js 6 has incorrect results for Math.exp */ (parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.exp(10) @@ -102,7 +102,7 @@ test('math.log', () => { test('math.min, math.max', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.max(10, 5, 23), math.min(10, 5, 23) @@ -120,7 +120,7 @@ test('math.min, math.max', () => { test('math.random', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.random(), math.random(10, 15) @@ -146,7 +146,7 @@ test('math.random', () => { test('math.sqrt', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.sqrt(10) @@ -163,7 +163,7 @@ test('math.sqrt', () => { test('math.tointeger', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.tointeger('10') @@ -180,7 +180,7 @@ test('math.tointeger', () => { test('math.type', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.type(10), math.type(10.5), math.type('hello') @@ -191,15 +191,15 @@ test('math.type', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -3)).toBe("integer"); - expect(lua_tojsstring(L, -2)).toBe("float"); + expect(lua_tojsstring(L, -3)).toBe('integer'); + expect(lua_tojsstring(L, -2)).toBe('float'); expect(lua_tojsstring(L, -1)).toBe(null); }); test('math.ult', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.ult(5, 200) @@ -216,7 +216,7 @@ test('math.ult', () => { test('math.fmod', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.fmod(2,5) @@ -233,7 +233,7 @@ test('math.fmod', () => { test('math.modf', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return math.modf(3.4, 0.6) diff --git a/test/load.test.js b/test/load.test.js index c8870c6b..769ecfb6 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -1,13 +1,13 @@ -import { toByteCode } from "./tests.js"; +import { toByteCode } from './tests.js'; import { LUA_OK, lua_call, lua_tojsstring } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('luaL_loadstring', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -19,13 +19,13 @@ test('luaL_loadstring', () => { lua_call(L, 0, -1); } expect(lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('load', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = load("return 'js running lua running lua'") @@ -37,13 +37,13 @@ test('load', () => { lua_call(L, 0, -1); } expect(lua_tojsstring(L, -1)) - .toBe("js running lua running lua"); + .toBe('js running lua running lua'); }); test('undump empty string', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(load(string.dump(function() @@ -61,7 +61,7 @@ test('undump empty string', () => { test('luaL_loadbuffer', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -70,17 +70,17 @@ test('luaL_loadbuffer', () => { { luaL_openlibs(L); let bc = toByteCode(luaCode); - luaL_loadbuffer(L, bc, null, to_luastring("test")); + luaL_loadbuffer(L, bc, null, to_luastring('test')); lua_call(L, 0, -1); } expect(lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); // TODO: test stdin test('loadfile', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = assert(loadfile("test/loadfile-test.lua")) @@ -92,13 +92,13 @@ test('loadfile', () => { lua_call(L, 0, -1); } expect(lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('loadfile (binary)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = assert(loadfile("test/loadfile-test.bc")) @@ -110,13 +110,13 @@ test('loadfile (binary)', () => { lua_call(L, 0, -1); } expect(lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); test('dofile', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return dofile("test/loadfile-test.lua") @@ -127,5 +127,5 @@ test('dofile', () => { lua_call(L, 0, -1); } expect(lua_tojsstring(L, -1)) - .toBe("hello world"); + .toBe('hello world'); }); diff --git a/test/loadlib.test.js b/test/loadlib.test.js index 3f28600c..0cc842d6 100644 --- a/test/loadlib.test.js +++ b/test/loadlib.test.js @@ -1,11 +1,11 @@ import { LUA_OK, lua_call, lua_istable, lua_tojsstring } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('require an existing module', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return require('os') @@ -22,7 +22,7 @@ test('require an existing module', () => { test('require a file', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return require('test.module-hello')() @@ -33,13 +33,13 @@ test('require a file', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello from module"); + expect(lua_tojsstring(L, -1)).toBe('hello from module'); }); test('package.loadlib', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return package.loadlib('./test/lib-hello.js.mod', 'hello')() @@ -50,13 +50,13 @@ test('package.loadlib', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello from js lib"); + expect(lua_tojsstring(L, -1)).toBe('hello from js lib'); }); test('package.searchpath', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return package.searchpath('module-hello', './?.lua;./test/?.lua') @@ -67,5 +67,5 @@ test('package.searchpath', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("./test/module-hello.lua"); + expect(lua_tojsstring(L, -1)).toBe('./test/module-hello.lua'); }); diff --git a/test/loslib.test.js b/test/loslib.test.js index 202e50c3..e5e1d61c 100644 --- a/test/loslib.test.js +++ b/test/loslib.test.js @@ -1,11 +1,11 @@ import { LUA_OK, lua_call, lua_isinteger, lua_tointeger, lua_isnumber, lua_tojsstring, lua_isstring } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('os.time', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.time() @@ -22,7 +22,7 @@ test('os.time', () => { test('os.time (with format)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.time({ @@ -44,7 +44,7 @@ test('os.time (with format)', () => { test('os.difftime', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1 = os.time() @@ -63,7 +63,7 @@ test('os.difftime', () => { test('os.date', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -78,13 +78,13 @@ test('os.date', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("2015-02-08"); + expect(lua_tojsstring(L, -1)).toBe('2015-02-08'); }); test('os.date normalisation', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -99,13 +99,13 @@ test('os.date normalisation', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("2013-11-30"); + expect(lua_tojsstring(L, -1)).toBe('2013-11-30'); }); test('os.time normalisation of table', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = { @@ -128,7 +128,7 @@ test('os.time normalisation of table', () => { test('os.setlocale', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("C" == os.setlocale()) @@ -145,7 +145,7 @@ test('os.setlocale', () => { test('os.getenv', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.getenv('PATH') diff --git a/test/lstrlib.test.js b/test/lstrlib.test.js index a611ced5..22934f0a 100644 --- a/test/lstrlib.test.js +++ b/test/lstrlib.test.js @@ -1,11 +1,11 @@ import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring, lua_tostring, lua_load, lua_toboolean, lua_gettop } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('string.len', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "world" @@ -24,7 +24,7 @@ test('string.len', () => { test('string.char', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.char(104, 101, 108, 108, 111) @@ -35,13 +35,13 @@ test('string.char', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('string.upper, string.lower', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.upper("hello"), string.lower("HELLO") @@ -52,14 +52,14 @@ test('string.upper, string.lower', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("HELLO"); - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -2)).toBe('HELLO'); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('string.rep', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.rep("hello", 3, ", ") @@ -70,13 +70,13 @@ test('string.rep', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello, hello, hello"); + expect(lua_tojsstring(L, -1)).toBe('hello, hello, hello'); }); test('string.reverse', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.reverse("olleh") @@ -87,13 +87,13 @@ test('string.reverse', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('string.byte', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.byte("hello", 2, 4) @@ -112,7 +112,7 @@ test('string.byte', () => { test('string.format', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.format("%%%d %010d", 10, 23) @@ -123,13 +123,13 @@ test('string.format', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("%10 0000000023"); + expect(lua_tojsstring(L, -1)).toBe('%10 0000000023'); }); test('string.format', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.format("%07X", 0xFFFFFFF) @@ -140,13 +140,13 @@ test('string.format', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("FFFFFFF"); + expect(lua_tojsstring(L, -1)).toBe('FFFFFFF'); }); test('string.format', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.format("%q", 'a string with "quotes" and \\n new line') @@ -158,14 +158,14 @@ test('string.format', () => { } expect(lua_tojsstring(L, -1)).toBe('"a string with \\"quotes\\" and \\\n new line"', - "Correct element(s) on the stack" + 'Correct element(s) on the stack' ); }); test('string.sub', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.sub("123456789",2,4), -- "234" @@ -186,23 +186,23 @@ test('string.sub', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -11)).toBe("234"); - expect(lua_tojsstring(L, -10)).toBe("789"); - expect(lua_tojsstring(L, -9)).toBe(""); - expect(lua_tojsstring(L, -8)).toBe("7"); - expect(lua_tojsstring(L, -7)).toBe(""); - expect(lua_tojsstring(L, -6)).toBe("123456789"); - expect(lua_tojsstring(L, -5)).toBe("123456789"); - expect(lua_tojsstring(L, -4)).toBe(""); - expect(lua_tojsstring(L, -3)).toBe("9"); - expect(lua_tojsstring(L, -2)).toBe("6789"); - expect(lua_tojsstring(L, -1)).toBe("456"); + expect(lua_tojsstring(L, -11)).toBe('234'); + expect(lua_tojsstring(L, -10)).toBe('789'); + expect(lua_tojsstring(L, -9)).toBe(''); + expect(lua_tojsstring(L, -8)).toBe('7'); + expect(lua_tojsstring(L, -7)).toBe(''); + expect(lua_tojsstring(L, -6)).toBe('123456789'); + expect(lua_tojsstring(L, -5)).toBe('123456789'); + expect(lua_tojsstring(L, -4)).toBe(''); + expect(lua_tojsstring(L, -3)).toBe('9'); + expect(lua_tojsstring(L, -2)).toBe('6789'); + expect(lua_tojsstring(L, -1)).toBe('456'); }); test('string.dump', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local todump = function() @@ -225,17 +225,17 @@ test('string.dump', () => { let r = s.str; s.str = null; return r; - }, {str: str}, to_luastring("test"), to_luastring("binary")); + }, {str: str}, to_luastring('test'), to_luastring('binary')); lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello1212.5"); + expect(lua_tojsstring(L, -1)).toBe('hello1212.5'); }); test('string.pack/unpack/packsize', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s1, n, s2 = "hello", 2, "you" @@ -256,7 +256,7 @@ test('string.pack/unpack/packsize', () => { test('string.find without pattern', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.find("hello to you", " to ") @@ -274,7 +274,7 @@ test('string.find without pattern', () => { test('string.find with special pattern (issue #185)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.find("-", "-") @@ -293,7 +293,7 @@ test('string.find with special pattern (issue #185)', () => { test('string.match', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)") @@ -304,14 +304,14 @@ test('string.match', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("foo"); - expect(lua_tojsstring(L, -1)).toBe("123"); + expect(lua_tojsstring(L, -2)).toBe('foo'); + expect(lua_tojsstring(L, -1)).toBe('123'); }); test('string.find', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)") @@ -324,14 +324,14 @@ test('string.find', () => { expect(lua_tointeger(L, -4)).toBe(1); expect(lua_tointeger(L, -3)).toBe(8); - expect(lua_tojsstring(L, -2)).toBe("foo"); - expect(lua_tojsstring(L, -1)).toBe("123"); + expect(lua_tojsstring(L, -2)).toBe('foo'); + expect(lua_tojsstring(L, -1)).toBe('123'); }); test('string.gmatch', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "hello world from Lua" @@ -349,16 +349,16 @@ test('string.gmatch', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -4)).toBe("hello"); - expect(lua_tojsstring(L, -3)).toBe("world"); - expect(lua_tojsstring(L, -2)).toBe("from"); - expect(lua_tojsstring(L, -1)).toBe("Lua"); + expect(lua_tojsstring(L, -4)).toBe('hello'); + expect(lua_tojsstring(L, -3)).toBe('world'); + expect(lua_tojsstring(L, -2)).toBe('from'); + expect(lua_tojsstring(L, -1)).toBe('Lua'); }); test('string.gsub', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("hello world", "(%w+)", "%1 %1") @@ -369,14 +369,14 @@ test('string.gsub', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("hello hello world world"); + expect(lua_tojsstring(L, -2)).toBe('hello hello world world'); expect(lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (number)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("hello world", "%w+", "%0 %0", 1) @@ -387,14 +387,14 @@ test('string.gsub (number)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("hello hello world"); + expect(lua_tojsstring(L, -2)).toBe('hello hello world'); expect(lua_tointeger(L, -1)).toBe(1); }); test('string.gsub (pattern)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1") @@ -405,14 +405,14 @@ test('string.gsub (pattern)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("world hello Lua from"); + expect(lua_tojsstring(L, -2)).toBe('world hello Lua from'); expect(lua_tointeger(L, -1)).toBe(2); }); test('string.gsub (function)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) @@ -425,7 +425,7 @@ test('string.gsub (function)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("4+5 = 9"); + expect(lua_tojsstring(L, -2)).toBe('4+5 = 9'); expect(lua_tointeger(L, -1)).toBe(1); }); @@ -433,7 +433,7 @@ test('string.gsub (function)', () => { test('string.gsub (table)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {name="lua", version="5.3"} @@ -445,6 +445,6 @@ test('string.gsub (table)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -2)).toBe("lua-5.3.tar.gz"); + expect(lua_tojsstring(L, -2)).toBe('lua-5.3.tar.gz'); expect(lua_tointeger(L, -1)).toBe(2); }); diff --git a/test/ltablib.test.js b/test/ltablib.test.js index 42771ef1..b4e2620b 100644 --- a/test/ltablib.test.js +++ b/test/ltablib.test.js @@ -1,7 +1,7 @@ import { LUA_OK, lua_call, lua_tojsstring, lua_topointer, lua_tointeger } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; const inttable2array = function(t) { let a = []; @@ -14,7 +14,7 @@ const inttable2array = function(t) { test('table.concat', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return table.concat({1, 2, 3, 4, 5, 6, 7}, ",", 3, 5) @@ -25,13 +25,13 @@ test('table.concat', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("3,4,5"); + expect(lua_tojsstring(L, -1)).toBe('3,4,5'); }); test('table.pack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return table.pack(1, 2, 3) @@ -51,7 +51,7 @@ test('table.pack', () => { test('table.unpack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return table.unpack({1, 2, 3, 4, 5}, 2, 4) @@ -70,7 +70,7 @@ test('table.unpack', () => { test('table.insert', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 3, 4} @@ -94,7 +94,7 @@ test('table.insert', () => { test('table.remove', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 3, 4, 4} @@ -118,7 +118,7 @@ test('table.remove', () => { test('table.move', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1 = {3, 4, 5} @@ -141,7 +141,7 @@ test('table.move', () => { test('table.sort (<)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} @@ -161,7 +161,7 @@ test('table.sort (<)', () => { test('table.sort with cmp function', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} diff --git a/test/ltm.test.js b/test/ltm.test.js index ec844b74..b9ab0f4b 100644 --- a/test/ltm.test.js +++ b/test/ltm.test.js @@ -1,11 +1,11 @@ import { LUA_OK, lua_call, lua_isnil, lua_tointeger, lua_tojsstring, lua_toboolean } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; test('__index, __newindex: with actual table', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {yo=1} @@ -24,7 +24,7 @@ test('__index, __newindex: with actual table', () => { test('__newindex: with non table', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = "a string" @@ -43,7 +43,7 @@ test('__newindex: with non table', () => { test('__index function in metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -64,13 +64,13 @@ test('__index function in metatable', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("__index"); + expect(lua_tojsstring(L, -1)).toBe('__index'); }); test('__newindex function in metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -99,7 +99,7 @@ test('__newindex function in metatable', () => { test('__index table in metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmt = { @@ -122,13 +122,13 @@ test('__index table in metatable', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('__newindex table in metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmt = { @@ -153,14 +153,14 @@ test('__newindex table in metatable', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("world"); + expect(lua_tojsstring(L, -1)).toBe('world'); expect(lua_isnil(L, -2)).toBe(true); }); test('__index table with own metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmmt = { @@ -191,13 +191,13 @@ test('__index table with own metatable', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('__newindex table with own metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = nil @@ -232,14 +232,14 @@ test('__newindex table with own metatable', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); expect(lua_isnil(L, -2)).toBe(true); }); test('binary __xxx functions in metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -319,25 +319,25 @@ test('binary __xxx functions in metatable', () => { expect(L.stack.slice(L.top - 12, L.top).map(e => e.jsstring())) .toEqual([ - "{} + 1", - "{} - 1", - "{} * 1", - "{} % 1", - "{} ^ 1", - "{} / 1", - "{} // 1", - "{} & 1", - "{} | 1", - "{} ~ 1", - "{} << 1", - "{} >> 1" + '{} + 1', + '{} - 1', + '{} * 1', + '{} % 1', + '{} ^ 1', + '{} / 1', + '{} // 1', + '{} & 1', + '{} | 1', + '{} ~ 1', + '{} << 1', + '{} >> 1' ]); }); test('__eq', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -364,7 +364,7 @@ test('__eq', () => { test('__lt', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -391,7 +391,7 @@ test('__lt', () => { test('__le', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -418,7 +418,7 @@ test('__le', () => { test('__le that uses __lt', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -445,7 +445,7 @@ test('__le that uses __lt', () => { test('__unm, __bnot', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -470,14 +470,14 @@ test('__unm, __bnot', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("world"); - expect(lua_tojsstring(L, -2)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('world'); + expect(lua_tojsstring(L, -2)).toBe('hello'); }); test('__len', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -498,13 +498,13 @@ test('__len', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('__concat', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -525,13 +525,13 @@ test('__concat', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('__call', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -553,5 +553,5 @@ test('__call', () => { } expect(L.stack.slice(L.top - 3, L.top).map(e => e.jsstring())) - .toEqual(["hello", "world", "wow"]); + .toEqual(['hello', 'world', 'wow']); }); diff --git a/test/lua.test.js b/test/lua.test.js index 8520dcd1..d793a658 100644 --- a/test/lua.test.js +++ b/test/lua.test.js @@ -1,12 +1,12 @@ import { LUA_OK, lua_call } from '../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from "../src/fengaricore.js"; +import { to_luastring } from '../src/fengaricore.js'; // TODO: remove test.skip('locals.lua', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -23,7 +23,7 @@ test.skip('locals.lua', () => { test.skip('constructs.lua', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -40,7 +40,7 @@ test.skip('constructs.lua', () => { test.skip('strings.lua', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return dofile("tests/lua-tests/strings.lua") @@ -55,7 +55,7 @@ test.skip('strings.lua', () => { test('__newindex leaves nils', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = setmetatable({}, { diff --git a/test/lutf8lib.test.js b/test/lutf8lib.test.js index af38dfc4..e6d0eaac 100644 --- a/test/lutf8lib.test.js +++ b/test/lutf8lib.test.js @@ -1,11 +1,11 @@ -import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring } from "../src/lua.js"; -import { luaL_newstate, luaL_loadstring } from "../src/lauxlib.js"; -import { luaL_openlibs } from "../src/lualib.js"; -import { to_luastring } from "../src/fengaricore.js"; +import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaL_openlibs } from '../src/lualib.js'; +import { to_luastring } from '../src/fengaricore.js'; test('utf8.offset', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.offset("( ͡° ͜ʖ ͡° )", 5) @@ -22,7 +22,7 @@ test('utf8.offset', () => { test('utf8.codepoint', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8) @@ -41,7 +41,7 @@ test('utf8.codepoint', () => { test('utf8.char', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.char(40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 32, 41) @@ -52,13 +52,13 @@ test('utf8.char', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("( ͡° ͜ʖ ͡° )"); + expect(lua_tojsstring(L, -1)).toBe('( ͡° ͜ʖ ͡° )'); }); test('utf8.len', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return utf8.len("( ͡° ͜ʖ ͡° )") @@ -75,7 +75,7 @@ test('utf8.len', () => { test('utf8.codes', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "( ͡° ͜ʖ ͡° )" @@ -91,5 +91,5 @@ test('utf8.codes', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] "); + expect(lua_tojsstring(L, -1)).toBe('[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] '); }); diff --git a/test/lvm.test.js b/test/lvm.test.js index 3acb9a5e..61abd53e 100644 --- a/test/lvm.test.js +++ b/test/lvm.test.js @@ -1,12 +1,12 @@ -import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from "../src/lua.js"; -import { luaL_newstate, luaL_loadstring } from "../src/lauxlib.js"; -import { luaS_hash } from "../src/lstring.js"; -import { to_luastring } from "../src/fengaricore.js"; +import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { luaS_hash } from '../src/lstring.js'; +import { to_luastring } from '../src/fengaricore.js'; test('LOADK, RETURN', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -17,13 +17,13 @@ test('LOADK, RETURN', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe('hello world'); }); test('MOVE', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -35,12 +35,12 @@ test('MOVE', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello world"); + expect(lua_tojsstring(L, -1)).toBe('hello world'); }); test('Binary op', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -59,7 +59,7 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -78,7 +78,7 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -95,7 +95,7 @@ test('NEWTABLE', () => { test('CALL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -117,7 +117,7 @@ test('CALL', () => { test('Multiple return', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -144,7 +144,7 @@ test('Multiple return', () => { test('TAILCALL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -164,7 +164,7 @@ test('TAILCALL', () => { test('VARARG', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (...) @@ -185,7 +185,7 @@ test('VARARG', () => { test('LE, JMP', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -203,7 +203,7 @@ test('LE, JMP', () => { test('LT', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -221,7 +221,7 @@ test('LT', () => { test('EQ', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -239,7 +239,7 @@ test('EQ', () => { test('TESTSET (and)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -252,13 +252,13 @@ test('TESTSET (and)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('TESTSET (or)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -271,13 +271,13 @@ test('TESTSET (or)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('TEST (true)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -294,13 +294,13 @@ test('TEST (true)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('TEST (false)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -317,13 +317,13 @@ test('TEST (false)', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("goodbye"); + expect(lua_tojsstring(L, -1)).toBe('goodbye'); }); test('FORPREP, FORLOOP (int)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -345,7 +345,7 @@ test('FORPREP, FORLOOP (int)', () => { test('FORPREP, FORLOOP (float)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -367,7 +367,7 @@ test('FORPREP, FORLOOP (float)', () => { test('SETTABLE, GETTABLE', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -383,15 +383,15 @@ test('SETTABLE, GETTABLE', () => { } expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SETUPVAL, GETUPVAL', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = "hello" @@ -409,13 +409,13 @@ test('SETUPVAL, GETUPVAL', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("world"); + expect(lua_tojsstring(L, -1)).toBe('world'); }); test('SETTABUP, GETTABUP', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -431,15 +431,15 @@ test('SETTABUP, GETTABUP', () => { } expect(lua_topointer(L, -1).strong.get(1).value.jsstring()) - .toBe("hello"); - expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + .toBe('hello'); + expect(lua_topointer(L, -1).strong.get(luaS_hash(to_luastring('two'))).value.jsstring()) + .toBe('world'); }); test('SELF', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -456,13 +456,13 @@ test('SELF', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello"); + expect(lua_tojsstring(L, -1)).toBe('hello'); }); test('SETLIST', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -481,7 +481,7 @@ test('SETLIST', () => { test('Variable SETLIST', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = function () @@ -504,7 +504,7 @@ test('Variable SETLIST', () => { test('Long SETLIST', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} @@ -547,7 +547,7 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local iterator = function (t, i) @@ -581,7 +581,7 @@ test('TFORCALL, TFORLOOP', () => { test('LEN', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[10000] = "foo"} @@ -603,7 +603,7 @@ test('LEN', () => { test('CONCAT', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return "hello " .. 2 .. " you" @@ -613,5 +613,5 @@ test('CONCAT', () => { lua_call(L, 0, -1); } - expect(lua_tojsstring(L, -1)).toBe("hello 2 you"); + expect(lua_tojsstring(L, -1)).toBe('hello 2 you'); }); diff --git a/test/manual-tests/debug-cli.js b/test/manual-tests/debug-cli.js index 37a63ed8..119dd6a2 100755 --- a/test/manual-tests/debug-cli.js +++ b/test/manual-tests/debug-cli.js @@ -3,7 +3,7 @@ import { lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; let luaCode = ` a = "debug me" diff --git a/test/test-suite/api.test.js b/test/test-suite/api.test.js index 9381b150..ebdf6920 100644 --- a/test/test-suite/api.test.js +++ b/test/test-suite/api.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; import { luaopen_tests } from './ltests.js'; @@ -24,9 +24,9 @@ const prefix = ` end `; -test("[test-suite] api: registry", () => { +test('[test-suite] api: registry', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = T.testC("pushvalue R; return 1") @@ -40,9 +40,9 @@ test("[test-suite] api: registry", () => { }); -test("[test-suite] api: absindex", () => { +test('[test-suite] api: absindex', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("settop 10; absindex -1; return 1") == 10) @@ -58,9 +58,9 @@ test("[test-suite] api: absindex", () => { }); -test("[test-suite] api: testing alignment", () => { +test('[test-suite] api: testing alignment', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- Useless tests in fengari since we do the same thing in d2s than in string.pack @@ -83,9 +83,9 @@ test("[test-suite] api: testing alignment", () => { }); -test("[test-suite] api: test that all trues are equal", () => { +test('[test-suite] api: test that all trues are equal', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a,b,c = T.testC("pushbool 1; pushbool 2; pushbool 0; return 3") @@ -136,9 +136,9 @@ test("[test-suite] api: test that all trues are equal", () => { }); -test("[test-suite] api: testing 'rotate'", () => { +test('[test-suite] api: testing \'rotate\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing 'rotate' @@ -172,9 +172,9 @@ test("[test-suite] api: testing 'rotate'", () => { }); -test("[test-suite] api: testing non-function message handlers", () => { +test('[test-suite] api: testing non-function message handlers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -213,9 +213,9 @@ test("[test-suite] api: testing non-function message handlers", () => { }); -test("[test-suite] api: testing MULTRET", () => { +test('[test-suite] api: testing MULTRET', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = pack(T.testC("call 2,-1; return *", @@ -230,9 +230,9 @@ test("[test-suite] api: testing MULTRET", () => { }); -test("[test-suite] api: test returning more results than fit in the caller stack", () => { +test('[test-suite] api: test returning more results than fit in the caller stack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test returning more results than fit in the caller stack @@ -251,9 +251,9 @@ test("[test-suite] api: test returning more results than fit in the caller stack }); -test("[test-suite] api: testing globals", () => { +test('[test-suite] api: testing globals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.a = 14; _G.b = "a31" @@ -274,9 +274,9 @@ test("[test-suite] api: testing globals", () => { }); -test("[test-suite] api: testing arith", () => { +test('[test-suite] api: testing arith', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5) @@ -320,9 +320,9 @@ test("[test-suite] api: testing arith", () => { }); -test("[test-suite] api: errors in arithmetic", () => { +test('[test-suite] api: errors in arithmetic', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerr("divide by zero", T.testC, "arith \\\\", 10, 0) @@ -336,9 +336,9 @@ test("[test-suite] api: errors in arithmetic", () => { }); -test("[test-suite] api: testing lessthan and lessequal", () => { +test('[test-suite] api: testing lessthan and lessequal', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("compare LT 2 5, return 1", 3, 2, 2, 4, 2, 2)) @@ -357,9 +357,9 @@ test("[test-suite] api: testing lessthan and lessequal", () => { }); -test("[test-suite] api: non-valid indices produce false", () => { +test('[test-suite] api: non-valid indices produce false', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not T.testC("compare LT 1 4, return 1")) @@ -388,9 +388,9 @@ test("[test-suite] api: non-valid indices produce false", () => { }); -test("[test-suite] api: testing length", () => { +test('[test-suite] api: testing length', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = setmetatable({x = 20}, {__len = function (t) return t.x end}) @@ -427,9 +427,9 @@ test("[test-suite] api: testing length", () => { }); -test("[test-suite] api: testing __concat", () => { +test('[test-suite] api: testing __concat', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = setmetatable({x="u"}, {__concat = function (a,b) return a.x..'.'..b.x end}) @@ -457,9 +457,9 @@ test("[test-suite] api: testing __concat", () => { }); -test("[test-suite] api: testing lua_is", () => { +test('[test-suite] api: testing lua_is', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function B(x) return x and 1 or 0 end @@ -500,9 +500,9 @@ test("[test-suite] api: testing lua_is", () => { }); -test("[test-suite] api: testing lua_to...", () => { +test('[test-suite] api: testing lua_to...', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function to (s, x, n) @@ -548,9 +548,9 @@ test("[test-suite] api: testing lua_to...", () => { lua_call(L, 0, 0); }); -test("[test-suite] api: testing panic function", () => { +test('[test-suite] api: testing panic function', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -596,9 +596,9 @@ test("[test-suite] api: testing panic function", () => { }); -test.skip("[test-suite] api: testing deep JS stack", () => { +test.skip('[test-suite] api: testing deep JS stack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -640,9 +640,9 @@ test.skip("[test-suite] api: testing deep JS stack", () => { }); -test("[test-suite] api: testing errors", () => { +test('[test-suite] api: testing errors', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = T.testC([[ @@ -671,9 +671,9 @@ test("[test-suite] api: testing errors", () => { }); -test("[test-suite] api: test errors in non protected threads", () => { +test('[test-suite] api: test errors in non protected threads', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function checkerrnopro (code, msg) @@ -697,9 +697,9 @@ test("[test-suite] api: test errors in non protected threads", () => { }); -test("[test-suite] api: testing table access", () => { +test('[test-suite] api: testing table access', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- getp/setp @@ -748,9 +748,9 @@ test("[test-suite] api: testing table access", () => { }); -test("[test-suite] api: testing getfield/setfield with long keys", () => { +test('[test-suite] api: testing getfield/setfield with long keys', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing getfield/setfield with long keys @@ -776,9 +776,9 @@ test("[test-suite] api: testing getfield/setfield with long keys", () => { }); -test("[test-suite] api: testing next", () => { +test('[test-suite] api: testing next', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -798,9 +798,9 @@ test("[test-suite] api: testing next", () => { }); -test("[test-suite] api: testing upvalues", () => { +test('[test-suite] api: testing upvalues', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -826,9 +826,9 @@ test("[test-suite] api: testing upvalues", () => { }); -test("[test-suite] api: testing absent upvalues from JS-function pointers", () => { +test('[test-suite] api: testing absent upvalues from JS-function pointers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC[[isnull U1; return 1]] == true) @@ -850,9 +850,9 @@ test("[test-suite] api: testing absent upvalues from JS-function pointers", () = }); -test("[test-suite] api: large closures", () => { +test('[test-suite] api: large closures', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -875,9 +875,9 @@ test("[test-suite] api: large closures", () => { }); -test("[test-suite] api: testing get/setuservalue", () => { +test('[test-suite] api: testing get/setuservalue', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- bug in 5.1.2 @@ -910,9 +910,9 @@ test("[test-suite] api: testing get/setuservalue", () => { }); -test.skip("[test-suite] api: testing get/setuservalue", () => { +test.skip('[test-suite] api: testing get/setuservalue', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T.gcstate("atomic") @@ -929,9 +929,9 @@ test.skip("[test-suite] api: testing get/setuservalue", () => { }); -test.skip("[test-suite] api: long chain of userdata", () => { +test.skip('[test-suite] api: long chain of userdata', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, 1000 do @@ -954,9 +954,9 @@ test.skip("[test-suite] api: long chain of userdata", () => { }); -test.skip("[test-suite] api: reuse of references", () => { +test.skip('[test-suite] api: reuse of references', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local i = T.ref{} @@ -1014,9 +1014,9 @@ test.skip("[test-suite] api: reuse of references", () => { }); -test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", () => { +test.skip('[test-suite] api: collect in cl the `val\' of all collected userdata', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` tt = {} @@ -1130,9 +1130,9 @@ test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", }); -test.skip("[test-suite] api: test whether udate collection frees memory in the right time", () => { +test.skip('[test-suite] api: test whether udate collection frees memory in the right time', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1174,9 +1174,9 @@ test.skip("[test-suite] api: test whether udate collection frees memory in the r }); -test("[test-suite] api: testing lua_equal", () => { +test('[test-suite] api: testing lua_equal', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("compare EQ 2 4; return 1", print, 1, print, 20)) @@ -1194,9 +1194,9 @@ test("[test-suite] api: testing lua_equal", () => { }); -test("[test-suite] api: testing lua_equal with fallbacks", () => { +test('[test-suite] api: testing lua_equal with fallbacks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1224,9 +1224,9 @@ test("[test-suite] api: testing lua_equal with fallbacks", () => { }); -test("[test-suite] api: testing changing hooks during hooks", () => { +test('[test-suite] api: testing changing hooks during hooks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.t = {} @@ -1258,9 +1258,9 @@ test("[test-suite] api: testing changing hooks during hooks", () => { }); -test.skip("[test-suite] api: testing errors during GC", () => { +test.skip('[test-suite] api: testing errors during GC', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing errors during GC @@ -1298,9 +1298,9 @@ test.skip("[test-suite] api: testing errors during GC", () => { }); -test("[test-suite] api: test for userdata vals", () => { +test('[test-suite] api: test for userdata vals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1321,9 +1321,9 @@ test("[test-suite] api: test for userdata vals", () => { }); -test("[test-suite] api: testing multiple states", () => { +test('[test-suite] api: testing multiple states', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T.closestate(T.newstate()); @@ -1380,9 +1380,9 @@ test("[test-suite] api: testing multiple states", () => { }); -test.skip("[test-suite] api: testing memory limits", () => { +test.skip('[test-suite] api: testing memory limits', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerr("block too big", T.newuserdata, math.maxinteger) @@ -1426,9 +1426,9 @@ const memprefix = ` `; -test.skip("[test-suite] api: testing memory errors when creating a new state", () => { +test.skip('[test-suite] api: testing memory errors when creating a new state', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` b = testamem("state creation", T.newstate) @@ -1441,9 +1441,9 @@ test.skip("[test-suite] api: testing memory errors when creating a new state", ( lua_call(L, 0, 0); }); -test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", () => { +test('[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` mt = T.testC("rawgeti R 1; return 1") @@ -1456,9 +1456,9 @@ test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHR lua_call(L, 0, 0); }); -test.skip("[test-suite] api: test thread creation after stressing GC", () => { +test.skip('[test-suite] api: test thread creation after stressing GC', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function expand (n,s) @@ -1484,9 +1484,9 @@ test.skip("[test-suite] api: test thread creation after stressing GC", () => { }); -test.skip("[test-suite] api: testing memory x compiler", () => { +test.skip('[test-suite] api: testing memory x compiler', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` testamem("loadstring", function () @@ -1501,9 +1501,9 @@ test.skip("[test-suite] api: testing memory x compiler", () => { }); -test.skip("[test-suite] api: testing memory x dofile", () => { +test.skip('[test-suite] api: testing memory x dofile', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local testprog = [[ @@ -1535,9 +1535,9 @@ test.skip("[test-suite] api: testing memory x dofile", () => { }); -test.skip("[test-suite] api: other generic tests", () => { +test.skip('[test-suite] api: other generic tests', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` testamem("string creation", function () @@ -1606,9 +1606,9 @@ test.skip("[test-suite] api: other generic tests", () => { }); -test("[test-suite] api: testing some auxlib functions", () => { +test('[test-suite] api: testing some auxlib functions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function gsub (a, b, c) @@ -1631,9 +1631,9 @@ test("[test-suite] api: testing some auxlib functions", () => { }); -test("[test-suite] api: testing luaL_newmetatable", () => { +test('[test-suite] api: testing luaL_newmetatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt_xuxu, res, top = T.testC("newmetatable xuxu; gettop; return 3") diff --git a/test/test-suite/attrib.test.js b/test/test-suite/attrib.test.js index 5797dac0..bfba6f3d 100644 --- a/test/test-suite/attrib.test.js +++ b/test/test-suite/attrib.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; -test("[test-suite] attrib: testing require", () => { +test('[test-suite] attrib: testing require', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(require"string" == string) @@ -60,15 +60,15 @@ test("[test-suite] attrib: testing require", () => { // TODO: when io.write etc. -test.skip("[test-suite] attrib: system specific tests for 'require'", () => { +test.skip('[test-suite] attrib: system specific tests for \'require\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); }); -test("[test-suite] attrib: testing assignments, logical operators, and constructors", () => { +test('[test-suite] attrib: testing assignments, logical operators, and constructors', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local res, res2 = 27 @@ -166,9 +166,9 @@ test("[test-suite] attrib: testing assignments, logical operators, and construct }); -test("[test-suite] attrib: test of large float/integer indices ", () => { +test('[test-suite] attrib: test of large float/integer indices ', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -230,9 +230,9 @@ test("[test-suite] attrib: test of large float/integer indices ", () => { }); -test("[test-suite] attrib: test conflicts in multiple assignment", () => { +test('[test-suite] attrib: test conflicts in multiple assignment', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -250,9 +250,9 @@ test("[test-suite] attrib: test conflicts in multiple assignment", () => { }); -test("[test-suite] attrib: repeat test with upvalues", () => { +test('[test-suite] attrib: repeat test with upvalues', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -276,9 +276,9 @@ test("[test-suite] attrib: repeat test with upvalues", () => { }); -test("[test-suite] attrib: bug in 5.2 beta", () => { +test('[test-suite] attrib: bug in 5.2 beta', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () diff --git a/test/test-suite/bitwise.test.js b/test/test-suite/bitwise.test.js index 08644f69..c8b1edd9 100644 --- a/test/test-suite/bitwise.test.js +++ b/test/test-suite/bitwise.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` package.preload.bit32 = function () --{ @@ -112,9 +112,9 @@ const prefix = ` local bit32 = require'bit32' `; -test("[test-suite] bitwise: testing bitwise operations", () => { +test('[test-suite] bitwise: testing bitwise operations', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local numbits = string.packsize('j') * 8 @@ -182,9 +182,9 @@ test("[test-suite] bitwise: testing bitwise operations", () => { }); -test("[test-suite] bitwise: testing bitwise library", () => { +test('[test-suite] bitwise: testing bitwise library', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.band() == bit32.bnot(0)) @@ -202,9 +202,9 @@ test("[test-suite] bitwise: testing bitwise library", () => { }); -test("[test-suite] bitwise: out-of-range numbers", () => { +test('[test-suite] bitwise: out-of-range numbers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.band(-1) == 0xffffffff) @@ -267,9 +267,9 @@ test("[test-suite] bitwise: out-of-range numbers", () => { }); -test("[test-suite] bitwise: some special cases", () => { +test('[test-suite] bitwise: some special cases', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555, @@ -310,9 +310,9 @@ test("[test-suite] bitwise: some special cases", () => { }); -test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)", () => { +test('[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` c = {0, 1, 2, 3, 10, 0x800000, 0xaaaaaa, 0x555555, 0xffffff, 0x7fffff} @@ -337,9 +337,9 @@ test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si }); -test("[test-suite] bitwise: testing extract/replace", () => { +test('[test-suite] bitwise: testing extract/replace', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.extract(0x12345678, 0, 4) == 8) @@ -368,9 +368,9 @@ test("[test-suite] bitwise: testing extract/replace", () => { }); -test("[test-suite] bitwise: testing conversion of floats", () => { +test('[test-suite] bitwise: testing conversion of floats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.bor(3.0) == 3) @@ -383,9 +383,9 @@ test("[test-suite] bitwise: testing conversion of floats", () => { }); -test("[test-suite] bitwise: large floats and large-enough integers?", () => { +test('[test-suite] bitwise: large floats and large-enough integers?', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if 2.0^50 < 2.0^50 + 1.0 and 2.0^50 < (-1 >> 1) then diff --git a/test/test-suite/calls.test.js b/test/test-suite/calls.test.js index 94566aef..e7776ea8 100644 --- a/test/test-suite/calls.test.js +++ b/test/test-suite/calls.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; -test("[test-suite] calls: test 'type'", () => { +test('[test-suite] calls: test \'type\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(1<2) == 'boolean') @@ -28,9 +28,9 @@ test("[test-suite] calls: test 'type'", () => { }); -test("[test-suite] calls: test error in 'print'", () => { +test('[test-suite] calls: test error in \'print\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test error in 'print' too... @@ -54,9 +54,9 @@ test("[test-suite] calls: test error in 'print'", () => { }); -test("[test-suite] calls: testing local-function recursion", () => { +test('[test-suite] calls: testing local-function recursion', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` fact = false @@ -78,9 +78,9 @@ test("[test-suite] calls: testing local-function recursion", () => { }); -test("[test-suite] calls: testing declarations", () => { +test('[test-suite] calls: testing declarations', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {i = 10} @@ -173,9 +173,9 @@ test("[test-suite] calls: testing declarations", () => { }); -test("[test-suite] calls: testing closures", () => { +test('[test-suite] calls: testing closures', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- fixed-point operator @@ -219,9 +219,9 @@ test("[test-suite] calls: testing closures", () => { }); -test("[test-suite] calls: testing multiple returns", () => { +test('[test-suite] calls: testing multiple returns', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function unlpack (t, i) @@ -265,9 +265,9 @@ test("[test-suite] calls: testing multiple returns", () => { }); -test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { +test('[test-suite] calls: testing calls with \'incorrect\' arguments', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` rawget({}, "x", 1) @@ -282,9 +282,9 @@ test("[test-suite] calls: testing calls with 'incorrect' arguments", () => { }); -test("[test-suite] calls: test for generic load", () => { +test('[test-suite] calls: test for generic load', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = "-- a comment\\0\\0\\0\\n x = 10 + \\n23; \\ @@ -342,9 +342,9 @@ test("[test-suite] calls: test for generic load", () => { }); -test("[test-suite] calls: any value is valid for _ENV", () => { +test('[test-suite] calls: any value is valid for _ENV', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(load("return _ENV", nil, nil, 123)() == 123) @@ -356,9 +356,9 @@ test("[test-suite] calls: any value is valid for _ENV", () => { }); -test("[test-suite] calls: load when _ENV is not first upvalue", () => { +test('[test-suite] calls: load when _ENV is not first upvalue', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x; XX = 123 @@ -381,9 +381,9 @@ test("[test-suite] calls: load when _ENV is not first upvalue", () => { }); -test("[test-suite] calls: test generic load with nested functions", () => { +test('[test-suite] calls: test generic load with nested functions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function read1 (x) @@ -414,9 +414,9 @@ test("[test-suite] calls: test generic load with nested functions", () => { }); -test("[test-suite] calls: test for dump/undump with upvalues", () => { +test('[test-suite] calls: test for dump/undump with upvalues', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 20, 30 @@ -442,9 +442,9 @@ test("[test-suite] calls: test for dump/undump with upvalues", () => { }); -test("[test-suite] calls: test for dump/undump with many upvalues", () => { +test('[test-suite] calls: test for dump/undump with many upvalues', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -477,9 +477,9 @@ test("[test-suite] calls: test for dump/undump with many upvalues", () => { }); -test("[test-suite] calls: test for long method names", () => { +test('[test-suite] calls: test for long method names', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -497,9 +497,9 @@ test("[test-suite] calls: test for long method names", () => { }); -test("[test-suite] calls: test for bug in parameter adjustment", () => { +test('[test-suite] calls: test for bug in parameter adjustment', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert((function () return nil end)(4) == nil) @@ -513,9 +513,9 @@ test("[test-suite] calls: test for bug in parameter adjustment", () => { }); -test("[test-suite] calls: testing binary chunks", () => { +test('[test-suite] calls: testing binary chunks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/closure.test.js b/test/test-suite/closure.test.js index f00d4de6..9be13f0f 100644 --- a/test/test-suite/closure.test.js +++ b/test/test-suite/closure.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; -test("[test-suite] closure: testing equality", () => { +test('[test-suite] closure: testing equality', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -27,9 +27,9 @@ test("[test-suite] closure: testing equality", () => { }); -test("[test-suite] closure: testing closures with 'for' control variable", () => { +test('[test-suite] closure: testing closures with \'for\' control variable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -68,9 +68,9 @@ test("[test-suite] closure: testing closures with 'for' control variable", () => }); -test("[test-suite] closure: testing closures with 'for' control variable x break", () => { +test('[test-suite] closure: testing closures with \'for\' control variable x break', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {"a", "b"} @@ -96,9 +96,9 @@ test("[test-suite] closure: testing closures with 'for' control variable x break }); -test("[test-suite] closure: testing closure x break x return x errors", () => { +test('[test-suite] closure: testing closure x break x return x errors', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local b @@ -140,9 +140,9 @@ test("[test-suite] closure: testing closure x break x return x errors", () => { }); -test("[test-suite] closure: testing multi-level closure", () => { +test('[test-suite] closure: testing multi-level closure', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local w @@ -163,9 +163,9 @@ test("[test-suite] closure: testing multi-level closure", () => { }); -test("[test-suite] closure: testing closures x repeat-until", () => { +test('[test-suite] closure: testing closures x repeat-until', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -183,9 +183,9 @@ test("[test-suite] closure: testing closures x repeat-until", () => { }); -test("[test-suite] closure: testing closures created in 'then' and 'else' parts of 'if's", () => { +test('[test-suite] closure: testing closures created in \'then\' and \'else\' parts of \'if\'s', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -224,9 +224,9 @@ test("[test-suite] closure: testing closures created in 'then' and 'else' parts }); -test("[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions", () => { +test('[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function t () diff --git a/test/test-suite/code.test.js b/test/test-suite/code.test.js index 16c56812..82e70c19 100644 --- a/test/test-suite/code.test.js +++ b/test/test-suite/code.test.js @@ -1,13 +1,13 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; import { luaopen_tests } from './ltests.js'; -test("[test-suite] code: testing reuse in constant table", () => { +test('[test-suite] code: testing reuse in constant table', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkKlist (func, list) @@ -62,9 +62,9 @@ const prefix = ` `; -test("[test-suite] code: some basic instructions", () => { +test('[test-suite] code: some basic instructions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -79,9 +79,9 @@ test("[test-suite] code: some basic instructions", () => { }); -test("[test-suite] code: sequence of LOADNILs", () => { +test('[test-suite] code: sequence of LOADNILs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -110,9 +110,9 @@ test("[test-suite] code: sequence of LOADNILs", () => { }); -test("[test-suite] code: single return", () => { +test('[test-suite] code: single return', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check (function (a,b,c) return a end, 'RETURN') @@ -125,9 +125,9 @@ test("[test-suite] code: single return", () => { }); -test("[test-suite] code: infinite loops", () => { +test('[test-suite] code: infinite loops', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () while true do local a = -1 end end, @@ -147,9 +147,9 @@ test("[test-suite] code: infinite loops", () => { }); -test("[test-suite] code: concat optimization", () => { +test('[test-suite] code: concat optimization', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function (a,b,c,d) return a..b..c..d end, @@ -163,9 +163,9 @@ test("[test-suite] code: concat optimization", () => { }); -test("[test-suite] code: not", () => { +test('[test-suite] code: not', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return not not nil end, 'LOADBOOL', 'RETURN') @@ -181,9 +181,9 @@ test("[test-suite] code: not", () => { }); -test("[test-suite] code: direct access to locals", () => { +test('[test-suite] code: direct access to locals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -204,9 +204,9 @@ test("[test-suite] code: direct access to locals", () => { }); -test("[test-suite] code: direct access to constants", () => { +test('[test-suite] code: direct access to constants', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -239,9 +239,9 @@ test("[test-suite] code: direct access to constants", () => { }); -test("[test-suite] code: constant folding", () => { +test('[test-suite] code: constant folding', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkK (func, val) @@ -273,9 +273,9 @@ test("[test-suite] code: constant folding", () => { }); -test("[test-suite] code: no folding", () => { +test('[test-suite] code: no folding', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return -0.0 end, 'LOADK', 'UNM', 'RETURN') @@ -291,9 +291,9 @@ test("[test-suite] code: no folding", () => { }); -test("[test-suite] code: bug in constant folding for 5.1", () => { +test('[test-suite] code: bug in constant folding for 5.1', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN') @@ -321,9 +321,9 @@ test("[test-suite] code: bug in constant folding for 5.1", () => { }); -test("[test-suite] code: x == nil , x ~= nil", () => { +test('[test-suite] code: x == nil , x ~= nil', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkequal(function () if (a==nil) then a=1 end; if a~=nil then a=1 end end, @@ -346,9 +346,9 @@ test("[test-suite] code: x == nil , x ~= nil", () => { }); -test("[test-suite] code: if-goto optimizations", () => { +test('[test-suite] code: if-goto optimizations', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function (a, b, c, d, e) diff --git a/test/test-suite/constructs.test.js b/test/test-suite/constructs.test.js index df2ebf49..56029360 100644 --- a/test/test-suite/constructs.test.js +++ b/test/test-suite/constructs.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const checkload = ` local function checkload (s, msg) @@ -11,7 +11,7 @@ const checkload = ` test('[test-suite] constructs: testing semicolons', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do ;;; end @@ -27,7 +27,7 @@ test('[test-suite] constructs: testing semicolons', () => { test('[test-suite] constructs: invalid operations should not raise errors when not executed', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if false then a = 3 // 0; a = 0 % 0 end @@ -41,7 +41,7 @@ test('[test-suite] constructs: invalid operations should not raise errors when n test('[test-suite] constructs: testing priorities', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(2^3^2 == 2^(3^2)); @@ -94,7 +94,7 @@ test('[test-suite] constructs: testing priorities', () => { test('[test-suite] constructs: silly loops', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` repeat until 1; repeat until true; @@ -267,7 +267,7 @@ test('[test-suite] constructs: silly loops', () => { test.skip('[test-suite] constructs: huge loops, upvalue', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- sometimes will be 0, sometimes will not... @@ -341,9 +341,9 @@ test.skip('[test-suite] constructs: huge loops, upvalue', () => { }); -test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", () => { +test('[test-suite] constructs: testing some syntax errors (chosen through \'gcov\')', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true diff --git a/test/test-suite/coroutine.test.js b/test/test-suite/coroutine.test.js index 193de600..3386b33c 100644 --- a/test/test-suite/coroutine.test.js +++ b/test/test-suite/coroutine.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; import { luaopen_tests } from './ltests.js'; @@ -53,9 +53,9 @@ const prefix = ` end `; -test("[test-suite] coroutine: is main thread", () => { +test('[test-suite] coroutine: is main thread', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local main, ismain = coroutine.running() @@ -71,9 +71,9 @@ test("[test-suite] coroutine: is main thread", () => { }); -test("[test-suite] coroutine: trivial errors", () => { +test('[test-suite] coroutine: trivial errors', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(coroutine.resume, 0)) @@ -86,9 +86,9 @@ test("[test-suite] coroutine: trivial errors", () => { }); -test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => { +test('[test-suite] coroutine: tests for multiple yield/resume arguments', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function eqtab (t1, t2) @@ -141,9 +141,9 @@ test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => }); -test("[test-suite] coroutine: yields in tail calls", () => { +test('[test-suite] coroutine: yields in tail calls', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (i) return coroutine.yield(i) end @@ -163,9 +163,9 @@ test("[test-suite] coroutine: yields in tail calls", () => { }); -test("[test-suite] coroutine: recursive", () => { +test('[test-suite] coroutine: recursive', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function pf (n, i) @@ -187,9 +187,9 @@ test("[test-suite] coroutine: recursive", () => { }); -test("[test-suite] coroutine: sieve", () => { +test('[test-suite] coroutine: sieve', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function gen (n) @@ -228,9 +228,9 @@ test("[test-suite] coroutine: sieve", () => { }); -test("[test-suite] coroutine: yielding across JS boundaries", () => { +test('[test-suite] coroutine: yielding across JS boundaries', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (s, i) return coroutine.yield(i) end @@ -268,9 +268,9 @@ test("[test-suite] coroutine: yielding across JS boundaries", () => { }); -test("[test-suite] coroutine: unyieldable JS call", () => { +test('[test-suite] coroutine: unyieldable JS call', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -294,9 +294,9 @@ test("[test-suite] coroutine: unyieldable JS call", () => { }); -test("[test-suite] coroutine: errors in coroutines", () => { +test('[test-suite] coroutine: errors in coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function foo () @@ -327,9 +327,9 @@ test("[test-suite] coroutine: errors in coroutines", () => { }); -test("[test-suite] coroutine: co-routines x for loop", () => { +test('[test-suite] coroutine: co-routines x for loop', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function all (a, n, k) @@ -355,9 +355,9 @@ test("[test-suite] coroutine: co-routines x for loop", () => { }); -test("[test-suite] coroutine: old bug: attempt to resume itself", () => { +test('[test-suite] coroutine: old bug: attempt to resume itself', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function co_func (current_co) @@ -386,9 +386,9 @@ test("[test-suite] coroutine: old bug: attempt to resume itself", () => { }); -test("[test-suite] coroutine: old bug: other old bug when attempting to resume itself", () => { +test('[test-suite] coroutine: old bug: other old bug when attempting to resume itself', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -409,9 +409,9 @@ test("[test-suite] coroutine: old bug: other old bug when attempting to resume i }); -test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { +test('[test-suite] coroutine: attempt to resume \'normal\' coroutine', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co1, co2 @@ -433,9 +433,9 @@ test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => { }); -test("[test-suite] coroutine: infinite recursion of coroutines", () => { +test('[test-suite] coroutine: infinite recursion of coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = function(a) coroutine.wrap(a)(a) end @@ -449,9 +449,9 @@ test("[test-suite] coroutine: infinite recursion of coroutines", () => { }); -test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { +test('[test-suite] coroutine: access to locals of erroneous coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = coroutine.create (function () @@ -472,9 +472,9 @@ test("[test-suite] coroutine: access to locals of erroneous coroutines", () => { lua_call(L, 0, 0); }); -test("[test-suite] coroutine: leaving a pending coroutine open", () => { +test('[test-suite] coroutine: leaving a pending coroutine open', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _X = coroutine.wrap(function () @@ -492,9 +492,9 @@ test("[test-suite] coroutine: leaving a pending coroutine open", () => { }); -test("[test-suite] coroutine: stack overflow", () => { +test('[test-suite] coroutine: stack overflow', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- bug (stack overflow) @@ -520,9 +520,9 @@ test("[test-suite] coroutine: stack overflow", () => { }); -test("[test-suite] coroutine: testing yields inside metamethods", () => { +test('[test-suite] coroutine: testing yields inside metamethods', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = new(10) @@ -568,9 +568,9 @@ test("[test-suite] coroutine: testing yields inside metamethods", () => { }); -test("[test-suite] coroutine: tests for comparsion operators", () => { +test('[test-suite] coroutine: tests for comparsion operators', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -620,9 +620,9 @@ test("[test-suite] coroutine: tests for comparsion operators", () => { }); -test("[test-suite] coroutine: getuptable & setuptable", () => { +test('[test-suite] coroutine: getuptable & setuptable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do local _ENV = _ENV @@ -640,9 +640,9 @@ test("[test-suite] coroutine: getuptable & setuptable", () => { }); -test("[test-suite] coroutine: testing yields inside 'for' iterators", () => { +test('[test-suite] coroutine: testing yields inside \'for\' iterators', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (s, i) @@ -674,9 +674,9 @@ const jsprefix = ` end `; -test("[test-suite] coroutine: testing yields inside hooks", () => { +test('[test-suite] coroutine: testing yields inside hooks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local A, B = 0, 0 @@ -706,9 +706,9 @@ test("[test-suite] coroutine: testing yields inside hooks", () => { }); -test("[test-suite] coroutine: testing yields inside line hook", () => { +test('[test-suite] coroutine: testing yields inside line hook', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -737,9 +737,9 @@ test("[test-suite] coroutine: testing yields inside line hook", () => { }); -test("[test-suite] coroutine: testing yields in count hook", () => { +test('[test-suite] coroutine: testing yields in count hook', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -766,9 +766,9 @@ test("[test-suite] coroutine: testing yields in count hook", () => { }); -test("[test-suite] coroutine: testing yields inside line hook", () => { +test('[test-suite] coroutine: testing yields inside line hook', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -804,9 +804,9 @@ test("[test-suite] coroutine: testing yields inside line hook", () => { }); -test("[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook", () => { +test('[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -844,9 +844,9 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins }); -test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", () => { +test('[test-suite] coroutine: testing debug library on last function in a suspended coroutine', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -868,9 +868,9 @@ test("[test-suite] coroutine: testing debug library on last function in a suspen }); -test("[test-suite] coroutine: reusing a thread", () => { +test('[test-suite] coroutine: reusing a thread', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC([[ @@ -902,9 +902,9 @@ test("[test-suite] coroutine: reusing a thread", () => { }); -test("[test-suite] coroutine: resuming running coroutine", () => { +test('[test-suite] coroutine: resuming running coroutine', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = coroutine.create(function () @@ -938,9 +938,9 @@ test("[test-suite] coroutine: resuming running coroutine", () => { lua_call(L, 0, 0); }); -test("[test-suite] coroutine: using a main thread as a coroutine", () => { +test('[test-suite] coroutine: using a main thread as a coroutine', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local state = T.newstate() @@ -982,9 +982,9 @@ test("[test-suite] coroutine: using a main thread as a coroutine", () => { }); -test("[test-suite] coroutine: tests for coroutine API", () => { +test('[test-suite] coroutine: tests for coroutine API', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function apico (...) @@ -1034,9 +1034,9 @@ test("[test-suite] coroutine: tests for coroutine API", () => { }); -test("[test-suite] coroutine: tests for coroutine API", () => { +test('[test-suite] coroutine: tests for coroutine API', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` f = T.makeCfunc("pushnum 3; pushnum 5; yield 1;") @@ -1055,9 +1055,9 @@ test("[test-suite] coroutine: tests for coroutine API", () => { }); -test("[test-suite] coroutine: testing coroutines with C bodies", () => { +test('[test-suite] coroutine: testing coroutines with C bodies', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function eqtab (t1, t2) @@ -1100,9 +1100,9 @@ test("[test-suite] coroutine: testing coroutines with C bodies", () => { }); -test("[test-suite] coroutine: testing chain of suspendable C calls", () => { +test('[test-suite] coroutine: testing chain of suspendable C calls', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local count = 3 -- number of levels @@ -1143,9 +1143,9 @@ test("[test-suite] coroutine: testing chain of suspendable C calls", () => { }); -test("[test-suite] coroutine: testing yields with continuations", () => { +test('[test-suite] coroutine: testing yields with continuations', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = coroutine.wrap(function (...) return @@ -1208,9 +1208,9 @@ test("[test-suite] coroutine: testing yields with continuations", () => { }); -test("[test-suite] coroutine: bug in nCcalls", () => { +test('[test-suite] coroutine: bug in nCcalls', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.wrap(function () diff --git a/test/test-suite/db.test.js b/test/test-suite/db.test.js index 58b2911b..3edcaadb 100644 --- a/test/test-suite/db.test.js +++ b/test/test-suite/db.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` local function dostring(s) return assert(load(s))() end @@ -20,9 +20,9 @@ const prefix = ` end `; -test("[test-suite] db: getinfo, ...line...", () => { +test('[test-suite] db: getinfo, ...line...', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(debug.getinfo, print, "X")) -- invalid option @@ -48,9 +48,9 @@ test("[test-suite] db: getinfo, ...line...", () => { }); -test("[test-suite] db: test file and string names truncation", () => { +test('[test-suite] db: test file and string names truncation', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = "function f () end" @@ -83,9 +83,9 @@ test("[test-suite] db: test file and string names truncation", () => { lua_call(L, 0, 0); }); -test("[test-suite] db: local", () => { +test('[test-suite] db: local', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` repeat @@ -131,9 +131,9 @@ test("[test-suite] db: local", () => { }); -test("[test-suite] db: line hook", () => { +test('[test-suite] db: line hook', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` test([[if @@ -197,9 +197,9 @@ test("[test-suite] db: line hook", () => { }); -test("[test-suite] db: invalid levels in [gs]etlocal", () => { +test('[test-suite] db: invalid levels in [gs]etlocal', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(debug.getlocal, 20, 1)) @@ -212,9 +212,9 @@ test("[test-suite] db: invalid levels in [gs]etlocal", () => { }); -test("[test-suite] db: parameter names", () => { +test('[test-suite] db: parameter names', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (a,b,...) local d, e end @@ -236,9 +236,9 @@ test("[test-suite] db: parameter names", () => { }); -test("[test-suite] db: vararg", () => { +test('[test-suite] db: vararg', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (a, ...) @@ -273,9 +273,9 @@ test("[test-suite] db: vararg", () => { }); -test("[test-suite] db: access to vararg in non-vararg function", () => { +test('[test-suite] db: access to vararg in non-vararg function', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () return debug.getlocal(1, -1) end @@ -288,9 +288,9 @@ test("[test-suite] db: access to vararg in non-vararg function", () => { }); -test("[test-suite] db: test hook presence in debug info", () => { +test('[test-suite] db: test hook presence in debug info', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test hook presence in debug info @@ -384,9 +384,9 @@ test("[test-suite] db: test hook presence in debug info", () => { }); -test("[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)", () => { +test('[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local n, v = debug.getlocal(0, 1) @@ -418,9 +418,9 @@ test("[test-suite] db: tests for manipulating non-registered locals (C and Lua t }); -test("[test-suite] db: testing access to function arguments", () => { +test('[test-suite] db: testing access to function arguments', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function collectlocals (level) @@ -467,9 +467,9 @@ test("[test-suite] db: testing access to function arguments", () => { }); -test("[test-suite] db: testing access to local variables in return hook (bug in 5.2)", () => { +test('[test-suite] db: testing access to local variables in return hook (bug in 5.2)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function collectlocals (level) @@ -514,9 +514,9 @@ test("[test-suite] db: testing access to local variables in return hook (bug in }); -test("[test-suite] db: testing upvalue access", () => { +test('[test-suite] db: testing upvalue access', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function getupvalues (f) @@ -554,9 +554,9 @@ test("[test-suite] db: testing upvalue access", () => { }); -test("[test-suite] db: testing count hooks", () => { +test('[test-suite] db: testing count hooks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a=0 @@ -584,9 +584,9 @@ test("[test-suite] db: testing count hooks", () => { }); -test("[test-suite] db: tests for tail calls", () => { +test('[test-suite] db: tests for tail calls', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (x) @@ -650,9 +650,9 @@ test("[test-suite] db: tests for tail calls", () => { }); -test("[test-suite] db: testing local function information", () => { +test('[test-suite] db: testing local function information', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = load[[ @@ -680,9 +680,9 @@ test("[test-suite] db: testing local function information", () => { }); -test("[test-suite] db: testing traceback", () => { +test('[test-suite] db: testing traceback', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(debug.traceback(print) == print) @@ -705,9 +705,9 @@ test("[test-suite] db: testing traceback", () => { }); -test("[test-suite] db: testing nparams, nups e isvararg", () => { +test('[test-suite] db: testing nparams, nups e isvararg', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = debug.getinfo(print, "u") @@ -730,9 +730,9 @@ test("[test-suite] db: testing nparams, nups e isvararg", () => { }); -test("[test-suite] db: testing debugging of coroutines", () => { +test('[test-suite] db: testing debugging of coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checktraceback (co, p, level) @@ -803,15 +803,15 @@ test("[test-suite] db: testing debugging of coroutines", () => { `; luaL_openlibs(L); let b = to_luastring(luaCode); - if (luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === LUA_ERRSYNTAX) + if (luaL_loadbuffer(L, b, b.length, to_luastring('@db.lua')) === LUA_ERRSYNTAX) throw new SyntaxError(lua_tojsstring(L, -1)); lua_call(L, 0, 0); }); -test("[test-suite] db: check get/setlocal in coroutines", () => { +test('[test-suite] db: check get/setlocal in coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = coroutine.create(function (x) @@ -836,9 +836,9 @@ test("[test-suite] db: check get/setlocal in coroutines", () => { }); -test("[test-suite] db: check traceback of suspended (or dead with error) coroutines", () => { +test('[test-suite] db: check traceback of suspended (or dead with error) coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checktraceback (co, p, level) @@ -871,9 +871,9 @@ test("[test-suite] db: check traceback of suspended (or dead with error) corouti }); -test("[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function", () => { +test('[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function g(x) @@ -902,9 +902,9 @@ test("[test-suite] db: check test acessing line numbers of a coroutine from a re }); -test("[test-suite] db: test tagmethod information", () => { +test('[test-suite] db: test tagmethod information', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -942,9 +942,9 @@ test("[test-suite] db: test tagmethod information", () => { }); -test("[test-suite] db: testing for-iterator name", () => { +test('[test-suite] db: testing for-iterator name', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -962,9 +962,9 @@ test("[test-suite] db: testing for-iterator name", () => { }); -test("[test-suite] db: testing traceback sizes", () => { +test('[test-suite] db: testing traceback sizes', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function countlines (s) @@ -1004,15 +1004,15 @@ test("[test-suite] db: testing traceback sizes", () => { `; luaL_openlibs(L); let b = to_luastring(luaCode); - if (luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === LUA_ERRSYNTAX) + if (luaL_loadbuffer(L, b, b.length, to_luastring('@db.lua')) === LUA_ERRSYNTAX) throw new SyntaxError(lua_tojsstring(L, -1)); lua_call(L, 0, 0); }); -test("[test-suite] db: testing debug functions on chunk without debug info", () => { +test('[test-suite] db: testing debug functions on chunk without debug info', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` prog = [[-- program to be loaded without debug information @@ -1065,9 +1065,9 @@ test("[test-suite] db: testing debug functions on chunk without debug info", () }); -test("[test-suite] db: tests for 'source' in binary dumps", () => { +test('[test-suite] db: tests for \'source\' in binary dumps', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/errors.test.js b/test/test-suite/errors.test.js index 8131cceb..403325dc 100644 --- a/test/test-suite/errors.test.js +++ b/test/test-suite/errors.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` -- avoid problems with 'strict' module (which may generate other error messages) @@ -40,9 +40,9 @@ const prefix = ` end `; -test("[test-suite] errors: test error message with no extra info", () => { +test('[test-suite] errors: test error message with no extra info', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(doit("error('hi', 0)") == 'hi') @@ -54,9 +54,9 @@ test("[test-suite] errors: test error message with no extra info", () => { }); -test("[test-suite] errors: test error message with no info", () => { +test('[test-suite] errors: test error message with no info', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(doit("error()") == nil) @@ -68,9 +68,9 @@ test("[test-suite] errors: test error message with no info", () => { }); -test("[test-suite] errors: test common errors/errors that crashed in the past", () => { +test('[test-suite] errors: test common errors/errors that crashed in the past', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(doit("table.unpack({}, 1, n=2^30)")) @@ -97,9 +97,9 @@ test("[test-suite] errors: test common errors/errors that crashed in the past", }); -test("[test-suite] errors: tests for better error messages", () => { +test('[test-suite] errors: tests for better error messages', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("a = {} + 1", "arithmetic") @@ -131,9 +131,9 @@ test("[test-suite] errors: tests for better error messages", () => { }); -test("[test-suite] errors: upvalues being indexed do not go to the stack", () => { +test('[test-suite] errors: upvalues being indexed do not go to the stack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("local a,b,cc; (function () a = cc[1] end)()", "upvalue 'cc'") @@ -153,9 +153,9 @@ test("[test-suite] errors: upvalues being indexed do not go to the stack", () => }); -test("[test-suite] errors: short circuit", () => { +test('[test-suite] errors: short circuit', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("a=1; local a,bbbb=2,3; a = math.sin(1) and bbbb(3)", @@ -178,9 +178,9 @@ test("[test-suite] errors: short circuit", () => { }); -test("[test-suite] errors: float->integer conversions", () => { +test('[test-suite] errors: float->integer conversions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("local a = 2.0^100; x = a << 2", "local a") @@ -208,9 +208,9 @@ test("[test-suite] errors: float->integer conversions", () => { }); -test("[test-suite] errors: passing light userdata instead of full userdata", () => { +test('[test-suite] errors: passing light userdata instead of full userdata', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.D = debug @@ -228,9 +228,9 @@ test("[test-suite] errors: passing light userdata instead of full userdata", () }); -test("[test-suite] errors: named objects (field '__name')", () => { +test('[test-suite] errors: named objects (field \'__name\')', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -253,9 +253,9 @@ test("[test-suite] errors: named objects (field '__name')", () => { }); -test("[test-suite] errors: global functions", () => { +test('[test-suite] errors: global functions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("(io.write or print){}", "io.write") @@ -268,9 +268,9 @@ test("[test-suite] errors: global functions", () => { }); -test("[test-suite] errors: errors in functions without debug info", () => { +test('[test-suite] errors: errors in functions without debug info', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -294,9 +294,9 @@ test("[test-suite] errors: errors in functions without debug info", () => { }); -test("[test-suite] errors: tests for field accesses after RK limit", () => { +test('[test-suite] errors: tests for field accesses after RK limit', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -317,9 +317,9 @@ test("[test-suite] errors: tests for field accesses after RK limit", () => { }); -test("[test-suite] errors: global", () => { +test('[test-suite] errors: global', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[aaa=9 @@ -340,9 +340,9 @@ test("[test-suite] errors: global", () => { }); -test("[test-suite] errors: field", () => { +test('[test-suite] errors: field', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -357,9 +357,9 @@ test("[test-suite] errors: field", () => { }); -test("[test-suite] errors: global insert", () => { +test('[test-suite] errors: global insert', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -378,9 +378,9 @@ test("[test-suite] errors: global insert", () => { }); -test("[test-suite] errors: sin", () => { +test('[test-suite] errors: sin', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ -- tail call @@ -394,9 +394,9 @@ test("[test-suite] errors: sin", () => { }); -test("[test-suite] errors: concatenate", () => { +test('[test-suite] errors: concatenate', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[x = print .. "a"]], "concatenate") @@ -410,9 +410,9 @@ test("[test-suite] errors: concatenate", () => { }); -test("[test-suite] errors: unknown global", () => { +test('[test-suite] errors: unknown global', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -430,9 +430,9 @@ test("[test-suite] errors: unknown global", () => { }); -test("[test-suite] errors: __index", () => { +test('[test-suite] errors: __index', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {}; setmetatable(a, {__index = string}) @@ -450,9 +450,9 @@ test("[test-suite] errors: __index", () => { }); -test("[test-suite] errors: tests for errors in coroutines", () => { +test('[test-suite] errors: tests for errors in coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (n) @@ -474,9 +474,9 @@ test("[test-suite] errors: tests for errors in coroutines", () => { }); -test("[test-suite] errors: testing size of 'source' info", () => { +test('[test-suite] errors: testing size of \'source\' info', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` idsize = 60 - 1 @@ -501,9 +501,9 @@ test("[test-suite] errors: testing size of 'source' info", () => { }); -test("[test-suite] errors: testing line error", () => { +test('[test-suite] errors: testing line error', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function lineerror (s, l) @@ -566,9 +566,9 @@ test("[test-suite] errors: testing line error", () => { }); -test("[test-suite] errors: several tests that exhaust the Lua stack", () => { +test('[test-suite] errors: several tests that exhaust the Lua stack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = 0 @@ -589,9 +589,9 @@ test("[test-suite] errors: several tests that exhaust the Lua stack", () => { }); -test("[test-suite] errors: error lines in stack overflow", () => { +test('[test-suite] errors: error lines in stack overflow', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = 0 @@ -620,9 +620,9 @@ test("[test-suite] errors: error lines in stack overflow", () => { }); -test("[test-suite] errors: error in error handling", () => { +test('[test-suite] errors: error in error handling', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local res, msg = xpcall(error, error) @@ -645,9 +645,9 @@ test("[test-suite] errors: error in error handling", () => { }); -test("[test-suite] errors: too many results", () => { +test('[test-suite] errors: too many results', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function loop (x,y,z) return 1 + loop(x, y, z) end @@ -672,9 +672,9 @@ test("[test-suite] errors: too many results", () => { }); -test("[test-suite] errors: non string messages", () => { +test('[test-suite] errors: non string messages', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -712,15 +712,15 @@ test("[test-suite] errors: non string messages", () => { end `; luaL_openlibs(L); - if (luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua")) === LUA_ERRSYNTAX) + if (luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring('@errors.lua')) === LUA_ERRSYNTAX) throw new SyntaxError(lua_tojsstring(L, -1)); lua_call(L, 0, 0); }); -test("[test-suite] errors: xpcall with arguments", () => { +test('[test-suite] errors: xpcall with arguments', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a, b, c = xpcall(string.find, error, "alo", "al") @@ -735,9 +735,9 @@ test("[test-suite] errors: xpcall with arguments", () => { }); -test("[test-suite] errors: testing tokens in error messages", () => { +test('[test-suite] errors: testing tokens in error messages', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("syntax error", "", "error", 1) @@ -754,9 +754,9 @@ test("[test-suite] errors: testing tokens in error messages", () => { }); -test("[test-suite] errors: test invalid non-printable char in a chunk", () => { +test('[test-suite] errors: test invalid non-printable char in a chunk', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("a\\1a = 1", "", "<\\\\1>", 1) @@ -768,9 +768,9 @@ test("[test-suite] errors: test invalid non-printable char in a chunk", () => { }); -test("[test-suite] errors: test 255 as first char in a chunk", () => { +test('[test-suite] errors: test 255 as first char in a chunk', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("\\255a = 1", "", "<\\\\255>", 1) @@ -785,9 +785,9 @@ test("[test-suite] errors: test 255 as first char in a chunk", () => { }); -test("[test-suite] errors: lots of errors", () => { +test('[test-suite] errors: lots of errors', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` lim = 1000 @@ -804,9 +804,9 @@ test("[test-suite] errors: lots of errors", () => { }); -test("[test-suite] errors: testing syntax limits", () => { +test('[test-suite] errors: testing syntax limits', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local maxClevel = 200 -- LUAI_MAXCCALLS (in llimits.h) @@ -839,9 +839,9 @@ test("[test-suite] errors: testing syntax limits", () => { }); -test("[test-suite] errors: upvalues limit", () => { +test('[test-suite] errors: upvalues limit', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local lim = 127 @@ -873,9 +873,9 @@ test("[test-suite] errors: upvalues limit", () => { }); -test("[test-suite] errors: local variables limit", () => { +test('[test-suite] errors: local variables limit', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` s = "\\nfunction foo ()\\n local " diff --git a/test/test-suite/events.test.js b/test/test-suite/events.test.js index 0f4f6e08..42633549 100644 --- a/test/test-suite/events.test.js +++ b/test/test-suite/events.test.js @@ -1,13 +1,13 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; import { luaopen_tests } from './ltests.js'; -test("[test-suite] events: testing metatable", () => { +test('[test-suite] events: testing metatable', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` X = 20; B = 30 @@ -188,9 +188,9 @@ test("[test-suite] events: testing metatable", () => { }); -test("[test-suite] events: test for rawlen", () => { +test('[test-suite] events: test for rawlen', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = setmetatable({1,2,3}, {__len = function () return 10 end}) @@ -210,9 +210,9 @@ test("[test-suite] events: test for rawlen", () => { }); -test("[test-suite] events: test comparison", () => { +test('[test-suite] events: test comparison', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -259,9 +259,9 @@ test("[test-suite] events: test comparison", () => { }); -test("[test-suite] events: test 'partial order'", () => { +test('[test-suite] events: test \'partial order\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -330,9 +330,9 @@ test("[test-suite] events: test 'partial order'", () => { }); -test("[test-suite] events: __eq between userdata", () => { +test('[test-suite] events: __eq between userdata', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T = require('T') @@ -362,9 +362,9 @@ test("[test-suite] events: __eq between userdata", () => { }); -test("[test-suite] events: concat", () => { +test('[test-suite] events: concat', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -401,9 +401,9 @@ test("[test-suite] events: concat", () => { }); -test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { +test('[test-suite] events: concat metamethod x numbers (bug in 5.1.1)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` c = {} @@ -423,9 +423,9 @@ test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => { }); -test("[test-suite] events: test comparison compatibilities", () => { +test('[test-suite] events: test comparison compatibilities', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1, t2, c, d @@ -449,9 +449,9 @@ test("[test-suite] events: test comparison compatibilities", () => { }); -test("[test-suite] events: test for several levels of callstest for several levels of calls", () => { +test('[test-suite] events: test for several levels of callstest for several levels of calls', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local i @@ -480,9 +480,9 @@ test("[test-suite] events: test for several levels of callstest for several leve }); -test("[test-suite] events: __index on _ENV", () => { +test('[test-suite] events: __index on _ENV', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local _g = _G @@ -500,9 +500,9 @@ test("[test-suite] events: __index on _ENV", () => { }); -test("[test-suite] events: testing metatables for basic types", () => { +test('[test-suite] events: testing metatables for basic types', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` mt = {__index = function (a,b) return a+b end, @@ -542,9 +542,9 @@ test("[test-suite] events: testing metatables for basic types", () => { }); -test("[test-suite] events: loops in delegation", () => { +test('[test-suite] events: loops in delegation', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {}; setmetatable(a, a); a.__index = a; a.__newindex = a @@ -559,9 +559,9 @@ test("[test-suite] events: loops in delegation", () => { }); -test("[test-suite] events: bug in 5.1", () => { +test('[test-suite] events: bug in 5.1', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T, K, V = nil diff --git a/test/test-suite/goto.test.js b/test/test-suite/goto.test.js index cef94c53..53dc3c82 100644 --- a/test/test-suite/goto.test.js +++ b/test/test-suite/goto.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; -test("[test-suite] goto: error messages", () => { +test('[test-suite] goto: error messages', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function errmsg (code, m) @@ -51,9 +51,9 @@ test("[test-suite] goto: error messages", () => { }); -test("[test-suite] goto", () => { +test('[test-suite] goto', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- simple gotos @@ -118,9 +118,9 @@ test("[test-suite] goto", () => { }); -test("[test-suite] goto: to repeat a label in a different function is OK", () => { +test('[test-suite] goto: to repeat a label in a different function is OK', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () @@ -146,9 +146,9 @@ test("[test-suite] goto: to repeat a label in a different function is OK", () => }); -test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { +test('[test-suite] goto: bug in 5.2 -> 5.3.2', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- bug in 5.2 -> 5.3.2 @@ -173,9 +173,9 @@ test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => { }); -test("[test-suite] goto: testing closing of upvalues", () => { +test('[test-suite] goto: testing closing of upvalues', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () @@ -246,9 +246,9 @@ test("[test-suite] goto: testing closing of upvalues", () => { }); -test("[test-suite] goto: testing if x goto optimizations", () => { +test('[test-suite] goto: testing if x goto optimizations', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function testG (a) diff --git a/test/test-suite/literals.test.js b/test/test-suite/literals.test.js index 25181e62..014fc754 100644 --- a/test/test-suite/literals.test.js +++ b/test/test-suite/literals.test.js @@ -1,15 +1,15 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const dostring = ` local function dostring (x) return assert(load(x), "")() end `; -test("[test-suite] literals: dostring", () => { +test('[test-suite] literals: dostring', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` dostring("x \\v\\f = \\t\\r 'a\\0a' \\v\\f\\f") @@ -23,9 +23,9 @@ test("[test-suite] literals: dostring", () => { // TODO: bell character '\a' in JS is parsed as 'a' -test("[test-suite] literals: escape sequences", () => { +test('[test-suite] literals: escape sequences', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('\\n\\"\\'\\\\' == [[ @@ -40,9 +40,9 @@ test("[test-suite] literals: escape sequences", () => { }); -test("[test-suite] literals: assume ASCII just for tests", () => { +test('[test-suite] literals: assume ASCII just for tests', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\09912" == 'c12') @@ -60,9 +60,9 @@ test("[test-suite] literals: assume ASCII just for tests", () => { }); -test("[test-suite] literals: hexadecimal escapes", () => { +test('[test-suite] literals: hexadecimal escapes', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\x00\\x05\\x10\\x1f\\x3C\\xfF\\xe8" == "\\0\\5\\16\\31\\60\\255\\232") @@ -95,9 +95,9 @@ assert("abc\\z }); -test("[test-suite] literals: UTF-8 sequences", () => { +test('[test-suite] literals: UTF-8 sequences', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\u{0}\\u{00000000}\\x00\\0" == string.char(0, 0, 0, 0)) @@ -121,9 +121,9 @@ test("[test-suite] literals: UTF-8 sequences", () => { }); -test("[test-suite] literals: Error in escape sequences", () => { +test('[test-suite] literals: Error in escape sequences', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function lexerror (s, err) @@ -175,9 +175,9 @@ test("[test-suite] literals: Error in escape sequences", () => { }); -test("[test-suite] literals: valid characters in variable names", () => { +test('[test-suite] literals: valid characters in variable names', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 0, 255 do @@ -194,9 +194,9 @@ test("[test-suite] literals: valid characters in variable names", () => { }); -test("[test-suite] literals: long variable names", () => { +test('[test-suite] literals: long variable names', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` var1 = string.rep('a', 15000) .. '1' @@ -217,9 +217,9 @@ test("[test-suite] literals: long variable names", () => { }); -test("[test-suite] literals: escapes", () => { +test('[test-suite] literals: escapes', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `assert("\\n\\t" == [[\n\n\t]]) assert([[\n\n $debug]] == "\\n $debug") @@ -231,9 +231,9 @@ assert([[ [ ]] ~= [[ ] ]])`; }); -test("[test-suite] literals: long strings", () => { +test('[test-suite] literals: long strings', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789" assert(string.len(b) == 960) @@ -294,9 +294,9 @@ b = nil`; }); -test("[test-suite] literals: testing line ends", () => { +test('[test-suite] literals: testing line ends', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `prog = [[ a = 1 -- a comment @@ -324,9 +324,9 @@ end`; }); -test("[test-suite] literals: testing comments and strings with long brackets", () => { +test('[test-suite] literals: testing comments and strings with long brackets', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `a = [==[]=]==] assert(a == "]=") @@ -354,9 +354,9 @@ error error]=]===]`; }); -test("[test-suite] literals: generate all strings of four of these chars", () => { +test('[test-suite] literals: generate all strings of four of these chars', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = `local x = {"=", "[", "]", "\\n"} local len = 4 @@ -379,9 +379,9 @@ end`; }); -test("[test-suite] literals: testing %q x line ends", () => { +test('[test-suite] literals: testing %q x line ends', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "a string with \\r and \\n and \\r\\n and \\n\\r" @@ -395,9 +395,9 @@ test("[test-suite] literals: testing %q x line ends", () => { }); -test("[test-suite] literals: testing errors", () => { +test('[test-suite] literals: testing errors', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not load"a = 'non-ending string") diff --git a/test/test-suite/locals.test.js b/test/test-suite/locals.test.js index 8f92d931..339c9e7d 100644 --- a/test/test-suite/locals.test.js +++ b/test/test-suite/locals.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; test('[test-suite] locals: bug in 5.1', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f(x) x = nil; return x end @@ -26,7 +26,7 @@ test('[test-suite] locals: bug in 5.1', () => { test('[test-suite] locals: local scope', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -95,7 +95,7 @@ const getenv = ` test('[test-suite] locals: test for global table of loaded chunks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(getenv(load"a=3") == _G) @@ -114,7 +114,7 @@ test('[test-suite] locals: test for global table of loaded chunks', () => { test('[test-suite] locals: old test for limits for special instructions (now just a generic test)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -145,7 +145,7 @@ test('[test-suite] locals: old test for limits for special instructions (now jus test('[test-suite] locals: testing lexical environments', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(_ENV == _G) diff --git a/test/test-suite/ltests.js b/test/test-suite/ltests.js index fb33e1a2..e23d1138 100644 --- a/test/test-suite/ltests.js +++ b/test/test-suite/ltests.js @@ -1,14 +1,14 @@ -import assert from "assert"; +import assert from 'assert'; import { lua_tointeger, lua_pop, lua_gettop, LUA_REGISTRYINDEX, lua_upvalueindex, lua_pushstring, lua_pushnumber, lua_absindex, lua_rawlen, lua_rawseti, lua_arith, lua_call, lua_callk, LUA_OPEQ, LUA_OPLT, LUA_OPLE, lua_pushboolean, lua_compare, lua_concat, lua_copy, lua_tocfunction, lua_getfield, lua_getglobal, lua_getmetatable, lua_pushnil, lua_gettable, lua_pushinteger, lua_tostring, lua_insert, lua_iscfunction, lua_isfunction, lua_isnil, lua_isnone, lua_isnumber, lua_isstring, lua_istable, lua_islightuserdata, lua_isuserdata, lua_len, lua_newtable, lua_newthread, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pushcclosure, lua_pushvalue, lua_rawgeti, lua_rawgetp, lua_rawsetp, lua_remove, lua_replace, lua_resume, lua_tothread, lua_rotate, lua_setfield, lua_setglobal, lua_setmetatable, lua_settable, lua_settop, lua_error, lua_toboolean, lua_pushcfunction, lua_tonumber, lua_topointer, lua_xmove, lua_yield, lua_yieldk, lua_isthread, LUA_TFUNCTION, lua_getupvalue, lua_setupvalue, lua_pushlightuserdata, lua_touserdata, lua_pushlstring, lua_newstate, lua_atpanic, lua_type, LUA_TTABLE, lua_close, LUA_OK, LUA_MULTRET, lua_tojsstring, lua_checkstack, lua_pushliteral, lua_sethook, lua_isnoneornil, LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, LUA_MASKCOUNT, LUA_YIELD, lua_createtable } from '../../src/lua.js'; import { luaL_error, luaL_checkstack, luaL_gsub, luaL_len, luaL_loadfile, luaL_checkstring, luaL_loadstring, luaL_newmetatable, luaL_tojsstring, luaL_testudata, luaL_typename, luaL_checkinteger, luaL_checktype, luaL_checknumber, luaL_argcheck, luaL_requiref, luaL_getsubtable, LUA_PRELOAD_TABLE, luaL_checklstring, luaL_loadbuffer, luaL_optstring, luaL_optinteger, luaL_newlib } from '../../src/lauxlib.js'; -import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from "../../src/fengaricore.js"; +import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from '../../src/fengaricore.js'; import { lisdigit } from '../../src/ljstype.js'; import { GET_OPCODE, OpCodes, getOpMode, iABC, GETARG_A, GETARG_B, GETARG_C, iABx, GETARG_Bx, iAsBx, GETARG_sBx, iAx, GETARG_Ax } from '../../src/lopcodes.js'; import { pushobj2s } from '../../src/lobject.js'; import { sprintf } from 'sprintf-js'; -const delimits = [" ", "\t", "\n", ",", ";"].map(e => e.charCodeAt(0)); +const delimits = [' ', '\t', '\n', ',', ';'].map(e => e.charCodeAt(0)); const skip = function(pc) { for (;;) { @@ -40,7 +40,7 @@ const getnum = function(L, L1, pc) { pc.offset++; } if (!lisdigit(pc.script[pc.offset])) - luaL_error(L, to_luastring("number expected (%s)"), pc.script); + luaL_error(L, to_luastring('number expected (%s)'), pc.script); while (lisdigit(pc.script[pc.offset])) res = res*10 + pc.script[pc.offset++] - '0'.charCodeAt(0); return sig*res; }; @@ -52,7 +52,7 @@ const getstring = function(L, buff, pc) { let quote = pc.script[pc.offset++]; while (pc.script[pc.offset] !== quote) { if (pc.script[pc.offset] === 0 || pc.offset >= pc.script.length) - luaL_error(L, to_luastring("unfinished string in JS script", true)); + luaL_error(L, to_luastring('unfinished string in JS script', true)); buff[i++] = pc.script[pc.offset++]; } pc.offset++; @@ -67,13 +67,13 @@ const getindex = function(L, L1, pc) { skip(pc); switch (pc.script[pc.offset++]) { case 'R'.charCodeAt(0): return LUA_REGISTRYINDEX; - case 'G'.charCodeAt(0): return luaL_error(L, to_luastring("deprecated index 'G'", true)); + case 'G'.charCodeAt(0): return luaL_error(L, to_luastring('deprecated index \'G\'', true)); case 'U'.charCodeAt(0): return lua_upvalueindex(getnum(L, L1, pc)); default: pc.offset--; return getnum(L, L1, pc); } }; -const codes = ["OK", "YIELD", "ERRRUN", "ERRSYNTAX", "ERRMEM", "ERRGCMM", "ERRERR"].map(e => to_luastring(e)); +const codes = ['OK', 'YIELD', 'ERRRUN', 'ERRSYNTAX', 'ERRMEM', 'ERRGCMM', 'ERRERR'].map(e => to_luastring(e)); const pushcode = function(L, code) { lua_pushstring(L, codes[code]); @@ -82,10 +82,10 @@ const pushcode = function(L, code) { const printstack = function(L) { let n = lua_gettop(L); for (let i = 1; i <= n; i++) { - console.log("${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n"); + console.log('${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n'); lua_pop(L, 1); } - console.log(""); + console.log(''); }; /* @@ -96,47 +96,47 @@ const printstack = function(L) { ** LUA_OPUNM -> _ ** LUA_OPBNOT -> ! */ -const ops = "+-*%^/\\&|~<>_!".split('').map(e => e.charCodeAt(0)); +const ops = '+-*%^/\\&|~<>_!'.split('').map(e => e.charCodeAt(0)); const runJS = function(L, L1, pc) { let buff = new Uint8Array(300); let status = 0; - if (!pc || !pc.script) return luaL_error(L, to_luastring("attempt to runJS null script")); + if (!pc || !pc.script) return luaL_error(L, to_luastring('attempt to runJS null script')); for (;;) { let inst = to_jsstring(getstring(L, buff, pc)); if (inst.length === 0) return 0; switch (inst) { - case "absindex": { + case 'absindex': { lua_pushnumber(L1, lua_absindex(L1, getindex(L, L1, pc))); break; } - case "append": { + case 'append': { let t = getindex(L, L1, pc); let i = lua_rawlen(L1, t); lua_rawseti(L1, t, i + 1); break; } - case "arith": { + case 'arith': { let op; skip(pc); op = ops.indexOf(pc.script[pc.offset++]); lua_arith(L1, op); break; } - case "call": { + case 'call': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); lua_call(L1, narg, nres); break; } - case "callk": { + case 'callk': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); lua_callk(L1, narg, nres, i, Cfunck); break; } - case "checkstack": { + case 'checkstack': { let sz = getnum(L, L1, pc); let msg = getstring(L, buff, pc); if (msg.length === 0) @@ -144,7 +144,7 @@ const runJS = function(L, L1, pc) { luaL_checkstack(L1, sz, msg); break; } - case "compare": { + case 'compare': { let opt = getstring(L, buff, pc); /* EQ, LT, or LE */ let op = (opt[0] === 'E'.charCodeAt(0)) ? LUA_OPEQ @@ -154,150 +154,150 @@ const runJS = function(L, L1, pc) { lua_pushboolean(L1, lua_compare(L1, a, b, op)); break; } - case "concat": { + case 'concat': { lua_concat(L1, getnum(L, L1, pc)); break; } - case "copy": { + case 'copy': { let f = getindex(L, L1, pc); lua_copy(L1, f, getindex(L, L1, pc)); break; } - case "func2num": { + case 'func2num': { let func = lua_tocfunction(L1, getindex(L, L1, pc)); if (func === null) func = 0; else if (func.id) func = func.id; lua_pushnumber(L1, func); break; } - case "getfield": { + case 'getfield': { let t = getindex(L, L1, pc); lua_getfield(L1, t, getstring(L, buff, pc)); break; } - case "getglobal": { + case 'getglobal': { lua_getglobal(L1, getstring(L, buff, pc)); break; } - case "getmetatable": { + case 'getmetatable': { if (lua_getmetatable(L1, getindex(L, L1, pc)) === 0) lua_pushnil(L1); break; } - case "gettable": { + case 'gettable': { lua_gettable(L1, getindex(L, L1, pc)); break; } - case "gettop": { + case 'gettop': { lua_pushinteger(L1, lua_gettop(L1)); break; } - case "gsub": { + case 'gsub': { let a = getnum(L, L1, pc); let b = getnum(L, L1, pc); let c = getnum(L, L1, pc); luaL_gsub(L1, lua_tostring(L1, a), lua_tostring(L1, b), lua_tostring(L1, c)); break; } - case "insert": { + case 'insert': { lua_insert(L1, getnum(L, L1, pc)); break; } - case "iscfunction": { + case 'iscfunction': { lua_pushboolean(L1, lua_iscfunction(L1, getindex(L, L1, pc))); break; } - case "isfunction": { + case 'isfunction': { lua_pushboolean(L1, lua_isfunction(L1, getindex(L, L1, pc))); break; } - case "isnil": { + case 'isnil': { lua_pushboolean(L1, lua_isnil(L1, getindex(L, L1, pc))); break; } - case "isnull": { + case 'isnull': { lua_pushboolean(L1, lua_isnone(L1, getindex(L, L1, pc))); break; } - case "isnumber": { + case 'isnumber': { lua_pushboolean(L1, lua_isnumber(L1, getindex(L, L1, pc))); break; } - case "isstring": { + case 'isstring': { lua_pushboolean(L1, lua_isstring(L1, getindex(L, L1, pc))); break; } - case "istable": { + case 'istable': { lua_pushboolean(L1, lua_istable(L1, getindex(L, L1, pc))); break; } - case "isudataval": { + case 'isudataval': { lua_pushboolean(L1, lua_islightuserdata(L1, getindex(L, L1, pc))); break; } - case "isuserdata": { + case 'isuserdata': { lua_pushboolean(L1, lua_isuserdata(L1, getindex(L, L1, pc))); break; } - case "len": { + case 'len': { lua_len(L1, getindex(L, L1, pc)); break; } - case "Llen": { + case 'Llen': { lua_pushinteger(L1, luaL_len(L1, getindex(L, L1, pc))); break; } - case "loadfile": { + case 'loadfile': { luaL_loadfile(L1, luaL_checkstring(L1, getnum(L, L1, pc))); break; } - case "loadstring": { + case 'loadstring': { let s = luaL_checkstring(L1, getnum(L, L1, pc)); luaL_loadstring(L1, s); break; } - case "newmetatable": { + case 'newmetatable': { lua_pushboolean(L1, luaL_newmetatable(L1, getstring(L, buff, pc))); break; } - case "newtable": { + case 'newtable': { lua_newtable(L1); break; } - case "newthread": { + case 'newthread': { lua_newthread(L1); break; } - case "newuserdata": { + case 'newuserdata': { lua_newuserdata(L1, getnum(L, L1, pc)); break; } - case "next": { + case 'next': { lua_next(L1, -2); break; } - case "objsize": { + case 'objsize': { lua_pushinteger(L1, lua_rawlen(L1, getindex(L, L1, pc))); break; } - case "pcall": { + case 'pcall': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); status = lua_pcall(L1, narg, nres, getnum(L, L1, pc)); break; } - case "pcallk": { + case 'pcallk': { let narg = getnum(L, L1, pc); let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); status = lua_pcallk(L1, narg, nres, 0, i, Cfunck); break; } - case "pop": { + case 'pop': { lua_pop(L1, getnum(L, L1, pc)); break; } - case "print": { + case 'print': { let n = getnum(L, L1, pc); if (n !== 0) { console.log(`${luaL_tojsstring(L1, n, null)}\n`); @@ -306,71 +306,71 @@ const runJS = function(L, L1, pc) { else printstack(L1); break; } - case "pushbool": { + case 'pushbool': { lua_pushboolean(L1, getnum(L, L1, pc)); break; } - case "pushcclosure": { + case 'pushcclosure': { lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); break; } - case "pushint": { + case 'pushint': { lua_pushinteger(L1, getnum(L, L1, pc)); break; } - case "pushnil": { + case 'pushnil': { lua_pushnil(L1); break; } - case "pushnum": { + case 'pushnum': { lua_pushnumber(L1, getnum(L, L1, pc)); break; } - case "pushstatus": { + case 'pushstatus': { pushcode(L1, status); break; } - case "pushstring": { + case 'pushstring': { lua_pushstring(L1, getstring(L, buff, pc)); break; } - case "pushupvalueindex": { + case 'pushupvalueindex': { lua_pushinteger(L1, lua_upvalueindex(getnum(L, L1, pc))); break; } - case "pushvalue": { + case 'pushvalue': { lua_pushvalue(L1, getindex(L, L1, pc)); break; } - case "rawgeti": { + case 'rawgeti': { let t = getindex(L, L1, pc); lua_rawgeti(L1, t, getnum(L, L1, pc)); break; } - case "rawgetp": { + case 'rawgetp': { let t = getindex(L, L1, pc); lua_rawgetp(L1, t, getnum(L, L1, pc)); break; } - case "rawsetp": { + case 'rawsetp': { let t = getindex(L, L1, pc); lua_rawsetp(L1, t, getnum(L, L1, pc)); break; } - case "remove": { + case 'remove': { lua_remove(L1, getnum(L, L1, pc)); break; } - case "replace": { + case 'replace': { lua_replace(L1, getindex(L, L1, pc)); break; } - case "resume": { + case 'resume': { let i = getindex(L, L1, pc); status = lua_resume(lua_tothread(L1, i), L, getnum(L, L1, pc)); break; } - case "return": { + case 'return': { let n = getnum(L, L1, pc); if (L1 != L) { let i; @@ -379,84 +379,84 @@ const runJS = function(L, L1, pc) { } return n; } - case "rotate": { + case 'rotate': { let i = getindex(L, L1, pc); lua_rotate(L1, i, getnum(L, L1, pc)); break; } - case "setfield": { + case 'setfield': { let t = getindex(L, L1, pc); lua_setfield(L1, t, getstring(L, buff, pc)); break; } - case "setglobal": { + case 'setglobal': { lua_setglobal(L1, getstring(L, buff, pc)); break; } - case "sethook": { + case 'sethook': { let mask = getnum(L, L1, pc); let count = getnum(L, L1, pc); sethookaux(L1, mask, count, getstring(L, buff, pc)); break; } - case "setmetatable": { + case 'setmetatable': { lua_setmetatable(L1, getindex(L, L1, pc)); break; } - case "settable": { + case 'settable': { lua_settable(L1, getindex(L, L1, pc)); break; } - case "settop": { + case 'settop': { lua_settop(L1, getnum(L, L1, pc)); break; } - case "testudata": { + case 'testudata': { let i = getindex(L, L1, pc); lua_pushboolean(L1, luaL_testudata(L1, i, getstring(L, buff, pc)) !== null); break; } - case "error": { + case 'error': { lua_error(L1); break; } - case "throw": { + case 'throw': { throw new Error(); } - case "tobool": { + case 'tobool': { lua_pushboolean(L1, lua_toboolean(L1, getindex(L, L1, pc))); break; } - case "tocfunction": { + case 'tocfunction': { lua_pushcfunction(L1, lua_tocfunction(L1, getindex(L, L1, pc))); break; } - case "tointeger": { + case 'tointeger': { lua_pushinteger(L1, lua_tointeger(L1, getindex(L, L1, pc))); break; } - case "tonumber": { + case 'tonumber': { lua_pushnumber(L1, lua_tonumber(L1, getindex(L, L1, pc))); break; } - case "topointer": { + case 'topointer': { let p = lua_topointer(L1, getindex(L, L1, pc)); if (p === null) p = 0; else if (p.id) p = p.id; lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */ break; } - case "tostring": { + case 'tostring': { let s = lua_tostring(L1, getindex(L, L1, pc)); let s1 = lua_pushstring(L1, s); assert(luastring_eq(s, s1)); break; } - case "type": { + case 'type': { lua_pushstring(L1, luaL_typename(L1, getnum(L, L1, pc))); break; } - case "xmove": { + case 'xmove': { let f = getindex(L, L1, pc); let t = getindex(L, L1, pc); let fs = (f === 0) ? L1 : lua_tothread(L1, f); @@ -466,16 +466,16 @@ const runJS = function(L, L1, pc) { lua_xmove(fs, ts, n); break; } - case "yield": { + case 'yield': { return lua_yield(L1, getnum(L, L1, pc)); } - case "yieldk": { + case 'yieldk': { let nres = getnum(L, L1, pc); let i = getindex(L, L1, pc); return lua_yieldk(L1, nres, i, Cfunck); } default: - luaL_error(L, to_luastring("unknown instruction %s"), buff); + luaL_error(L, to_luastring('unknown instruction %s'), buff); } } }; @@ -552,36 +552,36 @@ const newstate = function(L) { const getstate = function(L) { let L1 = lua_touserdata(L, 1); - luaL_argcheck(L, L1 !== null, 1, "state expected"); + luaL_argcheck(L, L1 !== null, 1, 'state expected'); return L1; }; -import { luaopen_base } from "../../src/lbaselib.js"; -import { luaopen_coroutine } from "../../src/lcorolib.js"; -import { luaopen_debug } from "../../src/ldblib.js"; -import { luaopen_io } from "../../src/liolib.js"; -import { luaopen_os } from "../../src/loslib.js"; -import { luaopen_math } from "../../src/lmathlib.js"; -import { luaopen_string } from "../../src/lstrlib.js"; -import { luaopen_table } from "../../src/ltablib.js"; -import { luaopen_package } from "../../src/loadlib.js"; +import { luaopen_base } from '../../src/lbaselib.js'; +import { luaopen_coroutine } from '../../src/lcorolib.js'; +import { luaopen_debug } from '../../src/ldblib.js'; +import { luaopen_io } from '../../src/liolib.js'; +import { luaopen_os } from '../../src/loslib.js'; +import { luaopen_math } from '../../src/lmathlib.js'; +import { luaopen_string } from '../../src/lstrlib.js'; +import { luaopen_table } from '../../src/ltablib.js'; +import { luaopen_package } from '../../src/loadlib.js'; const loadlib = function(L) { let libs = { - "_G": luaopen_base, - "coroutine": luaopen_coroutine, - "debug": luaopen_debug, - "io": luaopen_io, - "os": luaopen_os, - "math": luaopen_math, - "string": luaopen_string, - "table": luaopen_table + '_G': luaopen_base, + 'coroutine': luaopen_coroutine, + 'debug': luaopen_debug, + 'io': luaopen_io, + 'os': luaopen_os, + 'math': luaopen_math, + 'string': luaopen_string, + 'table': luaopen_table }; let L1 = getstate(L); - luaL_requiref(L1, to_luastring("package", true), luaopen_package, 0); + luaL_requiref(L1, to_luastring('package', true), luaopen_package, 0); assert(lua_type(L1, -1) == LUA_TTABLE); /* 'requiref' should not reload module already loaded... */ - luaL_requiref(L1, to_luastring("package", true), null, 1); /* seg. fault if it reloads */ + luaL_requiref(L1, to_luastring('package', true), null, 1); /* seg. fault if it reloads */ /* ...but should return the same module */ assert(lua_compare(L1, -1, -2, LUA_OPEQ)); luaL_getsubtable(L1, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); @@ -637,8 +637,8 @@ const newuserdata = function(L) { */ const Chook = function(L, ar) { let scpt; - let events = ["call", "ret", "line", "count", "tailcall"].map(e => to_luastring(e)); - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); + let events = ['call', 'ret', 'line', 'count', 'tailcall'].map(e => to_luastring(e)); + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); lua_pushlightuserdata(L, L); lua_gettable(L, -2); /* get C_HOOK[L] (script saved by sethookaux) */ scpt = lua_tostring(L, -1); /* not very religious (string will be popped) */ @@ -661,7 +661,7 @@ class Aux { const panicback = function(L) { let b = new Aux(); lua_checkstack(L, 1); /* open space for 'Aux' struct */ - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* get 'Aux' struct */ + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('_jmpbuf', true)); /* get 'Aux' struct */ b = lua_touserdata(L, -1); lua_pop(L, 1); /* remove 'Aux' struct */ runJS(b.L, L, { script: b.paniccode, offset: 0 }); /* run optional panic code */ @@ -671,7 +671,7 @@ const panicback = function(L) { const checkpanic = function(L) { let b = new Aux(); let code = luaL_checkstring(L, 1); - b.paniccode = luaL_optstring(L, 2, ""); + b.paniccode = luaL_optstring(L, 2, ''); b.L = L; let L1 = lua_newstate(); /* create new state */ if (L1 === null) { /* error? */ @@ -680,10 +680,10 @@ const checkpanic = function(L) { } lua_atpanic(L1, panicback); /* set its panic function */ lua_pushlightuserdata(L1, b); - lua_setfield(L1, LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* store 'Aux' struct */ + lua_setfield(L1, LUA_REGISTRYINDEX, to_luastring('_jmpbuf', true)); /* store 'Aux' struct */ try { /* set jump buffer */ runJS(L, L1, { script: code, offset: 0 }); /* run code unprotected */ - lua_pushliteral(L, "no errors"); + lua_pushliteral(L, 'no errors'); } catch (e) { /* error handling */ /* move error message to original state */ lua_pushstring(L, lua_tostring(L1, -1)); @@ -700,12 +700,12 @@ const sethookaux = function(L, mask, count, scpt) { lua_sethook(L, null, 0, 0); /* turn off hooks */ return; } - lua_getfield(L, LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* get C_HOOK table */ + lua_getfield(L, LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); /* get C_HOOK table */ if (!lua_istable(L, -1)) { /* no hook table? */ lua_pop(L, 1); /* remove previous value */ lua_newtable(L); /* create new C_HOOK table */ lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* register it */ + lua_setfield(L, LUA_REGISTRYINDEX, to_luastring('JS_HOOK', true)); /* register it */ } lua_pushlightuserdata(L, L); lua_pushstring(L, scpt); @@ -736,9 +736,9 @@ const Cfunc = function(L) { const Cfunck = function(L, status, ctx) { pushcode(L, status); - lua_setglobal(L, to_luastring("status", true)); + lua_setglobal(L, to_luastring('status', true)); lua_pushinteger(L, ctx); - lua_setglobal(L, to_luastring("ctx", true)); + lua_setglobal(L, to_luastring('ctx', true)); return runJS(L, L, { script: lua_tostring(L, ctx), offset: 0 }); }; @@ -751,7 +751,7 @@ const makeCfunc = function(L) { const coresume = function(L) { let status; let co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "coroutine expected"); + luaL_argcheck(L, co, 1, 'coroutine expected'); status = lua_resume(co, L, 0); if (status != LUA_OK && status !== LUA_YIELD) { lua_pushboolean(L, 0); @@ -776,7 +776,7 @@ const setnameval = function(L, name, val) { const pushobject = function(L, o){ pushobj2s(L, o); - assert(L.top <= L.ci.top, "stack overflow"); + assert(L.top <= L.ci.top, 'stack overflow'); }; const buildop = function(p, pc) { @@ -784,19 +784,19 @@ const buildop = function(p, pc) { let o = GET_OPCODE(i); let name = OpCodes[o]; let line = p.lineinfo.length !== 0 ? p.lineinfo[pc] : -1; - let result = sprintf("(%4d) %4d - ", line, pc); //`(${line}) ${pc} - `; + let result = sprintf('(%4d) %4d - ', line, pc); //`(${line}) ${pc} - `; switch (getOpMode(o)) { case iABC: - result += sprintf("%-12s%4d %4d %4d", name, GETARG_A(i), GETARG_B(i), GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; + result += sprintf('%-12s%4d %4d %4d', name, GETARG_A(i), GETARG_B(i), GETARG_C(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_B(i)} ${lopcodes.GETARG_C(i)}`; break; case iABx: - result += sprintf("%-12s%4d %4d", name, GETARG_A(i), GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; + result += sprintf('%-12s%4d %4d', name, GETARG_A(i), GETARG_Bx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_Bx(i)}`; break; case iAsBx: - result += sprintf("%-12s%4d %4d", name, GETARG_A(i), GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; + result += sprintf('%-12s%4d %4d', name, GETARG_A(i), GETARG_sBx(i)); // `${name} ${lopcodes.GETARG_A(i)} ${lopcodes.GETARG_sBx(i)}`; break; case iAx: - result += sprintf("%-12s%4d", name, GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; + result += sprintf('%-12s%4d', name, GETARG_Ax(i)); // `${name} ${lopcodes.GETARG_Ax(i)}`; break; } @@ -805,11 +805,11 @@ const buildop = function(p, pc) { const listcode = function(L) { luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), - 1, "Lua function expected"); + 1, 'Lua function expected'); let p = obj_at(L, 1); lua_newtable(L); - setnameval(L, to_luastring("maxstack", true), p.maxstacksize); - setnameval(L, to_luastring("numparams", true), p.numparams); + setnameval(L, to_luastring('maxstack', true), p.maxstacksize); + setnameval(L, to_luastring('numparams', true), p.numparams); for (let pc = 0; pc < p.code.length; pc++) { lua_pushinteger(L, pc+1); lua_pushstring(L, buildop(p, pc)); @@ -821,7 +821,7 @@ const listcode = function(L) { const listk = function(L) { luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), - 1, "Lua function expected"); + 1, 'Lua function expected'); let p = obj_at(L, 1); lua_createtable(L, p.k.length, 0); for (let i = 0; i < p.k.length; i++) { @@ -832,24 +832,24 @@ const listk = function(L) { }; const tests_funcs = { - "checkpanic": checkpanic, - "closestate": closestate, - "d2s": d2s, - "doremote": doremote, - "listcode": listcode, - "listk": listk, - "loadlib": loadlib, - "makeCfunc": makeCfunc, - "newstate": newstate, - "newuserdata": newuserdata, - "pushuserdata": pushuserdata, - "resume": coresume, - "s2d": s2d, - "sethook": sethook, - "testC": testJS, - "testJS": testJS, - "udataval": udataval, - "upvalue": upvalue + 'checkpanic': checkpanic, + 'closestate': closestate, + 'd2s': d2s, + 'doremote': doremote, + 'listcode': listcode, + 'listk': listk, + 'loadlib': loadlib, + 'makeCfunc': makeCfunc, + 'newstate': newstate, + 'newuserdata': newuserdata, + 'pushuserdata': pushuserdata, + 'resume': coresume, + 's2d': s2d, + 'sethook': sethook, + 'testC': testJS, + 'testJS': testJS, + 'udataval': udataval, + 'upvalue': upvalue }; const luaB_opentests = function(L) { @@ -858,10 +858,7 @@ const luaB_opentests = function(L) { return 1; }; -const luaopen_tests = function(L) { - luaL_requiref(L, to_luastring("T"), luaB_opentests, 1); +export const luaopen_tests = function(L) { + luaL_requiref(L, to_luastring('T'), luaB_opentests, 1); lua_pop(L, 1); /* remove lib */ }; - -const _luaopen_tests = luaopen_tests; -export { _luaopen_tests as luaopen_tests }; diff --git a/test/test-suite/math.test.js b/test/test-suite/math.test.js index d1035d92..07cfacb1 100644 --- a/test/test-suite/math.test.js +++ b/test/test-suite/math.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` local minint = math.mininteger @@ -52,9 +52,9 @@ const prefix = ` end `; -test("[test-suite] math: int bits", () => { +test('[test-suite] math: int bits', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -67,9 +67,9 @@ test("[test-suite] math: int bits", () => { }); -test("[test-suite] math: number of bits in the mantissa of a floating-point number", () => { +test('[test-suite] math: number of bits in the mantissa of a floating-point number', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(isNaN(0/0)) @@ -94,9 +94,9 @@ test("[test-suite] math: number of bits in the mantissa of a floating-point numb }); -test("[test-suite] math: basic float notation", () => { +test('[test-suite] math: basic float notation', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(0e12 == 0 and .0 == 0 and 0. == 0 and .2e2 == 20 and 2.E-1 == 0.2) @@ -146,9 +146,9 @@ test("[test-suite] math: basic float notation", () => { }); -test("[test-suite] math: math.huge", () => { +test('[test-suite] math: math.huge', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(math.huge > 10e30) @@ -161,9 +161,9 @@ test("[test-suite] math: math.huge", () => { }); -test("[test-suite] math: integer arithmetic", () => { +test('[test-suite] math: integer arithmetic', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint < minint + 1) @@ -179,9 +179,9 @@ test("[test-suite] math: integer arithmetic", () => { }); -test("[test-suite] math: testing floor division and conversions", () => { +test('[test-suite] math: testing floor division and conversions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for _, i in pairs{-16, -15, -3, -2, -1, 0, 1, 2, 3, 15} do @@ -222,9 +222,9 @@ test("[test-suite] math: testing floor division and conversions", () => { }); -test("[test-suite] math: negative exponents", () => { +test('[test-suite] math: negative exponents', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -247,9 +247,9 @@ test("[test-suite] math: negative exponents", () => { }); -test("[test-suite] math: comparison between floats and integers (border cases)", () => { +test('[test-suite] math: comparison between floats and integers (border cases)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if floatbits < intbits then @@ -275,9 +275,9 @@ test("[test-suite] math: comparison between floats and integers (border cases)", }); -test("[test-suite] math: order between floats and integers", () => { +test('[test-suite] math: order between floats and integers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -312,9 +312,9 @@ test("[test-suite] math: order between floats and integers", () => { }); -test("[test-suite] math: testing order (floats can represent all integers)", () => { +test('[test-suite] math: testing order (floats can represent all integers)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(floatbits >= intbits) @@ -354,9 +354,9 @@ test("[test-suite] math: testing order (floats can represent all integers)", () }); -test("[test-suite] math: NaN order", () => { +test('[test-suite] math: NaN order', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local NaN = 0/0 @@ -375,9 +375,9 @@ test("[test-suite] math: NaN order", () => { }); -test("[test-suite] math: avoiding errors at compile time", () => { +test('[test-suite] math: avoiding errors at compile time', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkcompt("divide by zero", "return 2 // 0") @@ -393,9 +393,9 @@ test("[test-suite] math: avoiding errors at compile time", () => { lua_call(L, 0, 0); }); -test("[test-suite] math: testing overflow errors when converting from float to integer (runtime)", () => { +test('[test-suite] math: testing overflow errors when converting from float to integer (runtime)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f2i (x) return x | x end @@ -435,9 +435,9 @@ test("[test-suite] math: testing overflow errors when converting from float to i }); -test("[test-suite] math: testing numeric strings", () => { +test('[test-suite] math: testing numeric strings', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("2" + 1 == 3) @@ -452,9 +452,9 @@ test("[test-suite] math: testing numeric strings", () => { }); -test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () => { +test('[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -498,9 +498,9 @@ test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () }); -test("[test-suite] math: 'tonumber' with numbers", () => { +test('[test-suite] math: \'tonumber\' with numbers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber(3.4) == 3.4) @@ -515,9 +515,9 @@ test("[test-suite] math: 'tonumber' with numbers", () => { }); -test("[test-suite] math: 'tonumber' with strings", () => { +test('[test-suite] math: \'tonumber\' with strings', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber("0") == 0) @@ -565,9 +565,9 @@ test("[test-suite] math: 'tonumber' with strings", () => { }); -test("[test-suite] math: tests with very long numerals", () => { +test('[test-suite] math: tests with very long numerals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber("0x"..string.rep("f", 13)..".0") == 2.0^(4*13) - 1) @@ -591,9 +591,9 @@ test("[test-suite] math: tests with very long numerals", () => { }); -test("[test-suite] math: testing 'tonumber' for invalid formats", () => { +test('[test-suite] math: testing \'tonumber\' for invalid formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (...) @@ -635,9 +635,9 @@ test("[test-suite] math: testing 'tonumber' for invalid formats", () => { }); -test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () => { +test('[test-suite] math: testing \'tonumber\' for invalid hexadecimal formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber('0x') == nil) @@ -660,9 +660,9 @@ test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () }); -test("[test-suite] math: testing hexadecimal numerals", () => { +test('[test-suite] math: testing hexadecimal numerals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(0x10 == 16 and 0xfff == 2^12 - 1 and 0XFB == 251) @@ -682,9 +682,9 @@ test("[test-suite] math: testing hexadecimal numerals", () => { }); -test("[test-suite] math: floating hexas", () => { +test('[test-suite] math: floating hexas', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber(' 0x2.5 ') == 0x25/16) @@ -718,9 +718,9 @@ test("[test-suite] math: floating hexas", () => { }); -test("[test-suite] math: testing order operators", () => { +test('[test-suite] math: testing order operators', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not(1<1) and (1<2) and not(2<1)) @@ -740,9 +740,9 @@ test("[test-suite] math: testing order operators", () => { }); -test("[test-suite] math: testing mod operator", () => { +test('[test-suite] math: testing mod operator', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(eqT(-4 % 3, 2)) @@ -769,9 +769,9 @@ test("[test-suite] math: testing mod operator", () => { }); -test("[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly", () => { +test('[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function anan (x) assert(isNaN(x)) end -- assert Not a Number @@ -794,9 +794,9 @@ test("[test-suite] math: non-portable tests because Windows C library cannot com }); -test("[test-suite] math: testing unsigned comparisons", () => { +test('[test-suite] math: testing unsigned comparisons', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(math.ult(3, 4)) @@ -838,9 +838,9 @@ test("[test-suite] math: testing unsigned comparisons", () => { }); -test("[test-suite] math: testing constant limits", () => { +test('[test-suite] math: testing constant limits', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(8388609 + -8388609 == 0) @@ -854,9 +854,9 @@ test("[test-suite] math: testing constant limits", () => { }); -test("[test-suite] math: testing floor & ceil", () => { +test('[test-suite] math: testing floor & ceil', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -909,9 +909,9 @@ test("[test-suite] math: testing floor & ceil", () => { }); -test("[test-suite] math: testing fmod for integers", () => { +test('[test-suite] math: testing fmod for integers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = -6, 6 do @@ -941,9 +941,9 @@ test("[test-suite] math: testing fmod for integers", () => { }); -test("[test-suite] math: testing max/min", () => { +test('[test-suite] math: testing max/min', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -969,9 +969,9 @@ test("[test-suite] math: testing max/min", () => { }); -test("[test-suite] math: testing implicit convertions", () => { +test('[test-suite] math: testing implicit convertions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a,b = '10', '20' @@ -985,9 +985,9 @@ test("[test-suite] math: testing implicit convertions", () => { }); -test("[test-suite] math: testing -0 and NaN", () => { +test('[test-suite] math: testing -0 and NaN', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1031,9 +1031,9 @@ test("[test-suite] math: testing -0 and NaN", () => { }); -test("[test-suite] math: test random for floats", () => { +test('[test-suite] math: test random for floats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` math.randomseed(0) @@ -1062,9 +1062,9 @@ test("[test-suite] math: test random for floats", () => { }); -test("[test-suite] math: test random for small intervals", () => { +test('[test-suite] math: test random for small intervals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1106,9 +1106,9 @@ test("[test-suite] math: test random for small intervals", () => { }); -test("[test-suite] math: test random for large intervals", () => { +test('[test-suite] math: test random for large intervals', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1152,9 +1152,9 @@ test("[test-suite] math: test random for large intervals", () => { }); -test("[test-suite] math: test random for empty interval", () => { +test('[test-suite] math: test random for empty interval', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(math.random, minint + 1, minint)) @@ -1168,9 +1168,9 @@ test("[test-suite] math: test random for empty interval", () => { }); -test("[test-suite] math: interval too large", () => { +test('[test-suite] math: interval too large', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(math.random, minint, 0)) diff --git a/test/test-suite/nextvar.test.js b/test/test-suite/nextvar.test.js index f360959d..ad29b057 100644 --- a/test/test-suite/nextvar.test.js +++ b/test/test-suite/nextvar.test.js @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` local function checkerror (msg, f, ...) @@ -12,9 +12,9 @@ const prefix = ` end `; -test("[test-suite] nextvar: testing size operator", () => { +test('[test-suite] nextvar: testing size operator', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -35,9 +35,9 @@ test("[test-suite] nextvar: testing size operator", () => { }); -test("[test-suite] nextvar: testing ipairs", () => { +test('[test-suite] nextvar: testing ipairs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = 0 @@ -55,9 +55,9 @@ test("[test-suite] nextvar: testing ipairs", () => { }); -test("[test-suite] nextvar: test for 'false' x ipair", () => { +test('[test-suite] nextvar: test for \'false\' x ipair', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` x = false @@ -76,9 +76,9 @@ test("[test-suite] nextvar: test for 'false' x ipair", () => { }); -test("[test-suite] nextvar: iterator function is always the same", () => { +test('[test-suite] nextvar: iterator function is always the same', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{}) @@ -90,9 +90,9 @@ test("[test-suite] nextvar: iterator function is always the same", () => { }); -test.skip("[test-suite] nextvar: JS tests", () => { +test.skip('[test-suite] nextvar: JS tests', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- testing table sizes @@ -232,9 +232,9 @@ test.skip("[test-suite] nextvar: JS tests", () => { }); -test("[test-suite] nextvar: test size operation on empty tables", () => { +test('[test-suite] nextvar: test size operation on empty tables', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -250,9 +250,9 @@ test("[test-suite] nextvar: test size operation on empty tables", () => { }); -test("[test-suite] nextvar: test size operation on empty tables", () => { +test('[test-suite] nextvar: test size operation on empty tables', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -268,9 +268,9 @@ test("[test-suite] nextvar: test size operation on empty tables", () => { }); -test("[test-suite] nextvar: next uses always the same iteration function", () => { +test('[test-suite] nextvar: next uses always the same iteration function', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local nofind = {} @@ -317,9 +317,9 @@ test("[test-suite] nextvar: next uses always the same iteration function", () => }); -test("[test-suite] nextvar: invalid key to 'next'", () => { +test('[test-suite] nextvar: invalid key to \'next\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("invalid key", next, {10,20}, 3) @@ -331,9 +331,9 @@ test("[test-suite] nextvar: invalid key to 'next'", () => { }); -test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => { +test('[test-suite] nextvar: both \'pairs\' and \'ipairs\' need an argument', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("bad argument", pairs) @@ -346,9 +346,9 @@ test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => { }); -test("[test-suite] nextvar: fmod table", () => { +test('[test-suite] nextvar: fmod table', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -373,9 +373,9 @@ test("[test-suite] nextvar: fmod table", () => { }); -test("[test-suite] nextvar: check next", () => { +test('[test-suite] nextvar: check next', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checknext (a) @@ -398,9 +398,9 @@ test("[test-suite] nextvar: check next", () => { }); -test("[test-suite] nextvar: # operator", () => { +test('[test-suite] nextvar: # operator', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -419,9 +419,9 @@ test("[test-suite] nextvar: # operator", () => { }); -test("[test-suite] nextvar: maxn", () => { +test('[test-suite] nextvar: maxn', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- 'maxn' is now deprecated, but it is easily defined in Lua @@ -448,9 +448,9 @@ test("[test-suite] nextvar: maxn", () => { }); -test("[test-suite] nextvar: int overflow", () => { +test('[test-suite] nextvar: int overflow', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -464,9 +464,9 @@ test("[test-suite] nextvar: int overflow", () => { }); -test("[test-suite] nextvar: erasing values", () => { +test('[test-suite] nextvar: erasing values', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[{1}] = 1, [{2}] = 2, [string.rep("x ", 4)] = 3, @@ -549,9 +549,9 @@ test("[test-suite] nextvar: erasing values", () => { }); -test("[test-suite] nextvar: testing table library with metamethods", () => { +test('[test-suite] nextvar: testing table library with metamethods', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -607,9 +607,9 @@ test("[test-suite] nextvar: testing table library with metamethods", () => { }); -test.skip("[test-suite] nextvar: JS tests", () => { +test.skip('[test-suite] nextvar: JS tests', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local tab = {10, 20, 30} @@ -648,9 +648,9 @@ test.skip("[test-suite] nextvar: JS tests", () => { }); -test("[test-suite] nextvar: next", () => { +test('[test-suite] nextvar: next', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -675,9 +675,9 @@ test("[test-suite] nextvar: next", () => { }); -test("[test-suite] nextvar: testing floats in numeric for", () => { +test('[test-suite] nextvar: testing floats in numeric for', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -706,9 +706,9 @@ test("[test-suite] nextvar: testing floats in numeric for", () => { }); -test("[test-suite] nextvar: conversion", () => { +test('[test-suite] nextvar: conversion', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5) @@ -720,9 +720,9 @@ test("[test-suite] nextvar: conversion", () => { }); -test("[test-suite] nextvar: checking types", () => { +test('[test-suite] nextvar: checking types', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -786,9 +786,9 @@ test("[test-suite] nextvar: checking types", () => { }); -test("[test-suite] nextvar: testing generic 'for'", () => { +test('[test-suite] nextvar: testing generic \'for\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (n, p) @@ -815,9 +815,9 @@ test("[test-suite] nextvar: testing generic 'for'", () => { }); -test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { +test('[test-suite] nextvar: testing __pairs and __ipairs metamethod', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -855,9 +855,9 @@ test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => { }); -test("[test-suite] nextvar: testing ipairs with metamethods", () => { +test('[test-suite] nextvar: testing ipairs with metamethods', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {n=10} diff --git a/test/test-suite/pm.test.js b/test/test-suite/pm.test.js index 47140d48..32f3a34c 100644 --- a/test/test-suite/pm.test.js +++ b/test/test-suite/pm.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring, luaL_loadfile } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; -test("[test-suite] pm: pattern matching", () => { +test('[test-suite] pm: pattern matching', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(s, p) @@ -92,9 +92,9 @@ test("[test-suite] pm: pattern matching", () => { }); -test("[test-suite] pm: tonumber", () => { +test('[test-suite] pm: tonumber', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f1(s, p) @@ -119,9 +119,9 @@ test("[test-suite] pm: tonumber", () => { }); -test("[test-suite] pm: range", () => { +test('[test-suite] pm: range', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function range (i, j) @@ -160,32 +160,32 @@ test("[test-suite] pm: range", () => { // Can't be represented by JS string, testing from actual lua file -test("[test-suite] pm: classes", () => { +test('[test-suite] pm: classes', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); luaL_openlibs(L); - if (luaL_loadfile(L, to_luastring("test/test-suite/pm-classes.lua")) === LUA_ERRSYNTAX) + if (luaL_loadfile(L, to_luastring('test/test-suite/pm-classes.lua')) === LUA_ERRSYNTAX) throw new SyntaxError(lua_tojsstring(L, -1)); lua_call(L, 0, 0); }); // Can't be represented by JS string, testing from actual lua file -test("[test-suite] pm: gsub", () => { +test('[test-suite] pm: gsub', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); luaL_openlibs(L); - if (luaL_loadfile(L, to_luastring("test/test-suite/pm-gsub.lua")) === LUA_ERRSYNTAX) + if (luaL_loadfile(L, to_luastring('test/test-suite/pm-gsub.lua')) === LUA_ERRSYNTAX) throw new SyntaxError(lua_tojsstring(L, -1)); lua_call(L, 0, 0); }); -test("[test-suite] pm: empty matches", () => { +test('[test-suite] pm: empty matches', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- new (5.3.3) semantics for empty matches @@ -208,9 +208,9 @@ test("[test-suite] pm: empty matches", () => { }); -test("[test-suite] pm: gsub", () => { +test('[test-suite] pm: gsub', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("um (dois) tres (quatro)", "(%(%w+%))", string.upper) == @@ -250,9 +250,9 @@ test("[test-suite] pm: gsub", () => { }); -test("[test-suite] pm: gsub isbalanced", () => { +test('[test-suite] pm: gsub isbalanced', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function isbalanced (s) @@ -270,9 +270,9 @@ test("[test-suite] pm: gsub isbalanced", () => { }); -test("[test-suite] pm: capture", () => { +test('[test-suite] pm: capture', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkerror (msg, f, ...) @@ -307,9 +307,9 @@ test("[test-suite] pm: capture", () => { }); -test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { +test('[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -332,9 +332,9 @@ test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => { }); -test("[test-suite] pm: big strings (TODO: _soft)", () => { +test('[test-suite] pm: big strings (TODO: _soft)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true -- TODO @@ -357,9 +357,9 @@ test("[test-suite] pm: big strings (TODO: _soft)", () => { }); -test("[test-suite] pm: recursive nest of gsubs", () => { +test('[test-suite] pm: recursive nest of gsubs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function rev (s) @@ -376,9 +376,9 @@ test("[test-suite] pm: recursive nest of gsubs", () => { }); -test("[test-suite] pm: gsub with tables", () => { +test('[test-suite] pm: gsub with tables', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("alo alo", ".", {}) == "alo alo") @@ -398,9 +398,9 @@ test("[test-suite] pm: gsub with tables", () => { }); -test("[test-suite] pm: gmatch", () => { +test('[test-suite] pm: gmatch', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 0 @@ -434,9 +434,9 @@ test("[test-suite] pm: gmatch", () => { }); -test("[test-suite] pm: tests for '%f' ('frontiers')", () => { +test('[test-suite] pm: tests for \'%f\' (\'frontiers\')', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") @@ -472,9 +472,9 @@ test("[test-suite] pm: tests for '%f' ('frontiers')", () => { }); -test("[test-suite] pm: malformed patterns", () => { +test('[test-suite] pm: malformed patterns', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function malform (p, m) @@ -502,9 +502,9 @@ test("[test-suite] pm: malformed patterns", () => { }); -test("[test-suite] pm: \\0 in patterns", () => { +test('[test-suite] pm: \\0 in patterns', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.match("ab\\0\\1\\2c", "[\\0-\\2]+") == "\\0\\1\\2") @@ -522,9 +522,9 @@ test("[test-suite] pm: \\0 in patterns", () => { }); -test("[test-suite] pm: magic char after \\0", () => { +test('[test-suite] pm: magic char after \\0', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.find("abc\\0\\0","\\0.") == 4) diff --git a/test/test-suite/sort.test.js b/test/test-suite/sort.test.js index 38816a0b..3f186b22 100644 --- a/test/test-suite/sort.test.js +++ b/test/test-suite/sort.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` local unpack = table.unpack @@ -28,9 +28,9 @@ const prefix = ` if _soft then limit = 5000 end `; -test("[test-suite] sort: testing unpack", () => { +test('[test-suite] sort: testing unpack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("wrong number of arguments", table.insert, {}, 2, 3, 4) @@ -65,9 +65,9 @@ test("[test-suite] sort: testing unpack", () => { }); -test("[test-suite] sort: testing unpack", () => { +test('[test-suite] sort: testing unpack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -105,9 +105,9 @@ test("[test-suite] sort: testing unpack", () => { }); -test("[test-suite] sort: testing unpack", () => { +test('[test-suite] sort: testing unpack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- length is not an integer @@ -123,9 +123,9 @@ test("[test-suite] sort: testing unpack", () => { }); -test("[test-suite] sort: testing pack", () => { +test('[test-suite] sort: testing pack', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = table.pack() @@ -144,9 +144,9 @@ test("[test-suite] sort: testing pack", () => { }); -test("[test-suite] sort: testing move", () => { +test('[test-suite] sort: testing move', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -227,9 +227,9 @@ test("[test-suite] sort: testing move", () => { }); -test("[test-suite] sort: testing long move", () => { +test('[test-suite] sort: testing long move', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -266,9 +266,9 @@ test("[test-suite] sort: testing long move", () => { }); -test("[test-suite] sort: testing sort, strange lengths", () => { +test('[test-suite] sort: testing sort, strange lengths', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = setmetatable({}, {__len = function () return -1 end}) @@ -284,9 +284,9 @@ test("[test-suite] sort: testing sort, strange lengths", () => { }); -test("[test-suite] sort: test checks for invalid order functions", () => { +test('[test-suite] sort: test checks for invalid order functions', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function check (t) @@ -305,9 +305,9 @@ test("[test-suite] sort: test checks for invalid order functions", () => { }); -test("[test-suite] sort: sort alpha", () => { +test('[test-suite] sort: sort alpha', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -330,9 +330,9 @@ test("[test-suite] sort: sort alpha", () => { }); -test("[test-suite] sort: sort perm", () => { +test('[test-suite] sort: sort perm', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -375,9 +375,9 @@ test("[test-suite] sort: sort perm", () => { }); -test("[test-suite] sort: Invert-sorting", () => { +test('[test-suite] sort: Invert-sorting', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -413,9 +413,9 @@ test("[test-suite] sort: Invert-sorting", () => { }); -test("[test-suite] sort: sorting", () => { +test('[test-suite] sort: sorting', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) diff --git a/test/test-suite/strings.test.js b/test/test-suite/strings.test.js index 10fe6f7b..19918413 100644 --- a/test/test-suite/strings.test.js +++ b/test/test-suite/strings.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const checkerror = ` local maxi, mini = math.maxinteger, math.mininteger @@ -14,7 +14,7 @@ const checkerror = ` test('[test-suite] strings: string comparisons', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('alo' < 'alo1') @@ -44,7 +44,7 @@ test('[test-suite] strings: string comparisons', () => { test('[test-suite] strings: string.sub', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('alo' < 'alo1') @@ -74,7 +74,7 @@ test('[test-suite] strings: string.sub', () => { test('[test-suite] strings: string.find', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.find("123456789", "345") == 3) @@ -100,7 +100,7 @@ test('[test-suite] strings: string.find', () => { test('[test-suite] strings: string.len and #', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.len("") == 0) @@ -120,7 +120,7 @@ test('[test-suite] strings: string.len and #', () => { test('[test-suite] strings: string.byte/string.char', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.byte("a") == 97) @@ -165,7 +165,7 @@ test('[test-suite] strings: string.byte/string.char', () => { test('[test-suite] strings: repetitions with separator', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.rep('teste', 0, 'xuxu') == '') @@ -190,7 +190,7 @@ test('[test-suite] strings: repetitions with separator', () => { test('[test-suite] strings: tostring', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(tostring(nil)) == 'string') @@ -230,7 +230,7 @@ test('[test-suite] strings: tostring', () => { test('[test-suite] strings: string.format', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` x = '"ílo"\\n\\\\' @@ -265,7 +265,7 @@ test('[test-suite] strings: string.format', () => { test('[test-suite] strings: %q', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -294,7 +294,7 @@ test('[test-suite] strings: %q', () => { test('[test-suite] strings: embedded zeros error', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.format("\\0%s\\0", "\\0\\0\\1") == "\\0\\0\\0\\1\\0") @@ -309,7 +309,7 @@ test('[test-suite] strings: embedded zeros error', () => { test('[test-suite] strings: format x tostring', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.format("%s %s", nil, true) == "nil true") @@ -340,7 +340,7 @@ test('[test-suite] strings: format x tostring', () => { test('[test-suite] strings: longest number that can be formatted', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -365,7 +365,7 @@ test('[test-suite] strings: longest number that can be formatted', () => { test('[test-suite] strings: large numbers for format', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- assume at least 32 bits @@ -400,9 +400,9 @@ test('[test-suite] strings: large numbers for format', () => { }); -test("[test-suite] strings: 'format %a %A'", () => { +test('[test-suite] strings: \'format %a %A\'', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -445,9 +445,9 @@ test("[test-suite] strings: 'format %a %A'", () => { }); -test("[test-suite] strings: errors in format", () => { +test('[test-suite] strings: errors in format', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function check (fmt, msg) @@ -473,9 +473,9 @@ test("[test-suite] strings: errors in format", () => { }); -test("[test-suite] strings: table.concat", () => { +test('[test-suite] strings: table.concat', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("table expected", table.concat, 3) @@ -513,9 +513,9 @@ test("[test-suite] strings: table.concat", () => { // TODO: os.setlocale NYI -test.skip("[test-suite] strings: locale", () => { +test.skip('[test-suite] strings: locale', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if not _port then @@ -556,9 +556,9 @@ test.skip("[test-suite] strings: locale", () => { }); -test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", () => { +test('[test-suite] strings: bug in Lua 5.3.2: \'gmatch\' iterator does not work across coroutines', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/tpack.test.js b/test/test-suite/tpack.test.js index 422228fb..4d316be7 100644 --- a/test/test-suite/tpack.test.js +++ b/test/test-suite/tpack.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` local pack = string.pack @@ -28,9 +28,9 @@ const prefix = ` local align = packsize("!xXi16") `; -test("[test-suite] tpack: maximum size for integers", () => { +test('[test-suite] tpack: maximum size for integers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and @@ -52,9 +52,9 @@ test("[test-suite] tpack: maximum size for integers", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(unpack("B", pack("B", 0xff)) == 0xff) @@ -76,9 +76,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, NB do @@ -103,9 +103,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -136,9 +136,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: minimum behavior for integer formats", () => { +test('[test-suite] tpack: minimum behavior for integer formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, sizeLI do @@ -158,9 +158,9 @@ test("[test-suite] tpack: minimum behavior for integer formats", () => { }); -test("[test-suite] tpack: sign extension", () => { +test('[test-suite] tpack: sign extension', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -179,9 +179,9 @@ test("[test-suite] tpack: sign extension", () => { }); -test("[test-suite] tpack: mixed endianness", () => { +test('[test-suite] tpack: mixed endianness', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -198,9 +198,9 @@ test("[test-suite] tpack: mixed endianness", () => { }); -test("[test-suite] tpack: testing invalid formats", () => { +test('[test-suite] tpack: testing invalid formats', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("out of limits", pack, "i0", 0) @@ -221,9 +221,9 @@ test("[test-suite] tpack: testing invalid formats", () => { }); -test("[test-suite] tpack: overflow in option size (error will be in digit after limit)", () => { +test('[test-suite] tpack: overflow in option size (error will be in digit after limit)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("invalid format", packsize, "c1" .. string.rep("0", 40)) @@ -244,9 +244,9 @@ test("[test-suite] tpack: overflow in option size (error will be in digit after }); -test("[test-suite] tpack: overflow in packing", () => { +test('[test-suite] tpack: overflow in packing', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, sizeLI - 1 do @@ -273,9 +273,9 @@ test("[test-suite] tpack: overflow in packing", () => { }); -test("[test-suite] tpack: Lua integer size", () => { +test('[test-suite] tpack: Lua integer size', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(unpack(">j", pack(">j", math.maxinteger)) == math.maxinteger) @@ -295,9 +295,9 @@ test("[test-suite] tpack: Lua integer size", () => { }); -test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => { +test('[test-suite] tpack: testing pack/unpack of floating-point numbers', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do @@ -323,9 +323,9 @@ test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => }); -test("[test-suite] tpack: testing pack/unpack of strings", () => { +test('[test-suite] tpack: testing pack/unpack of strings', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -377,9 +377,9 @@ test("[test-suite] tpack: testing pack/unpack of strings", () => { }); -test("[test-suite] tpack: testing multiple types and sequence", () => { +test('[test-suite] tpack: testing multiple types and sequence', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -397,9 +397,9 @@ test("[test-suite] tpack: testing multiple types and sequence", () => { }); -test("[test-suite] tpack: testing alignment", () => { +test('[test-suite] tpack: testing alignment', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -451,9 +451,9 @@ test("[test-suite] tpack: testing alignment", () => { }); -test("[test-suite] tpack: testing initial position", () => { +test('[test-suite] tpack: testing initial position', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do diff --git a/test/test-suite/utf8.test.js b/test/test-suite/utf8.test.js index 124681ea..42f0941b 100644 --- a/test/test-suite/utf8.test.js +++ b/test/test-suite/utf8.test.js @@ -1,7 +1,7 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; const prefix = ` local function checkerror (msg, f, ...) @@ -92,9 +92,9 @@ const prefix = ` end `; -test("[test-suite] utf8: offset", () => { +test('[test-suite] utf8: offset', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` assert(utf8.offset("alo", 5) == nil) @@ -107,9 +107,9 @@ test("[test-suite] utf8: offset", () => { }); -test("[test-suite] utf8: error indication in utf8.len", () => { +test('[test-suite] utf8: error indication in utf8.len', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` do @@ -130,9 +130,9 @@ test("[test-suite] utf8: error indication in utf8.len", () => { }); -test("[test-suite] utf8: error in initial position for offset", () => { +test('[test-suite] utf8: error in initial position for offset', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` checkerror("position out of range", utf8.offset, "abc", 1, 5) @@ -150,9 +150,9 @@ test("[test-suite] utf8: error in initial position for offset", () => { }); -test("[test-suite] utf8: codepoints", () => { +test('[test-suite] utf8: codepoints', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` local s = "hello World" @@ -188,9 +188,9 @@ test("[test-suite] utf8: codepoints", () => { }); -test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", () => { +test('[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\xF4\\x9F\\xBF\\xBF") @@ -202,9 +202,9 @@ test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid r }); -test("[test-suite] utf8: overlong sequences", () => { +test('[test-suite] utf8: overlong sequences', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\xC0\\x80") -- zero @@ -219,9 +219,9 @@ test("[test-suite] utf8: overlong sequences", () => { }); -test("[test-suite] utf8: invalid bytes", () => { +test('[test-suite] utf8: invalid bytes', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\x80") -- continuation byte @@ -236,9 +236,9 @@ test("[test-suite] utf8: invalid bytes", () => { }); -test("[test-suite] utf8: empty strings", () => { +test('[test-suite] utf8: empty strings', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` check("", {}) @@ -250,9 +250,9 @@ test("[test-suite] utf8: empty strings", () => { }); -test("[test-suite] utf8: minimum and maximum values for each sequence size", () => { +test('[test-suite] utf8: minimum and maximum values for each sequence size', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` s = "\\0 \\x7F\\z diff --git a/test/test-suite/vararg.test.js b/test/test-suite/vararg.test.js index 61f218d8..298a9b35 100644 --- a/test/test-suite/vararg.test.js +++ b/test/test-suite/vararg.test.js @@ -1,11 +1,11 @@ import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from "../../src/fengaricore.js"; +import { to_luastring } from '../../src/fengaricore.js'; -test("[test-suite] vararg: testing vararg", () => { +test('[test-suite] vararg: testing vararg', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(a, ...) @@ -79,9 +79,9 @@ test("[test-suite] vararg: testing vararg", () => { }); -test("[test-suite] vararg: new-style varargs", () => { +test('[test-suite] vararg: new-style varargs', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function oneless (a, ...) return ... end @@ -112,9 +112,9 @@ test("[test-suite] vararg: new-style varargs", () => { }); -test("[test-suite] vararg: varargs for main chunks", () => { +test('[test-suite] vararg: varargs for main chunks', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` f = load[[ return {...} ]] @@ -150,9 +150,9 @@ test("[test-suite] vararg: varargs for main chunks", () => { }); -test("[test-suite] vararg: bug in 5.2.2", () => { +test('[test-suite] vararg: bug in 5.2.2', () => { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, diff --git a/test/tests.js b/test/tests.js index f8e7ebac..abdb0f77 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,10 +1,10 @@ -import { LUA_OK, lua_tojsstring, lua_dump } from "../src/lua.js"; -import { luaL_newstate, luaL_loadstring } from "../src/lauxlib.js"; -import { to_luastring } from "../src/fengaricore.js"; +import { LUA_OK, lua_tojsstring, lua_dump } from '../src/lua.js'; +import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; +import { to_luastring } from '../src/fengaricore.js'; -const toByteCode = function(luaCode) { +export const toByteCode = function(luaCode) { let L = luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + if (!L) throw Error('failed to create lua state'); if (luaL_loadstring(L, to_luastring(luaCode)) !== LUA_OK) throw Error(lua_tojsstring(L, -1)); @@ -14,9 +14,6 @@ const toByteCode = function(luaCode) { B.push(...b.slice(0, size)); return 0; }, b, false) !== 0) - throw Error("unable to dump given function"); + throw Error('unable to dump given function'); return Uint8Array.from(b); }; - -const _toByteCode = toByteCode; -export { _toByteCode as toByteCode }; diff --git a/yarn.lock b/yarn.lock index 3ad7b24f..b35e9f56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,7 @@ # yarn lockfile v1 +<<<<<<< HEAD "@babel/code-frame@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" @@ -37,6 +38,36 @@ "@babel/template" "^7.27.2" "@babel/traverse" "^7.28.5" "@babel/types" "^7.28.5" +======= +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.29.7.tgz#f2fbbfea87c44a21590ec515b778b2c26d8866e7" + integrity sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw== + dependencies: + "@babel/helper-validator-identifier" "^7.29.7" + js-tokens "^4.0.0" + picocolors "^1.1.1" + +"@babel/compat-data@^7.28.6", "@babel/compat-data@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.29.7.tgz#6f0237f0f36d2e51c0570a636faed9d2d0efe629" + integrity sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg== + +"@babel/core@^7.1.0", "@babel/core@^7.23.9", "@babel/core@^7.27.4", "@babel/core@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.29.7.tgz#80c10b17248082968b57a857b91640971f2070f7" + integrity sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA== + dependencies: + "@babel/code-frame" "^7.29.7" + "@babel/generator" "^7.29.7" + "@babel/helper-compilation-targets" "^7.29.7" + "@babel/helper-module-transforms" "^7.29.7" + "@babel/helpers" "^7.29.7" + "@babel/parser" "^7.29.7" + "@babel/template" "^7.29.7" + "@babel/traverse" "^7.29.7" + "@babel/types" "^7.29.7" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/remapping" "^2.3.5" convert-source-map "^2.0.0" debug "^4.1.0" @@ -44,6 +75,7 @@ json5 "^2.2.3" semver "^6.3.1" +<<<<<<< HEAD "@babel/generator@^7.27.5", "@babel/generator@^7.28.5": version "7.28.5" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.28.5.tgz#712722d5e50f44d07bc7ac9fe84438742dd61298" @@ -51,10 +83,20 @@ dependencies: "@babel/parser" "^7.28.5" "@babel/types" "^7.28.5" +======= +"@babel/generator@^7.29.7", "@babel/generator@^7.4.0": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.29.7.tgz#cca0b8827e6bcf3ba176788e7f3b180ad6db2fa3" + integrity sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ== + dependencies: + "@babel/parser" "^7.29.7" + "@babel/types" "^7.29.7" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/gen-mapping" "^0.3.12" "@jridgewell/trace-mapping" "^0.3.28" jsesc "^3.0.2" +<<<<<<< HEAD "@babel/helper-compilation-targets@^7.27.2": version "7.27.2" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz#46a0f6efab808d51d29ce96858dd10ce8732733d" @@ -62,10 +104,27 @@ dependencies: "@babel/compat-data" "^7.27.2" "@babel/helper-validator-option" "^7.27.1" +======= +"@babel/helper-annotate-as-pure@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz#c70fe3c6ecbdc3fd2dd1b0f498428b88b82ce47f" + integrity sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw== + dependencies: + "@babel/types" "^7.29.7" + +"@babel/helper-compilation-targets@^7.28.6", "@babel/helper-compilation-targets@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz#7a1def704302401c47f64fa85589e974ae217042" + integrity sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g== + dependencies: + "@babel/compat-data" "^7.29.7" + "@babel/helper-validator-option" "^7.29.7" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) browserslist "^4.24.0" lru-cache "^5.1.1" semver "^6.3.1" +<<<<<<< HEAD "@babel/helper-globals@^7.28.0": version "7.28.0" resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.28.0.tgz#b9430df2aa4e17bc28665eadeae8aa1d985e6674" @@ -141,6 +200,199 @@ integrity sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ== dependencies: "@babel/types" "^7.28.5" +======= +"@babel/helper-create-class-features-plugin@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.7.tgz#6eddf286f2ec418f740c91d60a83347c55838ddd" + integrity sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.29.7" + "@babel/helper-member-expression-to-functions" "^7.29.7" + "@babel/helper-optimise-call-expression" "^7.29.7" + "@babel/helper-replace-supers" "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.29.7" + "@babel/traverse" "^7.29.7" + semver "^6.3.1" + +"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.29.7.tgz#5d4c3f928f315cf6c4184ea2fc3b5b38745b2430" + integrity sha512-907Uymvqgg1dwUA+7IGwFAOSYzQOuzPXKNJ1yxzwPffzkYFg2q2eHi1fIOs6sXkG9NbIUMunnUlkYsfRFNvomg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.29.7" + regexpu-core "^6.3.1" + semver "^6.3.1" + +"@babel/helper-define-polyfill-provider@^0.6.8": + version "0.6.8" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.8.tgz#cf1e4462b613f2b54c41e6ff758d5dfcaa2c85d1" + integrity sha512-47UwBLPpQi1NoWzLuHNjRoHlYXMwIJoBf7MFou6viC/sIHWYygpvr0B6IAyh5sBdA2nr2LPIRww8lfaUVQINBA== + dependencies: + "@babel/helper-compilation-targets" "^7.28.6" + "@babel/helper-plugin-utils" "^7.28.6" + debug "^4.4.3" + lodash.debounce "^4.0.8" + resolve "^1.22.11" + +"@babel/helper-globals@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.29.7.tgz#f04a96fbd8473241b1079243f5b3f03a3010ab7b" + integrity sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA== + +"@babel/helper-member-expression-to-functions@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.29.7.tgz#8dbdb3ce0b5c487e1aec10e13c9a43a500814df8" + integrity sha512-j+7JYmk1JYDtACIGj0QJqqWZjoUpMoEikQGADMaHgCMCSDqd2+P32rfcibUNrGOMWrlzK1WJBdxrB3JJQZwWtg== + dependencies: + "@babel/traverse" "^7.29.7" + "@babel/types" "^7.29.7" + +"@babel/helper-module-imports@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz#ef25048a518e828d7393fac5882ddd73921d7396" + integrity sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g== + dependencies: + "@babel/traverse" "^7.29.7" + "@babel/types" "^7.29.7" + +"@babel/helper-module-transforms@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz#b062747a5997ba138637201328bbff77960574ae" + integrity sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg== + dependencies: + "@babel/helper-module-imports" "^7.29.7" + "@babel/helper-validator-identifier" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/helper-optimise-call-expression@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.29.7.tgz#77b0b5b94f1997fa9d6e3125f445227b1faf9d85" + integrity sha512-+kmGVjcT9RGYzoDwdwEqEvGgKe3BYq+O1iGzjFubaNgZHwYHP6lsF2Yghf4kEuv9BV7tYDZ913aBW9am6YKong== + dependencies: + "@babel/types" "^7.29.7" + +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.28.6", "@babel/helper-plugin-utils@^7.29.7", "@babel/helper-plugin-utils@^7.8.0": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz#c0a0766f1a13617d8a17407d7ab8f9d486225ea4" + integrity sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw== + +"@babel/helper-remap-async-to-generator@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.29.7.tgz#34b1f68dd75b86d31df781a29c3ff2df88da82e6" + integrity sha512-16AMiW26DbXWBbr3B8wNozKM0ydMLB892vaOaJW/fPJdnT8vJk5sdkQcU/isqUxyCE0cEoa8wZOcbgDuC4b6Og== + dependencies: + "@babel/helper-annotate-as-pure" "^7.29.7" + "@babel/helper-wrap-function" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/helper-replace-supers@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.29.7.tgz#bc3c3964329043c79112e513c1b198f16589ac21" + integrity sha512-atfGXWSeCiF4DnKZIfmJfQRkSw9b9gNNXR1kqKjbhG4pGYCOnkp8OcTB8E3NXjBu8NpheSnOeNKz8KT7UNFTmQ== + dependencies: + "@babel/helper-member-expression-to-functions" "^7.29.7" + "@babel/helper-optimise-call-expression" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/helper-skip-transparent-expression-wrappers@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.29.7.tgz#50c95c7e4c4f54936cfa0116428edc559862d551" + integrity sha512-brcMGQaVzIeUb+6/bs1Av0f8YuNNjKY2JyvfRCsFuFsdKccEQ5Ges2y74D74NZ1Rz8lKJ9ksJkfqwQFJ/iNEyQ== + dependencies: + "@babel/traverse" "^7.29.7" + "@babel/types" "^7.29.7" + +"@babel/helper-string-parser@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz#7f0871d99824d23137d60f86fcf6130fd5a1b51f" + integrity sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw== + +"@babel/helper-validator-identifier@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz#bd87084ced0c796ec46bda492de6e83d29e89fc2" + integrity sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg== + +"@babel/helper-validator-option@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz#cf315be940213b354eb4abcc0bd01ebe3f73bc2a" + integrity sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw== + +"@babel/helper-wrap-function@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.29.7.tgz#eec72163044548a0935e9d182bf2d547ec5ff483" + integrity sha512-iES0Skag9ERIF68aXadpO6dbXa03mNWK3sEqJaMnLNs/eC3l0lkImdfoy6Y09/SfkpawdAB4RjQ7PVA7TcVGdw== + dependencies: + "@babel/template" "^7.29.7" + "@babel/traverse" "^7.29.7" + "@babel/types" "^7.29.7" + +"@babel/helpers@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.29.7.tgz#45abfde7548997e34376c3e69feb475cffb4a607" + integrity sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg== + dependencies: + "@babel/template" "^7.29.7" + "@babel/types" "^7.29.7" + +"@babel/parser@^7.1.0", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.29.7", "@babel/parser@^7.4.3": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.29.7.tgz#837b87387cbf5ec5530cb634b3c622f68edb9334" + integrity sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg== + dependencies: + "@babel/types" "^7.29.7" + +"@babel/plugin-bugfix-firefox-class-in-computed-class-key@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-firefox-class-in-computed-class-key/-/plugin-bugfix-firefox-class-in-computed-class-key-7.29.7.tgz#2b535896d933a85aa92377eaa3d51a437d54a4e3" + integrity sha512-j8SrR0zLZrRsC09DlszEx8FpMiwukKffYXMK0d5LmOglO7vGG6sz/BR/20yHqWH+Lnn31JTt2PE3hIWNgM2J6w== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-bugfix-safari-class-field-initializer-scope@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-class-field-initializer-scope/-/plugin-bugfix-safari-class-field-initializer-scope-7.29.7.tgz#b00711a9e52bf4fe55ef7e54b2ef4a881bf804c8" + integrity sha512-r8j8escF+U2FUHo0KOhPUdMzUO+jp9fInva6+ACVAF3Y97Ev+5iNZwiqTghmzNeWwDkOPlYuTcfb1vDaoZKmAQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.29.7.tgz#2375328852026a3cf6bc0bcf2de7d236f2d5e701" + integrity sha512-GE1TFSiuFeGsCxmYXZl8HwoPrVlwe4rHPFE8weieGKZqnDORK+Ar3vgWMgW+AOxQ6/2TgLSKx9p6W7O4rC6qgQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-bugfix-safari-rest-destructuring-rhs-array@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-rest-destructuring-rhs-array/-/plugin-bugfix-safari-rest-destructuring-rhs-array-7.29.7.tgz#759a857c46c4d2a6199685cf71070d81ae5f743a" + integrity sha512-oBNVCvnO5tND+xSopWvV8WNGfpTfgP4Zr/YXXSj8zfmcPktp5Ku/aZlsIowgSD4fjmgHn6sGmB9APVsU5zOdhA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.29.7" + +"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.29.7.tgz#86de98dd8e03836178231ea96c27dab26016a705" + integrity sha512-QQt9qKHZ2sg/kivaLr7lnQr8HVrQDdBNSfCsTjiDxRuX/K5ORyKq+Bu8Xr0cDE3Dfkv0cw28Ve0EKyKMvulkOw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.29.7" + "@babel/plugin-transform-optional-chaining" "^7.29.7" + +"@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.29.7.tgz#f5d892681dbf4b08753436a5e55000d5ba728d6d" + integrity sha512-pn6QacGLgvCcwc+syUhKE/qSjV2D1IHDB84RNxWYSt1mW3K/SCtjinZ2p0cETJxAWBjPy3K/1lHwG5BjjPxNlw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2": + version "7.21.0-placeholder-for-preset-env.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz#7844f9289546efa9febac2de4cfe358a050bd703" + integrity sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -170,12 +422,28 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" +<<<<<<< HEAD "@babel/plugin-syntax-import-attributes@^7.24.7": version "7.27.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz#34c017d54496f9b11b61474e7ea3dfd5563ffe07" integrity sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww== dependencies: "@babel/helper-plugin-utils" "^7.27.1" +======= +"@babel/plugin-syntax-import-assertions@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.29.7.tgz#c5cd868505269126cc18882e1f01f7b0e0e24b4e" + integrity sha512-/An1OCBN93thpBAGyfsK2pcf0jvju1SAtKkL2Ny++B5Sy6sqgzXDQH1cZxWbF96Wuk+bn41MDA9bLd4VVAw6rw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-syntax-import-attributes@^7.24.7", "@babel/plugin-syntax-import-attributes@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.29.7.tgz#6115264516e95ead0f35a41710906612e447f605" + integrity sha512-zGYcYfq/WmZ4V+kBIXQon9dSSc8ircGZqw9ZaNhhGj9nZkeBu1jHLBDQqYYi5WA9uawvA2sIMbry2nCFhf5Djg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@babel/plugin-syntax-import-meta@^7.10.4": version "7.10.4" @@ -191,6 +459,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" +<<<<<<< HEAD "@babel/plugin-syntax-jsx@^7.27.1": version "7.27.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz#2f9beb5eff30fa507c5532d107daac7b888fa34c" @@ -198,6 +467,8 @@ dependencies: "@babel/helper-plugin-utils" "^7.27.1" +======= +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@babel/plugin-syntax-logical-assignment-operators@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" @@ -219,7 +490,11 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" +<<<<<<< HEAD "@babel/plugin-syntax-object-rest-spread@^7.8.3": +======= +"@babel/plugin-syntax-object-rest-spread@^7.0.0", "@babel/plugin-syntax-object-rest-spread@^7.8.3": +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== @@ -254,6 +529,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" +<<<<<<< HEAD "@babel/plugin-syntax-typescript@^7.27.1": version "7.27.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz#5147d29066a793450f220c63fa3a9431b7e6dd18" @@ -335,10 +611,550 @@ eslint-visitor-keys "^3.4.3" "@eslint-community/regexpp@^4.12.1": +======= +"@babel/plugin-syntax-unicode-sets-regex@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz#d49a3b3e6b52e5be6740022317580234a6a47357" + integrity sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" + +"@babel/plugin-transform-arrow-functions@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.29.7.tgz#d651343f562c03f47951bd1802195d0e10605f27" + integrity sha512-N7zArUXWzAMzm+/N0uPBeVB3Fam5lMxtUwMmDK5f/IBBS7a7p1qeUoxd/6CckXoxUdgsntq1Dh8xNW06maZbDQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-async-generator-functions@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.29.7.tgz#a5365617921d82a1fee33124a1102bb38a1e677d" + integrity sha512-d98gXZkgswvkyohMBABkhm3GeXhYj8psWfwQ2C7gtfrKGTykQa/iOIi+JJhwMjPlZ6Vm2XN+DCf3Es1EoG4ZLA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-remap-async-to-generator" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-transform-async-to-generator@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.29.7.tgz#3b5e8f1fb58133cf701bcf0baaf6f01bfd1a8889" + integrity sha512-pcUb2SS+RMo9TWVBwKGI5ShtoG7R+zBsFmCKDa6fe8c+hPr3XJlZgoE5j6i8W7gDjhyvy+85vmYexanvXh3d1w== + dependencies: + "@babel/helper-module-imports" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-remap-async-to-generator" "^7.29.7" + +"@babel/plugin-transform-block-scoped-functions@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.29.7.tgz#96d292634434082d6687bcdb81139affedf77e8c" + integrity sha512-cUSmjh72N+rN4PrkFlN1dJwNCwjVp5d38/CQrEsFggkD10UiFlBFgdH3tv5dNsLuHY+3S8db2xCHjhZcv5WgvA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-block-scoping@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.29.7.tgz#baa376691ae16244cd14335422fca6900f54e17d" + integrity sha512-ONyr4+AZhKh8yKWInVxU9AXA9EbsyeLcL6V0dJy6M2/62vuvpGm29zzuymbTpdc451GEpDIdAyPLP3r+P61yKQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-class-properties@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.29.7.tgz#034897b8a21beec163332fac2de235b14409abdf" + integrity sha512-GtcpjFvanPfzNQi3eTitsCqtRRmmqzpy/A+yhTR1HaZo1Ly3EA8ZXxlPyHdR8/IuRMYc3E4wdGBewB2QKQjAaA== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-class-static-block@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.29.7.tgz#fed8efd19f3dd3e1114ee390707c70912778fd7c" + integrity sha512-kibJgmEdX2iMwsHY2tSZNDgj8PwIlCQz7FK9KuGKO8zsuoUwSEhoNnNVp/emKWrbY4HeO6kkXfdMqRKKKXBm2A== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-classes@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.29.7.tgz#61d3e5aaae0c838acc3204d9db7c8dc05c25815b" + integrity sha512-qV0OGGBVacduzQHE649JyCneOFI/maT+YKsO+K4Yi3xv2wTPNjM/W2o2gdzMwEAZz7fXNTHAe0NcSg30bIN69g== + dependencies: + "@babel/helper-annotate-as-pure" "^7.29.7" + "@babel/helper-compilation-targets" "^7.29.7" + "@babel/helper-globals" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-replace-supers" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-transform-computed-properties@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.29.7.tgz#95028787ca31901b9a20b5c6d9605c32346f55ad" + integrity sha512-RK7/IyU5phpuCdBAuig5VkzG/EnbDaui5SQGdU9BFrHdV+mV4cUjLMQ9lJDjLNtWHsqtiefpGZUXQP2BiTYMsA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/template" "^7.29.7" + +"@babel/plugin-transform-destructuring@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.29.7.tgz#5781ec6947852e27b64c1165f0db431f408090e4" + integrity sha512-iPX8aD6H9zV5s7ZsqTdNocPN/MGQ5sSMnElKrktxjJRMnB2jN/1p2+R7GkfD6CAYoVFqy5A4XnSIUeGgJzIWpg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-transform-dotall-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.29.7.tgz#b203de9740e4c7ff6b55ce436ed5313b88d70af8" + integrity sha512-3qc18hsD2RdZiyJNDNc7HQpv6xbncwh8FYtxNFFzclSyh/trPD9KkVR9BDECUjDLvb7yJVF15GfYUuC+LMkkiQ== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-duplicate-keys@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.29.7.tgz#8f3fe721835cb7a433420841dae90afc962ea7ae" + integrity sha512-6IvRRriEMqnBwD6chtxdLpMYCHWEzN+oL5cyQtjykya19UgzbmKhxmhZgKC/LHxS2nYr9Q/qYPZ5Lr6jOL9+yQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-duplicate-named-capturing-groups-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-named-capturing-groups-regex/-/plugin-transform-duplicate-named-capturing-groups-regex-7.29.7.tgz#dc6c405e55c01b7657e1827a25332c4ac17e9cac" + integrity sha512-2wiIyo2BjtgU7HufSeDnL9L2O7zr8jmhFKuSr65VpRkUiRKRNpb0mdlk56+XPPKoIrfHqzbMuglDvZun0RISsA== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-dynamic-import@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.29.7.tgz#a83a6faec5bab5b619adf9d0eac6c1c270123c2a" + integrity sha512-giOlEm/EFjfjr+te9NsdjkUo2v4f8rS/SXPumRVHAtbNcyNlvtREkU1dZzaIDclNpnaVhlCqRdFKhJBjBikzLg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-explicit-resource-management@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-explicit-resource-management/-/plugin-transform-explicit-resource-management-7.29.7.tgz#65c8b9f76ec915b02a0e1df703125a0fca58abaa" + integrity sha512-Rstj7coNz8sE+7Ju7ihpHLI564lsK5pUpNNlvptCIC/16E/S5hbl6n3kESPKdNRmqEWlpn5xpS5Q2dvXBsySLw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/plugin-transform-destructuring" "^7.29.7" + +"@babel/plugin-transform-exponentiation-operator@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.29.7.tgz#00bf002fde8794356171f5d4df200f6bc0d5a303" + integrity sha512-zFpMOTLZBdW5LfObqcSbL6kefg4R4eLdmvS0wbN9M6D5Mym/sKm9toOoWyVOa+xDjvCnuWcHls2YonXwHvH3CQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-export-namespace-from@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.29.7.tgz#d6014f45cec61d7691335c6c9804204bee801d51" + integrity sha512-24B2nOy2TeJSMheqwPD4DDQOV/elLSIlKxjZt4i05H5AgdPdWR3n18HnNrcJ+j76WJd9gbwb9jPjNYUy6RautA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-for-of@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.29.7.tgz#c65a678592117717aacdb10c1b73a9cb85e830be" + integrity sha512-zeSIHh0+E1Um1WJRXCFlHQYu2ieJNdivLLjlBEp+dIBu3S51n+SZZmIXjxnItw6pz56Cn+KvK68BIBVsxq2JiQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.29.7" + +"@babel/plugin-transform-function-name@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.29.7.tgz#8b87f8a7504dbcd96135167e3fc4f61126a7bd86" + integrity sha512-otRWaHXE6fbAGkePvaj/kvs3HsqXfPhlnzwSOlnFgbqCPMd975dW+4wZ00WFBt+/YlBGcJwNrARQTOJOb4ZrIg== + dependencies: + "@babel/helper-compilation-targets" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-transform-json-strings@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.29.7.tgz#f57d63dcc05b4481c281acedcd8fc4e3e439a1d4" + integrity sha512-RRnE2+eon1rJAq8MnoF1b5kTpY1vU88twHcvcKMrsqP/jxIRqDVs9iJB5fqPuqyeFAW0wJo4MlUIPpQCq/aRsg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-literals@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.29.7.tgz#b90bd47463326c2a9d779e1bd5e1f88b9f421921" + integrity sha512-DZ/oLP21ZuWx1vKqnoNv6/tvEK48AQOBRai40CX9dTjGluvT/YZCyY3rryDtyUqCEoyNroy5KKPwX2iQCiRvyw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-logical-assignment-operators@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.29.7.tgz#9b29425adf5c794967aabe4b046a046a167bac2f" + integrity sha512-A0H91hh6W8MFRkp5TqJmMr39jzGD1A1E1Ysiv2O06Sfbhkapm+XyIzxWCEh5kqwOZ1/8QZ0dY3SeQ7XBqfJd5Q== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-member-expression-literals@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.29.7.tgz#1281689fa2fefc17b110d21ebafd0fe9402d5309" + integrity sha512-hl1kwFZCCiDyfH25Xmco9jTrkPgnS9pmOzSG7W5I4SaGbLeqKv417hcU2RKmaxoPEgsoJh7ZPOrnPGq99bHoUg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-modules-amd@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.29.7.tgz#f05ca662c8a1dc4be2f337af9c7e80369c942d6c" + integrity sha512-fxtQoH3m5ywUSIfaH0FGCzWu4McsYon5bD3K4XnskC7f+OyQMj7rsOMi4NvvmJ83WwBAg4UCe+ov4VZlqEvyew== + dependencies: + "@babel/helper-module-transforms" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-modules-commonjs@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.29.7.tgz#70e6835abf2663dafbe94b8ef1f51de7351ef135" + integrity sha512-j0vCldybPC5b5dwCQOJ21uKtHzt7hxLygJTg9eF1ScfaikEDNfzn94XoW5Fi+seBR0nCyL23xaBFFkq7dTM8XQ== + dependencies: + "@babel/helper-module-transforms" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-modules-systemjs@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.29.7.tgz#e575dd2ab9882906de120ff7dc9dee9914d8b6f3" + integrity sha512-TM2ZcQLoG2/y4HODiStCo10DibYhWhGWAwVv+EQKmG/7GFl0N+AAmUiXOMKM+aiJ9XBJ9AHVZBvTzMnJ2sM3cQ== + dependencies: + "@babel/helper-module-transforms" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-validator-identifier" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-transform-modules-umd@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.29.7.tgz#391d1c0215aca6307257f2f608598dfe55feb6cf" + integrity sha512-B4UkaTK3QpgCwJnrxKfMPKdo92CN7OKXAlpAAnM3UPu0Q0lCCk57ylA9AJbRy2v8dDKOPAAWcoR6CMyeoHwRCA== + dependencies: + "@babel/helper-module-transforms" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-named-capturing-groups-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.29.7.tgz#21e75d847b31189842fa7a77703722ed4b43d27d" + integrity sha512-vuFoLwr4qnv2xbZ16SQd6uPcH5FNrLHhk/Jzo++0XJFcaDsr4gjJVg6j398oMHiC+83k/GiBzviwF5KBJkPUtQ== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-new-target@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.29.7.tgz#714147ce7947e1b49cbd84137ca2e75e92b2a067" + integrity sha512-fEo41GmsOUhOBlw8ioo6zvjX5Xc2Lqkzlyfqbpsk3eB6TReV18uhxZ0esfEokVbY2+PVJAQHNKxER6lGrzNd3A== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-nullish-coalescing-operator@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.29.7.tgz#8a54cdf88c3f50433a6173117a286195b67714cc" + integrity sha512-idmp1dFaekP9GbcMvG24Kvw2BfhFZjHnNJCkV4WuIY4PskJzwI3f1N5OdgYke38T7rftO6ERulFRn2cFeZwRkg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-numeric-separator@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.29.7.tgz#0266d5cd42ab87ec40fee45a4e36483cfdcbc66a" + integrity sha512-zR7fv/z14OjgHl4AgRtkDBvBMhIzCxqV/qN/2BCRC7LjFwvuzjYe7gDWxC4Wl/SNsLM6SE1IWvRPYMgSJaUvNw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-object-rest-spread@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.29.7.tgz#e0d5060241803922c545676613cc8acbbda0d266" + integrity sha512-Ld98jn4c0smUywL57m7SgsHq3OpThOa6LqZJif3G6jYOovPleoFhVrBJ1WegRApSFB2wu4+RelAj9AC9G08Z4A== + dependencies: + "@babel/helper-compilation-targets" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/plugin-transform-destructuring" "^7.29.7" + "@babel/plugin-transform-parameters" "^7.29.7" + "@babel/traverse" "^7.29.7" + +"@babel/plugin-transform-object-super@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.29.7.tgz#e89283d14fa3c35817d4493ffc6bc649aa10e4eb" + integrity sha512-Ea/diGcw0twB5IlZPO5sgET6fJsLJqPABqTuFWIR+iMPGPZJkATEIWx0wa+aEQ5UY1CBQyP/gkAiLEqn1vBiQA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-replace-supers" "^7.29.7" + +"@babel/plugin-transform-optional-catch-binding@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.29.7.tgz#729664f79985be504eba112c51de9f71d009030b" + integrity sha512-sLsyndxK2VwX6yNUOakMb7Sh553ZTe/vVM1XJ+9Z5aW1ytsc8xOIwmyk05NNjN60vkc5/KqoTH6hB4V41LJhng== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-optional-chaining@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.29.7.tgz#b84a1b574b3c73001023092567e16c492b720e51" + integrity sha512-6GM1dhvK3gNODkXcEcMCOLEDCLSoZ/sBbro2Ax8HURyasQ4NshagQixkRFdh5niI6E4gmA/jYI/4aT7rRos3ZQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.29.7" + +"@babel/plugin-transform-parameters@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.29.7.tgz#a5ddc3b9bfb534814cb8334cbeba47d9cf9db090" + integrity sha512-ZDOBqV/qLYJI0YElr8DcENEyARsFQeESqWXH6gZlghYXuPPjvweuDhP4VyEi4BlUBlLRFZVjxoZDMjxhLW766g== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-private-methods@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.29.7.tgz#cea8bd3ab99533892897a02999d5b752584ad145" + integrity sha512-/6Rz4DK1ETDEM/bWHsPHcaEe7ZaT1EqSXjtSP/L0DijOYuaUhiRiOKcwpZ8P7zR4xXEHc2ITdiCgBm9Tpyv9ug== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-private-property-in-object@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.29.7.tgz#4a2f6be5aba47be7afbdb4cd7903c46edf3a7661" + integrity sha512-+BNo06dnrzdNNqCm1X6YUaVv0DKk8Q+JYcoZfOkLhYWNCXzlwTSRq8zGWayT1csjcpNXV9CQTBRRbmTLZac5cA== + dependencies: + "@babel/helper-annotate-as-pure" "^7.29.7" + "@babel/helper-create-class-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-property-literals@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.29.7.tgz#d45817cd72f9e134ab1f7fbb79264cfcb85cf636" + integrity sha512-bOMRLQuI0A5ZqHq3OWJ89/rXpJ/NJrbVhXiP4zwPGMs6kpcVsuTUNjwoE30K0Qm3mf48a/TnRYYD6vPNqcg6jA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-regenerator@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.29.7.tgz#0f42626a7dbb0e7a7f52e036d3e43deebdc3ea4e" + integrity sha512-rNNFV0DBAJp988xW2DOntfDoYn1eR8GGF5AT5vYc+rjyfaQkM242c9tZUHHPe7KYaiJizXPWhQTzzdbXySyhBw== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-regexp-modifiers@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regexp-modifiers/-/plugin-transform-regexp-modifiers-7.29.7.tgz#68311c0c10af2198212528863f8542843e424025" + integrity sha512-mB5Fs0VWrJ42ZCmc8114v60qetdaUVNkj9PmSZRmanCZM3S9hm0CFRLjRmYIsuXav14l2jvZ+4T8iiCGnhj3nQ== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-reserved-words@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.29.7.tgz#a6feeb179b36a5f1fc6e3154c1eb727bdbe35876" + integrity sha512-5+YhdpVgmfSmwZyLMftfaiffLRMHjzIRHFHHLdibcSyJm2pasMrKHrO3Ptrt2DRshjvpgjEJJ1zVW14WPq/6QA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-shorthand-properties@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.29.7.tgz#25c0436b98f4bd9ca4b98e1fbd662743bbaab9bf" + integrity sha512-I+WYbGBAiCn7nA6xBrlgPH+MB7HWb4u8pv5S0Pv7OtwNvIFvCCb24YlttKEeUFVurfBCEaOTnuhlqsb7f0Z5Dg== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-spread@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.29.7.tgz#a128bcdd6b5e5e47054907b2e50bc19c3f856edd" + integrity sha512-/u5K1QWada7tbYNqTjMh96718g9NTwh9tfPJMsSmVsQwGT447FskV+KcfeXkXq2GWki4EM/MuTdmBec+hOuVTQ== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.29.7" + +"@babel/plugin-transform-sticky-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.29.7.tgz#a42c0fd1fa42f7e98e1e0c7757f72a1bbca3a015" + integrity sha512-BCHzNYJGe9l7EpwwDBN/ztlL2NYFFq8hp9ddjtUEM9f2O7S7kKV/lL6Fwo7IF7NSkYhPK2vO+86nIGltA90MsA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-template-literals@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.29.7.tgz#ada97d8e0832bca8edb315888aa654b1570f3835" + integrity sha512-NCSEJ4sLFU2gqAub45HYh4fus2yQ36rr6ei6vpU7NdoJqCpxvEG8E6eJpscGyXP3VHD2Ny+fSXr04k1hoUrFqA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-typeof-symbol@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.29.7.tgz#d848a4677c1ee3485ab017f4018f04597798911c" + integrity sha512-223mNGoTkBiTEWFoK+Q6Go3tueMRclO8vxxxxquNCYuNI4jWOofFKJRRDu6SDrB8Sgo1UEGW9T4GAQ8ZyRso1A== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-unicode-escapes@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.29.7.tgz#1e99554b0cddfd650d649a9f2b996049893e5720" + integrity sha512-jCfXxSjf94lf4E0hKE0AByxF6F3/pVFqRdUUNkDJhsY0m1ZKjnN6ZYyMeHNpzflxb/0q5b7t3p+BE+SLF1WOtA== + dependencies: + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-unicode-property-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.29.7.tgz#44444afc73768c2190fac4d95f7716817b7f204a" + integrity sha512-OgZ+zoAJgZLUCunsTRQ5LAjOywDv5zzZ2/hQ5aMw1pGXyY2rtE8/chXYUmu3AlVHKpm10KEdG9aMwbI/K76ZGw== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-unicode-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.29.7.tgz#c3064b293ff7f1794b71f7650eec8db9896d3e59" + integrity sha512-7D/x/23/d/3VqZ0QA+LGbZMlGwZjztBygSWWWsfTPoQ1oQ6Q1P6Mr3d0kk42XabyUVw+fha3LqdRsFqeKqvCyA== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/plugin-transform-unicode-sets-regex@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.29.7.tgz#b03ac9f27326f6197e8e574add83bbf33fc34ecd" + integrity sha512-BLOhLht9DOJwIxlmp91wHvkXv1lguuHS3/FwUO8HL1H0u8s4hR1gASVFyilu9iGtcTRYqjTZmlsFFeQletntEg== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + +"@babel/preset-env@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.29.7.tgz#5e2ab5e764b493fdefc99c43aeaa70a9533a37fd" + integrity sha512-GYzX36n1nsciIb0uyH0GHwxwtNwPQIcpxSeiVLDtG/B7jB5xXgchnmL1f/jCX5o+pwnaDBtO60ONSJhEBJfxYA== + dependencies: + "@babel/compat-data" "^7.29.7" + "@babel/helper-compilation-targets" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-validator-option" "^7.29.7" + "@babel/plugin-bugfix-firefox-class-in-computed-class-key" "^7.29.7" + "@babel/plugin-bugfix-safari-class-field-initializer-scope" "^7.29.7" + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.29.7" + "@babel/plugin-bugfix-safari-rest-destructuring-rhs-array" "^7.29.7" + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.29.7" + "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly" "^7.29.7" + "@babel/plugin-proposal-private-property-in-object" "7.21.0-placeholder-for-preset-env.2" + "@babel/plugin-syntax-import-assertions" "^7.29.7" + "@babel/plugin-syntax-import-attributes" "^7.29.7" + "@babel/plugin-syntax-unicode-sets-regex" "^7.18.6" + "@babel/plugin-transform-arrow-functions" "^7.29.7" + "@babel/plugin-transform-async-generator-functions" "^7.29.7" + "@babel/plugin-transform-async-to-generator" "^7.29.7" + "@babel/plugin-transform-block-scoped-functions" "^7.29.7" + "@babel/plugin-transform-block-scoping" "^7.29.7" + "@babel/plugin-transform-class-properties" "^7.29.7" + "@babel/plugin-transform-class-static-block" "^7.29.7" + "@babel/plugin-transform-classes" "^7.29.7" + "@babel/plugin-transform-computed-properties" "^7.29.7" + "@babel/plugin-transform-destructuring" "^7.29.7" + "@babel/plugin-transform-dotall-regex" "^7.29.7" + "@babel/plugin-transform-duplicate-keys" "^7.29.7" + "@babel/plugin-transform-duplicate-named-capturing-groups-regex" "^7.29.7" + "@babel/plugin-transform-dynamic-import" "^7.29.7" + "@babel/plugin-transform-explicit-resource-management" "^7.29.7" + "@babel/plugin-transform-exponentiation-operator" "^7.29.7" + "@babel/plugin-transform-export-namespace-from" "^7.29.7" + "@babel/plugin-transform-for-of" "^7.29.7" + "@babel/plugin-transform-function-name" "^7.29.7" + "@babel/plugin-transform-json-strings" "^7.29.7" + "@babel/plugin-transform-literals" "^7.29.7" + "@babel/plugin-transform-logical-assignment-operators" "^7.29.7" + "@babel/plugin-transform-member-expression-literals" "^7.29.7" + "@babel/plugin-transform-modules-amd" "^7.29.7" + "@babel/plugin-transform-modules-commonjs" "^7.29.7" + "@babel/plugin-transform-modules-systemjs" "^7.29.7" + "@babel/plugin-transform-modules-umd" "^7.29.7" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.29.7" + "@babel/plugin-transform-new-target" "^7.29.7" + "@babel/plugin-transform-nullish-coalescing-operator" "^7.29.7" + "@babel/plugin-transform-numeric-separator" "^7.29.7" + "@babel/plugin-transform-object-rest-spread" "^7.29.7" + "@babel/plugin-transform-object-super" "^7.29.7" + "@babel/plugin-transform-optional-catch-binding" "^7.29.7" + "@babel/plugin-transform-optional-chaining" "^7.29.7" + "@babel/plugin-transform-parameters" "^7.29.7" + "@babel/plugin-transform-private-methods" "^7.29.7" + "@babel/plugin-transform-private-property-in-object" "^7.29.7" + "@babel/plugin-transform-property-literals" "^7.29.7" + "@babel/plugin-transform-regenerator" "^7.29.7" + "@babel/plugin-transform-regexp-modifiers" "^7.29.7" + "@babel/plugin-transform-reserved-words" "^7.29.7" + "@babel/plugin-transform-shorthand-properties" "^7.29.7" + "@babel/plugin-transform-spread" "^7.29.7" + "@babel/plugin-transform-sticky-regex" "^7.29.7" + "@babel/plugin-transform-template-literals" "^7.29.7" + "@babel/plugin-transform-typeof-symbol" "^7.29.7" + "@babel/plugin-transform-unicode-escapes" "^7.29.7" + "@babel/plugin-transform-unicode-property-regex" "^7.29.7" + "@babel/plugin-transform-unicode-regex" "^7.29.7" + "@babel/plugin-transform-unicode-sets-regex" "^7.29.7" + "@babel/preset-modules" "0.1.6-no-external-plugins" + babel-plugin-polyfill-corejs2 "^0.4.15" + babel-plugin-polyfill-corejs3 "^0.14.0" + babel-plugin-polyfill-regenerator "^0.6.6" + core-js-compat "^3.48.0" + semver "^6.3.1" + +"@babel/preset-modules@0.1.6-no-external-plugins": + version "0.1.6-no-external-plugins" + resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz#ccb88a2c49c817236861fee7826080573b8a923a" + integrity sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/types" "^7.4.4" + esutils "^2.0.2" + +"@babel/template@^7.29.7", "@babel/template@^7.4.0": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.29.7.tgz#4d9d4004f645cdd304de958c725162784ecac700" + integrity sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg== + dependencies: + "@babel/code-frame" "^7.29.7" + "@babel/parser" "^7.29.7" + "@babel/types" "^7.29.7" + +"@babel/traverse@^7.1.0", "@babel/traverse@^7.29.7", "@babel/traverse@^7.4.3": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.29.7.tgz#c47b07a41b95da0907d026b5dd894d98de7d2f2d" + integrity sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw== + dependencies: + "@babel/code-frame" "^7.29.7" + "@babel/generator" "^7.29.7" + "@babel/helper-globals" "^7.29.7" + "@babel/parser" "^7.29.7" + "@babel/template" "^7.29.7" + "@babel/types" "^7.29.7" + debug "^4.3.1" + +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.28.2", "@babel/types@^7.29.7", "@babel/types@^7.4.0", "@babel/types@^7.4.4": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.29.7.tgz#8005e31d82712ee7adaef6e23c63b71a62770a92" + integrity sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA== + dependencies: + "@babel/helper-string-parser" "^7.29.7" + "@babel/helper-validator-identifier" "^7.29.7" + +"@cnakazawa/watch@^1.0.3": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a" + integrity sha512-v9kIhKwjeZThiWrLmj0y17CWoyddASLj9O2yvbZkbvw/N3rWOYy9zkV66ursAoVr0mV15bL8g0c4QZUE6cdDoQ== + dependencies: + exec-sh "^0.3.2" + minimist "^1.2.0" + +"@eslint-community/eslint-utils@^4.8.0", "@eslint-community/eslint-utils@^4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz#4e90af67bc51ddee6cdef5284edf572ec376b595" + integrity sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ== + dependencies: + eslint-visitor-keys "^3.4.3" + +"@eslint-community/regexpp@^4.12.2": +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.12.2" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz#bccdf615bcf7b6e8db830ec0b8d21c9a25de597b" integrity sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew== +<<<<<<< HEAD "@eslint/config-array@^0.21.1": version "0.21.1" resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.21.1.tgz#7d1b0060fea407f8301e932492ba8c18aff29713" @@ -408,6 +1224,70 @@ "@humanfs/core" "^0.19.1" "@humanwhocodes/retry" "^0.4.0" +======= +"@eslint/config-array@^0.23.5": + version "0.23.5" + resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.23.5.tgz#56e86d243049195d8acc0c06a1b3dfdc3fa3de95" + integrity sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA== + dependencies: + "@eslint/object-schema" "^3.0.5" + debug "^4.3.1" + minimatch "^10.2.4" + +"@eslint/config-helpers@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@eslint/config-helpers/-/config-helpers-0.6.0.tgz#ef9a36881d39dfd5dbeac22b0da997fabfb08b03" + integrity sha512-ii6Bw9jJ2zi2cWA2Z+9/QZ/+3DX6kwaV5Q986D/CdP3Lap3w/pgQZ373FV7byY/i7L4IRH/G43I5dz1ClsCbpA== + dependencies: + "@eslint/core" "^1.2.1" + +"@eslint/core@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@eslint/core/-/core-1.2.1.tgz#c1da7cd1b82fa8787f98b5629fb811848a1b63ce" + integrity sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ== + dependencies: + "@types/json-schema" "^7.0.15" + +"@eslint/js@^10.0.1": + version "10.0.1" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-10.0.1.tgz#1e8a876f50117af8ab67e47d5ad94d38d6622583" + integrity sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA== + +"@eslint/object-schema@^3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-3.0.5.tgz#88e9bf4d11d2b19c082e78ebe7ce88724a5eb091" + integrity sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw== + +"@eslint/plugin-kit@^0.7.2": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.7.2.tgz#4b0962f3f2c7ce8bc98b3ecfe34525c09d2cb729" + integrity sha512-+CNAzxglkrpNf/kKywqQfk74QjtceuOE7Qm+AF8miRvPF/wmmK5+OJOgVh3AVTT3RP2mH3+FOaxlE5v72owk0A== + dependencies: + "@eslint/core" "^1.2.1" + levn "^0.4.1" + +"@humanfs/core@^0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.2.tgz#a8272ca03b2acf492670222b2320b6c421bfde60" + integrity sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA== + dependencies: + "@humanfs/types" "^0.15.0" + +"@humanfs/node@^0.16.6": + version "0.16.8" + resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.8.tgz#8f800cccc13f4f8cd3116e2d9c0a94939da3e3ed" + integrity sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ== + dependencies: + "@humanfs/core" "^0.19.2" + "@humanfs/types" "^0.15.0" + "@humanwhocodes/retry" "^0.4.0" + +"@humanfs/types@^0.15.0": + version "0.15.0" + resolved "https://registry.yarnpkg.com/@humanfs/types/-/types-0.15.0.tgz#f2a09f62012390b2bff3fc6fb248ddec8c09a090" + integrity sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q== + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@humanwhocodes/module-importer@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" @@ -418,6 +1298,7 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba" integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ== +<<<<<<< HEAD "@isaacs/cliui@^8.0.2": version "8.0.2" resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" @@ -430,6 +1311,8 @@ wrap-ansi "^8.1.0" wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" +======= +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -442,6 +1325,7 @@ resolve-from "^5.0.0" "@istanbuljs/schema@^0.1.2", "@istanbuljs/schema@^0.1.3": +<<<<<<< HEAD version "0.1.3" resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== @@ -639,20 +1523,172 @@ dependencies: "@babel/core" "^7.27.4" "@jest/types" "30.2.0" +======= + version "0.1.6" + resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.6.tgz#8dc9afa2ac1506cb1a58f89940f1c124446c8df3" + integrity sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw== + +"@jest/console@^24.7.1", "@jest/console@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-24.9.0.tgz#79b1bc06fb74a8cfb01cbdedf945584b1b9707f0" + integrity sha512-Zuj6b8TnKXi3q4ymac8EQfc3ea/uhLeCGThFqXeC8H9/raaH8ARPUTdId+XyGd03Z4In0/VjD2OYFcBF09fNLQ== + dependencies: + "@jest/source-map" "^24.9.0" + chalk "^2.0.1" + slash "^2.0.0" + +"@jest/core@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-24.9.0.tgz#2ceccd0b93181f9c4850e74f2a9ad43d351369c4" + integrity sha512-Fogg3s4wlAr1VX7q+rhV9RVnUv5tD7VuWfYy1+whMiWUrvl7U3QJSJyWcDio9Lq2prqYsZaeTv2Rz24pWGkJ2A== + dependencies: + "@jest/console" "^24.7.1" + "@jest/reporters" "^24.9.0" + "@jest/test-result" "^24.9.0" + "@jest/transform" "^24.9.0" + "@jest/types" "^24.9.0" + ansi-escapes "^3.0.0" + chalk "^2.0.1" + exit "^0.1.2" + graceful-fs "^4.1.15" + jest-changed-files "^24.9.0" + jest-config "^24.9.0" + jest-haste-map "^24.9.0" + jest-message-util "^24.9.0" + jest-regex-util "^24.3.0" + jest-resolve "^24.9.0" + jest-resolve-dependencies "^24.9.0" + jest-runner "^24.9.0" + jest-runtime "^24.9.0" + jest-snapshot "^24.9.0" + jest-util "^24.9.0" + jest-validate "^24.9.0" + jest-watcher "^24.9.0" + micromatch "^3.1.10" + p-each-series "^1.0.0" + realpath-native "^1.1.0" + rimraf "^2.5.4" + slash "^2.0.0" + strip-ansi "^5.0.0" + +"@jest/environment@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-24.9.0.tgz#21e3afa2d65c0586cbd6cbefe208bafade44ab18" + integrity sha512-5A1QluTPhvdIPFYnO3sZC3smkNeXPVELz7ikPbhUj0bQjB07EoE9qtLrem14ZUYWdVayYbsjVwIiL4WBIMV4aQ== + dependencies: + "@jest/fake-timers" "^24.9.0" + "@jest/transform" "^24.9.0" + "@jest/types" "^24.9.0" + jest-mock "^24.9.0" + +"@jest/fake-timers@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-24.9.0.tgz#ba3e6bf0eecd09a636049896434d306636540c93" + integrity sha512-eWQcNa2YSwzXWIMC5KufBh3oWRIijrQFROsIqt6v/NS9Io/gknw1jsAC9c+ih/RQX4A3O7SeWAhQeN0goKhT9A== + dependencies: + "@jest/types" "^24.9.0" + jest-message-util "^24.9.0" + jest-mock "^24.9.0" + +"@jest/pattern@30.4.0": + version "30.4.0" + resolved "https://registry.yarnpkg.com/@jest/pattern/-/pattern-30.4.0.tgz#fcb519eeacc25caa3768f787595a27afa15302ae" + integrity sha512-RAWn3+f9u8BsHijKJ71uHcFp6vmyEt6VvoWXkl6hKF3qVIuWNmudVjg12DlBPGup/frIl5UcUlH5HfEuvHpEXg== + dependencies: + "@types/node" "*" + jest-regex-util "30.4.0" + +"@jest/reporters@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-24.9.0.tgz#86660eff8e2b9661d042a8e98a028b8d631a5b43" + integrity sha512-mu4X0yjaHrffOsWmVLzitKmmmWSQ3GGuefgNscUSWNiUNcEOSEQk9k3pERKEQVBb0Cnn88+UESIsZEMH3o88Gw== + dependencies: + "@jest/environment" "^24.9.0" + "@jest/test-result" "^24.9.0" + "@jest/transform" "^24.9.0" + "@jest/types" "^24.9.0" + chalk "^2.0.1" + exit "^0.1.2" + glob "^7.1.2" + istanbul-lib-coverage "^2.0.2" + istanbul-lib-instrument "^3.0.1" + istanbul-lib-report "^2.0.4" + istanbul-lib-source-maps "^3.0.1" + istanbul-reports "^2.2.6" + jest-haste-map "^24.9.0" + jest-resolve "^24.9.0" + jest-runtime "^24.9.0" + jest-util "^24.9.0" + jest-worker "^24.6.0" + node-notifier "^5.4.2" + slash "^2.0.0" + source-map "^0.6.0" + string-length "^2.0.0" + +"@jest/schemas@30.4.1": + version "30.4.1" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-30.4.1.tgz#c3703fdd71357e2c83aa59bd38469e60a11529c6" + integrity sha512-i6b4qw5qnP8c5FEeBJg/uZQ4ddrkN6Ca8qISJh0pr7a5hfn3h3v5x60BEbOC7OYAGZNMs1LfFLwnW2CuK8F57Q== + dependencies: + "@sinclair/typebox" "^0.34.0" + +"@jest/source-map@^24.3.0", "@jest/source-map@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-24.9.0.tgz#0e263a94430be4b41da683ccc1e6bffe2a191714" + integrity sha512-/Xw7xGlsZb4MJzNDgB7PW5crou5JqWiBQaz6xyPd3ArOg2nfn/PunV8+olXbbEZzNl591o5rWKE9BRDaFAuIBg== + dependencies: + callsites "^3.0.0" + graceful-fs "^4.1.15" + source-map "^0.6.0" + +"@jest/test-result@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-24.9.0.tgz#11796e8aa9dbf88ea025757b3152595ad06ba0ca" + integrity sha512-XEFrHbBonBJ8dGp2JmF8kP/nQI/ImPpygKHwQ/SY+es59Z3L5PI4Qb9TQQMAEeYsThG1xF0k6tmG0tIKATNiiA== + dependencies: + "@jest/console" "^24.9.0" + "@jest/types" "^24.9.0" + "@types/istanbul-lib-coverage" "^2.0.0" + +"@jest/test-sequencer@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-24.9.0.tgz#f8f334f35b625a4f2f355f2fe7e6036dad2e6b31" + integrity sha512-6qqsU4o0kW1dvA95qfNog8v8gkRN9ph6Lz7r96IvZpHdNipP2cBcb07J1Z45mz/VIS01OHJ3pY8T5fUY38tg4A== + dependencies: + "@jest/test-result" "^24.9.0" + jest-haste-map "^24.9.0" + jest-runner "^24.9.0" + jest-runtime "^24.9.0" + +"@jest/transform@30.4.1": + version "30.4.1" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-30.4.1.tgz#1646cddb800d38d9c4e30fecfd4a6eba0fa8acfa" + integrity sha512-Wz0LyktlTvRefoymh+n64hQ84KNXsRGcwdoZ8CSa0Ea+fgYcHZlnk+hDP7v2MS7il2bQ5uTEIxf4/NNfhMN4KQ== + dependencies: + "@babel/core" "^7.27.4" + "@jest/types" "30.4.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/trace-mapping" "^0.3.25" babel-plugin-istanbul "^7.0.1" chalk "^4.1.2" convert-source-map "^2.0.0" fast-json-stable-stringify "^2.1.0" graceful-fs "^4.2.11" +<<<<<<< HEAD jest-haste-map "30.2.0" jest-regex-util "30.0.1" jest-util "30.2.0" micromatch "^4.0.8" +======= + jest-haste-map "30.4.1" + jest-regex-util "30.4.0" + jest-util "30.4.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) pirates "^4.0.7" slash "^3.0.0" write-file-atomic "^5.0.1" +<<<<<<< HEAD "@jest/types@30.2.0": version "30.2.0" resolved "https://registry.yarnpkg.com/@jest/types/-/types-30.2.0.tgz#1c678a7924b8f59eafd4c77d56b6d0ba976d62b8" @@ -660,12 +1696,55 @@ dependencies: "@jest/pattern" "30.0.1" "@jest/schemas" "30.0.5" +======= +"@jest/transform@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-24.9.0.tgz#4ae2768b296553fadab09e9ec119543c90b16c56" + integrity sha512-TcQUmyNRxV94S0QpMOnZl0++6RMiqpbH/ZMccFB/amku6Uwvyb1cjYX7xkp5nGNkbX4QPH/FcB6q1HBTHynLmQ== + dependencies: + "@babel/core" "^7.1.0" + "@jest/types" "^24.9.0" + babel-plugin-istanbul "^5.1.0" + chalk "^2.0.1" + convert-source-map "^1.4.0" + fast-json-stable-stringify "^2.0.0" + graceful-fs "^4.1.15" + jest-haste-map "^24.9.0" + jest-regex-util "^24.9.0" + jest-util "^24.9.0" + micromatch "^3.1.10" + pirates "^4.0.1" + realpath-native "^1.1.0" + slash "^2.0.0" + source-map "^0.6.1" + write-file-atomic "2.4.1" + +"@jest/types@30.4.1": + version "30.4.1" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-30.4.1.tgz#f79b647a85cb2ff4a90cc55984b31dae820db1f7" + integrity sha512-f1x/vJXIfjOlEmejYpbkbgw1gOqpPECwMvMEtBqe47j7H2Hg8h8w3o3ikhSXq3MI15kg+oQ0exWO0uCtTNJLoQ== + dependencies: + "@jest/pattern" "30.4.0" + "@jest/schemas" "30.4.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/istanbul-lib-coverage" "^2.0.6" "@types/istanbul-reports" "^3.0.4" "@types/node" "*" "@types/yargs" "^17.0.33" chalk "^4.1.2" +<<<<<<< HEAD +======= +"@jest/types@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-24.9.0.tgz#63cb26cb7500d069e5a389441a7c6ab5e909fc59" + integrity sha512-XKK7ze1apu5JWQ5eZjHITP66AX+QsLlbaJRBGYr8pNzwcAE2JVkwnf0yqjHTsDRcjR0mujy/NmZMXw5kl+kGBw== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^1.1.1" + "@types/yargs" "^13.0.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/gen-mapping@^0.3.12", "@jridgewell/gen-mapping@^0.3.5": version "0.3.13" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f" @@ -692,7 +1771,11 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz#6912b00d2c631c0d15ce1a7ab57cd657f2a8f8ba" integrity sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og== +<<<<<<< HEAD "@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.23", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25", "@jridgewell/trace-mapping@^0.3.28": +======= +"@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25", "@jridgewell/trace-mapping@^0.3.28": +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "0.3.31" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz#db15d6781c931f3a251a3dac39501c98a6082fd0" integrity sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw== @@ -700,6 +1783,7 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +<<<<<<< HEAD "@napi-rs/wasm-runtime@^0.2.11": version "0.2.12" resolved "https://registry.yarnpkg.com/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz#3e78a8b96e6c33a6c517e1894efbd5385a7cb6f2" @@ -746,6 +1830,26 @@ tslib "^2.4.0" "@types/babel__core@^7.20.5": +======= +"@sinclair/typebox@^0.34.0": + version "0.34.49" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.34.49.tgz#4f1369234f2ecf693866476c3b2e1b54d2a9d68e" + integrity sha512-brySQQs7Jtn0joV8Xh9ZV/hZb9Ozb0pmazDIASBkYKCjXrXU3mpcFahmK/z4YDhGkQvP9mWJbVyahdtU5wQA+A== + +"@stylistic/eslint-plugin@^5.10.0": + version "5.10.0" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-5.10.0.tgz#471bbd9f7a27ceaac4a217e7f5b3890855e5640c" + integrity sha512-nPK52ZHvot8Ju/0A4ucSX1dcPV2/1clx0kLcH5wDmrE4naKso7TUC/voUyU1O9OTKTrR6MYip6LP0ogEMQ9jPQ== + dependencies: + "@eslint-community/eslint-utils" "^4.9.1" + "@typescript-eslint/types" "^8.56.0" + eslint-visitor-keys "^4.2.1" + espree "^10.4.0" + estraverse "^5.3.0" + picomatch "^4.0.3" + +"@types/babel__core@^7.1.0", "@types/babel__core@^7.20.5": +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA== @@ -757,20 +1861,33 @@ "@types/babel__traverse" "*" "@types/babel__generator@*": +<<<<<<< HEAD version "7.0.2" resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.0.2.tgz#d2112a6b21fad600d7674274293c85dce0cb47fc" integrity sha512-NHcOfab3Zw4q5sEE2COkpfXjoE7o+PmqD9DQW4koUT3roNxwziUdXGnRndMat/LJNUtePwn1TlP4do3uoe3KZQ== +======= + version "7.27.0" + resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.27.0.tgz#b5819294c51179957afaec341442f9341e4108a9" + integrity sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: "@babel/types" "^7.0.0" "@types/babel__template@*": +<<<<<<< HEAD version "7.0.2" resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.0.2.tgz#4ff63d6b52eddac1de7b975a5223ed32ecea9307" integrity sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg== +======= + version "7.4.4" + resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f" + integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" +<<<<<<< HEAD "@types/babel__traverse@*": version "7.0.6" resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.0.6.tgz#328dd1a8fc4cfe3c8458be9477b219ea158fd7b2" @@ -784,6 +1901,26 @@ integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.1", "@types/istanbul-lib-coverage@^2.0.6": +======= +"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": + version "7.28.0" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.28.0.tgz#07d713d6cce0d265c9849db0cbe62d3f61f36f74" + integrity sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q== + dependencies: + "@babel/types" "^7.28.2" + +"@types/esrecurse@^4.3.1": + version "4.3.1" + resolved "https://registry.yarnpkg.com/@types/esrecurse/-/esrecurse-4.3.1.tgz#6f636af962fbe6191b830bd676ba5986926bccec" + integrity sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw== + +"@types/estree@^1.0.6", "@types/estree@^1.0.8": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.9.tgz#cf3f0e876d7bee15a93ab925b82bf570a3904a24" + integrity sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg== + +"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.6": +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.6" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== @@ -795,6 +1932,17 @@ dependencies: "@types/istanbul-lib-coverage" "*" +<<<<<<< HEAD +======= +"@types/istanbul-reports@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz#e875cc689e47bce549ec81f3df5e6f6f11cfaeb2" + integrity sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw== + dependencies: + "@types/istanbul-lib-coverage" "*" + "@types/istanbul-lib-report" "*" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/istanbul-reports@^3.0.4": version "3.0.4" resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" @@ -808,6 +1956,7 @@ integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== "@types/node@*": +<<<<<<< HEAD version "25.0.2" resolved "https://registry.yarnpkg.com/@types/node/-/node-25.0.2.tgz#411f9dd6cb2bf5ee46aed7199a9f85ca6b068b4e" integrity sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA== @@ -818,12 +1967,34 @@ version "2.0.3" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== +======= + version "25.9.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-25.9.1.tgz#3bda556db500ae4319c08e7fc9ab94f19013ba0b" + integrity sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg== + dependencies: + undici-types ">=7.24.0 <7.24.7" + +"@types/stack-utils@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" + integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/yargs-parser@*": version "21.0.3" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== +<<<<<<< HEAD +======= +"@types/yargs@^13.0.0": + version "13.0.12" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-13.0.12.tgz#d895a88c703b78af0465a9de88aa92c61430b092" + integrity sha512-qCxJE1qgz2y0hA4pIxjBR+PelCH0U5CK1XJXFwCNqfmliatKp47UCXXE9Dyk1OXBDLvsCF57TqQEJaeLfDYEOQ== + dependencies: + "@types/yargs-parser" "*" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/yargs@^17.0.33": version "17.0.35" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.35.tgz#07013e46aa4d7d7d50a49e15604c1c5340d4eb24" @@ -831,6 +2002,7 @@ dependencies: "@types/yargs-parser" "*" +<<<<<<< HEAD "@ungap/structured-clone@^1.3.0": version "1.3.0" resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8" @@ -932,12 +2104,37 @@ version "1.11.1" resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-win32-x64-msvc/-/resolver-binding-win32-x64-msvc-1.11.1.tgz#538b1e103bf8d9864e7b85cc96fa8d6fb6c40777" integrity sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g== +======= +"@typescript-eslint/types@^8.56.0": + version "8.60.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.60.1.tgz#ccdc482ba9e17f9723a10ce240b5e67dad3046c4" + integrity sha512-4h0tY8ppCkdCzcrl2YM5M3my0xsE1Tf8om3owEu5oPWmXwkKRmk0j0LGDzYBGUcAlesEbxBhazqu/K4cu3Ug7w== + +"@ungap/structured-clone@^1.3.0": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.1.tgz#0e8f34854df7966b09304a18e808b23997bb9fc1" + integrity sha512-mUFwbeTqrVgDQxFveS+df2yfap6iuP20NAKAsBt5jDEoOTDew+zwLAOilHCeQJOVSvmgCX4ogqIrA0mnyr08yQ== + +abab@^2.0.0: + version "2.0.6" + resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" + integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA== + +acorn-globals@^4.1.0: + version "4.3.4" + resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.3.4.tgz#9fa1926addc11c97308c4e66d7add0d40c3272e7" + integrity sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A== + dependencies: + acorn "^6.0.1" + acorn-walk "^6.0.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== +<<<<<<< HEAD acorn@^8.15.0: version "8.15.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816" @@ -947,12 +2144,39 @@ ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== +======= +acorn-walk@^6.0.1: + version "6.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.2.0.tgz#123cb8f3b84c2171f1f7fb252615b1c78a6b1a8c" + integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA== + +acorn@^5.5.3: + version "5.7.4" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e" + integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg== + +acorn@^6.0.1: + version "6.4.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" + integrity sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ== + +acorn@^8.15.0, acorn@^8.16.0: + version "8.16.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.16.0.tgz#4ce79c89be40afe7afe8f3adb902a1f1ce9ac08a" + integrity sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw== + +ajv@^6.12.3, ajv@^6.14.0: + version "6.15.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.15.0.tgz#07e982c74626167aa7a2495c53817892d7139492" + integrity sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: fast-deep-equal "^3.1.1" fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.4.1" uri-js "^4.2.2" +<<<<<<< HEAD ansi-escapes@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" @@ -971,19 +2195,42 @@ ansi-regex@^6.0.1: integrity sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg== ansi-styles@^3.2.1: +======= +ansi-escapes@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" + integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== + +ansi-regex@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1" + integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw== + +ansi-regex@^4.0.0, ansi-regex@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" +<<<<<<< HEAD ansi-styles@^4.0.0, ansi-styles@^4.1.0: +======= +ansi-styles@^4.1.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: color-convert "^2.0.1" +<<<<<<< HEAD ansi-styles@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" @@ -993,6 +2240,15 @@ ansi-styles@^6.1.0: version "6.2.3" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.3.tgz#c044d5dcc521a076413472597a1acb1f103c4041" integrity sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg== +======= +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) anymatch@^3.1.3: version "3.1.3" @@ -1009,6 +2265,7 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +<<<<<<< HEAD argparse@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" @@ -1023,10 +2280,166 @@ babel-jest@30.2.0: "@types/babel__core" "^7.20.5" babel-plugin-istanbul "^7.0.1" babel-preset-jest "30.2.0" +======= +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA== + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q== + +array-buffer-byte-length@^1.0.1, array-buffer-byte-length@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz#384d12a37295aec3769ab022ad323a18a51ccf8b" + integrity sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw== + dependencies: + call-bound "^1.0.3" + is-array-buffer "^3.0.5" + +array-equal@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.2.tgz#a8572e64e822358271250b9156d20d96ef5dec04" + integrity sha512-gUHx76KtnhEgB3HOuFYiCm3FIdEs6ocM2asHvNTkfu/Y09qQVrrVVaOKENmS2KkSaGoxgXNqC+ZVtR/n0MOkSA== + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ== + +array.prototype.reduce@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/array.prototype.reduce/-/array.prototype.reduce-1.0.8.tgz#42f97f5078daedca687d4463fd3c05cbfd83da57" + integrity sha512-DwuEqgXFBwbmZSRqt3BpQigWNUoqw9Ml2dTWdF3B2zQlQX4OeUE0zyuzX0fX0IbTvjdkZbcBTU3idgpO78qkTw== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.4" + define-properties "^1.2.1" + es-abstract "^1.23.9" + es-array-method-boxes-properly "^1.0.0" + es-errors "^1.3.0" + es-object-atoms "^1.1.1" + is-string "^1.1.1" + +arraybuffer.prototype.slice@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz#9d760d84dbdd06d0cbf92c8849615a1a7ab3183c" + integrity sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ== + dependencies: + array-buffer-byte-length "^1.0.1" + call-bind "^1.0.8" + define-properties "^1.2.1" + es-abstract "^1.23.5" + es-errors "^1.3.0" + get-intrinsic "^1.2.6" + is-array-buffer "^3.0.4" + +asn1@~0.2.3: + version "0.2.6" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" + integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw== + +astral-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" + integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== + +async-function@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-function/-/async-function-1.0.0.tgz#509c9fca60eaf85034c6829838188e4e4c8ffb2b" + integrity sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA== + +async-limiter@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" + integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + +available-typed-arrays@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" + integrity sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ== + dependencies: + possible-typed-array-names "^1.0.0" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + integrity sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA== + +aws4@^1.8.0: + version "1.13.2" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.13.2.tgz#0aa167216965ac9474ccfa83892cfb6b3e1e52ef" + integrity sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw== + +babel-jest@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.9.0.tgz#3fc327cb8467b89d14d7bc70e315104a783ccd54" + integrity sha512-ntuddfyiN+EhMw58PTNL1ph4C9rECiQXjI4nMMBKBaNjXvqLdkXpPRcMSr4iyBrJg/+wz9brFUD6RhOAT6r4Iw== + dependencies: + "@jest/transform" "^24.9.0" + "@jest/types" "^24.9.0" + "@types/babel__core" "^7.1.0" + babel-plugin-istanbul "^5.1.0" + babel-preset-jest "^24.9.0" + chalk "^2.4.2" + slash "^2.0.0" + +babel-jest@^30.4.1: + version "30.4.1" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-30.4.1.tgz#63cba904438bbe64c4cf0acdea87b0a45cb809fc" + integrity sha512-fATAbM8piYxkiXQp3RBXmZHxZVNJZAVXXfyeyCN2Tida3+qJ8ea9UxhiJ2y4fLO90ZImKt6k9FlcH2+rLkJGhw== + dependencies: + "@jest/transform" "30.4.1" + "@types/babel__core" "^7.20.5" + babel-plugin-istanbul "^7.0.1" + babel-preset-jest "30.4.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) chalk "^4.1.2" graceful-fs "^4.2.11" slash "^3.0.0" +<<<<<<< HEAD +======= +babel-plugin-istanbul@^5.1.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.2.0.tgz#df4ade83d897a92df069c4d9a25cf2671293c854" + integrity sha512-5LphC0USA8t4i1zCtjbbNb6jJj/9+X6P37Qfirc/70EQ34xKlMW+a1RHGwxGI+SwWpNwZ27HqvzAobeqaXwiZw== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + find-up "^3.0.0" + istanbul-lib-instrument "^3.3.0" + test-exclude "^5.2.3" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) babel-plugin-istanbul@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-7.0.1.tgz#d8b518c8ea199364cf84ccc82de89740236daf92" @@ -1038,6 +2451,7 @@ babel-plugin-istanbul@^7.0.1: istanbul-lib-instrument "^6.0.2" test-exclude "^6.0.0" +<<<<<<< HEAD babel-plugin-jest-hoist@30.2.0: version "30.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-30.2.0.tgz#94c250d36b43f95900f3a219241e0f4648191ce2" @@ -1045,6 +2459,46 @@ babel-plugin-jest-hoist@30.2.0: dependencies: "@types/babel__core" "^7.20.5" +======= +babel-plugin-jest-hoist@30.4.0: + version "30.4.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-30.4.0.tgz#f7d6a6d8f435808b56b45a81dc4b61a39e36794a" + integrity sha512-9EdtWM/sSfXLOGLwSn+GS6pIXyBnL07/8gyJlwFXjWy4DxMOyItqyUT29d4lQiS380EZwYlX7/At4PgBS+m2aA== + dependencies: + "@types/babel__core" "^7.20.5" + +babel-plugin-jest-hoist@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.9.0.tgz#4f837091eb407e01447c8843cbec546d0002d756" + integrity sha512-2EMA2P8Vp7lG0RAzr4HXqtYwacfMErOuv1U3wrvxHX6rD1sV6xS3WXG3r8TRQ2r6w8OhvSdWt+z41hQNwNm3Xw== + dependencies: + "@types/babel__traverse" "^7.0.6" + +babel-plugin-polyfill-corejs2@^0.4.15: + version "0.4.17" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.17.tgz#198f970f1c99a856b466d1187e88ce30bd199d91" + integrity sha512-aTyf30K/rqAsNwN76zYrdtx8obu0E4KoUME29B1xj+B3WxgvWkp943vYQ+z8Mv3lw9xHXMHpvSPOBxzAkIa94w== + dependencies: + "@babel/compat-data" "^7.28.6" + "@babel/helper-define-polyfill-provider" "^0.6.8" + semver "^6.3.1" + +babel-plugin-polyfill-corejs3@^0.14.0: + version "0.14.2" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.14.2.tgz#6ac08d2f312affb70c4c69c0fbba4cb417ee5587" + integrity sha512-coWpDLJ410R781Npmn/SIBZEsAetR4xVi0SxLMXPaMO4lSf1MwnkGYMtkFxew0Dn8B3/CpbpYxN0JCgg8mn67g== + dependencies: + "@babel/helper-define-polyfill-provider" "^0.6.8" + core-js-compat "^3.48.0" + +babel-plugin-polyfill-regenerator@^0.6.6: + version "0.6.8" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.8.tgz#8a6bfd5dd54239362b3d06ce47ac52b2d95d7721" + integrity sha512-M762rNHfSF1EV3SLtnCJXFoQbbIIz0OyRwnCmV0KPC7qosSfCO0QLTSuJX3ayAebubhE6oYBAYPrBA5ljowaZg== + dependencies: + "@babel/helper-define-polyfill-provider" "^0.6.8" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) babel-preset-current-node-syntax@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.2.0.tgz#20730d6cdc7dda5d89401cab10ac6a32067acde6" @@ -1066,6 +2520,7 @@ babel-preset-current-node-syntax@^1.2.0: "@babel/plugin-syntax-private-property-in-object" "^7.14.5" "@babel/plugin-syntax-top-level-await" "^7.14.5" +<<<<<<< HEAD babel-preset-jest@30.2.0: version "30.2.0" resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-30.2.0.tgz#04717843e561347781d6d7f69c81e6bcc3ed11ce" @@ -1088,10 +2543,75 @@ brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== +======= +babel-preset-jest@30.4.0: + version "30.4.0" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-30.4.0.tgz#295486c2ec1127b3dc7d0d2adaa72a1dcaaafccd" + integrity sha512-lBY4jxsNmCnSiu7kquw8ZC9F4+XLMOKypT3RnNHPvU2Kpd4W0xaPuLr5ZkRyOsvLYAY4yaW1ZwTW4xB7NIiZzg== + dependencies: + babel-plugin-jest-hoist "30.4.0" + babel-preset-current-node-syntax "^1.2.0" + +babel-preset-jest@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.9.0.tgz#192b521e2217fb1d1f67cf73f70c336650ad3cdc" + integrity sha512-izTUuhE4TMfTRPF92fFwD2QfdXaZW08qvWTFCI51V8rW5x00UuPgc3ajRoWofXOuxjfcOM5zzSYsQS3H8KGCAg== + dependencies: + "@babel/plugin-syntax-object-rest-spread" "^7.0.0" + babel-plugin-jest-hoist "^24.9.0" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +balanced-match@^4.0.2: + version "4.0.4" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-4.0.4.tgz#bfb10662feed8196a2c62e7c68e17720c274179a" + integrity sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA== + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +baseline-browser-mapping@^2.10.12: + version "2.10.33" + resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.10.33.tgz#27c299b096404978831958d429f48390424c4f9b" + integrity sha512-bA6+tcSLpz2tIEdDXZPpPTIuxBcC4+w6SieaYyfigIa4h8GlFxbA17v22Vx3JUtuZQj9SgOsnbK+aTBzyDyEuw== + +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + integrity sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w== + dependencies: + tweetnacl "^0.14.3" + +bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + +brace-expansion@^1.1.7: + version "1.1.15" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.15.tgz#a6d90d54067236e5f42570a3b7378d594d9b7738" + integrity sha512-EwOCDEex4quD37XhqM3omwtMoJjr//isUZz1JopUNWms+4Z2ViyM/k1YIRePpoVNnQhENnxtFjLaxNHrT7xIUg== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: balanced-match "^1.0.0" concat-map "0.0.1" +<<<<<<< HEAD brace-expansion@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.2.tgz#54fc53237a613d854c7bd37463aad17df87214e7" @@ -1116,6 +2636,53 @@ browserslist@^4.24.0: electron-to-chromium "^1.5.263" node-releases "^2.0.27" update-browserslist-db "^1.2.0" +======= +brace-expansion@^5.0.5: + version "5.0.6" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-5.0.6.tgz#ec68fe0a641a29d8711579caf641d05bae1f2285" + integrity sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g== + dependencies: + balanced-match "^4.0.2" + +braces@^2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +browser-process-hrtime@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" + integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== + +browser-resolve@^1.11.3: + version "1.11.3" + resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.3.tgz#9b7cbb3d0f510e4cb86bdbd796124d28b5890af6" + integrity sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ== + dependencies: + resolve "1.1.7" + +browserslist@^4.24.0, browserslist@^4.28.1: + version "4.28.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.28.2.tgz#f50b65362ef48974ca9f50b3680566d786b811d2" + integrity sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg== + dependencies: + baseline-browser-mapping "^2.10.12" + caniuse-lite "^1.0.30001782" + electron-to-chromium "^1.5.328" + node-releases "^2.0.36" + update-browserslist-db "^1.2.3" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) bser@2.1.1: version "2.1.1" @@ -1125,6 +2692,7 @@ bser@2.1.1: node-int64 "^0.4.0" buffer-from@^1.0.0: +<<<<<<< HEAD version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== @@ -1135,15 +2703,68 @@ callsites@^3.0.0: integrity sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw== callsites@^3.1.0: +======= + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz#4b5428c222be985d79c3d82657479dbe0b59b2d6" + integrity sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + +call-bind@^1.0.7, call-bind@^1.0.8, call-bind@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.9.tgz#39a644700c80bc7d0ca9102fc6d1d43b2fd7eee7" + integrity sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ== + dependencies: + call-bind-apply-helpers "^1.0.2" + es-define-property "^1.0.1" + get-intrinsic "^1.3.0" + set-function-length "^1.2.2" + +call-bound@^1.0.2, call-bound@^1.0.3, call-bound@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.4.tgz#238de935d2a2a692928c538c7ccfa91067fd062a" + integrity sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg== + dependencies: + call-bind-apply-helpers "^1.0.2" + get-intrinsic "^1.3.0" + +callsites@^3.0.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== +<<<<<<< HEAD camelcase@^5.3.1: +======= +camelcase@^5.0.0, camelcase@^5.3.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== +<<<<<<< HEAD camelcase@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" @@ -1155,6 +2776,26 @@ caniuse-lite@^1.0.30001759: integrity sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw== chalk@^2.0.0: +======= +caniuse-lite@^1.0.30001782: + version "1.0.30001793" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001793.tgz#238887ddf5fcfc8c36d872394d0a78a517312a72" + integrity sha512-iwSsYWaCOoh26cV8NwNRViHlrfUvYsHDfRVcbtmw0Kg6PJIZZXwMkj1442FYLBGkeUf1juAsU3DTfxW579mrPA== + +capture-exit@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" + integrity sha512-PiT/hQmTonHhl/HFGN+Lx3JJUznrVYJ3+AQsnthneZbvW7x+f08Tk7yLJTLEOUvBTbduLeeBkxEaYXUOUrRq6g== + dependencies: + rsvp "^4.8.4" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== + +chalk@^2.0.1, chalk@^2.4.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1163,7 +2804,11 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +<<<<<<< HEAD chalk@^4.0.0, chalk@^4.1.2: +======= +chalk@^4.1.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1171,6 +2816,7 @@ chalk@^4.0.0, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" +<<<<<<< HEAD char-regex@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" @@ -1194,16 +2840,58 @@ cliui@^8.0.1: string-width "^4.2.0" strip-ansi "^6.0.1" wrap-ansi "^7.0.0" +======= +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + +ci-info@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-4.4.0.tgz#7d54eff9f54b45b62401c26032696eb59c8bd18c" + integrity sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg== + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" +<<<<<<< HEAD integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= collect-v8-coverage@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz#cc1f01eb8d02298cbc9a437c74c70ab4e5210b80" integrity sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw== +======= + integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw== + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) color-convert@^1.9.0: version "1.9.3" @@ -1222,24 +2910,84 @@ color-convert@^2.0.1: color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" +<<<<<<< HEAD integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= +======= + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +<<<<<<< HEAD concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= +======= +combined-stream@^1.0.6, combined-stream@~1.0.6: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +component-emitter@^1.2.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.1.tgz#ef1d5796f7d93f135ee6fb684340b26403c97d17" + integrity sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +convert-source-map@^1.4.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" + integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) convert-source-map@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== +<<<<<<< HEAD cross-spawn@^7.0.3, cross-spawn@^7.0.6: +======= +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw== + +core-js-compat@^3.48.0: + version "3.49.0" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.49.0.tgz#06145447d92f4aaf258a0c44f24b47afaeaffef6" + integrity sha512-VQXt1jr9cBz03b331DFDCCP90b3fanciLkgiOoy8SBHy06gNf+vQ1A3WFLqG7I8TipYIKeYK9wxd0tUrvHcOZA== + dependencies: + browserslist "^4.28.1" + +core-util-is@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== + +cross-spawn@^6.0.0: + version "6.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.6.tgz#30d0efa0712ddb7eb5a76e1e8721bffafa6b5d57" + integrity sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +cross-spawn@^7.0.6: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.0.6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== @@ -1248,6 +2996,7 @@ cross-spawn@^7.0.3, cross-spawn@^7.0.6: shebang-command "^2.0.0" which "^2.0.1" +<<<<<<< HEAD debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" @@ -1256,22 +3005,102 @@ debug@^4.1.0, debug@^4.1.1: ms "^2.1.1" debug@^4.3.1, debug@^4.3.2: +======= +cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0": + version "0.3.8" + resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" + integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg== + +cssstyle@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-1.4.0.tgz#9d31328229d3c565c61e586b02041a28fccdccf1" + integrity sha512-GBrLZYZ4X4x6/QEoBnIrqb8B/f5l4+8me2dkom/j1Gtbxy0kBv6OGzKuAsGM75bkGwGAFkt56Iwg28S3XTZgSA== + dependencies: + cssom "0.3.x" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + integrity sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g== + dependencies: + assert-plus "^1.0.0" + +data-urls@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-1.1.0.tgz#15ee0582baa5e22bb59c77140da8f9c76963bbfe" + integrity sha512-YTWYI9se1P55u58gL5GkQHW4P6VJBJ5iBT+B5a7i2Tjadhv52paJG0qHX4A0OR6/t52odI64KP2YvFpkDOi3eQ== + dependencies: + abab "^2.0.0" + whatwg-mimetype "^2.2.0" + whatwg-url "^7.0.0" + +data-view-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/data-view-buffer/-/data-view-buffer-1.0.2.tgz#211a03ba95ecaf7798a8c7198d79536211f88570" + integrity sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ== + dependencies: + call-bound "^1.0.3" + es-errors "^1.3.0" + is-data-view "^1.0.2" + +data-view-byte-length@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz#9e80f7ca52453ce3e93d25a35318767ea7704735" + integrity sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ== + dependencies: + call-bound "^1.0.3" + es-errors "^1.3.0" + is-data-view "^1.0.2" + +data-view-byte-offset@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz#068307f9b71ab76dbbe10291389e020856606191" + integrity sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + is-data-view "^1.0.1" + +debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.4.3: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.4.3" resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a" integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA== dependencies: ms "^2.1.3" +<<<<<<< HEAD dedent@^1.6.0: version "1.7.0" resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.7.0.tgz#c1f9445335f0175a96587be245a282ff451446ca" integrity sha512-HGFtf8yhuhGhqO07SV79tRp+br4MnbdjeVxotpn1QBl30pcLLCQjX5b2295ll0fv8RKDKsmWYrl05usHM9CewQ== deep-is@^0.1.3: +======= +decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== + +decode-uri-component@^0.2.0: + version "0.2.2" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" + integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== + +deep-is@^0.1.3, deep-is@~0.1.3: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== +<<<<<<< HEAD deepmerge@^4.3.1: version "4.3.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" @@ -1315,6 +3144,213 @@ error-ex@^1.3.1: is-arrayish "^0.2.1" escalade@^3.1.1, escalade@^3.2.0: +======= +define-data-property@^1.0.1, define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +define-properties@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.1.tgz#10781cc616eb951a80a034bafcaa7377f6af2b6c" + integrity sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg== + dependencies: + define-data-property "^1.0.1" + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA== + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA== + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + +detect-newline@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" + integrity sha512-CwffZFvlJffUg9zZA0uqrjQayUTC8ob94pnr5sFwaVv3IOmkfUHcWH+jXaQK3askE51Cqe8/9Ql/0uXNwqZ8Zg== + +diff-sequences@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5" + integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew== + +domexception@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90" + integrity sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug== + dependencies: + webidl-conversions "^4.0.2" + +dunder-proto@^1.0.0, dunder-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" + integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== + dependencies: + call-bind-apply-helpers "^1.0.1" + es-errors "^1.3.0" + gopd "^1.2.0" + +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + integrity sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw== + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +electron-to-chromium@^1.5.328: + version "1.5.365" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.365.tgz#65ccc724af6312d34c5b7e8faa0b57a62d5d311d" + integrity sha512-xfip4u1QF1s+URFqpA6N+OeFpDGpN7VJz1f3MO3bVL0QYBjpGiZ5/Of7kugvM+o8TTqmanUlviHN3c8M9vYWCw== + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +end-of-stream@^1.1.0: + version "1.4.5" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.5.tgz#7344d711dea40e0b74abc2ed49778743ccedb08c" + integrity sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg== + dependencies: + once "^1.4.0" + +error-ex@^1.3.1: + version "1.3.4" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.4.tgz#b3a8d8bb6f92eecc1629e3e27d3c8607a8a32414" + integrity sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ== + dependencies: + is-arrayish "^0.2.1" + +es-abstract@^1.23.5, es-abstract@^1.23.9, es-abstract@^1.24.0: + version "1.24.2" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.24.2.tgz#2dbd38c180735ee983f77585140a2706a963ed9a" + integrity sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg== + dependencies: + array-buffer-byte-length "^1.0.2" + arraybuffer.prototype.slice "^1.0.4" + available-typed-arrays "^1.0.7" + call-bind "^1.0.8" + call-bound "^1.0.4" + data-view-buffer "^1.0.2" + data-view-byte-length "^1.0.2" + data-view-byte-offset "^1.0.1" + es-define-property "^1.0.1" + es-errors "^1.3.0" + es-object-atoms "^1.1.1" + es-set-tostringtag "^2.1.0" + es-to-primitive "^1.3.0" + function.prototype.name "^1.1.8" + get-intrinsic "^1.3.0" + get-proto "^1.0.1" + get-symbol-description "^1.1.0" + globalthis "^1.0.4" + gopd "^1.2.0" + has-property-descriptors "^1.0.2" + has-proto "^1.2.0" + has-symbols "^1.1.0" + hasown "^2.0.2" + internal-slot "^1.1.0" + is-array-buffer "^3.0.5" + is-callable "^1.2.7" + is-data-view "^1.0.2" + is-negative-zero "^2.0.3" + is-regex "^1.2.1" + is-set "^2.0.3" + is-shared-array-buffer "^1.0.4" + is-string "^1.1.1" + is-typed-array "^1.1.15" + is-weakref "^1.1.1" + math-intrinsics "^1.1.0" + object-inspect "^1.13.4" + object-keys "^1.1.1" + object.assign "^4.1.7" + own-keys "^1.0.1" + regexp.prototype.flags "^1.5.4" + safe-array-concat "^1.1.3" + safe-push-apply "^1.0.0" + safe-regex-test "^1.1.0" + set-proto "^1.0.0" + stop-iteration-iterator "^1.1.0" + string.prototype.trim "^1.2.10" + string.prototype.trimend "^1.0.9" + string.prototype.trimstart "^1.0.8" + typed-array-buffer "^1.0.3" + typed-array-byte-length "^1.0.3" + typed-array-byte-offset "^1.0.4" + typed-array-length "^1.0.7" + unbox-primitive "^1.1.0" + which-typed-array "^1.1.19" + +es-array-method-boxes-properly@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz#873f3e84418de4ee19c5be752990b2e44718d09e" + integrity sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA== + +es-define-property@^1.0.0, es-define-property@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" + integrity sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g== + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/es-object-atoms/-/es-object-atoms-1.1.2.tgz#a2d0b373205724dfa525d23b0c3e1b1ca582c99b" + integrity sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw== + dependencies: + es-errors "^1.3.0" + +es-set-tostringtag@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz#f31dbbe0c183b00a6d26eb6325c810c0fd18bd4d" + integrity sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA== + dependencies: + es-errors "^1.3.0" + get-intrinsic "^1.2.6" + has-tostringtag "^1.0.2" + hasown "^2.0.2" + +es-to-primitive@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.3.0.tgz#96c89c82cc49fd8794a24835ba3e1ff87f214e18" + integrity sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g== + dependencies: + is-callable "^1.2.7" + is-date-object "^1.0.5" + is-symbol "^1.0.4" + +escalade@^3.2.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.2.0" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== @@ -1322,7 +3358,11 @@ escalade@^3.1.1, escalade@^3.2.0: escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" +<<<<<<< HEAD integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +======= + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) escape-string-regexp@^2.0.0: version "2.0.0" @@ -1334,11 +3374,33 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +<<<<<<< HEAD eslint-scope@^8.4.0: version "8.4.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.4.0.tgz#88e646a207fad61436ffa39eb505147200655c82" integrity sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg== dependencies: +======= +escodegen@^1.9.1: + version "1.14.3" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" + integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== + dependencies: + esprima "^4.0.1" + estraverse "^4.2.0" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.6.1" + +eslint-scope@^9.1.2: + version "9.1.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-9.1.2.tgz#b9de6ace2fab1cff24d2e58d85b74c8fcea39802" + integrity sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ== + dependencies: + "@types/esrecurse" "^4.3.1" + "@types/estree" "^1.0.8" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) esrecurse "^4.3.0" estraverse "^5.2.0" @@ -1352,6 +3414,7 @@ eslint-visitor-keys@^4.2.1: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz#4cfea60fe7dd0ad8e816e1ed026c1d5251b512c1" integrity sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ== +<<<<<<< HEAD eslint@^9.39.2: version "9.39.2" resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.39.2.tgz#cb60e6d16ab234c0f8369a3fe7cc87967faf4b6c" @@ -1365,10 +3428,29 @@ eslint@^9.39.2: "@eslint/eslintrc" "^3.3.1" "@eslint/js" "9.39.2" "@eslint/plugin-kit" "^0.4.1" +======= +eslint-visitor-keys@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz#9e3c9489697824d2d4ce3a8ad12628f91e9f59be" + integrity sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA== + +eslint@^10.0.0: + version "10.4.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-10.4.1.tgz#f6640b176e0912246d9ddbf8fcfa5e8b7f02445a" + integrity sha512-AyIKhnOBuOAdueD7RB3xB+YeAWScb9jHsJBgH2Hcde8InP5JYhqrRR6iTMHyTEwgENK54Cp44e4v8BwNhsuHuw== + dependencies: + "@eslint-community/eslint-utils" "^4.8.0" + "@eslint-community/regexpp" "^4.12.2" + "@eslint/config-array" "^0.23.5" + "@eslint/config-helpers" "^0.6.0" + "@eslint/core" "^1.2.1" + "@eslint/plugin-kit" "^0.7.2" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@humanfs/node" "^0.16.6" "@humanwhocodes/module-importer" "^1.0.1" "@humanwhocodes/retry" "^0.4.2" "@types/estree" "^1.0.6" +<<<<<<< HEAD ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.6" @@ -1378,6 +3460,16 @@ eslint@^9.39.2: eslint-visitor-keys "^4.2.1" espree "^10.4.0" esquery "^1.5.0" +======= + ajv "^6.14.0" + cross-spawn "^7.0.6" + debug "^4.3.2" + escape-string-regexp "^4.0.0" + eslint-scope "^9.1.2" + eslint-visitor-keys "^5.0.1" + espree "^11.2.0" + esquery "^1.7.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^8.0.0" @@ -1387,12 +3479,20 @@ eslint@^9.39.2: imurmurhash "^0.1.4" is-glob "^4.0.0" json-stable-stringify-without-jsonify "^1.0.1" +<<<<<<< HEAD lodash.merge "^4.6.2" minimatch "^3.1.2" natural-compare "^1.4.0" optionator "^0.9.3" espree@^10.0.1, espree@^10.4.0: +======= + minimatch "^10.2.4" + natural-compare "^1.4.0" + optionator "^0.9.3" + +espree@^10.4.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "10.4.0" resolved "https://registry.yarnpkg.com/espree/-/espree-10.4.0.tgz#d54f4949d4629005a1fa168d937c3ff1f7e2a837" integrity sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ== @@ -1401,15 +3501,35 @@ espree@^10.0.1, espree@^10.4.0: acorn-jsx "^5.3.2" eslint-visitor-keys "^4.2.1" +<<<<<<< HEAD esprima@^4.0.0: +======= +espree@^11.2.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-11.2.0.tgz#01d5e47dc332aaba3059008362454a8cc34ccaa5" + integrity sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw== + dependencies: + acorn "^8.16.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^5.0.1" + +esprima@^4.0.0, esprima@^4.0.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== +<<<<<<< HEAD esquery@^1.5.0: version "1.6.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== +======= +esquery@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.7.0.tgz#08d048f261f0ddedb5bae95f46809463d9c9496d" + integrity sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: estraverse "^5.1.0" @@ -1420,12 +3540,22 @@ esrecurse@^4.3.0: dependencies: estraverse "^5.2.0" +<<<<<<< HEAD estraverse@^5.1.0, estraverse@^5.2.0: +======= +estraverse@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "5.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== esutils@^2.0.2: +<<<<<<< HEAD version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= @@ -1461,28 +3591,137 @@ expect@30.2.0: jest-message-util "30.2.0" jest-mock "30.2.0" jest-util "30.2.0" +======= + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +exec-sh@^0.3.2: + version "0.3.6" + resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.3.6.tgz#ff264f9e325519a60cb5e273692943483cca63bc" + integrity sha512-nQn+hI3yp+oD0huYhKwvYI32+JFeq+XkNcD1GAo3Y/MjxsfVGmrrzrnzjWiNY6f+pUCP440fThsFh5gZrRAU/w== + +execa@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== + dependencies: + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +exit@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA== + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +expect@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-24.9.0.tgz#b75165b4817074fa4a157794f46fe9f1ba15b6ca" + integrity sha512-wvVAx8XIol3Z5m9zvZXiyZOQ+sRJqNTIm6sGjdWlaZIeupQGO3WbYI+15D/AmEwZywL6wtJkbAbJtzkOfBuR0Q== + dependencies: + "@jest/types" "^24.9.0" + ansi-styles "^3.2.0" + jest-get-type "^24.9.0" + jest-matcher-utils "^24.9.0" + jest-message-util "^24.9.0" + jest-regex-util "^24.9.0" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug== + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q== + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + integrity sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g== + +extsprintf@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07" + integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +<<<<<<< HEAD fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= fast-json-stable-stringify@^2.1.0: +======= +fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== +<<<<<<< HEAD fast-levenshtein@^2.0.6: +======= +fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== +<<<<<<< HEAD fb-watchman@^2.0.2: +======= +fb-watchman@^2.0.0, fb-watchman@^2.0.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.2" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== @@ -1496,6 +3735,7 @@ file-entry-cache@^8.0.0: dependencies: flat-cache "^4.0.0" +<<<<<<< HEAD fill-range@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" @@ -1504,6 +3744,31 @@ fill-range@^7.1.1: to-regex-range "^5.0.1" find-up@^4.0.0, find-up@^4.1.0: +======= +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ== + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +find-up@^4.1.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== @@ -1528,6 +3793,7 @@ flat-cache@^4.0.0: keyv "^4.5.4" flatted@^3.2.9: +<<<<<<< HEAD version "3.3.3" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358" integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== @@ -1539,36 +3805,177 @@ foreground-child@^3.1.0: dependencies: cross-spawn "^7.0.6" signal-exit "^4.0.1" +======= + version "3.4.2" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.4.2.tgz#f5c23c107f0f37de8dbdf24f13722b3b98d52726" + integrity sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA== + +for-each@^0.3.3, for-each@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.5.tgz#d650688027826920feeb0af747ee7b9421a41d47" + integrity sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg== + dependencies: + is-callable "^1.2.7" + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ== + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== + +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA== + dependencies: + map-cache "^0.2.2" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" +<<<<<<< HEAD integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= +======= + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@^1.2.7: + version "1.2.13" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.13.tgz#f325cb0455592428bcf11b383370ef70e3bfcc38" + integrity sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw== + dependencies: + bindings "^1.5.0" + nan "^2.12.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) fsevents@^2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== +<<<<<<< HEAD +======= +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +function.prototype.name@^1.1.6, function.prototype.name@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.8.tgz#e68e1df7b259a5c949eeef95cdbde53edffabb78" + integrity sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.3" + define-properties "^1.2.1" + functions-have-names "^1.2.3" + hasown "^2.0.2" + is-callable "^1.2.7" + +functions-have-names@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== + +generator-function@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/generator-function/-/generator-function-2.0.1.tgz#0e75dd410d1243687a0ba2e951b94eedb8f737a2" + integrity sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g== + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== +<<<<<<< HEAD get-caller-file@^2.0.5: +======= +get-caller-file@^2.0.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== +<<<<<<< HEAD +======= +get-intrinsic@^1.2.4, get-intrinsic@^1.2.5, get-intrinsic@^1.2.6, get-intrinsic@^1.2.7, get-intrinsic@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" + integrity sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ== + dependencies: + call-bind-apply-helpers "^1.0.2" + es-define-property "^1.0.1" + es-errors "^1.3.0" + es-object-atoms "^1.1.1" + function-bind "^1.1.2" + get-proto "^1.0.1" + gopd "^1.2.0" + has-symbols "^1.1.0" + hasown "^2.0.2" + math-intrinsics "^1.1.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== +<<<<<<< HEAD get-stream@^6.0.0: version "6.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== +======= +get-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" + integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== + dependencies: + dunder-proto "^1.0.1" + es-object-atoms "^1.0.0" + +get-stream@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + +get-symbol-description@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.1.0.tgz#7bdd54e0befe8ffc9f3b4e203220d9f1e881b6ee" + integrity sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg== + dependencies: + call-bound "^1.0.3" + es-errors "^1.3.0" + get-intrinsic "^1.2.6" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA== + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + integrity sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng== + dependencies: + assert-plus "^1.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) glob-parent@^6.0.2: version "6.0.2" @@ -1577,6 +3984,7 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +<<<<<<< HEAD glob@^10.3.10: version "10.5.0" resolved "https://registry.yarnpkg.com/glob/-/glob-10.5.0.tgz#8ec0355919cd3338c28428a23d4f24ecc5fe738c" @@ -1590,6 +3998,9 @@ glob@^10.3.10: path-scurry "^1.11.1" glob@^7.1.4: +======= +glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -1601,41 +4012,191 @@ glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" +<<<<<<< HEAD globals@^14.0.0: version "14.0.0" resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== graceful-fs@^4.2.11: +======= +globals@^17.6.0: + version "17.6.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-17.6.0.tgz#0f0be018d5cca8690e6375ead1f65c4bb96191fc" + integrity sha512-sepffkT8stwnIYbsMBpoCHJuJM5l98FUF2AnE07hfvE0m/qp3R586hw4jF4uadbhvg1ooIdzuu7CsfD2jzCaNA== + +globalthis@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.4.tgz#7430ed3a975d97bfb59bcce41f5cabbafa651236" + integrity sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ== + dependencies: + define-properties "^1.2.1" + gopd "^1.0.1" + +gopd@^1.0.1, gopd@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" + integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== + +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.2.11: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== +<<<<<<< HEAD has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +======= +growly@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" + integrity sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw== + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q== + +har-validator@~5.1.3: + version "5.1.5" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" + integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== + dependencies: + ajv "^6.12.3" + har-schema "^2.0.0" + +has-bigints@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.1.0.tgz#28607e965ac967e03cd2a2c70a2636a1edad49fe" + integrity sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== +<<<<<<< HEAD +======= +has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.2.0.tgz#5de5a6eabd95fdffd9818b43055e8065e39fe9d5" + integrity sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ== + dependencies: + dunder-proto "^1.0.0" + +has-symbols@^1.0.3, has-symbols@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" + integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== + +has-tostringtag@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz#2cdc42d40bef2e5b4eeab7c01a73c54ce7ab5abc" + integrity sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw== + dependencies: + has-symbols "^1.0.3" + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q== + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw== + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ== + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ== + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +hasown@^2.0.0, hasown@^2.0.2, hasown@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.4.tgz#8c62d8cb90beb2aad5d0a5b67581ad9854c3f003" + integrity sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A== + dependencies: + function-bind "^1.1.2" + +hosted-git-info@^2.1.4: + version "2.8.9" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" + integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== + +html-encoding-sniffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8" + integrity sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw== + dependencies: + whatwg-encoding "^1.0.1" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) html-escaper@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== +<<<<<<< HEAD human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +======= +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) ignore@^5.2.0: version "5.3.2" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5" integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g== +<<<<<<< HEAD import-fresh@^3.2.1: version "3.3.1" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.1.tgz#9cecb56503c0ada1f2741dbbd6546e4b13b57ccf" @@ -1651,45 +4212,236 @@ import-local@^3.2.0: dependencies: pkg-dir "^4.2.0" resolve-cwd "^3.0.0" +======= +import-local@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" + integrity sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ== + dependencies: + pkg-dir "^3.0.0" + resolve-cwd "^2.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" +<<<<<<< HEAD integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= +======= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" +<<<<<<< HEAD integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= +======= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: once "^1.3.0" wrappy "1" inherits@2: +<<<<<<< HEAD version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +======= + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +internal-slot@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.1.0.tgz#1eac91762947d2f7056bc838d93e13b2e9604961" + integrity sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw== + dependencies: + es-errors "^1.3.0" + hasown "^2.0.2" + side-channel "^1.1.0" + +invariant@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + +is-accessor-descriptor@^1.0.1, is-accessor-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.2.tgz#fff67ca43f7acc57edbc557335c2e2c62b98e41e" + integrity sha512-AIbwAcazqP3R65dGvqk1V+a+vE5Fg1yu/ZKMOiBWSUIXXiwQkYmXQcVa2O0nh0tSDKDFKxG2mY7dB1Sr4hEP1g== + dependencies: + hasown "^2.0.3" + +is-array-buffer@^3.0.4, is-array-buffer@^3.0.5: + version "3.0.5" + resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.5.tgz#65742e1e687bd2cc666253068fd8707fe4d44280" + integrity sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.3" + get-intrinsic "^1.2.6" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" +<<<<<<< HEAD integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= +======= + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== + +is-async-function@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-async-function/-/is-async-function-2.1.1.tgz#3e69018c8e04e73b738793d020bfe884b9fd3523" + integrity sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ== + dependencies: + async-function "^1.0.0" + call-bound "^1.0.3" + get-proto "^1.0.1" + has-tostringtag "^1.0.2" + safe-regex-test "^1.1.0" + +is-bigint@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.1.0.tgz#dda7a3445df57a42583db4228682eba7c4170672" + integrity sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ== + dependencies: + has-bigints "^1.0.2" + +is-boolean-object@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.2.2.tgz#7067f47709809a393c71ff5bb3e135d8a9215d9e" + integrity sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A== + dependencies: + call-bound "^1.0.3" + has-tostringtag "^1.0.2" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-callable@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== + +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + +is-core-module@^2.16.1: + version "2.16.2" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.16.2.tgz#3e07450a8080ebce3fbf0cac494f4d2ab324e082" + integrity sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA== + dependencies: + hasown "^2.0.3" + +is-data-descriptor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.1.tgz#2109164426166d32ea38c405c1e0945d9e6a4eeb" + integrity sha512-bc4NlCDiCr28U4aEsQ3Qs2491gVq4V8G7MQyws968ImqjKuYtTJXrl7Vq7jsN7Ly/C3xj5KWFrY7sHNeDkAzXw== + dependencies: + hasown "^2.0.0" + +is-data-view@^1.0.1, is-data-view@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-data-view/-/is-data-view-1.0.2.tgz#bae0a41b9688986c2188dda6657e56b8f9e63b8e" + integrity sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw== + dependencies: + call-bound "^1.0.2" + get-intrinsic "^1.2.6" + is-typed-array "^1.1.13" + +is-date-object@^1.0.5, is-date-object@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.1.0.tgz#ad85541996fc7aa8b2729701d27b7319f95d82f7" + integrity sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg== + dependencies: + call-bound "^1.0.2" + has-tostringtag "^1.0.2" + +is-descriptor@^0.1.0: + version "0.1.8" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.8.tgz#c1ea9d2fb20cd51e812e438a455a7f78443a5a17" + integrity sha512-SceYGWXvdqlWa/OnQ5FQuV+NxvNmMRhMw/w9AHkH71hTzveND4BTYgvp16g+oITK47qbOl/3D0bl0iygehWAWQ== + dependencies: + is-accessor-descriptor "^1.0.1" + is-data-descriptor "^1.0.1" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.4.tgz#7934d74f609d0dbe754b80186d501026a78739b5" + integrity sha512-bv5z95W0dDtLfKwDfkTNxaRxmISBD3eQBKJeVxv2AQ7MjuUnDNG7cIQqvFtMOUYhsILWHhMayWdoGqNqYYYjww== + dependencies: + is-accessor-descriptor "^1.0.2" + is-data-descriptor "^1.0.1" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw== + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== +<<<<<<< HEAD is-fullwidth-code-point@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== is-generator-fn@^2.1.0: - version "2.1.0" +======= +is-finalizationregistry@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz#eefdcdc6c94ddd0674d9c85887bf93f944a97c90" + integrity sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg== + dependencies: + call-bound "^1.0.3" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w== + +is-generator-fn@^2.0.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) + version "2.1.0" resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== +<<<<<<< HEAD +======= +is-generator-function@^1.0.10: + version "1.1.2" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.1.2.tgz#ae3b61e3d5ea4e4839b90bad22b02335051a17d5" + integrity sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA== + dependencies: + call-bound "^1.0.4" + generator-function "^2.0.0" + get-proto "^1.0.1" + has-tostringtag "^1.0.2" + safe-regex-test "^1.1.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) is-glob@^4.0.0, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" @@ -1697,6 +4449,7 @@ is-glob@^4.0.0, is-glob@^4.0.3: dependencies: is-extglob "^2.1.1" +<<<<<<< HEAD is-number@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" @@ -1706,18 +4459,192 @@ is-stream@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== +======= +is-map@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.3.tgz#ede96b7fe1e270b3c4465e3a465658764926d62e" + integrity sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw== + +is-negative-zero@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.3.tgz#ced903a027aca6381b777a5743069d7376a49747" + integrity sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw== + +is-number-object@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.1.1.tgz#144b21e95a1bc148205dcc2814a9134ec41b2541" + integrity sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw== + dependencies: + call-bound "^1.0.3" + has-tostringtag "^1.0.2" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg== + dependencies: + kind-of "^3.0.2" + +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-regex@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.2.1.tgz#76d70a3ed10ef9be48eb577887d74205bf0cad22" + integrity sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g== + dependencies: + call-bound "^1.0.2" + gopd "^1.2.0" + has-tostringtag "^1.0.2" + hasown "^2.0.2" + +is-set@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.3.tgz#8ab209ea424608141372ded6e0cb200ef1d9d01d" + integrity sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg== + +is-shared-array-buffer@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz#9b67844bd9b7f246ba0708c3a93e34269c774f6f" + integrity sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A== + dependencies: + call-bound "^1.0.3" + +is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ== + +is-string@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.1.1.tgz#92ea3f3d5c5b6e039ca8677e5ac8d07ea773cbb9" + integrity sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA== + dependencies: + call-bound "^1.0.3" + has-tostringtag "^1.0.2" + +is-symbol@^1.0.4, is-symbol@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.1.1.tgz#f47761279f532e2b05a7024a7506dbbedacd0634" + integrity sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w== + dependencies: + call-bound "^1.0.2" + has-symbols "^1.1.0" + safe-regex-test "^1.1.0" + +is-typed-array@^1.1.13, is-typed-array@^1.1.14, is-typed-array@^1.1.15: + version "1.1.15" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.15.tgz#4bfb4a45b61cee83a5a46fba778e4e8d59c0ce0b" + integrity sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ== + dependencies: + which-typed-array "^1.1.16" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== + +is-weakmap@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.2.tgz#bf72615d649dfe5f699079c54b83e47d1ae19cfd" + integrity sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w== + +is-weakref@^1.0.2, is-weakref@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.1.1.tgz#eea430182be8d64174bd96bffbc46f21bf3f9293" + integrity sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew== + dependencies: + call-bound "^1.0.3" + +is-weakset@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.4.tgz#c9f5deb0bc1906c6d6f1027f284ddf459249daca" + integrity sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ== + dependencies: + call-bound "^1.0.3" + get-intrinsic "^1.2.6" + +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" + integrity sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw== + +isarray@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" +<<<<<<< HEAD integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: +======= + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA== + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + integrity sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g== + +istanbul-lib-coverage@^2.0.2, istanbul-lib-coverage@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz#675f0ab69503fad4b1d849f736baaca803344f49" + integrity sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA== + +istanbul-lib-coverage@^3.2.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.2.2" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756" integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg== +<<<<<<< HEAD istanbul-lib-instrument@^6.0.0, istanbul-lib-instrument@^6.0.2: +======= +istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz#a5f63d91f0bbc0c3e479ef4c5de027335ec6d630" + integrity sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA== + dependencies: + "@babel/generator" "^7.4.0" + "@babel/parser" "^7.4.3" + "@babel/template" "^7.4.0" + "@babel/traverse" "^7.4.3" + "@babel/types" "^7.4.0" + istanbul-lib-coverage "^2.0.5" + semver "^6.0.0" + +istanbul-lib-instrument@^6.0.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "6.0.3" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz#fa15401df6c15874bcb2105f773325d78c666765" integrity sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q== @@ -1728,6 +4655,7 @@ istanbul-lib-instrument@^6.0.0, istanbul-lib-instrument@^6.0.2: istanbul-lib-coverage "^3.2.0" semver "^7.5.4" +<<<<<<< HEAD istanbul-lib-report@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" @@ -1891,18 +4819,168 @@ jest-haste-map@30.2.0: integrity sha512-sQA/jCb9kNt+neM0anSj6eZhLZUIhQgwDt7cPGjumgLM4rXsfb9kpnlacmvZz3Q5tb80nS+oG/if+NBKrHC+Xw== dependencies: "@jest/types" "30.2.0" +======= +istanbul-lib-report@^2.0.4: + version "2.0.8" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz#5a8113cd746d43c4889eba36ab10e7d50c9b4f33" + integrity sha512-fHBeG573EIihhAblwgxrSenp0Dby6tJMFR/HvlerBsrCTD5bkUuoNtn3gVh29ZCS824cGGBPn7Sg7cNk+2xUsQ== + dependencies: + istanbul-lib-coverage "^2.0.5" + make-dir "^2.1.0" + supports-color "^6.1.0" + +istanbul-lib-source-maps@^3.0.1: + version "3.0.6" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz#284997c48211752ec486253da97e3879defba8c8" + integrity sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw== + dependencies: + debug "^4.1.1" + istanbul-lib-coverage "^2.0.5" + make-dir "^2.1.0" + rimraf "^2.6.3" + source-map "^0.6.1" + +istanbul-reports@^2.2.6: + version "2.2.7" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-2.2.7.tgz#5d939f6237d7b48393cc0959eab40cd4fd056931" + integrity sha512-uu1F/L1o5Y6LzPVSVZXNOoD/KXpJue9aeLRd0sM9uMXfZvzomB0WxVamWb5ue8kA2vVWEmW7EG+A5n3f1kqHKg== + dependencies: + html-escaper "^2.0.0" + +jest-changed-files@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-24.9.0.tgz#08d8c15eb79a7fa3fc98269bc14b451ee82f8039" + integrity sha512-6aTWpe2mHF0DhL28WjdkO8LyGjs3zItPET4bMSeXU6T3ub4FPMw+mcOcbdGXQOAfmLcxofD23/5Bl9Z4AkFwqg== + dependencies: + "@jest/types" "^24.9.0" + execa "^1.0.0" + throat "^4.0.0" + +jest-cli@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-24.9.0.tgz#ad2de62d07472d419c6abc301fc432b98b10d2af" + integrity sha512-+VLRKyitT3BWoMeSUIHRxV/2g8y9gw91Jh5z2UmXZzkZKpbC08CSehVxgHUwTpy+HwGcns/tqafQDJW7imYvGg== + dependencies: + "@jest/core" "^24.9.0" + "@jest/test-result" "^24.9.0" + "@jest/types" "^24.9.0" + chalk "^2.0.1" + exit "^0.1.2" + import-local "^2.0.0" + is-ci "^2.0.0" + jest-config "^24.9.0" + jest-util "^24.9.0" + jest-validate "^24.9.0" + prompts "^2.0.1" + realpath-native "^1.1.0" + yargs "^13.3.0" + +jest-config@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-24.9.0.tgz#fb1bbc60c73a46af03590719efa4825e6e4dd1b5" + integrity sha512-RATtQJtVYQrp7fvWg6f5y3pEFj9I+H8sWw4aKxnDZ96mob5i5SD6ZEGWgMLXQ4LE8UurrjbdlLWdUeo+28QpfQ== + dependencies: + "@babel/core" "^7.1.0" + "@jest/test-sequencer" "^24.9.0" + "@jest/types" "^24.9.0" + babel-jest "^24.9.0" + chalk "^2.0.1" + glob "^7.1.1" + jest-environment-jsdom "^24.9.0" + jest-environment-node "^24.9.0" + jest-get-type "^24.9.0" + jest-jasmine2 "^24.9.0" + jest-regex-util "^24.3.0" + jest-resolve "^24.9.0" + jest-util "^24.9.0" + jest-validate "^24.9.0" + micromatch "^3.1.10" + pretty-format "^24.9.0" + realpath-native "^1.1.0" + +jest-diff@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.9.0.tgz#931b7d0d5778a1baf7452cb816e325e3724055da" + integrity sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ== + dependencies: + chalk "^2.0.1" + diff-sequences "^24.9.0" + jest-get-type "^24.9.0" + pretty-format "^24.9.0" + +jest-docblock@^24.3.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-24.9.0.tgz#7970201802ba560e1c4092cc25cbedf5af5a8ce2" + integrity sha512-F1DjdpDMJMA1cN6He0FNYNZlo3yYmOtRUnktrT9Q37njYzC5WEaDdmbynIgy0L/IvXvvgsG8OsqhLPXTpfmZAA== + dependencies: + detect-newline "^2.1.0" + +jest-each@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-24.9.0.tgz#eb2da602e2a610898dbc5f1f6df3ba86b55f8b05" + integrity sha512-ONi0R4BvW45cw8s2Lrx8YgbeXL1oCQ/wIDwmsM3CqM/nlblNCPmnC3IPQlMbRFZu3wKdQ2U8BqM6lh3LJ5Bsog== + dependencies: + "@jest/types" "^24.9.0" + chalk "^2.0.1" + jest-get-type "^24.9.0" + jest-util "^24.9.0" + pretty-format "^24.9.0" + +jest-environment-jsdom@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-24.9.0.tgz#4b0806c7fc94f95edb369a69cc2778eec2b7375b" + integrity sha512-Zv9FV9NBRzLuALXjvRijO2351DRQeLYXtpD4xNvfoVFw21IOKNhZAEUKcbiEtjTkm2GsJ3boMVgkaR7rN8qetA== + dependencies: + "@jest/environment" "^24.9.0" + "@jest/fake-timers" "^24.9.0" + "@jest/types" "^24.9.0" + jest-mock "^24.9.0" + jest-util "^24.9.0" + jsdom "^11.5.1" + +jest-environment-node@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-24.9.0.tgz#333d2d2796f9687f2aeebf0742b519f33c1cbfd3" + integrity sha512-6d4V2f4nxzIzwendo27Tr0aFm+IXWa0XEUnaH6nU0FMaozxovt+sfRvh4J47wL1OvF83I3SSTu0XK+i4Bqe7uA== + dependencies: + "@jest/environment" "^24.9.0" + "@jest/fake-timers" "^24.9.0" + "@jest/types" "^24.9.0" + jest-mock "^24.9.0" + jest-util "^24.9.0" + +jest-get-type@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-24.9.0.tgz#1684a0c8a50f2e4901b6644ae861f579eed2ef0e" + integrity sha512-lUseMzAley4LhIcpSP9Jf+fTrQ4a1yHQwLNeeVa2cEmbCGeoZAtYPOIv8JaxLD/sUpKxetKGP+gsHl8f8TSj8Q== + +jest-haste-map@30.4.1: + version "30.4.1" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-30.4.1.tgz#6d80d09d668c20bf3944977e50acac94fcd672fe" + integrity sha512-rFrcONd8jeFsyw+Z9CrScJgglRf2+NFmNam8dKu7n+SoHqNYT47mn0DdEcVUZJpvh7Iz6/si7f7yUH7GJHVgnw== + dependencies: + "@jest/types" "30.4.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/node" "*" anymatch "^3.1.3" fb-watchman "^2.0.2" graceful-fs "^4.2.11" +<<<<<<< HEAD jest-regex-util "30.0.1" jest-util "30.2.0" jest-worker "30.2.0" micromatch "^4.0.8" +======= + jest-regex-util "30.4.0" + jest-util "30.4.1" + jest-worker "30.4.1" + picomatch "^4.0.3" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) walker "^1.0.8" optionalDependencies: fsevents "^2.3.3" +<<<<<<< HEAD jest-leak-detector@30.2.0: version "30.2.0" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-30.2.0.tgz#292fdca7b7c9cf594e1e570ace140b01d8beb736" @@ -1946,10 +5024,94 @@ jest-mock@30.2.0: jest-util "30.2.0" jest-pnp-resolver@^1.2.3: +======= +jest-haste-map@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-24.9.0.tgz#b38a5d64274934e21fa417ae9a9fbeb77ceaac7d" + integrity sha512-kfVFmsuWui2Sj1Rp1AJ4D9HqJwE4uwTlS/vO+eRUaMmd54BFpli2XhMQnPC2k4cHFVbB2Q2C+jtI1AGLgEnCjQ== + dependencies: + "@jest/types" "^24.9.0" + anymatch "^2.0.0" + fb-watchman "^2.0.0" + graceful-fs "^4.1.15" + invariant "^2.2.4" + jest-serializer "^24.9.0" + jest-util "^24.9.0" + jest-worker "^24.9.0" + micromatch "^3.1.10" + sane "^4.0.3" + walker "^1.0.7" + optionalDependencies: + fsevents "^1.2.7" + +jest-jasmine2@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-24.9.0.tgz#1f7b1bd3242c1774e62acabb3646d96afc3be6a0" + integrity sha512-Cq7vkAgaYKp+PsX+2/JbTarrk0DmNhsEtqBXNwUHkdlbrTBLtMJINADf2mf5FkowNsq8evbPc07/qFO0AdKTzw== + dependencies: + "@babel/traverse" "^7.1.0" + "@jest/environment" "^24.9.0" + "@jest/test-result" "^24.9.0" + "@jest/types" "^24.9.0" + chalk "^2.0.1" + co "^4.6.0" + expect "^24.9.0" + is-generator-fn "^2.0.0" + jest-each "^24.9.0" + jest-matcher-utils "^24.9.0" + jest-message-util "^24.9.0" + jest-runtime "^24.9.0" + jest-snapshot "^24.9.0" + jest-util "^24.9.0" + pretty-format "^24.9.0" + throat "^4.0.0" + +jest-leak-detector@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-24.9.0.tgz#b665dea7c77100c5c4f7dfcb153b65cf07dcf96a" + integrity sha512-tYkFIDsiKTGwb2FG1w8hX9V0aUb2ot8zY/2nFg087dUageonw1zrLMP4W6zsRO59dPkTSKie+D4rhMuP9nRmrA== + dependencies: + jest-get-type "^24.9.0" + pretty-format "^24.9.0" + +jest-matcher-utils@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-24.9.0.tgz#f5b3661d5e628dffe6dd65251dfdae0e87c3a073" + integrity sha512-OZz2IXsu6eaiMAwe67c1T+5tUAtQyQx27/EMEkbFAGiw52tB9em+uGbzpcgYVpA8wl0hlxKPZxrly4CXU/GjHA== + dependencies: + chalk "^2.0.1" + jest-diff "^24.9.0" + jest-get-type "^24.9.0" + pretty-format "^24.9.0" + +jest-message-util@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-24.9.0.tgz#527f54a1e380f5e202a8d1149b0ec872f43119e3" + integrity sha512-oCj8FiZ3U0hTP4aSui87P4L4jC37BtQwUMqk+zk/b11FR19BJDeZsZAvIHutWnmtw7r85UmR3CEWZ0HWU2mAlw== + dependencies: + "@babel/code-frame" "^7.0.0" + "@jest/test-result" "^24.9.0" + "@jest/types" "^24.9.0" + "@types/stack-utils" "^1.0.1" + chalk "^2.0.1" + micromatch "^3.1.10" + slash "^2.0.0" + stack-utils "^1.0.1" + +jest-mock@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-24.9.0.tgz#c22835541ee379b908673ad51087a2185c13f1c6" + integrity sha512-3BEYN5WbSq9wd+SyLDES7AHnjH9A/ROBwmz7l2y+ol+NtSFO8DYiEBzoO1CeFc9a8DYy10EO4dDFVv/wN3zl1w== + dependencies: + "@jest/types" "^24.9.0" + +jest-pnp-resolver@^1.2.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.2.3" resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== +<<<<<<< HEAD jest-regex-util@30.0.1: version "30.0.1" resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-30.0.1.tgz#f17c1de3958b67dfe485354f5a10093298f2a49b" @@ -2066,10 +5228,127 @@ jest-util@30.2.0: integrity sha512-QKNsM0o3Xe6ISQU869e+DhG+4CK/48aHYdJZGlFQVTjnbvgpcKyxpzk29fGiO7i/J8VENZ+d2iGnSsvmuHywlA== dependencies: "@jest/types" "30.2.0" +======= +jest-regex-util@30.4.0: + version "30.4.0" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-30.4.0.tgz#f75ccc43857633df2563a03588b5cb45c7c2941b" + integrity sha512-mWlvLviKIgIQ8VCuM1xRdD0TWp3zlzionlmDBjuXVBs+VkmXq6FgW9T4Emr7oGz/Rk6feDCGyiugolcQEyp3mg== + +jest-regex-util@^24.3.0, jest-regex-util@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-24.9.0.tgz#c13fb3380bde22bf6575432c493ea8fe37965636" + integrity sha512-05Cmb6CuxaA+Ys6fjr3PhvV3bGQmO+2p2La4hFbU+W5uOc479f7FdLXUWXw4pYMAhhSZIuKHwSXSu6CsSBAXQA== + +jest-resolve-dependencies@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-24.9.0.tgz#ad055198959c4cfba8a4f066c673a3f0786507ab" + integrity sha512-Fm7b6AlWnYhT0BXy4hXpactHIqER7erNgIsIozDXWl5dVm+k8XdGVe1oTg1JyaFnOxarMEbax3wyRJqGP2Pq+g== + dependencies: + "@jest/types" "^24.9.0" + jest-regex-util "^24.3.0" + jest-snapshot "^24.9.0" + +jest-resolve@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-24.9.0.tgz#dff04c7687af34c4dd7e524892d9cf77e5d17321" + integrity sha512-TaLeLVL1l08YFZAt3zaPtjiVvyy4oSA6CRe+0AFPPVX3Q/VI0giIWWoAvoS5L96vj9Dqxj4fB5p2qrHCmTU/MQ== + dependencies: + "@jest/types" "^24.9.0" + browser-resolve "^1.11.3" + chalk "^2.0.1" + jest-pnp-resolver "^1.2.1" + realpath-native "^1.1.0" + +jest-runner@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-24.9.0.tgz#574fafdbd54455c2b34b4bdf4365a23857fcdf42" + integrity sha512-KksJQyI3/0mhcfspnxxEOBueGrd5E4vV7ADQLT9ESaCzz02WnbdbKWIf5Mkaucoaj7obQckYPVX6JJhgUcoWWg== + dependencies: + "@jest/console" "^24.7.1" + "@jest/environment" "^24.9.0" + "@jest/test-result" "^24.9.0" + "@jest/types" "^24.9.0" + chalk "^2.4.2" + exit "^0.1.2" + graceful-fs "^4.1.15" + jest-config "^24.9.0" + jest-docblock "^24.3.0" + jest-haste-map "^24.9.0" + jest-jasmine2 "^24.9.0" + jest-leak-detector "^24.9.0" + jest-message-util "^24.9.0" + jest-resolve "^24.9.0" + jest-runtime "^24.9.0" + jest-util "^24.9.0" + jest-worker "^24.6.0" + source-map-support "^0.5.6" + throat "^4.0.0" + +jest-runtime@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-24.9.0.tgz#9f14583af6a4f7314a6a9d9f0226e1a781c8e4ac" + integrity sha512-8oNqgnmF3v2J6PVRM2Jfuj8oX3syKmaynlDMMKQ4iyzbQzIG6th5ub/lM2bCMTmoTKM3ykcUYI2Pw9xwNtjMnw== + dependencies: + "@jest/console" "^24.7.1" + "@jest/environment" "^24.9.0" + "@jest/source-map" "^24.3.0" + "@jest/transform" "^24.9.0" + "@jest/types" "^24.9.0" + "@types/yargs" "^13.0.0" + chalk "^2.0.1" + exit "^0.1.2" + glob "^7.1.3" + graceful-fs "^4.1.15" + jest-config "^24.9.0" + jest-haste-map "^24.9.0" + jest-message-util "^24.9.0" + jest-mock "^24.9.0" + jest-regex-util "^24.3.0" + jest-resolve "^24.9.0" + jest-snapshot "^24.9.0" + jest-util "^24.9.0" + jest-validate "^24.9.0" + realpath-native "^1.1.0" + slash "^2.0.0" + strip-bom "^3.0.0" + yargs "^13.3.0" + +jest-serializer@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.9.0.tgz#e6d7d7ef96d31e8b9079a714754c5d5c58288e73" + integrity sha512-DxYipDr8OvfrKH3Kel6NdED3OXxjvxXZ1uIY2I9OFbGg+vUkkg7AGvi65qbhbWNPvDckXmzMPbK3u3HaDO49bQ== + +jest-snapshot@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-24.9.0.tgz#ec8e9ca4f2ec0c5c87ae8f925cf97497b0e951ba" + integrity sha512-uI/rszGSs73xCM0l+up7O7a40o90cnrk429LOiK3aeTvfC0HHmldbd81/B7Ix81KSFe1lwkbl7GnBGG4UfuDew== + dependencies: + "@babel/types" "^7.0.0" + "@jest/types" "^24.9.0" + chalk "^2.0.1" + expect "^24.9.0" + jest-diff "^24.9.0" + jest-get-type "^24.9.0" + jest-matcher-utils "^24.9.0" + jest-message-util "^24.9.0" + jest-resolve "^24.9.0" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + pretty-format "^24.9.0" + semver "^6.2.0" + +jest-util@30.4.1: + version "30.4.1" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-30.4.1.tgz#979c9d014fdd12bb95d3dcde0192e1a9e0bc93d6" + integrity sha512-vjQb1sACEiv13DKJMDToJpzVW0joCsIQrmbg0fi7CyOOt+g9jTuQl2A216pWRBYhOVt53XbL/2LbMKg1BECWOw== + dependencies: + "@jest/types" "30.4.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/node" "*" chalk "^4.1.2" ci-info "^4.2.0" graceful-fs "^4.2.11" +<<<<<<< HEAD picomatch "^4.0.2" jest-validate@30.2.0: @@ -2120,6 +5399,81 @@ jest@^30.2.0: jest-cli "30.2.0" js-tokens@^4.0.0: +======= + picomatch "^4.0.3" + +jest-util@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-24.9.0.tgz#7396814e48536d2e85a37de3e4c431d7cb140162" + integrity sha512-x+cZU8VRmOJxbA1K5oDBdxQmdq0OIdADarLxk0Mq+3XS4jgvhG/oKGWcIDCtPG0HgjxOYvF+ilPJQsAyXfbNOg== + dependencies: + "@jest/console" "^24.9.0" + "@jest/fake-timers" "^24.9.0" + "@jest/source-map" "^24.9.0" + "@jest/test-result" "^24.9.0" + "@jest/types" "^24.9.0" + callsites "^3.0.0" + chalk "^2.0.1" + graceful-fs "^4.1.15" + is-ci "^2.0.0" + mkdirp "^0.5.1" + slash "^2.0.0" + source-map "^0.6.0" + +jest-validate@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-24.9.0.tgz#0775c55360d173cd854e40180756d4ff52def8ab" + integrity sha512-HPIt6C5ACwiqSiwi+OfSSHbK8sG7akG8eATl+IPKaeIjtPOeBUd/g3J7DghugzxrGjI93qS/+RPKe1H6PqvhRQ== + dependencies: + "@jest/types" "^24.9.0" + camelcase "^5.3.1" + chalk "^2.0.1" + jest-get-type "^24.9.0" + leven "^3.1.0" + pretty-format "^24.9.0" + +jest-watcher@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-24.9.0.tgz#4b56e5d1ceff005f5b88e528dc9afc8dd4ed2b3b" + integrity sha512-+/fLOfKPXXYJDYlks62/4R4GoT+GU1tYZed99JSCOsmzkkF7727RqKrjNAxtfO4YpGv11wybgRvCjR73lK2GZw== + dependencies: + "@jest/test-result" "^24.9.0" + "@jest/types" "^24.9.0" + "@types/yargs" "^13.0.0" + ansi-escapes "^3.0.0" + chalk "^2.0.1" + jest-util "^24.9.0" + string-length "^2.0.0" + +jest-worker@30.4.1: + version "30.4.1" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-30.4.1.tgz#ac010eb6c512425748a39e2d6bf05b2c4866ca4f" + integrity sha512-SHynN/q/QD++iNyvMdy+WMmbCGk8jIsNcRxycXbWubSOhvo6T+j2afcfUSl+3hYsiBebOTo0cT7c2H7CXugu1g== + dependencies: + "@types/node" "*" + "@ungap/structured-clone" "^1.3.0" + jest-util "30.4.1" + merge-stream "^2.0.0" + supports-color "^8.1.1" + +jest-worker@^24.6.0, jest-worker@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5" + integrity sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw== + dependencies: + merge-stream "^2.0.0" + supports-color "^6.1.0" + +jest@^24.5.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-24.9.0.tgz#987d290c05a08b52c56188c1002e368edb007171" + integrity sha512-YvkBL1Zm7d2B1+h5fHEOdyjCG+sGMz4f8D86/0HiqJ6MB4MnDc8FgP5vdWsGnemOQro7lnYo8UakZ3+5A0jxGw== + dependencies: + import-local "^2.0.0" + jest-cli "^24.9.0" + +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== @@ -2132,6 +5486,7 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +<<<<<<< HEAD js-yaml@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b" @@ -2140,6 +5495,46 @@ js-yaml@^4.1.1: argparse "^2.0.1" jsesc@^3.0.2: +======= +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg== + +jsdom@^11.5.1: + version "11.12.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.12.0.tgz#1a80d40ddd378a1de59656e9e6dc5a3ba8657bc8" + integrity sha512-y8Px43oyiBM13Zc1z780FrfNLJCXTL40EWlty/LXUtcjykRBNgLlCjWXpfSPBl2iv+N7koQN+dvqszHZgT/Fjw== + dependencies: + abab "^2.0.0" + acorn "^5.5.3" + acorn-globals "^4.1.0" + array-equal "^1.0.0" + cssom ">= 0.3.2 < 0.4.0" + cssstyle "^1.0.0" + data-urls "^1.0.0" + domexception "^1.0.1" + escodegen "^1.9.1" + html-encoding-sniffer "^1.0.2" + left-pad "^1.3.0" + nwsapi "^2.0.7" + parse5 "4.0.0" + pn "^1.1.0" + request "^2.87.0" + request-promise-native "^1.0.5" + sax "^1.2.4" + symbol-tree "^3.2.2" + tough-cookie "^2.3.4" + w3c-hr-time "^1.0.1" + webidl-conversions "^4.0.2" + whatwg-encoding "^1.0.3" + whatwg-mimetype "^2.1.0" + whatwg-url "^6.4.1" + ws "^5.2.0" + xml-name-validator "^3.0.0" + +jsesc@^3.0.2, jsesc@~3.1.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.1.0.tgz#74d335a234f67ed19907fdadfac7ccf9d409825d" integrity sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA== @@ -2149,26 +5544,63 @@ json-buffer@3.0.1: resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== +<<<<<<< HEAD json-parse-even-better-errors@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== +======= +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +<<<<<<< HEAD json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= +======= +json-schema@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" + integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) json5@^2.2.3: version "2.2.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== +<<<<<<< HEAD +======= +jsprim@^1.2.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" + integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.4.0" + verror "1.10.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) keyv@^4.5.4: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -2176,6 +5608,38 @@ keyv@^4.5.4: dependencies: json-buffer "3.0.1" +<<<<<<< HEAD +======= +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw== + dependencies: + is-buffer "^1.1.5" + +kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + +left-pad@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e" + integrity sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA== + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -2189,10 +5653,38 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +<<<<<<< HEAD lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +======= +levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + integrity sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA== + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + integrity sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw== + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) locate-path@^5.0.0: version "5.0.0" @@ -2208,6 +5700,7 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +<<<<<<< HEAD lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" @@ -2222,6 +5715,29 @@ lru-cache@^10.2.0: version "10.4.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== +======= +lodash.debounce@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" + integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow== + +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== + +lodash@^4.17.19: + version "4.18.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.18.1.tgz#ff2b66c1f6326d59513de2407bf881439812771c" + integrity sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q== + +loose-envify@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) lru-cache@^5.1.1: version "5.1.1" @@ -2230,12 +5746,22 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +<<<<<<< HEAD make-dir@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== dependencies: semver "^7.5.3" +======= +make-dir@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" + integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== + dependencies: + pify "^4.0.1" + semver "^5.6.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) makeerror@1.0.12: version "1.0.12" @@ -2244,11 +5770,32 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" +<<<<<<< HEAD +======= +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg== + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w== + dependencies: + object-visit "^1.0.0" + +math-intrinsics@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" + integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== +<<<<<<< HEAD micromatch@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" @@ -2292,37 +5839,179 @@ ms@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== +======= +micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12, mime-types@~2.1.19: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +minimatch@^10.2.4: + version "10.2.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.5.tgz#bd48687a0be38ed2961399105600f832095861d1" + integrity sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg== + dependencies: + brace-expansion "^5.0.5" + +minimatch@^3.0.4, minimatch@^3.1.1: + version "3.1.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.5.tgz#580c88f8d5445f2bd6aa8f3cadefa0de79fbd69e" + integrity sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp@^0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +<<<<<<< HEAD napi-postinstall@^0.3.0: version "0.3.4" resolved "https://registry.yarnpkg.com/napi-postinstall/-/napi-postinstall-0.3.4.tgz#7af256d6588b5f8e952b9190965d6b019653bbb9" integrity sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ== +======= +nan@^2.12.1: + version "2.27.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.27.0.tgz#804e389f4c0e39b729a17eca85c80ebc4355c4c4" + integrity sha512-hC+0LidcL3XE4rp1C4H54KujgXKzbfyTngZTwBByQxsOxCEKZT0MPQ4hOKUH2jU1OYstqdDH4onyHPDzcV0XdQ== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" +<<<<<<< HEAD integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= +======= + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" +<<<<<<< HEAD integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs= node-releases@^2.0.27: version "2.0.27" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.27.tgz#eedca519205cf20f650f61d56b070db111231e4e" integrity sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA== +======= + integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== + +node-notifier@^5.4.2: + version "5.4.5" + resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.4.5.tgz#0cbc1a2b0f658493b4025775a13ad938e96091ef" + integrity sha512-tVbHs7DyTLtzOiN78izLA85zRqB9NvEXkAf014Vx3jtSvn/xBl6bR8ZYifj+dFcFrKI21huSQgJZ6ZtL3B4HfQ== + dependencies: + growly "^1.3.0" + is-wsl "^1.1.0" + semver "^5.5.0" + shellwords "^0.1.1" + which "^1.3.0" + +node-releases@^2.0.36: + version "2.0.47" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.47.tgz#521bb2786da8eb140b748841c0b3b3a75334ffc4" + integrity sha512-Uzmd6LXpouKo8EUK68IjH4+E01w/hXyV3R3g/geCJo+rXLNfh1xucB+LOzYEOQPSiUK3h/xZf0cQGcSsmyL2Og== + +normalize-package-data@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + integrity sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w== + dependencies: + remove-trailing-separator "^1.0.1" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) normalize-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== +<<<<<<< HEAD npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" @@ -2343,6 +6032,101 @@ onetime@^5.1.2: integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== dependencies: mimic-fn "^2.1.0" +======= +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + integrity sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw== + dependencies: + path-key "^2.0.0" + +nwsapi@^2.0.7: + version "2.2.23" + resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.23.tgz#59712c3a88e6de2bb0b6ccc1070397267019cf6c" + integrity sha512-7wfH4sLbt4M0gCDzGE6vzQBo0bfTKjU7Sfpqy/7gs1qBfYz2vEJH6vXcBKpO3+6Yu1telwd0t9HpyOoLEQQbIQ== + +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ== + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-inspect@^1.13.3, object-inspect@^1.13.4: + version "1.13.4" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.4.tgz#8375265e21bc20d0fa582c22e1b13485d6e00213" + integrity sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew== + +object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA== + dependencies: + isobject "^3.0.0" + +object.assign@^4.1.7: + version "4.1.7" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.7.tgz#8c14ca1a424c6a561b0bb2a22f66f5049a945d3d" + integrity sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.3" + define-properties "^1.2.1" + es-object-atoms "^1.0.0" + has-symbols "^1.1.0" + object-keys "^1.1.1" + +object.getownpropertydescriptors@^2.1.8: + version "2.1.9" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.9.tgz#bf9e7520f14d50de88dee2b9c9eca841166322dc" + integrity sha512-mt8YM6XwsTTovI+kdZdHSxoyF2DI59up034orlC9NfweclcWOt7CVascNNLp6U+bjFVCVCIh9PwS76tDM/rH8g== + dependencies: + array.prototype.reduce "^1.0.8" + call-bind "^1.0.8" + define-properties "^1.2.1" + es-abstract "^1.24.0" + es-object-atoms "^1.1.1" + gopd "^1.2.0" + safe-array-concat "^1.1.3" + +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ== + dependencies: + isobject "^3.0.1" + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +optionator@^0.8.1: + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.6" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + word-wrap "~1.2.3" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) optionator@^0.9.3: version "0.9.4" @@ -2356,20 +6140,64 @@ optionator@^0.9.3: type-check "^0.4.0" word-wrap "^1.2.5" +<<<<<<< HEAD p-limit@^2.2.0: +======= +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + +own-keys@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/own-keys/-/own-keys-1.0.1.tgz#e4006910a2bf913585289676eebd6f390cf51358" + integrity sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg== + dependencies: + get-intrinsic "^1.2.6" + object-keys "^1.1.1" + safe-push-apply "^1.0.0" + +p-each-series@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-1.0.0.tgz#930f3d12dd1f50e7434457a22cd6f04ac6ad7f71" + integrity sha512-J/e9xiZZQNrt+958FFzJ+auItsBGq+UrQ7nE89AUP7UOTtjHnkISANXLdayhVzh538UnLMCSlf13lFfRIAKQOA== + dependencies: + p-reduce "^1.0.0" + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow== + +p-limit@^2.0.0, p-limit@^2.2.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== dependencies: p-try "^2.0.0" +<<<<<<< HEAD p-limit@^3.0.2, p-limit@^3.1.0: +======= +p-limit@^3.0.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== dependencies: yocto-queue "^0.1.0" +<<<<<<< HEAD +======= +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -2384,6 +6212,7 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +<<<<<<< HEAD p-try@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" @@ -2410,6 +6239,40 @@ parse-json@^5.2.0: error-ex "^1.3.1" json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" +======= +p-reduce@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" + integrity sha512-3Tx1T3oM1xO/Y8Gj0sWyE78EIJZ+t+aEmXUdvQgvGmSMri7aPTHoovbXEreWKkL5j21Er60XAWLTzKbAKYOujQ== + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw== + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + +parse5@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" + integrity sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA== + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw== + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) path-exists@^4.0.0: version "4.0.0" @@ -2419,13 +6282,25 @@ path-exists@^4.0.0: path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" +<<<<<<< HEAD integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= path-key@^3.0.0, path-key@^3.1.0: +======= + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^2.0.0, path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== + +path-key@^3.1.0: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== +<<<<<<< HEAD path-scurry@^1.11.1: version "1.11.1" resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" @@ -2433,12 +6308,31 @@ path-scurry@^1.11.1: dependencies: lru-cache "^10.2.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" +======= +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== + dependencies: + pify "^3.0.0" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) picocolors@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== +<<<<<<< HEAD picomatch@^2.0.4, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" @@ -2450,22 +6344,70 @@ picomatch@^4.0.2: integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q== pirates@^4.0.7: +======= +picomatch@^2.0.4: + version "2.3.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.2.tgz#5a942915e26b372dc0f0e6753149a16e6b1c5601" + integrity sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA== + +picomatch@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.4.tgz#fd6f5e00a143086e074dffe4c924b8fb293b0589" + integrity sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A== + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg== + +pify@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" + integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== + +pirates@^4.0.1, pirates@^4.0.7: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.0.7" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.7.tgz#643b4a18c4257c8a65104b73f3049ce9a0a15e22" integrity sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA== +<<<<<<< HEAD pkg-dir@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== dependencies: find-up "^4.0.0" +======= +pkg-dir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" + integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== + dependencies: + find-up "^3.0.0" + +pn@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" + integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA== + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg== + +possible-typed-array-names@^1.0.0, possible-typed-array-names@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz#93e3582bc0e5426586d9d07b79ee40fc841de4ae" + integrity sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +<<<<<<< HEAD pretty-format@30.2.0: version "30.2.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-30.2.0.tgz#2d44fe6134529aed18506f6d11509d8a62775ebe" @@ -2491,10 +6433,84 @@ react-is@^18.3.1: integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== readline-sync@^1.4.10: +======= +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== + +pretty-format@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" + integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA== + dependencies: + "@jest/types" "^24.9.0" + ansi-regex "^4.0.0" + ansi-styles "^3.2.0" + react-is "^16.8.4" + +prompts@^2.0.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + +psl@^1.1.28: + version "1.15.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.15.0.tgz#bdace31896f1d97cec6a79e8224898ce93d974c6" + integrity sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w== + dependencies: + punycode "^2.3.1" + +pump@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.4.tgz#1f313430527fa8b905622ebd22fe1444e757ab3c" + integrity sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +punycode@^2.1.0, punycode@^2.1.1, punycode@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +qs@~6.5.2: + version "6.5.5" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.5.tgz#7c9442fc3f1c58bb52ac57ad09db63ba68916395" + integrity sha512-mzR4sElr1bfCaPJe7m8ilJ6ZXdDaGoObcYR0ZHSsktM/Lt21MVHj5De30GQH2eiZ1qGRTO7LCAzQsUeXTNexWQ== + +react-is@^16.8.4: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== + +read-pkg-up@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-4.0.0.tgz#1b221c6088ba7799601c808f91161c66e58f8978" + integrity sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA== + dependencies: + find-up "^3.0.0" + read-pkg "^3.0.0" + +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + integrity sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA== + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + +readline-sync@^1.4.9: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.4.10" resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.10.tgz#41df7fbb4b6312d673011594145705bf56d8873b" integrity sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw== +<<<<<<< HEAD require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -2511,21 +6527,349 @@ resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== +======= +realpath-native@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.1.0.tgz#2003294fea23fb0672f2476ebe22fcf498a2d65c" + integrity sha512-wlgPA6cCIIg9gKz0fgAPjnzh4yR/LnXovwuo9hvyGvx3h8nX4+/iLZplfUWasXpqD8BdnGnP5njOFjkUwPzvjA== + dependencies: + util.promisify "^1.0.0" + +reflect.getprototypeof@^1.0.10, reflect.getprototypeof@^1.0.9: + version "1.0.10" + resolved "https://registry.yarnpkg.com/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz#c629219e78a3316d8b604c765ef68996964e7bf9" + integrity sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw== + dependencies: + call-bind "^1.0.8" + define-properties "^1.2.1" + es-abstract "^1.23.9" + es-errors "^1.3.0" + es-object-atoms "^1.0.0" + get-intrinsic "^1.2.7" + get-proto "^1.0.1" + which-builtin-type "^1.2.1" + +regenerate-unicode-properties@^10.2.2: + version "10.2.2" + resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.2.tgz#aa113812ba899b630658c7623466be71e1f86f66" + integrity sha512-m03P+zhBeQd1RGnYxrGyDAPpWX/epKirLrp8e3qevZdVkKtnCrjjWczIbYc8+xd6vcTStVlqfycTx1KR4LOr0g== + dependencies: + regenerate "^1.4.2" + +regenerate@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" + integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +regexp.prototype.flags@^1.5.4: + version "1.5.4" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz#1ad6c62d44a259007e55b3970e00f746efbcaa19" + integrity sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA== + dependencies: + call-bind "^1.0.8" + define-properties "^1.2.1" + es-errors "^1.3.0" + get-proto "^1.0.1" + gopd "^1.2.0" + set-function-name "^2.0.2" + +regexpu-core@^6.3.1: + version "6.4.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-6.4.0.tgz#3580ce0c4faedef599eccb146612436b62a176e5" + integrity sha512-0ghuzq67LI9bLXpOX/ISfve/Mq33a4aFRzoQYhnnok1JOFpmE/A2TBGkNVenOGEeSBCjIiWcc6MVOG5HEQv0sA== + dependencies: + regenerate "^1.4.2" + regenerate-unicode-properties "^10.2.2" + regjsgen "^0.8.0" + regjsparser "^0.13.0" + unicode-match-property-ecmascript "^2.0.0" + unicode-match-property-value-ecmascript "^2.2.1" + +regjsgen@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.8.0.tgz#df23ff26e0c5b300a6470cad160a9d090c3a37ab" + integrity sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q== + +regjsparser@^0.13.0: + version "0.13.1" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.13.1.tgz#0593cbacb27527927692030928ae4d3b878d6f8d" + integrity sha512-dLsljMd9sqwRkby8zhO1gSg3PnJIBFid8f4CQj/sXx+7cKx+E7u0PKhZ+U4wmhx7EfmtvnA318oVaIkAB1lRJw== + dependencies: + jsesc "~3.1.0" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + integrity sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw== + +repeat-element@^1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.4.tgz#be681520847ab58c7568ac75fbfad28ed42d39e9" + integrity sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w== + +request-promise-core@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.4.tgz#3eedd4223208d419867b78ce815167d10593a22f" + integrity sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw== + dependencies: + lodash "^4.17.19" + +request-promise-native@^1.0.5: + version "1.0.9" + resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.9.tgz#e407120526a5efdc9a39b28a5679bf47b9d9dc28" + integrity sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g== + dependencies: + request-promise-core "1.1.4" + stealthy-require "^1.1.1" + tough-cookie "^2.3.3" + +request@^2.87.0: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +resolve-cwd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" + integrity sha512-ccu8zQTrzVr954472aUVPLEcB3YpKSYR3cg/3lo1okzobPBM+1INXBbBZlDbnI/hbEocnf8j0QVo43hQKrbchg== + dependencies: + resolve-from "^3.0.0" + +resolve-from@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" + integrity sha512-GnlH6vxLymXJNMBo7XP1fJIzBFbdYt49CuTwmB/6N53t+kMPRMFKz783LlQ4tv28XoQfMWinAJX6WCGf2IlaIw== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) resolve-from@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== +<<<<<<< HEAD semver@^6.3.1: +======= +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg== + +resolve@1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + integrity sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg== + +resolve@^1.10.0, resolve@^1.22.11: + version "1.22.12" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.12.tgz#f5b2a680897c69c238a13cd16b15671f8b73549f" + integrity sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA== + dependencies: + es-errors "^1.3.0" + is-core-module "^2.16.1" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +rimraf@^2.5.4, rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + +rsvp@^4.8.4: + version "4.8.5" + resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" + integrity sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA== + +safe-array-concat@^1.1.3: + version "1.1.4" + resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.1.4.tgz#a54cc9b61a57f33b42abad3cbdda3a2b38cc5719" + integrity sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg== + dependencies: + call-bind "^1.0.9" + call-bound "^1.0.4" + get-intrinsic "^1.3.0" + has-symbols "^1.1.0" + isarray "^2.0.5" + +safe-buffer@^5.0.1, safe-buffer@^5.1.2: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-push-apply@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-push-apply/-/safe-push-apply-1.0.0.tgz#01850e981c1602d398c85081f360e4e6d03d27f5" + integrity sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA== + dependencies: + es-errors "^1.3.0" + isarray "^2.0.5" + +safe-regex-test@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz#7f87dfb67a3150782eaaf18583ff5d1711ac10c1" + integrity sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + is-regex "^1.2.1" + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg== + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +sane@^4.0.3: + version "4.1.0" + resolved "https://registry.yarnpkg.com/sane/-/sane-4.1.0.tgz#ed881fd922733a6c461bc189dc2b6c006f3ffded" + integrity sha512-hhbzAgTIX8O7SHfp2c8/kREfEn4qO/9q8C9beyY6+tvZ87EpoZ3i1RIEvp27YBswnNbY9mWd6paKVmKbAgLfZA== + dependencies: + "@cnakazawa/watch" "^1.0.3" + anymatch "^2.0.0" + capture-exit "^2.0.0" + exec-sh "^0.3.2" + execa "^1.0.0" + fb-watchman "^2.0.0" + micromatch "^3.1.4" + minimist "^1.1.1" + walker "~1.0.5" + +sax@^1.2.4: + version "1.6.0" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.6.0.tgz#da59637629307b97e7c4cb28e080a7bc38560d5b" + integrity sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA== + +"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + +semver@^6.0.0, semver@^6.2.0, semver@^6.3.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== +<<<<<<< HEAD semver@^7.5.3, semver@^7.5.4, semver@^7.7.2: version "7.7.3" resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946" integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q== +======= +semver@^7.5.4: + version "7.8.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.8.1.tgz#bf4970b5e70fda0686363cc18bfe8805d5ed957e" + integrity sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg== + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== + +set-function-length@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +set-function-name@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/set-function-name/-/set-function-name-2.0.2.tgz#16a705c5a0dc2f5e638ca96d8a8cd4e1c2b90985" + integrity sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + functions-have-names "^1.2.3" + has-property-descriptors "^1.0.2" + +set-proto@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/set-proto/-/set-proto-1.0.0.tgz#0760dbcff30b2d7e801fd6e19983e56da337565e" + integrity sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw== + dependencies: + dunder-proto "^1.0.1" + es-errors "^1.3.0" + es-object-atoms "^1.0.0" + +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== + dependencies: + shebang-regex "^1.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) shebang-command@^2.0.0: version "2.0.0" @@ -2534,12 +6878,69 @@ shebang-command@^2.0.0: dependencies: shebang-regex "^3.0.0" +<<<<<<< HEAD +======= +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) shebang-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +<<<<<<< HEAD signal-exit@^3.0.3: +======= +shellwords@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" + integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== + +side-channel-list@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/side-channel-list/-/side-channel-list-1.0.1.tgz#c2e0b5a14a540aebee3bbc6c3f8666cc9b509127" + integrity sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w== + dependencies: + es-errors "^1.3.0" + object-inspect "^1.13.4" + +side-channel-map@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/side-channel-map/-/side-channel-map-1.0.1.tgz#d6bb6b37902c6fef5174e5f533fab4c732a26f42" + integrity sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + get-intrinsic "^1.2.5" + object-inspect "^1.13.3" + +side-channel-weakmap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz#11dda19d5368e40ce9ec2bdc1fb0ecbc0790ecea" + integrity sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + get-intrinsic "^1.2.5" + object-inspect "^1.13.3" + side-channel-map "^1.0.1" + +side-channel@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.1.0.tgz#c3fcff9c4da932784873335ec9765fa94ff66bc9" + integrity sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw== + dependencies: + es-errors "^1.3.0" + object-inspect "^1.13.3" + side-channel-list "^1.0.0" + side-channel-map "^1.0.1" + side-channel-weakmap "^1.0.2" + +signal-exit@^3.0.0, signal-exit@^3.0.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== @@ -2549,25 +6950,137 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== +<<<<<<< HEAD +======= +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + +slash@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" + integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== +<<<<<<< HEAD source-map-support@0.5.13: version "0.5.13" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== +======= +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +source-map-resolve@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" + integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-support@^0.5.6: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: buffer-from "^1.0.0" source-map "^0.6.0" +<<<<<<< HEAD source-map@^0.6.0: +======= +source-map-url@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" + integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== + +source-map@^0.5.6: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ== + +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +<<<<<<< HEAD sprintf-js@^1.1.3: +======= +spdx-correct@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.2.0.tgz#4f5ab0668f0059e34f9c00dce331784a12de4e9c" + integrity sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz#5d607d27fc806f66d7b64a766650fa890f04ed66" + integrity sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.23" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.23.tgz#b069e687b1291a32f126893ed76a27a745ee2133" + integrity sha512-CWLcCCH7VLu13TgOH+r8p1O/Znwhqv/dbb6lqWy67G+pT1kHmeD/+V36AVb/vq8QMIQwVShJ6Ssl5FPh0fuSdw== + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +sprintf-js@^1.1.2: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.1.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== @@ -2575,6 +7088,7 @@ sprintf-js@^1.1.3: sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" +<<<<<<< HEAD integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= stack-utils@^2.0.6: @@ -2654,6 +7168,125 @@ strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== +======= + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +sshpk@^1.7.0: + version "1.18.0" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.18.0.tgz#1663e55cddf4d688b86a46b77f0d5fe363aba028" + integrity sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ== + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + bcrypt-pbkdf "^1.0.0" + dashdash "^1.12.0" + ecc-jsbn "~0.1.1" + getpass "^0.1.1" + jsbn "~0.1.0" + safer-buffer "^2.0.2" + tweetnacl "~0.14.0" + +stack-utils@^1.0.1: + version "1.0.5" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.5.tgz#a19b0b01947e0029c8e451d5d61a498f5bb1471b" + integrity sha512-KZiTzuV3CnSnSvgMRrARVCj+Ht7rMbauGDK0LdVFRGyenwdylpajAp4Q0i6SX8rEmbTpMMf6ryq2gb8pPq2WgQ== + dependencies: + escape-string-regexp "^2.0.0" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g== + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +stealthy-require@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" + integrity sha512-ZnWpYnYugiOVEY5GkcuJK1io5V8QmNYChG62gSit9pQVGErXtrKuPC55ITaVSukmMta5qpMU7vqLt2Lnni4f/g== + +stop-iteration-iterator@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz#f481ff70a548f6124d0312c3aa14cbfa7aa542ad" + integrity sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ== + dependencies: + es-errors "^1.3.0" + internal-slot "^1.1.0" + +string-length@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" + integrity sha512-Qka42GGrS8Mm3SZ+7cH8UXiIWI867/b/Z/feQSpQx/rbfB8UGknGEZVaUQMOUVj+soY6NpWAxily63HI1OckVQ== + dependencies: + astral-regex "^1.0.0" + strip-ansi "^4.0.0" + +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +string.prototype.trim@^1.2.10: + version "1.2.10" + resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz#40b2dd5ee94c959b4dcfb1d65ce72e90da480c81" + integrity sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.2" + define-data-property "^1.1.4" + define-properties "^1.2.1" + es-abstract "^1.23.5" + es-object-atoms "^1.0.0" + has-property-descriptors "^1.0.2" + +string.prototype.trimend@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.9.tgz#62e2731272cd285041b36596054e9f66569b6942" + integrity sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.2" + define-properties "^1.2.1" + es-object-atoms "^1.0.0" + +string.prototype.trimstart@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz#7ee834dda8c7c17eff3118472bb35bfedaa34dde" + integrity sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg== + dependencies: + call-bind "^1.0.7" + define-properties "^1.2.1" + es-object-atoms "^1.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow== + dependencies: + ansi-regex "^3.0.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + integrity sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) supports-color@^5.3.0: version "5.5.0" @@ -2662,6 +7295,16 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +<<<<<<< HEAD +======= +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -2676,12 +7319,34 @@ supports-color@^8.1.1: dependencies: has-flag "^4.0.0" +<<<<<<< HEAD synckit@^0.11.8: version "0.11.11" resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.11.tgz#c0b619cf258a97faa209155d9cd1699b5c998cb0" integrity sha512-MeQTA1r0litLUf0Rp/iisCaL8761lKAZHaimlbGK4j0HysC4PLfqygQj9srcs0m2RdtDYnF8UuYyKpbjHYp7Jw== dependencies: "@pkgr/core" "^0.2.9" +======= +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +symbol-tree@^3.2.2: + version "3.2.4" + resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" + integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== + +test-exclude@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0" + integrity sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g== + dependencies: + glob "^7.1.3" + minimatch "^3.0.4" + read-pkg-up "^4.0.0" + require-main-filename "^2.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) test-exclude@^6.0.0: version "6.0.0" @@ -2692,16 +7357,31 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" +<<<<<<< HEAD tmp@^0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8" integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow== +======= +throat@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" + integrity sha512-wCVxLDcFxw7ujDxaeJC6nfl2XfHJNYs8yUYJnvMgtPEFlttP9tHSfRUv2vBe6C4hkVFPWoP1P6ZccbYjmSEkKA== + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== +<<<<<<< HEAD to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" @@ -2718,6 +7398,59 @@ tslib@^2.4.0: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== +======= +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg== + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg== + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +tough-cookie@^2.3.3, tough-cookie@^2.3.4, tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + +tr46@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA== + dependencies: + punycode "^2.1.0" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + integrity sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" @@ -2726,6 +7459,7 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" +<<<<<<< HEAD type-detect@4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" @@ -2772,11 +7506,126 @@ update-browserslist-db@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.2.2.tgz#cfb4358afa08b3d5731a2ecd95eebf4ddef8033e" integrity sha512-E85pfNzMQ9jpKkA7+TJAi4TJN+tBCuWh5rUcS/sv6cFi+1q9LYDwDI5dpUL0u/73EElyQ8d3TEaeW4sPedBqYA== +======= +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + integrity sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg== + dependencies: + prelude-ls "~1.1.2" + +typed-array-buffer@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536" + integrity sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw== + dependencies: + call-bound "^1.0.3" + es-errors "^1.3.0" + is-typed-array "^1.1.14" + +typed-array-byte-length@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz#8407a04f7d78684f3d252aa1a143d2b77b4160ce" + integrity sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg== + dependencies: + call-bind "^1.0.8" + for-each "^0.3.3" + gopd "^1.2.0" + has-proto "^1.2.0" + is-typed-array "^1.1.14" + +typed-array-byte-offset@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.4.tgz#ae3698b8ec91a8ab945016108aef00d5bff12355" + integrity sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ== + dependencies: + available-typed-arrays "^1.0.7" + call-bind "^1.0.8" + for-each "^0.3.3" + gopd "^1.2.0" + has-proto "^1.2.0" + is-typed-array "^1.1.15" + reflect.getprototypeof "^1.0.9" + +typed-array-length@^1.0.7: + version "1.0.8" + resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.8.tgz#0b70e982c9e9dafe2def6d6458ff4b3f2d2b6d70" + integrity sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g== + dependencies: + call-bind "^1.0.9" + for-each "^0.3.5" + gopd "^1.2.0" + is-typed-array "^1.1.15" + possible-typed-array-names "^1.1.0" + reflect.getprototypeof "^1.0.10" + +unbox-primitive@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.1.0.tgz#8d9d2c9edeea8460c7f35033a88867944934d1e2" + integrity sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw== + dependencies: + call-bound "^1.0.3" + has-bigints "^1.0.2" + has-symbols "^1.1.0" + which-boxed-primitive "^1.1.1" + +"undici-types@>=7.24.0 <7.24.7": + version "7.24.6" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.24.6.tgz#61275b485d7fd4e9d269c7cf04ec2873c9cc0f91" + integrity sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg== + +unicode-canonical-property-names-ecmascript@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz#cb3173fe47ca743e228216e4a3ddc4c84d628cc2" + integrity sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg== + +unicode-match-property-ecmascript@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz#54fd16e0ecb167cf04cf1f756bdcc92eba7976c3" + integrity sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q== + dependencies: + unicode-canonical-property-names-ecmascript "^2.0.0" + unicode-property-aliases-ecmascript "^2.0.0" + +unicode-match-property-value-ecmascript@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.1.tgz#65a7adfad8574c219890e219285ce4c64ed67eaa" + integrity sha512-JQ84qTuMg4nVkx8ga4A16a1epI9H6uTXAknqxkGF/aFfRLw1xC/Bp24HNLaZhHSkWd3+84t8iXnp1J0kYcZHhg== + +unicode-property-aliases-ecmascript@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.2.0.tgz#301d4f8a43d2b75c97adfad87c9dd5350c9475d1" + integrity sha512-hpbDzxUY9BFwX+UeBnxv3Sh1q7HFxj48DTmXchNgRa46lO8uj3/1iEn3MiNUYTg1g9ctIqXCCERn8gYZhHC5lQ== + +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ== + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +update-browserslist-db@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz#64d76db58713136acbeb4c49114366cc6cc2e80d" + integrity sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: escalade "^3.2.0" picocolors "^1.1.1" uri-js@^4.2.2: +<<<<<<< HEAD version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== @@ -2793,12 +7642,181 @@ v8-to-istanbul@^9.0.1: convert-source-map "^2.0.0" walker@^1.0.8: +======= + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg== + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +util.promisify@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.1.3.tgz#3d77cf56628b4aad743e5acde8e5c44cea7dbf1c" + integrity sha512-GIEaZ6o86fj09Wtf0VfZ5XP7tmd4t3jM5aZCgmBi231D0DB1AEBa3Aa6MP48DMsAIi96WkpWLimIWVwOjbDMOw== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.3" + define-data-property "^1.1.4" + define-properties "^1.2.1" + es-errors "^1.3.0" + es-object-atoms "^1.0.0" + for-each "^0.3.3" + get-intrinsic "^1.2.6" + has-proto "^1.2.0" + has-symbols "^1.1.0" + object.getownpropertydescriptors "^2.1.8" + safe-array-concat "^1.1.3" + +uuid@^3.3.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" + integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + integrity sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw== + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +w3c-hr-time@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" + integrity sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ== + dependencies: + browser-process-hrtime "^1.0.0" + +walker@^1.0.7, walker@^1.0.8, walker@~1.0.5: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.0.8" resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f" integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ== dependencies: makeerror "1.0.12" +<<<<<<< HEAD +======= +webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== + +whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3: + version "1.0.5" + resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz#5abacf777c32166a51d085d6b4f3e7d27113ddb0" + integrity sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw== + dependencies: + iconv-lite "0.4.24" + +whatwg-mimetype@^2.1.0, whatwg-mimetype@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" + integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== + +whatwg-url@^6.4.1: + version "6.5.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8" + integrity sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" + +whatwg-url@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06" + integrity sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" + +which-boxed-primitive@^1.1.0, which-boxed-primitive@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz#d76ec27df7fa165f18d5808374a5fe23c29b176e" + integrity sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA== + dependencies: + is-bigint "^1.1.0" + is-boolean-object "^1.2.1" + is-number-object "^1.1.1" + is-string "^1.1.1" + is-symbol "^1.1.1" + +which-builtin-type@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/which-builtin-type/-/which-builtin-type-1.2.1.tgz#89183da1b4907ab089a6b02029cc5d8d6574270e" + integrity sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q== + dependencies: + call-bound "^1.0.2" + function.prototype.name "^1.1.6" + has-tostringtag "^1.0.2" + is-async-function "^2.0.0" + is-date-object "^1.1.0" + is-finalizationregistry "^1.1.0" + is-generator-function "^1.0.10" + is-regex "^1.2.1" + is-weakref "^1.0.2" + isarray "^2.0.5" + which-boxed-primitive "^1.1.0" + which-collection "^1.0.2" + which-typed-array "^1.1.16" + +which-collection@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.2.tgz#627ef76243920a107e7ce8e96191debe4b16c2a0" + integrity sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw== + dependencies: + is-map "^2.0.3" + is-set "^2.0.3" + is-weakmap "^2.0.2" + is-weakset "^2.0.3" + +which-module@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" + integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== + +which-typed-array@^1.1.16, which-typed-array@^1.1.19: + version "1.1.21" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.21.tgz#ea7aab68168079646af06b4a36a6f7d7b72e1c0a" + integrity sha512-zbRA8cVm6io/d5W8uIe2hblzN76/Wm3v/yiythQvr+dpBWeqhPSWIDNj4zOyHi4zKbMK6DN34Xsr9jPHJERAEw== + dependencies: + available-typed-arrays "^1.0.7" + call-bind "^1.0.9" + call-bound "^1.0.4" + for-each "^0.3.5" + get-proto "^1.0.1" + gopd "^1.2.0" + has-tostringtag "^1.0.2" + +which@^1.2.9, which@^1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -2806,11 +7824,16 @@ which@^2.0.1: dependencies: isexe "^2.0.0" +<<<<<<< HEAD word-wrap@^1.2.5: +======= +word-wrap@^1.2.5, word-wrap@~1.2.3: +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.2.5" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== +<<<<<<< HEAD "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -2837,11 +7860,34 @@ wrap-ansi@^8.1.0: ansi-styles "^6.1.0" string-width "^5.0.1" strip-ansi "^7.0.1" +======= +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" +<<<<<<< HEAD integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +======= + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +write-file-atomic@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.1.tgz#d0b05463c188ae804396fd5ab2a370062af87529" + integrity sha512-TGHFeZEZMnv+gBFRfjAcxL5bPHrsGKtnb4qsFAws7/vlh+QfwAaySIw4AXP9ZskTTh5GWu3FLuJhsWVdiJPGvg== + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) write-file-atomic@^5.0.1: version "5.0.1" @@ -2851,16 +7897,36 @@ write-file-atomic@^5.0.1: imurmurhash "^0.1.4" signal-exit "^4.0.1" +<<<<<<< HEAD y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +======= +ws@^5.2.0: + version "5.2.5" + resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.5.tgz#41d693f6502b7a020349cfa220a6799a7f13335c" + integrity sha512-G0gACQIjFmv7NqpaOAXEpe9nEtRYD6ZCy2Ip/B4EzR08qEwnf/wYJoQd3cjosPdnJsHkeh0j2tzOaIBZIOC1yA== + dependencies: + async-limiter "~1.0.0" + +xml-name-validator@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" + integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== + +y18n@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" + integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== +<<<<<<< HEAD yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" @@ -2878,6 +7944,31 @@ yargs@^17.7.2: string-width "^4.2.3" y18n "^5.0.5" yargs-parser "^21.1.1" +======= +yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs@^13.3.0: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" +>>>>>>> e396c16 (Update files, eslint run, and iteration complete) yocto-queue@^0.1.0: version "0.1.0" From c1b297362783cd0cf5db1fba60a1e0066a3df51b Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 4 Jun 2026 12:12:31 +0100 Subject: [PATCH 09/11] Update dependencies and format files --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99476215..97a7d66f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "fengari", + "name": "@ctrlo/fengari", "version": "0.1.6", "description": "A Lua VM written in JS modules targeting the browser", "main": "src/fengari.js", From 57372e016e0cf3e02aaeab0cd0be560fa8ec4f00 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Fri, 5 Jun 2026 13:25:06 +0100 Subject: [PATCH 10/11] Fix `yarn.lock` conflicts --- yarn.lock | 2277 ----------------------------------------------------- 1 file changed, 2277 deletions(-) diff --git a/yarn.lock b/yarn.lock index b35e9f56..48dc35e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,43 +2,6 @@ # yarn lockfile v1 -<<<<<<< HEAD -"@babel/code-frame@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" - integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== - dependencies: - "@babel/highlight" "^7.0.0" - -"@babel/code-frame@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.27.1.tgz#200f715e66d52a23b221a9435534a91cc13ad5be" - integrity sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg== - dependencies: - "@babel/helper-validator-identifier" "^7.27.1" - js-tokens "^4.0.0" - picocolors "^1.1.1" - -"@babel/compat-data@^7.27.2": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.28.5.tgz#a8a4962e1567121ac0b3b487f52107443b455c7f" - integrity sha512-6uFXyCayocRbqhZOB+6XcuZbkMNimwfVGFji8CTZnCzOHVGvDqzvitu1re2AU5LROliz7eQPhB8CpAMvnx9EjA== - -"@babel/core@^7.23.9", "@babel/core@^7.27.4": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.28.5.tgz#4c81b35e51e1b734f510c99b07dfbc7bbbb48f7e" - integrity sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw== - dependencies: - "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.28.5" - "@babel/helper-compilation-targets" "^7.27.2" - "@babel/helper-module-transforms" "^7.28.3" - "@babel/helpers" "^7.28.4" - "@babel/parser" "^7.28.5" - "@babel/template" "^7.27.2" - "@babel/traverse" "^7.28.5" - "@babel/types" "^7.28.5" -======= "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.29.7": version "7.29.7" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.29.7.tgz#f2fbbfea87c44a21590ec515b778b2c26d8866e7" @@ -67,7 +30,6 @@ "@babel/template" "^7.29.7" "@babel/traverse" "^7.29.7" "@babel/types" "^7.29.7" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/remapping" "^2.3.5" convert-source-map "^2.0.0" debug "^4.1.0" @@ -75,15 +37,6 @@ json5 "^2.2.3" semver "^6.3.1" -<<<<<<< HEAD -"@babel/generator@^7.27.5", "@babel/generator@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.28.5.tgz#712722d5e50f44d07bc7ac9fe84438742dd61298" - integrity sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ== - dependencies: - "@babel/parser" "^7.28.5" - "@babel/types" "^7.28.5" -======= "@babel/generator@^7.29.7", "@babel/generator@^7.4.0": version "7.29.7" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.29.7.tgz#cca0b8827e6bcf3ba176788e7f3b180ad6db2fa3" @@ -91,20 +44,10 @@ dependencies: "@babel/parser" "^7.29.7" "@babel/types" "^7.29.7" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/gen-mapping" "^0.3.12" "@jridgewell/trace-mapping" "^0.3.28" jsesc "^3.0.2" -<<<<<<< HEAD -"@babel/helper-compilation-targets@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz#46a0f6efab808d51d29ce96858dd10ce8732733d" - integrity sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ== - dependencies: - "@babel/compat-data" "^7.27.2" - "@babel/helper-validator-option" "^7.27.1" -======= "@babel/helper-annotate-as-pure@^7.29.7": version "7.29.7" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz#c70fe3c6ecbdc3fd2dd1b0f498428b88b82ce47f" @@ -119,88 +62,10 @@ dependencies: "@babel/compat-data" "^7.29.7" "@babel/helper-validator-option" "^7.29.7" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) browserslist "^4.24.0" lru-cache "^5.1.1" semver "^6.3.1" -<<<<<<< HEAD -"@babel/helper-globals@^7.28.0": - version "7.28.0" - resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.28.0.tgz#b9430df2aa4e17bc28665eadeae8aa1d985e6674" - integrity sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw== - -"@babel/helper-module-imports@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz#7ef769a323e2655e126673bb6d2d6913bbead204" - integrity sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w== - dependencies: - "@babel/traverse" "^7.27.1" - "@babel/types" "^7.27.1" - -"@babel/helper-module-transforms@^7.28.3": - version "7.28.3" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.28.3.tgz#a2b37d3da3b2344fe085dab234426f2b9a2fa5f6" - integrity sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw== - dependencies: - "@babel/helper-module-imports" "^7.27.1" - "@babel/helper-validator-identifier" "^7.27.1" - "@babel/traverse" "^7.28.3" - -"@babel/helper-plugin-utils@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" - integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA== - -"@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.27.1", "@babel/helper-plugin-utils@^7.8.0": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz#ddb2f876534ff8013e6c2b299bf4d39b3c51d44c" - integrity sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw== - -"@babel/helper-string-parser@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz#54da796097ab19ce67ed9f88b47bb2ec49367687" - integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA== - -"@babel/helper-validator-identifier@^7.27.1", "@babel/helper-validator-identifier@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz#010b6938fab7cb7df74aa2bbc06aa503b8fe5fb4" - integrity sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q== - -"@babel/helper-validator-option@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f" - integrity sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg== - -"@babel/helpers@^7.28.4": - version "7.28.4" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.28.4.tgz#fe07274742e95bdf7cf1443593eeb8926ab63827" - integrity sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w== - dependencies: - "@babel/template" "^7.27.2" - "@babel/types" "^7.28.4" - -"@babel/highlight@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" - integrity sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw== - dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^4.0.0" - -"@babel/parser@^7.1.0": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.4.tgz#a43357e4bbf4b92a437fb9e465c192848287f27c" - integrity sha512-tXZCqWtlOOP4wgCp6RjRvLmfuhnqTLy9VHwRochJBCP2nDm27JnnuFEnXFASVyQNHk36jD1tAammsCEEqgscIQ== - -"@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.27.2", "@babel/parser@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.28.5.tgz#0b0225ee90362f030efd644e8034c99468893b08" - integrity sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ== - dependencies: - "@babel/types" "^7.28.5" -======= "@babel/helper-create-class-features-plugin@^7.29.7": version "7.29.7" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.7.tgz#6eddf286f2ec418f740c91d60a83347c55838ddd" @@ -392,7 +257,6 @@ version "7.21.0-placeholder-for-preset-env.2" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz#7844f9289546efa9febac2de4cfe358a050bd703" integrity sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -422,14 +286,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -<<<<<<< HEAD -"@babel/plugin-syntax-import-attributes@^7.24.7": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz#34c017d54496f9b11b61474e7ea3dfd5563ffe07" - integrity sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww== - dependencies: - "@babel/helper-plugin-utils" "^7.27.1" -======= "@babel/plugin-syntax-import-assertions@^7.29.7": version "7.29.7" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.29.7.tgz#c5cd868505269126cc18882e1f01f7b0e0e24b4e" @@ -443,7 +299,6 @@ integrity sha512-zGYcYfq/WmZ4V+kBIXQon9dSSc8ircGZqw9ZaNhhGj9nZkeBu1jHLBDQqYYi5WA9uawvA2sIMbry2nCFhf5Djg== dependencies: "@babel/helper-plugin-utils" "^7.29.7" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@babel/plugin-syntax-import-meta@^7.10.4": version "7.10.4" @@ -459,16 +314,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -<<<<<<< HEAD -"@babel/plugin-syntax-jsx@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz#2f9beb5eff30fa507c5532d107daac7b888fa34c" - integrity sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w== - dependencies: - "@babel/helper-plugin-utils" "^7.27.1" - -======= ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@babel/plugin-syntax-logical-assignment-operators@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" @@ -490,11 +335,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -<<<<<<< HEAD -"@babel/plugin-syntax-object-rest-spread@^7.8.3": -======= "@babel/plugin-syntax-object-rest-spread@^7.0.0", "@babel/plugin-syntax-object-rest-spread@^7.8.3": ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== @@ -529,89 +370,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -<<<<<<< HEAD -"@babel/plugin-syntax-typescript@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz#5147d29066a793450f220c63fa3a9431b7e6dd18" - integrity sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ== - dependencies: - "@babel/helper-plugin-utils" "^7.27.1" - -"@babel/template@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.27.2.tgz#fa78ceed3c4e7b63ebf6cb39e5852fca45f6809d" - integrity sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw== - dependencies: - "@babel/code-frame" "^7.27.1" - "@babel/parser" "^7.27.2" - "@babel/types" "^7.27.1" - -"@babel/traverse@^7.27.1", "@babel/traverse@^7.28.3", "@babel/traverse@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.28.5.tgz#450cab9135d21a7a2ca9d2d35aa05c20e68c360b" - integrity sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ== - dependencies: - "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.28.5" - "@babel/helper-globals" "^7.28.0" - "@babel/parser" "^7.28.5" - "@babel/template" "^7.27.2" - "@babel/types" "^7.28.5" - debug "^4.3.1" - -"@babel/types@^7.0.0", "@babel/types@^7.3.0": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.4.tgz#bf482eaeaffb367a28abbf9357a94963235d90ed" - integrity sha512-WEkp8MsLftM7O/ty580wAmZzN1nDmCACc5+jFzUt+GUFNNIi3LdRlueYz0YIlmJhlZx1QYDMZL5vdWCL0fNjFQ== - dependencies: - esutils "^2.0.2" - lodash "^4.17.11" - to-fast-properties "^2.0.0" - -"@babel/types@^7.20.7", "@babel/types@^7.27.1", "@babel/types@^7.27.3", "@babel/types@^7.28.4", "@babel/types@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.28.5.tgz#10fc405f60897c35f07e85493c932c7b5ca0592b" - integrity sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA== - dependencies: - "@babel/helper-string-parser" "^7.27.1" - "@babel/helper-validator-identifier" "^7.28.5" - -"@bcoe/v8-coverage@^0.2.3": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" - integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== - -"@emnapi/core@^1.4.3": - version "1.7.1" - resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.7.1.tgz#3a79a02dbc84f45884a1806ebb98e5746bdfaac4" - integrity sha512-o1uhUASyo921r2XtHYOHy7gdkGLge8ghBEQHMWmyJFoXlpU58kIrhhN3w26lpQb6dspetweapMn2CSNwQ8I4wg== - dependencies: - "@emnapi/wasi-threads" "1.1.0" - tslib "^2.4.0" - -"@emnapi/runtime@^1.4.3": - version "1.7.1" - resolved "https://registry.yarnpkg.com/@emnapi/runtime/-/runtime-1.7.1.tgz#a73784e23f5d57287369c808197288b52276b791" - integrity sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA== - dependencies: - tslib "^2.4.0" - -"@emnapi/wasi-threads@1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz#60b2102fddc9ccb78607e4a3cf8403ea69be41bf" - integrity sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ== - dependencies: - tslib "^2.4.0" - -"@eslint-community/eslint-utils@^4.8.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz#7308df158e064f0dd8b8fdb58aa14fa2a7f913b3" - integrity sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g== - dependencies: - eslint-visitor-keys "^3.4.3" - -"@eslint-community/regexpp@^4.12.1": -======= "@babel/plugin-syntax-unicode-sets-regex@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz#d49a3b3e6b52e5be6740022317580234a6a47357" @@ -1149,82 +907,10 @@ eslint-visitor-keys "^3.4.3" "@eslint-community/regexpp@^4.12.2": ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.12.2" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz#bccdf615bcf7b6e8db830ec0b8d21c9a25de597b" integrity sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew== -<<<<<<< HEAD -"@eslint/config-array@^0.21.1": - version "0.21.1" - resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.21.1.tgz#7d1b0060fea407f8301e932492ba8c18aff29713" - integrity sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA== - dependencies: - "@eslint/object-schema" "^2.1.7" - debug "^4.3.1" - minimatch "^3.1.2" - -"@eslint/config-helpers@^0.4.2": - version "0.4.2" - resolved "https://registry.yarnpkg.com/@eslint/config-helpers/-/config-helpers-0.4.2.tgz#1bd006ceeb7e2e55b2b773ab318d300e1a66aeda" - integrity sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw== - dependencies: - "@eslint/core" "^0.17.0" - -"@eslint/core@^0.17.0": - version "0.17.0" - resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.17.0.tgz#77225820413d9617509da9342190a2019e78761c" - integrity sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ== - dependencies: - "@types/json-schema" "^7.0.15" - -"@eslint/eslintrc@^3.3.1": - version "3.3.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.3.3.tgz#26393a0806501b5e2b6a43aa588a4d8df67880ac" - integrity sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ== - dependencies: - ajv "^6.12.4" - debug "^4.3.2" - espree "^10.0.1" - globals "^14.0.0" - ignore "^5.2.0" - import-fresh "^3.2.1" - js-yaml "^4.1.1" - minimatch "^3.1.2" - strip-json-comments "^3.1.1" - -"@eslint/js@9.39.2": - version "9.39.2" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.39.2.tgz#2d4b8ec4c3ea13c1b3748e0c97ecd766bdd80599" - integrity sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA== - -"@eslint/object-schema@^2.1.7": - version "2.1.7" - resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.7.tgz#6e2126a1347e86a4dedf8706ec67ff8e107ebbad" - integrity sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA== - -"@eslint/plugin-kit@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz#9779e3fd9b7ee33571a57435cf4335a1794a6cb2" - integrity sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA== - dependencies: - "@eslint/core" "^0.17.0" - levn "^0.4.1" - -"@humanfs/core@^0.19.1": - version "0.19.1" - resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" - integrity sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA== - -"@humanfs/node@^0.16.6": - version "0.16.7" - resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.7.tgz#822cb7b3a12c5a240a24f621b5a2413e27a45f26" - integrity sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ== - dependencies: - "@humanfs/core" "^0.19.1" - "@humanwhocodes/retry" "^0.4.0" - -======= "@eslint/config-array@^0.23.5": version "0.23.5" resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.23.5.tgz#56e86d243049195d8acc0c06a1b3dfdc3fa3de95" @@ -1287,7 +973,6 @@ resolved "https://registry.yarnpkg.com/@humanfs/types/-/types-0.15.0.tgz#f2a09f62012390b2bff3fc6fb248ddec8c09a090" integrity sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@humanwhocodes/module-importer@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" @@ -1298,21 +983,6 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba" integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ== -<<<<<<< HEAD -"@isaacs/cliui@^8.0.2": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" - integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== - dependencies: - string-width "^5.1.2" - string-width-cjs "npm:string-width@^4.2.0" - strip-ansi "^7.0.1" - strip-ansi-cjs "npm:strip-ansi@^6.0.1" - wrap-ansi "^8.1.0" - wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" - -======= ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1325,205 +995,6 @@ resolve-from "^5.0.0" "@istanbuljs/schema@^0.1.2", "@istanbuljs/schema@^0.1.3": -<<<<<<< HEAD - version "0.1.3" - resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" - integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== - -"@jest/console@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/console/-/console-30.2.0.tgz#c52fcd5b58fdd2e8eb66b2fd8ae56f2f64d05b28" - integrity sha512-+O1ifRjkvYIkBqASKWgLxrpEhQAAE7hY77ALLUufSk5717KfOShg6IbqLmdsLMPdUiFvA2kTs0R7YZy+l0IzZQ== - dependencies: - "@jest/types" "30.2.0" - "@types/node" "*" - chalk "^4.1.2" - jest-message-util "30.2.0" - jest-util "30.2.0" - slash "^3.0.0" - -"@jest/core@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/core/-/core-30.2.0.tgz#813d59faa5abd5510964a8b3a7b17cc77b775275" - integrity sha512-03W6IhuhjqTlpzh/ojut/pDB2LPRygyWX8ExpgHtQA8H/3K7+1vKmcINx5UzeOX1se6YEsBsOHQ1CRzf3fOwTQ== - dependencies: - "@jest/console" "30.2.0" - "@jest/pattern" "30.0.1" - "@jest/reporters" "30.2.0" - "@jest/test-result" "30.2.0" - "@jest/transform" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - ansi-escapes "^4.3.2" - chalk "^4.1.2" - ci-info "^4.2.0" - exit-x "^0.2.2" - graceful-fs "^4.2.11" - jest-changed-files "30.2.0" - jest-config "30.2.0" - jest-haste-map "30.2.0" - jest-message-util "30.2.0" - jest-regex-util "30.0.1" - jest-resolve "30.2.0" - jest-resolve-dependencies "30.2.0" - jest-runner "30.2.0" - jest-runtime "30.2.0" - jest-snapshot "30.2.0" - jest-util "30.2.0" - jest-validate "30.2.0" - jest-watcher "30.2.0" - micromatch "^4.0.8" - pretty-format "30.2.0" - slash "^3.0.0" - -"@jest/diff-sequences@30.0.1": - version "30.0.1" - resolved "https://registry.yarnpkg.com/@jest/diff-sequences/-/diff-sequences-30.0.1.tgz#0ededeae4d071f5c8ffe3678d15f3a1be09156be" - integrity sha512-n5H8QLDJ47QqbCNn5SuFjCRDrOLEZ0h8vAHCK5RL9Ls7Xa8AQLa/YxAc9UjFqoEDM48muwtBGjtMY5cr0PLDCw== - -"@jest/environment@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-30.2.0.tgz#1e673cdb8b93ded707cf6631b8353011460831fa" - integrity sha512-/QPTL7OBJQ5ac09UDRa3EQes4gt1FTEG/8jZ/4v5IVzx+Cv7dLxlVIvfvSVRiiX2drWyXeBjkMSR8hvOWSog5g== - dependencies: - "@jest/fake-timers" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - jest-mock "30.2.0" - -"@jest/expect-utils@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-30.2.0.tgz#4f95413d4748454fdb17404bf1141827d15e6011" - integrity sha512-1JnRfhqpD8HGpOmQp180Fo9Zt69zNtC+9lR+kT7NVL05tNXIi+QC8Csz7lfidMoVLPD3FnOtcmp0CEFnxExGEA== - dependencies: - "@jest/get-type" "30.1.0" - -"@jest/expect@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/expect/-/expect-30.2.0.tgz#9a5968499bb8add2bbb09136f69f7df5ddbf3185" - integrity sha512-V9yxQK5erfzx99Sf+7LbhBwNWEZ9eZay8qQ9+JSC0TrMR1pMDHLMY+BnVPacWU6Jamrh252/IKo4F1Xn/zfiqA== - dependencies: - expect "30.2.0" - jest-snapshot "30.2.0" - -"@jest/fake-timers@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-30.2.0.tgz#0941ddc28a339b9819542495b5408622dc9e94ec" - integrity sha512-HI3tRLjRxAbBy0VO8dqqm7Hb2mIa8d5bg/NJkyQcOk7V118ObQML8RC5luTF/Zsg4474a+gDvhce7eTnP4GhYw== - dependencies: - "@jest/types" "30.2.0" - "@sinonjs/fake-timers" "^13.0.0" - "@types/node" "*" - jest-message-util "30.2.0" - jest-mock "30.2.0" - jest-util "30.2.0" - -"@jest/get-type@30.1.0": - version "30.1.0" - resolved "https://registry.yarnpkg.com/@jest/get-type/-/get-type-30.1.0.tgz#4fcb4dc2ebcf0811be1c04fd1cb79c2dba431cbc" - integrity sha512-eMbZE2hUnx1WV0pmURZY9XoXPkUYjpc55mb0CrhtdWLtzMQPFvu/rZkTLZFTsdaVQa+Tr4eWAteqcUzoawq/uA== - -"@jest/globals@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-30.2.0.tgz#2f4b696d5862664b89c4ee2e49ae24d2bb7e0988" - integrity sha512-b63wmnKPaK+6ZZfpYhz9K61oybvbI1aMcIs80++JI1O1rR1vaxHUCNqo3ITu6NU0d4V34yZFoHMn/uoKr/Rwfw== - dependencies: - "@jest/environment" "30.2.0" - "@jest/expect" "30.2.0" - "@jest/types" "30.2.0" - jest-mock "30.2.0" - -"@jest/pattern@30.0.1": - version "30.0.1" - resolved "https://registry.yarnpkg.com/@jest/pattern/-/pattern-30.0.1.tgz#d5304147f49a052900b4b853dedb111d080e199f" - integrity sha512-gWp7NfQW27LaBQz3TITS8L7ZCQ0TLvtmI//4OwlQRx4rnWxcPNIYjxZpDcN4+UlGxgm3jS5QPz8IPTCkb59wZA== - dependencies: - "@types/node" "*" - jest-regex-util "30.0.1" - -"@jest/reporters@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-30.2.0.tgz#a36b28fcbaf0c4595250b108e6f20e363348fd91" - integrity sha512-DRyW6baWPqKMa9CzeiBjHwjd8XeAyco2Vt8XbcLFjiwCOEKOvy82GJ8QQnJE9ofsxCMPjH4MfH8fCWIHHDKpAQ== - dependencies: - "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "30.2.0" - "@jest/test-result" "30.2.0" - "@jest/transform" "30.2.0" - "@jest/types" "30.2.0" - "@jridgewell/trace-mapping" "^0.3.25" - "@types/node" "*" - chalk "^4.1.2" - collect-v8-coverage "^1.0.2" - exit-x "^0.2.2" - glob "^10.3.10" - graceful-fs "^4.2.11" - istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^6.0.0" - istanbul-lib-report "^3.0.0" - istanbul-lib-source-maps "^5.0.0" - istanbul-reports "^3.1.3" - jest-message-util "30.2.0" - jest-util "30.2.0" - jest-worker "30.2.0" - slash "^3.0.0" - string-length "^4.0.2" - v8-to-istanbul "^9.0.1" - -"@jest/schemas@30.0.5": - version "30.0.5" - resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-30.0.5.tgz#7bdf69fc5a368a5abdb49fd91036c55225846473" - integrity sha512-DmdYgtezMkh3cpU8/1uyXakv3tJRcmcXxBOcO0tbaozPwpmh4YMsnWrQm9ZmZMfa5ocbxzbFk6O4bDPEc/iAnA== - dependencies: - "@sinclair/typebox" "^0.34.0" - -"@jest/snapshot-utils@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/snapshot-utils/-/snapshot-utils-30.2.0.tgz#387858eb90c2f98f67bff327435a532ac5309fbe" - integrity sha512-0aVxM3RH6DaiLcjj/b0KrIBZhSX1373Xci4l3cW5xiUWPctZ59zQ7jj4rqcJQ/Z8JuN/4wX3FpJSa3RssVvCug== - dependencies: - "@jest/types" "30.2.0" - chalk "^4.1.2" - graceful-fs "^4.2.11" - natural-compare "^1.4.0" - -"@jest/source-map@30.0.1": - version "30.0.1" - resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-30.0.1.tgz#305ebec50468f13e658b3d5c26f85107a5620aaa" - integrity sha512-MIRWMUUR3sdbP36oyNyhbThLHyJ2eEDClPCiHVbrYAe5g3CHRArIVpBw7cdSB5fr+ofSfIb2Tnsw8iEHL0PYQg== - dependencies: - "@jridgewell/trace-mapping" "^0.3.25" - callsites "^3.1.0" - graceful-fs "^4.2.11" - -"@jest/test-result@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-30.2.0.tgz#9c0124377fb7996cdffb86eda3dbc56eacab363d" - integrity sha512-RF+Z+0CCHkARz5HT9mcQCBulb1wgCP3FBvl9VFokMX27acKphwyQsNuWH3c+ojd1LeWBLoTYoxF0zm6S/66mjg== - dependencies: - "@jest/console" "30.2.0" - "@jest/types" "30.2.0" - "@types/istanbul-lib-coverage" "^2.0.6" - collect-v8-coverage "^1.0.2" - -"@jest/test-sequencer@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-30.2.0.tgz#bf0066bc72e176d58f5dfa7f212b6e7eee44f221" - integrity sha512-wXKgU/lk8fKXMu/l5Hog1R61bL4q5GCdT6OJvdAFz1P+QrpoFuLU68eoKuVc4RbrTtNnTL5FByhWdLgOPSph+Q== - dependencies: - "@jest/test-result" "30.2.0" - graceful-fs "^4.2.11" - jest-haste-map "30.2.0" - slash "^3.0.0" - -"@jest/transform@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-30.2.0.tgz#54bef1a4510dcbd58d5d4de4fe2980a63077ef2a" - integrity sha512-XsauDV82o5qXbhalKxD7p4TZYYdwcaEXC77PPD2HixEFF+6YGppjrAAQurTl2ECWcEomHBMMNS9AH3kcCFx8jA== - dependencies: - "@babel/core" "^7.27.4" - "@jest/types" "30.2.0" -======= version "0.1.6" resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.6.tgz#8dc9afa2ac1506cb1a58f89940f1c124446c8df3" integrity sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw== @@ -1667,36 +1138,19 @@ dependencies: "@babel/core" "^7.27.4" "@jest/types" "30.4.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/trace-mapping" "^0.3.25" babel-plugin-istanbul "^7.0.1" chalk "^4.1.2" convert-source-map "^2.0.0" fast-json-stable-stringify "^2.1.0" graceful-fs "^4.2.11" -<<<<<<< HEAD - jest-haste-map "30.2.0" - jest-regex-util "30.0.1" - jest-util "30.2.0" - micromatch "^4.0.8" -======= jest-haste-map "30.4.1" jest-regex-util "30.4.0" jest-util "30.4.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) pirates "^4.0.7" slash "^3.0.0" write-file-atomic "^5.0.1" -<<<<<<< HEAD -"@jest/types@30.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-30.2.0.tgz#1c678a7924b8f59eafd4c77d56b6d0ba976d62b8" - integrity sha512-H9xg1/sfVvyfU7o3zMfBEjQ1gcsdeTMgqHoYdN79tuLqfTtuu7WckRA1R5whDwOzxaZAeMKTYWqP+WCAi0CHsg== - dependencies: - "@jest/pattern" "30.0.1" - "@jest/schemas" "30.0.5" -======= "@jest/transform@^24.9.0": version "24.9.0" resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-24.9.0.tgz#4ae2768b296553fadab09e9ec119543c90b16c56" @@ -1726,15 +1180,12 @@ dependencies: "@jest/pattern" "30.4.0" "@jest/schemas" "30.4.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/istanbul-lib-coverage" "^2.0.6" "@types/istanbul-reports" "^3.0.4" "@types/node" "*" "@types/yargs" "^17.0.33" chalk "^4.1.2" -<<<<<<< HEAD -======= "@jest/types@^24.9.0": version "24.9.0" resolved "https://registry.yarnpkg.com/@jest/types/-/types-24.9.0.tgz#63cb26cb7500d069e5a389441a7c6ab5e909fc59" @@ -1744,7 +1195,6 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@jridgewell/gen-mapping@^0.3.12", "@jridgewell/gen-mapping@^0.3.5": version "0.3.13" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f" @@ -1771,11 +1221,7 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz#6912b00d2c631c0d15ce1a7ab57cd657f2a8f8ba" integrity sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og== -<<<<<<< HEAD -"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.23", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25", "@jridgewell/trace-mapping@^0.3.28": -======= "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25", "@jridgewell/trace-mapping@^0.3.28": ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "0.3.31" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz#db15d6781c931f3a251a3dac39501c98a6082fd0" integrity sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw== @@ -1783,54 +1229,6 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -<<<<<<< HEAD -"@napi-rs/wasm-runtime@^0.2.11": - version "0.2.12" - resolved "https://registry.yarnpkg.com/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz#3e78a8b96e6c33a6c517e1894efbd5385a7cb6f2" - integrity sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ== - dependencies: - "@emnapi/core" "^1.4.3" - "@emnapi/runtime" "^1.4.3" - "@tybys/wasm-util" "^0.10.0" - -"@pkgjs/parseargs@^0.11.0": - version "0.11.0" - resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" - integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== - -"@pkgr/core@^0.2.9": - version "0.2.9" - resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.9.tgz#d229a7b7f9dac167a156992ef23c7f023653f53b" - integrity sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA== - -"@sinclair/typebox@^0.34.0": - version "0.34.41" - resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.34.41.tgz#aa51a6c1946df2c5a11494a2cdb9318e026db16c" - integrity sha512-6gS8pZzSXdyRHTIqoqSVknxolr1kzfy4/CeDnrzsVz8TTIWUbOBr6gnzOmTYJ3eXQNh4IYHIGi5aIL7sOZ2G/g== - -"@sinonjs/commons@^3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.1.tgz#1029357e44ca901a615585f6d27738dbc89084cd" - integrity sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ== - dependencies: - type-detect "4.0.8" - -"@sinonjs/fake-timers@^13.0.0": - version "13.0.5" - resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-13.0.5.tgz#36b9dbc21ad5546486ea9173d6bea063eb1717d5" - integrity sha512-36/hTbH2uaWuGVERyC6da9YwGWnzUZXuPro/F2LfsdOsLnCojz/iSH8MxUt/FD2S5XBSVPhmArFUXcpCQ2Hkiw== - dependencies: - "@sinonjs/commons" "^3.0.1" - -"@tybys/wasm-util@^0.10.0": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@tybys/wasm-util/-/wasm-util-0.10.1.tgz#ecddd3205cf1e2d5274649ff0eedd2991ed7f414" - integrity sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg== - dependencies: - tslib "^2.4.0" - -"@types/babel__core@^7.20.5": -======= "@sinclair/typebox@^0.34.0": version "0.34.49" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.34.49.tgz#4f1369234f2ecf693866476c3b2e1b54d2a9d68e" @@ -1849,7 +1247,6 @@ picomatch "^4.0.3" "@types/babel__core@^7.1.0", "@types/babel__core@^7.20.5": ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA== @@ -1861,47 +1258,20 @@ "@types/babel__traverse" "*" "@types/babel__generator@*": -<<<<<<< HEAD - version "7.0.2" - resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.0.2.tgz#d2112a6b21fad600d7674274293c85dce0cb47fc" - integrity sha512-NHcOfab3Zw4q5sEE2COkpfXjoE7o+PmqD9DQW4koUT3roNxwziUdXGnRndMat/LJNUtePwn1TlP4do3uoe3KZQ== -======= version "7.27.0" resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.27.0.tgz#b5819294c51179957afaec341442f9341e4108a9" integrity sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: "@babel/types" "^7.0.0" "@types/babel__template@*": -<<<<<<< HEAD - version "7.0.2" - resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.0.2.tgz#4ff63d6b52eddac1de7b975a5223ed32ecea9307" - integrity sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg== -======= version "7.4.4" resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f" integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" -<<<<<<< HEAD -"@types/babel__traverse@*": - version "7.0.6" - resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.0.6.tgz#328dd1a8fc4cfe3c8458be9477b219ea158fd7b2" - integrity sha512-XYVgHF2sQ0YblLRMLNPB3CkFMewzFmlDsH/TneZFHUXDlABQgh88uOxuez7ZcXxayLFrqLwtDH1t+FmlFwNZxw== - dependencies: - "@babel/types" "^7.3.0" - -"@types/estree@^1.0.6": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" - integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== - -"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.1", "@types/istanbul-lib-coverage@^2.0.6": -======= "@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": version "7.28.0" resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.28.0.tgz#07d713d6cce0d265c9849db0cbe62d3f61f36f74" @@ -1920,7 +1290,6 @@ integrity sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg== "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.6": ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.6" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== @@ -1932,8 +1301,6 @@ dependencies: "@types/istanbul-lib-coverage" "*" -<<<<<<< HEAD -======= "@types/istanbul-reports@^1.1.1": version "1.1.2" resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz#e875cc689e47bce549ec81f3df5e6f6f11cfaeb2" @@ -1942,7 +1309,6 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/istanbul-reports@^3.0.4": version "3.0.4" resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" @@ -1956,18 +1322,6 @@ integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== "@types/node@*": -<<<<<<< HEAD - version "25.0.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-25.0.2.tgz#411f9dd6cb2bf5ee46aed7199a9f85ca6b068b4e" - integrity sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA== - dependencies: - undici-types "~7.16.0" - -"@types/stack-utils@^2.0.3": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" - integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== -======= version "25.9.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-25.9.1.tgz#3bda556db500ae4319c08e7fc9ab94f19013ba0b" integrity sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg== @@ -1978,15 +1332,12 @@ version "1.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/yargs-parser@*": version "21.0.3" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== -<<<<<<< HEAD -======= "@types/yargs@^13.0.0": version "13.0.12" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-13.0.12.tgz#d895a88c703b78af0465a9de88aa92c61430b092" @@ -1994,7 +1345,6 @@ dependencies: "@types/yargs-parser" "*" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/yargs@^17.0.33": version "17.0.35" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.35.tgz#07013e46aa4d7d7d50a49e15604c1c5340d4eb24" @@ -2002,109 +1352,6 @@ dependencies: "@types/yargs-parser" "*" -<<<<<<< HEAD -"@ungap/structured-clone@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8" - integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== - -"@unrs/resolver-binding-android-arm-eabi@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-android-arm-eabi/-/resolver-binding-android-arm-eabi-1.11.1.tgz#9f5b04503088e6a354295e8ea8fe3cb99e43af81" - integrity sha512-ppLRUgHVaGRWUx0R0Ut06Mjo9gBaBkg3v/8AxusGLhsIotbBLuRk51rAzqLC8gq6NyyAojEXglNjzf6R948DNw== - -"@unrs/resolver-binding-android-arm64@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-android-arm64/-/resolver-binding-android-arm64-1.11.1.tgz#7414885431bd7178b989aedc4d25cccb3865bc9f" - integrity sha512-lCxkVtb4wp1v+EoN+HjIG9cIIzPkX5OtM03pQYkG+U5O/wL53LC4QbIeazgiKqluGeVEeBlZahHalCaBvU1a2g== - -"@unrs/resolver-binding-darwin-arm64@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-darwin-arm64/-/resolver-binding-darwin-arm64-1.11.1.tgz#b4a8556f42171fb9c9f7bac8235045e82aa0cbdf" - integrity sha512-gPVA1UjRu1Y/IsB/dQEsp2V1pm44Of6+LWvbLc9SDk1c2KhhDRDBUkQCYVWe6f26uJb3fOK8saWMgtX8IrMk3g== - -"@unrs/resolver-binding-darwin-x64@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-darwin-x64/-/resolver-binding-darwin-x64-1.11.1.tgz#fd4d81257b13f4d1a083890a6a17c00de571f0dc" - integrity sha512-cFzP7rWKd3lZaCsDze07QX1SC24lO8mPty9vdP+YVa3MGdVgPmFc59317b2ioXtgCMKGiCLxJ4HQs62oz6GfRQ== - -"@unrs/resolver-binding-freebsd-x64@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-freebsd-x64/-/resolver-binding-freebsd-x64-1.11.1.tgz#d2513084d0f37c407757e22f32bd924a78cfd99b" - integrity sha512-fqtGgak3zX4DCB6PFpsH5+Kmt/8CIi4Bry4rb1ho6Av2QHTREM+47y282Uqiu3ZRF5IQioJQ5qWRV6jduA+iGw== - -"@unrs/resolver-binding-linux-arm-gnueabihf@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-arm-gnueabihf/-/resolver-binding-linux-arm-gnueabihf-1.11.1.tgz#844d2605d057488d77fab09705f2866b86164e0a" - integrity sha512-u92mvlcYtp9MRKmP+ZvMmtPN34+/3lMHlyMj7wXJDeXxuM0Vgzz0+PPJNsro1m3IZPYChIkn944wW8TYgGKFHw== - -"@unrs/resolver-binding-linux-arm-musleabihf@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-arm-musleabihf/-/resolver-binding-linux-arm-musleabihf-1.11.1.tgz#204892995cefb6bd1d017d52d097193bc61ddad3" - integrity sha512-cINaoY2z7LVCrfHkIcmvj7osTOtm6VVT16b5oQdS4beibX2SYBwgYLmqhBjA1t51CarSaBuX5YNsWLjsqfW5Cw== - -"@unrs/resolver-binding-linux-arm64-gnu@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-arm64-gnu/-/resolver-binding-linux-arm64-gnu-1.11.1.tgz#023eb0c3aac46066a10be7a3f362e7b34f3bdf9d" - integrity sha512-34gw7PjDGB9JgePJEmhEqBhWvCiiWCuXsL9hYphDF7crW7UgI05gyBAi6MF58uGcMOiOqSJ2ybEeCvHcq0BCmQ== - -"@unrs/resolver-binding-linux-arm64-musl@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-arm64-musl/-/resolver-binding-linux-arm64-musl-1.11.1.tgz#9e6f9abb06424e3140a60ac996139786f5d99be0" - integrity sha512-RyMIx6Uf53hhOtJDIamSbTskA99sPHS96wxVE/bJtePJJtpdKGXO1wY90oRdXuYOGOTuqjT8ACccMc4K6QmT3w== - -"@unrs/resolver-binding-linux-ppc64-gnu@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-ppc64-gnu/-/resolver-binding-linux-ppc64-gnu-1.11.1.tgz#b111417f17c9d1b02efbec8e08398f0c5527bb44" - integrity sha512-D8Vae74A4/a+mZH0FbOkFJL9DSK2R6TFPC9M+jCWYia/q2einCubX10pecpDiTmkJVUH+y8K3BZClycD8nCShA== - -"@unrs/resolver-binding-linux-riscv64-gnu@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-riscv64-gnu/-/resolver-binding-linux-riscv64-gnu-1.11.1.tgz#92ffbf02748af3e99873945c9a8a5ead01d508a9" - integrity sha512-frxL4OrzOWVVsOc96+V3aqTIQl1O2TjgExV4EKgRY09AJ9leZpEg8Ak9phadbuX0BA4k8U5qtvMSQQGGmaJqcQ== - -"@unrs/resolver-binding-linux-riscv64-musl@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-riscv64-musl/-/resolver-binding-linux-riscv64-musl-1.11.1.tgz#0bec6f1258fc390e6b305e9ff44256cb207de165" - integrity sha512-mJ5vuDaIZ+l/acv01sHoXfpnyrNKOk/3aDoEdLO/Xtn9HuZlDD6jKxHlkN8ZhWyLJsRBxfv9GYM2utQ1SChKew== - -"@unrs/resolver-binding-linux-s390x-gnu@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-s390x-gnu/-/resolver-binding-linux-s390x-gnu-1.11.1.tgz#577843a084c5952f5906770633ccfb89dac9bc94" - integrity sha512-kELo8ebBVtb9sA7rMe1Cph4QHreByhaZ2QEADd9NzIQsYNQpt9UkM9iqr2lhGr5afh885d/cB5QeTXSbZHTYPg== - -"@unrs/resolver-binding-linux-x64-gnu@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-x64-gnu/-/resolver-binding-linux-x64-gnu-1.11.1.tgz#36fb318eebdd690f6da32ac5e0499a76fa881935" - integrity sha512-C3ZAHugKgovV5YvAMsxhq0gtXuwESUKc5MhEtjBpLoHPLYM+iuwSj3lflFwK3DPm68660rZ7G8BMcwSro7hD5w== - -"@unrs/resolver-binding-linux-x64-musl@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-linux-x64-musl/-/resolver-binding-linux-x64-musl-1.11.1.tgz#bfb9af75f783f98f6a22c4244214efe4df1853d6" - integrity sha512-rV0YSoyhK2nZ4vEswT/QwqzqQXw5I6CjoaYMOX0TqBlWhojUf8P94mvI7nuJTeaCkkds3QE4+zS8Ko+GdXuZtA== - -"@unrs/resolver-binding-wasm32-wasi@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-wasm32-wasi/-/resolver-binding-wasm32-wasi-1.11.1.tgz#752c359dd875684b27429500d88226d7cc72f71d" - integrity sha512-5u4RkfxJm+Ng7IWgkzi3qrFOvLvQYnPBmjmZQ8+szTK/b31fQCnleNl1GgEt7nIsZRIf5PLhPwT0WM+q45x/UQ== - dependencies: - "@napi-rs/wasm-runtime" "^0.2.11" - -"@unrs/resolver-binding-win32-arm64-msvc@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-win32-arm64-msvc/-/resolver-binding-win32-arm64-msvc-1.11.1.tgz#ce5735e600e4c2fbb409cd051b3b7da4a399af35" - integrity sha512-nRcz5Il4ln0kMhfL8S3hLkxI85BXs3o8EYoattsJNdsX4YUU89iOkVn7g0VHSRxFuVMdM4Q1jEpIId1Ihim/Uw== - -"@unrs/resolver-binding-win32-ia32-msvc@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-win32-ia32-msvc/-/resolver-binding-win32-ia32-msvc-1.11.1.tgz#72fc57bc7c64ec5c3de0d64ee0d1810317bc60a6" - integrity sha512-DCEI6t5i1NmAZp6pFonpD5m7i6aFrpofcp4LA2i8IIq60Jyo28hamKBxNrZcyOwVOZkgsRp9O2sXWBWP8MnvIQ== - -"@unrs/resolver-binding-win32-x64-msvc@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@unrs/resolver-binding-win32-x64-msvc/-/resolver-binding-win32-x64-msvc-1.11.1.tgz#538b1e103bf8d9864e7b85cc96fa8d6fb6c40777" - integrity sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g== -======= "@typescript-eslint/types@^8.56.0": version "8.60.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.60.1.tgz#ccdc482ba9e17f9723a10ce240b5e67dad3046c4" @@ -2127,24 +1374,12 @@ acorn-globals@^4.1.0: dependencies: acorn "^6.0.1" acorn-walk "^6.0.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -<<<<<<< HEAD -acorn@^8.15.0: - version "8.15.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816" - integrity sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg== - -ajv@^6.12.4: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== -======= acorn-walk@^6.0.1: version "6.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.2.0.tgz#123cb8f3b84c2171f1f7fb252615b1c78a6b1a8c" @@ -2169,33 +1404,12 @@ ajv@^6.12.3, ajv@^6.14.0: version "6.15.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.15.0.tgz#07e982c74626167aa7a2495c53817892d7139492" integrity sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: fast-deep-equal "^3.1.1" fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.4.1" uri-js "^4.2.2" -<<<<<<< HEAD -ansi-escapes@^4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" - integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== - dependencies: - type-fest "^0.21.3" - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-regex@^6.0.1: - version "6.2.2" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.2.2.tgz#60216eea464d864597ce2832000738a0589650c1" - integrity sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg== - -ansi-styles@^3.2.1: -======= ansi-escapes@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" @@ -2212,35 +1426,19 @@ ansi-regex@^4.0.0, ansi-regex@^4.1.0: integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-styles@^3.2.0, ansi-styles@^3.2.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" -<<<<<<< HEAD -ansi-styles@^4.0.0, ansi-styles@^4.1.0: -======= ansi-styles@^4.1.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: color-convert "^2.0.1" -<<<<<<< HEAD -ansi-styles@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" - integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== - -ansi-styles@^6.1.0: - version "6.2.3" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.3.tgz#c044d5dcc521a076413472597a1acb1f103c4041" - integrity sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg== -======= anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -2248,7 +1446,6 @@ anymatch@^2.0.0: dependencies: micromatch "^3.1.4" normalize-path "^2.1.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) anymatch@^3.1.3: version "3.1.3" @@ -2265,22 +1462,6 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -<<<<<<< HEAD -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - -babel-jest@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-30.2.0.tgz#fd44a1ec9552be35ead881f7381faa7d8f3b95ac" - integrity sha512-0YiBEOxWqKkSQWL9nNGGEgndoeL0ZpWrbLMNL5u/Kaxrli3Eaxlt3ZtIDktEvXt4L/R9r3ODr2zKwGM/2BjxVw== - dependencies: - "@jest/transform" "30.2.0" - "@types/babel__core" "^7.20.5" - babel-plugin-istanbul "^7.0.1" - babel-preset-jest "30.2.0" -======= arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" @@ -2422,13 +1603,10 @@ babel-jest@^30.4.1: "@types/babel__core" "^7.20.5" babel-plugin-istanbul "^7.0.1" babel-preset-jest "30.4.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) chalk "^4.1.2" graceful-fs "^4.2.11" slash "^3.0.0" -<<<<<<< HEAD -======= babel-plugin-istanbul@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.2.0.tgz#df4ade83d897a92df069c4d9a25cf2671293c854" @@ -2439,7 +1617,6 @@ babel-plugin-istanbul@^5.1.0: istanbul-lib-instrument "^3.3.0" test-exclude "^5.2.3" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) babel-plugin-istanbul@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-7.0.1.tgz#d8b518c8ea199364cf84ccc82de89740236daf92" @@ -2451,15 +1628,6 @@ babel-plugin-istanbul@^7.0.1: istanbul-lib-instrument "^6.0.2" test-exclude "^6.0.0" -<<<<<<< HEAD -babel-plugin-jest-hoist@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-30.2.0.tgz#94c250d36b43f95900f3a219241e0f4648191ce2" - integrity sha512-ftzhzSGMUnOzcCXd6WHdBGMyuwy15Wnn0iyyWGKgBDLxf9/s5ABuraCSpBX2uG0jUg4rqJnxsLc5+oYBqoxVaA== - dependencies: - "@types/babel__core" "^7.20.5" - -======= babel-plugin-jest-hoist@30.4.0: version "30.4.0" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-30.4.0.tgz#f7d6a6d8f435808b56b45a81dc4b61a39e36794a" @@ -2498,7 +1666,6 @@ babel-plugin-polyfill-regenerator@^0.6.6: dependencies: "@babel/helper-define-polyfill-provider" "^0.6.8" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) babel-preset-current-node-syntax@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.2.0.tgz#20730d6cdc7dda5d89401cab10ac6a32067acde6" @@ -2520,30 +1687,6 @@ babel-preset-current-node-syntax@^1.2.0: "@babel/plugin-syntax-private-property-in-object" "^7.14.5" "@babel/plugin-syntax-top-level-await" "^7.14.5" -<<<<<<< HEAD -babel-preset-jest@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-30.2.0.tgz#04717843e561347781d6d7f69c81e6bcc3ed11ce" - integrity sha512-US4Z3NOieAQumwFnYdUWKvUKh8+YSnS/gB3t6YBiz0bskpu7Pine8pPCheNxlPEW4wnUkma2a94YuW2q3guvCQ== - dependencies: - babel-plugin-jest-hoist "30.2.0" - babel-preset-current-node-syntax "^1.2.0" - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -baseline-browser-mapping@^2.9.0: - version "2.9.7" - resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.9.7.tgz#d36ce64f2a2c468f6f743c8db495d319120007db" - integrity sha512-k9xFKplee6KIio3IDbwj+uaCLpqzOwakOgmqzPezM0sFJlFKcg30vk2wOiAJtkTSfx0SSQDSe8q+mWA/fSH5Zg== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== -======= babel-preset-jest@30.4.0: version "30.4.0" resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-30.4.0.tgz#295486c2ec1127b3dc7d0d2adaa72a1dcaaafccd" @@ -2606,37 +1749,10 @@ brace-expansion@^1.1.7: version "1.1.15" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.15.tgz#a6d90d54067236e5f42570a3b7378d594d9b7738" integrity sha512-EwOCDEex4quD37XhqM3omwtMoJjr//isUZz1JopUNWms+4Z2ViyM/k1YIRePpoVNnQhENnxtFjLaxNHrT7xIUg== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: balanced-match "^1.0.0" concat-map "0.0.1" -<<<<<<< HEAD -brace-expansion@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.2.tgz#54fc53237a613d854c7bd37463aad17df87214e7" - integrity sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ== - dependencies: - balanced-match "^1.0.0" - -braces@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" - integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== - dependencies: - fill-range "^7.1.1" - -browserslist@^4.24.0: - version "4.28.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.28.1.tgz#7f534594628c53c63101079e27e40de490456a95" - integrity sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA== - dependencies: - baseline-browser-mapping "^2.9.0" - caniuse-lite "^1.0.30001759" - electron-to-chromium "^1.5.263" - node-releases "^2.0.27" - update-browserslist-db "^1.2.0" -======= brace-expansion@^5.0.5: version "5.0.6" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-5.0.6.tgz#ec68fe0a641a29d8711579caf641d05bae1f2285" @@ -2682,7 +1798,6 @@ browserslist@^4.24.0, browserslist@^4.28.1: electron-to-chromium "^1.5.328" node-releases "^2.0.36" update-browserslist-db "^1.2.3" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) bser@2.1.1: version "2.1.1" @@ -2692,18 +1807,6 @@ bser@2.1.1: node-int64 "^0.4.0" buffer-from@^1.0.0: -<<<<<<< HEAD - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -callsites@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.0.0.tgz#fb7eb569b72ad7a45812f93fd9430a3e410b3dd3" - integrity sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw== - -callsites@^3.1.0: -======= version "1.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== @@ -2750,33 +1853,15 @@ call-bound@^1.0.2, call-bound@^1.0.3, call-bound@^1.0.4: get-intrinsic "^1.3.0" callsites@^3.0.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -<<<<<<< HEAD -camelcase@^5.3.1: -======= camelcase@^5.0.0, camelcase@^5.3.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -<<<<<<< HEAD -camelcase@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" - integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== - -caniuse-lite@^1.0.30001759: - version "1.0.30001760" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001760.tgz#bdd1960fafedf8d5f04ff16e81460506ff9b798f" - integrity sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw== - -chalk@^2.0.0: -======= caniuse-lite@^1.0.30001782: version "1.0.30001793" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001793.tgz#238887ddf5fcfc8c36d872394d0a78a517312a72" @@ -2795,7 +1880,6 @@ caseless@~0.12.0: integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== chalk@^2.0.1, chalk@^2.4.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -2804,11 +1888,7 @@ chalk@^2.0.1, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -<<<<<<< HEAD -chalk@^4.0.0, chalk@^4.1.2: -======= chalk@^4.1.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -2816,31 +1896,6 @@ chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -<<<<<<< HEAD -char-regex@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" - integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== - -ci-info@^4.2.0: - version "4.3.1" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-4.3.1.tgz#355ad571920810b5623e11d40232f443f16f1daa" - integrity sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA== - -cjs-module-lexer@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-2.1.1.tgz#bff23b0609cc9afa428bd35f1918f7d03b448562" - integrity sha512-+CmxIZ/L2vNcEfvNtLdU0ZQ6mbq3FZnwAP2PPTiKP+1QOoKwlKlPgb8UKV0Dds7QVaMnHm+FwSft2VB0s/SLjQ== - -cliui@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" - integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.1" - wrap-ansi "^7.0.0" -======= ci-info@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" @@ -2869,19 +1924,10 @@ cliui@^5.0.0: string-width "^3.1.0" strip-ansi "^5.2.0" wrap-ansi "^5.1.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" -<<<<<<< HEAD - integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= - -collect-v8-coverage@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz#cc1f01eb8d02298cbc9a437c74c70ab4e5210b80" - integrity sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw== -======= integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== collection-visit@^1.0.0: @@ -2891,7 +1937,6 @@ collection-visit@^1.0.0: dependencies: map-visit "^1.0.0" object-visit "^1.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) color-convert@^1.9.0: version "1.9.3" @@ -2910,23 +1955,13 @@ color-convert@^2.0.1: color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" -<<<<<<< HEAD - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -======= integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -<<<<<<< HEAD -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -======= combined-stream@^1.0.6, combined-stream@~1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" @@ -2948,16 +1983,12 @@ convert-source-map@^1.4.0: version "1.9.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) convert-source-map@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== -<<<<<<< HEAD -cross-spawn@^7.0.3, cross-spawn@^7.0.6: -======= copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" @@ -2987,7 +2018,6 @@ cross-spawn@^6.0.0: which "^1.2.9" cross-spawn@^7.0.6: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.0.6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== @@ -2996,16 +2026,6 @@ cross-spawn@^7.0.6: shebang-command "^2.0.0" which "^2.0.1" -<<<<<<< HEAD -debug@^4.1.0, debug@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" - -debug@^4.3.1, debug@^4.3.2: -======= cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0": version "0.3.8" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" @@ -3069,21 +2089,12 @@ debug@^2.2.0, debug@^2.3.3: ms "2.0.0" debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.4.3: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.4.3" resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a" integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA== dependencies: ms "^2.1.3" -<<<<<<< HEAD -dedent@^1.6.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.7.0.tgz#c1f9445335f0175a96587be245a282ff451446ca" - integrity sha512-HGFtf8yhuhGhqO07SV79tRp+br4MnbdjeVxotpn1QBl30pcLLCQjX5b2295ll0fv8RKDKsmWYrl05usHM9CewQ== - -deep-is@^0.1.3: -======= decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -3095,56 +2106,10 @@ decode-uri-component@^0.2.0: integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== deep-is@^0.1.3, deep-is@~0.1.3: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -<<<<<<< HEAD -deepmerge@^4.3.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" - integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== - -detect-newline@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" - integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== - -eastasianwidth@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" - integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== - -electron-to-chromium@^1.5.263: - version "1.5.267" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.267.tgz#5d84f2df8cdb6bfe7e873706bb21bd4bfb574dc7" - integrity sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw== - -emittery@^0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad" - integrity sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escalade@^3.1.1, escalade@^3.2.0: -======= define-data-property@^1.0.1, define-data-property@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" @@ -3350,7 +2315,6 @@ es-to-primitive@^1.3.0: is-symbol "^1.0.4" escalade@^3.2.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.2.0" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== @@ -3358,11 +2322,7 @@ escalade@^3.2.0: escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -<<<<<<< HEAD - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -======= integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) escape-string-regexp@^2.0.0: version "2.0.0" @@ -3374,13 +2334,6 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -<<<<<<< HEAD -eslint-scope@^8.4.0: - version "8.4.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.4.0.tgz#88e646a207fad61436ffa39eb505147200655c82" - integrity sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg== - dependencies: -======= escodegen@^1.9.1: version "1.14.3" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" @@ -3400,7 +2353,6 @@ eslint-scope@^9.1.2: dependencies: "@types/esrecurse" "^4.3.1" "@types/estree" "^1.0.8" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) esrecurse "^4.3.0" estraverse "^5.2.0" @@ -3414,21 +2366,6 @@ eslint-visitor-keys@^4.2.1: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz#4cfea60fe7dd0ad8e816e1ed026c1d5251b512c1" integrity sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ== -<<<<<<< HEAD -eslint@^9.39.2: - version "9.39.2" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.39.2.tgz#cb60e6d16ab234c0f8369a3fe7cc87967faf4b6c" - integrity sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw== - dependencies: - "@eslint-community/eslint-utils" "^4.8.0" - "@eslint-community/regexpp" "^4.12.1" - "@eslint/config-array" "^0.21.1" - "@eslint/config-helpers" "^0.4.2" - "@eslint/core" "^0.17.0" - "@eslint/eslintrc" "^3.3.1" - "@eslint/js" "9.39.2" - "@eslint/plugin-kit" "^0.4.1" -======= eslint-visitor-keys@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz#9e3c9489697824d2d4ce3a8ad12628f91e9f59be" @@ -3445,22 +2382,10 @@ eslint@^10.0.0: "@eslint/config-helpers" "^0.6.0" "@eslint/core" "^1.2.1" "@eslint/plugin-kit" "^0.7.2" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@humanfs/node" "^0.16.6" "@humanwhocodes/module-importer" "^1.0.1" "@humanwhocodes/retry" "^0.4.2" "@types/estree" "^1.0.6" -<<<<<<< HEAD - ajv "^6.12.4" - chalk "^4.0.0" - cross-spawn "^7.0.6" - debug "^4.3.2" - escape-string-regexp "^4.0.0" - eslint-scope "^8.4.0" - eslint-visitor-keys "^4.2.1" - espree "^10.4.0" - esquery "^1.5.0" -======= ajv "^6.14.0" cross-spawn "^7.0.6" debug "^4.3.2" @@ -3469,7 +2394,6 @@ eslint@^10.0.0: eslint-visitor-keys "^5.0.1" espree "^11.2.0" esquery "^1.7.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^8.0.0" @@ -3479,20 +2403,11 @@ eslint@^10.0.0: imurmurhash "^0.1.4" is-glob "^4.0.0" json-stable-stringify-without-jsonify "^1.0.1" -<<<<<<< HEAD - lodash.merge "^4.6.2" - minimatch "^3.1.2" - natural-compare "^1.4.0" - optionator "^0.9.3" - -espree@^10.0.1, espree@^10.4.0: -======= minimatch "^10.2.4" natural-compare "^1.4.0" optionator "^0.9.3" espree@^10.4.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "10.4.0" resolved "https://registry.yarnpkg.com/espree/-/espree-10.4.0.tgz#d54f4949d4629005a1fa168d937c3ff1f7e2a837" integrity sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ== @@ -3501,9 +2416,6 @@ espree@^10.4.0: acorn-jsx "^5.3.2" eslint-visitor-keys "^4.2.1" -<<<<<<< HEAD -esprima@^4.0.0: -======= espree@^11.2.0: version "11.2.0" resolved "https://registry.yarnpkg.com/espree/-/espree-11.2.0.tgz#01d5e47dc332aaba3059008362454a8cc34ccaa5" @@ -3514,22 +2426,14 @@ espree@^11.2.0: eslint-visitor-keys "^5.0.1" esprima@^4.0.0, esprima@^4.0.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -<<<<<<< HEAD -esquery@^1.5.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" - integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== -======= esquery@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.7.0.tgz#08d048f261f0ddedb5bae95f46809463d9c9496d" integrity sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: estraverse "^5.1.0" @@ -3540,58 +2444,17 @@ esrecurse@^4.3.0: dependencies: estraverse "^5.2.0" -<<<<<<< HEAD -estraverse@^5.1.0, estraverse@^5.2.0: -======= estraverse@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "5.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== esutils@^2.0.2: -<<<<<<< HEAD - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= - -execa@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" - integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== - dependencies: - cross-spawn "^7.0.3" - get-stream "^6.0.0" - human-signals "^2.1.0" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.1" - onetime "^5.1.2" - signal-exit "^3.0.3" - strip-final-newline "^2.0.0" - -exit-x@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/exit-x/-/exit-x-0.2.2.tgz#1f9052de3b8d99a696b10dad5bced9bdd5c3aa64" - integrity sha512-+I6B/IkJc1o/2tiURyz/ivu/O0nKNEArIUB5O7zBrlDVJr22SCLH3xTeEry428LvFhRzIA1g8izguxJ/gbNcVQ== - -expect@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/expect/-/expect-30.2.0.tgz#d4013bed267013c14bc1199cec8aa57cee9b5869" - integrity sha512-u/feCi0GPsI+988gU2FLcsHyAHTU0MX1Wg68NhAnN7z/+C5wqG+CY8J53N9ioe8RXgaoz0nBR/TYMf3AycUuPw== - dependencies: - "@jest/expect-utils" "30.2.0" - "@jest/get-type" "30.1.0" - jest-matcher-utils "30.2.0" - jest-message-util "30.2.0" - jest-mock "30.2.0" - jest-util "30.2.0" -======= version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== @@ -3687,41 +2550,23 @@ extsprintf@^1.2.0: version "1.4.1" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07" integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -<<<<<<< HEAD -fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= - -fast-json-stable-stringify@^2.1.0: -======= fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -<<<<<<< HEAD -fast-levenshtein@^2.0.6: -======= fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== -<<<<<<< HEAD -fb-watchman@^2.0.2: -======= fb-watchman@^2.0.0, fb-watchman@^2.0.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.2" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== @@ -3735,16 +2580,6 @@ file-entry-cache@^8.0.0: dependencies: flat-cache "^4.0.0" -<<<<<<< HEAD -fill-range@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" - integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== - dependencies: - to-regex-range "^5.0.1" - -find-up@^4.0.0, find-up@^4.1.0: -======= file-uri-to-path@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" @@ -3768,7 +2603,6 @@ find-up@^3.0.0: locate-path "^3.0.0" find-up@^4.1.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== @@ -3793,19 +2627,6 @@ flat-cache@^4.0.0: keyv "^4.5.4" flatted@^3.2.9: -<<<<<<< HEAD - version "3.3.3" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358" - integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== - -foreground-child@^3.1.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.1.tgz#32e8e9ed1b68a3497befb9ac2b6adf92a638576f" - integrity sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw== - dependencies: - cross-spawn "^7.0.6" - signal-exit "^4.0.1" -======= version "3.4.2" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.4.2.tgz#f5c23c107f0f37de8dbdf24f13722b3b98d52726" integrity sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA== @@ -3842,14 +2663,10 @@ fragment-cache@^0.2.1: integrity sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA== dependencies: map-cache "^0.2.2" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" -<<<<<<< HEAD - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= -======= integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@^1.2.7: @@ -3859,15 +2676,12 @@ fsevents@^1.2.7: dependencies: bindings "^1.5.0" nan "^2.12.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) fsevents@^2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== -<<<<<<< HEAD -======= function-bind@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" @@ -3895,23 +2709,16 @@ generator-function@^2.0.0: resolved "https://registry.yarnpkg.com/generator-function/-/generator-function-2.0.1.tgz#0e75dd410d1243687a0ba2e951b94eedb8f737a2" integrity sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== -<<<<<<< HEAD -get-caller-file@^2.0.5: -======= get-caller-file@^2.0.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -<<<<<<< HEAD -======= get-intrinsic@^1.2.4, get-intrinsic@^1.2.5, get-intrinsic@^1.2.6, get-intrinsic@^1.2.7, get-intrinsic@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" @@ -3928,18 +2735,11 @@ get-intrinsic@^1.2.4, get-intrinsic@^1.2.5, get-intrinsic@^1.2.6, get-intrinsic@ hasown "^2.0.2" math-intrinsics "^1.1.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== -<<<<<<< HEAD -get-stream@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== -======= get-proto@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" @@ -3975,7 +2775,6 @@ getpass@^0.1.1: integrity sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng== dependencies: assert-plus "^1.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) glob-parent@^6.0.2: version "6.0.2" @@ -3984,23 +2783,7 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" -<<<<<<< HEAD -glob@^10.3.10: - version "10.5.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-10.5.0.tgz#8ec0355919cd3338c28428a23d4f24ecc5fe738c" - integrity sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg== - dependencies: - foreground-child "^3.1.0" - jackspeak "^3.1.2" - minimatch "^9.0.4" - minipass "^7.1.2" - package-json-from-dist "^1.0.0" - path-scurry "^1.11.1" - -glob@^7.1.4: -======= glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -4012,14 +2795,6 @@ glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -<<<<<<< HEAD -globals@^14.0.0: - version "14.0.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" - integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== - -graceful-fs@^4.2.11: -======= globals@^17.6.0: version "17.6.0" resolved "https://registry.yarnpkg.com/globals/-/globals-17.6.0.tgz#0f0be018d5cca8690e6375ead1f65c4bb96191fc" @@ -4039,17 +2814,10 @@ gopd@^1.0.1, gopd@^1.2.0: integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.2.11: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== -<<<<<<< HEAD -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= -======= growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" @@ -4077,15 +2845,12 @@ has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -<<<<<<< HEAD -======= has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" @@ -4162,18 +2927,11 @@ html-encoding-sniffer@^1.0.2: dependencies: whatwg-encoding "^1.0.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) html-escaper@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -<<<<<<< HEAD -human-signals@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" - integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -======= http-signature@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" @@ -4189,30 +2947,12 @@ iconv-lite@0.4.24: integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== dependencies: safer-buffer ">= 2.1.2 < 3" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) ignore@^5.2.0: version "5.3.2" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5" integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g== -<<<<<<< HEAD -import-fresh@^3.2.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.1.tgz#9cecb56503c0ada1f2741dbbd6546e4b13b57ccf" - integrity sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -import-local@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.2.0.tgz#c3d5c745798c02a6f8b897726aba5100186ee260" - integrity sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" -======= import-local@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" @@ -4220,35 +2960,21 @@ import-local@^2.0.0: dependencies: pkg-dir "^3.0.0" resolve-cwd "^2.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" -<<<<<<< HEAD - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= -======= integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" -<<<<<<< HEAD - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= -======= integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: once "^1.3.0" wrappy "1" inherits@2: -<<<<<<< HEAD - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -======= version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -4284,14 +3010,10 @@ is-array-buffer@^3.0.4, is-array-buffer@^3.0.5: call-bind "^1.0.8" call-bound "^1.0.3" get-intrinsic "^1.2.6" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" -<<<<<<< HEAD - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= -======= integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== is-async-function@^2.0.0: @@ -4395,21 +3117,12 @@ is-extendable@^1.0.1: integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== dependencies: is-plain-object "^2.0.4" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== -<<<<<<< HEAD -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-generator-fn@^2.1.0: -======= is-finalizationregistry@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz#eefdcdc6c94ddd0674d9c85887bf93f944a97c90" @@ -4423,13 +3136,10 @@ is-fullwidth-code-point@^2.0.0: integrity sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w== is-generator-fn@^2.0.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.1.0" resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -<<<<<<< HEAD -======= is-generator-function@^1.0.10: version "1.1.2" resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.1.2.tgz#ae3b61e3d5ea4e4839b90bad22b02335051a17d5" @@ -4441,7 +3151,6 @@ is-generator-function@^1.0.10: has-tostringtag "^1.0.2" safe-regex-test "^1.1.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) is-glob@^4.0.0, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" @@ -4449,17 +3158,6 @@ is-glob@^4.0.0, is-glob@^4.0.3: dependencies: is-extglob "^2.1.1" -<<<<<<< HEAD -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== -======= is-map@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.3.tgz#ede96b7fe1e270b3c4465e3a465658764926d62e" @@ -4587,16 +3285,10 @@ isarray@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" -<<<<<<< HEAD - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: -======= integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== isobject@^2.0.0: @@ -4622,14 +3314,10 @@ istanbul-lib-coverage@^2.0.2, istanbul-lib-coverage@^2.0.5: integrity sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA== istanbul-lib-coverage@^3.2.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.2.2" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756" integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg== -<<<<<<< HEAD -istanbul-lib-instrument@^6.0.0, istanbul-lib-instrument@^6.0.2: -======= istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz#a5f63d91f0bbc0c3e479ef4c5de027335ec6d630" @@ -4644,7 +3332,6 @@ istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.3.0: semver "^6.0.0" istanbul-lib-instrument@^6.0.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "6.0.3" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz#fa15401df6c15874bcb2105f773325d78c666765" integrity sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q== @@ -4655,171 +3342,6 @@ istanbul-lib-instrument@^6.0.2: istanbul-lib-coverage "^3.2.0" semver "^7.5.4" -<<<<<<< HEAD -istanbul-lib-report@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" - integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== - dependencies: - istanbul-lib-coverage "^3.0.0" - make-dir "^4.0.0" - supports-color "^7.1.0" - -istanbul-lib-source-maps@^5.0.0: - version "5.0.6" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz#acaef948df7747c8eb5fbf1265cb980f6353a441" - integrity sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A== - dependencies: - "@jridgewell/trace-mapping" "^0.3.23" - debug "^4.1.1" - istanbul-lib-coverage "^3.0.0" - -istanbul-reports@^3.1.3: - version "3.2.0" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.2.0.tgz#cb4535162b5784aa623cee21a7252cf2c807ac93" - integrity sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA== - dependencies: - html-escaper "^2.0.0" - istanbul-lib-report "^3.0.0" - -jackspeak@^3.1.2: - version "3.4.3" - resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a" - integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw== - dependencies: - "@isaacs/cliui" "^8.0.2" - optionalDependencies: - "@pkgjs/parseargs" "^0.11.0" - -jest-changed-files@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-30.2.0.tgz#602266e478ed554e1e1469944faa7efd37cee61c" - integrity sha512-L8lR1ChrRnSdfeOvTrwZMlnWV8G/LLjQ0nG9MBclwWZidA2N5FviRki0Bvh20WRMOX31/JYvzdqTJrk5oBdydQ== - dependencies: - execa "^5.1.1" - jest-util "30.2.0" - p-limit "^3.1.0" - -jest-circus@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-30.2.0.tgz#98b8198b958748a2f322354311023d1d02e7603f" - integrity sha512-Fh0096NC3ZkFx05EP2OXCxJAREVxj1BcW/i6EWqqymcgYKWjyyDpral3fMxVcHXg6oZM7iULer9wGRFvfpl+Tg== - dependencies: - "@jest/environment" "30.2.0" - "@jest/expect" "30.2.0" - "@jest/test-result" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - chalk "^4.1.2" - co "^4.6.0" - dedent "^1.6.0" - is-generator-fn "^2.1.0" - jest-each "30.2.0" - jest-matcher-utils "30.2.0" - jest-message-util "30.2.0" - jest-runtime "30.2.0" - jest-snapshot "30.2.0" - jest-util "30.2.0" - p-limit "^3.1.0" - pretty-format "30.2.0" - pure-rand "^7.0.0" - slash "^3.0.0" - stack-utils "^2.0.6" - -jest-cli@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-30.2.0.tgz#1780f8e9d66bf84a10b369aea60aeda7697dcc67" - integrity sha512-Os9ukIvADX/A9sLt6Zse3+nmHtHaE6hqOsjQtNiugFTbKRHYIYtZXNGNK9NChseXy7djFPjndX1tL0sCTlfpAA== - dependencies: - "@jest/core" "30.2.0" - "@jest/test-result" "30.2.0" - "@jest/types" "30.2.0" - chalk "^4.1.2" - exit-x "^0.2.2" - import-local "^3.2.0" - jest-config "30.2.0" - jest-util "30.2.0" - jest-validate "30.2.0" - yargs "^17.7.2" - -jest-config@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-30.2.0.tgz#29df8c50e2ad801cc59c406b50176c18c362a90b" - integrity sha512-g4WkyzFQVWHtu6uqGmQR4CQxz/CH3yDSlhzXMWzNjDx843gYjReZnMRanjRCq5XZFuQrGDxgUaiYWE8BRfVckA== - dependencies: - "@babel/core" "^7.27.4" - "@jest/get-type" "30.1.0" - "@jest/pattern" "30.0.1" - "@jest/test-sequencer" "30.2.0" - "@jest/types" "30.2.0" - babel-jest "30.2.0" - chalk "^4.1.2" - ci-info "^4.2.0" - deepmerge "^4.3.1" - glob "^10.3.10" - graceful-fs "^4.2.11" - jest-circus "30.2.0" - jest-docblock "30.2.0" - jest-environment-node "30.2.0" - jest-regex-util "30.0.1" - jest-resolve "30.2.0" - jest-runner "30.2.0" - jest-util "30.2.0" - jest-validate "30.2.0" - micromatch "^4.0.8" - parse-json "^5.2.0" - pretty-format "30.2.0" - slash "^3.0.0" - strip-json-comments "^3.1.1" - -jest-diff@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-30.2.0.tgz#e3ec3a6ea5c5747f605c9e874f83d756cba36825" - integrity sha512-dQHFo3Pt4/NLlG5z4PxZ/3yZTZ1C7s9hveiOj+GCN+uT109NC2QgsoVZsVOAvbJ3RgKkvyLGXZV9+piDpWbm6A== - dependencies: - "@jest/diff-sequences" "30.0.1" - "@jest/get-type" "30.1.0" - chalk "^4.1.2" - pretty-format "30.2.0" - -jest-docblock@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-30.2.0.tgz#42cd98d69f887e531c7352309542b1ce4ee10256" - integrity sha512-tR/FFgZKS1CXluOQzZvNH3+0z9jXr3ldGSD8bhyuxvlVUwbeLOGynkunvlTMxchC5urrKndYiwCFC0DLVjpOCA== - dependencies: - detect-newline "^3.1.0" - -jest-each@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-30.2.0.tgz#39e623ae71641c2ac3ee69b3ba3d258fce8e768d" - integrity sha512-lpWlJlM7bCUf1mfmuqTA8+j2lNURW9eNafOy99knBM01i5CQeY5UH1vZjgT9071nDJac1M4XsbyI44oNOdhlDQ== - dependencies: - "@jest/get-type" "30.1.0" - "@jest/types" "30.2.0" - chalk "^4.1.2" - jest-util "30.2.0" - pretty-format "30.2.0" - -jest-environment-node@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-30.2.0.tgz#3def7980ebd2fd86e74efd4d2e681f55ab38da0f" - integrity sha512-ElU8v92QJ9UrYsKrxDIKCxu6PfNj4Hdcktcn0JX12zqNdqWHB0N+hwOnnBBXvjLd2vApZtuLUGs1QSY+MsXoNA== - dependencies: - "@jest/environment" "30.2.0" - "@jest/fake-timers" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - jest-mock "30.2.0" - jest-util "30.2.0" - jest-validate "30.2.0" - -jest-haste-map@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-30.2.0.tgz#808e3889f288603ac70ff0ac047598345a66022e" - integrity sha512-sQA/jCb9kNt+neM0anSj6eZhLZUIhQgwDt7cPGjumgLM4rXsfb9kpnlacmvZz3Q5tb80nS+oG/if+NBKrHC+Xw== - dependencies: - "@jest/types" "30.2.0" -======= istanbul-lib-report@^2.0.4: version "2.0.8" resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz#5a8113cd746d43c4889eba36ab10e7d50c9b4f33" @@ -4960,71 +3482,18 @@ jest-haste-map@30.4.1: integrity sha512-rFrcONd8jeFsyw+Z9CrScJgglRf2+NFmNam8dKu7n+SoHqNYT47mn0DdEcVUZJpvh7Iz6/si7f7yUH7GJHVgnw== dependencies: "@jest/types" "30.4.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/node" "*" anymatch "^3.1.3" fb-watchman "^2.0.2" graceful-fs "^4.2.11" -<<<<<<< HEAD - jest-regex-util "30.0.1" - jest-util "30.2.0" - jest-worker "30.2.0" - micromatch "^4.0.8" -======= jest-regex-util "30.4.0" jest-util "30.4.1" jest-worker "30.4.1" picomatch "^4.0.3" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) walker "^1.0.8" optionalDependencies: fsevents "^2.3.3" -<<<<<<< HEAD -jest-leak-detector@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-30.2.0.tgz#292fdca7b7c9cf594e1e570ace140b01d8beb736" - integrity sha512-M6jKAjyzjHG0SrQgwhgZGy9hFazcudwCNovY/9HPIicmNSBuockPSedAP9vlPK6ONFJ1zfyH/M2/YYJxOz5cdQ== - dependencies: - "@jest/get-type" "30.1.0" - pretty-format "30.2.0" - -jest-matcher-utils@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-30.2.0.tgz#69a0d4c271066559ec8b0d8174829adc3f23a783" - integrity sha512-dQ94Nq4dbzmUWkQ0ANAWS9tBRfqCrn0bV9AMYdOi/MHW726xn7eQmMeRTpX2ViC00bpNaWXq+7o4lIQ3AX13Hg== - dependencies: - "@jest/get-type" "30.1.0" - chalk "^4.1.2" - jest-diff "30.2.0" - pretty-format "30.2.0" - -jest-message-util@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-30.2.0.tgz#fc97bf90d11f118b31e6131e2b67fc4f39f92152" - integrity sha512-y4DKFLZ2y6DxTWD4cDe07RglV88ZiNEdlRfGtqahfbIjfsw1nMCPx49Uev4IA/hWn3sDKyAnSPwoYSsAEdcimw== - dependencies: - "@babel/code-frame" "^7.27.1" - "@jest/types" "30.2.0" - "@types/stack-utils" "^2.0.3" - chalk "^4.1.2" - graceful-fs "^4.2.11" - micromatch "^4.0.8" - pretty-format "30.2.0" - slash "^3.0.0" - stack-utils "^2.0.6" - -jest-mock@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-30.2.0.tgz#69f991614eeb4060189459d3584f710845bff45e" - integrity sha512-JNNNl2rj4b5ICpmAcq+WbLH83XswjPbjH4T7yvGzfAGCPh1rw+xVNbtk+FnRslvt9lkCcdn9i1oAoKUuFsOxRw== - dependencies: - "@jest/types" "30.2.0" - "@types/node" "*" - jest-util "30.2.0" - -jest-pnp-resolver@^1.2.3: -======= jest-haste-map@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-24.9.0.tgz#b38a5d64274934e21fa417ae9a9fbeb77ceaac7d" @@ -5106,129 +3575,10 @@ jest-mock@^24.9.0: "@jest/types" "^24.9.0" jest-pnp-resolver@^1.2.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.2.3" resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== -<<<<<<< HEAD -jest-regex-util@30.0.1: - version "30.0.1" - resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-30.0.1.tgz#f17c1de3958b67dfe485354f5a10093298f2a49b" - integrity sha512-jHEQgBXAgc+Gh4g0p3bCevgRCVRkB4VB70zhoAE48gxeSr1hfUOsM/C2WoJgVL7Eyg//hudYENbm3Ne+/dRVVA== - -jest-resolve-dependencies@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-30.2.0.tgz#3370e2c0b49cc560f6a7e8ec3a59dd99525e1a55" - integrity sha512-xTOIGug/0RmIe3mmCqCT95yO0vj6JURrn1TKWlNbhiAefJRWINNPgwVkrVgt/YaerPzY3iItufd80v3lOrFJ2w== - dependencies: - jest-regex-util "30.0.1" - jest-snapshot "30.2.0" - -jest-resolve@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-30.2.0.tgz#2e2009cbd61e8f1f003355d5ec87225412cebcd7" - integrity sha512-TCrHSxPlx3tBY3hWNtRQKbtgLhsXa1WmbJEqBlTBrGafd5fiQFByy2GNCEoGR+Tns8d15GaL9cxEzKOO3GEb2A== - dependencies: - chalk "^4.1.2" - graceful-fs "^4.2.11" - jest-haste-map "30.2.0" - jest-pnp-resolver "^1.2.3" - jest-util "30.2.0" - jest-validate "30.2.0" - slash "^3.0.0" - unrs-resolver "^1.7.11" - -jest-runner@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-30.2.0.tgz#c62b4c3130afa661789705e13a07bdbcec26a114" - integrity sha512-PqvZ2B2XEyPEbclp+gV6KO/F1FIFSbIwewRgmROCMBo/aZ6J1w8Qypoj2pEOcg3G2HzLlaP6VUtvwCI8dM3oqQ== - dependencies: - "@jest/console" "30.2.0" - "@jest/environment" "30.2.0" - "@jest/test-result" "30.2.0" - "@jest/transform" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - chalk "^4.1.2" - emittery "^0.13.1" - exit-x "^0.2.2" - graceful-fs "^4.2.11" - jest-docblock "30.2.0" - jest-environment-node "30.2.0" - jest-haste-map "30.2.0" - jest-leak-detector "30.2.0" - jest-message-util "30.2.0" - jest-resolve "30.2.0" - jest-runtime "30.2.0" - jest-util "30.2.0" - jest-watcher "30.2.0" - jest-worker "30.2.0" - p-limit "^3.1.0" - source-map-support "0.5.13" - -jest-runtime@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-30.2.0.tgz#395ea792cde048db1b0cd1a92dc9cb9f1921bf8a" - integrity sha512-p1+GVX/PJqTucvsmERPMgCPvQJpFt4hFbM+VN3n8TMo47decMUcJbt+rgzwrEme0MQUA/R+1de2axftTHkKckg== - dependencies: - "@jest/environment" "30.2.0" - "@jest/fake-timers" "30.2.0" - "@jest/globals" "30.2.0" - "@jest/source-map" "30.0.1" - "@jest/test-result" "30.2.0" - "@jest/transform" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - chalk "^4.1.2" - cjs-module-lexer "^2.1.0" - collect-v8-coverage "^1.0.2" - glob "^10.3.10" - graceful-fs "^4.2.11" - jest-haste-map "30.2.0" - jest-message-util "30.2.0" - jest-mock "30.2.0" - jest-regex-util "30.0.1" - jest-resolve "30.2.0" - jest-snapshot "30.2.0" - jest-util "30.2.0" - slash "^3.0.0" - strip-bom "^4.0.0" - -jest-snapshot@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-30.2.0.tgz#266fbbb4b95fc4665ce6f32f1f38eeb39f4e26d0" - integrity sha512-5WEtTy2jXPFypadKNpbNkZ72puZCa6UjSr/7djeecHWOu7iYhSXSnHScT8wBz3Rn8Ena5d5RYRcsyKIeqG1IyA== - dependencies: - "@babel/core" "^7.27.4" - "@babel/generator" "^7.27.5" - "@babel/plugin-syntax-jsx" "^7.27.1" - "@babel/plugin-syntax-typescript" "^7.27.1" - "@babel/types" "^7.27.3" - "@jest/expect-utils" "30.2.0" - "@jest/get-type" "30.1.0" - "@jest/snapshot-utils" "30.2.0" - "@jest/transform" "30.2.0" - "@jest/types" "30.2.0" - babel-preset-current-node-syntax "^1.2.0" - chalk "^4.1.2" - expect "30.2.0" - graceful-fs "^4.2.11" - jest-diff "30.2.0" - jest-matcher-utils "30.2.0" - jest-message-util "30.2.0" - jest-util "30.2.0" - pretty-format "30.2.0" - semver "^7.7.2" - synckit "^0.11.8" - -jest-util@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-30.2.0.tgz#5142adbcad6f4e53c2776c067a4db3c14f913705" - integrity sha512-QKNsM0o3Xe6ISQU869e+DhG+4CK/48aHYdJZGlFQVTjnbvgpcKyxpzk29fGiO7i/J8VENZ+d2iGnSsvmuHywlA== - dependencies: - "@jest/types" "30.2.0" -======= jest-regex-util@30.4.0: version "30.4.0" resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-30.4.0.tgz#f75ccc43857633df2563a03588b5cb45c7c2941b" @@ -5343,63 +3693,10 @@ jest-util@30.4.1: integrity sha512-vjQb1sACEiv13DKJMDToJpzVW0joCsIQrmbg0fi7CyOOt+g9jTuQl2A216pWRBYhOVt53XbL/2LbMKg1BECWOw== dependencies: "@jest/types" "30.4.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) "@types/node" "*" chalk "^4.1.2" ci-info "^4.2.0" graceful-fs "^4.2.11" -<<<<<<< HEAD - picomatch "^4.0.2" - -jest-validate@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-30.2.0.tgz#273eaaed4c0963b934b5b31e96289edda6e0a2ef" - integrity sha512-FBGWi7dP2hpdi8nBoWxSsLvBFewKAg0+uSQwBaof4Y4DPgBabXgpSYC5/lR7VmnIlSpASmCi/ntRWPbv7089Pw== - dependencies: - "@jest/get-type" "30.1.0" - "@jest/types" "30.2.0" - camelcase "^6.3.0" - chalk "^4.1.2" - leven "^3.1.0" - pretty-format "30.2.0" - -jest-watcher@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-30.2.0.tgz#f9c055de48e18c979e7756a3917e596e2d69b07b" - integrity sha512-PYxa28dxJ9g777pGm/7PrbnMeA0Jr7osHP9bS7eJy9DuAjMgdGtxgf0uKMyoIsTWAkIbUW5hSDdJ3urmgXBqxg== - dependencies: - "@jest/test-result" "30.2.0" - "@jest/types" "30.2.0" - "@types/node" "*" - ansi-escapes "^4.3.2" - chalk "^4.1.2" - emittery "^0.13.1" - jest-util "30.2.0" - string-length "^4.0.2" - -jest-worker@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-30.2.0.tgz#fd5c2a36ff6058ec8f74366ec89538cc99539d26" - integrity sha512-0Q4Uk8WF7BUwqXHuAjc23vmopWJw5WH7w2tqBoUOZpOjW/ZnR44GXXd1r82RvnmI2GZge3ivrYXk/BE2+VtW2g== - dependencies: - "@types/node" "*" - "@ungap/structured-clone" "^1.3.0" - jest-util "30.2.0" - merge-stream "^2.0.0" - supports-color "^8.1.1" - -jest@^30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/jest/-/jest-30.2.0.tgz#9f0a71e734af968f26952b5ae4b724af82681630" - integrity sha512-F26gjC0yWN8uAA5m5Ss8ZQf5nDHWGlN/xWZIh8S5SRbsEKBovwZhxGd6LJlbZYxBgCYOtreSUyb8hpXyGC5O4A== - dependencies: - "@jest/core" "30.2.0" - "@jest/types" "30.2.0" - import-local "^3.2.0" - jest-cli "30.2.0" - -js-tokens@^4.0.0: -======= picomatch "^4.0.3" jest-util@^24.9.0: @@ -5473,7 +3770,6 @@ jest@^24.5.0: jest-cli "^24.9.0" "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== @@ -5486,16 +3782,6 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -<<<<<<< HEAD -js-yaml@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b" - integrity sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA== - dependencies: - argparse "^2.0.1" - -jsesc@^3.0.2: -======= jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -5534,7 +3820,6 @@ jsdom@^11.5.1: xml-name-validator "^3.0.0" jsesc@^3.0.2, jsesc@~3.1.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.1.0.tgz#74d335a234f67ed19907fdadfac7ccf9d409825d" integrity sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA== @@ -5544,29 +3829,16 @@ json-buffer@3.0.1: resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== -<<<<<<< HEAD -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== -======= json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -<<<<<<< HEAD -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= -======= json-schema@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" @@ -5581,15 +3853,12 @@ json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) json5@^2.2.3: version "2.2.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== -<<<<<<< HEAD -======= jsprim@^1.2.2: version "1.4.2" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" @@ -5600,7 +3869,6 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) keyv@^4.5.4: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -5608,8 +3876,6 @@ keyv@^4.5.4: dependencies: json-buffer "3.0.1" -<<<<<<< HEAD -======= kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -5639,7 +3905,6 @@ left-pad@^1.3.0: resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e" integrity sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -5653,12 +3918,6 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -<<<<<<< HEAD -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -======= levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" @@ -5684,7 +3943,6 @@ locate-path@^3.0.0: dependencies: p-locate "^3.0.0" path-exists "^3.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) locate-path@^5.0.0: version "5.0.0" @@ -5700,22 +3958,6 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" -<<<<<<< HEAD -lodash.merge@^4.6.2: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" - integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== - -lodash@^4.17.11: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== - -lru-cache@^10.2.0: - version "10.4.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" - integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== -======= lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -5737,7 +3979,6 @@ loose-envify@^1.0.0: integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== dependencies: js-tokens "^3.0.0 || ^4.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) lru-cache@^5.1.1: version "5.1.1" @@ -5746,14 +3987,6 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" -<<<<<<< HEAD -make-dir@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" - integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== - dependencies: - semver "^7.5.3" -======= make-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" @@ -5761,7 +3994,6 @@ make-dir@^2.1.0: dependencies: pify "^4.0.1" semver "^5.6.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) makeerror@1.0.12: version "1.0.12" @@ -5770,8 +4002,6 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" -<<<<<<< HEAD -======= map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -5789,57 +4019,11 @@ math-intrinsics@^1.1.0: resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -<<<<<<< HEAD -micromatch@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" - integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== - dependencies: - braces "^3.0.3" - picomatch "^2.3.1" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^3.1.1, minimatch@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^9.0.4: - version "9.0.5" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5" - integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== - dependencies: - brace-expansion "^2.0.1" - -"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707" - integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw== - -ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -======= micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -5909,19 +4093,12 @@ ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -<<<<<<< HEAD -napi-postinstall@^0.3.0: - version "0.3.4" - resolved "https://registry.yarnpkg.com/napi-postinstall/-/napi-postinstall-0.3.4.tgz#7af256d6588b5f8e952b9190965d6b019653bbb9" - integrity sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ== -======= nan@^2.12.1: version "2.27.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.27.0.tgz#804e389f4c0e39b729a17eca85c80ebc4355c4c4" @@ -5943,33 +4120,20 @@ nanomatch@^1.2.9: regex-not "^1.0.0" snapdragon "^0.8.1" to-regex "^3.0.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" -<<<<<<< HEAD - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -======= integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" -<<<<<<< HEAD - integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs= - -node-releases@^2.0.27: - version "2.0.27" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.27.tgz#eedca519205cf20f650f61d56b070db111231e4e" - integrity sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA== -======= integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== node-notifier@^5.4.2: @@ -6004,35 +4168,12 @@ normalize-path@^2.1.1: integrity sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w== dependencies: remove-trailing-separator "^1.0.1" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) normalize-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -<<<<<<< HEAD -npm-run-path@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" -======= npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -6126,7 +4267,6 @@ optionator@^0.8.1: prelude-ls "~1.1.2" type-check "~0.3.2" word-wrap "~1.2.3" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) optionator@^0.9.3: version "0.9.4" @@ -6140,9 +4280,6 @@ optionator@^0.9.3: type-check "^0.4.0" word-wrap "^1.2.5" -<<<<<<< HEAD -p-limit@^2.2.0: -======= os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -6170,26 +4307,19 @@ p-finally@^1.0.0: integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow== p-limit@^2.0.0, p-limit@^2.2.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== dependencies: p-try "^2.0.0" -<<<<<<< HEAD -p-limit@^3.0.2, p-limit@^3.1.0: -======= p-limit@^3.0.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== dependencies: yocto-queue "^0.1.0" -<<<<<<< HEAD -======= p-locate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" @@ -6197,7 +4327,6 @@ p-locate@^3.0.0: dependencies: p-limit "^2.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -6212,34 +4341,6 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" -<<<<<<< HEAD -p-try@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" - integrity sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ== - -package-json-from-dist@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz#4f1471a010827a86f94cfd9b0727e36d267de505" - integrity sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw== - -parent-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.0.tgz#df250bdc5391f4a085fb589dad761f5ad6b865b5" - integrity sha512-8Mf5juOMmiE4FcmzYc4IaiS9L3+9paz2KOiXzkRviCP6aDmN49Hz6EMWz0lGNp9pX80GvvAuLADtyGfW/Em3TA== - dependencies: - callsites "^3.0.0" - -parse-json@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" -======= p-reduce@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" @@ -6272,7 +4373,6 @@ path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) path-exists@^4.0.0: version "4.0.0" @@ -6282,11 +4382,6 @@ path-exists@^4.0.0: path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -<<<<<<< HEAD - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.0.0, path-key@^3.1.0: -======= integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-key@^2.0.0, path-key@^2.0.1: @@ -6295,20 +4390,10 @@ path-key@^2.0.0, path-key@^2.0.1: integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== path-key@^3.1.0: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -<<<<<<< HEAD -path-scurry@^1.11.1: - version "1.11.1" - resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" - integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== - dependencies: - lru-cache "^10.2.0" - minipass "^5.0.0 || ^6.0.2 || ^7.0.0" -======= path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" @@ -6325,26 +4410,12 @@ performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) picocolors@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== -<<<<<<< HEAD -picomatch@^2.0.4, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -picomatch@^4.0.2: - version "4.0.3" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.3.tgz#796c76136d1eead715db1e7bad785dedd695a042" - integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q== - -pirates@^4.0.7: -======= picomatch@^2.0.4: version "2.3.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.2.tgz#5a942915e26b372dc0f0e6753149a16e6b1c5601" @@ -6366,19 +4437,10 @@ pify@^4.0.1: integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== pirates@^4.0.1, pirates@^4.0.7: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "4.0.7" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.7.tgz#643b4a18c4257c8a65104b73f3049ce9a0a15e22" integrity sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA== -<<<<<<< HEAD -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" -======= pkg-dir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" @@ -6400,40 +4462,12 @@ possible-typed-array-names@^1.0.0, possible-typed-array-names@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz#93e3582bc0e5426586d9d07b79ee40fc841de4ae" integrity sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -<<<<<<< HEAD -pretty-format@30.2.0: - version "30.2.0" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-30.2.0.tgz#2d44fe6134529aed18506f6d11509d8a62775ebe" - integrity sha512-9uBdv/B4EefsuAL+pWqueZyZS2Ba+LxfFeQ9DN14HU4bN8bhaxKdkpjpB6fs9+pSjIBu+FXQHImEg8j/Lw0+vA== - dependencies: - "@jest/schemas" "30.0.5" - ansi-styles "^5.2.0" - react-is "^18.3.1" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -pure-rand@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-7.0.1.tgz#6f53a5a9e3e4a47445822af96821ca509ed37566" - integrity sha512-oTUZM/NAZS8p7ANR3SHh30kXB+zK2r2BPcEn/awJIbOvq82WoMN4p62AWWp3Hhw50G0xMsw1mhIBLqHw64EcNQ== - -react-is@^18.3.1: - version "18.3.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" - integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== - -readline-sync@^1.4.10: -======= prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -6505,29 +4539,10 @@ read-pkg@^3.0.0: path-type "^3.0.0" readline-sync@^1.4.9: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.4.10" resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.10.tgz#41df7fbb4b6312d673011594145705bf56d8873b" integrity sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw== -<<<<<<< HEAD -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -======= realpath-native@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.1.0.tgz#2003294fea23fb0672f2476ebe22fcf498a2d65c" @@ -6683,16 +4698,12 @@ resolve-from@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" integrity sha512-GnlH6vxLymXJNMBo7XP1fJIzBFbdYt49CuTwmB/6N53t+kMPRMFKz783LlQ4tv28XoQfMWinAJX6WCGf2IlaIw== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) resolve-from@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== -<<<<<<< HEAD -semver@^6.3.1: -======= resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -6801,17 +4812,10 @@ sax@^1.2.4: integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@^6.0.0, semver@^6.2.0, semver@^6.3.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -<<<<<<< HEAD -semver@^7.5.3, semver@^7.5.4, semver@^7.7.2: - version "7.7.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946" - integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q== -======= semver@^7.5.4: version "7.8.1" resolved "https://registry.yarnpkg.com/semver/-/semver-7.8.1.tgz#bf4970b5e70fda0686363cc18bfe8805d5ed957e" @@ -6869,7 +4873,6 @@ shebang-command@^1.2.0: integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== dependencies: shebang-regex "^1.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) shebang-command@^2.0.0: version "2.0.0" @@ -6878,22 +4881,16 @@ shebang-command@^2.0.0: dependencies: shebang-regex "^3.0.0" -<<<<<<< HEAD -======= shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) shebang-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -<<<<<<< HEAD -signal-exit@^3.0.3: -======= shellwords@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" @@ -6940,7 +4937,6 @@ side-channel@^1.1.0: side-channel-weakmap "^1.0.2" signal-exit@^3.0.0, signal-exit@^3.0.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== @@ -6950,8 +4946,6 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== -<<<<<<< HEAD -======= sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -6962,18 +4956,11 @@ slash@^2.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -<<<<<<< HEAD -source-map-support@0.5.13: - version "0.5.13" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" - integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== -======= snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -7019,14 +5006,10 @@ source-map-support@^0.5.6: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: buffer-from "^1.0.0" source-map "^0.6.0" -<<<<<<< HEAD -source-map@^0.6.0: -======= source-map-url@^0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" @@ -7038,14 +5021,10 @@ source-map@^0.5.6: integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ== source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -<<<<<<< HEAD -sprintf-js@^1.1.3: -======= spdx-correct@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.2.0.tgz#4f5ab0668f0059e34f9c00dce331784a12de4e9c" @@ -7080,7 +5059,6 @@ split-string@^3.0.1, split-string@^3.0.2: extend-shallow "^3.0.0" sprintf-js@^1.1.2: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.1.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== @@ -7088,87 +5066,6 @@ sprintf-js@^1.1.2: sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" -<<<<<<< HEAD - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -stack-utils@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" - integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== - dependencies: - escape-string-regexp "^2.0.0" - -string-length@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" - integrity sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ== - dependencies: - char-regex "^1.0.2" - strip-ansi "^6.0.0" - -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^5.0.1, string-width@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" - integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== - dependencies: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" - -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@^7.0.1: - version "7.1.2" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.2.tgz#132875abde678c7ea8d691533f2e7e22bb744dba" - integrity sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA== - dependencies: - ansi-regex "^6.0.1" - -strip-bom@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" - integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -strip-json-comments@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -======= integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== sshpk@^1.7.0: @@ -7286,7 +5183,6 @@ strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" integrity sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) supports-color@^5.3.0: version "5.5.0" @@ -7295,8 +5191,6 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -<<<<<<< HEAD -======= supports-color@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" @@ -7304,7 +5198,6 @@ supports-color@^6.1.0: dependencies: has-flag "^3.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -7319,14 +5212,6 @@ supports-color@^8.1.1: dependencies: has-flag "^4.0.0" -<<<<<<< HEAD -synckit@^0.11.8: - version "0.11.11" - resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.11.tgz#c0b619cf258a97faa209155d9cd1699b5c998cb0" - integrity sha512-MeQTA1r0litLUf0Rp/iisCaL8761lKAZHaimlbGK4j0HysC4PLfqygQj9srcs0m2RdtDYnF8UuYyKpbjHYp7Jw== - dependencies: - "@pkgr/core" "^0.2.9" -======= supports-preserve-symlinks-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" @@ -7346,7 +5231,6 @@ test-exclude@^5.2.3: minimatch "^3.0.4" read-pkg-up "^4.0.0" require-main-filename "^2.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) test-exclude@^6.0.0: version "6.0.0" @@ -7357,12 +5241,6 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -<<<<<<< HEAD -tmp@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8" - integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow== -======= throat@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" @@ -7374,31 +5252,12 @@ tmp@^0.0.33: integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== dependencies: os-tmpdir "~1.0.2" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== -<<<<<<< HEAD -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -tslib@^2.4.0: - version "2.8.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" - integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== -======= to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -7450,7 +5309,6 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" integrity sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" @@ -7459,54 +5317,6 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -<<<<<<< HEAD -type-detect@4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" - integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== - -type-fest@^0.21.3: - version "0.21.3" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" - integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== - -undici-types@~7.16.0: - version "7.16.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" - integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== - -unrs-resolver@^1.7.11: - version "1.11.1" - resolved "https://registry.yarnpkg.com/unrs-resolver/-/unrs-resolver-1.11.1.tgz#be9cd8686c99ef53ecb96df2a473c64d304048a9" - integrity sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg== - dependencies: - napi-postinstall "^0.3.0" - optionalDependencies: - "@unrs/resolver-binding-android-arm-eabi" "1.11.1" - "@unrs/resolver-binding-android-arm64" "1.11.1" - "@unrs/resolver-binding-darwin-arm64" "1.11.1" - "@unrs/resolver-binding-darwin-x64" "1.11.1" - "@unrs/resolver-binding-freebsd-x64" "1.11.1" - "@unrs/resolver-binding-linux-arm-gnueabihf" "1.11.1" - "@unrs/resolver-binding-linux-arm-musleabihf" "1.11.1" - "@unrs/resolver-binding-linux-arm64-gnu" "1.11.1" - "@unrs/resolver-binding-linux-arm64-musl" "1.11.1" - "@unrs/resolver-binding-linux-ppc64-gnu" "1.11.1" - "@unrs/resolver-binding-linux-riscv64-gnu" "1.11.1" - "@unrs/resolver-binding-linux-riscv64-musl" "1.11.1" - "@unrs/resolver-binding-linux-s390x-gnu" "1.11.1" - "@unrs/resolver-binding-linux-x64-gnu" "1.11.1" - "@unrs/resolver-binding-linux-x64-musl" "1.11.1" - "@unrs/resolver-binding-wasm32-wasi" "1.11.1" - "@unrs/resolver-binding-win32-arm64-msvc" "1.11.1" - "@unrs/resolver-binding-win32-ia32-msvc" "1.11.1" - "@unrs/resolver-binding-win32-x64-msvc" "1.11.1" - -update-browserslist-db@^1.2.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.2.2.tgz#cfb4358afa08b3d5731a2ecd95eebf4ddef8033e" - integrity sha512-E85pfNzMQ9jpKkA7+TJAi4TJN+tBCuWh5rUcS/sv6cFi+1q9LYDwDI5dpUL0u/73EElyQ8d3TEaeW4sPedBqYA== -======= type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -7619,30 +5429,11 @@ update-browserslist-db@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz#64d76db58713136acbeb4c49114366cc6cc2e80d" integrity sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) dependencies: escalade "^3.2.0" picocolors "^1.1.1" uri-js@^4.2.2: -<<<<<<< HEAD - version "4.2.2" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" - integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== - dependencies: - punycode "^2.1.0" - -v8-to-istanbul@^9.0.1: - version "9.3.0" - resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz#b9572abfa62bd556c16d75fdebc1a411d5ff3175" - integrity sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA== - dependencies: - "@jridgewell/trace-mapping" "^0.3.12" - "@types/istanbul-lib-coverage" "^2.0.1" - convert-source-map "^2.0.0" - -walker@^1.0.8: -======= version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== @@ -7707,15 +5498,12 @@ w3c-hr-time@^1.0.1: browser-process-hrtime "^1.0.0" walker@^1.0.7, walker@^1.0.8, walker@~1.0.5: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.0.8" resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f" integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ== dependencies: makeerror "1.0.12" -<<<<<<< HEAD -======= webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" @@ -7816,7 +5604,6 @@ which@^1.2.9, which@^1.3.0: dependencies: isexe "^2.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -7824,43 +5611,11 @@ which@^2.0.1: dependencies: isexe "^2.0.0" -<<<<<<< HEAD -word-wrap@^1.2.5: -======= word-wrap@^1.2.5, word-wrap@~1.2.3: ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) version "1.2.5" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -<<<<<<< HEAD -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" - integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== - dependencies: - ansi-styles "^6.1.0" - string-width "^5.0.1" - strip-ansi "^7.0.1" -======= wrap-ansi@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" @@ -7869,14 +5624,10 @@ wrap-ansi@^5.1.0: ansi-styles "^3.2.0" string-width "^3.0.0" strip-ansi "^5.0.0" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" -<<<<<<< HEAD - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -======= integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== write-file-atomic@2.4.1: @@ -7887,7 +5638,6 @@ write-file-atomic@2.4.1: graceful-fs "^4.1.11" imurmurhash "^0.1.4" signal-exit "^3.0.2" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) write-file-atomic@^5.0.1: version "5.0.1" @@ -7897,12 +5647,6 @@ write-file-atomic@^5.0.1: imurmurhash "^0.1.4" signal-exit "^4.0.1" -<<<<<<< HEAD -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -======= ws@^5.2.0: version "5.2.5" resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.5.tgz#41d693f6502b7a020349cfa220a6799a7f13335c" @@ -7919,32 +5663,12 @@ y18n@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== -<<<<<<< HEAD -yargs-parser@^21.1.1: - version "21.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" - integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== - -yargs@^17.7.2: - version "17.7.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" - integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== - dependencies: - cliui "^8.0.1" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.1.1" -======= yargs-parser@^13.1.2: version "13.1.2" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" @@ -7968,7 +5692,6 @@ yargs@^13.3.0: which-module "^2.0.0" y18n "^4.0.0" yargs-parser "^13.1.2" ->>>>>>> e396c16 (Update files, eslint run, and iteration complete) yocto-queue@^0.1.0: version "0.1.0" From d7af2e652e26d86ba9736f898458afbb5d1c5b98 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Fri, 5 Jun 2026 15:52:53 +0100 Subject: [PATCH 11/11] Cleanup --- eslint.config.js | 2 +- eslint.config.mjs | 40 ------- src/defs.js | 2 +- src/fengaricore.js | 2 +- src/lapi.js | 6 +- src/lauxlib.js | 8 +- src/ldblib.js | 4 +- src/ldo.js | 6 +- src/loadlib.js | 10 +- src/lobject.js | 9 +- src/loslib.js | 5 +- src/lparser.js | 3 +- src/lstring.js | 2 +- src/lstrlib.js | 8 +- src/ltablib.js | 6 +- src/lua.js | 2 +- src/luaconf.js | 14 +-- src/lualib.js | 5 +- src/lundump.js | 2 +- src/lvm.js | 11 +- src/lzio.js | 2 +- test/defs.test.js | 2 +- test/lapi.test.js | 43 +++++++- test/lauxlib.test.js | 6 +- test/lbaselib.test.js | 19 +++- test/lcorolib.test.js | 10 +- test/ldebug.test.js | 8 +- test/lexparse.test.js | 20 +++- test/lmathlib.test.js | 10 +- test/load.test.js | 10 +- test/loadlib.test.js | 8 +- test/loslib.test.js | 16 ++- test/lstrlib.test.js | 17 ++- test/ltablib.test.js | 8 +- test/ltm.test.js | 8 +- test/lua.test.js | 8 +- test/lutf8lib.test.js | 8 +- test/lvm.test.js | 17 ++- test/manual-tests/debug-cli.js | 8 +- test/test-suite/api.test.js | 10 +- test/test-suite/attrib.test.js | 8 +- test/test-suite/bitwise.test.js | 8 +- test/test-suite/calls.test.js | 8 +- test/test-suite/closure.test.js | 8 +- test/test-suite/code.test.js | 10 +- test/test-suite/constructs.test.js | 8 +- test/test-suite/coroutine.test.js | 10 +- test/test-suite/db.test.js | 8 +- test/test-suite/errors.test.js | 8 +- test/test-suite/events.test.js | 10 +- test/test-suite/goto.test.js | 8 +- test/test-suite/literals.test.js | 8 +- test/test-suite/locals.test.js | 8 +- test/test-suite/ltests.js | 165 ++++++++++++++++++++++++++--- test/test-suite/math.test.js | 8 +- test/test-suite/nextvar.test.js | 8 +- test/test-suite/pm.test.js | 8 +- test/test-suite/sort.test.js | 8 +- test/test-suite/strings.test.js | 8 +- test/test-suite/tpack.test.js | 8 +- test/test-suite/utf8.test.js | 8 +- test/test-suite/vararg.test.js | 8 +- test/tests.js | 6 +- 63 files changed, 447 insertions(+), 283 deletions(-) delete mode 100644 eslint.config.mjs diff --git a/eslint.config.js b/eslint.config.js index fb227fe8..9db4af4d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,6 @@ import js from "@eslint/js"; import globals from "globals"; -import { defineConfig } from "eslint/config"; +import {defineConfig} from "eslint/config"; import stylistic from "@stylistic/eslint-plugin"; export default defineConfig([ diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 667ad4b4..00000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,40 +0,0 @@ -import globals from "globals"; -import { defineConfig } from "eslint/config"; - -export default defineConfig([ - { files: ["**/*.{js,mjs,cjs}"], languageOptions: { globals: { ...globals.browser, ...globals.node, ...globals.worker } } }, - { files: ["test/**/*.{js,mjs,cjs}"], languageOptions: { globals: globals.jest } }, - { - "rules": { - "indent": [ - "error", - 4, - { - "SwitchCase": 1 - } - ], - "linebreak-style": [ - "error", - "unix" - ], - "no-console": 0, - "no-empty": [ - 2, - { - "allowEmptyCatch": true - } - ], - "no-unused-vars": [ - 2, - { - "args": "none", - "caughtErrors": "none" - } - ], - "semi": [ - "error", - "always" - ] - } - } -]); diff --git a/src/defs.js b/src/defs.js index c700e401..2368445e 100644 --- a/src/defs.js +++ b/src/defs.js @@ -2,7 +2,7 @@ * Fengari specific string conversion functions */ -import { LUAI_MAXSTACK } from './common.js'; +import {LUAI_MAXSTACK} from './common.js'; export { LUAI_MAXSTACK }; diff --git a/src/fengaricore.js b/src/fengaricore.js index 5f2d70e3..7c77c00a 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,7 +6,7 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ -import { LUA_COPYRIGHT } from './defs.js'; +import {LUA_COPYRIGHT} from './defs.js'; export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from './defs.js'; diff --git a/src/lapi.js b/src/lapi.js index 2f4e8a4f..e74fe589 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -498,8 +498,7 @@ export const lua_rawget = function (L, idx) { // narray and nrec are mostly useless for this implementation export const lua_createtable = function (L, _narray, _nrec) { - let t = new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L)); - L.stack[L.top] = t; + L.stack[L.top] = new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L)); api_incr_top(L); }; @@ -1079,8 +1078,7 @@ export const lua_upvalueid = function (L, fidx, n) { export const lua_upvaluejoin = function (L, fidx1, n1, fidx2, n2) { let ref1 = getupvalref(L, fidx1, n1); let ref2 = getupvalref(L, fidx2, n2); - let up2 = ref2.f.upvals[ref2.i]; - ref1.f.upvals[ref1.i] = up2; + ref1.f.upvals[ref1.i] = ref2.f.upvals[ref2.i]; }; // This functions are only there for compatibility purposes diff --git a/src/lauxlib.js b/src/lauxlib.js index 8aa7b9a0..ef5dadde 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -565,8 +565,8 @@ export const luaL_requiref = function (L, modname, openf, glb) { }; export const find_subarray = function (arr, subarr, from_index) { - var i = from_index >>> 0, - sl = subarr.length, + let i = from_index >>> 0; + const sl = subarr.length, l = arr.length + 1 - sl; loop: for (; i < l; i++) { @@ -923,9 +923,9 @@ export const lua_writestringerror = function () { export const luaL_checkversion_ = function (L, ver, sz) { let v = lua.lua_version(L); - if (sz != LUAL_NUMSIZES) /* check numeric types */ + if (sz !== LUAL_NUMSIZES) /* check numeric types */ luaL_error(L, fengaricore.to_luastring('core and library have incompatible numeric types')); - if (v != lua.lua_version(null)) + if (v !== lua.lua_version(null)) luaL_error(L, fengaricore.to_luastring('multiple Lua VMs detected')); else if (v !== ver) luaL_error(L, fengaricore.to_luastring('version mismatch: app. needs %f, Lua core provides %f'), ver, v); diff --git a/src/ldblib.js b/src/ldblib.js index 5c1dbbc8..f594e3ca 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -34,7 +34,7 @@ const db_getmetatable = function(L) { const db_setmetatable = function(L) { const t = lua.lua_type(L, 2); - lauxlib.luaL_argcheck(L, t == lua.LUA_TNIL || t == lua.LUA_TTABLE, 2, 'nil or table expected'); + lauxlib.luaL_argcheck(L, t === lua.LUA_TNIL || t === lua.LUA_TTABLE, 2, 'nil or table expected'); lua.lua_settop(L, 2); lua.lua_setmetatable(L, 1); return 1; /* return 1st argument */ @@ -106,7 +106,7 @@ const settabsb = function(L, k, v) { ** 'lua_setfield'. */ const treatstackoption = function(L, L1, fname) { - if (L == L1) + if (L === L1) lua.lua_rotate(L, -2, 1); /* exchange object and table */ else lua.lua_xmove(L1, L, 1); /* move object to the "main" stack */ diff --git a/src/ldo.js b/src/ldo.js index 95956c3c..26fae159 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -68,8 +68,8 @@ export const seterrorobj = function (L, errcode, oldtop) { export const ERRORSTACKSIZE = common.LUAI_MAXSTACK + 200; export const luaD_reallocstack = function (L, newsize) { - llimits.lua_assert(newsize <= common.LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); - llimits.lua_assert(L.stack_last == L.stack.length - lstate.EXTRA_STACK); + llimits.lua_assert(newsize <= common.LUAI_MAXSTACK || newsize === ERRORSTACKSIZE); + llimits.lua_assert(L.stack_last === L.stack.length - lstate.EXTRA_STACK); L.stack.length = newsize; L.stack_last = newsize - lstate.EXTRA_STACK; }; @@ -286,7 +286,7 @@ export const callhook = function (L, ci) { let hook = defs.LUA_HOOKCALL; ci.l_savedpc++; /* hooks assume 'pc' is already incremented */ if ((ci.previous.callstatus & lstate.CIST_LUA) && - ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == lopcodes.OpCodesI.OP_TAILCALL) { + ci.previous.l_code[ci.previous.l_savedpc - 1].opcode === lopcodes.OpCodesI.OP_TAILCALL) { ci.callstatus |= lstate.CIST_TAIL; hook = defs.LUA_HOOKTAILCALL; } diff --git a/src/loadlib.js b/src/loadlib.js index ad7c92da..201095ee 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -373,7 +373,7 @@ const searcher_Croot = function (L) { let filename = findfile(L, lua.lua_tostring(L, -1), fengaricore.to_luastring('jspath', true), fengaricore.to_luastring(LUA_CSUBSEP, true)); if (filename === null) return 1; /* root not found */ if ((stat = loadfunc(L, filename, name)) !== 0) { - if (stat != ERRFUNC) + if (stat !== ERRFUNC) return checkload(L, 0, filename); /* real error */ else { /* open function not found */ lua.lua_pushfstring(L, fengaricore.to_luastring('\n\tno module \'%s\' in file \'%s\''), name, filename); @@ -437,13 +437,11 @@ const ll_require = function (L) { return 1; /* package is already loaded */ /* else must load package */ lua.lua_pop(L, 1); /* remove 'getfield' result */ - let ctx = name; - return findloader(L, name, ctx, ll_require_cont); + return findloader(L, name, name, ll_require_cont); }; const ll_require_cont = function (L, status, ctx) { - let name = ctx; - lua.lua_pushstring(L, name); /* pass name as argument to module loader */ + lua.lua_pushstring(L, ctx); /* pass name as argument to module loader */ lua.lua_insert(L, -2); /* name is 1st argument (before search data) */ lua.lua_callk(L, 2, 1, ctx, ll_require_cont2); return ll_require_cont2(L, lua.LUA_OK, ctx); /* run loader to load module */ @@ -453,7 +451,7 @@ const ll_require_cont2 = function (L, status, ctx) { let name = ctx; if (!lua.lua_isnil(L, -1)) /* non-nil return? */ lua.lua_setfield(L, 2, name); /* LOADED[name] = returned value */ - if (lua.lua_getfield(L, 2, name) == lua.LUA_TNIL) { /* module set no value? */ + if (lua.lua_getfield(L, 2, name) === lua.LUA_TNIL) { /* module set no value? */ lua.lua_pushboolean(L, 1); /* use true as result */ lua.lua_pushvalue(L, -1); /* extra copy to be returned */ lua.lua_setfield(L, 2, name); /* LOADED[name] = true */ diff --git a/src/lobject.js b/src/lobject.js index 933daa33..0b110ba2 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -140,7 +140,7 @@ export class TValue { } chgfltvalue(x) { - llimits.lua_assert(this.type == LUA_TNUMFLT); + llimits.lua_assert(this.type === LUA_TNUMFLT); this.value = x; } @@ -150,7 +150,7 @@ export class TValue { } chgivalue(x) { - llimits.lua_assert(this.type == LUA_TNUMINT); + llimits.lua_assert(this.type === LUA_TNUMINT); this.value = x; } @@ -487,11 +487,10 @@ export const l_str2d = function (s) { let mode = modes[pmode]; if (mode === 'n') /* reject 'inf' and 'nan' */ return null; - let end = l_str2dloc(s, mode); /* try to convert */ // if (end === null) { /* failed? may be a different locale */ // throw new Error("Locale not available to handle number"); // TODO // } - return end; + return l_str2dloc(s, mode); }; export const MAXBY10 = Math.floor(llimits.MAX_INT / 10); @@ -572,7 +571,7 @@ export const luaO_pushvfstring = function (L, fmt, argp) { let e; for (; ;) { e = defs.luastring_indexOf(fmt, 37 /* ('%').charCodeAt(0) */, i); - if (e == -1) break; + if (e === -1) break; pushstr(L, fmt.subarray(i, e)); switch (fmt[e + 1]) { case 115 /* ('s').charCodeAt(0) */: { diff --git a/src/loslib.js b/src/loslib.js index a2e59d34..73d8ec38 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -406,9 +406,8 @@ const os_time = function(L) { }; const l_checktime = function(L, arg) { - let t = lauxlib.luaL_checkinteger(L, arg); // luaL_argcheck(L, t, arg, "time out-of-bounds"); - return t; + return lauxlib.luaL_checkinteger(L, arg); }; const os_difftime = function(L) { @@ -429,7 +428,7 @@ const os_setlocale = function(L) { IEEE Std 1003.1-2017 Section 7.2 as equivalent to "C" */ lua.lua_pushstring(L, ( l === null /* passing nil returns the current locale; which is "C" */ - || l.length == 0 /* empty string resets to the default locale; which is "C" */ + || l.length === 0 /* empty string resets to the default locale; which is "C" */ || fengaricore.luastring_eq(l, C) /* user passed "C" */ || fengaricore.luastring_eq(l, POSIX) /* user passed "POSIX", equivalent to "C" */ ) ? C : null); diff --git a/src/lparser.js b/src/lparser.js index 748b04e5..60e761c6 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1275,8 +1275,7 @@ const exp1 = function (ls) { expr(ls, e); lcode.luaK_exp2nextreg(ls.fs, e); llimits.lua_assert(e.k === expkind.VNONRELOC); - let reg = e.u.info; - return reg; + return e.u.info; }; const forbody = function (ls, base, line, nvars, isnum) { diff --git a/src/lstring.js b/src/lstring.js index f2215357..55c1d275 100644 --- a/src/lstring.js +++ b/src/lstring.js @@ -21,7 +21,7 @@ export class TString { export const luaS_eqlngstr = function (a, b) { llimits.lua_assert(a instanceof TString); llimits.lua_assert(b instanceof TString); - return a == b || defs.luastring_eq(a.realstring, b.realstring); + return a === b || defs.luastring_eq(a.realstring, b.realstring); }; /* converts strings (arrays) to a consistent map key diff --git a/src/lstrlib.js b/src/lstrlib.js index 369834be..aceb1ad9 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -1,4 +1,4 @@ -import { sprintf } from 'sprintf-js'; +import {sprintf} from 'sprintf-js'; import * as luaconf from './luaconf.js'; import * as lua from './lua.js'; @@ -736,7 +736,7 @@ const unpacknum = function (L, b, islittle, size) { for (let i = 0; i < size; i++) dv.setUint8(i, b[i]); - if (size == 4) return dv.getFloat32(0, islittle); + if (size === 4) return dv.getFloat32(0, islittle); else return dv.getFloat64(0, islittle); }; @@ -1155,8 +1155,8 @@ const reprepstate = function (ms) { }; const find_subarray = function (arr, subarr, from_index) { - var i = from_index >>> 0, - sl = subarr.length; + let i = from_index >>> 0; + const sl = subarr.length; if (sl === 0) return i; diff --git a/src/ltablib.js b/src/ltablib.js index 6e3b7d81..27fa1812 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -204,7 +204,7 @@ const partition = function(L, lo, up) { for (;;) { /* next loop: repeat ++i while a[i] < P */ while (lua.lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ + if (i === up - 1) /* a[i] < P but a[up - 1] == P ?? */ lauxlib.luaL_error(L, fengaricore.to_luastring('invalid order function for sorting')); lua.lua_pop(L, 1); /* remove a[i] */ } @@ -244,7 +244,7 @@ const auxsort = function(L, lo, up, rnd) { set2(L, lo, up); /* swap a[lo] - a[up] */ else lua.lua_pop(L, 2); /* remove both values */ - if (up - lo == 1) /* only 2 elements? */ + if (up - lo === 1) /* only 2 elements? */ return; /* already sorted */ let p; /* Pivot index */ if (up - lo < RANLIMIT || rnd === 0) /* small interval or no randomize? */ @@ -263,7 +263,7 @@ const auxsort = function(L, lo, up, rnd) { else lua.lua_pop(L, 2); } - if (up - lo == 2) /* only 3 elements? */ + if (up - lo === 2) /* only 3 elements? */ return; /* already sorted */ lua.lua_geti(L, 1, p); /* get middle element (Pivot) */ lua.lua_pushvalue(L, -1); /* push Pivot */ diff --git a/src/lua.js b/src/lua.js index ceb11884..b1a8dbaa 100644 --- a/src/lua.js +++ b/src/lua.js @@ -1,4 +1,4 @@ -import { thread_status, constant_types } from './defs.js'; +import {constant_types, thread_status} from './defs.js'; export { LUA_AUTHORS, LUA_COPYRIGHT, thread_status, LUA_HOOKCALL, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, LUA_MINSTACK, LUA_MULTRET, constant_types, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, LUA_REGISTRYINDEX, LUA_RELEASE, LUA_RIDX_GLOBALS, LUA_RIDX_LAST, LUA_RIDX_MAINTHREAD, LUA_SIGNATURE, LUA_VERSION, LUA_VERSION_MAJOR, LUA_VERSION_MINOR, LUA_VERSION_NUM, LUA_VERSION_RELEASE, lua_Debug, lua_upvalueindex } from './defs.js'; export { lua_absindex, lua_arith, lua_atpanic, lua_atnativeerror, lua_call, lua_callk, lua_checkstack, lua_compare, lua_concat, lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, lua_getextraspace, lua_getfield, lua_getglobal, lua_geti, lua_getmetatable, lua_gettable, lua_gettop, lua_getupvalue, lua_getuservalue, lua_insert, lua_isboolean, lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isproxy, lua_isstring, lua_istable, lua_isthread, lua_isuserdata, lua_len, lua_load, lua_newtable, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, lua_pushcfunction, lua_pushfstring, lua_pushglobaltable, lua_pushinteger, lua_pushjsclosure, lua_pushjsfunction, lua_pushlightuserdata, lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, lua_replace, lua_rotate, lua_setallocf, lua_setfield, lua_setglobal, lua_seti, lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, lua_setuservalue, lua_status, lua_stringtonumber, lua_toboolean, lua_todataview, lua_tointeger, lua_tointegerx, lua_tojsstring, lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, lua_toproxy, lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, lua_upvalueid, lua_upvaluejoin, lua_version, lua_xmove, lua_tocfunction } from './lapi.js'; diff --git a/src/luaconf.js b/src/luaconf.js index fd7866cf..2f9a99b8 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -153,22 +153,22 @@ export const LUAL_BUFFERSIZE = conf.LUAL_BUFFERSIZE || 8192; // See: http://croquetweak.blogspot.fr/2014/08/deconstructing-floats-frexp-and-ldexp.html export const frexp = function (value) { if (value === 0) return [value, 0]; - var data = new DataView(new ArrayBuffer(8)); + const data = new DataView(new ArrayBuffer(8)); data.setFloat64(0, value); - var bits = (data.getUint32(0) >>> 20) & 0x7FF; + let bits = (data.getUint32(0) >>> 20) & 0x7FF; if (bits === 0) { // denormal data.setFloat64(0, value * Math.pow(2, 64)); // exp + 64 bits = ((data.getUint32(0) >>> 20) & 0x7FF) - 64; } - var exponent = bits - 1022; - var mantissa = ldexp(value, -exponent); + const exponent = bits - 1022; + const mantissa = ldexp(value, -exponent); return [mantissa, exponent]; }; export const ldexp = function (mantissa, exponent) { - var steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023)); - var result = mantissa; - for (var i = 0; i < steps; i++) + const steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023)); + let result = mantissa; + for (let i = 0; i < steps; i++) result *= Math.pow(2, Math.floor((exponent + i) / steps)); return result; }; diff --git a/src/lualib.js b/src/lualib.js index ebae6fb7..7719fadd 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,5 +1,7 @@ export { luaL_openlibs } from './linit.js'; -import { luaopen_io } from './liolib.js'; +import {luaopen_io} from './liolib.js'; +import {LUA_VERSION_MAJOR, LUA_VERSION_MINOR} from './lua.js'; + export { luaopen_io }; export { luaopen_table } from './ltablib.js'; export { luaopen_coroutine } from './lcorolib.js'; @@ -10,7 +12,6 @@ export { luaopen_math } from './lmathlib.js'; export { luaopen_debug } from './ldblib.js'; export { luaopen_package } from './loadlib.js'; export { luaopen_fengari } from './fengarilib.js'; -import { LUA_VERSION_MAJOR, LUA_VERSION_MINOR } from './lua.js'; export const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; diff --git a/src/lundump.js b/src/lundump.js index 9223cec6..bbdd3b36 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -34,7 +34,7 @@ class BytecodeParser { if (name[0] === 64 /* ('@').charCodeAt(0) */ || name[0] === 61 /* ('=').charCodeAt(0) */) this.name = name.subarray(1); - else if (name[0] == defs.LUA_SIGNATURE[0]) + else if (name[0] === defs.LUA_SIGNATURE[0]) this.name = defs.to_luastring('binary string', true); else this.name = name; diff --git a/src/lvm.js b/src/lvm.js index 024a2da6..57b60ee9 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -103,7 +103,7 @@ export const luaV_finishOp = function (L) { res = !res; /* negate result */ } llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_JMP); - if (res !== (inst.A ? true : false)) /* condition failed? */ + if (res !== (!!inst.A)) /* condition failed? */ ci.l_savedpc++; /* skip jump instruction */ break; } @@ -158,7 +158,6 @@ export const luaV_execute = function (L) { let ci = L.ci; ci.callstatus |= lstate.CIST_FRESH; - newframe: for (; ;) { llimits.lua_assert(ci === L.ci); let cl = ci.func.value; @@ -499,7 +498,7 @@ export const luaV_execute = function (L) { ldo.adjust_top(L, ci.top); /* adjust results */ } else { ci = L.ci; - continue newframe; + continue; } break; @@ -530,7 +529,7 @@ export const luaV_execute = function (L) { llimits.lua_assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize); - continue newframe; + continue; } break; } @@ -545,7 +544,7 @@ export const luaV_execute = function (L) { if (b) ldo.adjust_top(L, ci.top); llimits.lua_assert(ci.callstatus & lstate.CIST_LUA); llimits.lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); - continue newframe; + break; } case OP_FORLOOP: { if (L.stack[ra].ttisinteger()) { /* integer loop? */ @@ -738,7 +737,7 @@ export const luaV_equalobj = function (L, t1, t2) { case LUA_TNIL: return 1; case LUA_TBOOLEAN: - return t1.value == t2.value ? 1 : 0; // Might be 1 or true + return t1.value === t2.value ? 1 : 0; // Might be 1 or true case LUA_TLIGHTUSERDATA: case LUA_TNUMINT: case LUA_TNUMFLT: diff --git a/src/lzio.js b/src/lzio.js index 491db5ef..1eef2ed2 100644 --- a/src/lzio.js +++ b/src/lzio.js @@ -1,4 +1,4 @@ -import { lua_assert } from './llimits.js'; +import {lua_assert} from './llimits.js'; export class MBuffer { constructor() { diff --git a/test/defs.test.js b/test/defs.test.js index c487ec88..e6319de8 100644 --- a/test/defs.test.js +++ b/test/defs.test.js @@ -1,4 +1,4 @@ -import { luastring_of, to_luastring, to_jsstring } from '../src/defs.js'; +import {luastring_of, to_jsstring, to_luastring} from '../src/defs.js'; const unicode_tests = [ diff --git a/test/lapi.test.js b/test/lapi.test.js index 59f18525..4175de1a 100644 --- a/test/lapi.test.js +++ b/test/lapi.test.js @@ -1,8 +1,41 @@ -import { toByteCode } from './tests.js'; - -import { lua_pushnil, lua_pushnumber, lua_tonumber, lua_pushinteger, lua_tointeger, lua_pushliteral, lua_tojsstring, lua_pushboolean, lua_toboolean, lua_pushvalue, lua_pushjsclosure, lua_pushjsfunction, lua_call, lua_pushstring, lua_tostring, lua_upvalueindex, lua_pcall, LUA_OK, lua_pop, lua_load, lua_setglobal, lua_createtable, lua_istable, lua_newtable, lua_settable, lua_gettable, lua_pushcfunction, lua_atnativeerror, lua_touserdata, LUA_ERRRUN, lua_seti, lua_len } from '../src/lua.js'; -import { luaL_newstate, luaL_typename, luaL_loadstring, luaL_error } from '../src/lauxlib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {toByteCode} from './tests.js'; + +import { + lua_atnativeerror, + lua_call, + lua_createtable, + LUA_ERRRUN, + lua_gettable, + lua_istable, + lua_len, + lua_load, + lua_newtable, + LUA_OK, + lua_pcall, + lua_pop, + lua_pushboolean, + lua_pushcfunction, + lua_pushinteger, + lua_pushjsclosure, + lua_pushjsfunction, + lua_pushliteral, + lua_pushnil, + lua_pushnumber, + lua_pushstring, + lua_pushvalue, + lua_setglobal, + lua_seti, + lua_settable, + lua_toboolean, + lua_tointeger, + lua_tojsstring, + lua_tonumber, + lua_tostring, + lua_touserdata, + lua_upvalueindex +} from '../src/lua.js'; +import {luaL_error, luaL_loadstring, luaL_newstate, luaL_typename} from '../src/lauxlib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('luaL_newstate, lua_pushnil, luaL_typename', () => { diff --git a/test/lauxlib.test.js b/test/lauxlib.test.js index ab863e72..798630ad 100644 --- a/test/lauxlib.test.js +++ b/test/lauxlib.test.js @@ -1,6 +1,6 @@ -import { lua_pushstring, LUA_REGISTRYINDEX, lua_rawgeti, lua_tojsstring } from '../src/lua.js'; -import { luaL_newstate, luaL_ref, luaL_unref } from '../src/lauxlib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_pushstring, lua_rawgeti, LUA_REGISTRYINDEX, lua_tojsstring} from '../src/lua.js'; +import {luaL_newstate, luaL_ref, luaL_unref} from '../src/lauxlib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => { diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js index a0627d4d..1c83ade1 100644 --- a/test/lbaselib.test.js +++ b/test/lbaselib.test.js @@ -1,7 +1,18 @@ -import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_toboolean, lua_pcall, lua_tointeger, lua_topointer, lua_isnil, lua_tonumber } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import { + lua_call, + lua_isnil, + lua_istable, + LUA_OK, + lua_pcall, + lua_toboolean, + lua_tointeger, + lua_tojsstring, + lua_tonumber, + lua_topointer +} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('print', () => { diff --git a/test/lcorolib.test.js b/test/lcorolib.test.js index cb254227..507b9c80 100644 --- a/test/lcorolib.test.js +++ b/test/lcorolib.test.js @@ -1,8 +1,8 @@ -import { LUA_OK, lua_call, lua_tonumber, lua_tojsstring, lua_toboolean, lua_tothread } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { lua_State } from '../src/lstate.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, LUA_OK, lua_toboolean, lua_tojsstring, lua_tonumber, lua_tothread} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {lua_State} from '../src/lstate.js'; +import {to_luastring} from '../src/fengaricore.js'; test('coroutine.create, coroutine.yield, coroutine.resume', () => { let L = luaL_newstate(); diff --git a/test/ldebug.test.js b/test/ldebug.test.js index 53000ee8..15910fcf 100644 --- a/test/ldebug.test.js +++ b/test/ldebug.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_pcall, lua_tojsstring } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {LUA_OK, lua_pcall, lua_tojsstring} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('luaG_typeerror', () => { let L = luaL_newstate(); diff --git a/test/lexparse.test.js b/test/lexparse.test.js index f50276a8..e28beabd 100644 --- a/test/lexparse.test.js +++ b/test/lexparse.test.js @@ -1,8 +1,18 @@ -import { lua_load, lua_call, lua_tojsstring, lua_type, LUA_TTABLE, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from '../src/lua.js'; -import { luaL_newstate } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { luaS_hash } from '../src/lstring.js'; -import { to_luastring } from '../src/fengaricore.js'; +import { + lua_call, + lua_load, + lua_toboolean, + lua_tointeger, + lua_tojsstring, + lua_tonumber, + lua_topointer, + LUA_TTABLE, + lua_type +} from '../src/lua.js'; +import {luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {luaS_hash} from '../src/lstring.js'; +import {to_luastring} from '../src/fengaricore.js'; // Roughly the same tests as test/lvm.js to cover all opcodes test('LOADK, RETURN', () => { diff --git a/test/lmathlib.test.js b/test/lmathlib.test.js index db1d5c44..4de68371 100644 --- a/test/lmathlib.test.js +++ b/test/lmathlib.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_call, lua_tointeger, lua_tonumber, lua_tojsstring, lua_toboolean } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, LUA_OK, lua_toboolean, lua_tointeger, lua_tojsstring, lua_tonumber} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', () => { let L = luaL_newstate(); @@ -83,7 +83,7 @@ test('math.log', () => { /* Node.js 6 has incorrect results for Math.exp */ -(parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', () => { +test('math.exp', () => { let L = luaL_newstate(); if (!L) throw Error('failed to create lua state'); diff --git a/test/load.test.js b/test/load.test.js index 769ecfb6..352eb262 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -1,9 +1,9 @@ -import { toByteCode } from './tests.js'; +import {toByteCode} from './tests.js'; -import { LUA_OK, lua_call, lua_tojsstring } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, LUA_OK, lua_tojsstring} from '../src/lua.js'; +import {luaL_loadbuffer, luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('luaL_loadstring', () => { let L = luaL_newstate(); diff --git a/test/loadlib.test.js b/test/loadlib.test.js index 0cc842d6..a084663d 100644 --- a/test/loadlib.test.js +++ b/test/loadlib.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_call, lua_istable, lua_tojsstring } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, lua_istable, LUA_OK, lua_tojsstring} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('require an existing module', () => { let L = luaL_newstate(); diff --git a/test/loslib.test.js b/test/loslib.test.js index e5e1d61c..6960e755 100644 --- a/test/loslib.test.js +++ b/test/loslib.test.js @@ -1,7 +1,15 @@ -import { LUA_OK, lua_call, lua_isinteger, lua_tointeger, lua_isnumber, lua_tojsstring, lua_isstring } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import { + lua_call, + lua_isinteger, + lua_isnumber, + lua_isstring, + LUA_OK, + lua_tointeger, + lua_tojsstring +} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('os.time', () => { let L = luaL_newstate(); diff --git a/test/lstrlib.test.js b/test/lstrlib.test.js index 22934f0a..1a31f1fe 100644 --- a/test/lstrlib.test.js +++ b/test/lstrlib.test.js @@ -1,7 +1,16 @@ -import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring, lua_tostring, lua_load, lua_toboolean, lua_gettop } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import { + lua_call, + lua_gettop, + lua_load, + LUA_OK, + lua_toboolean, + lua_tointeger, + lua_tojsstring, + lua_tostring +} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('string.len', () => { let L = luaL_newstate(); diff --git a/test/ltablib.test.js b/test/ltablib.test.js index b4e2620b..9993e875 100644 --- a/test/ltablib.test.js +++ b/test/ltablib.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_call, lua_tojsstring, lua_topointer, lua_tointeger } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, LUA_OK, lua_tointeger, lua_tojsstring, lua_topointer} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; const inttable2array = function(t) { let a = []; diff --git a/test/ltm.test.js b/test/ltm.test.js index b9ab0f4b..f7437cca 100644 --- a/test/ltm.test.js +++ b/test/ltm.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_call, lua_isnil, lua_tointeger, lua_tojsstring, lua_toboolean } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, lua_isnil, LUA_OK, lua_toboolean, lua_tointeger, lua_tojsstring} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('__index, __newindex: with actual table', () => { let L = luaL_newstate(); diff --git a/test/lua.test.js b/test/lua.test.js index d793a658..9819241b 100644 --- a/test/lua.test.js +++ b/test/lua.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_call } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, LUA_OK} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; // TODO: remove test.skip('locals.lua', () => { diff --git a/test/lutf8lib.test.js b/test/lutf8lib.test.js index e6d0eaac..36028173 100644 --- a/test/lutf8lib.test.js +++ b/test/lutf8lib.test.js @@ -1,7 +1,7 @@ -import { LUA_OK, lua_call, lua_tointeger, lua_tojsstring } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaL_openlibs } from '../src/lualib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_call, LUA_OK, lua_tointeger, lua_tojsstring} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaL_openlibs} from '../src/lualib.js'; +import {to_luastring} from '../src/fengaricore.js'; test('utf8.offset', () => { let L = luaL_newstate(); diff --git a/test/lvm.test.js b/test/lvm.test.js index 61abd53e..927ff66c 100644 --- a/test/lvm.test.js +++ b/test/lvm.test.js @@ -1,7 +1,16 @@ -import { LUA_OK, lua_call, lua_tojsstring, lua_istable, lua_tointeger, lua_toboolean, lua_tonumber, lua_topointer } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { luaS_hash } from '../src/lstring.js'; -import { to_luastring } from '../src/fengaricore.js'; +import { + lua_call, + lua_istable, + LUA_OK, + lua_toboolean, + lua_tointeger, + lua_tojsstring, + lua_tonumber, + lua_topointer +} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {luaS_hash} from '../src/lstring.js'; +import {to_luastring} from '../src/fengaricore.js'; test('LOADK, RETURN', () => { diff --git a/test/manual-tests/debug-cli.js b/test/manual-tests/debug-cli.js index 119dd6a2..83f97cf1 100755 --- a/test/manual-tests/debug-cli.js +++ b/test/manual-tests/debug-cli.js @@ -1,9 +1,9 @@ #!/usr/bin/env node -import { lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; let luaCode = ` a = "debug me" diff --git a/test/test-suite/api.test.js b/test/test-suite/api.test.js index ebdf6920..56082f7f 100644 --- a/test/test-suite/api.test.js +++ b/test/test-suite/api.test.js @@ -1,9 +1,9 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; -import { luaopen_tests } from './ltests.js'; +import {luaopen_tests} from './ltests.js'; // TODO: a lot of gc related tests are skipped // TODO: io.read is used in several tests, uncomment them when it's implemented diff --git a/test/test-suite/attrib.test.js b/test/test-suite/attrib.test.js index bfba6f3d..c5b055f6 100644 --- a/test/test-suite/attrib.test.js +++ b/test/test-suite/attrib.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] attrib: testing require', () => { let L = luaL_newstate(); diff --git a/test/test-suite/bitwise.test.js b/test/test-suite/bitwise.test.js index c8b1edd9..77b2f4c0 100644 --- a/test/test-suite/bitwise.test.js +++ b/test/test-suite/bitwise.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` package.preload.bit32 = function () --{ diff --git a/test/test-suite/calls.test.js b/test/test-suite/calls.test.js index e7776ea8..ef3014b3 100644 --- a/test/test-suite/calls.test.js +++ b/test/test-suite/calls.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] calls: test \'type\'', () => { let L = luaL_newstate(); diff --git a/test/test-suite/closure.test.js b/test/test-suite/closure.test.js index 9be13f0f..c3d61696 100644 --- a/test/test-suite/closure.test.js +++ b/test/test-suite/closure.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] closure: testing equality', () => { let L = luaL_newstate(); diff --git a/test/test-suite/code.test.js b/test/test-suite/code.test.js index 82e70c19..f159e387 100644 --- a/test/test-suite/code.test.js +++ b/test/test-suite/code.test.js @@ -1,9 +1,9 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; -import { luaopen_tests } from './ltests.js'; +import {luaopen_tests} from './ltests.js'; test('[test-suite] code: testing reuse in constant table', () => { let L = luaL_newstate(); diff --git a/test/test-suite/constructs.test.js b/test/test-suite/constructs.test.js index 56029360..d0758ccb 100644 --- a/test/test-suite/constructs.test.js +++ b/test/test-suite/constructs.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const checkload = ` local function checkload (s, msg) diff --git a/test/test-suite/coroutine.test.js b/test/test-suite/coroutine.test.js index 3386b33c..89e29046 100644 --- a/test/test-suite/coroutine.test.js +++ b/test/test-suite/coroutine.test.js @@ -1,9 +1,9 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; -import { luaopen_tests } from './ltests.js'; +import {luaopen_tests} from './ltests.js'; const prefix = ` mt = { diff --git a/test/test-suite/db.test.js b/test/test-suite/db.test.js index 3edcaadb..6108166f 100644 --- a/test/test-suite/db.test.js +++ b/test/test-suite/db.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadbuffer, luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` local function dostring(s) return assert(load(s))() end diff --git a/test/test-suite/errors.test.js b/test/test-suite/errors.test.js index 403325dc..f9ae121a 100644 --- a/test/test-suite/errors.test.js +++ b/test/test-suite/errors.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring, luaL_loadbuffer } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadbuffer, luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` -- avoid problems with 'strict' module (which may generate other error messages) diff --git a/test/test-suite/events.test.js b/test/test-suite/events.test.js index 42633549..b0b322df 100644 --- a/test/test-suite/events.test.js +++ b/test/test-suite/events.test.js @@ -1,9 +1,9 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; -import { luaopen_tests } from './ltests.js'; +import {luaopen_tests} from './ltests.js'; test('[test-suite] events: testing metatable', () => { let L = luaL_newstate(); diff --git a/test/test-suite/goto.test.js b/test/test-suite/goto.test.js index 53dc3c82..0861fa05 100644 --- a/test/test-suite/goto.test.js +++ b/test/test-suite/goto.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] goto: error messages', () => { let L = luaL_newstate(); diff --git a/test/test-suite/literals.test.js b/test/test-suite/literals.test.js index 014fc754..ad80471e 100644 --- a/test/test-suite/literals.test.js +++ b/test/test-suite/literals.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const dostring = ` local function dostring (x) return assert(load(x), "")() end diff --git a/test/test-suite/locals.test.js b/test/test-suite/locals.test.js index 339c9e7d..d9250be2 100644 --- a/test/test-suite/locals.test.js +++ b/test/test-suite/locals.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] locals: bug in 5.1', () => { let L = luaL_newstate(); diff --git a/test/test-suite/ltests.js b/test/test-suite/ltests.js index e23d1138..5bdd7cf5 100644 --- a/test/test-suite/ltests.js +++ b/test/test-suite/ltests.js @@ -1,12 +1,153 @@ import assert from 'assert'; -import { lua_tointeger, lua_pop, lua_gettop, LUA_REGISTRYINDEX, lua_upvalueindex, lua_pushstring, lua_pushnumber, lua_absindex, lua_rawlen, lua_rawseti, lua_arith, lua_call, lua_callk, LUA_OPEQ, LUA_OPLT, LUA_OPLE, lua_pushboolean, lua_compare, lua_concat, lua_copy, lua_tocfunction, lua_getfield, lua_getglobal, lua_getmetatable, lua_pushnil, lua_gettable, lua_pushinteger, lua_tostring, lua_insert, lua_iscfunction, lua_isfunction, lua_isnil, lua_isnone, lua_isnumber, lua_isstring, lua_istable, lua_islightuserdata, lua_isuserdata, lua_len, lua_newtable, lua_newthread, lua_newuserdata, lua_next, lua_pcall, lua_pcallk, lua_pushcclosure, lua_pushvalue, lua_rawgeti, lua_rawgetp, lua_rawsetp, lua_remove, lua_replace, lua_resume, lua_tothread, lua_rotate, lua_setfield, lua_setglobal, lua_setmetatable, lua_settable, lua_settop, lua_error, lua_toboolean, lua_pushcfunction, lua_tonumber, lua_topointer, lua_xmove, lua_yield, lua_yieldk, lua_isthread, LUA_TFUNCTION, lua_getupvalue, lua_setupvalue, lua_pushlightuserdata, lua_touserdata, lua_pushlstring, lua_newstate, lua_atpanic, lua_type, LUA_TTABLE, lua_close, LUA_OK, LUA_MULTRET, lua_tojsstring, lua_checkstack, lua_pushliteral, lua_sethook, lua_isnoneornil, LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, LUA_MASKCOUNT, LUA_YIELD, lua_createtable } from '../../src/lua.js'; -import { luaL_error, luaL_checkstack, luaL_gsub, luaL_len, luaL_loadfile, luaL_checkstring, luaL_loadstring, luaL_newmetatable, luaL_tojsstring, luaL_testudata, luaL_typename, luaL_checkinteger, luaL_checktype, luaL_checknumber, luaL_argcheck, luaL_requiref, luaL_getsubtable, LUA_PRELOAD_TABLE, luaL_checklstring, luaL_loadbuffer, luaL_optstring, luaL_optinteger, luaL_newlib } from '../../src/lauxlib.js'; -import { luastring_eq, luastring_indexOf, to_jsstring, to_luastring } from '../../src/fengaricore.js'; -import { lisdigit } from '../../src/ljstype.js'; -import { GET_OPCODE, OpCodes, getOpMode, iABC, GETARG_A, GETARG_B, GETARG_C, iABx, GETARG_Bx, iAsBx, GETARG_sBx, iAx, GETARG_Ax } from '../../src/lopcodes.js'; -import { pushobj2s } from '../../src/lobject.js'; -import { sprintf } from 'sprintf-js'; +import { + lua_absindex, + lua_arith, + lua_atpanic, + lua_call, + lua_callk, + lua_checkstack, + lua_close, + lua_compare, + lua_concat, + lua_copy, + lua_createtable, + lua_error, + lua_getfield, + lua_getglobal, + lua_getmetatable, + lua_gettable, + lua_gettop, + lua_getupvalue, + lua_insert, + lua_iscfunction, + lua_isfunction, + lua_islightuserdata, + lua_isnil, + lua_isnone, + lua_isnoneornil, + lua_isnumber, + lua_isstring, + lua_istable, + lua_isthread, + lua_isuserdata, + lua_len, + LUA_MASKCALL, + LUA_MASKCOUNT, + LUA_MASKLINE, + LUA_MASKRET, + LUA_MULTRET, + lua_newstate, + lua_newtable, + lua_newthread, + lua_newuserdata, + lua_next, + LUA_OK, + LUA_OPEQ, + LUA_OPLE, + LUA_OPLT, + lua_pcall, + lua_pcallk, + lua_pop, + lua_pushboolean, + lua_pushcclosure, + lua_pushcfunction, + lua_pushinteger, + lua_pushlightuserdata, + lua_pushliteral, + lua_pushlstring, + lua_pushnil, + lua_pushnumber, + lua_pushstring, + lua_pushvalue, + lua_rawgeti, + lua_rawgetp, + lua_rawlen, + lua_rawseti, + lua_rawsetp, + LUA_REGISTRYINDEX, + lua_remove, + lua_replace, + lua_resume, + lua_rotate, + lua_setfield, + lua_setglobal, + lua_sethook, + lua_setmetatable, + lua_settable, + lua_settop, + lua_setupvalue, + LUA_TFUNCTION, + lua_toboolean, + lua_tocfunction, + lua_tointeger, + lua_tojsstring, + lua_tonumber, + lua_topointer, + lua_tostring, + lua_tothread, + lua_touserdata, + LUA_TTABLE, + lua_type, + lua_upvalueindex, + lua_xmove, + lua_yield, + LUA_YIELD, + lua_yieldk +} from '../../src/lua.js'; +import { + LUA_PRELOAD_TABLE, + luaL_argcheck, + luaL_checkinteger, + luaL_checklstring, + luaL_checknumber, + luaL_checkstack, + luaL_checkstring, + luaL_checktype, + luaL_error, + luaL_getsubtable, + luaL_gsub, + luaL_len, + luaL_loadbuffer, + luaL_loadfile, + luaL_loadstring, + luaL_newlib, + luaL_newmetatable, + luaL_optinteger, + luaL_optstring, + luaL_requiref, + luaL_testudata, + luaL_tojsstring, + luaL_typename +} from '../../src/lauxlib.js'; +import {luastring_eq, luastring_indexOf, to_jsstring, to_luastring} from '../../src/fengaricore.js'; +import {lisdigit} from '../../src/ljstype.js'; +import { + GET_OPCODE, + GETARG_A, + GETARG_Ax, + GETARG_B, + GETARG_Bx, + GETARG_C, + GETARG_sBx, + getOpMode, + iABC, + iABx, + iAsBx, + iAx, + OpCodes +} from '../../src/lopcodes.js'; +import {pushobj2s} from '../../src/lobject.js'; +import {sprintf} from 'sprintf-js'; +import {luaopen_base} from '../../src/lbaselib.js'; +import {luaopen_coroutine} from '../../src/lcorolib.js'; +import {luaopen_debug} from '../../src/ldblib.js'; +import {luaopen_io} from '../../src/liolib.js'; +import {luaopen_os} from '../../src/loslib.js'; +import {luaopen_math} from '../../src/lmathlib.js'; +import {luaopen_string} from '../../src/lstrlib.js'; +import {luaopen_table} from '../../src/ltablib.js'; +import {luaopen_package} from '../../src/loadlib.js'; const delimits = [' ', '\t', '\n', ',', ';'].map(e => e.charCodeAt(0)); @@ -556,16 +697,6 @@ const getstate = function(L) { return L1; }; -import { luaopen_base } from '../../src/lbaselib.js'; -import { luaopen_coroutine } from '../../src/lcorolib.js'; -import { luaopen_debug } from '../../src/ldblib.js'; -import { luaopen_io } from '../../src/liolib.js'; -import { luaopen_os } from '../../src/loslib.js'; -import { luaopen_math } from '../../src/lmathlib.js'; -import { luaopen_string } from '../../src/lstrlib.js'; -import { luaopen_table } from '../../src/ltablib.js'; -import { luaopen_package } from '../../src/loadlib.js'; - const loadlib = function(L) { let libs = { '_G': luaopen_base, diff --git a/test/test-suite/math.test.js b/test/test-suite/math.test.js index 07cfacb1..78044c9e 100644 --- a/test/test-suite/math.test.js +++ b/test/test-suite/math.test.js @@ -1,9 +1,9 @@ 'use strict'; -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` local minint = math.mininteger diff --git a/test/test-suite/nextvar.test.js b/test/test-suite/nextvar.test.js index ad29b057..c0320a8b 100644 --- a/test/test-suite/nextvar.test.js +++ b/test/test-suite/nextvar.test.js @@ -1,9 +1,9 @@ 'use strict'; -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` local function checkerror (msg, f, ...) diff --git a/test/test-suite/pm.test.js b/test/test-suite/pm.test.js index 32f3a34c..f33123eb 100644 --- a/test/test-suite/pm.test.js +++ b/test/test-suite/pm.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring, luaL_loadfile } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadfile, luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] pm: pattern matching', () => { let L = luaL_newstate(); diff --git a/test/test-suite/sort.test.js b/test/test-suite/sort.test.js index 3f186b22..01a8d0e7 100644 --- a/test/test-suite/sort.test.js +++ b/test/test-suite/sort.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` local unpack = table.unpack diff --git a/test/test-suite/strings.test.js b/test/test-suite/strings.test.js index 19918413..127b51d9 100644 --- a/test/test-suite/strings.test.js +++ b/test/test-suite/strings.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const checkerror = ` local maxi, mini = math.maxinteger, math.mininteger diff --git a/test/test-suite/tpack.test.js b/test/test-suite/tpack.test.js index 4d316be7..9d1e8e3b 100644 --- a/test/test-suite/tpack.test.js +++ b/test/test-suite/tpack.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` local pack = string.pack diff --git a/test/test-suite/utf8.test.js b/test/test-suite/utf8.test.js index 42f0941b..b6d2c30a 100644 --- a/test/test-suite/utf8.test.js +++ b/test/test-suite/utf8.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; const prefix = ` local function checkerror (msg, f, ...) diff --git a/test/test-suite/vararg.test.js b/test/test-suite/vararg.test.js index 298a9b35..f2abe76d 100644 --- a/test/test-suite/vararg.test.js +++ b/test/test-suite/vararg.test.js @@ -1,7 +1,7 @@ -import { LUA_ERRSYNTAX, lua_tojsstring, lua_call } from '../../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../../src/lauxlib.js'; -import { luaL_openlibs } from '../../src/lualib.js'; -import { to_luastring } from '../../src/fengaricore.js'; +import {lua_call, LUA_ERRSYNTAX, lua_tojsstring} from '../../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../../src/lauxlib.js'; +import {luaL_openlibs} from '../../src/lualib.js'; +import {to_luastring} from '../../src/fengaricore.js'; test('[test-suite] vararg: testing vararg', () => { let L = luaL_newstate(); diff --git a/test/tests.js b/test/tests.js index abdb0f77..c67f06ad 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,6 +1,6 @@ -import { LUA_OK, lua_tojsstring, lua_dump } from '../src/lua.js'; -import { luaL_newstate, luaL_loadstring } from '../src/lauxlib.js'; -import { to_luastring } from '../src/fengaricore.js'; +import {lua_dump, LUA_OK, lua_tojsstring} from '../src/lua.js'; +import {luaL_loadstring, luaL_newstate} from '../src/lauxlib.js'; +import {to_luastring} from '../src/fengaricore.js'; export const toByteCode = function(luaCode) { let L = luaL_newstate();