Bug 138143

Summary: AST Nodes should keep track of their end offset
Product: WebKit Reporter: Saam Barati <saam>
Component: JavaScriptCoreAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, fpizlo, ggaren, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
patch
fpizlo: review+
patch fpizlo: review+

Description Saam Barati 2014-10-28 12:08:39 PDT
Currently, AST nodes only keep track of their starting position (offer, line number, and offset from line number).
This patch will make AST nodes also keep track of their ending offset.
Comment 1 Saam Barati 2014-10-28 13:09:56 PDT
Created attachment 240566 [details]
patch

Here is a patch that records the end offsets for all AST nodes.

It's a bit awkward that the endOffset property on Node is just an int. To be symmetric with node's position property, it should be a JSTextPosition.
But because we don't need the other two fields on JSTextPosition, making it an int is more efficient.
Comment 2 Saam Barati 2014-10-29 21:22:53 PDT
Created attachment 240656 [details]
patch
Comment 3 Filip Pizlo 2014-10-29 21:37:56 PDT
Comment on attachment 240656 [details]
patch

LGTM!
Comment 4 Saam Barati 2014-10-30 15:05:00 PDT
Created attachment 240705 [details]
patch

This fixes a few problems with the previous patch:
1. parseStatement should handle the case when result is null.
2. The FunctionBody and PropertyNode nodes weren't being assigned an endOffset.
Comment 5 Saam Barati 2014-10-30 16:51:24 PDT
landed in: http://trac.webkit.org/changeset/175396