@thigasdevelopment/luam 0.6.0 → 0.8.0
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/luam.mjs +24 -11
- package/package.json +1 -1
package/luam.mjs
CHANGED
|
@@ -4328,7 +4328,7 @@ function parseClassMethod(stream, token, decorators) {
|
|
|
4328
4328
|
position: token.position
|
|
4329
4329
|
};
|
|
4330
4330
|
}
|
|
4331
|
-
function
|
|
4331
|
+
function parseBraceClassMethod(stream, token, decorators) {
|
|
4332
4332
|
const parameters = parseParameters(stream);
|
|
4333
4333
|
const returnAnnotation = parseOptionalAnnotation(stream);
|
|
4334
4334
|
const body = parseBraceBlock(stream);
|
|
@@ -4359,7 +4359,8 @@ function parseClassMember(stream) {
|
|
|
4359
4359
|
const decorators = parseDecorators(stream);
|
|
4360
4360
|
const token = stream.expectName();
|
|
4361
4361
|
if (stream.check("punctuation", "(")) {
|
|
4362
|
-
|
|
4362
|
+
stream.report("parse-class-method-form", `Write class member "${token.value}" as "${token.value} = function (...) ... end".`, token.position);
|
|
4363
|
+
return parseBraceClassMethod(stream, token, decorators);
|
|
4363
4364
|
}
|
|
4364
4365
|
if (stream.check("operator", "=") && stream.checkAhead(1, "keyword", "function")) {
|
|
4365
4366
|
return parseClassMethod(stream, token, decorators);
|
|
@@ -5943,7 +5944,7 @@ import { tmpdir } from "node:os";
|
|
|
5943
5944
|
import { join as join2 } from "node:path";
|
|
5944
5945
|
|
|
5945
5946
|
// src/cli/version.ts
|
|
5946
|
-
var VERSION = true ? "0.
|
|
5947
|
+
var VERSION = true ? "0.8.0" : "0.0.0-dev";
|
|
5947
5948
|
var PROGRAM_NAME = "luam";
|
|
5948
5949
|
var PROGRAM_DESCRIPTION = "luam \u2014 the Luam compiler for Multi Theft Auto resources.";
|
|
5949
5950
|
|
|
@@ -11781,6 +11782,11 @@ function scopeLabel(environment) {
|
|
|
11781
11782
|
return environment === "shared" ? "shared" : `${environment}-only`;
|
|
11782
11783
|
}
|
|
11783
11784
|
function checkGlobalReference(context, name, position2) {
|
|
11785
|
+
if (name === "self") {
|
|
11786
|
+
const message2 = 'A "self" is only bound inside a class method or a "function Name:method()"; here it reads a global that is "nil".';
|
|
11787
|
+
context.report("check-invalid-self", message2, position2);
|
|
11788
|
+
return;
|
|
11789
|
+
}
|
|
11784
11790
|
const project = context.projectEnvironmentOf(name);
|
|
11785
11791
|
if (project !== null) {
|
|
11786
11792
|
const message2 = `"${name}" is declared by the project, is ${scopeLabel(project)}, and is not available in a "${context.environment}" file.`;
|
|
@@ -12426,6 +12432,13 @@ function fieldType(context, member) {
|
|
|
12426
12432
|
}
|
|
12427
12433
|
return declared;
|
|
12428
12434
|
}
|
|
12435
|
+
function checkFieldName(context, member) {
|
|
12436
|
+
if (member.name !== "constructor") {
|
|
12437
|
+
return;
|
|
12438
|
+
}
|
|
12439
|
+
const message = 'A "constructor" is the class constructor, not a field. Write it as "constructor = function (...) ... end" or rename the field.';
|
|
12440
|
+
context.report("check-invalid-constructor", message, member.position);
|
|
12441
|
+
}
|
|
12429
12442
|
function generatedMethodType(member, fieldTypes) {
|
|
12430
12443
|
const fieldType2 = [...fieldTypes].find(([field2]) => field2.position.offset === member.position.offset)?.[1] ?? ANY_TYPE;
|
|
12431
12444
|
return member.parameters.length === 0 ? createFunction([], fieldType2) : createFunction([fieldType2], VOID_TYPE);
|
|
@@ -12434,6 +12447,7 @@ function registerMembers(context, info, statement) {
|
|
|
12434
12447
|
const fieldTypes = /* @__PURE__ */ new Map();
|
|
12435
12448
|
for (const member of statement.members) {
|
|
12436
12449
|
if (member.kind === "class-field") {
|
|
12450
|
+
checkFieldName(context, member);
|
|
12437
12451
|
fieldTypes.set(member, fieldType(context, member));
|
|
12438
12452
|
}
|
|
12439
12453
|
}
|
|
@@ -13187,9 +13201,9 @@ function containsJump(body, kind) {
|
|
|
13187
13201
|
return inClause || statement.alternate !== null && containsJump(statement.alternate, kind);
|
|
13188
13202
|
});
|
|
13189
13203
|
}
|
|
13190
|
-
function emitNested(state, body,
|
|
13204
|
+
function emitNested(state, body, wrapped) {
|
|
13191
13205
|
const previous = state.loopWrap;
|
|
13192
|
-
state.loopWrap =
|
|
13206
|
+
state.loopWrap = wrapped;
|
|
13193
13207
|
try {
|
|
13194
13208
|
return emitBlock(state, body);
|
|
13195
13209
|
} finally {
|
|
@@ -13858,10 +13872,9 @@ function collectBundles(helpers, scripts, pinned) {
|
|
|
13858
13872
|
return members.length === 0 ? [] : [{ path: bundlePath(environment), environment, members }];
|
|
13859
13873
|
});
|
|
13860
13874
|
}
|
|
13861
|
-
function
|
|
13862
|
-
return
|
|
13863
|
-
|
|
13864
|
-
`;
|
|
13875
|
+
function terminated(content) {
|
|
13876
|
+
return content.length > 0 && !content.endsWith("\n") ? `${content}
|
|
13877
|
+
` : content;
|
|
13865
13878
|
}
|
|
13866
13879
|
function newlineCount(value) {
|
|
13867
13880
|
return value.match(/\n/g)?.length ?? 0;
|
|
@@ -13875,9 +13888,9 @@ function materializeBundle(bundle, resolveHelper) {
|
|
|
13875
13888
|
let generatedStartLine = 1;
|
|
13876
13889
|
for (const member of bundle.members) {
|
|
13877
13890
|
const content = member.kind === "helper" ? resolveHelper(member.helper) : member.module.content;
|
|
13878
|
-
const block =
|
|
13891
|
+
const block = terminated(content);
|
|
13879
13892
|
const generatedEndLine = generatedStartLine + newlineCount(block) - 1;
|
|
13880
|
-
const contentStartLine = generatedStartLine
|
|
13893
|
+
const contentStartLine = generatedStartLine;
|
|
13881
13894
|
const contentEndLine = contentStartLine + contentLineCount(content) - 1;
|
|
13882
13895
|
const source = member.kind === "helper" ? member.helper.file : member.module.source;
|
|
13883
13896
|
const lines = member.kind === "helper" ? [] : member.module.lines ?? [];
|