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/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..9db4af4d --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,25 @@ +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: ["**/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', + '@stylistic/semi': ['error', 'always'], + '@stylistic/curly-newline': 'error', + '@stylistic/indent': ['error', 4], + '@stylistic/comma-dangle': ['error', 'never'], + 'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }], + 'no-empty': ['error', { allowEmptyCatch: true }] + } + } +]); 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/jest.config.cjs b/jest.config.cjs new file mode 100644 index 00000000..a1449799 --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,199 @@ +/** + * 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/" + ], + + // 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..97a7d66f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { - "name": "fengari", - "version": "0.1.5", - "description": "A Lua VM written in JS ES6 targeting the browser", + "name": "@ctrlo/fengari", + "version": "0.1.6", + "description": "A Lua VM written in JS modules targeting the browser", "main": "src/fengari.js", + "type": "module", "directories": { "lib": "src", "test": "test" @@ -14,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", @@ -22,21 +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": { - "eslint": "^9.39.2", - "jest": "^30.2.0" + "@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", + "@stylistic/eslint-plugin": "^5.10.0", + "eslint": "^10.0.0", + "globals": "^17.6.0", + "jest": "^24.5.0" }, "dependencies": { - "readline-sync": "^1.4.10", - "sprintf-js": "^1.1.3", - "tmp": "^0.2.5" + "readline-sync": "^1.4.9", + "sprintf-js": "^1.1.2", + "tmp": "^0.0.33" }, "sideEffects": false } diff --git a/src/common.js b/src/common.js new file mode 100644 index 00000000..70c05ac5 --- /dev/null +++ b/src/common.js @@ -0,0 +1,9 @@ +const conf = (typeof process !== 'undefined' && 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 daa5f702..2368445e 100644 --- a/src/defs.js +++ b/src/defs.js @@ -1,64 +1,58 @@ -"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) { +import {LUAI_MAXSTACK} from './common.js'; + +export { LUAI_MAXSTACK }; + +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 function is_luastring(s) { return s instanceof Uint8Array; -}; +} /* test two lua strings for equality */ -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; /* 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 +113,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 */ @@ -151,33 +145,33 @@ const to_jsstring = function(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 */ -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++; @@ -222,76 +216,54 @@ const to_luastring = function(str, cache) { if (cache) to_luastring_cache[str] = outU8Array; return outU8Array; -}; +} -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; -}; - -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"; -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, +export const LUA_SIGNATURE = to_luastring('\x1bLua'); + +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 = '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, + 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, + 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 */ @@ -304,44 +276,45 @@ 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; -const LUA_OPUNM = 12; -const LUA_OPBNOT = 13; - -const LUA_OPEQ = 0; -const LUA_OPLT = 1; -const LUA_OPLE = 2; - -const LUA_MINSTACK = 20; - -const { LUAI_MAXSTACK } = require('./luaconf.js'); -const LUA_REGISTRYINDEX = -LUAI_MAXSTACK - 1000; - -const lua_upvalueindex = function(i) { +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; + +export const LUA_OPEQ = 0; +export const LUA_OPLT = 1; +export const LUA_OPLE = 2; + +export const LUA_MINSTACK = 20; + +export const LUA_REGISTRYINDEX = -LUAI_MAXSTACK - 1000; + +export function lua_upvalueindex(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_MAINTHREAD = 1; +export const LUA_RIDX_GLOBALS = 2; +export const LUA_RIDX_LAST = LUA_RIDX_GLOBALS; -class lua_Debug { +export class lua_Debug { constructor() { this.event = NaN; this.name = null; /* (n) */ @@ -364,54 +337,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_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); -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; +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 147756fe..0488f5fc 100644 --- a/src/fengari.js +++ b/src/fengari.js @@ -1,37 +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'; -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 * 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..7c77c00a 100644 --- a/src/fengaricore.js +++ b/src/fengaricore.js @@ -6,31 +6,15 @@ * avoid a dependency on defs.js from lauxlib.js they are defined in this file. */ -const defs = require("./defs.js"); +import {LUA_COPYRIGHT} 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; +export { LUA_COPYRIGHT, is_luastring, luastring_eq, luastring_from, luastring_indexOf, luastring_of, to_jsstring, to_luastring, to_uristring, from_userstring } from './defs.js'; -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 = '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 158fb034..aa6ee806 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 * 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; }; - -module.exports.luaopen_fengari = luaopen_fengari; diff --git a/src/lapi.js b/src/lapi.js index 7443fb78..e74fe589 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1,111 +1,93 @@ -"use strict"; - -const { - LUA_MULTRET, - LUA_OPBNOT, - LUA_OPEQ, - LUA_OPLE, - LUA_OPLT, - LUA_OPUNM, - 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 }, - 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'); -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) { +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, + 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 +} = defs.constant_types; + +export const { LUA_OK } = defs.thread_status; + +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) { - if (!c) throw TypeError("invalid argument"); +export const fengari_argcheck = function (c) { + if (!c) throw TypeError('invalid argument'); }; -const fengari_argcheckinteger = function(n) { - fengari_argcheck(typeof n === "number" && (n|0) === n); +export const fengari_argcheckinteger = function (n) { + fengari_argcheck(typeof n === 'number' && (n | 0) === n); }; -const isvalid = function(o) { +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"); + 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 <= lfunc.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 lobject.luaO_nilobject; /* it has no upvalues */ else { @@ -115,30 +97,30 @@ const index2addr = function(L, idx) { }; // 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"); + 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 + lstate.EXTRA_STACK; - if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */ + if (inuse > common.LUAI_MAXSTACK - n) /* can grow without overflow? */ res = false; /* no */ else { /* try to grow stack */ ldo.luaD_growstack(L, n); @@ -152,11 +134,11 @@ 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 lobject.TValue(); @@ -173,42 +155,42 @@ 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) { +export const lua_pushvalue = function (L, idx) { lobject.pushobj2s(L, index2addr(L, idx)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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) */ } 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); + let temp = new lobject.TValue(fromtv.type, fromtv.value); lobject.setobjs2s(L, from, to); lobject.setobj2s(L, to, temp); } @@ -218,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); }; @@ -253,124 +235,124 @@ 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) { - fengari_argcheck(typeof n === "number"); - L.stack[L.top] = new TValue(LUA_TNUMFLT, n); +export const lua_pushnumber = function (L, n) { + fengari_argcheck(typeof n === 'number'); + 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)); } lobject.pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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)); + 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); +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); +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); + fengari_argcheck(typeof s === 'string'); + 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) { - fengari_argcheck(typeof fn === "function"); +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 <= lfunc.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); } 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); }; /* @@ -380,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); lobject.pushsvalue2s(L, str); /* push 'str' (to make it a TValue) */ - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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, ltable.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; } @@ -422,7 +404,7 @@ 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); lvm.settable(L, t, L.stack[L.top - 2], L.stack[L.top - 1]); @@ -430,15 +412,15 @@ const lua_settable = function(L, idx) { 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); lvm.settable(L, t, L.stack[L.top - 1], L.stack[L.top - 2]); /* pop value and key */ @@ -446,10 +428,10 @@ const lua_seti = function(L, idx, n) { 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]; ltable.luaH_setfrom(L, o.value, k, v); @@ -458,20 +440,20 @@ const lua_rawset = function(L, idx) { 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"); + 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]; ltable.luaH_setfrom(L, o.value, k, v); delete L.stack[--L.top]; @@ -481,118 +463,117 @@ 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)); +export const auxgetstr = function (L, t, k) { + let str = lstring.luaS_new(L, defs.from_userstring(k)); lobject.pushsvalue2s(L, str); - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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"); + llimits.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"); + 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); + 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)); - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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"); + 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 lobject.TValue(LUA_TTABLE, ltable.luaH_new(L)); - L.stack[L.top] = t; +export const lua_createtable = function (L, _narray, _nrec) { + L.stack[L.top] = new lobject.TValue(LUA_TTABLE, ltable.luaH_new(L)); api_incr_top(L); }; -const luaS_newudata = function(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 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()) { + 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: defs.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() : defs.to_luastring('(*no name)', true), + val: f.upvals[n - 1] }; } default: return null; /* not a closure */ } }; -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; lobject.pushobj2s(L, val); - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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); 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) { +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; @@ -607,7 +588,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; } @@ -615,48 +596,48 @@ 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); 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); 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, ltable.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()) { @@ -668,9 +649,9 @@ const lua_tolstring = function(L, idx) { 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()) { @@ -682,12 +663,12 @@ const lua_tojsstring = function(L, idx) { 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: @@ -702,31 +683,31 @@ const lua_rawlen = function(L, idx) { } }; -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) { +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) { +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: @@ -737,12 +718,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: @@ -762,10 +743,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; @@ -773,24 +754,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) { - let proxy = function(L) { - api_check(L, L instanceof lstate.lua_State && G === L.l_G, "must be from same global state"); - L.stack[L.top] = new TValue(type, value); +export const create_proxy = function (G, type, value) { + let proxy = function (L) { + 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); @@ -798,18 +779,18 @@ 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 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(); +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; @@ -818,88 +799,88 @@ const lua_stringtonumber = function(L, s) { return sz; }; -const f_call = function(L, ud) { +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; + return isvalid(o) ? o.ttnov() : LUA_TNONE; }; -const lua_typename = function(L, t) { - api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); +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) { +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() || 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) ? 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); - lobject.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 */ lobject.luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]); @@ -910,18 +891,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); + 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 = ltable.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); } @@ -929,35 +910,35 @@ 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]; + 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)), - "results from function overflow current stack size"); +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 & lstate.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? */ @@ -968,18 +949,18 @@ const lua_callk = function(L, nargs, nresults, ctx, k) { 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 & lstate.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; @@ -1011,13 +992,13 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) { 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); }; @@ -1025,15 +1006,15 @@ 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); 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(); + 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); @@ -1045,37 +1026,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) lvm.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"); + 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(); + 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 */ @@ -1084,147 +1065,36 @@ 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]; - ref1.f.upvals[ref1.i] = up2; + ref1.f.upvals[ref1.i] = ref2.f.upvals[ref2.i]; }; // This functions are only there for compatibility purposes -const lua_gc = function () {}; +export const lua_gc = function () { }; -const lua_getallocf = function () { - console.warn("lua_getallocf is not available"); +export const lua_getallocf = function () { + console.warn('lua_getallocf is not available'); return 0; }; -const lua_setallocf = function () { - console.warn("lua_setallocf is not available"); +export const lua_setallocf = function () { + console.warn('lua_setallocf is not available'); return 0; }; -const lua_getextraspace = function () { - console.warn("lua_getextraspace is not available"); +export const lua_getextraspace = function () { + 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..ef5dadde 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -1,109 +1,28 @@ -"use strict"; - -const { - LUAL_BUFFERSIZE -} = require('./luaconf.js'); -const { - 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 -} = require('./lua.js'); -const { - from_userstring, - luastring_eq, - to_luastring, - to_uristring -} = require("./fengaricore.js"); +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; @@ -111,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 */ @@ -146,316 +65,316 @@ 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; + let m = Math.floor((li + le) / 2); + 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; 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.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"; + 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 */ 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 */ @@ -466,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); - switch(t) { - case LUA_TNUMBER: { - if (lua_isinteger(L, idx)) - lua_pushfstring(L, p_I, lua_tointeger(L, idx)); + let t = lua.lua_type(L, idx); + switch (t) { + 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); }; /* @@ -627,39 +546,39 @@ 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) { - var i = from_index >>> 0, - sl = subarr.length, +export const find_subarray = function (arr, subarr, from_index) { + let i = from_index >>> 0; + const 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) { +export const luaL_gsub = function (L, s, p, r) { let wild; let b = new luaL_Buffer(); luaL_buffinit(L, b); @@ -670,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 */ } }; @@ -695,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 */ }; /* @@ -713,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; @@ -799,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 */ @@ -818,9 +737,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 +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? */ @@ -846,60 +765,58 @@ 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 */ + 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"); + 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); + 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") { - lf.f = to_luastring(xhr.response); + if (typeof xhr.response === 'string') { + lf.f = fengaricore.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); /* 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' */ - return errfile(L, "read", fnameindex, readstatus); + 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 { - const fs = require('fs'); - class LoadF { constructor() { this.n = NaN; /* number of pre-read characters */ @@ -910,16 +827,16 @@ if (typeof process === "undefined") { } } - const getF = function(L, ud) { + 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 */ } 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 +847,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,53 +860,53 @@ 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 */ + 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"); + lf.f = fs.openSync(filename, 'r'); } catch (e) { - return errfile(L, "open", fnameindex, e); + return errfile(L, 'open', fnameindex, e); } } 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 (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); + 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() { - for (let i=0; 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; }; const opts = [ - "stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", - "isrunning" -].map((e) => to_luastring(e)); + 'stop', 'restart', 'collect', + 'count', 'step', 'setpause', 'setstepmul', + 'isrunning' +].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; }; /* @@ -259,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; } @@ -280,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; } }; @@ -351,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); }; @@ -373,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 */ } }; @@ -410,93 +336,91 @@ 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); }; 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) { +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; }; - -module.exports.luaopen_base = luaopen_base; diff --git a/src/lcode.js b/src/lcode.js index b6b9b16e..a8a11c48 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -1,83 +1,65 @@ -"use strict"; - -const { - 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: { - 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; +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, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TTABLE +} = 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; - -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, +export const NO_JUMP = -1; + +export 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_NOBINOPR: 21 }; -const UnOpr = { - OPR_MINUS: 0, - OPR_BNOT: 1, - OPR_NOT: 2, - OPR_LEN: 3, - OPR_NOUNOPR: 4 +export const UnOpr = { + OPR_MINUS: 0, + OPR_BNOT: 1, + OPR_NOT: 2, + OPR_LEN: 3, + OPR_NOUNOPR: 4 }; -const hasjumps = function(e) { +export const hasjumps = function (e) { return e.t !== e.f; }; @@ -85,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) { +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; @@ -110,16 +92,16 @@ 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? */ + previous = fs.f.code[fs.pc - 1]; + 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? */ + (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); @@ -128,10 +110,10 @@ const luaK_nil = function(fs, from, n) { } } /* 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]; }; @@ -139,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 */ @@ -151,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); + llimits.lua_assert(dest !== NO_JUMP); if (Math.abs(offset) > lopcodes.MAXARG_sBx) - llex.luaX_syntaxerror(fs.ls, to_luastring("control structure too long", true)); + 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; @@ -186,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); }; @@ -218,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; }; @@ -228,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) { +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)]; }; @@ -245,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 !== 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] = lopcodes.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; }; @@ -263,7 +245,7 @@ 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, lopcodes.NO_REG); }; @@ -273,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)) @@ -289,7 +271,7 @@ const patchlistaux = function(fs, list, vtarget, reg, dtarget) { ** to current position with no values) and reset list of pending ** jumps */ -const dischargejpc = function(fs) { +export const dischargejpc = function (fs) { patchlistaux(fs, fs.jpc, fs.pc, lopcodes.NO_REG, fs.pc); fs.jpc = NO_JUMP; }; @@ -298,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); }; @@ -308,11 +290,11 @@ 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); + llimits.lua_assert(target < fs.pc); patchlistaux(fs, list, target, lopcodes.NO_REG, target); } }; @@ -322,11 +304,11 @@ 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)); + llimits.lua_assert(ins.opcode === lopcodes.OpCodesI.OP_JMP && (ins.A === 0 || ins.A >= level)); lopcodes.SETARG_A(ins, level); } }; @@ -335,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 */ @@ -348,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(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); +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(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); +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) { +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 <= lopcodes.MAXARG_Ax); - return luaK_code(fs, lopcodes.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)); }; /* @@ -383,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) { +export const luaK_codek = function (fs, reg, k) { if (k <= lopcodes.MAXARG_Bx) - return luaK_codeABx(fs, OpCodesI.OP_LOADK, reg, k); + 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; } @@ -397,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) - llex.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; } }; @@ -409,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; }; @@ -418,17 +400,17 @@ 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) { +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) { +export const freeexp = function (fs, e) { if (e.k === lparser.expkind.VNONRELOC) freereg(fs, e.u.info); }; @@ -437,7 +419,7 @@ const freeexp = function(fs, e) { ** Free registers used by expressions 'e1' and 'e2' (if any) in proper ** order. */ -const freeexps = function(fs, e1, e2) { +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) { @@ -458,7 +440,7 @@ 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 = ltable.luaH_get(fs.L, fs.ls.h, key); /* index scanner table */ if (idx.ttisinteger()) { /* is there an index there? */ @@ -478,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 */ }; @@ -489,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 */ }; @@ -507,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 */ }; @@ -516,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); }; @@ -528,7 +510,7 @@ 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) { +export const luaK_setreturns = function (fs, e, nresults) { let ek = lparser.expkind; if (e.k === ek.VCALL) { /* expression is an open function call? */ lopcodes.SETARG_C(getinstruction(fs, e), nresults + 1); @@ -539,11 +521,11 @@ const luaK_setreturns = function(fs, e, nresults) { 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); }; /* @@ -556,11 +538,11 @@ 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) { +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) { @@ -572,16 +554,16 @@ const luaK_setoneret = function(fs, e) { /* ** Ensure that expression 'e' is not a variable. */ -const luaK_dischargevars = function(fs, e) { +export const luaK_dischargevars = function (fs, e) { let ek = lparser.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 */ - 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; } @@ -590,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; @@ -607,16 +589,16 @@ 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) { +export const discharge2reg = function (fs, e, reg) { let ek = lparser.expkind; luaK_dischargevars(fs, e); switch (e.k) { @@ -625,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: { @@ -647,11 +629,11 @@ const discharge2reg = function(fs, e, reg) { } 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... */ } } @@ -662,10 +644,10 @@ const discharge2reg = function(fs, e, reg) { /* ** Ensures expression value is in any register. */ -const discharge2anyreg = function(fs, e) { +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 */ + discharge2reg(fs, e, fs.freereg - 1); /* put value there */ } }; @@ -673,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 */ }; @@ -688,7 +670,7 @@ 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) { +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? */ @@ -716,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); @@ -728,7 +710,7 @@ 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 === lparser.expkind.VNONRELOC) { /* expression already has a register? */ if (!hasjumps(e)) /* no jumps? */ @@ -746,7 +728,7 @@ 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) { +export const luaK_exp2anyregup = function (fs, e) { if (e.k !== lparser.expkind.VUPVAL || hasjumps(e)) luaK_exp2anyreg(fs, e); }; @@ -755,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 @@ -768,7 +750,7 @@ const luaK_exp2val = function(fs, e) { ** in the range of R/K indices). ** Returns R/K index. */ -const luaK_exp2RK = function(fs, e) { +export const luaK_exp2RK = function (fs, e) { let ek = lparser.expkind; let vk = false; luaK_exp2val(fs, e); @@ -795,7 +777,7 @@ const luaK_exp2RK = function(fs, e) { /* ** Generate code to store result of expression 'ex' into variable 'var'. */ -const luaK_storevar = function(fs, vr, ex) { +export const luaK_storevar = function (fs, vr, ex) { let ek = lparser.expkind; switch (vr.k) { case ek.VLOCAL: { @@ -805,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; @@ -822,23 +804,23 @@ 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 = 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(lopcodes.testTMode(pc.opcode) && pc.opcode !== OpCodesI.OP_TESTSET && pc.opcode !== OpCodesI.OP_TEST); + 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)); }; @@ -848,24 +830,24 @@ const negatecondition = function(fs, e) { ** Optimize when 'e' is 'not' something, inverting the condition ** and removing the 'not'. */ -const jumponcond = function(fs, e, cond) { +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, lopcodes.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) { +export const luaK_goiftrue = function (fs, e) { let ek = lparser.expkind; let pc; /* pc of new jump */ luaK_dischargevars(fs, e); @@ -892,7 +874,7 @@ const luaK_goiftrue = function(fs, e) { /* ** Emit code to go through if 'e' is false, jump otherwise. */ -const luaK_goiffalse = function(fs, e) { +export const luaK_goiffalse = function (fs, e) { let ek = lparser.expkind; let pc; /* pc of new jump */ luaK_dischargevars(fs, e); @@ -918,7 +900,7 @@ const luaK_goiffalse = function(fs, e) { /* ** Code 'not e', doing constant folding. */ -const codenot = function(fs, e) { +export const codenot = function (fs, e) { let ek = lparser.expkind; luaK_dischargevars(fs, e); switch (e.k) { @@ -938,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; } @@ -953,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) { +export const luaK_indexed = function (fs, t, k) { let ek = lparser.expkind; - lua_assert(!hasjumps(t) && (lparser.vkisinreg(t.k) || t.k === ek.VUPVAL)); + 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; @@ -967,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 */ + 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 */ } @@ -983,12 +965,12 @@ 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) { +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 */ + let res = new lobject.TValue(); /* FIXME */ lobject.luaO_arith(null, op, v1, v2, res); /* does operation */ if (res.ttisinteger()) { e1.k = ek.VKINT; @@ -1009,7 +991,7 @@ 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 */ @@ -1026,7 +1008,7 @@ 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); @@ -1040,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) { +export const codecomp = function (fs, opr, e1, e2) { let ek = lparser.expkind; let rk1; if (e1.k === ek.VK) rk1 = lopcodes.RKASK(e1.u.info); else { - lua_assert(e1.k === ek.VNONRELOC); + llimits.lua_assert(e1.k === ek.VNONRELOC); rk1 = e1.u.info; } @@ -1055,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; } @@ -1076,7 +1058,7 @@ const codecomp = function(fs, opr, e1, e2) { /* ** Apply prefix operation 'op' to expression 'e'. */ -const luaK_prefix = function(fs, op, e, line) { +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; @@ -1084,11 +1066,11 @@ const luaK_prefix = function(fs, op, e, line) { 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 */ + /* 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; } @@ -1098,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 */ @@ -1135,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) { +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); @@ -1155,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); 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; } @@ -1171,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: @@ -1188,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; }; @@ -1199,61 +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)/lopcodes.LFIELDS_PER_FLUSH + 1; - let b = (tostore === LUA_MULTRET) ? 0 : tostore; - lua_assert(tostore !== 0 && tostore <= lopcodes.LFIELDS_PER_FLUSH); +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, OpCodesI.OP_SETLIST, base, b, c); + luaK_codeABC(fs, lopcodes.OpCodesI.OP_SETLIST, base, b, c); else if (c <= lopcodes.MAXARG_Ax) { - luaK_codeABC(fs, OpCodesI.OP_SETLIST, base, b, 0); + luaK_codeABC(fs, lopcodes.OpCodesI.OP_SETLIST, base, b, 0); codeextraarg(fs, c); } else - llex.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 */ }; - - -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..9988a61c 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -1,143 +1,109 @@ -"use strict"; - -const { - 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 -} = require('./lua.js'); -const { - luaL_argcheck, - luaL_checktype, - luaL_newlib, - luaL_where -} = require('./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; } } @@ -146,28 +112,26 @@ 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; }; 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) { - luaL_newlib(L, co_funcs); +export const luaopen_coroutine = function(L) { + lauxlib.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..f594e3ca 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -1,83 +1,13 @@ -"use strict"; - -const { - 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 -} = require('./lua.js'); -const { - 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 -} = require('./lauxlib.js'); -const lualib = require('./lualib.js'); -const { - luastring_indexOf, - to_luastring -} = require("./fengaricore.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'; + +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 @@ -85,45 +15,45 @@ const { ** 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; }; @@ -134,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 { @@ -153,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); }; @@ -176,11 +106,11 @@ const settabsb = function(L, k, v) { ** 'lua_setfield'. */ const treatstackoption = function(L, L1, fname) { - if (L == L1) - lua_rotate(L, -2, 1); /* exchange object and table */ + if (L === L1) + 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 */ }; /* @@ -190,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 */ }; @@ -241,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; } } @@ -270,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; }; @@ -290,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; }; @@ -305,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); }; @@ -314,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; }; @@ -339,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); - lualib.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 */ } }; @@ -367,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; }; @@ -379,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); }; @@ -390,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; }; @@ -419,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; }; @@ -440,50 +370,49 @@ 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; }; 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() { 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) { @@ -491,25 +420,23 @@ 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)) - || 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; }; - -module.exports.luaopen_debug = luaopen_debug; diff --git a/src/ldebug.js b/src/ldebug.js index a471c758..ba524d25 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -1,46 +1,34 @@ -"use strict"; - -const { - LUA_HOOKCOUNT, - LUA_HOOKLINE, - LUA_MASKCOUNT, - LUA_MASKLINE, - constant_types: { - LUA_TBOOLEAN, - LUA_TNIL, - LUA_TTABLE - }, - thread_status: { - 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); +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 +} = defs.constant_types; + +export const { + LUA_ERRRUN, + LUA_YIELD +} = defs.thread_status; + +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; }; @@ -50,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 */ @@ -60,7 +48,7 @@ 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; @@ -73,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 */ @@ -101,26 +89,26 @@ 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 & lstate.CIST_LUA) { @@ -136,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 */ } @@ -146,7 +134,7 @@ 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? */ @@ -159,7 +147,7 @@ const lua_getlocal = function(L, ar, n) { if (local) { name = local.name; lobject.pushobj2s(L, L.stack[local.pos]); - api_check(L, L.top <= L.ci.top, "stack overflow"); + llimits.api_check(L, L.top <= L.ci.top, 'stack overflow'); } else { name = null; } @@ -168,7 +156,7 @@ 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); @@ -183,24 +171,24 @@ const lua_setlocal = function(L, ar, n) { return name; }; -const funcinfo = function(ar, cl) { +export const funcinfo = function (ar, cl) { if (cl === null || cl instanceof lobject.CClosure) { - ar.source = to_luastring("=[JS]", true); + 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 = lobject.luaO_chunkid(ar.source, LUA_IDSIZE); + ar.short_src = lobject.luaO_chunkid(ar.source, luaconf.LUA_IDSIZE); }; -const collectvalidlines = function(L, f) { +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); @@ -215,7 +203,7 @@ const collectvalidlines = function(L, f) { } }; -const getfuncname = function(L, ci) { +export const getfuncname = function (L, ci) { let r = { name: null, funcname: null @@ -223,8 +211,8 @@ const getfuncname = function(L, ci) { 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 */ + 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? */ @@ -233,7 +221,7 @@ const getfuncname = function(L, ci) { 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]) { @@ -263,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 = defs.to_luastring('', true); ar.name = null; } else { ar.namewhat = r.funcname; @@ -281,37 +269,37 @@ 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) { + if (defs.luastring_indexOf(what, 102 /* ('f').charCodeAt(0) */) >= 0) { lobject.pushobj2s(L, func); - api_check(L, L.top <= L.ci.top, "stack overflow"); + 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 @@ -331,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 */ @@ -344,7 +332,7 @@ 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 = lopcodes.OpCodesI; @@ -390,14 +378,14 @@ const findsetreg = function(p, lastpc, reg) { }; -const getobjname = function(p, lastpc, reg) { +export const getobjname = function (p, lastpc, reg) { let r = { 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; } @@ -419,12 +407,12 @@ const getobjname = function(p, lastpc, reg) { let t = i.B; /* table index */ 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, llex.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: @@ -432,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; @@ -440,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; @@ -456,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 = lopcodes.OpCodesI; if (ci.callstatus & lstate.CIST_HOOKED) { - r.name = to_luastring("?", true); - r.funcname = to_luastring("hook", true); + r.name = defs.to_luastring('?', true); + r.funcname = defs.to_luastring('hook', true); return r; } @@ -479,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 = 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: @@ -492,35 +480,35 @@ const funcnamefromcode = function(L, ci) { case OCi.OP_SETTABLE: tm = ltm.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_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_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; @@ -534,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) }; } } @@ -548,7 +536,7 @@ 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 & lstate.CIST_LUA) { @@ -558,49 +546,49 @@ const varinfo = function(L, o) { 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 ? 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) { +export 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)); + 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) { +export const luaG_concaterror = function (L, p1, p2) { if (p1.ttisstring() || lvm.cvt2str(p1)) p1 = p2; - luaG_typeerror(L, p1, to_luastring('concatenate', true)); + 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) { +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) { +export const luaG_ordererror = function (L, p1, p2) { let t1 = ltm.luaT_objtypename(L, p1); let t2 = ltm.luaT_objtypename(L, p2); - if (luastring_eq(t1, t2)) - luaG_runerror(L, to_luastring("attempt to compare two %s values", true), t1); + 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 = lobject.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 lobject.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 = lobject.luaO_pushvfstring(L, fmt, argp); if (ci.callstatus & lstate.CIST_LUA) /* if Lua function, add source:line information */ @@ -608,7 +596,7 @@ const luaG_runerror = function(L, fmt, ...argp) { 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 */ @@ -622,35 +610,35 @@ const luaG_errormsg = function(L) { /* ** Error when both values are convertible to numbers, but not to integers */ -const luaG_tointerror = function(L, p1, p2) { +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 & 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) - ldo.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 */ - ldo.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? */ @@ -663,21 +651,3 @@ const luaG_traceexec = function(L) { ldo.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..26fae159 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -1,53 +1,36 @@ -"use strict"; - -const { - LUA_HOOKCALL, - LUA_HOOKRET, - LUA_HOOKTAILCALL, - LUA_MASKCALL, - LUA_MASKLINE, - LUA_MASKRET, - 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_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) { +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 +} = defs.constant_types; + +export const { + LUA_ERRMEM, + LUA_ERRERR, + LUA_ERRRUN, + LUA_ERRSYNTAX, + LUA_OK, + LUA_YIELD +} = defs.thread_status; + +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); @@ -57,7 +40,7 @@ const adjust_top = function(L, newtop) { } }; -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 */ @@ -66,11 +49,11 @@ const seterrorobj = function(L, errcode, oldtop) { switch (errcode) { case LUA_ERRMEM: { - lobject.setsvalue2s(L, oldtop, luaS_newliteral(L, "not enough memory")); + lobject.setsvalue2s(L, oldtop, lstring.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, lstring.luaS_newliteral(L, 'error in error handling')); break; } default: { @@ -82,61 +65,61 @@ 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 - lstate.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 - 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 + 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); - ldebug.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*lstate.EXTRA_STACK; - if (goodsize > LUAI_MAXSTACK) - goodsize = LUAI_MAXSTACK; /* respect stack limit */ - if (L.stack.length > LUAI_MAXSTACK) /* had been handling stack overflow? */ + 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 - lstate.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 lobject.TValue(LUA_TNIL, null); }; @@ -148,27 +131,27 @@ 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) { + switch (func.type) { case LUA_TCCL: case LUA_TLCF: { let f = func.type === LUA_TCCL ? func.value.f : func.value; - luaD_checkstack(L, LUA_MINSTACK); + 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)"); + 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); @@ -199,7 +182,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) + if (L.hookmask & defs.LUA_MASKCALL) callhook(L, ci); return false; } @@ -210,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 */ } @@ -225,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; @@ -237,10 +220,10 @@ const moveresults = function(L, firstResult, res, nres, wanted) { } break; } - case LUA_MULTRET: { + case defs.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--) + for (let i = L.top; i >= (res + nres); i--) delete L.stack[i]; L.top = res + nres; return false; @@ -254,7 +237,7 @@ const moveresults = function(L, firstResult, res, nres, wanted) { for (i = 0; i < nres; i++) lobject.setobjs2s(L, res + i, firstResult + i); for (; i < wanted; i++) { - if (res+i >= L.top) + if (res + i >= L.top) L.stack[res + i] = new lobject.TValue(LUA_TNIL, null); else L.stack[res + i].setnilvalue(); @@ -264,7 +247,7 @@ const moveresults = function(L, firstResult, res, nres, wanted) { } } let newtop = res + wanted; /* top points after the last result */ - for (let i=L.top; i>=newtop; i--) + for (let i = L.top; i >= newtop; i--) delete L.stack[i]; L.top = newtop; return true; @@ -275,23 +258,23 @@ 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 |= 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); @@ -299,19 +282,19 @@ const luaD_hook = function(L, event, line) { } }; -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 & 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 = LUA_HOOKTAILCALL; + 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 */ @@ -329,14 +312,14 @@ const adjust_varargs = function(L, p, actual) { return base; }; -const tryfuncTM = function(L, off, func) { +export 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)); + ldebug.luaG_typeerror(L, func, defs.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,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) - ldebug.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 */ }; @@ -360,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)) 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; @@ -391,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, @@ -447,13 +430,13 @@ 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 & lstate.CIST_YPCALL || status === LUA_YIELD); + llimits.lua_assert(ci.callstatus & lstate.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 */ @@ -462,7 +445,7 @@ const finishCcall = function(L, status) { /* 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 */ lapi.api_checknelems(L, n); @@ -477,7 +460,7 @@ 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 */ @@ -495,7 +478,7 @@ 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 & lstate.CIST_YPCALL) return ci; @@ -509,7 +492,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) { +export const recover = function (L, status) { let ci = findpcall(L); if (ci === null) return 0; /* no recovery point */ /* "finish" luaD_pcall */ @@ -529,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) { lobject.pushsvalue2s(L, ts); - api_check(L, L.top <= L.ci.top, "stack overflow"); + llimits.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 >= llimits.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'? */ @@ -609,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; 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)); + ldebug.luaG_runerror(L, defs.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)); + 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 & lstate.CIST_LUA) /* inside a hook? */ - api_check(L, k === null, "hooks cannot continue after yielding"); + llimits.api_check(L, k === null, 'hooks cannot continue after yielding'); else { ci.c_k = k; if (k !== null) /* is there a continuation? */ @@ -646,15 +629,15 @@ 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 */ + 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; @@ -680,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--; @@ -689,62 +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.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) { +export const checkmode = function (L, mode, x) { + if (mode && defs.luastring_indexOf(mode, x[0]) === -1) { lobject.luaO_pushfstring(L, - to_luastring("attempt to load a %s chunk (mode is '%s')"), x, mode); + 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)); + 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)); + 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); + 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; }; - -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..d600a78c 100644 --- a/src/ldump.js +++ b/src/ldump.js @@ -1,25 +1,19 @@ -"use strict"; +import * as defs from './defs.js'; const { - LUA_SIGNATURE, - 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'); - -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 */ + LUA_TBOOLEAN, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR +} = defs.constant_types; + +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(defs.LUA_VERSION_MAJOR) * 16 + Number(defs.LUA_VERSION_MINOR); +const LUAC_FORMAT = 0; /* this is the official format */ class DumpState { constructor() { @@ -31,16 +25,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) { - DumpBlock(luastring_of(y), 1, D); +const DumpByte = function (y, D) { + DumpBlock(defs.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); @@ -48,7 +42,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); @@ -56,7 +50,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); @@ -64,7 +58,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 { @@ -80,7 +74,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); @@ -88,7 +82,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++) { @@ -114,14 +108,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++) { @@ -130,7 +124,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++) @@ -148,7 +142,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 @@ -156,7 +150,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); @@ -165,8 +159,8 @@ const DumpFunction = function(f, psource, D) { DumpDebug(f, D); }; -const DumpHeader = function(D) { - DumpBlock(LUA_SIGNATURE, LUA_SIGNATURE.length, D); +const DumpHeader = function (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); @@ -182,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; @@ -194,5 +188,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..7269491c 100644 --- a/src/lfunc.js +++ b/src/lfunc.js @@ -1,9 +1,9 @@ -"use strict"; +import * as defs from './defs.js'; +import * as lobject from './lobject.js'; -const { constant_types: { LUA_TNIL } } = require('./defs.js'); -const lobject = require('./lobject.js'); +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,19 +22,19 @@ class Proto { } } -const luaF_newLclosure = function(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 && (fs.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) { @@ -158,51 +124,51 @@ 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 = { - "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 */ - 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; }; @@ -211,20 +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; }; - -module.exports.luaopen_io = luaopen_io; diff --git a/src/ljstype.js b/src/ljstype.js index eb24ac51..13058480 100644 --- a/src/ljstype.js +++ b/src/ljstype.js @@ -1,8 +1,6 @@ -"use strict"; +import * as defs from './defs.js'; -const { luastring_of } = require('./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, @@ -44,33 +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)); +export 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', + '//', '..', '...', '==', '>=', '<=', '~=', + '<<', '>>', '::', '', + '', '', '', '' +].map((e, _i) => defs.to_luastring(e)); class SemInfo { constructor() { @@ -146,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 */ @@ -164,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; - luaZ_resizebuffer(ls.L, b, newsize); + 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; + 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 lobject.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 lobject.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; } }; -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); }; @@ -206,11 +182,11 @@ const save_and_next = function(ls) { ** (by that time it should be anchored somewhere) */ const TVtrue = new lobject.TValue(LUA_TBOOLEAN, true); -const luaX_newstring = function(ls, str) { +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 lobject.TValue(LUA_TLNGSTR, ts); ltable.luaH_setfrom(L, ls.h, key, TVtrue); @@ -224,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)); + 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() @@ -250,11 +226,11 @@ 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) { +const check_next1 = function (ls, c) { if (ls.current === c) { next(ls); return true; @@ -267,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; @@ -276,18 +252,18 @@ 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)); + llimits.lua_assert(ljstype.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 */ - if (lisxdigit(ls.current)) + check_next2(ls, '-+'); /* optional exponent sign */ + if (ljstype.lisxdigit(ls.current)) save_and_next(ls); else if (ls.current === 46 /* ('.').charCodeAt(0) */) save_and_next(ls); @@ -297,37 +273,37 @@ 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); + 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; } }; -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 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) { +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, 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); }; @@ -336,10 +312,10 @@ 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) */); + 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); @@ -348,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 '[' */ @@ -356,12 +332,12 @@ 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"; + 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) */: { @@ -375,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: { @@ -389,82 +365,82 @@ 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) + if (ls.current !== lzio.EOZ) save_and_next(ls); /* add current to buffer for error message */ lexerror(ls, msg, TK_STRING); } }; -const gethexa = function(ls) { +const gethexa = function (ls) { save_and_next(ls); - esccheck(ls, lisxdigit(ls.current), to_luastring("hexadecimal digit expected", true)); + esccheck(ls, ljstype.lisxdigit(ls.current), defs.to_luastring('hexadecimal digit expected', true)); return lobject.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 */ + lzio.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) */, 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) + lobject.luaO_hexavalue(ls.current); - esccheck(ls, r <= 0x10FFFF, to_luastring("UTF-8 value too large", true)); + 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) { +const utf8esc = function (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[lobject.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 */ + 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; }; -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); + 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 */ 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; @@ -481,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; } @@ -502,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); } @@ -514,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[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); - for (;;) { - lua_assert(typeof ls.current == "number"); /* fengari addition */ +const llex = function (ls, seminfo) { + lzio.luaZ_resetbuffer(ls.buff); + for (; ;) { + llimits.lua_assert(typeof ls.current == 'number'); /* fengari addition */ switch (ls.current) { case 10 /* ('\n').charCodeAt(0) */: case 13 /* ('\r').charCodeAt(0) */: { /* line breaks */ @@ -549,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; } @@ -568,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) */: { @@ -615,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 @@ -647,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 */ @@ -659,21 +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; }; - -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..22564c0a 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; +export const LUAI_MAXCCALLS = 200; /* minimum size for string buffer */ -const LUA_MINBUFFER = 32; -module.exports.LUA_MINBUFFER = 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) + 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; +export const MAX_INT = 2147483647; +export const MIN_INT = -2147483648; diff --git a/src/lmathlib.js b/src/lmathlib.js index 8313e934..b2d69626 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,318 +1,283 @@ -"use strict"; - -const { - 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 -} = require('./lua.js'); -const { - 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"); +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 */ -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); - switch (lua_gettop(L)) { /* check number of arguments */ + let r = (rand_state === void 0) ? Math.random() : (l_rand() / 0x80000000); + 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, - "interval too large"); + 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)); +const math_randomseed = function (L) { + 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 (n < 0) n = (-n)|0; - lua_pushinteger(L, n); +const math_abs = function (L) { + if (lua.lua_isinteger(L, 1)) { + let n = lua.lua_tointeger(L, 1); + if (n < 0) n = (-n) | 0; + 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))); +const math_sin = function (L) { + 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))); +const math_cos = function (L) { + 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))); +const math_tan = function (L) { + 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))); +const math_asin = function (L) { + 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))); +const math_acos = function (L) { + 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)); +const math_atan = function (L) { + 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); +const math_toint = function (L) { + 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); +const pushnumint = function (L, 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); +const math_floor = function (L) { + 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); +const math_ceil = function (L) { + 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))); +const math_sqrt = function (L) { + 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= 0) ? (b < 0 || a < b) : (b < 0 && a < b)); return 1; }; -const math_log = function(L) { - let x = luaL_checknumber(L, 1); +const math_log = function (L) { + 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) res = Math.log10(x); else - res = Math.log(x)/Math.log(base); + 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))); +const math_exp = function (L) { + 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)); +const math_deg = function (L) { + 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)); +const math_rad = function (L) { + 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 */ +const math_min = function (L) { + 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"); - for (let i = 2; i <= n; i++){ - if (lua_compare(L, i, imin, LUA_OPLT)) + lauxlib.luaL_argcheck(L, n >= 1, 1, 'value expected'); + for (let i = 2; i <= n; i++) { + 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 */ +const math_max = function (L) { + 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"); - for (let i = 2; i <= n; i++){ - if (lua_compare(L, imax, i, LUA_OPLT)) + lauxlib.luaL_argcheck(L, n >= 1, 1, 'value expected'); + for (let i = 2; i <= n; i++) { + 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"); +const math_type = function (L) { + 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); +const math_fmod = function (L) { + 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 */ +const math_modf = function (L) { + 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; }; 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_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; }; - -module.exports.luaopen_math = luaopen_math; diff --git a/src/loadlib.js b/src/loadlib.js index 92bf677e..201095ee 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -1,82 +1,24 @@ -"use strict"; - -const { - 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, - 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_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 -} = 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'); - -const global_env = (function() { - if (typeof process !== "undefined") { +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'; + +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') { /* 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 +30,11 @@ const global_env = (function() { } })(); -const JSLIBS = to_luastring("__JSLIBS__"); -const LUA_PATH_VAR = "LUA_PATH"; -const LUA_JSPATH_VAR = "LUA_JSPATH"; +const JSLIBS = fengaricore.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 @@ -100,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 LIB_FAIL = "open"; +const LUA_OFSEP = fengaricore.to_luastring('_'); +const LIB_FAIL = 'open'; -const AUXMARK = to_luastring("\x01"); +const AUXMARK = fengaricore.to_luastring('\x01'); /* @@ -120,49 +62,48 @@ const AUXMARK = to_luastring("\x01"); ** error string in the stack. */ let lsys_load; -if (typeof process === "undefined") { - lsys_load = function(L, path, seeglb) { - path = to_uristring(path); +if (typeof process === 'undefined') { + lsys_load = function (L, path, _seeglb) { + path = fengaricore.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) { - lua_pushstring(L, to_luastring(`${xhr.status}: ${xhr.statusText}`)); + lua.lua_pushstring(L, fengaricore.to_luastring(`${xhr.status}: ${xhr.statusText}`)); return null; } 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}`)); + lua.lua_pushstring(L, fengaricore.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; } 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 { - const pathlib = require('path'); - 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; } }; @@ -173,13 +114,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) { - let f = lib[to_jsstring(sym)]; +const lsys_sym = function (L, lib, 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; } }; @@ -187,18 +128,16 @@ 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 */ +const noenv = function (L) { + 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; }; let readable; -if (typeof process !== "undefined") { // Only with Node - const fs = require('fs'); - - readable = function(filename) { +if (typeof process !== 'undefined') { // Only with Node + readable = function (filename) { try { let fd = fs.openSync(filename, 'r'); fs.closeSync(fd); @@ -208,11 +147,11 @@ if (typeof process !== "undefined") { // Only with Node return true; }; } else { - readable = function(path) { - path = to_uristring(path); - let xhr = new XMLHttpRequest(); + readable = function (path) { + 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.open('GET', path, false); xhr.send(); return xhr.status >= 200 && xhr.status <= 299; @@ -221,7 +160,7 @@ if (typeof process !== "undefined") { // Only with Node /* error codes for 'lookforfunc' */ -const ERRLIB = 1; +const ERRLIB = 1; const ERRFUNC = 2; /* @@ -235,7 +174,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'=='*' */ @@ -243,34 +182,34 @@ 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); +const ll_loadlib = function (L) { + 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 */ } }; -const env = (function() { - if (typeof process !== "undefined") { +const env = (function () { + if (typeof process !== 'undefined') { /* node */ return process.env; } else { @@ -281,37 +220,37 @@ const env = (function() { /* ** Set a path */ -const setpath = function(L, fieldname, envname, dft) { +const setpath = function (L, fieldname, envname, dft) { let nver = `${envname}${lualib.LUA_VERSUFFIX}`; - lua_pushstring(L, to_luastring(nver)); + 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' */ +const checkjslib = function (L, path) { + 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; }; @@ -319,80 +258,80 @@ 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) { - 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 */ +const addtojslib = function (L, path, plib) { + 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 */ +const pushnexttemplate = function (L, path) { + 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); +const searchpath = function (L, name, path, sep, dirsep) { + 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) { +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); +const findfile = function (L, name, pname, dirsep) { + 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) { +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)); +const searcher_Lua = function (L) { + 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); }; /* @@ -403,180 +342,176 @@ 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); - 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)); +const searcher_C = function (L) { + 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)); +const searcher_Croot = function (L) { + 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) + 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); +const searcher_preload = function (L) { + 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); +const findloader = function (L, name, ctx, k) { + 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")); - let ctx2 = {name: name, i: 1, msg: msg, ctx: ctx, k: k}; - return findloader_cont(L, LUA_OK, ctx2); + 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.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)); + 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? */ +const ll_require = function (L) { + 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 */ - let ctx = name; - return findloader(L, name, ctx, ll_require_cont); + lua.lua_pop(L, 1); /* remove 'getfield' result */ + return findloader(L, name, name, 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 */ +const ll_require_cont = function (L, status, ctx) { + 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 */ }; -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 */ - 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; }; 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); + 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' */ }; /* ** create table JSLIBS to keep track of loaded JS libraries, ** 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 */ +const createjslibstable = function (L) { + 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 */ }; - -module.exports.luaopen_package = luaopen_package; diff --git a/src/lobject.js b/src/lobject.js index c83439c7..0b110ba2 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -1,77 +1,39 @@ -"use strict"; - -const { - 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: { - 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 - }, - 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 { +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, + 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 +} = defs.constant_types; + +export const LUA_TPROTO = LUA_NUMTAGS; +export const LUA_TDEADKEY = LUA_NUMTAGS + 1; + +export class TValue { constructor(type, value) { this.type = type; @@ -178,7 +140,7 @@ class TValue { } chgfltvalue(x) { - lua_assert(this.type == LUA_TNUMFLT); + llimits.lua_assert(this.type === LUA_TNUMFLT); this.value = x; } @@ -188,7 +150,7 @@ class TValue { } chgivalue(x) { - lua_assert(this.type == LUA_TNUMINT); + llimits.lua_assert(this.type === LUA_TNUMINT); this.value = x; } @@ -253,7 +215,7 @@ class TValue { } tsvalue() { - lua_assert(this.ttisstring()); + llimits.lua_assert(this.ttisstring()); return this.value; } @@ -266,33 +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); -module.exports.luaO_nilobject = luaO_nilobject; -class LClosure { +export { luaO_nilobject }; + +export class LClosure { constructor(L, n) { this.id = L.l_G.id_counter++; @@ -304,7 +267,7 @@ class LClosure { } -class CClosure { +export class CClosure { constructor(L, f, n) { this.id = L.l_G.id_counter++; @@ -319,7 +282,7 @@ class CClosure { } -class Udata { +export class Udata { constructor(L, size) { this.id = L.l_G.id_counter++; @@ -336,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 */ @@ -344,24 +307,24 @@ 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 */ 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); @@ -371,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 */ @@ -393,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 */ @@ -419,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 */ @@ -433,16 +396,16 @@ 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' */ + 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(); */) { 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? */ @@ -461,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; } @@ -490,31 +453,31 @@ 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 = { - [ 46]: ".", - [120]: "x", - [ 88]: "x", - [110]: "n", - [ 78]: "n" +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= 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; } } - 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 { - n: (neg ? -a : a)|0, + n: (neg ? -a : a) | 0, i: i }; } }; -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); - 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 */ } }; -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) { +export const pushstr = function (L, str) { ldo.luaD_inctop(L); - setsvalue2s(L, L.top-1, luaS_new(L, str)); + 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); - if (e == -1) break; + for (; ;) { + e = defs.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 = 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); } @@ -627,22 +589,22 @@ 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) */: ldo.luaD_inctop(L); - L.stack[L.top-1].setivalue(argp[a++]); - luaO_tostring(L, L.stack[L.top-1]); + 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]); + 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++]; @@ -651,39 +613,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, defs.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, defs.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, defs.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, 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)")); + case 'boolean': /* before check object as null is an object */ + pushstr(L, defs.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, defs.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, 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; @@ -695,21 +657,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: - ldebug.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; } ldo.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) 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); }; @@ -719,7 +681,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 */ @@ -730,49 +692,49 @@ 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) { +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 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_OPBAND: 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_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) { - 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: - 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 = lvm.tointeger(p1)) !== false && (i2 = lvm.tointeger(p2)) !== false) { res.setivalue(intarith(L, op, i1, i2)); @@ -780,7 +742,7 @@ const luaO_arith = function(L, op, p1, p2, p3) { } 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 = lvm.tonumber(p1)) !== false && (n2 = lvm.tonumber(p2)) !== false) { res.setfltvalue(numarith(L, op, n1, n2)); @@ -802,31 +764,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) */ - ltm.luaT_trybinTM(L, p1, p2, p3, (op - LUA_OPADD) + ltm.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); }; - - -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..ce36dbed 100644 --- a/src/lopcodes.js +++ b/src/lopcodes.js @@ -1,61 +1,59 @@ -"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" +export 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' ]; -const OpCodesI = { - OP_MOVE: 0, - OP_LOADK: 1, - OP_LOADKX: 2, +export 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, @@ -63,40 +61,40 @@ 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 }; @@ -108,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 */ @@ -169,241 +167,182 @@ 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<> 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) { - return ((~((~0)<<(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) { - if (typeof ins === "number") { +export const fullins = function (ins) { + if (typeof ins === 'number') { return { - code: ins, + code: ins, opcode: (ins >> 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) { +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; - -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..73d8ec38 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -1,51 +1,17 @@ -"use strict"; - -const { - 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 -} = require('./lua.js'); -const { - luaL_Buffer, - luaL_addchar, - luaL_addstring, - // luaL_argcheck, - 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 -} = require('./lauxlib.js'); -const { - luastring_eq, - to_jsstring, - to_luastring -} = require("./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%"); @@ -69,66 +35,66 @@ const { - %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) { - 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); }; 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') } }; @@ -148,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); @@ -164,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' @@ -209,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' @@ -229,12 +195,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' @@ -244,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; // '' @@ -286,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; } @@ -310,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' @@ -325,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' @@ -359,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 */); @@ -382,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 */ @@ -395,124 +361,120 @@ 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? */ utc = true; i++; /* skip '!' */ } - if (s[i] === "*".charCodeAt(0) && s[i+1] === "t".charCodeAt(0)) { - lua_createtable(L, 0, 9); /* 9 = number of fields */ + if (s[i] === '*'.charCodeAt(0) && s[i+1] === 't'.charCodeAt(0)) { + 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); + cc[0] = '%'.charCodeAt(0); + 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), - 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); } - 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); // luaL_argcheck(L, t, arg, "time out-of-bounds"); - return t; + return lauxlib.luaL_checkinteger(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" */ + || 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); return 1; }; 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); + lua.lua_pushnumber(L, performance.now()/1000); return 1; }; } else { /* Only with Node */ - const fs = require('fs'); - const tmp = require('tmp'); - const child_process = require('child_process'); 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; }; @@ -521,7 +483,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) { @@ -529,38 +491,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, @@ -569,24 +531,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; }; - -module.exports.luaopen_os = luaopen_os; diff --git a/src/lparser.js b/src/lparser.js index 7c67709c..60e761c6 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1,127 +1,73 @@ -"use strict"; +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 { - LUA_MULTRET, - to_luastring -} = require('./defs.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 - }, - 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'); + 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 +} = lcode.BinOpr; + const { - OpCodesI: { - OP_CALL, - OP_CLOSURE, - OP_FORLOOP, - OP_FORPREP, - OP_GETUPVAL, - OP_MOVE, - OP_NEWTABLE, - OP_SETTABLE, - OP_TAILCALL, - OP_TFORCALL, - OP_TFORLOOP, - OP_VARARG - }, - LFIELDS_PER_FLUSH, - SETARG_B, - SETARG_C, - SET_OPCODE -} = require('./lopcodes.js'); + OPR_BNOT, + OPR_LEN, + OPR_MINUS, + OPR_NOT, + OPR_NOUNOPR +} = lcode.UnOpr; + const { - luaS_eqlngstr, - luaS_new, - luaS_newliteral -} = require('./lstring.js'); -const ltable = require('./ltable.js'); -const Proto = lfunc.Proto; -const R = llex.RESERVED; + OP_CALL, + OP_CLOSURE, + OP_FORLOOP, + OP_FORPREP, + OP_GETUPVAL, + OP_MOVE, + OP_NEWTABLE, + OP_SETTABLE, + OP_TAILCALL, + OP_TFORCALL, + OP_TFORLOOP, + OP_VARARG +} = lopcodes.OpCodesI; + +const R = llex.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); + return lstring.luaS_eqlngstr(a, b); }; class BlockCnt { @@ -135,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 */ @@ -160,15 +106,15 @@ 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) { +export const vkisinreg = function (k) { return k === expkind.VNONRELOC || k === expkind.VLOCAL; }; -class expdesc { +export class expdesc { constructor() { this.k = NaN; this.u = { @@ -241,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: [], @@ -253,31 +199,31 @@ 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); }; -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) { + 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) { +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), + ? 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); llex.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); return true; @@ -286,54 +232,54 @@ const testnext = function(ls, c) { 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); }; -const check_condition = function(ls, c, msg) { +const check_condition = function (ls, c, msg) { if (!c) llex.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)"), + 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) { +const str_checkname = function (ls) { check(ls, R.TK_NAME); let ts = ls.t.seminfo.ts; llex.luaX_next(ls); return ts; }; -const init_exp = function(e, k, i) { - e.f = e.t = NO_JUMP; +const init_exp = function (e, k, i) { + 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)); +const codestring = function (ls, e, s) { + init_exp(e, expkind.VK, lcode.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(); @@ -341,40 +287,40 @@ const registerlocalvar = function(ls, 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, 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, llex.luaX_newstring(ls, to_luastring(name, true))); +const new_localvarliteral = function (ls, name) { + new_localvar(ls, llex.luaX_newstring(ls, defs.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); + llimits.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)) @@ -383,9 +329,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, lfunc.MAXUPVAL, defs.to_luastring('upvalues', true)); f.upvalues[fs.nups] = { instack: v.k === expkind.VLOCAL, idx: v.u.info, @@ -394,7 +340,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; @@ -407,7 +353,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; @@ -418,7 +364,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 { @@ -441,62 +387,62 @@ 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); 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] */ } }; -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)) { 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) 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, llimits.LUAI_MAXCCALLS, defs.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)); + llimits.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'"), + 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]; @@ -506,7 +452,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]; @@ -515,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; } @@ -523,7 +469,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; @@ -538,7 +484,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) { @@ -555,7 +501,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 @@ -564,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)) @@ -572,7 +518,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; @@ -580,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"); +const breaklabel = function (ls) { + 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]); }; @@ -596,20 +542,20 @@ 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) { +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); + ? '<%s> at line %d not inside a loop' + : 'no visible label \'%s\' for at line %d'; + msg = lobject.luaO_pushfstring(ls.L, defs.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 clp = new lfunc.Proto(L); let fs = ls.fs; let f = fs.f; /* prototype of current function */ f.p[fs.np++] = clp; @@ -619,19 +565,19 @@ 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)); - 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) { +const open_func = function (ls, fs, bl) { fs.prev = ls.fs; /* linked list of funcstates */ fs.ls = ls; 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; @@ -646,14 +592,14 @@ 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_patchtohere(fs, j); + let j = lcode.luaK_jump(fs); + lcode.luaK_patchclose(fs, j, bl.nactvar); + lcode.luaK_patchtohere(fs, j); } if (bl.isloop) @@ -661,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? */ @@ -670,11 +616,11 @@ 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 */ + 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; }; @@ -682,7 +628,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: @@ -692,7 +638,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) { @@ -703,21 +649,21 @@ 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); + 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) { +const yindex = function (ls, v) { /* index -> '[' expr ']' */ 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) */); }; @@ -737,7 +683,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; @@ -745,50 +691,50 @@ 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) { +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 */ } }; -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); - 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) { +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++; }; -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' */ @@ -809,34 +755,34 @@ 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; 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], lobject.luaO_int2fb(cc.na)); /* set initial array size */ - SETARG_C(fs.f.code[pc], lobject.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 */ }; /* }====================================================================== */ -const parlist = function(ls) { +const parlist = function (ls) { /* parlist -> [ param { ',' param } ] */ let fs = ls.fs; let f = fs.f; @@ -855,16 +801,16 @@ 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, defs.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 */ + lcode.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(); @@ -873,7 +819,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); @@ -885,19 +831,19 @@ 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); while (testnext(ls, 44 /* (',').charCodeAt(0) */)) { - luaK_exp2nextreg(ls.fs, v); + lcode.luaK_exp2nextreg(ls.fs, v); expr(ls, v); n++; } 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) { @@ -907,7 +853,7 @@ const funcargs = function(ls, f, line) { 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; @@ -922,21 +868,21 @@ const funcargs = function(ls, f, line) { break; } default: { - llex.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 */ - nparams = fs.freereg - (base+1); + 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 */ }; @@ -946,7 +892,7 @@ 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) */: { @@ -954,7 +900,7 @@ const primaryexp = function(ls, v) { 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: { @@ -962,18 +908,18 @@ const primaryexp = function(ls, v) { return; } default: { - llex.luaX_syntaxerror(ls, to_luastring("unexpected symbol", true)); + llex.luaX_syntaxerror(ls, defs.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); @@ -981,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(); 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; } @@ -1004,7 +950,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) { @@ -1036,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 */ @@ -1057,7 +1003,7 @@ const simpleexp = function(ls, v) { llex.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; @@ -1067,7 +1013,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; @@ -1075,36 +1021,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; @@ -1113,14 +1059,14 @@ 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); 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' */ @@ -1129,17 +1075,17 @@ const subexpr = function(ls, v, limit) { let v2 = new expdesc(); let line = ls.linenumber; llex.luaX_next(ls); - luaK_infix(ls.fs, op, v); + 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); return op; /* return first untreated operator */ }; -const expr = function(ls, v) { +const expr = function (ls, v) { subexpr(ls, v, 0); }; @@ -1153,7 +1099,7 @@ const expr = function(ls, v) { ** ======================================================================= */ -const block = function(ls) { +const block = function (ls) { /* block -> statlist */ let fs = ls.fs; let bl = new BlockCnt(); @@ -1179,7 +1125,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; @@ -1201,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) { +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) */); @@ -1223,43 +1169,43 @@ 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); + init_exp(e, expkind.VNONRELOC, ls.fs.freereg - 1); /* default assignment */ + lcode.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 */ 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; }; -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"); + 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 */ }; /* 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), + defs.to_luastring('label \'%s\' already defined on line %d', true), label.getstr(), ll.arr[i].line); semerror(fs.ls, msg); } @@ -1267,12 +1213,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; @@ -1280,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 */ @@ -1289,26 +1235,26 @@ 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 */ - let whileinit = luaK_getlabel(fs); + 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) { +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 */ @@ -1318,53 +1264,52 @@ const repeatstat = function(ls, line) { 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) { +const exp1 = function (ls) { let e = new expdesc(); expr(ls, e); - luaK_exp2nextreg(ls.fs, e); - lua_assert(e.k === expkind.VNONRELOC); - let reg = e.u.info; - return reg; + lcode.luaK_exp2nextreg(ls.fs, e); + llimits.lua_assert(e.k === expkind.VNONRELOC); + return e.u.info; }; -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; 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) { +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 */ @@ -1373,22 +1318,22 @@ 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); }; -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) */)) { @@ -1398,11 +1343,11 @@ 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); }; -const forstat = function(ls, line) { +const forstat = function (ls, line) { /* forstat -> FOR (fornum | forlist) END */ let fs = ls.fs; let bl = new BlockCnt(); @@ -1412,13 +1357,13 @@ 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, 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) */ }; -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; @@ -1430,7 +1375,7 @@ const test_then_block = function(ls, escapelist) { 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 */ @@ -1438,9 +1383,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; } @@ -1448,26 +1393,26 @@ 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; }; -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 */ + 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) { +const localfunc = function (ls) { let b = new expdesc(); let fs = ls.fs; new_localvar(ls, str_checkname(ls)); /* new local variable */ @@ -1477,7 +1422,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; @@ -1496,7 +1441,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); @@ -1509,18 +1454,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 */ 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) { +const exprstat = function (ls) { /* stat -> func | assignment */ let fs = ls.fs; let v = new LHS_assign(); @@ -1530,12 +1475,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)); - 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 */ } }; -const retstat = function(ls) { +const retstat = function (ls) { /* stat -> RETURN [explist] [';'] */ let fs = ls.fs; let e = new expdesc(); @@ -1545,31 +1490,31 @@ 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 */ }; -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 ';' */ break; @@ -1620,7 +1565,7 @@ const statement = function(ls) { } 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 */ @@ -1628,7 +1573,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); }; @@ -1637,7 +1582,7 @@ 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); @@ -1650,32 +1595,25 @@ const mainfunc = function(ls, fs) { close_func(ls); }; -const luaY_parser = function(L, z, buff, dyd, name, firstchar) { +export const luaY_parser = function (L, z, buff, dyd, name, firstchar) { let lexstate = new llex.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); + 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); - funcstate.f = cl.p = new Proto(L); - funcstate.f.source = luaS_new(L, name); + L.stack[L.top - 1].sethvalue(lexstate.h); + 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; 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 */ }; - - -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..96de669f 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -1,30 +1,26 @@ -"use strict"; - -const { - LUA_MINSTACK, - 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'); +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 +} = defs.constant_types; + +export const { + LUA_OK +} = 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; @@ -48,7 +44,7 @@ class CallInfo { } -class lua_State { +export class lua_State { constructor(g) { this.id = g.id_counter++; @@ -76,7 +72,7 @@ class lua_State { } -class global_State { +export class global_State { constructor() { this.id_counter = 1; /* used to give objects unique ids */ @@ -93,7 +89,7 @@ class global_State { } -const luaE_extendCI = function(L) { +export const luaE_extendCI = function (L) { let ci = new CallInfo(); L.ci.next = ci; ci.previous = L.ci; @@ -102,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; @@ -118,11 +114,11 @@ const stack_init = function(L1, L) { ci.funcOff = L1.top; ci.func = L1.stack[L1.top]; L1.stack[L1.top++] = new lobject.TValue(LUA_TNIL, null); - ci.top = L1.top + LUA_MINSTACK; + 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; @@ -131,18 +127,18 @@ const freestack = function(L) { /* ** Create registry table and its predefined values */ -const init_registry = function(L, g) { +export 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)); - ltable.luaH_setint(registry, LUA_RIDX_GLOBALS, new lobject.TValue(LUA_TTABLE, ltable.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); @@ -150,7 +146,7 @@ const f_luaopen = function(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 lobject.TValue(LUA_TTHREAD, L1); @@ -163,11 +159,11 @@ 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; @@ -179,30 +175,21 @@ const lua_newstate = function() { 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); }; -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; +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 */ diff --git a/src/lstring.js b/src/lstring.js index 4769866c..55c1d275 100644 --- a/src/lstring.js +++ b/src/lstring.js @@ -1,14 +1,7 @@ -"use strict"; +import * as defs from './defs.js'; +import * as llimits from './llimits.js'; -const { - is_luastring, - luastring_eq, - luastring_from, - to_luastring -} = require('./defs.js'); -const { lua_assert } = require("./llimits.js"); - -class TString { +export class TString { constructor(L, str) { this.hash = null; @@ -25,51 +18,43 @@ 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 -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) { - let s = luaL_checkstring(L, 1); +const str_sub = function (L) { + 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); +const str_len = function (L) { + 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); +const str_char = function (L) { + 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 - p[i-1] = c; + 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); +const writer = function (L, b, size, B) { + 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); +const str_dump = function (L) { + 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) { +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); + zero = '-' + zero; + return fengaricore.to_luastring(zero); } else { - let buff = ""; - let fe = frexp(x); /* 'x' fraction and exponent */ + let buff = ''; + let fe = luaconf.frexp(x); /* 'x' fraction and exponent */ let m = fe[0]; let e = fe[1]; if (m < 0) { /* is number negative? */ 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) { - luaL_addchar(b, 34 /* '"'.charCodeAt(0) */); +const addquoted = function (b, s, len) { + 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)); + let buff = '' + s[i]; /* stringify */ + if (isdigit(s[i + 1])) + buff = ('000' + buff).slice(-3); /* pad to 3 digits with leading '0's */ + 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); +const checkdp = function (buff) { + 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); +const addliteral = function (L, b, 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) { +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) */) { @@ -311,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)")); + 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]; + 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]; @@ -331,46 +256,46 @@ const addlenmod = function(form, lenmod) { // form[l + lm] = 0; }; -const str_format = function(L) { - let top = lua_gettop(L); +const str_format = function (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': { @@ -378,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; }; @@ -434,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; } }; @@ -462,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); + lauxlib.luaL_error(h.L, fengaricore.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'")); + lauxlib.luaL_error(h.L, fengaricore.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: lauxlib.luaL_error(h.L, fengaricore.to_luastring('invalid format option \'%c\''), r.opt); } r.opt = Knop; return r; @@ -523,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, @@ -536,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? */ @@ -550,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? */ + 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; @@ -563,8 +488,8 @@ 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) { - let buff = luaL_prepbuffsize(b, size); +const packint = function (b, n, islittle, size, neg) { + 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; @@ -574,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(); +const str_pack = function (L) { + 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; @@ -595,124 +520,124 @@ 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"); - packint(b, n>>>0, h.islittle, size, false); + 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"); + 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); +const str_reverse = function (L) { + let s = lauxlib.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 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); @@ -723,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); +const str_byte = function (L) { + 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) { +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 */ @@ -760,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"); - /* call never return, but to avoid warnings: *//* fall through */ - default: break; + 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; }; @@ -782,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--) { @@ -798,72 +723,72 @@ 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) { +const unpacknum = function (L, b, islittle, size) { lualib.lua_assert(b.length >= size); let dv = new DataView(new ArrayBuffer(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); }; -const str_unpack = function(L) { +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; } @@ -873,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 CAP_POSITION = -2; +const MAXCCALLS = 200; +const SPECIALS = fengaricore.to_luastring('^$*+?.([%-'); class MatchState { constructor(L) { @@ -896,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 lauxlib.luaL_error(ms.L, fengaricore.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 lauxlib.luaL_error(ms.L, fengaricore.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 '%%')")); + 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) */); @@ -933,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 */ @@ -961,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; @@ -981,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 { @@ -995,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'")); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('malformed pattern (missing arguments to \'%%b\'')); if (ms.src[s] !== ms.p[p]) return null; else { @@ -1014,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++; @@ -1027,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; @@ -1038,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) 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; @@ -1051,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; @@ -1061,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 fengaricore.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")); + lauxlib.luaL_error(ms.L, fengaricore.to_luastring('pattern too complex')); while (gotoinit || gotodefault) { gotoinit = false; @@ -1116,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")); + 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)) { + 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 */ @@ -1162,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; @@ -1182,39 +1107,39 @@ 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 */ + 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) { +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 */ }; -const nospecials = function(p, l) { - for (let i=0; i>> 0, - sl = subarr.length; +const find_subarray = function (arr, subarr, from_index) { + let i = from_index >>> 0; + const sl = subarr.length; if (sl === 0) 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; } return -1; }; -const str_find_aux = function(L, find) { - let s = luaL_checkstring(L, 1); - let p = luaL_checkstring(L, 2); +const str_find_aux = function (L, find) { + 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 { @@ -1277,23 +1202,23 @@ 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; }; -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); }; @@ -1307,8 +1232,8 @@ class GMatchState { } } -const gmatch_aux = function(L) { - let gm = lua_touserdata(L, lua_upvalueindex(3)); +const gmatch_aux = function (L) { + 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); @@ -1321,59 +1246,59 @@ const gmatch_aux = function(L) { return 0; /* not found */ }; -const str_gmatch = function(L) { - let s = luaL_checkstring(L, 1); - let p = luaL_checkstring(L, 2); +const str_gmatch = function (L) { + 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) { +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 */ } } } }; -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: { - 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 */ @@ -1381,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 */ +const str_gsub = function (L) { + 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, - "string/function/table expected"); - luaL_buffinit(L, b); + 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'); + lauxlib.luaL_buffinit(L, b); if (anchor) { p = p.subarray(1); lp--; /* skip anchor character */ } @@ -1417,51 +1342,49 @@ 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; }; 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_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 */ +const createmetatable = function (L) { + 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; }; - -module.exports.luaopen_string = luaopen_string; diff --git a/src/ltable.js b/src/ltable.js index fdc34bf2..1f5d39ce 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -1,38 +1,30 @@ -"use strict"; +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 { - 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 - }, - 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'); +export const { + 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 +} = 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 @@ -43,14 +35,14 @@ const get_lightuserdata_hash = function(v) { return hash; }; -const table_hash = function(L, key) { - switch(key.type) { +export 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, defs.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 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: case LUA_TTABLE: @@ -62,26 +54,26 @@ 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) { - 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) || v instanceof Table || @@ -91,17 +83,17 @@ const table_hash = function(L, key) { /* 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); } }; -class Table { +export class Table { constructor(L) { this.id = L.l_G.id_counter++; this.strong = new Map(); @@ -114,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, @@ -134,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(); @@ -147,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(); @@ -162,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 : 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 lobject.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 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) { + 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); @@ -206,8 +198,8 @@ const luaH_setint = function(t, key, value) { } }; -const luaH_setfrom = function(L, t, key, value) { - lua_assert(key instanceof lobject.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); @@ -220,7 +212,7 @@ 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); } else { @@ -235,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++; @@ -251,14 +243,14 @@ 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; }; -const luaH_next = function(L, table, keyI) { +export const luaH_next = function (L, table, keyI) { let keyO = L.stack[keyI]; let entry; @@ -280,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 ldebug.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; @@ -290,17 +282,6 @@ const luaH_next = function(L, table, keyI) { } } lobject.setobj2s(L, keyI, entry.key); - lobject.setobj2s(L, keyI+1, entry.value); + 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..27fa1812 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -1,54 +1,8 @@ -"use strict"; - -const { LUA_MAXINTEGER } = require('./luaconf.js'); -const { - 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 -} = require('./lua.js'); -const { - 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 -} = require('./lauxlib.js'); -const lualib = require('./lualib.js'); -const { to_luastring } = require("./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 @@ -60,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; }; /* @@ -69,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; }; @@ -143,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; }; @@ -225,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; } }; @@ -249,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)) { - 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] */ + while (lua.lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { + 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] */ } /* 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; @@ -284,36 +238,36 @@ const choosePivot = function(lo, up, rnd) { 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 */ - if (up - lo == 1) /* only 2 elements? */ + lua.lua_pop(L, 2); /* remove both values */ + 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? */ 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? */ + 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; @@ -335,28 +289,26 @@ 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; }; 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); +export const luaopen_table = function(L) { + lauxlib.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..bfaa84fb 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -1,39 +1,33 @@ -"use strict"; +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 { - 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'); + LUA_TTABLE, + LUA_TUSERDATA +} = defs.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 */ -].map(e => to_luastring(e)); - -const ttypename = function(t) { + 'no value', + 'nil', + 'boolean', + 'userdata', + 'number', + 'string', + 'table', + 'function', + 'userdata', + 'thread', + 'proto' /* this last case is used for tests only */ +].map(e => defs.to_luastring(e)); + +export const ttypename = function (t) { return luaT_typenames_[t + 1]; }; @@ -42,78 +36,78 @@ const ttypename = function(t) { * WARNING: if you change the order of this enumeration, * grep "ORDER TM" and "ORDER OP" */ -const TMS = { - TM_INDEX: 0, +export const TMS = { + 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)); +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 = ltable.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; lobject.pushobj2s(L, f); /* push function (assume EXTRA_STACK) */ @@ -129,13 +123,13 @@ const luaT_callTM = function(L, f, p1, p2, p3, hasres) { ldo.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) { +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); @@ -144,7 +138,7 @@ 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: @@ -156,15 +150,15 @@ 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, defs.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, defs.to_luastring('perform arithmetic on', true)); } } }; -const luaT_callorderTM = function(L, p1, p2, event) { +export const luaT_callorderTM = function (L, p1, p2, event) { let res = new lobject.TValue(); if (!luaT_callbinTM(L, p1, p2, res, event)) return null; @@ -172,24 +166,24 @@ const luaT_callorderTM = function(L, p1, p2, event) { 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) { +export const luaT_gettm = function (events, event, ename) { const tm = ltable.luaH_getstr(events, ename); - lua_assert(event <= TMS.TM_EQ); + llimits.lua_assert(event <= TMS.TM_EQ); if (tm.ttisnil()) { /* no tag method? */ - events.flags |= 1< { + if (typeof process === 'undefined') return 'web'; + if (process.platform === 'win32') return 'win32'; + return 'posix'; +}; -const { - LUA_VERSION_MAJOR, - LUA_VERSION_MINOR, - to_luastring -} = require('./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. @@ -15,14 +15,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; +export const LUA_PATH_SEP = ';'; -const LUA_PATH_MARK = "?"; -module.exports.LUA_PATH_MARK = LUA_PATH_MARK; +export const LUA_PATH_MARK = '?'; -const LUA_EXEC_DIR = "!"; -module.exports.LUA_EXEC_DIR = LUA_EXEC_DIR; +export const LUA_EXEC_DIR = '!'; /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @@ -33,91 +30,75 @@ module.exports.LUA_EXEC_DIR = 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; -module.exports.LUA_VDIR = 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; -if (typeof process === "undefined") { - const LUA_DIRSEP = "/"; - module.exports.LUA_DIRSEP = LUA_DIRSEP; +if (typeof process === 'undefined') { + 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_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + + 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;./?/init.lua' ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - const LUA_JSPATH_DEFAULT = to_luastring( - LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;./?.js" + LUA_JSPATH_DEFAULT = defs.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_LDIR + "?.lua;" + LUA_LDIR + "?\\init.lua;" + - LUA_JSDIR + "?.lua;" + LUA_JSDIR + "?\\init.lua;" + - LUA_SHRDIR + "?.lua;" + LUA_SHRDIR + "?\\init.lua;" + - ".\\?.lua;.\\?\\init.lua" + 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' ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - const LUA_JSPATH_DEFAULT = to_luastring( - LUA_JSDIR + "?.js;" + - LUA_JSDIR + "..\\share\\lua\\" + LUA_VDIR + "\\?.js;" + - LUA_JSDIR + "loadall.js;.\\?.js" + LUA_JSPATH_DEFAULT = defs.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_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; + LUA_LDIR = LUA_ROOT + 'share/lua/' + LUA_VDIR + '/'; + const LUA_LDIR2 = LUA_ROOT2 + 'share/lua/' + LUA_VDIR + '/'; - const LUA_JSDIR = LUA_LDIR; - module.exports.LUA_JSDIR = LUA_JSDIR; + LUA_JSDIR = LUA_LDIR; const LUA_JSDIR2 = LUA_LDIR2; - const LUA_PATH_DEFAULT = to_luastring( - LUA_LDIR + "?.lua;" + LUA_LDIR + "?/init.lua;" + - LUA_LDIR2 + "?.lua;" + LUA_LDIR2 + "?/init.lua;" + + 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;./?/init.lua' ); - module.exports.LUA_PATH_DEFAULT = LUA_PATH_DEFAULT; - const LUA_JSPATH_DEFAULT = to_luastring( - LUA_JSDIR + "?.js;" + LUA_JSDIR + "loadall.js;" + - LUA_JSDIR2 + "?.js;" + LUA_JSDIR2 + "loadall.js;" + - "./?.js" + LUA_JSPATH_DEFAULT = defs.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; } /* @@ -126,45 +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; - -const LUA_MAXINTEGER = 2147483647; -const LUA_MININTEGER = -2147483648; +export const LUA_COMPAT_FLOATSTRING = conf.LUA_COMPAT_FLOATSTRING || false; -/* -@@ 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; +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. @@ -175,44 +148,27 @@ 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)); + 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]; }; -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++) +export const ldexp = function (mantissa, exponent) { + 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; }; - -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; diff --git a/src/lualib.js b/src/lualib.js index fa302684..7719fadd 100644 --- a/src/lualib.js +++ b/src/lualib.js @@ -1,62 +1,43 @@ -"use strict"; +export { luaL_openlibs } from './linit.js'; +import {luaopen_io} from './liolib.js'; +import {LUA_VERSION_MAJOR, LUA_VERSION_MINOR} from './lua.js'; -const { - LUA_VERSION_MAJOR, - LUA_VERSION_MINOR -} = require("./lua.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'; -const LUA_VERSUFFIX = "_" + LUA_VERSION_MAJOR + "_" + LUA_VERSION_MINOR; -module.exports.LUA_VERSUFFIX = LUA_VERSUFFIX; +export const LUA_VERSUFFIX = '_' + LUA_VERSION_MAJOR + '_' + LUA_VERSION_MINOR; -module.exports.lua_assert = function(c) {}; +export function lua_assert(_c) { } -module.exports.luaopen_base = require("./lbaselib.js").luaopen_base; +export { luaopen_base } from './lbaselib.js'; -const LUA_COLIBNAME = "coroutine"; -module.exports.LUA_COLIBNAME = LUA_COLIBNAME; -module.exports.luaopen_coroutine = require("./lcorolib.js").luaopen_coroutine; +export const LUA_COLIBNAME = 'coroutine'; -const LUA_TABLIBNAME = "table"; -module.exports.LUA_TABLIBNAME = LUA_TABLIBNAME; -module.exports.luaopen_table = require("./ltablib.js").luaopen_table; +export const LUA_TABLIBNAME = '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"; -module.exports.LUA_OSLIBNAME = LUA_OSLIBNAME; -module.exports.luaopen_os = require("./loslib.js").luaopen_os; +export const LUA_OSLIBNAME = 'os'; -const LUA_STRLIBNAME = "string"; -module.exports.LUA_STRLIBNAME = LUA_STRLIBNAME; -module.exports.luaopen_string = require("./lstrlib.js").luaopen_string; +export const LUA_STRLIBNAME = 'string'; -const LUA_UTF8LIBNAME = "utf8"; -module.exports.LUA_UTF8LIBNAME = LUA_UTF8LIBNAME; -module.exports.luaopen_utf8 = require("./lutf8lib.js").luaopen_utf8; +export const LUA_UTF8LIBNAME = 'utf8'; -const LUA_BITLIBNAME = "bit32"; -module.exports.LUA_BITLIBNAME = LUA_BITLIBNAME; +export 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; +export const LUA_MATHLIBNAME = 'math'; -const LUA_DBLIBNAME = "debug"; -module.exports.LUA_DBLIBNAME = LUA_DBLIBNAME; -module.exports.luaopen_debug = require("./ldblib.js").luaopen_debug; +export const LUA_DBLIBNAME = 'debug'; -const LUA_LOADLIBNAME = "package"; -module.exports.LUA_LOADLIBNAME = LUA_LOADLIBNAME; -module.exports.luaopen_package = require("./loadlib.js").luaopen_package; +export const LUA_LOADLIBNAME = '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; +export const LUA_FENGARILIBNAME = 'fengari'; diff --git a/src/lundump.js b/src/lundump.js index 807d8be4..bbdd3b36 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -1,44 +1,22 @@ -"use strict"; +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_SIGNATURE, - constant_types: { - LUA_TBOOLEAN, - LUA_TLNGSTR, - LUA_TNIL, - LUA_TNUMFLT, - LUA_TNUMINT, - LUA_TSHRSTR - }, - thread_status: { LUA_ERRSYNTAX }, - 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 { - 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 -} = require('./lopcodes.js'); -const { lua_assert } = require("./llimits.js"); -const { luaS_bless } = require('./lstring.js'); -const { - luaZ_read, - ZIO -} = require('./lzio.js'); + LUA_TBOOLEAN, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR +} = defs.constant_types; + +const { LUA_ERRSYNTAX } = defs.thread_status; let LUAC_DATA = [0x19, 0x93, 13, 10, 0x1a, 10]; @@ -51,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; @@ -74,32 +52,32 @@ class BytecodeParser { read(size) { let u8 = new Uint8Array(size); - if(luaZ_read(this.Z, u8, 0, size) !== 0) - this.error("truncated"); + 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) - this.error("truncated"); + 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) - this.error("truncated"); + 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) - this.error("truncated"); + 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) - this.error("truncated"); + if (lzio.luaZ_read(this.Z, this.u8, 0, this.integerSize) !== 0) + this.error('truncated'); return this.dv.getInt32(0, true); } @@ -113,12 +91,12 @@ 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' */ static MASK1(n, p) { - return ((~((~0)<<(n)))<<(p)); + return ((~((~0) << (n))) << (p)); } LoadCode(f) { @@ -126,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) - this.error("truncated"); + 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 + code: ins, + 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 }; } } @@ -185,9 +163,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 +180,7 @@ class BytecodeParser { f.locvars[i] = { varname: this.LoadString(), startpc: this.LoadInt(), - endpc: this.LoadInt() + endpc: this.LoadInt() }; } @@ -230,43 +208,43 @@ 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"); + 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, defs.to_luastring('%s: %s precompiled chunk'), this.name, defs.to_luastring(why)); ldo.luaD_throw(this.L, LUA_ERRSYNTAX); } @@ -276,17 +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 = 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); + llimits.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..7713c4a8 100644 --- a/src/lutf8lib.js +++ b/src/lutf8lib.js @@ -1,33 +1,6 @@ -"use strict"; - -const { - lua_gettop, - lua_pushcfunction, - lua_pushfstring, - lua_pushinteger, - lua_pushnil, - lua_pushstring, - lua_pushvalue, - lua_setfield, - lua_tointeger -} = require('./lua.js'); -const { - luaL_Buffer, - luaL_addvalue, - luaL_argcheck, - 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"); +import * as lua from './lua.js'; +import * as lauxlib from './lauxlib.js'; +import * as fengaricore from './fengaricore.js'; const MAXUNICODE = 0x10FFFF; @@ -80,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; }; @@ -133,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 */ @@ -166,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; }; @@ -178,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++; } @@ -203,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 */ @@ -219,37 +192,35 @@ 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; }; 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 */ -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; }; - -module.exports.luaopen_utf8 = luaopen_utf8; diff --git a/src/lvm.js b/src/lvm.js index 423d2a73..57b60ee9 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -1,104 +1,84 @@ -"use strict"; - -const { - LUA_MASKLINE, - LUA_MASKCOUNT, - 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 - }, - to_luastring -} = require('./defs.js'); -const { - 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'); -const { - lua_assert, - luai_nummod -} = require('./llimits.js'); -const lobject = require('./lobject.js'); -const lfunc = require('./lfunc.js'); -const lstate = require('./lstate.js'); -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'); +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, + LUA_TLNGSTR, + LUA_TNIL, + LUA_TNUMBER, + LUA_TNUMFLT, + LUA_TNUMINT, + LUA_TSHRSTR, + LUA_TTABLE, + LUA_TUSERDATA +} = defs.constant_types; + +export const { + 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 +} = 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 */ @@ -110,7 +90,7 @@ 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: { - lobject.setobjs2s(L, base + inst.A, L.top-1); + lobject.setobjs2s(L, base + inst.A, L.top - 1); delete L.stack[--L.top]; break; } @@ -118,12 +98,12 @@ const luaV_finishOp = function(L) { let res = !L.stack[L.top - 1].l_isfalse(); delete L.stack[--L.top]; if (ci.callstatus & lstate.CIST_LEQ) { /* "<=" using "<" instead? */ - lua_assert(op === OP_LE); + 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); - if (res !== (inst.A ? true : false)) /* condition failed? */ + llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_JMP); + if (res !== (!!inst.A)) /* condition failed? */ ci.l_savedpc++; /* skip jump instruction */ break; } @@ -142,7 +122,7 @@ const luaV_finishOp = function(L) { break; } case OP_TFORCALL: { - lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_TFORLOOP); + llimits.lua_assert(ci.l_code[ci.l_savedpc].opcode === OP_TFORLOOP); ldo.adjust_top(L, ci.top); /* correct top */ break; } @@ -154,11 +134,11 @@ const luaV_finishOp = function(L) { } }; -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; }; @@ -166,28 +146,27 @@ 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 |= lstate.CIST_FRESH; - newframe: - for (;;) { - lua_assert(ci === L.ci); + for (; ;) { + 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)) { + if (L.hookmask & (defs.LUA_MASKLINE | defs.LUA_MASKCOUNT)) { ldebug.luaG_traceexec(L); } @@ -205,7 +184,7 @@ const luaV_execute = function(L) { 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]; lobject.setobj2s(L, ra, konst); break; @@ -277,7 +256,7 @@ const luaV_execute = function(L) { let numberop1, numberop2; if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue((op1.value + op2.value)|0); + 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 { @@ -291,7 +270,7 @@ const luaV_execute = function(L) { let numberop1, numberop2; if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra].setivalue((op1.value - op2.value)|0); + 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 { @@ -321,7 +300,7 @@ 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 { ltm.luaT_trybinTM(L, op1, op2, L.stack[ra], ltm.TMS.TM_MOD); } @@ -430,7 +409,7 @@ const luaV_execute = function(L) { let numberop; if (op.ttisinteger()) { - L.stack[ra].setivalue((-op.value)|0); + L.stack[ra].setivalue((-op.value) | 0); } else if ((numberop = tonumber(op)) !== false) { L.stack[ra].setfltvalue(-numberop); } else { @@ -513,21 +492,21 @@ const luaV_execute = function(L) { 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 (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; + continue; } 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 + 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; @@ -548,9 +527,9 @@ const luaV_execute = function(L) { 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; + continue; } break; } @@ -563,14 +542,14 @@ const luaV_execute = function(L) { /* 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; + llimits.lua_assert(ci.callstatus & lstate.CIST_LUA); + llimits.lua_assert(ci.l_code[ci.l_savedpc - 1].opcode === OP_CALL); + break; } 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 idx = (L.stack[ra].value + step) | 0; let limit = L.stack[ra + 1].value; if (0 < step ? idx <= limit : limit <= idx) { @@ -601,17 +580,17 @@ const luaV_execute = function(L) { /* all values are integer */ let initv = forlim.stopnow ? 0 : init.value; plimit.value = forlim.ilimit; - init.value = (initv - pstep.value)|0; + 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)); + 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) - ldebug.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) - ldebug.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); } @@ -620,16 +599,16 @@ const luaV_execute = function(L) { } 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 + 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.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: { @@ -646,12 +625,12 @@ 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--) { ltable.luaH_setint(h, last--, L.stack[ra + n]); @@ -690,24 +669,24 @@ const luaV_execute = function(L) { break; } case OP_EXTRAARG: { - throw Error("invalid opcode"); + throw Error('invalid opcode'); } } } }; -const dojump = function(L, ci, i, e) { +export 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) { +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()) @@ -720,7 +699,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 +720,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,11 +733,11 @@ 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: - 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: @@ -766,7 +745,7 @@ 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: @@ -789,11 +768,11 @@ const luaV_equalobj = function(L, t1, t2) { 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) { @@ -802,10 +781,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; } } @@ -822,7 +801,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); @@ -834,7 +813,7 @@ 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)) { @@ -846,11 +825,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 +847,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; }; @@ -883,9 +862,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; @@ -898,9 +877,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 +894,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, defs.to_luastring('get length of', true)); break; } } @@ -924,7 +903,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) { +export const luaV_imul = Math.imul || function (a, b) { let aHi = (a >>> 16) & 0xffff; let aLo = a & 0xffff; let bHi = (b >>> 16) & 0xffff; @@ -936,22 +915,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) - ldebug.luaG_runerror(L, to_luastring("attempt to divide by zero")); - return Math.floor(m / n)|0; + 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) - ldebug.luaG_runerror(L, to_luastring("attempt to perform 'n%%0'")); - return (m - Math.floor(m / n) * 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; @@ -967,7 +946,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; @@ -985,7 +964,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) { +export 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 +979,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) { +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; @@ -1021,15 +1000,15 @@ const tostring = function(L, i) { 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]; + 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 +1020,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) { - 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)) { - 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(); @@ -1063,26 +1042,26 @@ const luaV_concat = function(L, total) { } let buff = new Uint8Array(tl); copy2buff(L, top, n, buff); - let ts = luaS_bless(L, buff); + 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 */ - 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; +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 = ltm.luaT_gettmbyobj(L, t, ltm.TMS.TM_INDEX); if (tm.ttisnil()) - ldebug.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 = ltable.luaH_get(L, t.value, key); @@ -1105,10 +1084,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, 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()) { @@ -1122,7 +1101,7 @@ const settable = function(L, t, key, val) { /* 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)); + ldebug.luaG_typeerror(L, t, defs.to_luastring('index', true)); } /* try the metamethod */ if (tm.ttisfunction()) { @@ -1132,26 +1111,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, defs.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..1eef2ed2 100644 --- a/src/lzio.js +++ b/src/lzio.js @@ -1,37 +1,35 @@ -"use strict"; +import {lua_assert} from './llimits.js'; -const { lua_assert } = require("./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"); + 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 */ @@ -44,13 +42,13 @@ 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; - 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; @@ -62,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) @@ -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..e6319de8 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_jsstring, to_luastring} 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 +50,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))) + test('non-utf8 char', () => { + expect(() => to_jsstring(luastring_of(165))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(208, 60))) + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(208, 60))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(225, 60, 145))) + test('invalid continuation byte', () => { + expect(() => to_jsstring(luastring_of(225, 60, 145))) .toThrow(RangeError); }); - test("invalid continuation byte", () => { - expect(() => defs.to_jsstring(defs.luastring_of(225, 145, 60))) + test('invalid continuation byte', () => { + 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))) + test('invalid continuation byte', () => { + 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))) + test('invalid continuation byte', () => { + 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))) + 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 399155a8..4175de1a 100644 --- a/test/lapi.test.js +++ b/test/lapi.test.js @@ -1,251 +1,282 @@ -"use strict"; - -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 {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', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toEqual(to_luastring("nil")); + expect(luaL_typename(L, -1)) + .toEqual(to_luastring('nil')); }); test('lua_pushnumber', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toEqual(to_luastring("number")); + 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(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toEqual(to_luastring("number")); + 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(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toEqual(to_luastring("string")); + expect(luaL_typename(L, -1)) + .toEqual(to_luastring('string')); - expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + expect(lua_tojsstring(L, -1)) + .toBe('hello'); }); test('lua_pushboolean', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toEqual(to_luastring("boolean")); + 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(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toEqual(to_luastring("string")); + expect(luaL_typename(L, -1)) + .toEqual(to_luastring('string')); - expect(lauxlib.luaL_typename(L, -2)) - .toEqual(to_luastring("string")); + expect(luaL_typename(L, -2)) + .toEqual(to_luastring('string')); - expect(lua.lua_tojsstring(L, -1)) - .toBe("hello"); + expect(lua_tojsstring(L, -1)) + .toBe('hello'); - expect(lua.lua_tojsstring(L, -2)) - .toBe("hello"); + expect(lua_tojsstring(L, -2)) + .toBe('hello'); }); test('lua_pushjsclosure', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); { - let fn = function(L) { + 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)) - .toEqual(to_luastring("function")); + expect(luaL_typename(L, -1)) + .toEqual(to_luastring('function')); }); test('lua_pushjsfunction', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); { - let fn = function(L) { + let fn = function(_L) { return 0; }; - lua.lua_pushjsfunction(L, fn); + lua_pushjsfunction(L, fn); } - expect(lauxlib.luaL_typename(L, -1)) - .toEqual(to_luastring("function")); + expect(luaL_typename(L, -1)) + .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"); + 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)) - .toBe("hello"); + expect(lua_tojsstring(L, -1)) + .toBe('hello'); }); test('lua_call (calling a JS closure)', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toBe("upvalue hello!"); + expect(lua_tojsstring(L, -1)) + .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"); + 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)) - .toBe("hello"); + expect(lua_tojsstring(L, -1)) + .toBe('hello'); }); test('lua_pcall that breaks', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); { - let fn = function(L) { - return "undefined_value"; + 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(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toBe("hello"); + expect(lua_tojsstring(L, -1)) + .toBe('hello'); }); test('lua_load with no chunkname', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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'") + code: to_luastring('return \'hello\'') }, null, null); - 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('lua_load and lua_call it', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); { let luaCode = ` @@ -253,174 +284,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); + }, {bc: bc}, to_luastring('test-lua_load'), to_luastring('binary')); + lua_call(L, 0, 1); } - expect(lua.lua_tojsstring(L, -1)) - .toBe("JS > Lua > JS \\o/"); + expect(lua_tojsstring(L, -1)) + .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"); + 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)) - .toBe("hello world"); + expect(lua_tojsstring(L, -1)) + .toBe('hello world'); }); test('lua_createtable', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toBe("value"); + expect(lua_tojsstring(L, -1)) + .toBe('value'); }); describe('lua_atnativeerror', () => { test('no native error handler', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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..798630ad 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_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', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toBe("hello references!"); + expect(lua_tojsstring(L, -1)) + .toBe('hello references!'); }); diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js index dc30a984..1c83ade1 100644 --- a/test/lbaselib.test.js +++ b/test/lbaselib.test.js @@ -1,29 +1,38 @@ -"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, + 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', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -39,21 +48,21 @@ 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)) - .toBe("hello"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -70,20 +79,20 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -102,92 +111,92 @@ 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)) - .toBe("hello"); + expect(lua_tojsstring(L, -4)) + .toBe('hello'); - expect(lua.lua_tojsstring(L, -3)) - .toBe("hello"); + expect(lua_tojsstring(L, -3)) + .toBe('hello'); - expect(lua.lua_tojsstring(L, -2)) - .toBe("bye"); + expect(lua_tojsstring(L, -2)) + .toBe('bye'); - expect(lua.lua_tojsstring(L, -1)) - .toBe("bye"); + expect(lua_tojsstring(L, -1)) + .toBe('bye'); }); test('type', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toBe("number"); + expect(lua_tojsstring(L, -5)) + .toBe('number'); - expect(lua.lua_tojsstring(L, -4)) - .toBe("boolean"); + expect(lua_tojsstring(L, -4)) + .toBe('boolean'); - expect(lua.lua_tojsstring(L, -3)) - .toBe("string"); + expect(lua_tojsstring(L, -3)) + .toBe('string'); - expect(lua.lua_tojsstring(L, -2)) - .toBe("table"); + expect(lua_tojsstring(L, -2)) + .toBe('table'); - expect(lua.lua_tojsstring(L, -1)) - .toBe("nil"); + expect(lua_tojsstring(L, -1)) + .toBe('nil'); }); test('error', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local willFail = function () @@ -197,18 +206,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local willFail = function () @@ -222,18 +231,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, ['yo'] = 'lo'} @@ -246,42 +255,42 @@ 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return tonumber('foo'), @@ -291,57 +300,57 @@ 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -359,18 +368,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -388,18 +397,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -426,10 +435,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..507b9c80 100644 --- a/test/lcorolib.test.js +++ b/test/lcorolib.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 lstate = require('../src/lstate.js'); -const {to_luastring} = require("../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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function (start) @@ -22,19 +20,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function (start) @@ -54,22 +52,22 @@ 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)) - .toBe("suspended"); + expect(lua_tojsstring(L, -2)) + .toBe('suspended'); - expect(lua.lua_tojsstring(L, -1)) - .toBe("dead"); + expect(lua_tojsstring(L, -1)) + .toBe('dead'); }); test('coroutine.isyieldable', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.create(function () @@ -81,19 +79,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local running, ismain @@ -107,19 +105,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.wrap(function (start) @@ -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..3a351115 100644 --- a/test/ldblib.test.js +++ b/test/ldblib.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"); +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 +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 = "" @@ -61,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" @@ -97,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" @@ -138,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" @@ -161,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" @@ -186,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 @@ -213,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); } @@ -236,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 @@ -258,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); } @@ -280,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 @@ -295,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 d52cfcba..15910fcf 100644 --- a/test/ldebug.test.js +++ b/test/ldebug.test.js @@ -1,135 +1,133 @@ -"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_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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true 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)) - .toMatch("attempt to get length of a boolean value (local 'a')"); + expect(lua_tojsstring(L, -1)) + .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"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true 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)) - .toMatch("attempt to index a boolean value (local 'a')"); + expect(lua_tojsstring(L, -1)) + .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"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true 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)) - .toMatch("attempt to index a boolean value (local 'a')"); + expect(lua_tojsstring(L, -1)) + .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"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true 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)) - .toMatch("attempt to index a boolean value (local 'a')"); + expect(lua_tojsstring(L, -1)) + .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"); + 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)) - .toMatch("attempt to concatenate a table value"); + expect(lua_tojsstring(L, -1)) + .toMatch('attempt to concatenate a table value'); }); test('luaG_opinterror', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toMatch("attempt to perform arithmetic on a table value"); + expect(lua_tojsstring(L, -1)) + .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"); + 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)) - .toMatch("number has no integer representation"); + 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..e28beabd 100644 --- a/test/lexparse.test.js +++ b/test/lexparse.test.js @@ -1,39 +1,47 @@ -"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_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', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" return a `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -41,24 +49,24 @@ test('MOVE', () => { return b `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -66,15 +74,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); - let reader = function(L, data) { + 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,8 +91,8 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -92,15 +100,15 @@ test('Unary op, LOADBOOL', () => { return -a, not b, ~a `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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,32 +117,32 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} return a `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -146,23 +154,23 @@ test('CALL', () => { return c `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -178,15 +186,15 @@ test('Multiple return', () => { return c, d, e `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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,8 +203,8 @@ test('Multiple return', () => { test('TAILCALL', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -206,24 +214,24 @@ test('TAILCALL', () => { return f(1,2) `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (...) @@ -233,15 +241,15 @@ test('VARARG', () => { return f(1,2,3) `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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,8 +258,8 @@ test('VARARG', () => { test('LE, JMP', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -259,24 +267,24 @@ test('LE, JMP', () => { return a >= b `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -284,24 +292,24 @@ test('LT', () => { return a > b `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -309,24 +317,24 @@ test('EQ', () => { return a == b `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -335,24 +343,24 @@ test('TESTSET (and)', () => { return a and b `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -361,24 +369,24 @@ test('TESTSET (or)', () => { return a or b `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -391,24 +399,24 @@ test('TEST (false)', () => { return "goodbye" `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -420,24 +428,24 @@ test('FORPREP, FORLOOP (int)', () => { return total `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -449,24 +457,24 @@ test('FORPREP, FORLOOP (float)', () => { return total `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -477,27 +485,27 @@ test('SETTABLE, GETTABLE', () => { return t `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + 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'); }); test('SETUPVAL, GETUPVAL', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = "hello" @@ -511,24 +519,24 @@ test('SETUPVAL, GETUPVAL', () => { return f() `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -539,27 +547,27 @@ test('SETTABUP, GETTABUP', () => { return t `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + 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'); }); test('SELF', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -572,24 +580,24 @@ test('SELF', () => { return t:get() `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -597,25 +605,25 @@ test('SETLIST', () => { return t `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = function () @@ -627,24 +635,24 @@ test('Variable SETLIST', () => { return t `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + 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} @@ -652,25 +660,25 @@ test('Long SETLIST', () => { return t `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local iterator = function (t, i) @@ -694,24 +702,24 @@ test('TFORCALL, TFORLOOP', () => { return r `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[10000] = "foo"} @@ -721,41 +729,41 @@ test('LEN', () => { return #t, #t2, #s `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return "hello " .. 2 .. " you" `; { - lualib.luaL_openlibs(L); - let reader = function(L, data) { + 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..4de68371 100644 --- a/test/lmathlib.test.js +++ b/test/lmathlib.test.js @@ -1,145 +1,143 @@ -"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, 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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + 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), 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); +test('math.exp', () => { + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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..352eb262 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -1,51 +1,49 @@ -"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_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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" 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)) - .toBe("hello world"); + expect(lua_tojsstring(L, -1)) + .toBe('hello world'); }); test('load', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = load("return 'js running lua running lua'") 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)) - .toBe("js running lua running lua"); + expect(lua_tojsstring(L, -1)) + .toBe('js running lua running lua'); }); test('undump empty string', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(load(string.dump(function() @@ -54,80 +52,80 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" 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)) - .toBe("hello world"); + expect(lua_tojsstring(L, -1)) + .toBe('hello world'); }); // TODO: test stdin test('loadfile', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = assert(loadfile("test/loadfile-test.lua")) 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)) - .toBe("hello world"); + expect(lua_tojsstring(L, -1)) + .toBe('hello world'); }); test('loadfile (binary)', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = assert(loadfile("test/loadfile-test.bc")) 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)) - .toBe("hello world"); + expect(lua_tojsstring(L, -1)) + .toBe('hello world'); }); test('dofile', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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)) - .toBe("hello world"); + expect(lua_tojsstring(L, -1)) + .toBe('hello world'); }); diff --git a/test/loadlib.test.js b/test/loadlib.test.js index c0125c08..a084663d 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_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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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..6960e755 100644 --- a/test/loslib.test.js +++ b/test/loslib.test.js @@ -1,30 +1,36 @@ -"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, + 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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.time({ @@ -34,19 +40,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1 = os.time() @@ -54,18 +60,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -75,18 +81,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return os.date('%Y-%m-%d', os.time({ @@ -96,18 +102,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = { @@ -122,15 +128,15 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("C" == os.setlocale()) @@ -139,24 +145,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(); - if (!L) throw Error("failed to create lua state"); + 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..1a31f1fe 100644 --- a/test/lstrlib.test.js +++ b/test/lstrlib.test.js @@ -1,173 +1,180 @@ -"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, + 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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "world" 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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"', - "Correct element(s) on the stack" + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.sub("123456789",2,4), -- "234" @@ -183,28 +190,28 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local todump = function() @@ -219,25 +226,25 @@ 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); + }, {str: str}, to_luastring('test'), to_luastring('binary')); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s1, n, s2 = "hello", 2, "you" @@ -246,94 +253,94 @@ 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "hello world from Lua" @@ -346,75 +353,75 @@ 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` return string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) @@ -422,31 +429,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {name="lua", version="5.3"} 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..9993e875 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_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 = []; @@ -15,36 +13,36 @@ const inttable2array = function(t) { }; test('table.concat', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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,27 +50,27 @@ test('table.pack', () => { test('table.unpack', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 3, 4} @@ -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,8 +93,8 @@ test('table.insert', () => { test('table.remove', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 3, 4, 4} @@ -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,8 +117,8 @@ test('table.remove', () => { test('table.move', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1 = {3, 4, 5} @@ -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,8 +140,8 @@ test('table.move', () => { test('table.sort (<)', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} @@ -151,19 +149,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4} @@ -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..f7437cca 100644 --- a/test/ltm.test.js +++ b/test/ltm.test.js @@ -1,51 +1,49 @@ -"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, 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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {yo=1} 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = "a string" 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -61,18 +59,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -90,18 +88,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmt = { @@ -119,18 +117,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmt = { @@ -150,19 +148,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mmmt = { @@ -188,18 +186,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = nil @@ -229,19 +227,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -314,32 +312,32 @@ 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())) .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"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -355,18 +353,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -382,18 +380,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -409,18 +407,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -436,18 +434,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -467,19 +465,19 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -495,18 +493,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -522,18 +520,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt = { @@ -549,11 +547,11 @@ 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())) - .toEqual(["hello", "world", "wow"]); + .toEqual(['hello', 'world', 'wow']); }); diff --git a/test/lua.test.js b/test/lua.test.js index 0f12238b..9819241b 100644 --- a/test/lua.test.js +++ b/test/lua.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 {to_luastring} = require("../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', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -16,16 +14,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -33,31 +31,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = setmetatable({}, { @@ -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..36028173 100644 --- a/test/lutf8lib.test.js +++ b/test/lutf8lib.test.js @@ -1,83 +1,81 @@ -"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, 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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local s = "( ͡° ͜ʖ ͡° )" @@ -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..927ff66c 100644 --- a/test/lvm.test.js +++ b/test/lvm.test.js @@ -1,31 +1,38 @@ -"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_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', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = "hello world" @@ -33,16 +40,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -50,8 +57,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,8 +67,8 @@ test('Binary op', () => { test('Unary op, LOADBOOL', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 5 @@ -69,8 +76,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,25 +86,25 @@ test('Unary op, LOADBOOL', () => { test('NEWTABLE', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -109,17 +116,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -135,8 +142,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,8 +152,8 @@ test('Multiple return', () => { test('TAILCALL', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (a, b) @@ -156,17 +163,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (...) @@ -176,8 +183,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,8 +193,8 @@ test('VARARG', () => { test('LE, JMP', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -195,17 +202,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -213,17 +220,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 1, 1 @@ -231,17 +238,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -250,17 +257,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -269,17 +276,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = true @@ -292,17 +299,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = false @@ -315,17 +322,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -337,17 +344,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local total = 0 @@ -359,17 +366,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -380,20 +387,20 @@ 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()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + 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'); }); test('SETUPVAL, GETUPVAL', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local up = "hello" @@ -407,17 +414,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -428,20 +435,20 @@ 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()) - .toBe("hello"); - expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring()) - .toBe("world"); + 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'); }); test('SELF', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -454,17 +461,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {1, 2, 3, 4, 5, 6, 7, 8, 9} @@ -472,18 +479,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = function () @@ -495,18 +502,18 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + 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} @@ -514,11 +521,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,8 +555,8 @@ test('Long SETLIST', () => { test('TFORCALL, TFORLOOP', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local iterator = function (t, i) @@ -573,17 +580,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[10000] = "foo"} @@ -593,27 +600,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(); - if (!L) throw Error("failed to create lua state"); + 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..83f97cf1 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_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" 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..56082f7f 100644 --- a/test/test-suite/api.test.js +++ b/test/test-suite/api.test.js @@ -1,11 +1,9 @@ -"use strict"; +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 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 @@ -26,25 +24,25 @@ const prefix = ` end `; -test("[test-suite] api: registry", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: registry', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: absindex', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("settop 10; absindex -1; return 1") == 10) @@ -52,17 +50,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing alignment', () => { + let L = luaL_newstate(); + 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 @@ -77,17 +75,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: test that all trues are equal', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a,b,c = T.testC("pushbool 1; pushbool 2; pushbool 0; return 3") @@ -130,17 +128,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing \'rotate\'', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing 'rotate' @@ -166,17 +164,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing non-function message handlers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -207,34 +205,34 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing MULTRET', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = pack(T.testC("call 2,-1; return *", 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do -- test returning more results than fit in the caller stack @@ -245,17 +243,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing globals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.a = 14; _G.b = "a31" @@ -268,17 +266,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing arith', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5) @@ -314,33 +312,33 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: errors in arithmetic', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing lessthan and lessequal', () => { + let L = luaL_newstate(); + 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)) @@ -351,17 +349,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: non-valid indices produce false', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not T.testC("compare LT 1 4, return 1")) @@ -382,17 +380,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing length', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = setmetatable({x = 20}, {__len = function (t) return t.x end}) @@ -421,17 +419,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing __concat', () => { + let L = luaL_newstate(); + 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}) @@ -451,17 +449,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing lua_is', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function B(x) return x and 1 or 0 end @@ -494,17 +492,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing lua_to...', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function to (s, x, n) @@ -543,16 +541,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing panic function', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -590,17 +588,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: testing deep JS stack', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -634,17 +632,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing errors', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = T.testC([[ @@ -665,17 +663,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: test errors in non protected threads', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function checkerrnopro (code, msg) @@ -691,17 +689,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing table access', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- getp/setp @@ -742,17 +740,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing getfield/setfield with long keys', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing getfield/setfield with long keys @@ -770,17 +768,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing next', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -792,17 +790,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing upvalues', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -820,17 +818,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing absent upvalues from JS-function pointers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC[[isnull U1; return 1]] == true) @@ -844,17 +842,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: large closures', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -869,17 +867,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing get/setuservalue', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- bug in 5.1.2 @@ -904,17 +902,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: testing get/setuservalue', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T.gcstate("atomic") @@ -923,17 +921,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: long chain of userdata', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, 1000 do @@ -948,17 +946,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: reuse of references', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local i = T.ref{} @@ -1008,17 +1006,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` tt = {} @@ -1124,17 +1122,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do @@ -1168,17 +1166,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing lua_equal', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC("compare EQ 2 4; return 1", print, 1, print, 20)) @@ -1188,17 +1186,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing lua_equal with fallbacks', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1218,17 +1216,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing changing hooks during hooks', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.t = {} @@ -1252,17 +1250,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: testing errors during GC', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- testing errors during GC @@ -1292,17 +1290,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: test for userdata vals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1315,17 +1313,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing multiple states', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T.closestate(T.newstate()); @@ -1374,17 +1372,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: testing memory limits', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerr("block too big", T.newuserdata, math.maxinteger) @@ -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); }); @@ -1428,39 +1426,39 @@ const memprefix = ` `; -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"); +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'); 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(); - if (!L) throw Error("failed to create lua state"); +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'); 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: test thread creation after stressing GC', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function expand (n,s) @@ -1478,34 +1476,34 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: testing memory x compiler', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` testamem("loadstring", function () 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: testing memory x dofile', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local testprog = [[ @@ -1529,17 +1527,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] api: other generic tests', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` testamem("string creation", function () @@ -1600,17 +1598,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing some auxlib functions', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function gsub (a, b, c) @@ -1625,17 +1623,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] api: testing luaL_newmetatable', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local mt_xuxu, res, top = T.testC("newmetatable xuxu; gettop; return 3") @@ -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..c5b055f6 100644 --- a/test/test-suite/attrib.test.js +++ b/test/test-suite/attrib.test.js @@ -1,13 +1,11 @@ -"use strict"; +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 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("[test-suite] attrib: testing require", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] attrib: testing require', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(require"string" == string) @@ -54,23 +52,23 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] attrib: system specific tests for \'require\'', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] attrib: testing assignments, logical operators, and constructors', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local res, res2 = 27 @@ -161,16 +159,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] attrib: test of large float/integer indices ', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -225,16 +223,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] attrib: test conflicts in multiple assignment', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -245,16 +243,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] attrib: repeat test with upvalues', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -271,16 +269,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] attrib: bug in 5.2 beta', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () @@ -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..77b2f4c0 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_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 () --{ @@ -114,9 +112,9 @@ const prefix = ` local bit32 = require'bit32' `; -test("[test-suite] bitwise: testing bitwise operations", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: testing bitwise operations', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local numbits = string.packsize('j') * 8 @@ -177,16 +175,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: testing bitwise library', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.band() == bit32.bnot(0)) @@ -197,16 +195,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: out-of-range numbers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.band(-1) == 0xffffffff) @@ -262,16 +260,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: some special cases', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555, @@ -305,16 +303,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` c = {0, 1, 2, 3, 10, 0x800000, 0xaaaaaa, 0x555555, 0xffffff, 0x7fffff} @@ -332,16 +330,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: testing extract/replace', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(bit32.extract(0x12345678, 0, 4) == 8) @@ -363,31 +361,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: testing conversion of floats', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] bitwise: large floats and large-enough integers?', () => { + let L = luaL_newstate(); + 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 @@ -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..ef3014b3 100644 --- a/test/test-suite/calls.test.js +++ b/test/test-suite/calls.test.js @@ -1,13 +1,11 @@ -"use strict"; +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 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("[test-suite] calls: test 'type'", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test \'type\'', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(1<2) == 'boolean') @@ -23,16 +21,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test error in \'print\'', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test error in 'print' too... @@ -49,16 +47,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: testing local-function recursion', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` fact = false @@ -73,16 +71,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: testing declarations', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {i = 10} @@ -168,16 +166,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: testing closures', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- fixed-point operator @@ -214,16 +212,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: testing multiple returns', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function unlpack (t, i) @@ -260,16 +258,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: testing calls with \'incorrect\' arguments', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` rawget({}, "x", 1) @@ -277,16 +275,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test for generic load', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = "-- a comment\\0\\0\\0\\n x = 10 + \\n23; \\ @@ -337,30 +335,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: any value is valid for _ENV', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: load when _ENV is not first upvalue', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x; XX = 123 @@ -376,16 +374,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test generic load with nested functions', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function read1 (x) @@ -409,16 +407,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test for dump/undump with upvalues', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a, b = 20, 30 @@ -437,16 +435,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test for dump/undump with many upvalues', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -472,16 +470,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test for long method names', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -492,32 +490,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: test for bug in parameter adjustment', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert((function () return nil end)(4) == nil) 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] calls: testing binary chunks', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -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..c3d61696 100644 --- a/test/test-suite/closure.test.js +++ b/test/test-suite/closure.test.js @@ -1,13 +1,11 @@ -"use strict"; +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 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("[test-suite] closure: testing equality", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] closure: testing equality', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -22,16 +20,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] closure: testing closures with \'for\' control variable', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -63,16 +61,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local t = {"a", "b"} @@ -91,16 +89,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local b @@ -135,16 +133,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] closure: testing multi-level closure', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local w @@ -158,16 +156,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] closure: testing closures x repeat-until', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -178,16 +176,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` a = {} @@ -219,16 +217,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function t () @@ -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..f159e387 100644 --- a/test/test-suite/code.test.js +++ b/test/test-suite/code.test.js @@ -1,15 +1,13 @@ -"use strict"; +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 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 {luaopen_tests} from './ltests.js'; -const ltests = require('./ltests.js'); - -test("[test-suite] code: testing reuse in constant table", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: testing reuse in constant table', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkKlist (func, list) @@ -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); }); @@ -64,26 +62,26 @@ const prefix = ` `; -test("[test-suite] code: some basic instructions", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: some basic instructions', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () (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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: sequence of LOADNILs', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -104,32 +102,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: single return', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: infinite loops', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () while true do local a = -1 end end, @@ -141,33 +139,33 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: concat optimization', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: not', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return not not nil end, 'LOADBOOL', 'RETURN') @@ -175,17 +173,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: direct access to locals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -198,17 +196,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: direct access to constants', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () @@ -233,17 +231,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: constant folding', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkK (func, val) @@ -267,17 +265,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: no folding', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return -0.0 end, 'LOADK', 'UNM', 'RETURN') @@ -285,17 +283,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: bug in constant folding for 5.1', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN') @@ -315,17 +313,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: x == nil , x ~= nil', () => { + let L = luaL_newstate(); + 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, @@ -340,17 +338,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] code: if-goto optimizations', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` check(function (a, b, c, d, e) @@ -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..d0758ccb 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_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) @@ -12,38 +10,38 @@ const checkload = ` `; test('[test-suite] constructs: testing semicolons', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do ;;; end ; 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(2^3^2 == 2^(3^2)); @@ -87,16 +85,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` repeat until 1; repeat until true; @@ -261,15 +259,15 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- sometimes will be 0, sometimes will not... @@ -336,16 +334,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] constructs: testing some syntax errors (chosen through \'gcov\')', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true @@ -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..89e29046 100644 --- a/test/test-suite/coroutine.test.js +++ b/test/test-suite/coroutine.test.js @@ -1,11 +1,9 @@ -"use strict"; +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 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 = { @@ -55,9 +53,9 @@ const prefix = ` end `; -test("[test-suite] coroutine: is main thread", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: is main thread', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local main, ismain = coroutine.running() @@ -66,31 +64,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: trivial errors', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: tests for multiple yield/resume arguments', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function eqtab (t1, t2) @@ -136,16 +134,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: yields in tail calls', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (i) return coroutine.yield(i) end @@ -158,16 +156,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: recursive', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function pf (n, i) @@ -182,16 +180,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: sieve', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function gen (n) @@ -223,16 +221,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: yielding across JS boundaries', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (s, i) return coroutine.yield(i) end @@ -263,16 +261,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: unyieldable JS call', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -289,16 +287,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: errors in coroutines', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function foo () @@ -322,16 +320,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: co-routines x for loop', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function all (a, n, k) @@ -350,16 +348,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: old bug: attempt to resume itself', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function co_func (current_co) @@ -381,16 +379,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do @@ -404,16 +402,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: attempt to resume \'normal\' coroutine', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co1, co2 @@ -428,32 +426,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: infinite recursion of coroutines', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = function(a) coroutine.wrap(a)(a) end 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: access to locals of erroneous coroutines', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = coroutine.create (function () @@ -468,15 +466,15 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: leaving a pending coroutine open', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _X = coroutine.wrap(function () @@ -487,16 +485,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: stack overflow', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- bug (stack overflow) @@ -515,16 +513,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields inside metamethods', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = new(10) @@ -563,16 +561,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: tests for comparsion operators', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -615,16 +613,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: getuptable & setuptable', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do local _ENV = _ENV @@ -635,16 +633,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields inside \'for\' iterators', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local f = function (s, i) @@ -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); }); @@ -676,9 +674,9 @@ const jsprefix = ` end `; -test("[test-suite] coroutine: testing yields inside hooks", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields inside hooks', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local A, B = 0, 0 @@ -700,17 +698,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields inside line hook', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -731,17 +729,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields in count hook', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -760,17 +758,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields inside line hook', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local line = debug.getinfo(1, "l").currentline + 2 -- get line number @@ -798,17 +796,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do @@ -838,17 +836,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do @@ -862,17 +860,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: reusing a thread', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(T.testC([[ @@ -896,17 +894,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: resuming running coroutine', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = coroutine.create(function () @@ -933,16 +931,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: using a main thread as a coroutine', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local state = T.newstate() @@ -976,17 +974,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: tests for coroutine API', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function apico (...) @@ -1028,17 +1026,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: tests for coroutine API', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` f = T.makeCfunc("pushnum 3; pushnum 5; yield 1;") @@ -1049,17 +1047,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing coroutines with C bodies', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function eqtab (t1, t2) @@ -1094,17 +1092,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing chain of suspendable C calls', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local count = 3 -- number of levels @@ -1137,17 +1135,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: testing yields with continuations', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = coroutine.wrap(function (...) return @@ -1202,17 +1200,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] coroutine: bug in nCcalls', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local co = coroutine.wrap(function () @@ -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..6108166f 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_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 @@ -22,9 +20,9 @@ const prefix = ` end `; -test("[test-suite] db: getinfo, ...line...", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: getinfo, ...line...', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(debug.getinfo, print, "X")) -- invalid option @@ -43,16 +41,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: test file and string names truncation', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = "function f () end" @@ -79,15 +77,15 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: local', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` repeat @@ -126,16 +124,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: line hook', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` test([[if @@ -192,31 +190,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: invalid levels in [gs]etlocal', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: parameter names', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (a,b,...) local d, e end @@ -231,16 +229,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: vararg', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo (a, ...) @@ -268,31 +266,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: access to vararg in non-vararg function', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: test hook presence in debug info', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- test hook presence in debug info @@ -379,16 +377,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local n, v = debug.getlocal(0, 1) @@ -413,16 +411,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing access to function arguments', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function collectlocals (level) @@ -462,16 +460,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function collectlocals (level) @@ -509,16 +507,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing upvalue access', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function getupvalues (f) @@ -549,16 +547,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing count hooks', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a=0 @@ -579,16 +577,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: tests for tail calls', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (x) @@ -645,16 +643,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing local function information', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = load[[ @@ -675,16 +673,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing traceback', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(debug.traceback(print) == print) @@ -700,16 +698,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing nparams, nups e isvararg', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = debug.getinfo(print, "u") @@ -725,16 +723,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing debugging of coroutines', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checktraceback (co, p, level) @@ -803,17 +801,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: check get/setlocal in coroutines', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` co = coroutine.create(function (x) @@ -831,16 +829,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function checktraceback (co, p, level) @@ -866,16 +864,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function g(x) @@ -897,16 +895,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: test tagmethod information', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -937,16 +935,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing for-iterator name', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -957,16 +955,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: testing traceback sizes', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function countlines (s) @@ -1004,17 +1002,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` prog = [[-- program to be loaded without debug information @@ -1060,16 +1058,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] db: tests for \'source\' in binary dumps', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -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..f9ae121a 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_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) @@ -42,37 +40,37 @@ const prefix = ` end `; -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"); +test('[test-suite] errors: test error message with no extra info', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: test error message with no info', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` assert(doit("table.unpack({}, 1, n=2^30)")) @@ -92,16 +90,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: tests for better error messages', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("a = {} + 1", "arithmetic") @@ -126,16 +124,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` checkmessage("local a,b,cc; (function () a = cc[1] end)()", "upvalue 'cc'") @@ -148,16 +146,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: short circuit', () => { + let L = luaL_newstate(); + 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)", @@ -173,16 +171,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: float->integer conversions', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage("local a = 2.0^100; x = a << 2", "local a") @@ -203,16 +201,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: passing light userdata instead of full userdata', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _G.D = debug @@ -223,16 +221,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: named objects (field \'__name\')', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -248,31 +246,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: global functions', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: errors in functions without debug info', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -289,16 +287,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: tests for field accesses after RK limit', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {} @@ -312,16 +310,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: global', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[aaa=9 @@ -335,16 +333,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: field', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -352,16 +350,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: global insert', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -373,48 +371,48 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: sin', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ -- tail call 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: concatenate', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[x = print .. "a"]], "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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: unknown global', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkmessage([[ @@ -425,16 +423,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: __index', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {}; setmetatable(a, {__index = string}) @@ -445,16 +443,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: tests for errors in coroutines', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (n) @@ -469,16 +467,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: testing size of \'source\' info', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` idsize = 60 - 1 @@ -496,16 +494,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: testing line error', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function lineerror (s, l) @@ -561,16 +559,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: several tests that exhaust the Lua stack', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = 0 @@ -584,16 +582,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: error lines in stack overflow', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` C = 0 @@ -615,16 +613,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: error in error handling', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local res, msg = xpcall(error, error) @@ -640,16 +638,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: too many results', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function loop (x,y,z) return 1 + loop(x, y, z) end @@ -667,16 +665,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: non string messages', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -713,16 +711,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: xpcall with arguments', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a, b, c = xpcall(string.find, error, "alo", "al") @@ -730,16 +728,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: testing tokens in error messages', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checksyntax("syntax error", "", "error", 1) @@ -749,30 +747,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` checksyntax("\\255a = 1", "", "<\\\\255>", 1) @@ -780,16 +778,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: lots of errors', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` lim = 1000 @@ -799,16 +797,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: testing syntax limits', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local maxClevel = 200 -- LUAI_MAXCCALLS (in llimits.h) @@ -834,16 +832,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: upvalues limit', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local lim = 127 @@ -868,16 +866,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] errors: local variables limit', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` s = "\\nfunction foo ()\\n local " @@ -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..b0b322df 100644 --- a/test/test-suite/events.test.js +++ b/test/test-suite/events.test.js @@ -1,15 +1,13 @@ -"use strict"; +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 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 {luaopen_tests} from './ltests.js'; -const ltests = require('./ltests.js'); - -test("[test-suite] events: testing metatable", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: testing metatable', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` X = 20; B = 30 @@ -183,16 +181,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: test for rawlen', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = setmetatable({1,2,3}, {__len = function () return 10 end}) @@ -205,16 +203,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: test comparison', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -254,16 +252,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: test \'partial order\'', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -325,16 +323,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: __eq between userdata', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T = require('T') @@ -356,17 +354,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: concat', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` t = {} @@ -395,17 +393,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` c = {} @@ -417,17 +415,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: test comparison compatibilities', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t1, t2, c, d @@ -443,17 +441,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local i @@ -474,17 +472,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: __index on _ENV', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local _g = _G @@ -494,17 +492,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: testing metatables for basic types', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` mt = {__index = function (a,b) return a+b end, @@ -536,34 +534,34 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: loops in delegation', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {}; setmetatable(a, a); a.__index = a; a.__newindex = a 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] events: bug in 5.1', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` T, K, V = nil @@ -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..0861fa05 100644 --- a/test/test-suite/goto.test.js +++ b/test/test-suite/goto.test.js @@ -1,13 +1,11 @@ -"use strict"; +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 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("[test-suite] goto: error messages", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] goto: error messages', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function errmsg (code, m) @@ -46,16 +44,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] goto', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- simple gotos @@ -113,16 +111,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function foo () @@ -141,16 +139,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] goto: bug in 5.2 -> 5.3.2', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- bug in 5.2 -> 5.3.2 @@ -168,16 +166,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] goto: testing closing of upvalues', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function foo () @@ -241,16 +239,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] goto: testing if x goto optimizations', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function testG (a) @@ -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..ad80471e 100644 --- a/test/test-suite/literals.test.js +++ b/test/test-suite/literals.test.js @@ -1,33 +1,31 @@ -"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, 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 `; -test("[test-suite] literals: dostring", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: dostring', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: escape sequences', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('\\n\\"\\'\\\\' == [[ @@ -35,16 +33,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: assume ASCII just for tests', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\09912" == 'c12') @@ -55,16 +53,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: hexadecimal escapes', () => { + let L = luaL_newstate(); + 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") @@ -90,16 +88,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: UTF-8 sequences', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("\\u{0}\\u{00000000}\\x00\\0" == string.char(0, 0, 0, 0)) @@ -116,16 +114,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: Error in escape sequences', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function lexerror (s, err) @@ -170,16 +168,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: valid characters in variable names', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 0, 255 do @@ -189,16 +187,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: long variable names', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` var1 = string.rep('a', 15000) .. '1' @@ -212,30 +210,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: escapes', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: long strings', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = `b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789" assert(string.len(b) == 960) @@ -289,16 +287,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: testing line ends', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = `prog = [[ a = 1 -- a comment @@ -319,16 +317,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: testing comments and strings with long brackets', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = `a = [==[]=]==] assert(a == "]=") @@ -349,16 +347,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = `local x = {"=", "[", "]", "\\n"} local len = 4 @@ -374,32 +372,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: testing %q x line ends', () => { + let L = luaL_newstate(); + 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" 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] literals: testing errors', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not load"a = 'non-ending string") @@ -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..d9250be2 100644 --- a/test/test-suite/locals.test.js +++ b/test/test-suite/locals.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_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 = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f(x) x = nil; return x end @@ -19,16 +17,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -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,8 +94,8 @@ 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"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(getenv(load"a=3") == _G) @@ -107,16 +105,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -138,16 +136,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(_ENV == _G) @@ -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..5bdd7cf5 100644 --- a/test/test-suite/ltests.js +++ b/test/test-suite/ltests.js @@ -1,21 +1,155 @@ -"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; - -const delimits = [" ", "\t", "\n", ",", ";"].map(e => e.charCodeAt(0)); +import assert from 'assert'; + +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)); const skip = function(pc) { for (;;) { @@ -33,12 +167,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 +180,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 +193,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,26 +207,26 @@ 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); } }; -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]); + 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); + console.log('${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n'); + lua_pop(L, 1); } - console.log(""); + console.log(''); }; /* @@ -103,386 +237,386 @@ 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 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))); + 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.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": { + 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": { + 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": { + 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": { + case 'checkstack': { let sz = getnum(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": { + 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)); + case 'concat': { + 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)); + lua_copy(L1, f, getindex(L, L1, pc)); break; } - case "func2num": { - let func = lua.lua_tocfunction(L1, getindex(L, L1, pc)); + case 'func2num': { + 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": { + 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)); + case 'getglobal': { + lua_getglobal(L1, getstring(L, buff, pc)); break; } - case "getmetatable": { - if (lua.lua_getmetatable(L1, getindex(L, L1, pc)) === 0) - lua.lua_pushnil(L1); + case 'getmetatable': { + if (lua_getmetatable(L1, getindex(L, L1, pc)) === 0) + lua_pushnil(L1); break; } - case "gettable": { - lua.lua_gettable(L1, getindex(L, L1, pc)); + case 'gettable': { + lua_gettable(L1, getindex(L, L1, pc)); break; } - case "gettop": { - lua.lua_pushinteger(L1, lua.lua_gettop(L1)); + 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); - 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)); + case 'insert': { + lua_insert(L1, getnum(L, L1, pc)); break; } - case "iscfunction": { - lua.lua_pushboolean(L1, lua.lua_iscfunction(L1, getindex(L, L1, pc))); + case 'iscfunction': { + 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))); + case 'isfunction': { + 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))); + case 'isnil': { + 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))); + case 'isnull': { + 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))); + case 'isnumber': { + 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))); + case 'isstring': { + 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))); + case 'istable': { + 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))); + case 'isudataval': { + 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))); + case 'isuserdata': { + lua_pushboolean(L1, lua_isuserdata(L1, getindex(L, L1, pc))); break; } - case "len": { - lua.lua_len(L1, getindex(L, L1, pc)); + case 'len': { + lua_len(L1, getindex(L, L1, pc)); break; } - case "Llen": { - lua.lua_pushinteger(L1, lauxlib.luaL_len(L1, getindex(L, L1, pc))); + case 'Llen': { + 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))); + case 'loadfile': { + 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); + case 'loadstring': { + 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))); + case 'newmetatable': { + lua_pushboolean(L1, luaL_newmetatable(L1, getstring(L, buff, pc))); break; } - case "newtable": { - lua.lua_newtable(L1); + case 'newtable': { + lua_newtable(L1); break; } - case "newthread": { - lua.lua_newthread(L1); + case 'newthread': { + lua_newthread(L1); break; } - case "newuserdata": { - lua.lua_newuserdata(L1, getnum(L, L1, pc)); + case 'newuserdata': { + lua_newuserdata(L1, getnum(L, L1, pc)); break; } - case "next": { - lua.lua_next(L1, -2); + case 'next': { + lua_next(L1, -2); break; } - case "objsize": { - lua.lua_pushinteger(L1, lua.lua_rawlen(L1, getindex(L, L1, pc))); + 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.lua_pcall(L1, narg, 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.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)); + 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(`${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)); + case 'pushbool': { + lua_pushboolean(L1, getnum(L, L1, pc)); break; } - case "pushcclosure": { - lua.lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); + case 'pushcclosure': { + lua_pushcclosure(L1, testJS, getnum(L, L1, pc)); break; } - case "pushint": { - lua.lua_pushinteger(L1, getnum(L, L1, pc)); + case 'pushint': { + lua_pushinteger(L1, getnum(L, L1, pc)); break; } - case "pushnil": { - lua.lua_pushnil(L1); + case 'pushnil': { + lua_pushnil(L1); break; } - case "pushnum": { - lua.lua_pushnumber(L1, getnum(L, L1, pc)); + case 'pushnum': { + lua_pushnumber(L1, getnum(L, L1, pc)); break; } - case "pushstatus": { + case 'pushstatus': { pushcode(L1, status); break; } - case "pushstring": { - lua.lua_pushstring(L1, getstring(L, buff, pc)); + case 'pushstring': { + lua_pushstring(L1, getstring(L, buff, pc)); break; } - case "pushupvalueindex": { - lua.lua_pushinteger(L1, lua.lua_upvalueindex(getnum(L, L1, pc))); + case 'pushupvalueindex': { + lua_pushinteger(L1, lua_upvalueindex(getnum(L, L1, pc))); break; } - case "pushvalue": { - lua.lua_pushvalue(L1, getindex(L, L1, pc)); + case 'pushvalue': { + 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)); + 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)); + 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)); + lua_rawsetp(L1, t, getnum(L, L1, pc)); break; } - case "remove": { - lua.lua_remove(L1, getnum(L, L1, pc)); + case 'remove': { + lua_remove(L1, getnum(L, L1, pc)); break; } - case "replace": { - lua.lua_replace(L1, getindex(L, L1, pc)); + case 'replace': { + 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)); + 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; 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": { + 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": { + 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)); + 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": { - lua.lua_setmetatable(L1, getindex(L, L1, pc)); + case 'setmetatable': { + lua_setmetatable(L1, getindex(L, L1, pc)); break; } - case "settable": { - lua.lua_settable(L1, getindex(L, L1, pc)); + case 'settable': { + lua_settable(L1, getindex(L, L1, pc)); break; } - case "settop": { - lua.lua_settop(L1, getnum(L, L1, pc)); + case 'settop': { + 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); + lua_pushboolean(L1, luaL_testudata(L1, i, getstring(L, buff, pc)) !== null); break; } - case "error": { - lua.lua_error(L1); + case 'error': { + lua_error(L1); break; } - case "throw": { + case 'throw': { throw new Error(); } - case "tobool": { - lua.lua_pushboolean(L1, lua.lua_toboolean(L1, getindex(L, L1, pc))); + case 'tobool': { + 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))); + case 'tocfunction': { + 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))); + case 'tointeger': { + 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))); + case 'tonumber': { + lua_pushnumber(L1, lua_tonumber(L1, getindex(L, L1, pc))); break; } - case "topointer": { - let p = lua.lua_topointer(L1, getindex(L, L1, pc)); + case 'topointer': { + 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); + 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": { - lua.lua_pushstring(L1, lauxlib.luaL_typename(L1, getnum(L, L1, pc))); + 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.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)); + 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.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,151 +625,141 @@ 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; - 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); - 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; }; @@ -644,14 +768,14 @@ 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 */ + 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) */ + 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 +791,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 +828,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,34 +900,34 @@ 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){ pushobj2s(L, o); - assert(L.top <= L.ci.top, "stack overflow"); + assert(L.top <= L.ci.top, 'stack overflow'); }; 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)}`; + 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)}`; 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,63 +935,61 @@ 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"); + 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); - setnameval(L, to_luastring("maxstack", true), p.maxstacksize); - setnameval(L, to_luastring("numparams", true), p.numparams); + 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), - 1, "Lua function expected"); + 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; }; 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) { - 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 */ +export const luaopen_tests = function(L) { + luaL_requiref(L, to_luastring('T'), luaB_opentests, 1); + lua_pop(L, 1); /* remove lib */ }; - -module.exports.luaopen_tests = luaopen_tests; diff --git a/test/test-suite/math.test.js b/test/test-suite/math.test.js index 9cf4e21a..78044c9e 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"); +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 @@ -52,24 +52,24 @@ const prefix = ` end `; -test("[test-suite] math: int bits", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: int bits', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` assert(isNaN(0/0)) @@ -87,16 +87,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: basic float notation', () => { + let L = luaL_newstate(); + 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) @@ -139,31 +139,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: math.huge', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: integer arithmetic', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint < minint + 1) @@ -172,16 +172,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing floor division and conversions', () => { + let L = luaL_newstate(); + 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 @@ -215,16 +215,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: negative exponents', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -240,16 +240,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: comparison between floats and integers (border cases)', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if floatbits < intbits then @@ -268,16 +268,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: order between floats and integers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(minint == 1 << (intbits - 1)) @@ -305,16 +305,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing order (floats can represent all integers)', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(floatbits >= intbits) @@ -347,16 +347,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: NaN order', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local NaN = 0/0 @@ -368,16 +368,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: avoiding errors at compile time', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkcompt("divide by zero", "return 2 // 0") @@ -387,15 +387,15 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function f2i (x) return x | x end @@ -428,16 +428,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing numeric strings', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert("2" + 1 == 3) @@ -445,16 +445,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do @@ -491,16 +491,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: \'tonumber\' with numbers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber(3.4) == 3.4) @@ -508,16 +508,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: \'tonumber\' with strings', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber("0") == 0) @@ -558,16 +558,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: tests with very long numerals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber("0x"..string.rep("f", 13)..".0") == 2.0^(4*13) - 1) @@ -584,16 +584,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing \'tonumber\' for invalid formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (...) @@ -628,16 +628,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing \'tonumber\' for invalid hexadecimal formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber('0x') == nil) @@ -653,16 +653,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing hexadecimal numerals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(0x10 == 16 and 0xfff == 2^12 - 1 and 0XFB == 251) @@ -675,16 +675,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: floating hexas', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(tonumber(' 0x2.5 ') == 0x25/16) @@ -711,16 +711,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing order operators', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not(1<1) and (1<2) and not(2<1)) @@ -733,16 +733,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing mod operator', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(eqT(-4 % 3, 2)) @@ -762,16 +762,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` local function anan (x) assert(isNaN(x)) end -- assert Not a Number @@ -787,16 +787,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing unsigned comparisons', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(math.ult(3, 4)) @@ -831,32 +831,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing constant limits', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(8388609 + -8388609 == 0) 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing floor & ceil', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -902,16 +902,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing fmod for integers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = -6, 6 do @@ -934,16 +934,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing max/min', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -962,32 +962,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing implicit convertions', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a,b = '10', '20' 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: testing -0 and NaN', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1024,16 +1024,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: test random for floats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` math.randomseed(0) @@ -1055,16 +1055,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: test random for small intervals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1099,16 +1099,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: test random for large intervals', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -1145,40 +1145,40 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: test random for empty interval', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(math.random, minint + 1, minint)) 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] math: interval too large', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(not pcall(math.random, minint, 0)) 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..c0320a8b 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"); +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, ...) @@ -12,9 +12,9 @@ const prefix = ` end `; -test("[test-suite] nextvar: testing size operator", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing size operator', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = {} @@ -28,16 +28,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing ipairs', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local x = 0 @@ -48,16 +48,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: test for \'false\' x ipair', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` x = false @@ -69,30 +69,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: iterator function is always the same', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] nextvar: JS tests', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- testing table sizes @@ -225,16 +225,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: test size operation on empty tables', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -243,16 +243,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: test size operation on empty tables', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -261,16 +261,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: next uses always the same iteration function', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local nofind = {} @@ -310,45 +310,45 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: invalid key to \'next\'', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: both \'pairs\' and \'ipairs\' need an argument', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: fmod table', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -366,16 +366,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: check next', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checknext (a) @@ -391,16 +391,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: # operator', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(#{} == 0) @@ -412,16 +412,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: maxn', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` -- 'maxn' is now deprecated, but it is easily defined in Lua @@ -441,32 +441,32 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: int overflow', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: erasing values', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local t = {[{1}] = 1, [{2}] = 2, [string.rep("x ", 4)] = 3, @@ -542,16 +542,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing table library with metamethods', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -600,16 +600,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] nextvar: JS tests', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local tab = {10, 20, 30} @@ -641,16 +641,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: next', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -668,16 +668,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing floats in numeric for', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -699,30 +699,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: conversion', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: checking types', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -779,16 +779,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing generic \'for\'', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function f (n, p) @@ -808,16 +808,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing __pairs and __ipairs metamethod', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {} @@ -848,16 +848,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] nextvar: testing ipairs with metamethods', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = {n=10} @@ -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..f33123eb 100644 --- a/test/test-suite/pm.test.js +++ b/test/test-suite/pm.test.js @@ -1,13 +1,11 @@ -"use strict"; +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'; -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("[test-suite] pm: pattern matching", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: pattern matching', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(s, p) @@ -87,16 +85,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: tonumber', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f1(s, p) @@ -114,16 +112,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: range', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function range (i, j) @@ -154,40 +152,40 @@ 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(); - 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); +test('[test-suite] pm: classes', () => { + let L = luaL_newstate(); + 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) + 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(); - 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); +test('[test-suite] pm: gsub', () => { + let L = luaL_newstate(); + 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) + throw new SyntaxError(lua_tojsstring(L, -1)); + lua_call(L, 0, 0); }); -test("[test-suite] pm: empty matches", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: empty matches', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- new (5.3.3) semantics for empty matches @@ -203,16 +201,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: gsub', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("um (dois) tres (quatro)", "(%(%w+%))", string.upper) == @@ -245,16 +243,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: gsub isbalanced', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function isbalanced (s) @@ -265,16 +263,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: capture', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function checkerror (msg, f, ...) @@ -302,16 +300,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` _soft = true @@ -327,16 +325,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: big strings (TODO: _soft)', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` _soft = true -- TODO @@ -352,16 +350,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: recursive nest of gsubs', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function rev (s) @@ -371,16 +369,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: gsub with tables', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.gsub("alo alo", ".", {}) == "alo alo") @@ -393,16 +391,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: gmatch', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = 0 @@ -429,16 +427,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: tests for \'%f\' (\'frontiers\')', () => { + let L = luaL_newstate(); + 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") @@ -467,16 +465,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: malformed patterns', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function malform (p, m) @@ -497,16 +495,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: \\0 in patterns', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.match("ab\\0\\1\\2c", "[\\0-\\2]+") == "\\0\\1\\2") @@ -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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] pm: magic char after \\0', () => { + 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..01a8d0e7 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_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 @@ -30,9 +28,9 @@ const prefix = ` if _soft then limit = 5000 end `; -test("[test-suite] sort: testing unpack", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing unpack', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("wrong number of arguments", table.insert, {}, 2, 3, 4) @@ -60,16 +58,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing unpack', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -100,16 +98,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing unpack', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- length is not an integer @@ -118,16 +116,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing pack', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` a = table.pack() @@ -139,16 +137,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing move', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -222,16 +220,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing long move', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -261,16 +259,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: testing sort, strange lengths', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local a = setmetatable({}, {__len = function () return -1 end}) @@ -279,16 +277,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: test checks for invalid order functions', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function check (t) @@ -300,16 +298,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: sort alpha', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -325,16 +323,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: sort perm', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -370,16 +368,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: Invert-sorting', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -408,16 +406,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] sort: sorting', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function check (a, f) @@ -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..127b51d9 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_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 @@ -15,8 +13,8 @@ const checkerror = ` `; test('[test-suite] strings: string comparisons', () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('alo' < 'alo1') @@ -37,16 +35,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert('alo' < 'alo1') @@ -67,16 +65,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.find("123456789", "345") == 3) @@ -93,16 +91,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.len("") == 0) @@ -113,16 +111,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.byte("a") == 97) @@ -158,16 +156,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.rep('teste', 0, 'xuxu') == '') @@ -183,16 +181,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(type(tostring(nil)) == 'string') @@ -223,16 +221,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` x = '"ílo"\\n\\\\' @@ -258,16 +256,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -287,31 +285,31 @@ 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(); - if (!L) throw Error("failed to create lua state"); + 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(string.format("%s %s", nil, true) == "nil true") @@ -333,16 +331,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -358,16 +356,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do -- assume at least 32 bits @@ -395,16 +393,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] strings: \'format %a %A\'', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -440,16 +438,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] strings: errors in format', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` local function check (fmt, msg) @@ -468,16 +466,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] strings: table.concat', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("table expected", table.concat, 3) @@ -507,17 +505,17 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test.skip('[test-suite] strings: locale', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` if not _port then @@ -551,16 +549,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` do @@ -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..9d1e8e3b 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_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 @@ -30,9 +28,9 @@ const prefix = ` local align = packsize("!xXi16") `; -test("[test-suite] tpack: maximum size for integers", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: maximum size for integers', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and @@ -47,16 +45,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: minimum behavior for integer formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(unpack("B", pack("B", 0xff)) == 0xff) @@ -71,16 +69,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: minimum behavior for integer formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, NB do @@ -98,16 +96,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: minimum behavior for integer formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -131,16 +129,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: minimum behavior for integer formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, sizeLI do @@ -153,16 +151,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: sign extension', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -174,16 +172,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: mixed endianness', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -193,16 +191,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: testing invalid formats', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` checkerror("out of limits", pack, "i0", 0) @@ -216,16 +214,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = ` checkerror("invalid format", packsize, "c1" .. string.rep("0", 40)) @@ -239,16 +237,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: overflow in packing', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` for i = 1, sizeLI - 1 do @@ -268,16 +266,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: Lua integer size', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` assert(unpack(">j", pack(">j", math.maxinteger)) == math.maxinteger) @@ -290,16 +288,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: testing pack/unpack of floating-point numbers', () => { + let L = luaL_newstate(); + 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 @@ -318,16 +316,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: testing pack/unpack of strings', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -372,16 +370,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: testing multiple types and sequence', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -392,16 +390,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: testing alignment', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -446,16 +444,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] tpack: testing initial position', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` do @@ -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..b6d2c30a 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_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, ...) @@ -94,24 +92,24 @@ const prefix = ` end `; -test("[test-suite] utf8: offset", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: offset', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: error indication in utf8.len', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` do @@ -125,16 +123,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: error in initial position for offset', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` checkerror("position out of range", utf8.offset, "abc", 1, 5) @@ -145,16 +143,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: codepoints', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` local s = "hello World" @@ -183,30 +181,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +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'); 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: overlong sequences', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\xC0\\x80") -- zero @@ -214,16 +212,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: invalid bytes', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = prefix + ` invalid("\\x80") -- continuation byte @@ -231,30 +229,30 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] utf8: empty strings', () => { + 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(); - if (!L) throw Error("failed to create lua state"); +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'); let luaCode = prefix + ` s = "\\0 \\x7F\\z @@ -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..f2abe76d 100644 --- a/test/test-suite/vararg.test.js +++ b/test/test-suite/vararg.test.js @@ -1,13 +1,11 @@ -"use strict"; +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 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("[test-suite] vararg: testing vararg", () => { - let L = lauxlib.luaL_newstate(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] vararg: testing vararg', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(a, ...) @@ -74,16 +72,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] vararg: new-style varargs', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function oneless (a, ...) return ... end @@ -107,16 +105,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] vararg: varargs for main chunks', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` f = load[[ return {...} ]] @@ -145,16 +143,16 @@ 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(); - if (!L) throw Error("failed to create lua state"); +test('[test-suite] vararg: bug in 5.2.2', () => { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); let luaCode = ` function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, @@ -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..c67f06ad 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,23 +1,19 @@ -"use strict"; +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'; -const lua = require("../src/lua.js"); -const lauxlib = require("../src/lauxlib.js"); -const {to_luastring} = require("../src/fengaricore.js"); +export const toByteCode = function(luaCode) { + let L = luaL_newstate(); + if (!L) throw Error('failed to create lua state'); -const toByteCode = function(luaCode) { - let L = lauxlib.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) - throw Error("unable to dump given function"); + throw Error('unable to dump given function'); return Uint8Array.from(b); }; - -module.exports.toByteCode = toByteCode; diff --git a/yarn.lock b/yarn.lock index 3ad7b24f..48dc35e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,41 +2,34 @@ # yarn lockfile v1 -"@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== +"@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/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" + "@babel/helper-validator-identifier" "^7.29.7" 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/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" "@jridgewell/remapping" "^2.3.5" convert-source-map "^2.0.0" debug "^4.1.0" @@ -44,103 +37,226 @@ json5 "^2.2.3" semver "^6.3.1" -"@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== +"@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.28.5" - "@babel/types" "^7.28.5" + "@babel/parser" "^7.29.7" + "@babel/types" "^7.29.7" "@jridgewell/gen-mapping" "^0.3.12" "@jridgewell/trace-mapping" "^0.3.28" jsesc "^3.0.2" -"@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== +"@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.27.2" - "@babel/helper-validator-option" "^7.27.1" + "@babel/compat-data" "^7.29.7" + "@babel/helper-validator-option" "^7.29.7" browserslist "^4.24.0" lru-cache "^5.1.1" semver "^6.3.1" -"@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/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/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/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/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== +"@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/types" "^7.28.5" + "@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== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -170,12 +286,19 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -"@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== +"@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.27.1" + "@babel/helper-plugin-utils" "^7.29.7" "@babel/plugin-syntax-import-meta@^7.10.4": version "7.10.4" @@ -191,13 +314,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@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" - "@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 +335,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@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": 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,160 +370,609 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -"@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/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/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== +"@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: - esutils "^2.0.2" - lodash "^4.17.11" - to-fast-properties "^2.0.0" + "@babel/helper-plugin-utils" "^7.29.7" -"@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== +"@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-string-parser" "^7.27.1" - "@babel/helper-validator-identifier" "^7.28.5" + "@babel/helper-plugin-utils" "^7.29.7" + "@babel/helper-remap-async-to-generator" "^7.29.7" + "@babel/traverse" "^7.29.7" -"@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== +"@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" -"@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== +"@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: - "@emnapi/wasi-threads" "1.1.0" - tslib "^2.4.0" + "@babel/helper-plugin-utils" "^7.29.7" -"@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== +"@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: - tslib "^2.4.0" + "@babel/helper-plugin-utils" "^7.29.7" -"@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== +"@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: - tslib "^2.4.0" + "@babel/helper-module-transforms" "^7.29.7" + "@babel/helper-plugin-utils" "^7.29.7" -"@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== +"@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.1": +"@eslint-community/regexpp@^4.12.2": 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== -"@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== +"@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" "^2.1.7" + "@eslint/object-schema" "^3.0.5" debug "^4.3.1" - minimatch "^3.1.2" + minimatch "^10.2.4" -"@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== +"@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" "^0.17.0" + "@eslint/core" "^1.2.1" -"@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== +"@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/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== +"@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" "^0.17.0" + "@eslint/core" "^1.2.1" 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/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.7" - resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.7.tgz#822cb7b3a12c5a240a24f621b5a2413e27a45f26" - integrity sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ== + 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.1" + "@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== + "@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,18 +983,6 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba" integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ== -"@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" - "@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,230 +995,206 @@ resolve-from "^5.0.0" "@istanbuljs/schema@^0.1.2", "@istanbuljs/schema@^0.1.3": - 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== + 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: - "@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-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.0.5": - version "30.0.5" - resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-30.0.5.tgz#7bdf69fc5a368a5abdb49fd91036c55225846473" - integrity sha512-DmdYgtezMkh3cpU8/1uyXakv3tJRcmcXxBOcO0tbaozPwpmh4YMsnWrQm9ZmZMfa5ocbxzbFk6O4bDPEc/iAnA== +"@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/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== +"@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: - "@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" + callsites "^3.0.0" + graceful-fs "^4.1.15" + source-map "^0.6.0" -"@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== +"@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" "30.2.0" - "@jest/types" "30.2.0" - "@types/istanbul-lib-coverage" "^2.0.6" - collect-v8-coverage "^1.0.2" + "@jest/console" "^24.9.0" + "@jest/types" "^24.9.0" + "@types/istanbul-lib-coverage" "^2.0.0" -"@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== +"@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" "30.2.0" - graceful-fs "^4.2.11" - jest-haste-map "30.2.0" - slash "^3.0.0" + "@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.2.0": - version "30.2.0" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-30.2.0.tgz#54bef1a4510dcbd58d5d4de4fe2980a63077ef2a" - integrity sha512-XsauDV82o5qXbhalKxD7p4TZYYdwcaEXC77PPD2HixEFF+6YGppjrAAQurTl2ECWcEomHBMMNS9AH3kcCFx8jA== +"@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.2.0" + "@jest/types" "30.4.1" "@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" - 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" pirates "^4.0.7" slash "^3.0.0" write-file-atomic "^5.0.1" -"@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== +"@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: - "@jest/pattern" "30.0.1" - "@jest/schemas" "30.0.5" + "@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" "@types/istanbul-lib-coverage" "^2.0.6" "@types/istanbul-reports" "^3.0.4" "@types/node" "*" "@types/yargs" "^17.0.33" chalk "^4.1.2" +"@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" + "@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 +1221,7 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz#6912b00d2c631c0d15ce1a7ab57cd657f2a8f8ba" integrity sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og== -"@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": version "0.3.31" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz#db15d6781c931f3a251a3dac39501c98a6082fd0" integrity sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw== @@ -700,52 +1229,24 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@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" + version "0.34.49" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.34.49.tgz#4f1369234f2ecf693866476c3b2e1b54d2a9d68e" + integrity sha512-brySQQs7Jtn0joV8Xh9ZV/hZb9Ozb0pmazDIASBkYKCjXrXU3mpcFahmK/z4YDhGkQvP9mWJbVyahdtU5wQA+A== -"@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== +"@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: - tslib "^2.4.0" + "@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.20.5": +"@types/babel__core@^7.1.0", "@types/babel__core@^7.20.5": version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA== @@ -757,33 +1258,38 @@ "@types/babel__traverse" "*" "@types/babel__generator@*": - 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== dependencies: "@babel/types" "^7.0.0" "@types/babel__template@*": - 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== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" -"@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== +"@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.3.0" + "@babel/types" "^7.28.2" -"@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/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/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.1", "@types/istanbul-lib-coverage@^2.0.6": +"@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": 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 +1301,14 @@ dependencies: "@types/istanbul-lib-coverage" "*" +"@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" "*" + "@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,22 +1322,29 @@ integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== "@types/node@*": - version "25.0.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-25.0.2.tgz#411f9dd6cb2bf5ee46aed7199a9f85ca6b068b4e" - integrity sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA== + 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.16.0" + undici-types ">=7.24.0 <7.24.7" -"@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== +"@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== "@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== +"@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" "*" + "@types/yargs@^17.0.33": version "17.0.35" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.35.tgz#07013e46aa4d7d7d50a49e15604c1c5340d4eb24" @@ -831,168 +1352,100 @@ dependencies: "@types/yargs-parser" "*" +"@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.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== + 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" 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== -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== +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== -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@^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== 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" -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-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@^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@^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@^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-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.1: +ansi-styles@^3.2.0, ansi-styles@^3.2.1: 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" -ansi-styles@^4.0.0, ansi-styles@^4.1.0: +ansi-styles@^4.1.0: 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" -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" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" anymatch@^3.1.3: version "3.1.3" @@ -1009,24 +1462,161 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -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== +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== -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== +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: - "@jest/transform" "30.2.0" + 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.2.0" + babel-preset-jest "30.4.0" chalk "^4.1.2" graceful-fs "^4.2.11" slash "^3.0.0" +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" + 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,13 +1628,44 @@ babel-plugin-istanbul@^7.0.1: istanbul-lib-instrument "^6.0.2" test-exclude "^6.0.0" -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== +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" + 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,56 +1687,117 @@ 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" -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== +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.2.0" + 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.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + 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" -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== +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.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + version "1.1.15" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.15.tgz#a6d90d54067236e5f42570a3b7378d594d9b7738" + integrity sha512-EwOCDEex4quD37XhqM3omwtMoJjr//isUZz1JopUNWms+4Z2ViyM/k1YIRePpoVNnQhENnxtFjLaxNHrT7xIUg== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" -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" +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== -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== +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: - fill-range "^7.1.1" + resolve "1.1.7" -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== +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.9.0" - caniuse-lite "^1.0.30001759" - electron-to-chromium "^1.5.263" - node-releases "^2.0.27" - update-browserslist-db "^1.2.0" + 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" bser@2.1.1: version "2.1.1" @@ -1125,36 +1807,79 @@ bser@2.1.1: node-int64 "^0.4.0" buffer-from@^1.0.0: - 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== + 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== -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 "3.1.0" +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: + version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -camelcase@^5.3.1: +camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -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.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" -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== +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.0: +chalk@^2.0.1, chalk@^2.4.2: 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 +1888,7 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0, chalk@^4.1.2: +chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1171,39 +1896,47 @@ chalk@^4.0.0, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -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@^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.3.1" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-4.3.1.tgz#355ad571920810b5623e11d40232f443f16f1daa" - integrity sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA== + version "4.4.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-4.4.0.tgz#7d54eff9f54b45b62401c26032696eb59c8bd18c" + integrity sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg== -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== +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@^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== +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 "^4.2.0" - strip-ansi "^6.0.1" - wrap-ansi "^7.0.0" + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" - integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= + integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== -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== +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" color-convert@^1.9.0: version "1.9.3" @@ -1222,24 +1955,69 @@ 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" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== 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== +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 sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + 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== 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== -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: version "7.0.6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== @@ -1248,73 +2026,295 @@ cross-spawn@^7.0.3, cross-spawn@^7.0.6: shebang-command "^2.0.0" which "^2.0.1" -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== +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: - ms "^2.1.1" + call-bound "^1.0.3" + es-errors "^1.3.0" + is-data-view "^1.0.2" -debug@^4.3.1, debug@^4.3.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: 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" -dedent@^1.6.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.7.0.tgz#c1f9445335f0175a96587be245a282ff451446ca" - integrity sha512-HGFtf8yhuhGhqO07SV79tRp+br4MnbdjeVxotpn1QBl30pcLLCQjX5b2295ll0fv8RKDKsmWYrl05usHM9CewQ== +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, deep-is@~0.1.3: 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== -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== +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" -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== +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" -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== +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" -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== +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" -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== +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== -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== +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@^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== +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.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + 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" -escalade@^3.1.1, escalade@^3.2.0: +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: version "3.2.0" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== @@ -1322,7 +2322,7 @@ 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" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== escape-string-regexp@^2.0.0: version "2.0.0" @@ -1334,11 +2334,25 @@ 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== -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== +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" esrecurse "^4.3.0" estraverse "^5.2.0" @@ -1352,32 +2366,34 @@ 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== -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== +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.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-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" "@humanfs/node" "^0.16.6" "@humanwhocodes/module-importer" "^1.0.1" "@humanwhocodes/retry" "^0.4.2" "@types/estree" "^1.0.6" - ajv "^6.12.4" - chalk "^4.0.0" + ajv "^6.14.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" + eslint-scope "^9.1.2" + eslint-visitor-keys "^5.0.1" + espree "^11.2.0" + esquery "^1.7.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^8.0.0" @@ -1387,12 +2403,11 @@ eslint@^9.39.2: imurmurhash "^0.1.4" is-glob "^4.0.0" json-stable-stringify-without-jsonify "^1.0.1" - lodash.merge "^4.6.2" - minimatch "^3.1.2" + minimatch "^10.2.4" natural-compare "^1.4.0" optionator "^0.9.3" -espree@^10.0.1, espree@^10.4.0: +espree@^10.4.0: version "10.4.0" resolved "https://registry.yarnpkg.com/espree/-/espree-10.4.0.tgz#d54f4949d4629005a1fa168d937c3ff1f7e2a837" integrity sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ== @@ -1401,15 +2416,24 @@ espree@^10.0.1, espree@^10.4.0: acorn-jsx "^5.3.2" eslint-visitor-keys "^4.2.1" -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: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -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== dependencies: estraverse "^5.1.0" @@ -1420,69 +2444,129 @@ esrecurse@^4.3.0: dependencies: estraverse "^5.2.0" -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: 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: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -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" +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== -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== +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== -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" +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== 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== -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: 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== -fast-levenshtein@^2.0.6: +fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== -fb-watchman@^2.0.2: +fb-watchman@^2.0.0, fb-watchman@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== @@ -1496,14 +2580,29 @@ file-entry-cache@^8.0.0: dependencies: flat-cache "^4.0.0" -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== +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: - to-regex-range "^5.0.1" + locate-path "^3.0.0" -find-up@^4.0.0, find-up@^4.1.0: +find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== @@ -1528,47 +2627,154 @@ flat-cache@^4.0.0: keyv "^4.5.4" flatted@^3.2.9: - version "3.3.3" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358" - integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== + version "3.4.2" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.4.2.tgz#f5c23c107f0f37de8dbdf24f13722b3b98d52726" + integrity sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA== -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== +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: - cross-spawn "^7.0.6" - signal-exit "^4.0.1" + 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" fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - 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" 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== +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== + 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== -get-caller-file@^2.0.5: +get-caller-file@^2.0.1: 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== +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" + 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== -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" glob-parent@^6.0.2: version "6.0.2" @@ -1577,19 +2783,7 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" -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: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -1601,525 +2795,981 @@ glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -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== +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.2.11: +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.2.11: 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== +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 sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== 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== +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" + 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== -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" 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== -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== +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 "^4.2.0" - resolve-cwd "^3.0.0" + pkg-dir "^3.0.0" + resolve-cwd "^2.0.0" imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" wrappy "1" inherits@2: - 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" is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== -is-extglob@^2.1.1: +is-async-function@^2.0.0: version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -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== + 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-generator-fn@^2.1.0: - 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== +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-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" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== +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: - is-extglob "^2.1.1" + call-bound "^1.0.3" + has-tostringtag "^1.0.2" -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-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-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-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== -isexe@^2.0.0: +is-ci@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" -istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: - 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== +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" -istanbul-lib-instrument@^6.0.0, istanbul-lib-instrument@^6.0.2: - 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== +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: - "@babel/core" "^7.23.9" - "@babel/parser" "^7.23.9" - "@istanbuljs/schema" "^0.1.3" - istanbul-lib-coverage "^3.2.0" - semver "^7.5.4" + hasown "^2.0.0" -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== +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: - istanbul-lib-coverage "^3.0.0" - make-dir "^4.0.0" - supports-color "^7.1.0" + call-bound "^1.0.2" + get-intrinsic "^1.2.6" + is-typed-array "^1.1.13" -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== +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: - "@jridgewell/trace-mapping" "^0.3.23" - debug "^4.1.1" - istanbul-lib-coverage "^3.0.0" + call-bound "^1.0.2" + has-tostringtag "^1.0.2" -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== +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: - html-escaper "^2.0.0" - istanbul-lib-report "^3.0.0" + is-accessor-descriptor "^1.0.1" + is-data-descriptor "^1.0.1" -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== +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: - "@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" + is-accessor-descriptor "^1.0.2" + is-data-descriptor "^1.0.1" -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== +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: - "@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== + is-plain-object "^2.0.4" + +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== + +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: - "@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" + 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: + 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== -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== +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: - "@jest/diff-sequences" "30.0.1" - "@jest/get-type" "30.1.0" - chalk "^4.1.2" - pretty-format "30.2.0" + 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" -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== +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" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: - detect-newline "^3.1.0" + is-extglob "^2.1.1" + +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== -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== +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: - "@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" + call-bound "^1.0.3" + has-tostringtag "^1.0.2" -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== +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: - "@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" + kind-of "^3.0.2" -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== +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: - "@jest/types" "30.2.0" - "@types/node" "*" - anymatch "^3.1.3" - fb-watchman "^2.0.2" - graceful-fs "^4.2.11" - jest-regex-util "30.0.1" - jest-util "30.2.0" - jest-worker "30.2.0" - micromatch "^4.0.8" - walker "^1.0.8" - optionalDependencies: - fsevents "^2.3.3" + isobject "^3.0.1" -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== +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: - "@jest/get-type" "30.1.0" - pretty-format "30.2.0" + 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== -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== +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: - "@jest/get-type" "30.1.0" - chalk "^4.1.2" - jest-diff "30.2.0" - pretty-format "30.2.0" + 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== -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== +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: - "@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" + call-bound "^1.0.3" + has-tostringtag "^1.0.2" -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== +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: - "@jest/types" "30.2.0" - "@types/node" "*" - jest-util "30.2.0" + call-bound "^1.0.2" + has-symbols "^1.1.0" + safe-regex-test "^1.1.0" -jest-pnp-resolver@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" - integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== +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" -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== +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== -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== +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: - jest-regex-util "30.0.1" - jest-snapshot "30.2.0" + call-bound "^1.0.3" -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== +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: - 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" + 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== -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== +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== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + 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: - "@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" + 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: + 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== + +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: + 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== + dependencies: + "@babel/core" "^7.23.9" + "@babel/parser" "^7.23.9" + "@istanbuljs/schema" "^0.1.3" + istanbul-lib-coverage "^3.2.0" + semver "^7.5.4" + +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" "@types/node" "*" - chalk "^4.1.2" - ci-info "^4.2.0" + anymatch "^3.1.3" + fb-watchman "^2.0.2" graceful-fs "^4.2.11" - picomatch "^4.0.2" + jest-regex-util "30.4.0" + jest-util "30.4.1" + jest-worker "30.4.1" + picomatch "^4.0.3" + walker "^1.0.8" + optionalDependencies: + fsevents "^2.3.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: + version "1.2.3" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" + integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== -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== +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: - "@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" + "@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-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== +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/test-result" "30.2.0" - "@jest/types" "30.2.0" + "@jest/types" "30.4.1" "@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" + ci-info "^4.2.0" + graceful-fs "^4.2.11" + 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-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== +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.2.0" + jest-util "30.4.1" 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== +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: - "@jest/core" "30.2.0" - "@jest/types" "30.2.0" - import-local "^3.2.0" - jest-cli "30.2.0" + 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@^4.0.0: +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== @@ -2132,14 +3782,44 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -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" + 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: version "3.1.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.1.0.tgz#74d335a234f67ed19907fdadfac7ccf9d409825d" integrity sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA== @@ -2149,26 +3829,46 @@ 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== -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== 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== +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 sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + 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== 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== +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" + keyv@^4.5.4: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -2176,6 +3876,35 @@ keyv@^4.5.4: dependencies: json-buffer "3.0.1" +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== + leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -2189,10 +3918,31 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -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" locate-path@^5.0.0: version "5.0.0" @@ -2208,20 +3958,27 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" -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.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@^4.17.11: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== +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== -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@^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" lru-cache@^5.1.1: version "5.1.1" @@ -2230,12 +3987,13 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" -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== +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: - semver "^7.5.3" + pify "^4.0.1" + semver "^5.6.0" makeerror@1.0.12: version "1.0.12" @@ -2244,105 +4002,271 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" +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== + 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== -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== +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" -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" +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== -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== +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: - brace-expansion "^2.0.1" + for-in "^1.0.2" + is-extendable "^1.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== +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.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== +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== 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== -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" natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - 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== node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" - 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" 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== -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== +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 "^3.0.0" + path-key "^2.0.0" -once@^1.3.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 sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== 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== +optionator@^0.8.1: + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== dependencies: - mimic-fn "^2.1.0" + 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" optionator@^0.9.3: version "0.9.4" @@ -2356,20 +4280,53 @@ optionator@^0.9.3: type-check "^0.4.0" word-wrap "^1.2.5" -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: 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" -p-limit@^3.0.2, p-limit@^3.1.0: +p-limit@^3.0.2: 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" +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" + p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -2384,32 +4341,38 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" -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: +p-reduce@^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" + 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@^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== +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: - "@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" + 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== path-exists@^4.0.0: version "4.0.0" @@ -2419,113 +4382,497 @@ 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" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + 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.0.0, path-key@^3.1.0: +path-key@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -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== +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: - lru-cache "^10.2.0" - minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + 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== 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== -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@^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.2: - version "4.0.3" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.3.tgz#796c76136d1eead715db1e7bad785dedd695a042" - integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q== +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.7: +pirates@^4.0.1, pirates@^4.0.7: version "4.0.7" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.7.tgz#643b4a18c4257c8a65104b73f3049ce9a0a15e22" integrity sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA== -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== +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 "^4.0.0" + 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== 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== -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== +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/schemas" "30.0.5" - ansi-styles "^5.2.0" - react-is "^18.3.1" + "@jest/types" "^24.9.0" + ansi-regex "^4.0.0" + ansi-styles "^3.2.0" + react-is "^16.8.4" -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== +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" -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== +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== -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== +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.10: +readline-sync@^1.4.9: 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== +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 sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -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== +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 "^5.0.0" + resolve-from "^3.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== +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== 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== -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: version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -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" shebang-command@^2.0.0: version "2.0.0" @@ -2534,12 +4881,62 @@ shebang-command@^2.0.0: dependencies: shebang-regex "^3.0.0" +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== + 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== -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: 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 +4946,119 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== +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== + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -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== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" -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: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -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: 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,85 +5066,123 @@ 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" - 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== + 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" -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== +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: - char-regex "^1.0.2" - strip-ansi "^6.0.0" + define-property "^0.2.5" + object-copy "^0.1.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" +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== -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== +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: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" + es-errors "^1.3.0" + internal-slot "^1.1.0" -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== +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: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" + astral-regex "^1.0.0" + strip-ansi "^4.0.0" -"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== +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: - ansi-regex "^5.0.1" + call-bind "^1.0.7" + define-properties "^1.2.1" + es-object-atoms "^1.0.0" -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== +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 "^5.0.1" + ansi-regex "^3.0.0" -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== +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 "^6.0.1" + ansi-regex "^4.1.0" -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-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-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== +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== supports-color@^5.3.0: version "5.5.0" @@ -2662,6 +5191,13 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +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" + 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 +5212,25 @@ supports-color@^8.1.1: dependencies: has-flag "^4.0.0" -synckit@^0.11.8: - version "0.11.11" - resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.11.tgz#c0b619cf258a97faa209155d9cd1699b5c998cb0" - integrity sha512-MeQTA1r0litLUf0Rp/iisCaL8761lKAZHaimlbGK4j0HysC4PLfqygQj9srcs0m2RdtDYnF8UuYyKpbjHYp7Jw== +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: - "@pkgr/core" "^0.2.9" + glob "^7.1.3" + minimatch "^3.0.4" + read-pkg-up "^4.0.0" + require-main-filename "^2.0.0" test-exclude@^6.0.0: version "6.0.0" @@ -2692,32 +5241,74 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -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" 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== -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-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@^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== +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: - is-number "^7.0.0" + 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" -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== +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== type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" @@ -2726,79 +5317,293 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -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-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" -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== +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" -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== +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" -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== +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: - 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== + 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== dependencies: escalade "^3.2.0" picocolors "^1.1.1" uri-js@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" - integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + 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" -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== +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: - "@jridgewell/trace-mapping" "^0.3.12" - "@types/istanbul-lib-coverage" "^2.0.1" - convert-source-map "^2.0.0" + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" -walker@^1.0.8: +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: 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" +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" + which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -2806,42 +5611,33 @@ which@^2.0.1: dependencies: isexe "^2.0.0" -word-wrap@^1.2.5: +word-wrap@^1.2.5, word-wrap@~1.2.3: version "1.2.5" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"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== +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 "^6.1.0" - string-width "^5.0.1" - strip-ansi "^7.0.1" + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - 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" write-file-atomic@^5.0.1: version "5.0.1" @@ -2851,33 +5647,51 @@ write-file-atomic@^5.0.1: imurmurhash "^0.1.4" signal-exit "^4.0.1" -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== yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== -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-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@^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== +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 "^8.0.1" - escalade "^3.1.1" - get-caller-file "^2.0.5" + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.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" yocto-queue@^0.1.0: version "0.1.0"