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

Side by Side Diff: tests/compiler/dart2js/cpa_inference_test.dart

Issue 12211112: Start work on a non-complete type inferrer. Currently only analyzes return types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:uri"; 5 import "dart:uri";
6 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"; 6 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t";
7 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da rt'; 7 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da rt';
8 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; 8 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart';
10 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; 10 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 BaseType int; 46 BaseType int;
47 BaseType double; 47 BaseType double;
48 BaseType num; 48 BaseType num;
49 BaseType bool; 49 BaseType bool;
50 BaseType string; 50 BaseType string;
51 BaseType list; 51 BaseType list;
52 BaseType map; 52 BaseType map;
53 BaseType nullType; 53 BaseType nullType;
54 54
55 AnalysisResult(MockCompiler compiler) : this.compiler = compiler { 55 AnalysisResult(MockCompiler compiler) : this.compiler = compiler {
56 inferrer = compiler.typesTask.concreteTypesInferrer; 56 inferrer = compiler.typesTask.typesInferrer;
57 int = inferrer.baseTypes.intBaseType; 57 int = inferrer.baseTypes.intBaseType;
58 double = inferrer.baseTypes.doubleBaseType; 58 double = inferrer.baseTypes.doubleBaseType;
59 num = inferrer.baseTypes.numBaseType; 59 num = inferrer.baseTypes.numBaseType;
60 bool = inferrer.baseTypes.boolBaseType; 60 bool = inferrer.baseTypes.boolBaseType;
61 string = inferrer.baseTypes.stringBaseType; 61 string = inferrer.baseTypes.stringBaseType;
62 list = inferrer.baseTypes.listBaseType; 62 list = inferrer.baseTypes.listBaseType;
63 map = inferrer.baseTypes.mapBaseType; 63 map = inferrer.baseTypes.mapBaseType;
64 nullType = new NullBaseType(); 64 nullType = new NullBaseType();
65 Element mainElement = compiler.mainApp.find(buildSourceString('main')); 65 Element mainElement = compiler.mainApp.find(buildSourceString('main'));
66 ast = mainElement.parseNode(compiler); 66 ast = mainElement.parseNode(compiler);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 class Dynamic_ {} 170 class Dynamic_ {}
171 bool identical(Object a, Object b) {}'''; 171 bool identical(Object a, Object b) {}''';
172 172
173 AnalysisResult analyze(String code, {int maxConcreteTypeSize: 1000}) { 173 AnalysisResult analyze(String code, {int maxConcreteTypeSize: 1000}) {
174 Uri uri = new Uri.fromComponents(scheme: 'source'); 174 Uri uri = new Uri.fromComponents(scheme: 'source');
175 MockCompiler compiler = new MockCompiler( 175 MockCompiler compiler = new MockCompiler(
176 coreSource: CORELIB, 176 coreSource: CORELIB,
177 enableConcreteTypeInference: true, 177 enableConcreteTypeInference: true,
178 maxConcreteTypeSize: maxConcreteTypeSize); 178 maxConcreteTypeSize: maxConcreteTypeSize);
179 compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code); 179 compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code);
180 compiler.typesTask.concreteTypesInferrer.testMode = true; 180 compiler.typesTask.typesInferrer.testMode = true;
181 compiler.runCompiler(uri); 181 compiler.runCompiler(uri);
182 return new AnalysisResult(compiler); 182 return new AnalysisResult(compiler);
183 } 183 }
184 184
185 testDynamicBackDoor() { 185 testDynamicBackDoor() {
186 final String source = r""" 186 final String source = r"""
187 main () { 187 main () {
188 var x = "__dynamic_for_test"; 188 var x = "__dynamic_for_test";
189 x; 189 x;
190 } 190 }
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 // testFieldInitialization(); // TODO(polux) 1069 // testFieldInitialization(); // TODO(polux)
1070 testSendWithWrongArity(); 1070 testSendWithWrongArity();
1071 testBigTypesWidening1(); 1071 testBigTypesWidening1();
1072 testBigTypesWidening2(); 1072 testBigTypesWidening2();
1073 testDynamicIsAbsorbing(); 1073 testDynamicIsAbsorbing();
1074 testLists(); 1074 testLists();
1075 testListWithCapacity(); 1075 testListWithCapacity();
1076 testEmptyList(); 1076 testEmptyList();
1077 testIsCheck(); 1077 testIsCheck();
1078 } 1078 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/types.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698