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

Side by Side Diff: pkg/compiler/lib/src/inferrer/builder.dart

Issue 2991313002: Split ast based parts from InferrerEngineImpl (Closed)
Patch Set: Created 3 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
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 simple_types_inferrer; 5 library simple_types_inferrer;
6 6
7 import '../closure.dart' show ClosureRepresentationInfo; 7 import '../closure.dart' show ClosureRepresentationInfo;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show Identifiers, Selectors; 9 import '../common/names.dart' show Identifiers, Selectors;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 node = resolvedAst.node; 97 node = resolvedAst.node;
98 } 98 }
99 FieldInitializationScope fieldScope = 99 FieldInitializationScope fieldScope =
100 analyzedElement.isGenerativeConstructor 100 analyzedElement.isGenerativeConstructor
101 ? new FieldInitializationScope(types) 101 ? new FieldInitializationScope(types)
102 : null; 102 : null;
103 locals = 103 locals =
104 new LocalsHandler(inferrer, types, compiler.options, node, fieldScope); 104 new LocalsHandler(inferrer, types, compiler.options, node, fieldScope);
105 } 105 }
106 106
107 ElementGraphBuilder(MemberElement element, ResolvedAst resolvedAst, 107 ElementGraphBuilder(
108 Compiler compiler, InferrerEngine inferrer, [LocalsHandler handler]) 108 MemberElement element, Compiler compiler, InferrerEngine inferrer,
109 : this.internal(element, resolvedAst, element.memberContext.declaration, 109 [LocalsHandler handler])
110 inferrer, compiler, handler); 110 : this.internal(element, element.resolvedAst,
111 element.memberContext.declaration, inferrer, compiler, handler);
111 112
112 TreeElements get elements => resolvedAst.elements; 113 TreeElements get elements => resolvedAst.elements;
113 114
114 bool accumulateIsChecks = false; 115 bool accumulateIsChecks = false;
115 bool conditionIsSimple = false; 116 bool conditionIsSimple = false;
116 List<ast.Send> isChecks; 117 List<ast.Send> isChecks;
117 int loopLevel = 0; 118 int loopLevel = 0;
118 119
119 bool get inLoop => loopLevel > 0; 120 bool get inLoop => loopLevel > 0;
120 bool get isThisExposed { 121 bool get isThisExposed {
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 886
886 TypeInformation visitCascade(ast.Cascade node) { 887 TypeInformation visitCascade(ast.Cascade node) {
887 // Ignore the result of the cascade send and return the type of the cascade 888 // Ignore the result of the cascade send and return the type of the cascade
888 // receiver. 889 // receiver.
889 visit(node.expression); 890 visit(node.expression);
890 return cascadeReceiverStack.removeLast(); 891 return cascadeReceiverStack.removeLast();
891 } 892 }
892 893
893 void analyzeSuperConstructorCall( 894 void analyzeSuperConstructorCall(
894 ConstructorElement target, ArgumentsTypes arguments) { 895 ConstructorElement target, ArgumentsTypes arguments) {
896 assert(target.isDeclaration);
895 ResolvedAst resolvedAst = target.resolvedAst; 897 ResolvedAst resolvedAst = target.resolvedAst;
896 inferrer.analyze(resolvedAst, arguments); 898 ast.Node body;
899 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
900 body = resolvedAst.node;
901 }
902 inferrer.analyze(target, body, arguments);
897 isThisExposed = isThisExposed || inferrer.checkIfExposesThis(target); 903 isThisExposed = isThisExposed || inferrer.checkIfExposesThis(target);
898 } 904 }
899 905
900 TypeInformation run() { 906 TypeInformation run() {
901 var node; 907 var node;
902 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 908 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
903 node = resolvedAst.node; 909 node = resolvedAst.node;
904 } 910 }
905 ast.Expression initializer; 911 ast.Expression initializer;
906 if (analyzedElement.isField) { 912 if (analyzedElement.isField) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 ? declaration.callMethod 955 ? declaration.callMethod
950 : declaration; 956 : declaration;
951 bool needNewContext = declarationMethod != analyzedElement; 957 bool needNewContext = declarationMethod != analyzedElement;
952 if (needNewContext) { 958 if (needNewContext) {
953 assert( 959 assert(
954 declarationMethod is ConstructorElement, 960 declarationMethod is ConstructorElement,
955 failedAt( 961 failedAt(
956 parameter, 962 parameter,
957 "Unexpected function declaration " 963 "Unexpected function declaration "
958 "${declarationMethod}, expected ${analyzedElement}.")); 964 "${declarationMethod}, expected ${analyzedElement}."));
959 visitor = new ElementGraphBuilder(declarationMethod, 965 visitor =
960 parameter.functionDeclaration.resolvedAst, compiler, inferrer); 966 new ElementGraphBuilder(declarationMethod, compiler, inferrer);
961 } 967 }
962 TypeInformation type = 968 TypeInformation type =
963 (defaultValue == null) ? types.nullType : visitor.visit(defaultValue); 969 (defaultValue == null) ? types.nullType : visitor.visit(defaultValue);
964 inferrer.setDefaultTypeOfParameter(parameter, type, 970 inferrer.setDefaultTypeOfParameter(parameter, type,
965 isInstanceMember: function.isInstanceMember); 971 isInstanceMember: function.isInstanceMember);
966 }); 972 });
967 973
968 if (closedWorld.nativeData.isNativeMember(analyzedElement)) { 974 if (closedWorld.nativeData.isNativeMember(analyzedElement)) {
969 // Native methods do not have a body, and we currently just say 975 // Native methods do not have a body, and we currently just say
970 // they return dynamic. 976 // they return dynamic.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // the safe side, we mark [this] as exposed here. We could do better by 1103 // the safe side, we mark [this] as exposed here. We could do better by
1098 // analyzing the closure. 1104 // analyzing the closure.
1099 // TODO(herhut): Analyze whether closure exposes this. 1105 // TODO(herhut): Analyze whether closure exposes this.
1100 isThisExposed = true; 1106 isThisExposed = true;
1101 LocalFunctionElement element = elements.getFunctionDefinition(node); 1107 LocalFunctionElement element = elements.getFunctionDefinition(node);
1102 // We don'TypeInformation put the closure in the work queue of the 1108 // We don'TypeInformation put the closure in the work queue of the
1103 // inferrer, because it will share information with its enclosing 1109 // inferrer, because it will share information with its enclosing
1104 // method, like for example the types of local variables. 1110 // method, like for example the types of local variables.
1105 LocalsHandler closureLocals = 1111 LocalsHandler closureLocals =
1106 new LocalsHandler.from(locals, node, useOtherTryBlock: false); 1112 new LocalsHandler.from(locals, node, useOtherTryBlock: false);
1107 ElementGraphBuilder visitor = new ElementGraphBuilder(element.callMethod, 1113 ElementGraphBuilder visitor = new ElementGraphBuilder(
1108 element.resolvedAst, compiler, inferrer, closureLocals); 1114 element.callMethod, compiler, inferrer, closureLocals);
1109 visitor.run(); 1115 visitor.run();
1110 inferrer.recordReturnType(element.callMethod, visitor.returnType); 1116 inferrer.recordReturnType(element.callMethod, visitor.returnType);
1111 1117
1112 // Record the types of captured non-boxed variables. Types of 1118 // Record the types of captured non-boxed variables. Types of
1113 // these variables may already be there, because of an analysis of 1119 // these variables may already be there, because of an analysis of
1114 // a previous closure. 1120 // a previous closure.
1115 ClosureRepresentationInfo nestedClosureData = compiler 1121 ClosureRepresentationInfo nestedClosureData = compiler
1116 .backendStrategy.closureDataLookup 1122 .backendStrategy.closureDataLookup
1117 .getClosureRepresentationInfo(element); 1123 .getClosureRepresentationInfo(element);
1118 nestedClosureData.forEachCapturedVariable((variable, field) { 1124 nestedClosureData.forEachCapturedVariable((variable, field) {
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 node, 2984 node,
2979 iteratorSelector, 2985 iteratorSelector,
2980 iteratorMask, 2986 iteratorMask,
2981 expressionType, 2987 expressionType,
2982 new ArgumentsTypes.empty()); 2988 new ArgumentsTypes.empty());
2983 2989
2984 return handleForInLoop(node, iteratorType, currentSelector, currentMask, 2990 return handleForInLoop(node, iteratorType, currentSelector, currentMask,
2985 moveNextSelector, moveNextMask); 2991 moveNextSelector, moveNextMask);
2986 } 2992 }
2987 } 2993 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/ast_inferrer_engine.dart ('k') | pkg/compiler/lib/src/inferrer/builder_kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698