Skip to content

Commit 450e44c

Browse files
committed
Added some todos
1 parent 9b24f50 commit 450e44c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/LuaTransformer.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,31 +1278,31 @@ export class LuaTransformer {
12781278
case ts.SyntaxKind.ElementAccessExpression:
12791279
return this.transformElementAccessExpression(expression as ts.ElementAccessExpression);
12801280
case ts.SyntaxKind.Identifier:
1281-
// Catch undefined which is passed as identifier
1282-
if ((expression as ts.Identifier).originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) {
1283-
return tstl.createNilLiteral();
1284-
}
1285-
// Otherwise simply return the name
12861281
return this.transformIdentifier(expression as ts.Identifier);
12871282
case ts.SyntaxKind.StringLiteral:
12881283
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
12891284
return this.transformStringLiteral(expression as ts.StringLiteral);
12901285
case ts.SyntaxKind.TemplateExpression:
12911286
return this.transformTemplateExpression(expression as ts.TemplateExpression);
12921287
case ts.SyntaxKind.NumericLiteral:
1288+
// TODO move to extra function (consistency)
12931289
return tstl.createNumericLiteral(
12941290
Number((expression as ts.NumericLiteral).text),
12951291
undefined,
12961292
expression
12971293
);
12981294
case ts.SyntaxKind.TrueKeyword:
1295+
// TODO move to extra function (consistency)
12991296
return tstl.createBooleanLiteral(true, undefined, expression);
13001297
case ts.SyntaxKind.FalseKeyword:
1298+
// TODO move to extra function (consistency)
13011299
return tstl.createBooleanLiteral(false, undefined, expression);
13021300
case ts.SyntaxKind.NullKeyword:
13031301
case ts.SyntaxKind.UndefinedKeyword:
1302+
// TODO move to extra function (consistency)
13041303
return tstl.createNilLiteral(undefined, expression);
13051304
case ts.SyntaxKind.ThisKeyword:
1305+
// TODO move to extra function (consistency)
13061306
return this.selfIdentifier;
13071307
case ts.SyntaxKind.PostfixUnaryExpression:
13081308
return this.transformPostfixUnaryExpression(expression as ts.PostfixUnaryExpression);
@@ -1321,12 +1321,14 @@ export class LuaTransformer {
13211321
case ts.SyntaxKind.ComputedPropertyName:
13221322
// return "[" + this.transpileExpression((node as ts.ComputedPropertyName).expression) + "]";
13231323
case ts.SyntaxKind.ParenthesizedExpression:
1324+
// TODO move to extra function (consistency)
13241325
return tstl.createParenthesizedExpression(
13251326
this.transformExpression((expression as ts.ParenthesizedExpression).expression),
13261327
undefined,
13271328
expression
13281329
);
13291330
case ts.SyntaxKind.SuperKeyword:
1331+
// TODO move to extra function (consistency)
13301332
return tstl.createTableIndexExpression(
13311333
this.selfIdentifier,
13321334
tstl.createStringLiteral("__base"),
@@ -1339,6 +1341,7 @@ export class LuaTransformer {
13391341
case ts.SyntaxKind.TypeOfExpression:
13401342
return this.transformTypeOfExpression(expression as ts.TypeOfExpression);
13411343
case ts.SyntaxKind.EmptyStatement:
1344+
// TODO move to extra function (consistency)
13421345
return undefined;
13431346
case ts.SyntaxKind.ClassExpression:
13441347
/*this.namespace.push("");
@@ -2448,6 +2451,11 @@ export class LuaTransformer {
24482451
}
24492452

24502453
public transformIdentifier(epxression: ts.Identifier, parent?: tstl.Node): tstl.Identifier {
2454+
if (epxression.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) {
2455+
return tstl.createIdentifier("nil"); // TODO this is a hack that allows use to keep Identifier as return time
2456+
// as changing that would break a lot of stuff.
2457+
// But this should be changed to retunr tstl.createNilLiteral() at somepoint
2458+
}
24512459
let escapedText = epxression.escapedText as string;
24522460
const underScoreCharCode = "_".charCodeAt(0);
24532461
if (escapedText.length >= 3

0 commit comments

Comments
 (0)