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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1293293002: Attach type info to extension method and object method tear-offs (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 4 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 | « lib/runtime/_classes.js ('k') | test/browser/runtime_tests.js » ('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) 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 library dev_compiler.src.codegen.js_codegen; 5 library dev_compiler.src.codegen.js_codegen;
6 6
7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 } 2449 }
2450 var name = _emitMemberName(memberId.name, 2450 var name = _emitMemberName(memberId.name,
2451 type: getStaticType(target), isStatic: isStatic); 2451 type: getStaticType(target), isStatic: isStatic);
2452 if (DynamicInvoke.get(target)) { 2452 if (DynamicInvoke.get(target)) {
2453 return js.call('dart.$DLOAD(#, #)', [_visit(target), name]); 2453 return js.call('dart.$DLOAD(#, #)', [_visit(target), name]);
2454 } 2454 }
2455 2455
2456 String code; 2456 String code;
2457 if (member != null && member is MethodElement && !isStatic) { 2457 if (member != null && member is MethodElement && !isStatic) {
2458 // Tear-off methods: explicitly bind it. 2458 // Tear-off methods: explicitly bind it.
2459 // TODO(leafp): Attach runtime types to these static tearoffs
2460 if (_requiresStaticDispatch(target, memberId.name)) { 2459 if (_requiresStaticDispatch(target, memberId.name)) {
2461 return js.call('dart.#.bind(#)', [name, _visit(target)]); 2460 var type = member.type;
2461 var clos = js.call('dart.#.bind(#)', [name, _visit(target)]);
2462 return js.call('dart.fn(#, #)', [clos, _emitFunctionTypeParts(type)]);
2462 } 2463 }
2463 code = 'dart.bind(#, #)'; 2464 code = 'dart.bind(#, #)';
2464 } else if (_requiresStaticDispatch(target, memberId.name)) { 2465 } else if (_requiresStaticDispatch(target, memberId.name)) {
2465 return js.call('dart.#(#)', [name, _visit(target)]); 2466 return js.call('dart.#(#)', [name, _visit(target)]);
2466 } else { 2467 } else {
2467 code = '#.#'; 2468 code = '#.#';
2468 } 2469 }
2469 2470
2470 return js.call(code, [_visit(target), name]); 2471 return js.call(code, [_visit(target), name]);
2471 } 2472 }
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 3075
3075 /// A special kind of element created by the compiler, signifying a temporary 3076 /// A special kind of element created by the compiler, signifying a temporary
3076 /// variable. These objects use instance equality, and should be shared 3077 /// variable. These objects use instance equality, and should be shared
3077 /// everywhere in the tree where they are treated as the same variable. 3078 /// everywhere in the tree where they are treated as the same variable.
3078 class TemporaryVariableElement extends LocalVariableElementImpl { 3079 class TemporaryVariableElement extends LocalVariableElementImpl {
3079 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 3080 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
3080 3081
3081 int get hashCode => identityHashCode(this); 3082 int get hashCode => identityHashCode(this);
3082 bool operator ==(Object other) => identical(this, other); 3083 bool operator ==(Object other) => identical(this, other);
3083 } 3084 }
OLDNEW
« no previous file with comments | « lib/runtime/_classes.js ('k') | test/browser/runtime_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698