typescript-to-lua 1.0.1 → 1.1.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/CHANGELOG.md +18 -0
- package/dist/CompilerOptions.d.ts +4 -3
- package/dist/LuaAST.js +4 -4
- package/dist/LuaLib.d.ts +1 -0
- package/dist/LuaLib.js +1 -0
- package/dist/LuaPrinter.d.ts +6 -2
- package/dist/LuaPrinter.js +25 -16
- package/dist/cli/diagnostics.js +2 -2
- package/dist/cli/report.js +1 -1
- package/dist/cli/tsconfig.js +4 -4
- package/dist/lualib/Await.lua +26 -10
- package/dist/lualib/Promise.lua +20 -6
- package/dist/lualib/SourceMapTraceBack.lua +18 -8
- package/dist/lualib/StringReplace.lua +8 -13
- package/dist/lualib/StringReplaceAll.lua +35 -0
- package/dist/lualib/lualib_bundle.lua +106 -35
- package/dist/transformation/builtins/array.js +29 -29
- package/dist/transformation/builtins/console.js +2 -2
- package/dist/transformation/builtins/function.js +9 -9
- package/dist/transformation/builtins/global.js +8 -8
- package/dist/transformation/builtins/index.js +33 -33
- package/dist/transformation/builtins/math.js +4 -4
- package/dist/transformation/builtins/number.js +7 -7
- package/dist/transformation/builtins/object.js +11 -11
- package/dist/transformation/builtins/promise.js +9 -9
- package/dist/transformation/builtins/string.js +32 -30
- package/dist/transformation/builtins/symbol.js +3 -3
- package/dist/transformation/context/context.js +5 -5
- package/dist/transformation/index.js +1 -1
- package/dist/transformation/utils/annotations.d.ts +1 -3
- package/dist/transformation/utils/annotations.js +0 -2
- package/dist/transformation/utils/assignment-validation.js +8 -7
- package/dist/transformation/utils/diagnostics.js +4 -4
- package/dist/transformation/utils/export.js +4 -4
- package/dist/transformation/utils/function-context.js +8 -8
- package/dist/transformation/utils/lua-ast.js +18 -19
- package/dist/transformation/utils/lualib.js +1 -1
- package/dist/transformation/utils/safe-names.js +5 -5
- package/dist/transformation/utils/scope.d.ts +6 -0
- package/dist/transformation/utils/scope.js +70 -40
- package/dist/transformation/utils/symbols.js +6 -6
- package/dist/transformation/utils/transform.js +3 -3
- package/dist/transformation/utils/typescript/nodes.d.ts +2 -0
- package/dist/transformation/utils/typescript/nodes.js +21 -1
- package/dist/transformation/visitors/access.js +16 -16
- package/dist/transformation/visitors/async-await.js +5 -4
- package/dist/transformation/visitors/binary-expression/assignments.js +29 -29
- package/dist/transformation/visitors/binary-expression/bit.js +4 -4
- package/dist/transformation/visitors/binary-expression/compound.js +18 -18
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +17 -17
- package/dist/transformation/visitors/binary-expression/index.js +21 -21
- package/dist/transformation/visitors/block.js +6 -6
- package/dist/transformation/visitors/break-continue.js +2 -2
- package/dist/transformation/visitors/call.js +35 -35
- package/dist/transformation/visitors/class/decorators.js +3 -3
- package/dist/transformation/visitors/class/index.js +34 -34
- package/dist/transformation/visitors/class/members/accessors.js +6 -6
- package/dist/transformation/visitors/class/members/constructor.js +7 -7
- package/dist/transformation/visitors/class/members/fields.js +6 -6
- package/dist/transformation/visitors/class/members/method.js +6 -6
- package/dist/transformation/visitors/class/new.js +12 -12
- package/dist/transformation/visitors/class/setup.js +11 -11
- package/dist/transformation/visitors/class/utils.js +2 -2
- package/dist/transformation/visitors/conditional.js +6 -6
- package/dist/transformation/visitors/delete.js +4 -4
- package/dist/transformation/visitors/enum.js +8 -8
- package/dist/transformation/visitors/errors.js +30 -30
- package/dist/transformation/visitors/expression-statement.js +10 -6
- package/dist/transformation/visitors/function.js +26 -26
- package/dist/transformation/visitors/identifier.js +22 -22
- package/dist/transformation/visitors/index.js +2 -2
- package/dist/transformation/visitors/language-extensions/iterable.js +7 -7
- package/dist/transformation/visitors/language-extensions/multi.d.ts +1 -1
- package/dist/transformation/visitors/language-extensions/multi.js +3 -3
- package/dist/transformation/visitors/language-extensions/operators.js +6 -6
- package/dist/transformation/visitors/language-extensions/range.js +6 -6
- package/dist/transformation/visitors/language-extensions/table.js +5 -5
- package/dist/transformation/visitors/literal.d.ts +1 -2
- package/dist/transformation/visitors/literal.js +19 -42
- package/dist/transformation/visitors/loops/do-while.js +2 -2
- package/dist/transformation/visitors/loops/for-in.js +4 -4
- package/dist/transformation/visitors/loops/for-of.js +13 -13
- package/dist/transformation/visitors/loops/for.js +3 -3
- package/dist/transformation/visitors/loops/utils.js +9 -9
- package/dist/transformation/visitors/modules/export.js +13 -13
- package/dist/transformation/visitors/modules/import.js +10 -10
- package/dist/transformation/visitors/namespace.js +13 -13
- package/dist/transformation/visitors/return.d.ts +1 -0
- package/dist/transformation/visitors/return.js +40 -26
- package/dist/transformation/visitors/sourceFile.js +8 -8
- package/dist/transformation/visitors/spread.js +11 -11
- package/dist/transformation/visitors/switch.js +34 -11
- package/dist/transformation/visitors/template.js +5 -5
- package/dist/transformation/visitors/typeof.js +2 -2
- package/dist/transformation/visitors/typescript.js +1 -1
- package/dist/transformation/visitors/unary-expression.js +9 -9
- package/dist/transformation/visitors/variable-declaration.js +28 -28
- package/dist/transformation/visitors/void.d.ts +6 -0
- package/dist/transformation/visitors/void.js +23 -0
- package/dist/transpilation/bundle.d.ts +3 -0
- package/dist/transpilation/bundle.js +52 -10
- package/dist/transpilation/diagnostics.js +3 -3
- package/dist/transpilation/index.js +2 -2
- package/dist/transpilation/output-collector.js +2 -2
- package/dist/transpilation/plugins.js +1 -1
- package/dist/transpilation/resolve.js +19 -12
- package/dist/transpilation/transformers.js +41 -24
- package/dist/transpilation/transpile.js +6 -6
- package/dist/transpilation/transpiler.js +8 -8
- package/dist/transpilation/utils.js +3 -2
- package/dist/tstl.js +8 -8
- package/dist/utils.js +2 -2
- package/package.json +15 -12
- package/dist/transformation/visitors/jsx/jsx.d.ts +0 -9
- package/dist/transformation/visitors/jsx/jsx.js +0 -237
- package/dist/transformation/visitors/jsx/xhtml.d.ts +0 -3
- package/dist/transformation/visitors/jsx/xhtml.js +0 -260
|
@@ -498,19 +498,35 @@ function __TS__AsyncAwaiter(generator)
|
|
|
498
498
|
return __TS__New(
|
|
499
499
|
__TS__Promise,
|
|
500
500
|
function(____, resolve, reject)
|
|
501
|
-
local
|
|
501
|
+
local adopt, fulfilled, rejected, step, asyncCoroutine
|
|
502
502
|
function adopt(self, value)
|
|
503
503
|
return ((__TS__InstanceOf(value, __TS__Promise) and (function() return value end)) or (function() return __TS__Promise.resolve(value) end))()
|
|
504
504
|
end
|
|
505
505
|
function fulfilled(self, value)
|
|
506
|
-
local success, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
506
|
+
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
507
507
|
if success then
|
|
508
|
-
step(_G, resultOrError)
|
|
508
|
+
step(_G, resultOrError, errorOrErrorHandler)
|
|
509
509
|
else
|
|
510
510
|
reject(_G, resultOrError)
|
|
511
511
|
end
|
|
512
512
|
end
|
|
513
|
-
function
|
|
513
|
+
function rejected(self, handler)
|
|
514
|
+
if handler then
|
|
515
|
+
return function(____, value)
|
|
516
|
+
local success, valueOrError = pcall(handler, value)
|
|
517
|
+
if success then
|
|
518
|
+
step(_G, valueOrError, handler)
|
|
519
|
+
else
|
|
520
|
+
reject(_G, valueOrError)
|
|
521
|
+
end
|
|
522
|
+
end
|
|
523
|
+
else
|
|
524
|
+
return function(____, value)
|
|
525
|
+
reject(_G, value)
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
function step(self, result, errorHandler)
|
|
514
530
|
if coroutine.status(asyncCoroutine) == "dead" then
|
|
515
531
|
resolve(_G, result)
|
|
516
532
|
else
|
|
@@ -519,23 +535,23 @@ function __TS__AsyncAwaiter(generator)
|
|
|
519
535
|
return ____self["then"](
|
|
520
536
|
____self,
|
|
521
537
|
fulfilled,
|
|
522
|
-
|
|
538
|
+
rejected(_G, errorHandler)
|
|
523
539
|
)
|
|
524
540
|
end)()
|
|
525
541
|
end
|
|
526
542
|
end
|
|
527
543
|
asyncCoroutine = coroutine.create(generator)
|
|
528
|
-
local success, resultOrError = coroutine.resume(asyncCoroutine)
|
|
544
|
+
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine)
|
|
529
545
|
if success then
|
|
530
|
-
step(_G, resultOrError)
|
|
546
|
+
step(_G, resultOrError, errorOrErrorHandler)
|
|
531
547
|
else
|
|
532
|
-
reject(_G,
|
|
548
|
+
reject(_G, errorOrErrorHandler)
|
|
533
549
|
end
|
|
534
550
|
end
|
|
535
551
|
)
|
|
536
552
|
end
|
|
537
|
-
function __TS__Await(thing)
|
|
538
|
-
return coroutine.yield(thing)
|
|
553
|
+
function __TS__Await(errorHandler, thing)
|
|
554
|
+
return coroutine.yield(errorHandler, thing)
|
|
539
555
|
end
|
|
540
556
|
|
|
541
557
|
function __TS__Class(self)
|
|
@@ -1417,7 +1433,10 @@ function __TS__Promise.prototype.____constructor(self, executor)
|
|
|
1417
1433
|
self.rejectedCallbacks = {}
|
|
1418
1434
|
self.finallyCallbacks = {}
|
|
1419
1435
|
do
|
|
1420
|
-
local
|
|
1436
|
+
local function ____catch(e)
|
|
1437
|
+
self:reject(e)
|
|
1438
|
+
end
|
|
1439
|
+
local ____try, ____hasReturned = pcall(
|
|
1421
1440
|
function()
|
|
1422
1441
|
executor(
|
|
1423
1442
|
_G,
|
|
@@ -1427,7 +1446,7 @@ function __TS__Promise.prototype.____constructor(self, executor)
|
|
|
1427
1446
|
end
|
|
1428
1447
|
)
|
|
1429
1448
|
if not ____try then
|
|
1430
|
-
|
|
1449
|
+
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
1431
1450
|
end
|
|
1432
1451
|
end
|
|
1433
1452
|
end
|
|
@@ -1456,10 +1475,12 @@ __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
|
1456
1475
|
local promise = ____.promise
|
|
1457
1476
|
local resolve = ____.resolve
|
|
1458
1477
|
local reject = ____.reject
|
|
1478
|
+
local isFulfilled = self.state == __TS__PromiseState.Fulfilled
|
|
1479
|
+
local isRejected = self.state == __TS__PromiseState.Rejected
|
|
1459
1480
|
if onFulfilled then
|
|
1460
1481
|
local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
|
|
1461
1482
|
__TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
|
|
1462
|
-
if
|
|
1483
|
+
if isFulfilled then
|
|
1463
1484
|
internalCallback(_G, self.value)
|
|
1464
1485
|
end
|
|
1465
1486
|
else
|
|
@@ -1471,10 +1492,16 @@ __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
|
1471
1492
|
if onRejected then
|
|
1472
1493
|
local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
|
|
1473
1494
|
__TS__ArrayPush(self.rejectedCallbacks, internalCallback)
|
|
1474
|
-
if
|
|
1495
|
+
if isRejected then
|
|
1475
1496
|
internalCallback(_G, self.rejectionReason)
|
|
1476
1497
|
end
|
|
1477
1498
|
end
|
|
1499
|
+
if isFulfilled then
|
|
1500
|
+
resolve(_G, self.value)
|
|
1501
|
+
end
|
|
1502
|
+
if isRejected then
|
|
1503
|
+
reject(_G, self.rejectionReason)
|
|
1504
|
+
end
|
|
1478
1505
|
return promise
|
|
1479
1506
|
end
|
|
1480
1507
|
function __TS__Promise.prototype.catch(self, onRejected)
|
|
@@ -1516,7 +1543,10 @@ end
|
|
|
1516
1543
|
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
|
|
1517
1544
|
return function(____, value)
|
|
1518
1545
|
do
|
|
1519
|
-
local
|
|
1546
|
+
local function ____catch(e)
|
|
1547
|
+
reject(_G, e)
|
|
1548
|
+
end
|
|
1549
|
+
local ____try, ____hasReturned = pcall(
|
|
1520
1550
|
function()
|
|
1521
1551
|
self:handleCallbackData(
|
|
1522
1552
|
f(_G, value),
|
|
@@ -1526,7 +1556,7 @@ function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve
|
|
|
1526
1556
|
end
|
|
1527
1557
|
)
|
|
1528
1558
|
if not ____try then
|
|
1529
|
-
|
|
1559
|
+
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
1530
1560
|
end
|
|
1531
1561
|
end
|
|
1532
1562
|
end
|
|
@@ -1947,16 +1977,26 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
1947
1977
|
if type(trace) ~= "string" then
|
|
1948
1978
|
return trace
|
|
1949
1979
|
end
|
|
1950
|
-
local
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
return (file .. ".ts:") .. tostring(fileSourceMap[line])
|
|
1980
|
+
local function replacer(____, file, srcFile, line)
|
|
1981
|
+
local fileSourceMap = _G.__TS__sourcemap[file]
|
|
1982
|
+
if fileSourceMap and fileSourceMap[line] then
|
|
1983
|
+
local data = fileSourceMap[line]
|
|
1984
|
+
if type(data) == "number" then
|
|
1985
|
+
return (srcFile .. ":") .. tostring(data)
|
|
1957
1986
|
end
|
|
1958
|
-
return (file .. "
|
|
1987
|
+
return (tostring(data.file) .. ":") .. tostring(data.line)
|
|
1959
1988
|
end
|
|
1989
|
+
return (file .. ":") .. line
|
|
1990
|
+
end
|
|
1991
|
+
local result = string.gsub(
|
|
1992
|
+
trace,
|
|
1993
|
+
"(%S+)%.lua:(%d+)",
|
|
1994
|
+
function(file, line) return replacer(_G, file .. ".lua", file .. ".ts", line) end
|
|
1995
|
+
)
|
|
1996
|
+
result = string.gsub(
|
|
1997
|
+
result,
|
|
1998
|
+
"(%[string \"[^\"]+\"%]):(%d+)",
|
|
1999
|
+
function(file, line) return replacer(_G, file, "unknown", line) end
|
|
1960
2000
|
)
|
|
1961
2001
|
return result
|
|
1962
2002
|
end
|
|
@@ -2082,20 +2122,51 @@ function __TS__StringPadStart(self, maxLength, fillString)
|
|
|
2082
2122
|
end
|
|
2083
2123
|
|
|
2084
2124
|
function __TS__StringReplace(source, searchValue, replaceValue)
|
|
2085
|
-
|
|
2125
|
+
local startPos, endPos = string.find(source, searchValue, nil, true)
|
|
2126
|
+
if not startPos then
|
|
2127
|
+
return source
|
|
2128
|
+
end
|
|
2129
|
+
local sub = string.sub
|
|
2130
|
+
local before = sub(source, 1, startPos - 1)
|
|
2131
|
+
local replacement = (((type(replaceValue) == "string") and (function() return replaceValue end)) or (function() return replaceValue(_G, searchValue, startPos - 1, source) end))()
|
|
2132
|
+
local after = sub(source, endPos + 1)
|
|
2133
|
+
return (before .. replacement) .. after
|
|
2134
|
+
end
|
|
2135
|
+
|
|
2136
|
+
function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
2137
|
+
local replacer
|
|
2086
2138
|
if type(replaceValue) == "string" then
|
|
2087
|
-
|
|
2088
|
-
local result = string.gsub(source, searchValue, replaceValue, 1)
|
|
2089
|
-
return result
|
|
2139
|
+
replacer = function() return replaceValue end
|
|
2090
2140
|
else
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2141
|
+
replacer = replaceValue
|
|
2142
|
+
end
|
|
2143
|
+
local parts = {}
|
|
2144
|
+
local partsIndex = 1
|
|
2145
|
+
local sub = string.sub
|
|
2146
|
+
if #searchValue == 0 then
|
|
2147
|
+
parts[1] = replacer(_G, "", 0, source)
|
|
2148
|
+
partsIndex = 2
|
|
2149
|
+
for i = 1, #source do
|
|
2150
|
+
parts[partsIndex] = sub(source, i, i)
|
|
2151
|
+
parts[partsIndex + 1] = replacer(_G, "", i, source)
|
|
2152
|
+
partsIndex = partsIndex + 2
|
|
2153
|
+
end
|
|
2154
|
+
else
|
|
2155
|
+
local find = string.find
|
|
2156
|
+
local currentPos = 1
|
|
2157
|
+
while true do
|
|
2158
|
+
local startPos, endPos = find(source, searchValue, currentPos, true)
|
|
2159
|
+
if not startPos then
|
|
2160
|
+
break
|
|
2161
|
+
end
|
|
2162
|
+
parts[partsIndex] = sub(source, currentPos, startPos - 1)
|
|
2163
|
+
parts[partsIndex + 1] = replacer(_G, searchValue, startPos - 1, source)
|
|
2164
|
+
partsIndex = partsIndex + 2
|
|
2165
|
+
currentPos = endPos + 1
|
|
2166
|
+
end
|
|
2167
|
+
parts[partsIndex] = sub(source, currentPos)
|
|
2098
2168
|
end
|
|
2169
|
+
return table.concat(parts)
|
|
2099
2170
|
end
|
|
2100
2171
|
|
|
2101
2172
|
function __TS__StringSlice(self, start, ____end)
|
|
@@ -9,69 +9,69 @@ const typescript_1 = require("../utils/typescript");
|
|
|
9
9
|
function transformArrayConstructorCall(context, node) {
|
|
10
10
|
const expression = node.expression;
|
|
11
11
|
const signature = context.checker.getResolvedSignature(node);
|
|
12
|
-
const params = call_1.transformArguments(context, node.arguments, signature);
|
|
12
|
+
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
13
13
|
const expressionName = expression.name.text;
|
|
14
14
|
switch (expressionName) {
|
|
15
15
|
case "isArray":
|
|
16
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayIsArray, node, ...params);
|
|
16
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayIsArray, node, ...params);
|
|
17
17
|
default:
|
|
18
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(expression.name, "Array", expressionName));
|
|
18
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(expression.name, "Array", expressionName));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.transformArrayConstructorCall = transformArrayConstructorCall;
|
|
22
22
|
function transformArrayPrototypeCall(context, node) {
|
|
23
23
|
const expression = node.expression;
|
|
24
24
|
const signature = context.checker.getResolvedSignature(node);
|
|
25
|
-
const params = call_1.transformArguments(context, node.arguments, signature);
|
|
25
|
+
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
26
26
|
const caller = context.transformExpression(expression.expression);
|
|
27
27
|
const expressionName = expression.name.text;
|
|
28
28
|
switch (expressionName) {
|
|
29
29
|
case "concat":
|
|
30
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayConcat, node, caller, ...params);
|
|
30
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayConcat, node, caller, ...params);
|
|
31
31
|
case "entries":
|
|
32
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayEntries, node, caller);
|
|
32
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayEntries, node, caller);
|
|
33
33
|
case "push":
|
|
34
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayPush, node, caller, ...params);
|
|
34
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayPush, node, caller, ...params);
|
|
35
35
|
case "reverse":
|
|
36
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayReverse, node, caller);
|
|
36
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayReverse, node, caller);
|
|
37
37
|
case "shift":
|
|
38
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayShift, node, caller);
|
|
38
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayShift, node, caller);
|
|
39
39
|
case "unshift":
|
|
40
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayUnshift, node, caller, ...params);
|
|
40
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayUnshift, node, caller, ...params);
|
|
41
41
|
case "sort":
|
|
42
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArraySort, node, caller, ...params);
|
|
42
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArraySort, node, caller, ...params);
|
|
43
43
|
case "pop":
|
|
44
44
|
return lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("remove")), [caller], node);
|
|
45
45
|
case "forEach":
|
|
46
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayForEach, node, caller, ...params);
|
|
46
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayForEach, node, caller, ...params);
|
|
47
47
|
case "find":
|
|
48
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayFind, node, caller, ...params);
|
|
48
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayFind, node, caller, ...params);
|
|
49
49
|
case "findIndex":
|
|
50
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayFindIndex, node, caller, ...params);
|
|
50
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayFindIndex, node, caller, ...params);
|
|
51
51
|
case "includes":
|
|
52
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayIncludes, node, caller, ...params);
|
|
52
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayIncludes, node, caller, ...params);
|
|
53
53
|
case "indexOf":
|
|
54
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayIndexOf, node, caller, ...params);
|
|
54
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayIndexOf, node, caller, ...params);
|
|
55
55
|
case "map":
|
|
56
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayMap, node, caller, ...params);
|
|
56
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayMap, node, caller, ...params);
|
|
57
57
|
case "filter":
|
|
58
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayFilter, node, caller, ...params);
|
|
58
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayFilter, node, caller, ...params);
|
|
59
59
|
case "reduce":
|
|
60
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayReduce, node, caller, ...params);
|
|
60
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayReduce, node, caller, ...params);
|
|
61
61
|
case "reduceRight":
|
|
62
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayReduceRight, node, caller, ...params);
|
|
62
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayReduceRight, node, caller, ...params);
|
|
63
63
|
case "some":
|
|
64
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArraySome, node, caller, ...params);
|
|
64
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArraySome, node, caller, ...params);
|
|
65
65
|
case "every":
|
|
66
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayEvery, node, caller, ...params);
|
|
66
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayEvery, node, caller, ...params);
|
|
67
67
|
case "slice":
|
|
68
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArraySlice, node, caller, ...params);
|
|
68
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArraySlice, node, caller, ...params);
|
|
69
69
|
case "splice":
|
|
70
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArraySplice, node, caller, ...params);
|
|
70
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArraySplice, node, caller, ...params);
|
|
71
71
|
case "join":
|
|
72
72
|
const callerType = context.checker.getTypeAtLocation(expression.expression);
|
|
73
73
|
const elementType = context.checker.getElementTypeOfArrayType(callerType);
|
|
74
|
-
if (elementType && (typescript_1.isStringType(context, elementType) || typescript_1.isNumberType(context, elementType))) {
|
|
74
|
+
if (elementType && ((0, typescript_1.isStringType)(context, elementType) || (0, typescript_1.isNumberType)(context, elementType))) {
|
|
75
75
|
const defaultSeparatorLiteral = lua.createStringLiteral(",");
|
|
76
76
|
const parameters = [
|
|
77
77
|
caller,
|
|
@@ -81,13 +81,13 @@ function transformArrayPrototypeCall(context, node) {
|
|
|
81
81
|
];
|
|
82
82
|
return lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("concat")), parameters, node);
|
|
83
83
|
}
|
|
84
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayJoin, node, caller, ...params);
|
|
84
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayJoin, node, caller, ...params);
|
|
85
85
|
case "flat":
|
|
86
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayFlat, node, caller, ...params);
|
|
86
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayFlat, node, caller, ...params);
|
|
87
87
|
case "flatMap":
|
|
88
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayFlatMap, node, caller, ...params);
|
|
88
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayFlatMap, node, caller, ...params);
|
|
89
89
|
default:
|
|
90
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(expression.name, "array", expressionName));
|
|
90
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(expression.name, "array", expressionName));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
exports.transformArrayPrototypeCall = transformArrayPrototypeCall;
|
|
@@ -10,7 +10,7 @@ function transformConsoleCall(context, expression) {
|
|
|
10
10
|
const method = expression.expression;
|
|
11
11
|
const methodName = method.name.text;
|
|
12
12
|
const signature = context.checker.getResolvedSignature(expression);
|
|
13
|
-
const parameters = call_1.transformArguments(context, expression.arguments, signature);
|
|
13
|
+
const parameters = (0, call_1.transformArguments)(context, expression.arguments, signature);
|
|
14
14
|
switch (methodName) {
|
|
15
15
|
case "error":
|
|
16
16
|
case "info":
|
|
@@ -42,7 +42,7 @@ function transformConsoleCall(context, expression) {
|
|
|
42
42
|
const debugTracebackCall = lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("debug"), lua.createStringLiteral("traceback")), parameters);
|
|
43
43
|
return lua.createCallExpression(lua.createIdentifier("print"), [debugTracebackCall]);
|
|
44
44
|
default:
|
|
45
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(method.name, "console", methodName));
|
|
45
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(method.name, "console", methodName));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
exports.transformConsoleCall = transformConsoleCall;
|
|
@@ -11,22 +11,22 @@ const call_1 = require("../visitors/call");
|
|
|
11
11
|
function transformFunctionPrototypeCall(context, node) {
|
|
12
12
|
const expression = node.expression;
|
|
13
13
|
const callerType = context.checker.getTypeAtLocation(expression.expression);
|
|
14
|
-
if (function_context_1.getFunctionContextType(context, callerType) === function_context_1.ContextType.Void) {
|
|
15
|
-
context.diagnostics.push(diagnostics_1.unsupportedSelfFunctionConversion(node));
|
|
14
|
+
if ((0, function_context_1.getFunctionContextType)(context, callerType) === function_context_1.ContextType.Void) {
|
|
15
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedSelfFunctionConversion)(node));
|
|
16
16
|
}
|
|
17
17
|
const signature = context.checker.getResolvedSignature(node);
|
|
18
|
-
const params = call_1.transformArguments(context, node.arguments, signature);
|
|
18
|
+
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
19
19
|
const caller = context.transformExpression(expression.expression);
|
|
20
20
|
const expressionName = expression.name.text;
|
|
21
21
|
switch (expressionName) {
|
|
22
22
|
case "apply":
|
|
23
|
-
return lua.createCallExpression(caller, [params[0], lua_ast_1.createUnpackCall(context, params[1], node.arguments[1])], node);
|
|
23
|
+
return lua.createCallExpression(caller, [params[0], (0, lua_ast_1.createUnpackCall)(context, params[1], node.arguments[1])], node);
|
|
24
24
|
case "bind":
|
|
25
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.FunctionBind, node, caller, ...params);
|
|
25
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.FunctionBind, node, caller, ...params);
|
|
26
26
|
case "call":
|
|
27
27
|
return lua.createCallExpression(caller, params, node);
|
|
28
28
|
default:
|
|
29
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(expression.name, "function", expressionName));
|
|
29
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(expression.name, "function", expressionName));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.transformFunctionPrototypeCall = transformFunctionPrototypeCall;
|
|
@@ -34,17 +34,17 @@ function transformFunctionProperty(context, node) {
|
|
|
34
34
|
switch (node.name.text) {
|
|
35
35
|
case "length":
|
|
36
36
|
if (context.luaTarget === CompilerOptions_1.LuaTarget.Lua51 || context.luaTarget === CompilerOptions_1.LuaTarget.Universal) {
|
|
37
|
-
context.diagnostics.push(diagnostics_1.unsupportedForTarget(node, "function.length", CompilerOptions_1.LuaTarget.Lua51));
|
|
37
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(node, "function.length", CompilerOptions_1.LuaTarget.Lua51));
|
|
38
38
|
}
|
|
39
39
|
// debug.getinfo(fn)
|
|
40
40
|
const getInfoCall = lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("debug"), lua.createStringLiteral("getinfo")), [context.transformExpression(node.expression)]);
|
|
41
41
|
const nparams = lua.createTableIndexExpression(getInfoCall, lua.createStringLiteral("nparams"));
|
|
42
|
-
const contextType = function_context_1.getFunctionContextType(context, context.checker.getTypeAtLocation(node.expression));
|
|
42
|
+
const contextType = (0, function_context_1.getFunctionContextType)(context, context.checker.getTypeAtLocation(node.expression));
|
|
43
43
|
return contextType === function_context_1.ContextType.NonVoid
|
|
44
44
|
? lua.createBinaryExpression(nparams, lua.createNumericLiteral(1), lua.SyntaxKind.SubtractionOperator)
|
|
45
45
|
: nparams;
|
|
46
46
|
default:
|
|
47
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(node.name, "function", node.name.text));
|
|
47
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(node.name, "function", node.name.text));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
exports.transformFunctionProperty = transformFunctionProperty;
|
|
@@ -6,24 +6,24 @@ const typescript_1 = require("../utils/typescript");
|
|
|
6
6
|
const call_1 = require("../visitors/call");
|
|
7
7
|
function transformGlobalCall(context, node) {
|
|
8
8
|
const signature = context.checker.getResolvedSignature(node);
|
|
9
|
-
const parameters = call_1.transformArguments(context, node.arguments, signature);
|
|
9
|
+
const parameters = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
10
10
|
const expressionType = context.checker.getTypeAtLocation(node.expression);
|
|
11
11
|
const name = expressionType.symbol.name;
|
|
12
12
|
switch (name) {
|
|
13
13
|
case "SymbolConstructor":
|
|
14
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.Symbol, node, ...parameters);
|
|
14
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.Symbol, node, ...parameters);
|
|
15
15
|
case "NumberConstructor":
|
|
16
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.Number, node, ...parameters);
|
|
16
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.Number, node, ...parameters);
|
|
17
17
|
case "isNaN":
|
|
18
18
|
case "isFinite":
|
|
19
|
-
const numberParameters = typescript_1.isNumberType(context, expressionType)
|
|
19
|
+
const numberParameters = (0, typescript_1.isNumberType)(context, expressionType)
|
|
20
20
|
? parameters
|
|
21
|
-
: [lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.Number, undefined, ...parameters)];
|
|
22
|
-
return lualib_1.transformLuaLibFunction(context, name === "isNaN" ? lualib_1.LuaLibFeature.NumberIsNaN : lualib_1.LuaLibFeature.NumberIsFinite, node, ...numberParameters);
|
|
21
|
+
: [(0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.Number, undefined, ...parameters)];
|
|
22
|
+
return (0, lualib_1.transformLuaLibFunction)(context, name === "isNaN" ? lualib_1.LuaLibFeature.NumberIsNaN : lualib_1.LuaLibFeature.NumberIsFinite, node, ...numberParameters);
|
|
23
23
|
case "parseFloat":
|
|
24
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ParseFloat, node, ...parameters);
|
|
24
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ParseFloat, node, ...parameters);
|
|
25
25
|
case "parseInt":
|
|
26
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ParseInt, node, ...parameters);
|
|
26
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ParseInt, node, ...parameters);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.transformGlobalCall = transformGlobalCall;
|
|
@@ -21,31 +21,31 @@ const string_1 = require("./string");
|
|
|
21
21
|
const symbol_1 = require("./symbol");
|
|
22
22
|
function transformBuiltinPropertyAccessExpression(context, node) {
|
|
23
23
|
const ownerType = context.checker.getTypeAtLocation(node.expression);
|
|
24
|
-
if (typescript_1.isStringType(context, ownerType)) {
|
|
25
|
-
return string_1.transformStringProperty(context, node);
|
|
24
|
+
if ((0, typescript_1.isStringType)(context, ownerType)) {
|
|
25
|
+
return (0, string_1.transformStringProperty)(context, node);
|
|
26
26
|
}
|
|
27
|
-
if (typescript_1.isArrayType(context, ownerType)) {
|
|
28
|
-
return array_1.transformArrayProperty(context, node);
|
|
27
|
+
if ((0, typescript_1.isArrayType)(context, ownerType)) {
|
|
28
|
+
return (0, array_1.transformArrayProperty)(context, node);
|
|
29
29
|
}
|
|
30
|
-
if (typescript_1.isFunctionType(context, ownerType)) {
|
|
31
|
-
return function_1.transformFunctionProperty(context, node);
|
|
30
|
+
if ((0, typescript_1.isFunctionType)(context, ownerType)) {
|
|
31
|
+
return (0, function_1.transformFunctionProperty)(context, node);
|
|
32
32
|
}
|
|
33
|
-
if (ts.isIdentifier(node.expression) && typescript_1.isStandardLibraryType(context, ownerType, undefined)) {
|
|
33
|
+
if (ts.isIdentifier(node.expression) && (0, typescript_1.isStandardLibraryType)(context, ownerType, undefined)) {
|
|
34
34
|
switch (node.expression.text) {
|
|
35
35
|
case "Math":
|
|
36
|
-
return math_1.transformMathProperty(context, node);
|
|
36
|
+
return (0, math_1.transformMathProperty)(context, node);
|
|
37
37
|
case "Symbol":
|
|
38
|
-
lualib_1.importLuaLibFeature(context, lualib_1.LuaLibFeature.Symbol);
|
|
38
|
+
(0, lualib_1.importLuaLibFeature)(context, lualib_1.LuaLibFeature.Symbol);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.transformBuiltinPropertyAccessExpression = transformBuiltinPropertyAccessExpression;
|
|
43
43
|
function transformBuiltinCallExpression(context, node) {
|
|
44
44
|
const expressionType = context.checker.getTypeAtLocation(node.expression);
|
|
45
|
-
if (ts.isIdentifier(node.expression) && typescript_1.isStandardLibraryType(context, expressionType, undefined)) {
|
|
45
|
+
if (ts.isIdentifier(node.expression) && (0, typescript_1.isStandardLibraryType)(context, expressionType, undefined)) {
|
|
46
46
|
// TODO:
|
|
47
|
-
new_1.checkForLuaLibType(context, expressionType);
|
|
48
|
-
const result = global_1.transformGlobalCall(context, node);
|
|
47
|
+
(0, new_1.checkForLuaLibType)(context, expressionType);
|
|
48
|
+
const result = (0, global_1.transformGlobalCall)(context, node);
|
|
49
49
|
if (result) {
|
|
50
50
|
return result;
|
|
51
51
|
}
|
|
@@ -53,43 +53,43 @@ function transformBuiltinCallExpression(context, node) {
|
|
|
53
53
|
if (!ts.isPropertyAccessExpression(node.expression)) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
utils_1.assume(node);
|
|
56
|
+
(0, utils_1.assume)(node);
|
|
57
57
|
// If the function being called is of type owner.func, get the type of owner
|
|
58
58
|
const ownerType = context.checker.getTypeAtLocation(node.expression.expression);
|
|
59
|
-
if (typescript_1.isStandardLibraryType(context, ownerType, undefined)) {
|
|
59
|
+
if ((0, typescript_1.isStandardLibraryType)(context, ownerType, undefined)) {
|
|
60
60
|
const symbol = ownerType.getSymbol();
|
|
61
61
|
switch (symbol === null || symbol === void 0 ? void 0 : symbol.name) {
|
|
62
62
|
case "ArrayConstructor":
|
|
63
|
-
return array_1.transformArrayConstructorCall(context, node);
|
|
63
|
+
return (0, array_1.transformArrayConstructorCall)(context, node);
|
|
64
64
|
case "Console":
|
|
65
|
-
return console_1.transformConsoleCall(context, node);
|
|
65
|
+
return (0, console_1.transformConsoleCall)(context, node);
|
|
66
66
|
case "Math":
|
|
67
|
-
return math_1.transformMathCall(context, node);
|
|
67
|
+
return (0, math_1.transformMathCall)(context, node);
|
|
68
68
|
case "StringConstructor":
|
|
69
|
-
return string_1.transformStringConstructorCall(context, node);
|
|
69
|
+
return (0, string_1.transformStringConstructorCall)(context, node);
|
|
70
70
|
case "ObjectConstructor":
|
|
71
|
-
return object_1.transformObjectConstructorCall(context, node);
|
|
71
|
+
return (0, object_1.transformObjectConstructorCall)(context, node);
|
|
72
72
|
case "SymbolConstructor":
|
|
73
|
-
return symbol_1.transformSymbolConstructorCall(context, node);
|
|
73
|
+
return (0, symbol_1.transformSymbolConstructorCall)(context, node);
|
|
74
74
|
case "NumberConstructor":
|
|
75
|
-
return number_1.transformNumberConstructorCall(context, node);
|
|
75
|
+
return (0, number_1.transformNumberConstructorCall)(context, node);
|
|
76
76
|
case "PromiseConstructor":
|
|
77
|
-
return promise_1.transformPromiseConstructorCall(context, node);
|
|
77
|
+
return (0, promise_1.transformPromiseConstructorCall)(context, node);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
if (typescript_1.isStringType(context, ownerType) && typescript_1.hasStandardLibrarySignature(context, node)) {
|
|
81
|
-
return string_1.transformStringPrototypeCall(context, node);
|
|
80
|
+
if ((0, typescript_1.isStringType)(context, ownerType) && (0, typescript_1.hasStandardLibrarySignature)(context, node)) {
|
|
81
|
+
return (0, string_1.transformStringPrototypeCall)(context, node);
|
|
82
82
|
}
|
|
83
|
-
if (typescript_1.isNumberType(context, ownerType) && typescript_1.hasStandardLibrarySignature(context, node)) {
|
|
84
|
-
return number_1.transformNumberPrototypeCall(context, node);
|
|
83
|
+
if ((0, typescript_1.isNumberType)(context, ownerType) && (0, typescript_1.hasStandardLibrarySignature)(context, node)) {
|
|
84
|
+
return (0, number_1.transformNumberPrototypeCall)(context, node);
|
|
85
85
|
}
|
|
86
|
-
if (typescript_1.isArrayType(context, ownerType) && typescript_1.hasStandardLibrarySignature(context, node)) {
|
|
87
|
-
return array_1.transformArrayPrototypeCall(context, node);
|
|
86
|
+
if ((0, typescript_1.isArrayType)(context, ownerType) && (0, typescript_1.hasStandardLibrarySignature)(context, node)) {
|
|
87
|
+
return (0, array_1.transformArrayPrototypeCall)(context, node);
|
|
88
88
|
}
|
|
89
|
-
if (typescript_1.isFunctionType(context, ownerType) && typescript_1.hasStandardLibrarySignature(context, node)) {
|
|
90
|
-
return function_1.transformFunctionPrototypeCall(context, node);
|
|
89
|
+
if ((0, typescript_1.isFunctionType)(context, ownerType) && (0, typescript_1.hasStandardLibrarySignature)(context, node)) {
|
|
90
|
+
return (0, function_1.transformFunctionPrototypeCall)(context, node);
|
|
91
91
|
}
|
|
92
|
-
const objectResult = object_1.transformObjectPrototypeCall(context, node);
|
|
92
|
+
const objectResult = (0, object_1.transformObjectPrototypeCall)(context, node);
|
|
93
93
|
if (objectResult) {
|
|
94
94
|
return objectResult;
|
|
95
95
|
}
|
|
@@ -98,13 +98,13 @@ exports.transformBuiltinCallExpression = transformBuiltinCallExpression;
|
|
|
98
98
|
function transformBuiltinIdentifierExpression(context, node) {
|
|
99
99
|
switch (node.text) {
|
|
100
100
|
case "NaN":
|
|
101
|
-
return lua_ast_1.createNaN(node);
|
|
101
|
+
return (0, lua_ast_1.createNaN)(node);
|
|
102
102
|
case "Infinity":
|
|
103
103
|
const math = lua.createIdentifier("math");
|
|
104
104
|
const huge = lua.createStringLiteral("huge");
|
|
105
105
|
return lua.createTableIndexExpression(math, huge, node);
|
|
106
106
|
case "globalThis":
|
|
107
|
-
return lua.createIdentifier("_G", node, symbols_1.getIdentifierSymbolId(context, node), "globalThis");
|
|
107
|
+
return lua.createIdentifier("_G", node, (0, symbols_1.getIdentifierSymbolId)(context, node), "globalThis");
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
exports.transformBuiltinIdentifierExpression = transformBuiltinIdentifierExpression;
|
|
@@ -22,14 +22,14 @@ function transformMathProperty(context, node) {
|
|
|
22
22
|
case "SQRT2":
|
|
23
23
|
return lua.createNumericLiteral(Math[name], node);
|
|
24
24
|
default:
|
|
25
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(node.name, "Math", name));
|
|
25
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(node.name, "Math", name));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
exports.transformMathProperty = transformMathProperty;
|
|
29
29
|
function transformMathCall(context, node) {
|
|
30
30
|
const expression = node.expression;
|
|
31
31
|
const signature = context.checker.getResolvedSignature(node);
|
|
32
|
-
const params = call_1.transformArguments(context, node.arguments, signature);
|
|
32
|
+
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
33
33
|
const math = lua.createIdentifier("math");
|
|
34
34
|
const expressionName = expression.name.text;
|
|
35
35
|
switch (expressionName) {
|
|
@@ -37,7 +37,7 @@ function transformMathCall(context, node) {
|
|
|
37
37
|
// Otherwise: math.atan2(y, x)
|
|
38
38
|
case "atan2": {
|
|
39
39
|
if (context.luaTarget === CompilerOptions_1.LuaTarget.Universal) {
|
|
40
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.MathAtan2, node, ...params);
|
|
40
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.MathAtan2, node, ...params);
|
|
41
41
|
}
|
|
42
42
|
const method = lua.createStringLiteral(context.luaTarget === CompilerOptions_1.LuaTarget.Lua53 ? "atan" : "atan2");
|
|
43
43
|
return lua.createCallExpression(lua.createTableIndexExpression(math, method), params, node);
|
|
@@ -84,7 +84,7 @@ function transformMathCall(context, node) {
|
|
|
84
84
|
return lua.createCallExpression(lua.createTableIndexExpression(math, method), params, node);
|
|
85
85
|
}
|
|
86
86
|
default:
|
|
87
|
-
context.diagnostics.push(diagnostics_1.unsupportedProperty(expression.name, "Math", expressionName));
|
|
87
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(expression.name, "Math", expressionName));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
exports.transformMathCall = transformMathCall;
|