esfuzz
Version:
JS fuzzer for generative testing of parsers that implement the SpiderMonkey Reflect.parse API
84 lines (83 loc) • 2.56 kB
JavaScript
// Generated by CoffeeScript 2.0.0-beta7
void function () {
var cache$, construct, continuable, ContinueStatement, FUNCTIONS, Identifier, ITERATION_STATEMENTS, labels, maybe, Node, randomElement, Statement;
Node = require('../node');
Statement = require('../classes/Statement');
Identifier = require('./Identifier');
cache$ = require('../combinators');
construct = cache$.construct;
maybe = cache$.maybe;
randomElement = require('../random').randomElement;
FUNCTIONS = [
'FunctionDeclaration',
'FunctionExpression'
];
ITERATION_STATEMENTS = [
'ForStatement',
'ForInStatement',
'DoWhileStatement',
'WhileStatement'
];
continuable = function (ancestors) {
var ancestor;
for (var i$ = 0, length$ = ancestors.length; i$ < length$; ++i$) {
ancestor = ancestors[i$];
if (in$(ancestor.type, FUNCTIONS))
return false;
if (in$(ancestor.type, ITERATION_STATEMENTS))
return true;
}
return false;
};
labels = function (ancestors) {
var accum, ancestor, i;
accum = [];
for (var i$ = 0, length$ = ancestors.length; i$ < length$; ++i$) {
ancestor = ancestors[i$];
i = i$;
if (in$(ancestor.type, FUNCTIONS))
break;
if (ancestor.type === 'LabeledStatement' && i > 0 && in$(ancestors[i - 1].type, ITERATION_STATEMENTS))
accum.push(ancestor.label);
}
return accum;
};
ContinueStatement = function (super$) {
extends$(ContinueStatement, super$);
ContinueStatement.prototype.type = ContinueStatement.name;
ContinueStatement.prototype.label = null;
function ContinueStatement(depth, ancestors) {
--depth;
if (depth > 0 && continuable(ancestors)) {
this.label = maybe(function () {
return randomElement(labels(ancestors));
})(depth);
} else {
return Statement(0);
}
}
return ContinueStatement;
}(Node);
module.exports = construct(ContinueStatement);
function in$(member, list) {
for (var i = 0, length = list.length; i < length; ++i)
if (i in list && list[i] === member)
return true;
return false;
}
function isOwn$(o, p) {
return {}.hasOwnProperty.call(o, p);
}
function extends$(child, parent) {
for (var key in parent)
if (isOwn$(parent, key))
child[key] = parent[key];
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}
}.call(this);