[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
Mon May 18 09:36:34 PDT 2015


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

--- Comment #12 from GSkachkov <gskachkov at gmail.com> ---
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->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".
> 
> I believe this is for the controlFlowProfiler

Fixed. Please check if correct.

>> 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).

Why do we need indent for 'info.body->setLoc()' statement?

>> Source/JavaScriptCore/parser/Lexer.cpp:1824
>> +            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.

Done

>> Source/JavaScriptCore/parser/Parser.cpp:605
>> +    setEndOfStatement();
> 
> Why do we need this?

Ohh, it will be difficult to explain with my English, but I'll try. 
I need invoke this function to set correctly position inside of the lexer. It is added by me in Source/JavaScriptCore/parser/Lexer.cpp line 1723 and repeat the same statement as do for '}'  in lexer https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/parser/Lexer.cpp#L1990. 
It is necessary because incase of arrow function with expression (var f = x=> x+1;) symbols ';', ']', '}', ')', and ',' has two meaning first it is end of statement and  second end of arrow function body. I haven't found way move this logic to lexer because only parser knowing context when it is only end of statement or end of arrow function body as well.

>>> Source/JavaScriptCore/parser/Parser.cpp:1203
>>> +            context.setEndOffset(result, m_lastTokenEndPosition.offset);
>> 
>> What is this setEndOffset for?
> 
> Actually, this is wrong. How does this code not segfault?
> setEndOffset is meant to be called with non-null AST nodes

Hmm, I run this method to set correct ending of the block for arrow function with expression for instance var f = x => x + 10; 
Where ';' is used as end of the statement var f...; and end of arrow function x=>x+10;
For the same purpose as in this method https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/parser/Parser.cpp#L1426

>> Source/JavaScriptCore/parser/Parser.cpp:2852
>> +    while (newCount--)
> 
> This should be tested.

I've removed this code.

-- 
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/20150518/cc9e8a9f/attachment-0001.html>


More information about the webkit-unassigned mailing list