Skip to content

Commit 078cd66

Browse files
committed
Remove bitwise operators
1 parent ddfba50 commit 078cd66

33 files changed

Lines changed: 107 additions & 0 deletions

File tree

src/parser/expression.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ pp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
246246
}
247247
}
248248

249+
if (this.hasPlugin("lightscript") && this.isBitwiseOp()) {
250+
this.unexpected(null, "Bitwise operators have been disabled in LightScript. " +
251+
"Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`).");
252+
}
253+
249254
const prec = this.state.type.binop;
250255
if (prec != null && (!noIn || !this.match(tt._in))) {
251256
if (prec > minPrec) {

src/plugins/lightscript.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,15 @@ pp.tryParseNamedArrowDeclaration = function () {
546546
return node;
547547
};
548548

549+
pp.isBitwiseOp = function () {
550+
return (
551+
this.match(tt.bitwiseOR) ||
552+
this.match(tt.bitwiseAND) ||
553+
this.match(tt.bitwiseXOR) ||
554+
this.match(tt.bitShift)
555+
);
556+
};
557+
549558

550559
export default function (instance) {
551560

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Bitwise operators have been disabled in LightScript. Use the stdlib functions instead (eg; `bitwiseAnd(a, b)`). (1:2)"
3+
}

0 commit comments

Comments
 (0)