| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.constant; | 8 library engine.constant; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| 11 import 'java_engine.dart' show ObjectUtilities; | 11 import 'java_engine.dart' show ObjectUtilities; |
| 12 import 'source.dart' show Source; | 12 import 'source.dart' show Source; |
| 13 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; | 13 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; |
| 14 import 'scanner.dart' show Token, TokenType; | 14 import 'scanner.dart' show Token, TokenType; |
| 15 import 'ast.dart'; | 15 import 'ast.dart'; |
| 16 import 'element.dart'; | 16 import 'element.dart'; |
| 17 import 'resolver.dart' show TypeProvider; | 17 import 'resolver.dart' show TypeProvider; |
| 18 import 'engine.dart' show AnalysisEngine; | 18 import 'engine.dart' show AnalysisEngine; |
| 19 import 'utilities_dart.dart' show ParameterKind; | 19 import 'utilities_dart.dart' show ParameterKind; |
| 20 import 'utilities_collection.dart' show DirectedGraph; |
| 20 | 21 |
| 21 /** | 22 /** |
| 22 * Instances of the class `ConstantEvaluator` evaluate constant expressions to p
roduce their | 23 * Instances of the class `ConstantEvaluator` evaluate constant expressions to p
roduce their |
| 23 * compile-time value. According to the Dart Language Specification: <blockquote
> A constant | 24 * compile-time value. According to the Dart Language Specification: <blockquote
> A constant |
| 24 * expression is one of the following: | 25 * expression is one of the following: |
| 25 * * A literal number. | 26 * * A literal number. |
| 26 * * A literal boolean. | 27 * * A literal boolean. |
| 27 * * A literal string where any interpolated expression is a compile-time consta
nt that evaluates | 28 * * A literal string where any interpolated expression is a compile-time consta
nt that evaluates |
| 28 * to a numeric, string or boolean value or to <b>null</b>. | 29 * to a numeric, string or boolean value or to <b>null</b>. |
| 29 * * A literal symbol. | 30 * * A literal symbol. |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 DartObjectImpl _valueOf(Expression expression) { | 882 DartObjectImpl _valueOf(Expression expression) { |
| 882 EvaluationResultImpl expressionValue = expression.accept(this); | 883 EvaluationResultImpl expressionValue = expression.accept(this); |
| 883 if (expressionValue is ValidResult) { | 884 if (expressionValue is ValidResult) { |
| 884 return expressionValue.value; | 885 return expressionValue.value; |
| 885 } | 886 } |
| 886 return null2; | 887 return null2; |
| 887 } | 888 } |
| 888 } | 889 } |
| 889 | 890 |
| 890 /** | 891 /** |
| 891 * Instances of the class `DirectedGraph` implement a directed graph in which th
e nodes are | |
| 892 * arbitrary (client provided) objects and edges are represented implicitly. The
graph will allow an | |
| 893 * edge from any node to any other node, including itself, but will not represen
t multiple edges | |
| 894 * between the same pair of nodes. | |
| 895 * | |
| 896 * @param N the type of the nodes in the graph | |
| 897 */ | |
| 898 class DirectedGraph<N> { | |
| 899 /** | |
| 900 * The table encoding the edges in the graph. An edge is represented by an ent
ry mapping the head | |
| 901 * to a set of tails. Nodes that are not the head of any edge are represented
by an entry mapping | |
| 902 * the node to an empty set of tails. | |
| 903 */ | |
| 904 Map<N, Set<N>> _edges = new Map<N, Set<N>>(); | |
| 905 | |
| 906 /** | |
| 907 * Add an edge from the given head node to the given tail node. Both nodes wil
l be a part of the | |
| 908 * graph after this method is invoked, whether or not they were before. | |
| 909 * | |
| 910 * @param head the node at the head of the edge | |
| 911 * @param tail the node at the tail of the edge | |
| 912 */ | |
| 913 void addEdge(N head, N tail) { | |
| 914 // | |
| 915 // First, ensure that the tail is a node known to the graph. | |
| 916 // | |
| 917 Set<N> tails = _edges[tail]; | |
| 918 if (tails == null) { | |
| 919 _edges[tail] = new Set<N>(); | |
| 920 } | |
| 921 // | |
| 922 // Then create the edge. | |
| 923 // | |
| 924 tails = _edges[head]; | |
| 925 if (tails == null) { | |
| 926 tails = new Set<N>(); | |
| 927 _edges[head] = tails; | |
| 928 } | |
| 929 tails.add(tail); | |
| 930 } | |
| 931 | |
| 932 /** | |
| 933 * Add the given node to the set of nodes in the graph. | |
| 934 * | |
| 935 * @param node the node to be added | |
| 936 */ | |
| 937 void addNode(N node) { | |
| 938 Set<N> tails = _edges[node]; | |
| 939 if (tails == null) { | |
| 940 _edges[node] = new Set<N>(); | |
| 941 } | |
| 942 } | |
| 943 | |
| 944 /** | |
| 945 * Return a list of nodes that form a cycle, or `null` if there are no cycles
in this graph. | |
| 946 * | |
| 947 * @return a list of nodes that form a cycle | |
| 948 */ | |
| 949 List<N> findCycle() => null; | |
| 950 | |
| 951 /** | |
| 952 * Return the number of nodes in this graph. | |
| 953 * | |
| 954 * @return the number of nodes in this graph | |
| 955 */ | |
| 956 int get nodeCount => _edges.length; | |
| 957 | |
| 958 /** | |
| 959 * Return a set containing the tails of edges that have the given node as thei
r head. The set will | |
| 960 * be empty if there are no such edges or if the node is not part of the graph
. Clients must not | |
| 961 * modify the returned set. | |
| 962 * | |
| 963 * @param head the node at the head of all of the edges whose tails are to be
returned | |
| 964 * @return a set containing the tails of edges that have the given node as the
ir head | |
| 965 */ | |
| 966 Set<N> getTails(N head) { | |
| 967 Set<N> tails = _edges[head]; | |
| 968 if (tails == null) { | |
| 969 return new Set<N>(); | |
| 970 } | |
| 971 return tails; | |
| 972 } | |
| 973 | |
| 974 /** | |
| 975 * Return `true` if this graph is empty. | |
| 976 * | |
| 977 * @return `true` if this graph is empty | |
| 978 */ | |
| 979 bool get isEmpty => _edges.isEmpty; | |
| 980 | |
| 981 /** | |
| 982 * Remove all of the given nodes from this graph. As a consequence, any edges
for which those | |
| 983 * nodes were either a head or a tail will also be removed. | |
| 984 * | |
| 985 * @param nodes the nodes to be removed | |
| 986 */ | |
| 987 void removeAllNodes(List<N> nodes) { | |
| 988 for (N node in nodes) { | |
| 989 removeNode(node); | |
| 990 } | |
| 991 } | |
| 992 | |
| 993 /** | |
| 994 * Remove the edge from the given head node to the given tail node. If there w
as no such edge then | |
| 995 * the graph will be unmodified: the number of edges will be the same and the
set of nodes will be | |
| 996 * the same (neither node will either be added or removed). | |
| 997 * | |
| 998 * @param head the node at the head of the edge | |
| 999 * @param tail the node at the tail of the edge | |
| 1000 * @return `true` if the graph was modified as a result of this operation | |
| 1001 */ | |
| 1002 void removeEdge(N head, N tail) { | |
| 1003 Set<N> tails = _edges[head]; | |
| 1004 if (tails != null) { | |
| 1005 tails.remove(tail); | |
| 1006 } | |
| 1007 } | |
| 1008 | |
| 1009 /** | |
| 1010 * Remove the given node from this graph. As a consequence, any edges for whic
h that node was | |
| 1011 * either a head or a tail will also be removed. | |
| 1012 * | |
| 1013 * @param node the node to be removed | |
| 1014 */ | |
| 1015 void removeNode(N node) { | |
| 1016 _edges.remove(node); | |
| 1017 for (Set<N> tails in _edges.values) { | |
| 1018 tails.remove(node); | |
| 1019 } | |
| 1020 } | |
| 1021 | |
| 1022 /** | |
| 1023 * Find one node (referred to as a sink node) that has no outgoing edges (that
is, for which there | |
| 1024 * are no edges that have that node as the head of the edge) and remove it fro
m this graph. Return | |
| 1025 * the node that was removed, or `null` if there are no such nodes either beca
use the graph | |
| 1026 * is empty or because every node in the graph has at least one outgoing edge.
As a consequence of | |
| 1027 * removing the node from the graph any edges for which that node was a tail w
ill also be removed. | |
| 1028 * | |
| 1029 * @return the sink node that was removed | |
| 1030 */ | |
| 1031 N removeSink() { | |
| 1032 N sink = _findSink(); | |
| 1033 if (sink == null) { | |
| 1034 return null; | |
| 1035 } | |
| 1036 removeNode(sink); | |
| 1037 return sink; | |
| 1038 } | |
| 1039 | |
| 1040 /** | |
| 1041 * Return one node that has no outgoing edges (that is, for which there are no
edges that have | |
| 1042 * that node as the head of the edge), or `null` if there are no such nodes. | |
| 1043 * | |
| 1044 * @return a sink node | |
| 1045 */ | |
| 1046 N _findSink() { | |
| 1047 for (N key in _edges.keys) { | |
| 1048 if (_edges[key].isEmpty) return key; | |
| 1049 } | |
| 1050 return null; | |
| 1051 } | |
| 1052 } | |
| 1053 | |
| 1054 /** | |
| 1055 * Instances of the class `ErrorResult` represent the result of evaluating an ex
pression that | 892 * Instances of the class `ErrorResult` represent the result of evaluating an ex
pression that |
| 1056 * is not a valid compile time constant. | 893 * is not a valid compile time constant. |
| 1057 */ | 894 */ |
| 1058 class ErrorResult extends EvaluationResultImpl { | 895 class ErrorResult extends EvaluationResultImpl { |
| 1059 /** | 896 /** |
| 1060 * The errors that prevent the expression from being a valid compile time cons
tant. | 897 * The errors that prevent the expression from being a valid compile time cons
tant. |
| 1061 */ | 898 */ |
| 1062 List<ErrorResult_ErrorData> _errors = new List<ErrorResult_ErrorData>(); | 899 List<ErrorResult_ErrorData> _errors = new List<ErrorResult_ErrorData>(); |
| 1063 | 900 |
| 1064 /** | 901 /** |
| (...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4513 | 4350 |
| 4514 @override | 4351 @override |
| 4515 String get typeName => "Type"; | 4352 String get typeName => "Type"; |
| 4516 | 4353 |
| 4517 @override | 4354 @override |
| 4518 int get hashCode => _element == null ? 0 : _element.hashCode; | 4355 int get hashCode => _element == null ? 0 : _element.hashCode; |
| 4519 | 4356 |
| 4520 @override | 4357 @override |
| 4521 String toString() => _element == null ? "-unknown-" : _element.name; | 4358 String toString() => _element == null ? "-unknown-" : _element.name; |
| 4522 } | 4359 } |
| OLD | NEW |