[Webkit-unassigned] [Bug 144955] [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri May 15 14:33:12 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=144955

--- Comment #7 from Ryosuke Niwa <rniwa at webkit.org> ---
Comment on attachment 253195
  --> https://bugs.webkit.org/attachment.cgi?id=253195
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253195&action=review

> Source/JavaScriptCore/parser/ASTBuilder.h:372
> +        ? m_sourceCode->subArrowExpression(info.arrowFunctionOffset, info.closeBraceOffset, info.bodyStartLine, info.bodyStartColumn)
> +        : m_sourceCode->subExpression(info.openBraceOffset, info.closeBraceOffset, info.bodyStartLine, info.bodyStartColumn);

Wrong indentation. ? and : should be exactly 4 spaces to the right from the beginning of "SourceCode source".

> Source/JavaScriptCore/parser/ASTBuilder.h:375
> +        info.body->setLoc(info.bodyStartLine, info.bodyEndLine, location.startOffset, location.lineStartOffset);

Ditto. Indent the second line by exactly 4 spaces further to the right (12 total spaces).

> Source/JavaScriptCore/parser/Lexer.cpp:1824
> +            tokenData->line = savedlineNumber;
> +            tokenData->offset = savedOffset;
> +            tokenData->lineStartOffset = savedLineStartOffset;
> +
> +            ASSERT(tokenData->offset >= tokenData->lineStartOffset);

I don't think we want to shift() and then set offset back manually like this.
We should use peek() instead.

> Source/JavaScriptCore/parser/Parser.cpp:605
> +    setEndOfStatement();

Why do we need this?

> Source/JavaScriptCore/parser/Parser.cpp:1203
> +            context.setEndOffset(result, m_lastTokenEndPosition.offset);

What is this setEndOffset for?

> Source/JavaScriptCore/parser/Parser.cpp:1260
> +        // Consume the end of arrow function ,;]) and prevent
> +        // parse this symbols by parseStatement as separate statement

I don't understand this comment.
In general, we prefer adding assertions to document conditions rather than adding comments.
Is there a way to express this as an assertion instead?

> Source/JavaScriptCore/parser/Parser.cpp:1341
> +#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
> +    if (parseType == StandardFunctionParseType) {
> +        next();
> +        if (match(CLOSEBRACE)) {
> +            unsigned endColumn = tokenColumn();
> +            return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind);
> +        }
> +    }
> +#else

It's not great to duplicate the code like this.
Since FunctionParseType is always define, we should just use that without wrapping in if-def.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150515/2ee3b7d9/attachment-0001.html>


More information about the webkit-unassigned mailing list