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

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

Issue 232563006: Insert checks before deferred calls and accesses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Correct update to co19 Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/deferred_load.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart2js; 5 part of dart2js;
6 6
7 /// A [ConstantEnvironment] provides access for constants compiled for variable 7 /// A [ConstantEnvironment] provides access for constants compiled for variable
8 /// initializers. 8 /// initializers.
9 abstract class ConstantEnvironment { 9 abstract class ConstantEnvironment {
10 /// Returns the constant for the initializer of [element]. 10 /// Returns the constant for the initializer of [element].
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 Constant makeTypeConstant(TypeDeclarationElement element) { 410 Constant makeTypeConstant(TypeDeclarationElement element) {
411 DartType elementType = element.rawType; 411 DartType elementType = element.rawType;
412 DartType constantType = 412 DartType constantType =
413 compiler.backend.typeImplementation.computeType(compiler); 413 compiler.backend.typeImplementation.computeType(compiler);
414 return new TypeConstant(elementType, constantType); 414 return new TypeConstant(elementType, constantType);
415 } 415 }
416 416
417 /// Returns true if the prefix of the send resolves to a deferred import 417 /// Returns true if the prefix of the send resolves to a deferred import
418 /// prefix. 418 /// prefix.
419 bool isDeferredUse(Send send) { 419 bool isDeferredUse(Send send) {
420 // We handle:
421 // 1. Send(Send(Send(null, Prefix), className), staticName)
422 // 2. Send(Send(Prefix, Classname), staticName)
423 // 3. Send(Send(null, Prefix), staticName | className)
424 // 4. Send(Send(Prefix), staticName | className)
425 // Nodes of the forms 2,4 occur in metadata.
426 if (send == null) return false; 420 if (send == null) return false;
427 while (send.receiver is Send) { 421 return compiler.deferredLoadTask
428 send = send.receiver; 422 .deferredPrefixElement(send, elements) != null;
429 }
430 Identifier prefixNode;
431 if (send.receiver is Identifier) {
432 prefixNode = send.receiver;
433 } else if (send.receiver == null &&
434 send.selector is Identifier) {
435 prefixNode = send.selector;
436 }
437 if (prefixNode != null) {
438 Element maybePrefix = elements[prefixNode.asIdentifier()];
439 if (maybePrefix != null && maybePrefix.isPrefix() &&
440 (maybePrefix as PrefixElement).isDeferred) {
441 return true;
442 }
443 }
444 return false;
445 } 423 }
446 424
447 Constant visitIdentifier(Identifier node) { 425 Constant visitIdentifier(Identifier node) {
448 Element element = elements[node]; 426 Element element = elements[node];
449 if (Elements.isClass(element) || Elements.isTypedef(element)) { 427 if (Elements.isClass(element) || Elements.isTypedef(element)) {
450 return makeTypeConstant(element); 428 return makeTypeConstant(element);
451 } 429 }
452 return signalNotCompileTimeConstant(node); 430 return signalNotCompileTimeConstant(node);
453 } 431 }
454 432
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 if (fieldValue == null) { 967 if (fieldValue == null) {
990 // Use the default value. 968 // Use the default value.
991 fieldValue = handler.compileConstant(field); 969 fieldValue = handler.compileConstant(field);
992 } 970 }
993 jsNewArguments.add(fieldValue); 971 jsNewArguments.add(fieldValue);
994 }, 972 },
995 includeSuperAndInjectedMembers: true); 973 includeSuperAndInjectedMembers: true);
996 return jsNewArguments; 974 return jsNewArguments;
997 } 975 }
998 } 976 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698