<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[181996] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181996">181996</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-03-25 21:37:35 -0700 (Wed, 25 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update prepare-ChangeLog to work with ES6 Class syntax
https://bugs.webkit.org/show_bug.cgi?id=143069
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-25
Reviewed by Timothy Hatcher.
* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_javascript):
Better handle ES6 Class syntax.
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests-expected.txt:
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests.js:
(BaseClass):
(DerivedClass):
(DerivedClass.staticMethod):
(DerivedClass.prototype.method.nestedFunctionInsideMethod):
(DerivedClass.prototype.method):
(DerivedClass.prototype.get getter):
(namespace.MyClass):
(namespace.MyClass.staticMethod):
(namespace.MyClass.prototype.method.nestedFunctionInsideMethod):
(namespace.MyClass.prototype.method):
(namespace.MyClass.prototype.get getter):
Proof!</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsprepareChangeLog">trunk/Tools/Scripts/prepare-ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitperlprepareChangeLog_unittestresourcesjavascript_unittestsexpectedtxt">trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests-expected.txt</a></li>
<li><a href="#trunkToolsScriptswebkitperlprepareChangeLog_unittestresourcesjavascript_unittestsjs">trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (181995 => 181996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-03-26 04:35:31 UTC (rev 181995)
+++ trunk/Tools/ChangeLog        2015-03-26 04:37:35 UTC (rev 181996)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2015-03-25 Joseph Pecoraro <pecoraro@apple.com>
+
+ Update prepare-ChangeLog to work with ES6 Class syntax
+ https://bugs.webkit.org/show_bug.cgi?id=143069
+
+ Reviewed by Timothy Hatcher.
+
+ * Scripts/prepare-ChangeLog:
+ (get_function_line_ranges_for_javascript):
+ Better handle ES6 Class syntax.
+
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests-expected.txt:
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests.js:
+ (BaseClass):
+ (DerivedClass):
+ (DerivedClass.staticMethod):
+ (DerivedClass.prototype.method.nestedFunctionInsideMethod):
+ (DerivedClass.prototype.method):
+ (DerivedClass.prototype.get getter):
+ (namespace.MyClass):
+ (namespace.MyClass.staticMethod):
+ (namespace.MyClass.prototype.method.nestedFunctionInsideMethod):
+ (namespace.MyClass.prototype.method):
+ (namespace.MyClass.prototype.get getter):
+ Proof!
+
</ins><span class="cx"> 2015-03-25 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> Use JITCompilationCanFail in more places, and make the fail path of JITCompilationMustSucceed a crash instead of attempting GC
</span></span></pre></div>
<a id="trunkToolsScriptsprepareChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/prepare-ChangeLog (181995 => 181996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/prepare-ChangeLog        2015-03-26 04:35:31 UTC (rev 181995)
+++ trunk/Tools/Scripts/prepare-ChangeLog        2015-03-26 04:37:35 UTC (rev 181996)
</span><span class="lines">@@ -1250,19 +1250,49 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> # Read a file and get all the line ranges of the things that look like
</span><del>-# JavaScript functions.
</del><ins>+# JavaScript functions or methods.
</ins><span class="cx"> #
</span><span class="cx"> # A function name is the word that immediately follows `function' when
</span><del>-# followed by an open curly brace. It can appear at the top level, or
-# inside other functions.
</del><ins>+# followed by an open curly brace. It can appear at the top level,
+# or inside other functions. For example:
</ins><span class="cx"> #
</span><del>-# An anonymous function name is the identifier chain immediately before
</del><ins>+# function name() { // (name)
+# function inner() { } // (name.inner)
+# }
+#
+# An anonymous function name is the identifier on the left hand side of
</ins><span class="cx"> # an assignment with the equals operator or object notation that has a
</span><del>-# value starting with `function' followed by an open curly brace.
</del><ins>+# value starting with `function' followed an open curly brace.
+# For example:
</ins><span class="cx"> #
</span><ins>+# namespace = {
+# name: function() {} // (namespace.name)
+# }
+# namespace.Foo = function() {} // (namespace.Foo)
+#
</ins><span class="cx"> # A getter or setter name is the word that immediately follows `get' or
</span><del>-# `set' when followed by an open curly brace .
</del><ins>+# `set' when followed by params and an open curly brace. For example:
</ins><span class="cx"> #
</span><ins>+# namespace = {
+# get foo() {} // (namespace.get foo)
+# }
+#
+# A method name is the word immediately before parenthesis, with an open
+# curly brace immediately following closing parenthesis. For simplification
+# we only parse for methods inside of a class. And for a class expression
+# we take the assignment identifier instead of the class name for namespacing.
+#
+# namespace.Foo = class DoesNotMatter extends Bar {
+# constructor() {} // (namespace.Foo)
+# static staticMethod() {} // (namespace.Foo.staticMethod)
+# instanceMethod() {} // (namespace.Foo.prototype.instanceMethod)
+# get getter() {} // (namespace.Foo.prototype.get getter)
+# }
+# class ClassName {
+# constructor() {} // (ClassName)
+# method() {} // (ClassName.prototype.method)
+# }
+#
</ins><span class="cx"> # Comment handling is simple-minded but will work for all but pathological cases.
</span><span class="cx"> #
</span><span class="cx"> # Result is a list of triples: [ start_line, end_line, function_name ].
</span><span class="lines">@@ -1273,6 +1303,7 @@
</span><span class="cx">
</span><span class="cx"> my @currentScopes;
</span><span class="cx"> my @currentIdentifiers;
</span><ins>+ my @currentParsingMode = ("global");
</ins><span class="cx"> my @currentFunctionNames;
</span><span class="cx"> my @currentFunctionDepths;
</span><span class="cx"> my @currentFunctionStartLines;
</span><span class="lines">@@ -1281,14 +1312,20 @@
</span><span class="cx">
</span><span class="cx"> my $inComment = 0;
</span><span class="cx"> my $inQuotedText = "";
</span><ins>+ my $inExtends = 0;
+ my $inMethod = 0;
</ins><span class="cx"> my $parenthesesDepth = 0;
</span><span class="cx"> my $bracesDepth = 0;
</span><span class="cx">
</span><ins>+ my $classJustSeen = 0;
+ my $parenthesisJustSeen = 0;
</ins><span class="cx"> my $functionJustSeen = 0;
</span><span class="cx"> my $getterJustSeen = 0;
</span><span class="cx"> my $setterJustSeen = 0;
</span><span class="cx"> my $assignmentJustSeen = 0;
</span><ins>+ my $staticOrContructorSeen = 0;
</ins><span class="cx">
</span><ins>+ my $possibleMethodName = "";
</ins><span class="cx"> my $word = "";
</span><span class="cx">
</span><span class="cx"> while (<$fileHandle>) {
</span><span class="lines">@@ -1326,38 +1363,69 @@
</span><span class="cx">
</span><span class="cx"> # Find function names.
</span><span class="cx"> while (m-(\w+|[(){}=:;,])-g) {
</span><ins>+ # Skip everything until "{" after extends.
+ if ($inExtends) {
+ next if $1 ne '{';
+ $inExtends = 0;
+ }
+
</ins><span class="cx"> # Open parenthesis.
</span><span class="cx"> if ($1 eq '(') {
</span><span class="cx"> $parenthesesDepth++;
</span><ins>+ $possibleMethodName = join('.', @currentIdentifiers);
</ins><span class="cx"> next;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> # Close parenthesis.
</span><span class="cx"> if ($1 eq ')') {
</span><span class="cx"> $parenthesesDepth--;
</span><ins>+ $parenthesisJustSeen = 1;
</ins><span class="cx"> next;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> # Open brace.
</span><span class="cx"> if ($1 eq '{') {
</span><del>- push(@currentScopes, join(".", @currentIdentifiers));
</del><ins>+ my $methodName = "";
+
+ # Method.
+ if ($currentParsingMode[$#currentParsingMode] eq 'class' and $parenthesisJustSeen and ($staticOrContructorSeen or $possibleMethodName)) {
+ $methodName = join('.', $staticOrContructorSeen ? "" : "prototype", $possibleMethodName);
+ $methodName =~ s/\.{2,}/\./g; # Removes consecutive periods.
+ $methodName =~ s/\.$//; # Remove trailing period.
+
+ my $currentMethod = join('.', @currentScopes, $methodName);
+ $currentMethod =~ s/\.{2,}/\./g; # Removes consecutive periods.
+ $currentMethod =~ s/\.$//; # Remove trailing period.
+
+ push(@currentParsingMode, "method");
+ push(@currentFunctionNames, $currentMethod);
+ push(@currentFunctionDepths, $bracesDepth);
+ push(@currentFunctionStartLines, $.);
+ }
+
+ $bracesDepth++;
+ $functionJustSeen = 0;
+
+ push(@currentScopes, join('.', $methodName ? $methodName : @currentIdentifiers));
</ins><span class="cx"> @currentIdentifiers = ();
</span><span class="cx">
</span><del>- $bracesDepth++;
</del><ins>+ $staticOrContructorSeen = 0;
</ins><span class="cx"> next;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> # Close brace.
</span><span class="cx"> if ($1 eq '}') {
</span><span class="cx"> $bracesDepth--;
</span><ins>+ $functionJustSeen = 0;
</ins><span class="cx">
</span><span class="cx"> if (@currentFunctionDepths and $bracesDepth == $currentFunctionDepths[$#currentFunctionDepths]) {
</span><span class="cx"> pop(@currentFunctionDepths);
</span><ins>+ pop(@currentParsingMode);
</ins><span class="cx">
</span><del>- my $currentFunction = pop(@currentFunctionNames);
</del><ins>+ my $currentName = pop(@currentFunctionNames);
</ins><span class="cx"> my $start = pop(@currentFunctionStartLines);
</span><span class="cx">
</span><del>- push(@ranges, [$start, $., $currentFunction]);
</del><ins>+ push(@ranges, [$start, $., $currentName]);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> pop(@currentScopes);
</span><span class="lines">@@ -1372,6 +1440,18 @@
</span><span class="cx"> next;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ # Class.
+ if ($1 eq 'class') {
+ $classJustSeen = 1;
+ next;
+ }
+
+ # Extends.
+ if ($1 eq 'extends') {
+ $inExtends = 1;
+ next;
+ }
+
</ins><span class="cx"> # Function.
</span><span class="cx"> if ($1 eq 'function') {
</span><span class="cx"> $functionJustSeen = 1;
</span><span class="lines">@@ -1380,6 +1460,7 @@
</span><span class="cx"> my $currentFunction = join('.', (@currentScopes, @currentIdentifiers));
</span><span class="cx"> $currentFunction =~ s/\.{2,}/\./g; # Removes consecutive periods.
</span><span class="cx">
</span><ins>+ push(@currentParsingMode, "function");
</ins><span class="cx"> push(@currentFunctionNames, $currentFunction);
</span><span class="cx"> push(@currentFunctionDepths, $bracesDepth);
</span><span class="cx"> push(@currentFunctionStartLines, $.);
</span><span class="lines">@@ -1400,6 +1481,12 @@
</span><span class="cx"> next;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ # Static.
+ if ($1 eq 'static' or $1 eq 'constructor') {
+ $staticOrContructorSeen = 1;
+ next;
+ }
+
</ins><span class="cx"> # Assignment operator.
</span><span class="cx"> if ($1 eq '=' or $1 eq ':') {
</span><span class="cx"> $assignmentJustSeen = 1;
</span><span class="lines">@@ -1410,15 +1497,38 @@
</span><span class="cx">
</span><span class="cx"> # Word.
</span><span class="cx"> $word = $1;
</span><del>- $word = "get $word" if $getterJustSeen;
- $word = "set $word" if $setterJustSeen;
</del><span class="cx">
</span><del>- if (($functionJustSeen and !$assignmentJustSeen) or $getterJustSeen or $setterJustSeen) {
</del><ins>+ if ($classJustSeen) {
+ push(@currentIdentifiers, $word) if !$assignmentJustSeen;
+
+ my $currentClass = join('.', (@currentScopes, @currentIdentifiers));
+ $currentClass =~ s/\.{2,}/\./g; # Removes consecutive periods.
+
+ push(@currentParsingMode, "class");
+ push(@currentFunctionNames, $currentClass);
+ push(@currentFunctionDepths, $bracesDepth);
+ push(@currentFunctionStartLines, $.);
+ } elsif ($getterJustSeen or $setterJustSeen) {
+ $word = "get $word" if $getterJustSeen;
+ $word = "set $word" if $setterJustSeen;
+
</ins><span class="cx"> push(@currentIdentifiers, $word);
</span><span class="cx">
</span><ins>+ my $mode = $currentParsingMode[$#currentParsingMode];
+ my $currentFunction = join('.', (@currentScopes, ($mode eq 'class') ? "prototype" : "", @currentIdentifiers));
+ $currentFunction =~ s/\.{2,}/\./g; # Removes consecutive periods.
+
+ push(@currentParsingMode, "function");
+ push(@currentFunctionNames, $currentFunction);
+ push(@currentFunctionDepths, $bracesDepth);
+ push(@currentFunctionStartLines, $.);
+ } elsif ($functionJustSeen and !$assignmentJustSeen) {
+ push(@currentIdentifiers, $word);
+
</ins><span class="cx"> my $currentFunction = join('.', (@currentScopes, @currentIdentifiers));
</span><span class="cx"> $currentFunction =~ s/\.{2,}/\./g; # Removes consecutive periods.
</span><span class="cx">
</span><ins>+ push(@currentParsingMode, "function");
</ins><span class="cx"> push(@currentFunctionNames, $currentFunction);
</span><span class="cx"> push(@currentFunctionDepths, $bracesDepth);
</span><span class="cx"> push(@currentFunctionStartLines, $.);
</span><span class="lines">@@ -1426,6 +1536,8 @@
</span><span class="cx"> push(@currentIdentifiers, $word);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ $classJustSeen = 0;
+ $parenthesisJustSeen = 0;
</ins><span class="cx"> $functionJustSeen = 0;
</span><span class="cx"> $getterJustSeen = 0;
</span><span class="cx"> $setterJustSeen = 0;
</span></span></pre></div>
<a id="trunkToolsScriptswebkitperlprepareChangeLog_unittestresourcesjavascript_unittestsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests-expected.txt (181995 => 181996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests-expected.txt        2015-03-26 04:35:31 UTC (rev 181995)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests-expected.txt        2015-03-26 04:37:35 UTC (rev 181996)
</span><span class="lines">@@ -131,6 +131,76 @@
</span><span class="cx"> '128',
</span><span class="cx"> '150',
</span><span class="cx"> 'func16'
</span><ins>+ ],
+ [
+ 152,
+ 152,
+ 'BaseClass'
+ ],
+ [
+ 152,
+ 152,
+ 'BaseClass'
+ ],
+ [
+ 156,
+ 158,
+ 'DerivedClass'
+ ],
+ [
+ 161,
+ 162,
+ 'DerivedClass.staticMethod'
+ ],
+ [
+ 166,
+ 168,
+ 'DerivedClass.prototype.method.nestedFunctionInsideMethod'
+ ],
+ [
+ 165,
+ 169,
+ 'DerivedClass.prototype.method'
+ ],
+ [
+ 171,
+ 171,
+ 'DerivedClass.prototype.get getter'
+ ],
+ [
+ 154,
+ 172,
+ 'DerivedClass'
+ ],
+ [
+ 177,
+ 178,
+ 'namespace.MyClass'
+ ],
+ [
+ 181,
+ 182,
+ 'namespace.MyClass.staticMethod'
+ ],
+ [
+ 186,
+ 188,
+ 'namespace.MyClass.prototype.method.nestedFunctionInsideMethod'
+ ],
+ [
+ 185,
+ 189,
+ 'namespace.MyClass.prototype.method'
+ ],
+ [
+ 191,
+ 191,
+ 'namespace.MyClass.prototype.get getter'
+ ],
+ [
+ 175,
+ 192,
+ 'namespace.MyClass'
</ins><span class="cx"> ]
</span><span class="cx"> ]
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsScriptswebkitperlprepareChangeLog_unittestresourcesjavascript_unittestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests.js (181995 => 181996)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests.js        2015-03-26 04:35:31 UTC (rev 181995)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/javascript_unittests.js        2015-03-26 04:37:35 UTC (rev 181996)
</span><span class="lines">@@ -148,3 +148,45 @@
</span><span class="cx"> return 123;
</span><span class="cx"> });
</span><span class="cx"> }
</span><ins>+
+class BaseClass { constructor() {} };
+
+class DerivedClass extends BaseClass {
+ constructor()
+ {
+ super();
+ }
+
+ static staticMethod()
+ {
+ }
+
+ method(a, b)
+ {
+ function nestedFunctionInsideMethod() {
+ // ..
+ }
+ }
+
+ get getter() { }
+}
+
+var namespace = {};
+namespace.MyClass = class IgnoredName {
+ constructor()
+ {
+ }
+
+ static staticMethod()
+ {
+ }
+
+ method(a, b)
+ {
+ function nestedFunctionInsideMethod() {
+ // ..
+ }
+ }
+
+ get getter() { }
+}
</ins></span></pre>
</div>
</div>
</body>
</html>