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

Side by Side Diff: tool/input_sdk/lib/js/dart2js/js_dart2js.dart

Issue 1609843002: partial fix for #414, avoid dcall in _convertToDart (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « test/codegen/expect/collection/wrappers.txt ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 * Support for interoperating with JavaScript. 6 * Support for interoperating with JavaScript.
7 * 7 *
8 * This library provides access to JavaScript objects from Dart, allowing 8 * This library provides access to JavaScript objects from Dart, allowing
9 * Dart code to get and set properties, and call methods of JavaScript objects 9 * Dart code to get and set properties, and call methods of JavaScript objects
10 * and invoke JavaScript functions. The library takes care of converting 10 * and invoke JavaScript functions. The library takes care of converting
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 var wrapper = JS('', 'function(/*...arguments*/) {' 468 var wrapper = JS('', 'function(/*...arguments*/) {'
469 ' let args = Array.prototype.map.call(arguments, #);' 469 ' let args = Array.prototype.map.call(arguments, #);'
470 ' return #(#(...args));' 470 ' return #(#(...args));'
471 '}', _convertToDart, _convertToJS, f); 471 '}', _convertToDart, _convertToJS, f);
472 _dartProxies[wrapper] = f; 472 _dartProxies[wrapper] = f;
473 return wrapper; 473 return wrapper;
474 } 474 }
475 475
476 // converts a Dart object to a reference to a native JS object 476 // converts a Dart object to a reference to a native JS object
477 // which might be a DartObject JS->Dart proxy 477 // which might be a DartObject JS->Dart proxy
478 Object _convertToDart(o, [bool isBrowserType(x)]) { 478 Object _convertToDart(o) {
479 if (isBrowserType == null) isBrowserType = _isBrowserType;
480 if (JS('bool', '# == null', o) || 479 if (JS('bool', '# == null', o) ||
481 JS('bool', 'typeof # == "string"', o) || 480 JS('bool', 'typeof # == "string"', o) ||
482 JS('bool', 'typeof # == "number"', o) || 481 JS('bool', 'typeof # == "number"', o) ||
483 JS('bool', 'typeof # == "boolean"', o) || 482 JS('bool', 'typeof # == "boolean"', o) ||
484 isBrowserType(o)) { 483 _isBrowserType(o)) {
485 return o; 484 return o;
486 } else if (JS('bool', '# instanceof Date', o)) { 485 } else if (JS('bool', '# instanceof Date', o)) {
487 var ms = JS('num', '#.getTime()', o); 486 var ms = JS('num', '#.getTime()', o);
488 return new DateTime.fromMillisecondsSinceEpoch(ms); 487 return new DateTime.fromMillisecondsSinceEpoch(ms);
489 } else if (o is _DartObject && 488 } else if (o is _DartObject &&
490 JS('bool', 'dart.jsobject != dart.realRuntimeType(#)', o)) { 489 JS('bool', 'dart.jsobject != dart.realRuntimeType(#)', o)) {
491 return o._dartObj; 490 return o._dartObj;
492 } else { 491 } else {
493 return _putIfAbsent(_dartProxies, o, _wrapToDart); 492 return _putIfAbsent(_dartProxies, o, _wrapToDart);
494 } 493 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 ' for (let arg of arguments) {' 549 ' for (let arg of arguments) {'
551 ' args.push(arg);' 550 ' args.push(arg);'
552 ' }' 551 ' }'
553 ' return #(...args);' 552 ' return #(...args);'
554 '}', 553 '}',
555 f); 554 f);
556 _interopCaptureThisExpando[f] = ret; 555 _interopCaptureThisExpando[f] = ret;
557 } 556 }
558 return ret; 557 return ret;
559 } 558 }
OLDNEW
« no previous file with comments | « test/codegen/expect/collection/wrappers.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698