Skip to content

Commit c060bcc

Browse files
committed
Fix formatting
1 parent 4e483db commit c060bcc

7 files changed

Lines changed: 12 additions & 51 deletions

File tree

src/transformation/builtins/console.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ export function transformConsoleCall(
2121
if (expression.arguments.length > 0 && isStringFormatTemplate(expression.arguments[0])) {
2222
// print(string.format([arguments]))
2323
const stringFormatCall = lua.createCallExpression(
24-
lua.createTableIndexExpression(
25-
lua.createIdentifier("string"),
26-
lua.createStringLiteral("format")
27-
),
24+
lua.createTableIndexExpression(lua.createIdentifier("string"), lua.createStringLiteral("format")),
2825
parameters
2926
);
3027
return lua.createCallExpression(lua.createIdentifier("print"), [stringFormatCall]);
@@ -35,10 +32,7 @@ export function transformConsoleCall(
3532
if (expression.arguments.length > 1 && isStringFormatTemplate(expression.arguments[1])) {
3633
// assert([condition], string.format([arguments]))
3734
const stringFormatCall = lua.createCallExpression(
38-
lua.createTableIndexExpression(
39-
lua.createIdentifier("string"),
40-
lua.createStringLiteral("format")
41-
),
35+
lua.createTableIndexExpression(lua.createIdentifier("string"), lua.createStringLiteral("format")),
4236
parameters.slice(1)
4337
);
4438
return lua.createCallExpression(lua.createIdentifier("assert"), [parameters[0], stringFormatCall]);
@@ -49,17 +43,11 @@ export function transformConsoleCall(
4943
if (expression.arguments.length > 0 && isStringFormatTemplate(expression.arguments[0])) {
5044
// print(debug.traceback(string.format([arguments])))
5145
const stringFormatCall = lua.createCallExpression(
52-
lua.createTableIndexExpression(
53-
lua.createIdentifier("string"),
54-
lua.createStringLiteral("format")
55-
),
46+
lua.createTableIndexExpression(lua.createIdentifier("string"), lua.createStringLiteral("format")),
5647
parameters
5748
);
5849
const debugTracebackCall = lua.createCallExpression(
59-
lua.createTableIndexExpression(
60-
lua.createIdentifier("debug"),
61-
lua.createStringLiteral("traceback")
62-
),
50+
lua.createTableIndexExpression(lua.createIdentifier("debug"), lua.createStringLiteral("traceback")),
6351
[stringFormatCall]
6452
);
6553
return lua.createCallExpression(lua.createIdentifier("print"), [debugTracebackCall]);

src/transformation/builtins/object.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ export function transformObjectCall(
5050
const rawGetIdentifier = lua.createIdentifier("rawget");
5151
const rawGetCall = lua.createCallExpression(rawGetIdentifier, [expr, ...parameters]);
5252
return lua.createParenthesizedExpression(
53-
lua.createBinaryExpression(
54-
rawGetCall,
55-
lua.createNilLiteral(),
56-
lua.SyntaxKind.InequalityOperator,
57-
node
58-
)
53+
lua.createBinaryExpression(rawGetCall, lua.createNilLiteral(), lua.SyntaxKind.InequalityOperator, node)
5954
);
6055
}
6156
}

src/transformation/transformers/class/new.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,5 @@ export const transformNewExpression: FunctionVisitor<ts.NewExpression> = (node,
8282
);
8383
}
8484

85-
return lua.createCallExpression(
86-
lua.createTableIndexExpression(name, lua.createStringLiteral("new")),
87-
params,
88-
node
89-
);
85+
return lua.createCallExpression(lua.createTableIndexExpression(name, lua.createStringLiteral("new")), params, node);
9086
};

src/transformation/transformers/generator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export function transformGeneratorFunctionBody(
4343
const errorCheck = lua.createIfStatement(
4444
lua.createUnaryExpression(errIdentifier, lua.SyntaxKind.NotOperator),
4545
lua.createBlock([
46-
lua.createExpressionStatement(
47-
lua.createCallExpression(lua.createIdentifier("error"), [valueIdentifier])
48-
),
46+
lua.createExpressionStatement(lua.createCallExpression(lua.createIdentifier("error"), [valueIdentifier])),
4947
])
5048
);
5149
nextBody.push(errorCheck);

src/transformation/transformers/loops/do-while.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ export const transformDoStatement: FunctionVisitor<ts.DoStatement> = (statement,
1717
if (lua.isUnaryExpression(condition) && condition.operator === lua.SyntaxKind.NotOperator) {
1818
condition = condition.operand;
1919
} else {
20-
condition = lua.createUnaryExpression(
21-
lua.createParenthesizedExpression(condition),
22-
lua.SyntaxKind.NotOperator
23-
);
20+
condition = lua.createUnaryExpression(lua.createParenthesizedExpression(condition), lua.SyntaxKind.NotOperator);
2421
}
2522

2623
return lua.createRepeatStatement(lua.createBlock([body]), condition, statement);

src/transformation/transformers/modules/export.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ export const transformExportAssignment: FunctionVisitor<ts.ExportAssignment> = (
3636
}
3737
};
3838

39-
function transformExportAllFrom(
40-
context: TransformationContext,
41-
node: ts.ExportDeclaration
42-
): lua.Statement | undefined {
39+
function transformExportAllFrom(context: TransformationContext, node: ts.ExportDeclaration): lua.Statement | undefined {
4340
if (node.moduleSpecifier === undefined) {
4441
throw InvalidExportDeclaration(node);
4542
}

src/transformation/transformers/variable.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ export function transformVariableDeclaration(
165165

166166
const vars =
167167
statement.name.elements.length > 0
168-
? castEach(
169-
statement.name.elements.map(e => transformArrayBindingElement(context, e)),
170-
lua.isIdentifier
171-
)
168+
? castEach(statement.name.elements.map(e => transformArrayBindingElement(context, e)), lua.isIdentifier)
172169
: lua.createAnonymousIdentifier(statement.name);
173170

174171
if (statement.initializer) {
@@ -210,16 +207,9 @@ export function transformVariableDeclaration(
210207
const identifier = addExportToIdentifier(context, variableName);
211208
statements.push(
212209
lua.createIfStatement(
213-
lua.createBinaryExpression(
214-
identifier,
215-
lua.createNilLiteral(),
216-
lua.SyntaxKind.EqualityOperator
217-
),
210+
lua.createBinaryExpression(identifier, lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator),
218211
lua.createBlock([
219-
lua.createAssignmentStatement(
220-
identifier,
221-
context.transformExpression(element.initializer)
222-
),
212+
lua.createAssignmentStatement(identifier, context.transformExpression(element.initializer)),
223213
])
224214
)
225215
);

0 commit comments

Comments
 (0)