Chromium Code Reviews| Index: pkg/compiler/lib/src/stats/analysis_result.dart |
| diff --git a/pkg/compiler/lib/src/stats/analysis_result.dart b/pkg/compiler/lib/src/stats/analysis_result.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e83ffd64463aa16eac5e20eaeef0d239f2b743b8 |
| --- /dev/null |
| +++ b/pkg/compiler/lib/src/stats/analysis_result.dart |
| @@ -0,0 +1,73 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/// API to get results from a static analysis of the source program. |
| +library compiler.src.stats.analysis_result; |
| + |
| +import '../tree/tree.dart' show Node; |
| +import '../universe/universe.dart' show Selector; |
| + |
| +/// A three-value logic bool (yes, no, maybe). We say that `yes` and `maybe` are |
| +/// "truthy", while `no` and `maybe` are "falsy". |
| +// TODO(sigmund): is it worth using an enum? or switch to true/false/null? |
| +enum boolish { yes, no, maybe } |
|
Johnni Winther
2015/07/13 19:21:43
'boolish' -> 'Boolish'
Siggi Cherem (dart-lang)
2015/09/29 01:39:33
Done.
|
| + |
| +/// Specifies results of some kind of static analysis on a source program. |
| +abstract class AnalysisResult { |
| + /// Information computed about a specific [receiver]. |
| + ReceiverInfo infoForReceiver(Node receiver); |
| + |
| + /// Information computed about a specific [selector] applied to a specific |
| + /// [receiver]. |
| + SelectorInfo infoForSelector(Node receiver, Selector selector); |
| +} |
| + |
| +/// Analysis information about a receiver of a send. |
| +abstract class ReceiverInfo { |
| + /// Receiver node for which this information is computed. |
| + Node get receiver; |
| + |
| + /// Return whether [receiver] resolves to a value that implements no such |
| + /// method. The answer is `yes` if all values that [receiver] could evaluate |
| + /// to at runtime contain it, or `no` if none of them does. Maybe if it |
| + /// depends on some context or we can't determine this information precisely. |
| + boolish get hasNoSuchMethod; |
| + |
| + /// When [hasNoSuchMethod] is yes, the precise number of possible noSuchMethod |
| + /// handlers for this receiver. |
| + final int possibleNsmTargets; |
| + |
| + /// Return whether [receiver] may ever be null. |
| + boolish get isNull; |
| +} |
| + |
| +/// Information about a specific selector applied to a specific receiver. |
| +abstract class SelectorInfo { |
| + /// Receiver node of the [selector]. |
| + Node get receiver; |
| + |
| + /// Specific selector on [receiver] for which this information is computed. |
| + Selector get selector; |
| + |
| + /// Whether a member matching [selector] exists in [receiver]. |
| + boolish get exists; |
| + |
| + /// Whether [receiver] needs an interceptor to implement [selector]. |
| + boolish get usesInterceptor; |
| + |
| + /// Possible total number of methods that could be the target of the selector. |
| + /// This needs to be combined with [isAccurate] to correctly understand the |
| + /// value. Some invariants: |
| + /// |
| + /// * If [exists] is `no`, the value here should be 0, regardless of |
| + /// accuracy. |
| + /// * If [exists] is `yes`, the value is always considered 1 or more. |
| + /// If [isAccurate] is false, we treat it as there may be many possible |
| + /// targets. |
| + /// * If [exists] is `maybe`, the value is considered 0 or more. |
| + int get possibleTargets; |
| + |
| + /// Whether the information about [possibleTargets] is accurate. |
| + bool get isAccurate; |
| +} |