Bug 138143 - AST Nodes should keep track of their end offset
Summary: AST Nodes should keep track of their end offset
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-28 12:08 PDT by Saam Barati
Modified: 2014-10-30 16:51 PDT (History)
4 users (show)

See Also:


Attachments
patch (6.48 KB, patch)
2014-10-28 13:09 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch (7.63 KB, patch)
2014-10-29 21:22 PDT, Saam Barati
fpizlo: review+
Details | Formatted Diff | Diff
patch (10.76 KB, patch)
2014-10-30 15:05 PDT, Saam Barati
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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