Bug 1587338 - Remove `const BinASTKind kind` parameter from non-sum parser methods. r=Yoric

Differential Revision: https://phabricator.services.mozilla.com/D48662

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tooru Fujisawa 2019-10-11 03:48:14 +00:00
Родитель 9ab36a85d7
Коммит a459e854b2
6 изменённых файлов: 451 добавлений и 709 удалений

Просмотреть файл

@ -977,7 +977,7 @@ EagerFunctionExpression:
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
BINJS_TRY_DECL(bodyScope,
handler_.newLexicalScope(*lexicalScopeData, body));
BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox));
BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox));
MOZ_TRY(setFunctionParametersAndBody(result, params, bodyScope));
MOZ_TRY(finishEagerFunction(funbox, nargs));
@ -1012,7 +1012,7 @@ LazyFunctionExpression:
forceStrictIfNecessary(funbox, directives);
BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, kind, funbox));
BINJS_MOZ_TRY_DECL(result, makeEmptyFunctionNode(start, syntax, funbox));
auto skipStart = contentsSkip.startOffset();
auto skipEnd = skipStart + contentsSkip.length();
@ -1039,7 +1039,7 @@ EagerMethod:
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
BINJS_TRY_DECL(bodyScope,
handler_.newLexicalScope(*lexicalScopeData, body));
BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, kind, funbox));
BINJS_MOZ_TRY_DECL(method, makeEmptyFunctionNode(start, syntax, funbox));
MOZ_TRY(setFunctionParametersAndBody(method, params, bodyScope));
BINJS_TRY_DECL(result,
handler_.newObjectMethodOrPropertyDefinition(name, method,
@ -1369,7 +1369,7 @@ ReturnStatement:
init: |
if (!pc_->isFunctionBox()) {
// Return statements are permitted only inside functions.
return raiseInvalidKind("Toplevel Statement", kind);
return raiseInvalidKind("Toplevel Statement", BinASTKind::ReturnStatement);
}
pc_->functionBox()->usesReturn = true;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -224,289 +224,214 @@ class BinASTParser : public BinASTParserPerTokenizer<Tok> {
JS::Result<ParseNode*> parseSwitchDefault(const FieldContext& context);
JS::Result<ParseNode*> parseVariableDeclarator(const ListContext& context);
JS::Result<ParseNode*> parseInterfaceArrayAssignmentTarget(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceArrayBinding(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceArrayExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<Ok> parseInterfaceAssertedBlockScope(const size_t start,
const BinASTKind kind,
const FieldContext& context);
JS::Result<Ok> parseInterfaceAssertedBoundName(const size_t start,
const BinASTKind kind,
AssertedScopeKind scopeKind,
const ListContext& context);
JS::Result<Ok> parseInterfaceAssertedBoundNamesScope(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<Ok> parseInterfaceAssertedDeclaredName(const size_t start,
const BinASTKind kind,
AssertedScopeKind scopeKind,
const ListContext& context);
JS::Result<Ok> parseInterfaceAssertedParameterScope(
const size_t start, const BinASTKind kind,
MutableHandle<GCVector<JSAtom*>> positionalParams,
const size_t start, MutableHandle<GCVector<JSAtom*>> positionalParams,
const FieldContext& context);
JS::Result<Ok> parseInterfaceAssertedPositionalParameterName(
const size_t start, const BinASTKind kind, AssertedScopeKind scopeKind,
const size_t start, AssertedScopeKind scopeKind,
MutableHandle<GCVector<JSAtom*>> positionalParams,
const ListContext& context);
JS::Result<Ok> parseInterfaceAssertedScriptGlobalScope(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<Ok> parseInterfaceAssertedVarScope(const size_t start,
const BinASTKind kind,
const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceAssignmentExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceAssignmentTargetIdentifier(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceAwaitExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceBinaryExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceBindingIdentifier(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceBindingWithInitializer(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceBlock(const size_t start,
const BinASTKind kind,
const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceBreakStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceCallExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<LexicalScopeNode*> parseInterfaceCatchClause(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceClassDeclaration(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceClassExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceCompoundAssignmentExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceComputedMemberAssignmentTarget(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceComputedMemberExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceComputedPropertyName(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceConditionalExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceContinueStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceDataProperty(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceDebuggerStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceDirective(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceDoWhileStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerArrowExpressionWithExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerArrowExpressionWithFunctionBody(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerFunctionDeclaration(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerFunctionExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerGetter(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerMethod(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceEagerSetter(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceEmptyStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceExpressionStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceForInOfBinding(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceForInStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceForOfStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceForStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ListNode*> parseInterfaceFormalParameters(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<Ok> parseInterfaceFunctionExpressionContents(
const size_t start, const BinASTKind kind, uint32_t funLength,
ListNode** paramsOut, ListNode** bodyOut,
const FieldOrRootContext& context);
const size_t start, uint32_t funLength, ListNode** paramsOut,
ListNode** bodyOut, const FieldOrRootContext& context);
JS::Result<Ok> parseInterfaceFunctionOrMethodContents(
const size_t start, const BinASTKind kind, uint32_t funLength,
ListNode** paramsOut, ListNode** bodyOut,
const FieldOrRootContext& context);
JS::Result<Ok> parseInterfaceGetterContents(
const size_t start, const BinASTKind kind, uint32_t funLength,
ListNode** paramsOut, ListNode** bodyOut, const FieldContext& context);
const size_t start, uint32_t funLength, ListNode** paramsOut,
ListNode** bodyOut, const FieldOrRootContext& context);
JS::Result<Ok> parseInterfaceGetterContents(const size_t start,
uint32_t funLength,
ListNode** paramsOut,
ListNode** bodyOut,
const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceIdentifierExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceIfStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLabelledStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLazyArrowExpressionWithExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLazyArrowExpressionWithFunctionBody(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLazyFunctionDeclaration(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLazyFunctionExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLazyGetter(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceLazyMethod(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceLazySetter(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralBooleanExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralInfinityExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralNullExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralNumericExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralPropertyName(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralRegExpExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceLiteralStringExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceModule(const size_t start,
const BinASTKind kind,
const RootContext& context);
JS::Result<ParseNode*> parseInterfaceNewExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceNewTargetExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceObjectAssignmentTarget(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceObjectBinding(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceObjectExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceReturnStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceScript(const size_t start,
const BinASTKind kind,
const RootContext& context);
JS::Result<Ok> parseInterfaceSetterContents(
const size_t start, const BinASTKind kind, uint32_t funLength,
ListNode** paramsOut, ListNode** bodyOut, const FieldContext& context);
JS::Result<Ok> parseInterfaceSetterContents(const size_t start,
uint32_t funLength,
ListNode** paramsOut,
ListNode** bodyOut,
const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceShorthandProperty(
const size_t start, const BinASTKind kind, const ListContext& context);
const size_t start, const ListContext& context);
JS::Result<ParseNode*> parseInterfaceSpreadElement(
const size_t start, const BinASTKind kind, const ListContext& context);
const size_t start, const ListContext& context);
JS::Result<ParseNode*> parseInterfaceStaticMemberAssignmentTarget(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceStaticMemberExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceSuper(const size_t start,
const BinASTKind kind,
const FieldContext& context);
JS::Result<CaseClause*> parseInterfaceSwitchCase(const size_t start,
const BinASTKind kind,
const ListContext& context);
JS::Result<ParseNode*> parseInterfaceSwitchDefault(
const size_t start, const BinASTKind kind, const FieldContext& context);
const size_t start, const FieldContext& context);
JS::Result<ParseNode*> parseInterfaceSwitchStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceSwitchStatementWithDefault(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceTemplateExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceThisExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceThrowStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceTryCatchStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceTryFinallyStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceUnaryExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceUpdateExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceVariableDeclaration(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceVariableDeclarator(
const size_t start, const BinASTKind kind, const ListContext& context);
const size_t start, const ListContext& context);
JS::Result<ParseNode*> parseInterfaceWhileStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceWithStatement(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceYieldExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
JS::Result<ParseNode*> parseInterfaceYieldStarExpression(
const size_t start, const BinASTKind kind,
const FieldOrListContext& context);
const size_t start, const FieldOrListContext& context);
// ----- String enums (by lexicographical order)
JS::Result<typename BinASTParser<Tok>::AssertedDeclaredKind>

Просмотреть файл

@ -207,11 +207,8 @@ JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::parseLazyFunction(
NewLexicalScopeData(cx_, lexicalScope, alloc_, pc_));
BINJS_TRY_DECL(body, handler_.newLexicalScope(*lexicalScopeData, tmpBody));
auto binASTKind = isExpr ? BinASTKind::LazyFunctionExpression
: BinASTKind::LazyFunctionDeclaration;
BINJS_MOZ_TRY_DECL(result,
makeEmptyFunctionNode(firstOffset, binASTKind, funbox));
makeEmptyFunctionNode(firstOffset, syntaxKind, funbox));
MOZ_TRY(setFunctionParametersAndBody(result, params, body));
MOZ_TRY(finishEagerFunction(funbox, nargs));
return result;
@ -295,41 +292,12 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
return funbox;
}
FunctionSyntaxKind BinASTKindToFunctionSyntaxKind(const BinASTKind kind) {
// FIXME: this doesn't cover FunctionSyntaxKind::ClassConstructor and
// FunctionSyntaxKind::DerivedClassConstructor.
switch (kind) {
case BinASTKind::EagerFunctionDeclaration:
case BinASTKind::LazyFunctionDeclaration:
return FunctionSyntaxKind::Statement;
case BinASTKind::EagerFunctionExpression:
case BinASTKind::LazyFunctionExpression:
return FunctionSyntaxKind::Expression;
case BinASTKind::EagerArrowExpressionWithFunctionBody:
case BinASTKind::LazyArrowExpressionWithFunctionBody:
case BinASTKind::EagerArrowExpressionWithExpression:
case BinASTKind::LazyArrowExpressionWithExpression:
return FunctionSyntaxKind::Arrow;
case BinASTKind::EagerMethod:
case BinASTKind::LazyMethod:
return FunctionSyntaxKind::Method;
case BinASTKind::EagerGetter:
case BinASTKind::LazyGetter:
return FunctionSyntaxKind::Getter;
case BinASTKind::EagerSetter:
case BinASTKind::LazySetter:
return FunctionSyntaxKind::Setter;
default:
MOZ_CRASH("Invalid/ kind");
}
}
template <typename Tok>
JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::makeEmptyFunctionNode(
const size_t start, const BinASTKind kind, FunctionBox* funbox) {
const size_t start, const FunctionSyntaxKind syntaxKind,
FunctionBox* funbox) {
// LazyScript compilation requires basically none of the fields filled out.
TokenPos pos = tokenizer_->pos(start);
FunctionSyntaxKind syntaxKind = BinASTKindToFunctionSyntaxKind(kind);
BINJS_TRY_DECL(result, handler_.newFunction(syntaxKind, pos));

Просмотреть файл

@ -141,9 +141,9 @@ class BinASTParserPerTokenizer : public BinASTParserBase,
FunctionSyntaxKind syntax,
ParseNode* name);
JS::Result<FunctionNode*> makeEmptyFunctionNode(const size_t start,
const BinASTKind kind,
FunctionBox* funbox);
JS::Result<FunctionNode*> makeEmptyFunctionNode(
const size_t start, const FunctionSyntaxKind syntaxKind,
FunctionBox* funbox);
MOZ_MUST_USE JS::Result<Ok> setFunctionParametersAndBody(FunctionNode* fun,
ListNode* params,
ParseNode* body);

Просмотреть файл

@ -548,10 +548,18 @@ enum MethodCallKind {
/// Fixed parameter of interface method.
const INTERFACE_PARAMS: &str =
"const size_t start, const BinASTKind kind";
"const size_t start";
/// Fixed arguments of interface method.
const INTERFACE_ARGS: &str =
"start";
/// Fixed parameter of sum interface method.
const SUM_INTERFACE_PARAMS: &str =
"const size_t start, const BinASTKind kind";
/// Fixed arguments of sum interface method.
const SUM_INTERFACE_ARGS: &str =
"start, kind";
/// The name of the toplevel interface for the script.
@ -1916,7 +1924,7 @@ enum class {name} {{
let rules_for_this_sum = self.rules.get(name);
let extra_params = rules_for_this_sum.extra_params;
let rendered = self.get_method_signature(name, prefix,
INTERFACE_PARAMS,
SUM_INTERFACE_PARAMS,
&extra_params);
buffer.push_str(&rendered.reindent(" ")
.newline_if_not_empty());
@ -2114,7 +2122,7 @@ impl CPPExporter {
",
bnf = rendered_bnf,
call = self.get_method_call("result", name,
"Sum", INTERFACE_ARGS,
"Sum", SUM_INTERFACE_ARGS,
&extra_args,
"context".to_string(),
MethodCallKind::AlwaysDecl)
@ -2175,7 +2183,7 @@ impl CPPExporter {
kind = kind,
cases = buffer_cases,
first_line = self.get_method_definition_start(name, inner_prefix,
INTERFACE_PARAMS,
SUM_INTERFACE_PARAMS,
&extra_params),
type_ok = self.get_type_ok(name)
));
@ -2410,7 +2418,7 @@ impl CPPExporter {
first_line = self.get_method_definition_start(&parser.name, "", "",
&extra_params),
call = self.get_method_call("result", &parser.elements,
"Sum", INTERFACE_ARGS,
"Sum", SUM_INTERFACE_ARGS,
&extra_args,
self.get_context_param_for_optional(
&parser.name,
@ -2775,7 +2783,6 @@ impl CPPExporter {
} else {
buffer.push_str(&format!("{first_line}
{{
MOZ_ASSERT(kind == BinASTKind::{kind});
BINJS_TRY(CheckRecursionLimit(cx_));
{pre}{fields_implem}
{post} return result;
@ -2785,7 +2792,6 @@ impl CPPExporter {
fields_implem = fields_implem,
pre = init.newline_if_not_empty(),
post = build_result.newline_if_not_empty(),
kind = name.to_cpp_enum_case(),
first_line = first_line,
));
}