Browse Source

Remove "undefined" redefinition protection

See #441.
redux
David Majda 5 years ago
parent
commit
f36a667376
  1. 2
      lib/compiler/index.js
  2. 12
      lib/compiler/passes/generate-js.js
  3. 114
      lib/parser.js
  4. 2
      lib/peg.js

2
lib/compiler/index.js

@ -40,7 +40,7 @@ var compiler = {
* cause its malfunction.
*/
compile: function(ast, passes, options) {
options = options !== void 0 ? options : {};
options = options !== undefined ? options : {};
var stage;

12
lib/compiler/passes/generate-js.js

@ -243,7 +243,7 @@ function generateJS(ast, options) {
' break;',
'',
' case ' + op.PUSH_UNDEFINED + ':', // PUSH_UNDEFINED
' stack.push(void 0);',
' stack.push(undefined);',
' ip++;',
' break;',
'',
@ -430,7 +430,7 @@ function generateJS(ast, options) {
pop: function(n) {
var values;
if (n === void 0) {
if (n === undefined) {
return s(this.sp--);
} else {
values = arrays.range(this.sp - n + 1, this.sp + 1).map(s);
@ -536,7 +536,7 @@ function generateJS(ast, options) {
break;
case op.PUSH_UNDEFINED: // PUSH_UNDEFINED
parts.push(stack.push('void 0'));
parts.push(stack.push('undefined'));
ip++;
break;
@ -933,7 +933,7 @@ function generateJS(ast, options) {
parts.push([
'function peg$parse(input, options) {',
' options = options !== void 0 ? options : {};',
' options = options !== undefined ? options : {};',
'',
' var peg$FAILED = {},',
''
@ -1045,7 +1045,7 @@ function generateJS(ast, options) {
' }',
'',
' function expected(description, location) {',
' location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)',
' location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos)',
'',
' throw peg$buildStructuredError(',
' [peg$otherExpectation(description)],',
@ -1055,7 +1055,7 @@ function generateJS(ast, options) {
' }',
'',
' function error(message, location) {',
' location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)',
' location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos)',
'',
' throw peg$buildSimpleError(message, location);',
' }',

114
lib/parser.js

@ -130,7 +130,7 @@ peg$SyntaxError.buildMessage = function(expected, found) {
};
function peg$parse(input, options) {
options = options !== void 0 ? options : {};
options = options !== undefined ? options : {};
var peg$FAILED = {},
@ -514,7 +514,7 @@ function peg$parse(input, options) {
}
function expected(description, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
@ -524,7 +524,7 @@ function peg$parse(input, options) {
}
function error(message, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildSimpleError(message, location);
}
@ -1294,7 +1294,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -1561,7 +1561,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -1593,7 +1593,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -1667,7 +1667,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -1702,7 +1702,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -1767,7 +1767,7 @@ function peg$parse(input, options) {
s5 = peg$parseLineTerminator();
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -1793,7 +1793,7 @@ function peg$parse(input, options) {
s5 = peg$parseLineTerminator();
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -1836,7 +1836,7 @@ function peg$parse(input, options) {
s2 = peg$parseReservedWord();
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
s1 = undefined;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
@ -2307,7 +2307,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
s1 = undefined;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
@ -2384,7 +2384,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
s1 = undefined;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
@ -2584,7 +2584,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
s1 = undefined;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
@ -2682,7 +2682,7 @@ function peg$parse(input, options) {
s3 = peg$parseDecimalDigit();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -2855,7 +2855,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
s1 = undefined;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
@ -3130,7 +3130,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -3163,7 +3163,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -3235,7 +3235,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -3268,7 +3268,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = void 0;
s4 = undefined;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
@ -3506,7 +3506,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3543,7 +3543,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3580,7 +3580,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3617,7 +3617,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3654,7 +3654,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3691,7 +3691,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3728,7 +3728,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3765,7 +3765,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3802,7 +3802,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3839,7 +3839,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3876,7 +3876,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3913,7 +3913,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3950,7 +3950,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -3987,7 +3987,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4024,7 +4024,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4061,7 +4061,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4098,7 +4098,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4135,7 +4135,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4172,7 +4172,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4209,7 +4209,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4246,7 +4246,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4283,7 +4283,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4320,7 +4320,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4357,7 +4357,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4394,7 +4394,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4431,7 +4431,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4468,7 +4468,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4505,7 +4505,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4542,7 +4542,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4579,7 +4579,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4616,7 +4616,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4653,7 +4653,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4690,7 +4690,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4727,7 +4727,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4764,7 +4764,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4801,7 +4801,7 @@ function peg$parse(input, options) {
s3 = peg$parseIdentifierPart();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
s2 = undefined;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
@ -4950,7 +4950,7 @@ function peg$parse(input, options) {
}
peg$silentFails--;
if (s1 === peg$FAILED) {
s0 = void 0;
s0 = undefined;
} else {
peg$currPos = s0;
s0 = peg$FAILED;

2
lib/peg.js

@ -22,7 +22,7 @@ var peg = {
* generated parser and cause its malfunction.
*/
generate: function(grammar, options) {
options = options !== void 0 ? options : {};
options = options !== undefined ? options : {};
function convertPasses(passes) {
var converted = {}, stage;

Loading…
Cancel
Save