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

Side by Side Diff: dart/frog/leg/lib/js_helper.dart

Issue 9558005: Implement literal maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « no previous file | dart/frog/leg/ssa/builder.dart » ('j') | dart/frog/leg/ssa/builder.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #library('js_helper'); 5 #library('js_helper');
6 6
7 #import('coreimpl.dart'); 7 #import('coreimpl.dart');
8 8
9 #source('date_helper.dart'); 9 #source('date_helper.dart');
10 #source('regexp_helper.dart'); 10 #source('regexp_helper.dart');
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 checkGrowable(list, reason) { 308 checkGrowable(list, reason) {
309 if (JS('bool', @'!!($0.fixed$length)', list)) { 309 if (JS('bool', @'!!($0.fixed$length)', list)) {
310 throw new UnsupportedOperationException(reason); 310 throw new UnsupportedOperationException(reason);
311 } 311 }
312 } 312 }
313 313
314 builtin$toString$0(var value) { 314 builtin$toString$0(var value) {
315 if (JS('bool', @'typeof $0 == "object"', value)) { 315 if (JS('bool', @'typeof $0 == "object"', value)) {
316 if (isJsArray(value)) { 316 if (isJsArray(value)) {
317 return "Instance of 'List'"; 317 return Collections.collectionToString(value);
318 } else {
319 return UNINTERCEPTED(value.toString());
318 } 320 }
319 return UNINTERCEPTED(value.toString());
320 } 321 }
321 if (JS('bool', @'$0 === 0 && (1 / $0) < 0', value)) { 322 if (JS('bool', @'$0 === 0 && (1 / $0) < 0', value)) {
322 return '-0.0'; 323 return '-0.0';
323 } 324 }
324 if (value === null) return 'null'; 325 if (value === null) return 'null';
325 if (JS('bool', @'typeof $0 == "function"', value)) { 326 if (JS('bool', @'typeof $0 == "function"', value)) {
326 return 'Closure'; 327 return 'Closure';
327 } 328 }
328 return JS('string', @'String($0)', value); 329 return JS('string', @'String($0)', value);
329 } 330 }
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 } 1290 }
1290 } 1291 }
1291 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { 1292 } else if (JS('bool', @'$0 instanceof RangeError', ex)) {
1292 var message = JS('String', @'$0.message', ex); 1293 var message = JS('String', @'$0.message', ex);
1293 if (message.contains('call stack')) { 1294 if (message.contains('call stack')) {
1294 return new StackOverflowException(); 1295 return new StackOverflowException();
1295 } 1296 }
1296 } 1297 }
1297 return ex; 1298 return ex;
1298 } 1299 }
1300
1301 /**
1302 * Called by generated code to build a map literal. [keyValuePairs] is
1303 * a list of key, value, key, value, ..., etc.
1304 */
1305 makeLiteralMap(List keyValuePairs) {
1306 var iterator = keyValuePairs.iterator();
ngeoffray 2012/03/01 08:36:09 var -> Iterator ?
ahe 2012/03/06 15:34:12 Done.
1307 Map result = new LinkedHashMap();
1308 while (iterator.hasNext()) {
1309 var key = iterator.next();
ngeoffray 2012/03/01 08:36:09 var key -> String key?
ahe 2012/03/06 15:34:12 Done.
1310 var value = iterator.next();
1311 // TODO(ahe): Don't use UNINTERCEPTED when optimizer is smarter.
floitsch 2012/03/01 10:24:07 Is this necessary or just a premature optimization
ahe 2012/03/06 15:34:12 Premature optimization to make the code readable.
1312 UNINTERCEPTED(result[key] = value);
1313 }
1314 return result;
1315 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/ssa/builder.dart » ('j') | dart/frog/leg/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698