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

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

Issue 11817013: Do not apply optimizations based on an element if that element cannot be resolved. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 library mock_compiler; 5 library mock_compiler;
6 6
7 import 'dart:uri'; 7 import 'dart:uri';
8 8
9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 abstract class JavaScriptIndexingBehavior {} 45 abstract class JavaScriptIndexingBehavior {}
46 class JSInvocationMirror {} 46 class JSInvocationMirror {}
47 S() {} 47 S() {}
48 assertHelper(a){} 48 assertHelper(a){}
49 throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {}'''; 49 throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {}''';
50 50
51 const String DEFAULT_INTERCEPTORSLIB = r''' 51 const String DEFAULT_INTERCEPTORSLIB = r'''
52 class JSArray { 52 class JSArray {
53 var length; 53 var length;
54 operator[](index) {} 54 operator[](index) {}
55 var add;
55 } 56 }
56 class JSString { 57 class JSString {
57 var length; 58 var length;
59 operator[](index) {}
58 } 60 }
59 class JSNumber { 61 class JSNumber {
60 } 62 }
61 class JSInt { 63 class JSInt {
62 } 64 }
63 class JSDouble { 65 class JSDouble {
64 } 66 }
65 class JSNull { 67 class JSNull {
66 } 68 }
67 class JSBool { 69 class JSBool {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 228 }
227 229
228 // The mock library doesn't need any patches. 230 // The mock library doesn't need any patches.
229 Uri resolvePatchUri(String dartLibraryName) => null; 231 Uri resolvePatchUri(String dartLibraryName) => null;
230 232
231 Script readScript(Uri uri, [ScriptTag node]) { 233 Script readScript(Uri uri, [ScriptTag node]) {
232 SourceFile sourceFile = sourceFiles[uri.toString()]; 234 SourceFile sourceFile = sourceFiles[uri.toString()];
233 if (sourceFile == null) throw new ArgumentError(uri); 235 if (sourceFile == null) throw new ArgumentError(uri);
234 return new Script(uri, sourceFile); 236 return new Script(uri, sourceFile);
235 } 237 }
238
239 Element findInScopeContainer(ScopeContainerElement scope, SourceString name) {
240 Element element = scope.localLookup(name);
241 return element != null ? element : new UnresolvedElement(name, scope);
242 }
236 } 243 }
237 244
238 void compareWarningKinds(String text, expectedWarnings, foundWarnings) { 245 void compareWarningKinds(String text, expectedWarnings, foundWarnings) {
239 var fail = (message) => Expect.fail('$text: $message'); 246 var fail = (message) => Expect.fail('$text: $message');
240 HasNextIterator<MessageKind> expected = 247 HasNextIterator<MessageKind> expected =
241 new HasNextIterator(expectedWarnings.iterator); 248 new HasNextIterator(expectedWarnings.iterator);
242 HasNextIterator<WarningMessage> found = 249 HasNextIterator<WarningMessage> found =
243 new HasNextIterator(foundWarnings.iterator); 250 new HasNextIterator(foundWarnings.iterator);
244 while (expected.hasNext && found.hasNext) { 251 while (expected.hasNext && found.hasNext) {
245 Expect.equals(expected.next(), found.next().message.kind); 252 Expect.equals(expected.next(), found.next().message.kind);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 operator []=(Node node, Element element) { 289 operator []=(Node node, Element element) {
283 map[node] = element; 290 map[node] = element;
284 } 291 }
285 292
286 operator [](Node node) => map[node]; 293 operator [](Node node) => map[node];
287 294
288 void remove(Node node) { 295 void remove(Node node) {
289 map.remove(node); 296 map.remove(node);
290 } 297 }
291 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698