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
package/dist/cli/ltc.js
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
import { compile } from '../index.js';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
-
import { getAllFiles, ensureDirectoryExistence, style } from './utils.js';
|
|
5
|
+
import { getAllFiles, ensureDirectoryExistence, style, getPackageVersion } from './utils.js';
|
|
6
6
|
const args = process.argv.slice(2);
|
|
7
7
|
const command = args[0];
|
|
8
8
|
if (!command) {
|
|
9
9
|
printUsage();
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
|
+
if (command === '-v' || command === '--version') {
|
|
13
|
+
console.log(`v${getPackageVersion()}`);
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
12
16
|
switch (command) {
|
|
13
17
|
case 'watch':
|
|
14
18
|
handleWatch(args.slice(1));
|
|
@@ -23,7 +27,7 @@ switch (command) {
|
|
|
23
27
|
}
|
|
24
28
|
function printUsage() {
|
|
25
29
|
console.log(`
|
|
26
|
-
${style.bold('LT Language Compiler')} ${style.gray(
|
|
30
|
+
${style.bold('LT Language Compiler')} ${style.gray(`(v${getPackageVersion()})`)}
|
|
27
31
|
${style.gray('----------------------------------------')}
|
|
28
32
|
|
|
29
33
|
${style.bold('Usage:')}
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function getAllFiles(dir: string, extension: string, fileList?: string[]): string[];
|
|
2
2
|
export declare function ensureDirectoryExistence(filePath: string): void;
|
|
3
|
+
export declare function getPackageVersion(): string;
|
|
3
4
|
export declare const colors: {
|
|
4
5
|
reset: string;
|
|
5
6
|
bright: string;
|
package/dist/cli/utils.js
CHANGED
|
@@ -24,6 +24,27 @@ export function ensureDirectoryExistence(filePath) {
|
|
|
24
24
|
ensureDirectoryExistence(dirname);
|
|
25
25
|
fs.mkdirSync(dirname);
|
|
26
26
|
}
|
|
27
|
+
export function getPackageVersion() {
|
|
28
|
+
try {
|
|
29
|
+
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
30
|
+
// Navigate up from dist/cli/utils.js to package.json
|
|
31
|
+
// dist/cli -> dist -> root
|
|
32
|
+
const packageJsonPath = path.resolve(__dirname, '../../package.json');
|
|
33
|
+
// Handle Windows path issues with URL pathname usually having leading slash
|
|
34
|
+
const adjustedPath = process.platform === 'win32' && packageJsonPath.startsWith('\\')
|
|
35
|
+
? packageJsonPath.substring(1)
|
|
36
|
+
: packageJsonPath;
|
|
37
|
+
if (fs.existsSync(adjustedPath)) {
|
|
38
|
+
const content = fs.readFileSync(adjustedPath, 'utf-8');
|
|
39
|
+
const pkg = JSON.parse(content);
|
|
40
|
+
return pkg.version || '1.0.0';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
// Fallback or dev environment handling
|
|
45
|
+
}
|
|
46
|
+
return '1.0.5'; // Fallback to current known version
|
|
47
|
+
}
|
|
27
48
|
export const colors = {
|
|
28
49
|
reset: "\x1b[0m",
|
|
29
50
|
bright: "\x1b[1m",
|
|
@@ -227,8 +227,6 @@ export class LuaEmitter {
|
|
|
227
227
|
return this.hasSideEffects(node.left) || this.hasSideEffects(node.right);
|
|
228
228
|
case AST.NodeType.UnaryExpr:
|
|
229
229
|
return this.hasSideEffects(node.operand);
|
|
230
|
-
case AST.NodeType.CallExpr:
|
|
231
|
-
return true; // Calls ALWAYS have side effects
|
|
232
230
|
case AST.NodeType.TableLiteral:
|
|
233
231
|
return node.fields.some(f => this.hasSideEffects(f.value) || (f.key && f.key.kind !== AST.NodeType.Identifier && this.hasSideEffects(f.key)));
|
|
234
232
|
case AST.NodeType.VectorLiteral:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NATIVE_NAMES: ReadonlySet<string>;
|