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

Side by Side Diff: lib/src/info.dart

Issue 1050703002: Downwards closure inference (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Created 5 years, 8 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
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 /// Defines static information collected by the type checker and used later by 5 /// Defines static information collected by the type checker and used later by
6 /// emitters to generate code. 6 /// emitters to generate code.
7 library dev_compiler.src.info; 7 library dev_compiler.src.info;
8 8
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 static InferredTypeBase create( 378 static InferredTypeBase create(
379 TypeRules rules, Expression expression, DartType type) { 379 TypeRules rules, Expression expression, DartType type) {
380 380
381 // Specialized inference: 381 // Specialized inference:
382 if (expression is Literal) { 382 if (expression is Literal) {
383 return new InferredTypeLiteral(rules, expression, type); 383 return new InferredTypeLiteral(rules, expression, type);
384 } 384 }
385 if (expression is InstanceCreationExpression) { 385 if (expression is InstanceCreationExpression) {
386 return new InferredTypeAllocation(rules, expression, type); 386 return new InferredTypeAllocation(rules, expression, type);
387 } 387 }
388 if (expression is FunctionExpression) {
389 return new InferredTypeClosure(rules, expression, type);
390 }
388 return new InferredType(rules, expression, type); 391 return new InferredType(rules, expression, type);
389 } 392 }
390 } 393 }
391 394
392 // An infered type for a literal expression. 395 // An infered type for a literal expression.
393 class InferredTypeLiteral extends InferredTypeBase { 396 class InferredTypeLiteral extends InferredTypeBase {
394 InferredTypeLiteral(TypeRules rules, Expression expression, DartType type) 397 InferredTypeLiteral(TypeRules rules, Expression expression, DartType type)
395 : super._internal(rules, expression, type); 398 : super._internal(rules, expression, type);
396 } 399 }
397 400
398 // An inferred type for a non-literal allocation site. 401 // An inferred type for a non-literal allocation site.
399 class InferredTypeAllocation extends InferredTypeBase { 402 class InferredTypeAllocation extends InferredTypeBase {
400 InferredTypeAllocation(TypeRules rules, Expression expression, DartType type) 403 InferredTypeAllocation(TypeRules rules, Expression expression, DartType type)
401 : super._internal(rules, expression, type); 404 : super._internal(rules, expression, type);
402 } 405 }
403 406
407 // An inferred type for a closure expression
408 class InferredTypeClosure extends InferredTypeBase {
409 InferredTypeClosure(TypeRules rules, Expression expression, DartType type)
410 : super._internal(rules, expression, type);
411 }
412
404 // TODO(vsm): Remove these. 413 // TODO(vsm): Remove these.
405 414
406 // A wrapped closure coerces the underlying type to the desired type. 415 // A wrapped closure coerces the underlying type to the desired type.
407 class ClosureWrapBase extends Conversion { 416 class ClosureWrapBase extends Conversion {
408 FunctionType _wrappedType; 417 FunctionType _wrappedType;
409 Wrapper _wrapper; 418 Wrapper _wrapper;
410 419
411 ClosureWrapBase._internal( 420 ClosureWrapBase._internal(
412 TypeRules rules, Expression expression, this._wrapper, this._wrappedType) 421 TypeRules rules, Expression expression, this._wrapper, this._wrappedType)
413 : super(rules, expression) { 422 : super(rules, expression) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 for (var cls in declarations.where((d) => d is ClassMirror)) { 718 for (var cls in declarations.where((d) => d is ClassMirror)) {
710 if (cls.isSubtypeOf(infoMirror)) { 719 if (cls.isSubtypeOf(infoMirror)) {
711 allTypes.add(cls); 720 allTypes.add(cls);
712 baseTypes.add(cls.superclass); 721 baseTypes.add(cls.superclass);
713 } 722 }
714 } 723 }
715 allTypes.removeAll(baseTypes); 724 allTypes.removeAll(baseTypes);
716 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) 725 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType))
717 ..sort((t1, t2) => '$t1'.compareTo('$t2')); 726 ..sort((t1, t2) => '$t1'.compareTo('$t2'));
718 }(); 727 }();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698