|
|
|
@ -1,17 +1,17 @@
|
|
|
|
/* eslint-disable import/order */
|
|
|
|
/* eslint-disable import/order */
|
|
|
|
/* eslint-disable import/no-duplicates */
|
|
|
|
/* eslint-disable import/no-duplicates */
|
|
|
|
|
|
|
|
import { LuaError } from './LuaError'
|
|
|
|
import { Scope } from './Scope'
|
|
|
|
import { Scope } from './Scope'
|
|
|
|
import { createG } from './lib/globals'
|
|
|
|
|
|
|
|
import { operators } from './operators'
|
|
|
|
|
|
|
|
import { Table } from './Table'
|
|
|
|
import { Table } from './Table'
|
|
|
|
import { LuaError } from './LuaError'
|
|
|
|
import { createG } from './lib/globals'
|
|
|
|
import { libMath } from './lib/math'
|
|
|
|
import { libMath } from './lib/math'
|
|
|
|
import { libTable } from './lib/table'
|
|
|
|
|
|
|
|
import { libString, metatable as stringMetatable } from './lib/string'
|
|
|
|
|
|
|
|
import { getLibOS } from './lib/os'
|
|
|
|
import { getLibOS } from './lib/os'
|
|
|
|
import { getLibPackage } from './lib/package'
|
|
|
|
import { getLibPackage } from './lib/package'
|
|
|
|
import { LuaType, ensureArray, Config } from './utils'
|
|
|
|
import { libString, metatable as stringMetatable } from './lib/string'
|
|
|
|
|
|
|
|
import { libTable } from './lib/table'
|
|
|
|
|
|
|
|
import { operators } from './operators'
|
|
|
|
import { parse as parseScript } from './parser'
|
|
|
|
import { parse as parseScript } from './parser'
|
|
|
|
|
|
|
|
import { Config, LuaType, ensureArray } from './utils'
|
|
|
|
|
|
|
|
|
|
|
|
interface Script {
|
|
|
|
interface Script {
|
|
|
|
exec: () => LuaType
|
|
|
|
exec: () => LuaType
|
|
|
|
@ -61,13 +61,14 @@ function createEnv(
|
|
|
|
LUA_PATH: './?.lua',
|
|
|
|
LUA_PATH: './?.lua',
|
|
|
|
stdin: '',
|
|
|
|
stdin: '',
|
|
|
|
stdout: console.log,
|
|
|
|
stdout: console.log,
|
|
|
|
|
|
|
|
encoding: 'x-user-defined',
|
|
|
|
...config
|
|
|
|
...config
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const _G = createG(cfg, execChunk)
|
|
|
|
const _G = createG(cfg, execChunk)
|
|
|
|
|
|
|
|
|
|
|
|
const { libPackage, _require } = getLibPackage(
|
|
|
|
const { libPackage, _require } = getLibPackage(
|
|
|
|
(content, moduleName) => execChunk(_G, parseScript(content), moduleName)[0],
|
|
|
|
(content, moduleName) => execChunk(_G, parseScript(content, cfg.encoding), moduleName)[0],
|
|
|
|
cfg
|
|
|
|
cfg
|
|
|
|
)
|
|
|
|
)
|
|
|
|
const loaded = libPackage.get('loaded') as Table
|
|
|
|
const loaded = libPackage.get('loaded') as Table
|
|
|
|
@ -111,4 +112,5 @@ function createEnv(
|
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line import/first
|
|
|
|
// eslint-disable-next-line import/first
|
|
|
|
import * as utils from './utils'
|
|
|
|
import * as utils from './utils'
|
|
|
|
export { createEnv, Table, LuaError, utils }
|
|
|
|
export { LuaError, Table, createEnv, utils }
|
|
|
|
|
|
|
|
|
|
|
|
|