There was an error while loading. Please reload this page.
1 parent 1c3fd47 commit 3bd5d04Copy full SHA for 3bd5d04
3 files changed
dist/Transpiler.js
@@ -443,9 +443,33 @@ var LuaTranspiler = /** @class */ (function () {
443
case ts.SyntaxKind.AmpersandToken:
444
result = "bit.band(" + lhs + "," + rhs + ")";
445
break;
446
+ case ts.SyntaxKind.AmpersandEqualsToken:
447
+ result = lhs + "=bit.band(" + lhs + "," + rhs + ")";
448
+ break;
449
case ts.SyntaxKind.BarToken:
450
result = "bit.bor(" + lhs + "," + rhs + ")";
451
452
+ case ts.SyntaxKind.BarEqualsToken:
453
+ result = lhs + "=bit.bor(" + lhs + "," + rhs + ")";
454
455
+ case ts.SyntaxKind.LessThanLessThanToken:
456
+ result = "bit.lshift(" + lhs + "," + rhs + ")";
457
458
+ case ts.SyntaxKind.LessThanLessThanEqualsToken:
459
+ result = lhs + "=bit.lshift(" + lhs + "," + rhs + ")";
460
461
+ case ts.SyntaxKind.GreaterThanGreaterThanToken:
462
+ result = "bit.arshift(" + lhs + "," + rhs + ")";
463
464
+ case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
465
+ result = lhs + "=bit.arshift(" + lhs + "," + rhs + ")";
466
467
+ case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
468
+ result = "bit.rshift(" + lhs + "," + rhs + ")";
469
470
+ case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
471
+ result = lhs + "=bit.rshift(" + lhs + "," + rhs + ")";
472
473
case ts.SyntaxKind.PlusToken:
474
// Replace string + with ..
475
var typeLeft = this.checker.getTypeAtLocation(node.left);
src/Transpiler.ts
@@ -486,9 +486,33 @@ export class LuaTranspiler {
486
487
result = `bit.band(${lhs},${rhs})`;
488
489
490
+ result = `${lhs}=bit.band(${lhs},${rhs})`;
491
492
493
result = `bit.bor(${lhs},${rhs})`;
494
495
496
+ result = `${lhs}=bit.bor(${lhs},${rhs})`;
497
498
499
+ result = `bit.lshift(${lhs},${rhs})`;
500
501
502
+ result = `${lhs}=bit.lshift(${lhs},${rhs})`;
503
504
505
+ result = `bit.arshift(${lhs},${rhs})`;
506
507
508
+ result = `${lhs}=bit.arshift(${lhs},${rhs})`;
509
510
511
+ result = `bit.rshift(${lhs},${rhs})`;
512
513
514
+ result = `${lhs}=bit.rshift(${lhs},${rhs})`;
515
516
517
518
const typeLeft = this.checker.getTypeAtLocation(node.left);
test/unit/expressions.spec.ts
@@ -39,7 +39,15 @@ export class ExpressionTests {
39
@TestCase("a*=b", "a=a*b")
40
@TestCase("a/=b", "a=a/b")
41
@TestCase("a&b", "bit.band(a,b)")
42
+ @TestCase("a&=b", "a=bit.band(a,b)")
43
@TestCase("a|b", "bit.bor(a,b)")
44
+ @TestCase("a|=b", "a=bit.bor(a,b)")
45
+ @TestCase("a<<b", "bit.lshift(a,b)")
46
+ @TestCase("a<<=b", "a=bit.lshift(a,b)")
47
+ @TestCase("a>>b", "bit.arshift(a,b)")
48
+ @TestCase("a>>=b", "a=bit.arshift(a,b)")
49
+ @TestCase("a>>>b", "bit.rshift(a,b)")
50
+ @TestCase("a>>>=b", "a=bit.rshift(a,b)")
51
@Test("Binary expressions overridden operators")
52
public binaryOperatorOverride(input: string, lua: string) {
53
Expect(transpileString(input)).toBe(lua);
@@ -61,4 +69,4 @@ export class ExpressionTests {
61
69
public conditional(input: string, lua: string) {
62
70
63
71
}
64
-}
72
+}
0 commit comments