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

Side by Side Diff: frog/corejs.dart

Issue 8511081: Better fix for client tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: update status Created 9 years, 1 month 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 | « client/tests/client/client.status ('k') | frog/frogsh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Generates JS helpers for dart:core. This used to be in a file "core.js". 6 * Generates JS helpers for dart:core. This used to be in a file "core.js".
7 * Having them in Dart code means we can easily control which are generated. 7 * Having them in Dart code means we can easily control which are generated.
8 */ 8 */
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native"
10 // methods somewhere in a library that we import. This would be rather elegant 10 // methods somewhere in a library that we import. This would be rather elegant
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 _usedOperators[name] = code; 137 _usedOperators[name] = code;
138 } 138 }
139 139
140 void generate(CodeWriter w) { 140 void generate(CodeWriter w) {
141 if (useVarMethod) { 141 if (useVarMethod) {
142 useTypeNameOf = true; 142 useTypeNameOf = true;
143 w.writeln(@""" 143 w.writeln(@"""
144 function $varMethod(name, methods) { 144 function $varMethod(name, methods) {
145 Object.prototype[name] = function() { 145 Object.prototype[name] = function() {
146 $patchMethod(this, name, methods); 146 $patchMethod(this, name, methods);
147 this[name].apply(this, Array.prototype.slice.call(arguments)); 147 return this[name].apply(this, Array.prototype.slice.call(arguments));
148 }; 148 };
149 } 149 }
150 function $patchMethod(obj, name, methods) { 150 function $patchMethod(obj, name, methods) {
151 // Get the prototype to patch. 151 // Get the prototype to patch.
152 // Don't overwrite an existing stub, like the one on Object.prototype 152 // Don't overwrite an existing stub, like the one on Object.prototype
153 var proto = Object.getPrototypeOf(obj); 153 var proto = Object.getPrototypeOf(obj);
154 if (!proto || proto.hasOwnProperty(name)) proto = obj; 154 if (!proto || proto.hasOwnProperty(name)) proto = obj;
155 var method; 155 var method;
156 while (obj && !(method = methods[obj.$typeNameOf()])) { 156 while (obj && !(method = methods[obj.$typeNameOf()])) {
157 obj = Object.getPrototypeOf(obj); 157 obj = Object.getPrototypeOf(obj);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 Object.prototype.$setindex = function(i, value) { return this[i] = value; } 384 Object.prototype.$setindex = function(i, value) { return this[i] = value; }
385 Array.prototype.$setindex = function(i, value) { return this[i] = value; }"""); 385 Array.prototype.$setindex = function(i, value) { return this[i] = value; }""");
386 } 386 }
387 387
388 // Write operator helpers 388 // Write operator helpers
389 for (var opImpl in orderValuesByKeys(_usedOperators)) { 389 for (var opImpl in orderValuesByKeys(_usedOperators)) {
390 w.writeln(opImpl); 390 w.writeln(opImpl);
391 } 391 }
392 } 392 }
393 } 393 }
OLDNEW
« no previous file with comments | « client/tests/client/client.status ('k') | frog/frogsh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698