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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart

Issue 57873002: Build new IR for functions returning a constant (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: no nested functions in ir Created 7 years 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 type_graph_inferrer; 5 library type_graph_inferrer;
6 6
7 import 'dart:collection' show Queue, IterableBase; 7 import 'dart:collection' show Queue, IterableBase;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeKind; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeKind;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../tree/tree.dart' show LiteralList, Node; 10 import '../tree/tree.dart' show LiteralList, Node;
11 import '../types/types.dart' show TypeMask, ContainerTypeMask, TypesInferrer; 11 import '../types/types.dart' show TypeMask, ContainerTypeMask, TypesInferrer;
12 import '../universe/universe.dart' show Selector, TypedSelector, SideEffects; 12 import '../universe/universe.dart' show Selector, TypedSelector, SideEffects;
13 import '../dart2jslib.dart' show Compiler, TreeElementMapping; 13 import '../dart2jslib.dart' show Compiler, TreeElementMapping;
14 import 'inferrer_visitor.dart' show TypeSystem, ArgumentsTypes; 14 import 'inferrer_visitor.dart' show TypeSystem, ArgumentsTypes;
15 import '../native_handler.dart' as native; 15 import '../native_handler.dart' as native;
16 import '../util/util.dart' show Spannable, Setlet; 16 import '../util/util.dart' show Spannable, Setlet;
17 import 'simple_types_inferrer.dart'; 17 import 'simple_types_inferrer.dart';
18 import 'ir_type_inferrer.dart';
18 import '../dart2jslib.dart' show invariant; 19 import '../dart2jslib.dart' show invariant;
19 20
20 part 'type_graph_nodes.dart'; 21 part 'type_graph_nodes.dart';
21 part 'container_tracer.dart'; 22 part 'container_tracer.dart';
22 23
23 /** 24 /**
24 * A set of selector names that [List] implements, that we know return 25 * A set of selector names that [List] implements, that we know return
25 * their element type. 26 * their element type.
26 */ 27 */
27 Set<Selector> returnsElementTypeSet = new Set<Selector>.from( 28 Set<Selector> returnsElementTypeSet = new Set<Selector>.from(
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 compiler.log('Inferred $overallRefineCount types.'); 462 compiler.log('Inferred $overallRefineCount types.');
462 463
463 processLoopInformation(); 464 processLoopInformation();
464 } 465 }
465 466
466 void analyze(Element element) { 467 void analyze(Element element) {
467 element = element.implementation; 468 element = element.implementation;
468 if (analyzedElements.contains(element)) return; 469 if (analyzedElements.contains(element)) return;
469 analyzedElements.add(element); 470 analyzedElements.add(element);
470 471
471 SimpleTypeInferrerVisitor visitor = 472 var visitor;
472 new SimpleTypeInferrerVisitor(element, compiler, this); 473 if (element.hasIrNode(compiler)) {
474 visitor = new IrTypeInferrerVisitor(compiler, element, this);
475 } else {
476 visitor = new SimpleTypeInferrerVisitor(element, compiler, this);
477 }
478 // SimpleTypeInferrerVisitor visitor =
ngeoffray 2013/11/21 15:02:05 Remove commented code.
lukas 2013/11/21 17:14:27 Done.
479 // new SimpleTypeInferrerVisitor(element, compiler, this);
473 TypeInformation type; 480 TypeInformation type;
474 compiler.withCurrentElement(element, () { 481 compiler.withCurrentElement(element, () {
475 type = visitor.run(); 482 type = visitor.run();
476 }); 483 });
477 addedInGraph++; 484 addedInGraph++;
478 485
479 if (element.isField()) { 486 if (element.isField()) {
480 Node node = element.parseNode(compiler); 487 Node node = element.parseNode(compiler);
481 if (element.modifiers.isFinal() || element.modifiers.isConst()) { 488 if (element.modifiers.isFinal() || element.modifiers.isConst()) {
482 // If [element] is final and has an initializer, we record 489 // If [element] is final and has an initializer, we record
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 680 }
674 681
675 bool recordType(Element element, TypeInformation type) { 682 bool recordType(Element element, TypeInformation type) {
676 types.getInferredTypeOf(element).addAssignment(type); 683 types.getInferredTypeOf(element).addAssignment(type);
677 return false; 684 return false;
678 } 685 }
679 686
680 void recordReturnType(Element element, TypeInformation type) { 687 void recordReturnType(Element element, TypeInformation type) {
681 TypeInformation info = types.getInferredTypeOf(element); 688 TypeInformation info = types.getInferredTypeOf(element);
682 if (element.name == '==') { 689 if (element.name == '==') {
690 // Even if x.== doesn't return a bool, 'x == null' evaluates to 'false'.
683 info.addAssignment(types.boolType); 691 info.addAssignment(types.boolType);
684 } 692 }
685 // TODO(ngeoffray): Clean up. We do these checks because 693 // TODO(ngeoffray): Clean up. We do these checks because
686 // [SimpleTypesInferrer] deals with two different inferrers. 694 // [SimpleTypesInferrer] deals with two different inferrers.
687 if (type == null) return; 695 if (type == null) return;
688 if (info.assignments.isEmpty) info.addAssignment(type); 696 if (info.assignments.isEmpty) info.addAssignment(type);
689 } 697 }
690 698
691 TypeInformation addReturnTypeFor(Element element, 699 TypeInformation addReturnTypeFor(Element element,
692 TypeInformation unused, 700 TypeInformation unused,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 throw new UnsupportedError( 920 throw new UnsupportedError(
913 "Cannot query the type inferrer when type inference is disabled."); 921 "Cannot query the type inferrer when type inference is disabled.");
914 } 922 }
915 return inferrer.getCallersOf(element); 923 return inferrer.getCallersOf(element);
916 } 924 }
917 925
918 void clear() { 926 void clear() {
919 inferrer.clear(); 927 inferrer.clear();
920 } 928 }
921 } 929 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698