esfuzz
Version:
JS fuzzer for generative testing of parsers that implement the SpiderMonkey Reflect.parse API
51 lines (50 loc) • 1.6 kB
JavaScript
// Generated by CoffeeScript 2.0.0-beta7
void function () {
var cache$, construct, Expression, maybe, Node, returnable, ReturnStatement, Statement;
Node = require('../node');
Expression = require('../classes/Expression');
Statement = require('../classes/Statement');
cache$ = require('../combinators');
construct = cache$.construct;
maybe = cache$.maybe;
returnable = function (ancestors) {
var ancestor;
for (var i$ = 0, length$ = ancestors.length; i$ < length$; ++i$) {
ancestor = ancestors[i$];
if (!(ancestor.type === 'FunctionDeclaration' || ancestor.type === 'FunctionExpression'))
continue;
return true;
}
return false;
};
ReturnStatement = function (super$) {
extends$(ReturnStatement, super$);
ReturnStatement.prototype.type = ReturnStatement.name;
function ReturnStatement(depth, ancestors) {
--depth;
if (depth > 0 && returnable(ancestors)) {
ancestors = [this].concat(ancestors);
this.argument = maybe(Expression)(depth, ancestors);
} else {
return Statement(0);
}
}
return ReturnStatement;
}(Node);
module.exports = construct(ReturnStatement);
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);