lt-script 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/ltc.js +6 -2
- package/dist/cli/utils.d.ts +1 -0
- package/dist/cli/utils.js +21 -0
- package/dist/compiler/codegen/LuaEmitter.js +0 -2
- package/dist/compiler/natives/NativeLoader.d.ts +4 -0
- package/dist/compiler/natives/NativeLoader.js +7 -0
- package/dist/compiler/natives/NativeNames.d.ts +1 -0
- package/dist/compiler/natives/NativeNames.js +7288 -0
- package/dist/compiler/semantics/SemanticAnalyzer.js +18 -22
- package/package.json +4 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as AST from '../parser/AST.js';
|
|
2
|
+
import { isNative } from '../natives/NativeLoader.js';
|
|
2
3
|
class Scope {
|
|
3
4
|
symbols = new Map();
|
|
4
5
|
parent;
|
|
@@ -418,34 +419,29 @@ export class SemanticAnalyzer {
|
|
|
418
419
|
if (expr.kind === AST.NodeType.Identifier) {
|
|
419
420
|
const id = expr;
|
|
420
421
|
const sym = this.currentScope.lookup(id.name);
|
|
421
|
-
//
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const luaGlobals = ['print', 'type', 'tostring', 'tonumber', 'pairs', 'ipairs',
|
|
422
|
+
// Lua core globals (standard library)
|
|
423
|
+
const luaCoreGlobals = [
|
|
424
|
+
'print', 'type', 'tostring', 'tonumber', 'pairs', 'ipairs',
|
|
425
425
|
'next', 'error', 'assert', 'pcall', 'xpcall', 'require',
|
|
426
426
|
'table', 'string', 'math', 'os', 'io', 'coroutine', 'debug',
|
|
427
427
|
'setmetatable', 'getmetatable', 'rawget', 'rawset', 'rawequal',
|
|
428
428
|
'collectgarbage', 'dofile', 'load', 'loadfile', 'select',
|
|
429
429
|
'unpack', '_G', '_VERSION', 'true', 'false', 'nil',
|
|
430
|
-
// FiveM
|
|
431
|
-
'Citizen', '
|
|
432
|
-
'
|
|
433
|
-
'
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
'Config', 'Framework', 'MySQL', 'lib', 'cache', 'json',
|
|
440
|
-
'NetworkGetNetworkIdFromEntity', 'NetworkGetEntityFromNetworkId',
|
|
441
|
-
'GetPlayerPed', 'GetVehiclePedIsIn', 'IsPedInAnyVehicle',
|
|
442
|
-
'SetPedCanRagdoll', 'SetTimeout', 'SetInterval', 'ClearTimeout',
|
|
443
|
-
'GetHashKey', 'IsModelValid', 'RequestModel', 'HasModelLoaded'];
|
|
444
|
-
if (!sym && !luaGlobals.includes(id.name)) {
|
|
445
|
-
// Check if it's a type name (not a variable)
|
|
446
|
-
if (!this.typeRegistry.has(id.name) && !this.typeAliasRegistry.has(id.name)) {
|
|
447
|
-
throw new Error(`Undefined variable '${id.name}' at line ${id.line ?? 0}`);
|
|
430
|
+
// FiveM framework globals (not in natives.lt)
|
|
431
|
+
'Citizen', 'exports', 'source', 'ESX', 'QBCore', 'Config',
|
|
432
|
+
'Framework', 'MySQL', 'lib', 'cache', 'json', 'LocalPlayer',
|
|
433
|
+
'vector2', 'vector3', 'vector4'
|
|
434
|
+
];
|
|
435
|
+
if (!sym && !luaCoreGlobals.includes(id.name)) {
|
|
436
|
+
// Check if it's a type name
|
|
437
|
+
if (this.typeRegistry.has(id.name) || this.typeAliasRegistry.has(id.name)) {
|
|
438
|
+
return;
|
|
448
439
|
}
|
|
440
|
+
// Check if it's a FiveM/CFX native (from natives.lt)
|
|
441
|
+
if (isNative(id.name)) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
throw new Error(`Undefined variable '${id.name}' at line ${id.line ?? 0}`);
|
|
449
445
|
}
|
|
450
446
|
return;
|
|
451
447
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lt-script",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "LT Language Compiler for FiveM",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"scripts": {
|
|
28
|
-
"
|
|
28
|
+
"generate:natives": "tsx tools/generate_native_names.ts",
|
|
29
|
+
"prebuild": "npm run generate:natives",
|
|
30
|
+
"build": "npm run prebuild && tsc",
|
|
29
31
|
"dev": "tsc --watch",
|
|
30
32
|
"test": "node dist/tests/run.js",
|
|
31
33
|
"build:lt": "npm run build",
|