From 98e88467e31dd8739b73065f140f81f4246976fa Mon Sep 17 00:00:00 2001 From: Lorenz Junglas Date: Sat, 20 Oct 2018 15:35:42 +0200 Subject: [PATCH 1/3] Fixed JIT using table.unpack sry --- src/targets/Transpiler.JIT.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/targets/Transpiler.JIT.ts b/src/targets/Transpiler.JIT.ts index 97173044f..76bf2fac2 100644 --- a/src/targets/Transpiler.JIT.ts +++ b/src/targets/Transpiler.JIT.ts @@ -37,6 +37,6 @@ export class LuaTranspilerJIT extends LuaTranspiler52 { /** @override */ public transpileDestructingAssignmentValue(node: ts.Expression): string { - return `table.unpack(${this.transpileExpression(node)})`; + return `unpack(${this.transpileExpression(node)})`; } } From 3a673cbe1fd2125135537dc6706a19951577135b Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 20 Oct 2018 15:39:32 +0200 Subject: [PATCH 2/3] Fixed test for JIT unpack --- test/unit/assignmentDestructuring.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/assignmentDestructuring.spec.ts b/test/unit/assignmentDestructuring.spec.ts index 994c3f83c..bbe555adb 100644 --- a/test/unit/assignmentDestructuring.spec.ts +++ b/test/unit/assignmentDestructuring.spec.ts @@ -35,6 +35,6 @@ export class AssignmentDestructuringTests { this.assignmentDestruturingTs, {luaTarget: LuaTarget.LuaJIT, luaLibImport: "none"} ); // Assert - Expect(lua).toBe(`local a,b=table.unpack(myFunc());`); + Expect(lua).toBe(`local a,b=unpack(myFunc());`); } } From 0fb6d38dbd11eb82c177c3d1848ec0fee52c6ed0 Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 20 Oct 2018 16:16:15 +0200 Subject: [PATCH 3/3] Moved transpileDestructingAssignmentValue from 5.1 to 5.0 --- src/Transpiler.ts | 2 +- src/targets/Transpiler.51.ts | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Transpiler.ts b/src/Transpiler.ts index 6bcae227e..fe6069ca9 100644 --- a/src/Transpiler.ts +++ b/src/Transpiler.ts @@ -1623,7 +1623,7 @@ export abstract class LuaTranspiler { } public transpileDestructingAssignmentValue(node: ts.Expression): string { - throw TSTLErrors.UnsupportedForTarget("Destructing statements", this.options.luaTarget, node); + return `unpack(${this.transpileExpression(node)})`; } public transpileVariableDeclaration(node: ts.VariableDeclaration): string { diff --git a/src/targets/Transpiler.51.ts b/src/targets/Transpiler.51.ts index f84d74fe6..bd4d63359 100644 --- a/src/targets/Transpiler.51.ts +++ b/src/targets/Transpiler.51.ts @@ -4,8 +4,5 @@ import { TSHelper as tsHelper } from "../TSHelper"; import * as ts from "typescript"; export class LuaTranspiler51 extends LuaTranspiler { - /** @override */ - public transpileDestructingAssignmentValue(node: ts.Expression): string { - return `unpack(${this.transpileExpression(node)})`; - } + }