Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: frog/minfrog

Issue 9653021: Add support for implicitly concatenating adjacent string literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added test case. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/gen.dart ('k') | frog/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env node 1 #!/usr/bin/env node
2 // ********** Library dart:core ************** 2 // ********** Library dart:core **************
3 // ********** Natives dart:core ************** 3 // ********** Natives dart:core **************
4 function $defProp(obj, prop, value) { 4 function $defProp(obj, prop, value) {
5 Object.defineProperty(obj, prop, 5 Object.defineProperty(obj, prop,
6 {value: value, enumerable: false, writable: true, configurable: true}); 6 {value: value, enumerable: false, writable: true, configurable: true});
7 } 7 }
8 Function.prototype.bind = Function.prototype.bind || 8 Function.prototype.bind = Function.prototype.bind ||
9 function(thisObj) { 9 function(thisObj) {
10 var func = this; 10 var func = this;
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 } 2644 }
2645 MethodAnalyzer.prototype.visitThisExpression = function(node) { 2645 MethodAnalyzer.prototype.visitThisExpression = function(node) {
2646 return this._frame.makeThisValue(node); 2646 return this._frame.makeThisValue(node);
2647 } 2647 }
2648 MethodAnalyzer.prototype.visitSuperExpression = function(node) { 2648 MethodAnalyzer.prototype.visitSuperExpression = function(node) {
2649 return this._frame.makeSuperValue(node); 2649 return this._frame.makeSuperValue(node);
2650 } 2650 }
2651 MethodAnalyzer.prototype.visitLiteralExpression = function(node) { 2651 MethodAnalyzer.prototype.visitLiteralExpression = function(node) {
2652 return new PureStaticValue(node.value.get$type(), node.span, true, false); 2652 return new PureStaticValue(node.value.get$type(), node.span, true, false);
2653 } 2653 }
2654 MethodAnalyzer.prototype.visitStringConcatExpression = function(node) {
2655 node.strings.forEach(this.get$visitValue());
2656 return this._frame._makeValue($globals.world.stringType, node);
2657 }
2654 MethodAnalyzer.prototype.visitStringInterpExpression = function(node) { 2658 MethodAnalyzer.prototype.visitStringInterpExpression = function(node) {
2655 node.pieces.forEach(this.get$visitValue()); 2659 node.pieces.forEach(this.get$visitValue());
2656 return this._frame._makeValue($globals.world.stringType, node); 2660 return this._frame._makeValue($globals.world.stringType, node);
2657 } 2661 }
2658 MethodAnalyzer.prototype._pushBlock$1 = MethodAnalyzer.prototype._pushBlock; 2662 MethodAnalyzer.prototype._pushBlock$1 = MethodAnalyzer.prototype._pushBlock;
2659 MethodAnalyzer.prototype.analyze$1 = MethodAnalyzer.prototype.analyze; 2663 MethodAnalyzer.prototype.analyze$1 = MethodAnalyzer.prototype.analyze;
2660 MethodAnalyzer.prototype.visitBinaryExpression$1 = function($0) { 2664 MethodAnalyzer.prototype.visitBinaryExpression$1 = function($0) {
2661 return this.visitBinaryExpression($0, false); 2665 return this.visitBinaryExpression($0, false);
2662 }; 2666 };
2663 MethodAnalyzer.prototype.visitCallExpression$1 = function($0) { 2667 MethodAnalyzer.prototype.visitCallExpression$1 = function($0) {
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
5129 } 5133 }
5130 MethodGenerator.prototype._isUnaryIncrement = function(item) { 5134 MethodGenerator.prototype._isUnaryIncrement = function(item) {
5131 if ((item instanceof UnaryExpression)) { 5135 if ((item instanceof UnaryExpression)) {
5132 var u = item; 5136 var u = item;
5133 return u.op.kind == (16) || u.op.kind == (17); 5137 return u.op.kind == (16) || u.op.kind == (17);
5134 } 5138 }
5135 else { 5139 else {
5136 return false; 5140 return false;
5137 } 5141 }
5138 } 5142 }
5143 MethodGenerator.prototype.visitStringConcatExpression = function(node) {
5144 var items = [];
5145 var $$list = node.strings;
5146 for (var $$i = $$list.iterator(); $$i.hasNext(); ) {
5147 var item = $$i.next();
5148 var val = this.visitValue(item);
5149 items.add(val.get$code());
5150 }
5151 return new Value($globals.world.stringType, ("(" + Strings.join(items, " + ") + ")"), node.span);
5152 }
5139 MethodGenerator.prototype.visitStringInterpExpression = function(node) { 5153 MethodGenerator.prototype.visitStringInterpExpression = function(node) {
5140 var items = []; 5154 var items = [];
5141 var $$list = node.pieces; 5155 var $$list = node.pieces;
5142 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { 5156 for (var $$i = $$list.iterator(); $$i.hasNext(); ) {
5143 var item = $$i.next(); 5157 var item = $$i.next();
5144 var val = this.visitValue(item); 5158 var val = this.visitValue(item);
5145 val.invoke(this, "toString", item, Arguments.get$EMPTY()); 5159 val.invoke(this, "toString", item, Arguments.get$EMPTY());
5146 var code = val.get$code(); 5160 var code = val.get$code();
5147 if (this._expressionNeedsParens(item)) { 5161 if (this._expressionNeedsParens(item)) {
5148 code = ("(" + code + ")"); 5162 code = ("(" + code + ")");
(...skipping 5016 matching lines...) Expand 10 before | Expand all | Expand 10 after
10165 10179
10166 var t = this._lang_next(); 10180 var t = this._lang_next();
10167 return this._makeLiteral(Value.fromInt(Math.parseInt(t.get$text()), t.get$ span())); 10181 return this._makeLiteral(Value.fromInt(Math.parseInt(t.get$text()), t.get$ span()));
10168 10182
10169 case (62): 10183 case (62):
10170 10184
10171 var t = this._lang_next(); 10185 var t = this._lang_next();
10172 return this._makeLiteral(Value.fromDouble(Math.parseDouble(t.get$text()), t.get$span())); 10186 return this._makeLiteral(Value.fromDouble(Math.parseDouble(t.get$text()), t.get$span()));
10173 10187
10174 case (58): 10188 case (58):
10175
10176 var t = this._lang_next();
10177 return this._makeLiteral(Value.fromString(t.get$value(), t.get$span()));
10178
10179 case (59): 10189 case (59):
10180 10190
10181 return this.stringInterpolation(); 10191 return this.adjacentStrings();
10182 10192
10183 case (52): 10193 case (52):
10184 10194
10185 return this.finishTypedLiteral(start, false); 10195 return this.finishTypedLiteral(start, false);
10186 10196
10187 case (115): 10197 case (115):
10188 case (114): 10198 case (114):
10189 case (99): 10199 case (99):
10190 10200
10191 return this.declaredIdentifier(false); 10201 return this.declaredIdentifier(false);
10192 10202
10193 default: 10203 default:
10194 10204
10195 if (!this._peekIdentifier()) { 10205 if (!this._peekIdentifier()) {
10196 this._errorExpected("expression"); 10206 this._errorExpected("expression");
10197 } 10207 }
10198 return new VarExpression(this.identifier(), this._makeSpan(start)); 10208 return new VarExpression(this.identifier(), this._makeSpan(start));
10199 10209
10200 } 10210 }
10201 } 10211 }
10212 Parser.prototype.adjacentStrings = function() {
10213 var start = this._peekToken.start;
10214 var strings = [];
10215 while (this._peek() == (58) || this._peek() == (59)) {
10216 var part = null;
10217 if (this._peek() == (58)) {
10218 var t = this._lang_next();
10219 part = this._makeLiteral(Value.fromString(t.get$value(), t.get$span()));
10220 }
10221 else {
10222 part = this.stringInterpolation();
10223 }
10224 strings.add(part);
10225 }
10226 if (strings.get$length() == (1)) {
10227 return strings.$index((0));
10228 }
10229 else {
10230 return new StringConcatExpression(strings, this._makeSpan(start));
10231 }
10232 }
10202 Parser.prototype.stringInterpolation = function() { 10233 Parser.prototype.stringInterpolation = function() {
10203 var start = this._peekToken.start; 10234 var start = this._peekToken.start;
10204 var pieces = new Array(); 10235 var pieces = new Array();
10205 var startQuote = null, endQuote = null; 10236 var startQuote = null, endQuote = null;
10206 while (this._peekKind((59))) { 10237 while (this._peekKind((59))) {
10207 var token = this._lang_next(); 10238 var token = this._lang_next();
10208 pieces.add(this._makeLiteral(Value.fromString(token.get$value(), token.get$s pan()))); 10239 pieces.add(this._makeLiteral(Value.fromString(token.get$value(), token.get$s pan())));
10209 if (this._maybeEat((6))) { 10240 if (this._maybeEat((6))) {
10210 pieces.add(this.expression()); 10241 pieces.add(this.expression());
10211 this._eat((7)); 10242 this._eat((7));
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
11238 $inherits(LiteralExpression, Expression); 11269 $inherits(LiteralExpression, Expression);
11239 function LiteralExpression(value, span) { 11270 function LiteralExpression(value, span) {
11240 this.value = value; 11271 this.value = value;
11241 Expression.call(this, span); 11272 Expression.call(this, span);
11242 } 11273 }
11243 LiteralExpression.prototype.get$value = function() { return this.value; }; 11274 LiteralExpression.prototype.get$value = function() { return this.value; };
11244 LiteralExpression.prototype.set$value = function(value) { return this.value = va lue; }; 11275 LiteralExpression.prototype.set$value = function(value) { return this.value = va lue; };
11245 LiteralExpression.prototype.visit = function(visitor) { 11276 LiteralExpression.prototype.visit = function(visitor) {
11246 return visitor.visitLiteralExpression(this); 11277 return visitor.visitLiteralExpression(this);
11247 } 11278 }
11279 // ********** Code for StringConcatExpression **************
11280 $inherits(StringConcatExpression, Expression);
11281 function StringConcatExpression(strings, span) {
11282 this.strings = strings;
11283 Expression.call(this, span);
11284 }
11285 StringConcatExpression.prototype.visit = function(visitor) {
11286 return visitor.visitStringConcatExpression(this);
11287 }
11248 // ********** Code for StringInterpExpression ************** 11288 // ********** Code for StringInterpExpression **************
11249 $inherits(StringInterpExpression, Expression); 11289 $inherits(StringInterpExpression, Expression);
11250 function StringInterpExpression(pieces, span) { 11290 function StringInterpExpression(pieces, span) {
11251 this.pieces = pieces; 11291 this.pieces = pieces;
11252 Expression.call(this, span); 11292 Expression.call(this, span);
11253 } 11293 }
11254 StringInterpExpression.prototype.visit = function(visitor) { 11294 StringInterpExpression.prototype.visit = function(visitor) {
11255 return visitor.visitStringInterpExpression(this); 11295 return visitor.visitStringInterpExpression(this);
11256 } 11296 }
11257 // ********** Code for SimpleTypeReference ************** 11297 // ********** Code for SimpleTypeReference **************
(...skipping 3647 matching lines...) Expand 10 before | Expand all | Expand 10 after
14905 var const$0002 = Object.create(EmptyQueueException.prototype, {}); 14945 var const$0002 = Object.create(EmptyQueueException.prototype, {});
14906 var const$0006 = Object.create(IllegalAccessException.prototype, {}); 14946 var const$0006 = Object.create(IllegalAccessException.prototype, {});
14907 var const$0007 = ImmutableList.ImmutableList$from$factory([]); 14947 var const$0007 = ImmutableList.ImmutableList$from$factory([]);
14908 var const$0009 = new JSSyntaxRegExp("^[a-zA-Z]:/"); 14948 var const$0009 = new JSSyntaxRegExp("^[a-zA-Z]:/");
14909 var const$0010 = ImmutableList.ImmutableList$from$factory(["__PROTO__", "prototy pe", "constructor"]); 14949 var const$0010 = ImmutableList.ImmutableList$from$factory(["__PROTO__", "prototy pe", "constructor"]);
14910 var const$0011 = ImmutableList.ImmutableList$from$factory(["NaN", "Infinity", "u ndefined", "eval", "parseInt", "parseFloat", "isNan", "isFinite", "decodeURI", " decodeURIComponent", "encodeURI", "encodeURIComponent", "Object", "Function", "A rray", "String", "Boolean", "Number", "Date", "RegExp", "Error", "EvalError", "R angeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "Math", "a rguments", "escape", "unescape", "applicationCache", "closed", "Components", "co ntent", "controllers", "crypto", "defaultStatus", "dialogArguments", "directorie s", "document", "frameElement", "frames", "fullScreen", "globalStorage", "histor y", "innerHeight", "innerWidth", "length", "location", "locationbar", "localStor age", "menubar", "mozInnerScreenX", "mozInnerScreenY", "mozScreenPixelsPerCssPix el", "name", "navigator", "opener", "outerHeight", "outerWidth", "pageXOffset", "pageYOffset", "parent", "personalbar", "pkcs11", "returnValue", "screen", "scro llbars", "scrollMaxX", "scrollMaxY", "self", "sessionStorage", "sidebar", "statu s", "statusbar", "toolbar", "top", "window", "alert", "addEventListener", "atob" , "back", "blur", "btoa", "captureEvents", "clearInterval", "clearTimeout", "clo se", "confirm", "disableExternalCapture", "dispatchEvent", "dump", "enableExtern alCapture", "escape", "find", "focus", "forward", "GeckoActiveXObject", "getAtte ntion", "getAttentionWithCycleCount", "getComputedStyle", "getSelection", "home" , "maximize", "minimize", "moveBy", "moveTo", "open", "openDialog", "postMessage ", "print", "prompt", "QueryInterface", "releaseEvents", "removeEventListener", "resizeBy", "resizeTo", "restore", "routeEvent", "scroll", "scrollBy", "scrollBy Lines", "scrollByPages", "scrollTo", "setInterval", "setResizeable", "setTimeout ", "showModalDialog", "sizeToContent", "stop", "uuescape", "updateCommands", "XP CNativeWrapper", "XPCSafeJSOjbectWrapper", "onabort", "onbeforeunload", "onchang e", "onclick", "onclose", "oncontextmenu", "ondragdrop", "onerror", "onfocus", " onhashchange", "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", "o nmousemove", "onmouseout", "onmouseover", "onmouseup", "onmozorientation", "onpa int", "onreset", "onresize", "onscroll", "onselect", "onsubmit", "onunload", "on touchcancel", "ontouchend", "ontouchmove", "ontouchstart", "ongesturestart", "on gesturechange", "ongestureend", "uneval", "getPrototypeOf", "let", "yield", "abs tract", "int", "short", "boolean", "interface", "static", "byte", "long", "char" , "final", "native", "synchronized", "float", "package", "throws", "goto", "priv ate", "transient", "implements", "protected", "volatile", "double", "public", "a ttachEvent", "clientInformation", "clipboardData", "createPopup", "dialogHeight" , "dialogLeft", "dialogTop", "dialogWidth", "onafterprint", "onbeforedeactivate" , "onbeforeprint", "oncontrolselect", "ondeactivate", "onhelp", "onresizeend", " event", "external", "Debug", "Enumerator", "Global", "Image", "ActiveXObject", " VBArray", "Components", "toString", "getClass", "constructor", "prototype", "val ueOf", "Anchor", "Applet", "Attr", "Canvas", "CanvasGradient", "CanvasPattern", "CanvasRenderingContext2D", "CDATASection", "CharacterData", "Comment", "CSS2Pro perties", "CSSRule", "CSSStyleSheet", "Document", "DocumentFragment", "DocumentT ype", "DOMException", "DOMImplementation", "DOMParser", "Element", "Event", "Ext ernalInterface", "FlashPlayer", "Form", "Frame", "History", "HTMLCollection", "H TMLDocument", "HTMLElement", "IFrame", "Image", "Input", "JSObject", "KeyEvent", "Link", "Location", "MimeType", "MouseEvent", "Navigator", "Node", "NodeList", "Option", "Plugin", "ProcessingInstruction", "Range", "RangeException", "Screen" , "Select", "Table", "TableCell", "TableRow", "TableSelection", "Text", "TextAre a", "UIEvent", "Window", "XMLHttpRequest", "XMLSerializer", "XPathException", "X PathResult", "XSLTProcessor", "java", "Packages", "netscape", "sun", "JavaObject ", "JavaClass", "JavaArray", "JavaMember", "$wnd", "$doc", "$entry", "$moduleNam e", "$moduleBase", "$gwt_version", "$sessionId", "$stack", "$stackDepth", "$loca tion", "call"]); 14950 var const$0011 = ImmutableList.ImmutableList$from$factory(["NaN", "Infinity", "u ndefined", "eval", "parseInt", "parseFloat", "isNan", "isFinite", "decodeURI", " decodeURIComponent", "encodeURI", "encodeURIComponent", "Object", "Function", "A rray", "String", "Boolean", "Number", "Date", "RegExp", "Error", "EvalError", "R angeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "Math", "a rguments", "escape", "unescape", "applicationCache", "closed", "Components", "co ntent", "controllers", "crypto", "defaultStatus", "dialogArguments", "directorie s", "document", "frameElement", "frames", "fullScreen", "globalStorage", "histor y", "innerHeight", "innerWidth", "length", "location", "locationbar", "localStor age", "menubar", "mozInnerScreenX", "mozInnerScreenY", "mozScreenPixelsPerCssPix el", "name", "navigator", "opener", "outerHeight", "outerWidth", "pageXOffset", "pageYOffset", "parent", "personalbar", "pkcs11", "returnValue", "screen", "scro llbars", "scrollMaxX", "scrollMaxY", "self", "sessionStorage", "sidebar", "statu s", "statusbar", "toolbar", "top", "window", "alert", "addEventListener", "atob" , "back", "blur", "btoa", "captureEvents", "clearInterval", "clearTimeout", "clo se", "confirm", "disableExternalCapture", "dispatchEvent", "dump", "enableExtern alCapture", "escape", "find", "focus", "forward", "GeckoActiveXObject", "getAtte ntion", "getAttentionWithCycleCount", "getComputedStyle", "getSelection", "home" , "maximize", "minimize", "moveBy", "moveTo", "open", "openDialog", "postMessage ", "print", "prompt", "QueryInterface", "releaseEvents", "removeEventListener", "resizeBy", "resizeTo", "restore", "routeEvent", "scroll", "scrollBy", "scrollBy Lines", "scrollByPages", "scrollTo", "setInterval", "setResizeable", "setTimeout ", "showModalDialog", "sizeToContent", "stop", "uuescape", "updateCommands", "XP CNativeWrapper", "XPCSafeJSOjbectWrapper", "onabort", "onbeforeunload", "onchang e", "onclick", "onclose", "oncontextmenu", "ondragdrop", "onerror", "onfocus", " onhashchange", "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", "o nmousemove", "onmouseout", "onmouseover", "onmouseup", "onmozorientation", "onpa int", "onreset", "onresize", "onscroll", "onselect", "onsubmit", "onunload", "on touchcancel", "ontouchend", "ontouchmove", "ontouchstart", "ongesturestart", "on gesturechange", "ongestureend", "uneval", "getPrototypeOf", "let", "yield", "abs tract", "int", "short", "boolean", "interface", "static", "byte", "long", "char" , "final", "native", "synchronized", "float", "package", "throws", "goto", "priv ate", "transient", "implements", "protected", "volatile", "double", "public", "a ttachEvent", "clientInformation", "clipboardData", "createPopup", "dialogHeight" , "dialogLeft", "dialogTop", "dialogWidth", "onafterprint", "onbeforedeactivate" , "onbeforeprint", "oncontrolselect", "ondeactivate", "onhelp", "onresizeend", " event", "external", "Debug", "Enumerator", "Global", "Image", "ActiveXObject", " VBArray", "Components", "toString", "getClass", "constructor", "prototype", "val ueOf", "Anchor", "Applet", "Attr", "Canvas", "CanvasGradient", "CanvasPattern", "CanvasRenderingContext2D", "CDATASection", "CharacterData", "Comment", "CSS2Pro perties", "CSSRule", "CSSStyleSheet", "Document", "DocumentFragment", "DocumentT ype", "DOMException", "DOMImplementation", "DOMParser", "Element", "Event", "Ext ernalInterface", "FlashPlayer", "Form", "Frame", "History", "HTMLCollection", "H TMLDocument", "HTMLElement", "IFrame", "Image", "Input", "JSObject", "KeyEvent", "Link", "Location", "MimeType", "MouseEvent", "Navigator", "Node", "NodeList", "Option", "Plugin", "ProcessingInstruction", "Range", "RangeException", "Screen" , "Select", "Table", "TableCell", "TableRow", "TableSelection", "Text", "TextAre a", "UIEvent", "Window", "XMLHttpRequest", "XMLSerializer", "XPathException", "X PathResult", "XSLTProcessor", "java", "Packages", "netscape", "sun", "JavaObject ", "JavaClass", "JavaArray", "JavaMember", "$wnd", "$doc", "$entry", "$moduleNam e", "$moduleBase", "$gwt_version", "$sessionId", "$stack", "$stackDepth", "$loca tion", "call"]);
14911 var const$0012 = ImmutableList.ImmutableList$from$factory(["break", "delete", "f unction", "return", "typeof", "case", "do", "if", "switch", "var", "catch", "els e", "in", "this", "void", "continue", "false", "instanceof", "throw", "while", " debugger", "finally", "new", "true", "with", "default", "for", "null", "try", "a bstract", "double", "goto", "native", "static", "boolean", "enum", "implements", "package", "super", "byte", "export", "import", "private", "synchronized", "cha r", "extends", "int", "protected", "throws", "class", "final", "interface", "pub lic", "transient", "const", "float", "long", "short", "volatile"]); 14951 var const$0012 = ImmutableList.ImmutableList$from$factory(["break", "delete", "f unction", "return", "typeof", "case", "do", "if", "switch", "var", "catch", "els e", "in", "this", "void", "continue", "false", "instanceof", "throw", "while", " debugger", "finally", "new", "true", "with", "default", "for", "null", "try", "a bstract", "double", "goto", "native", "static", "boolean", "enum", "implements", "package", "super", "byte", "export", "import", "private", "synchronized", "cha r", "extends", "int", "protected", "throws", "class", "final", "interface", "pub lic", "transient", "const", "float", "long", "short", "volatile"]);
14912 var $globals = {}; 14952 var $globals = {};
14913 $static_init(); 14953 $static_init();
14914 main(); 14954 main();
OLDNEW
« no previous file with comments | « frog/gen.dart ('k') | frog/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698