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

Side by Side Diff: lib/src/compiler/code_generator.dart

Issue 2291873002: Bind this in ng2 hack code (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 3 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 | « no previous file | 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 import 'dart:collection' show HashMap, HashSet; 5 import 'dart:collection' show HashMap, HashSet;
6 import 'dart:math' show min, max; 6 import 'dart:math' show min, max;
7 7
8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 var element = node.methodName.staticElement; 3216 var element = node.methodName.staticElement;
3217 bool isStatic = element is ExecutableElement && element.isStatic; 3217 bool isStatic = element is ExecutableElement && element.isStatic;
3218 var memberName = _emitMemberName(name, type: type, isStatic: isStatic); 3218 var memberName = _emitMemberName(name, type: type, isStatic: isStatic);
3219 3219
3220 JS.Expression jsTarget = _visit(target); 3220 JS.Expression jsTarget = _visit(target);
3221 if (isDynamicInvoke(target) || isDynamicInvoke(node.methodName)) { 3221 if (isDynamicInvoke(target) || isDynamicInvoke(node.methodName)) {
3222 if (_inWhitelistCode(target)) { 3222 if (_inWhitelistCode(target)) {
3223 var vars = <JS.MetaLetVariable, JS.Expression>{}; 3223 var vars = <JS.MetaLetVariable, JS.Expression>{};
3224 var l = _visit(_bindValue(vars, 'l', target)); 3224 var l = _visit(_bindValue(vars, 'l', target));
3225 jsTarget = new JS.MetaLet(vars, [ 3225 jsTarget = new JS.MetaLet(vars, [
3226 js.call('(#[(#[dart._extensionType]) ? dartx[#] : #])', 3226 js.call('(#[(#[dart._extensionType]) ? dartx[#] : #]).bind(#)',
vsm 2016/08/29 22:01:04 FYI: this was the path triggered by the example.
3227 [l, l, memberName, memberName,]) 3227 [l, l, memberName, memberName, l])
3228 ]); 3228 ]);
3229 if (typeArgs != null) jsTarget = new JS.Call(jsTarget, typeArgs); 3229 if (typeArgs != null) jsTarget = new JS.Call(jsTarget, typeArgs);
3230 return new JS.Call(jsTarget, args); 3230 return new JS.Call(jsTarget, args);
3231 } 3231 }
3232 if (typeArgs != null) { 3232 if (typeArgs != null) {
3233 return js.call('dart.dgsend(#, #, #, #)', 3233 return js.call('dart.dgsend(#, #, #, #)',
3234 [jsTarget, new JS.ArrayInitializer(typeArgs), memberName, args]); 3234 [jsTarget, new JS.ArrayInitializer(typeArgs), memberName, args]);
3235 } else { 3235 } else {
3236 return js.call('dart.dsend(#, #, #)', [jsTarget, memberName, args]); 3236 return js.call('dart.dsend(#, #, #)', [jsTarget, memberName, args]);
3237 } 3237 }
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 /// See [visitMethodInvocation]. 4558 /// See [visitMethodInvocation].
4559 JS.Expression _emitSend( 4559 JS.Expression _emitSend(
4560 Expression target, String name, List<Expression> args) { 4560 Expression target, String name, List<Expression> args) {
4561 var type = getStaticType(target); 4561 var type = getStaticType(target);
4562 var memberName = _emitMemberName(name, unary: args.isEmpty, type: type); 4562 var memberName = _emitMemberName(name, unary: args.isEmpty, type: type);
4563 if (isDynamicInvoke(target)) { 4563 if (isDynamicInvoke(target)) {
4564 if (_inWhitelistCode(target)) { 4564 if (_inWhitelistCode(target)) {
4565 var vars = <JS.MetaLetVariable, JS.Expression>{}; 4565 var vars = <JS.MetaLetVariable, JS.Expression>{};
4566 var l = _visit(_bindValue(vars, 'l', target)); 4566 var l = _visit(_bindValue(vars, 'l', target));
4567 return new JS.MetaLet(vars, [ 4567 return new JS.MetaLet(vars, [
4568 js.call('(#[(#[dart._extensionType]) ? dartx[#] : #])(#)', 4568 js.call('(#[(#[dart._extensionType]) ? dartx[#] : #]).call(#, #)',
vsm 2016/08/29 22:01:04 apply is the one that takes an array. :-)
4569 [l, l, memberName, memberName, _visitList(args)]) 4569 [l, l, memberName, memberName, l, _visitList(args)])
4570 ]); 4570 ]);
4571 } 4571 }
4572 // dynamic dispatch 4572 // dynamic dispatch
4573 var dynamicHelper = const {'[]': 'dindex', '[]=': 'dsetindex'}[name]; 4573 var dynamicHelper = const {'[]': 'dindex', '[]=': 'dsetindex'}[name];
4574 if (dynamicHelper != null) { 4574 if (dynamicHelper != null) {
4575 return js.call( 4575 return js.call(
4576 'dart.$dynamicHelper(#, #)', [_visit(target), _visitList(args)]); 4576 'dart.$dynamicHelper(#, #)', [_visit(target), _visitList(args)]);
4577 } else { 4577 } else {
4578 return js.call('dart.dsend(#, #, #)', 4578 return js.call('dart.dsend(#, #, #)',
4579 [_visit(target), memberName, _visitList(args)]); 4579 [_visit(target), memberName, _visitList(args)]);
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
5363 } 5363 }
5364 5364
5365 bool isLibraryPrefix(Expression node) => 5365 bool isLibraryPrefix(Expression node) =>
5366 node is SimpleIdentifier && node.staticElement is PrefixElement; 5366 node is SimpleIdentifier && node.staticElement is PrefixElement;
5367 5367
5368 LibraryElement _getLibrary(AnalysisContext c, String uri) => 5368 LibraryElement _getLibrary(AnalysisContext c, String uri) =>
5369 c.computeLibraryElement(c.sourceFactory.forUri(uri)); 5369 c.computeLibraryElement(c.sourceFactory.forUri(uri));
5370 5370
5371 bool _isDartRuntime(LibraryElement l) => 5371 bool _isDartRuntime(LibraryElement l) =>
5372 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 5372 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698