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

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/constant.dart

Issue 17249003: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.constant; 3 library engine.constant;
4 import 'java_core.dart'; 4 import 'java_core.dart';
5 import 'source.dart' show Source; 5 import 'source.dart' show Source;
6 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; 6 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode;
7 import 'scanner.dart' show TokenType; 7 import 'scanner.dart' show TokenType;
8 import 'ast.dart'; 8 import 'ast.dart';
9 import 'element.dart'; 9 import 'element.dart';
10 import 'engine.dart' show AnalysisEngine; 10 import 'engine.dart' show AnalysisEngine;
11 /** 11 /**
12 * Instances of the class {@code ConstantEvaluator} evaluate constant expression s to produce their 12 * Instances of the class `ConstantEvaluator` evaluate constant expressions to p roduce their
13 * compile-time value. According to the Dart Language Specification: <blockquote > A constant 13 * compile-time value. According to the Dart Language Specification: <blockquote > A constant
14 * expression is one of the following: 14 * expression is one of the following:
15 * <ul> 15 *
16 * <li>A literal number.</li> 16 * * A literal number.
17 * <li>A literal boolean.</li> 17 * * A literal boolean.
18 * <li>A literal string where any interpolated expression is a compile-time cons tant that evaluates 18 * * A literal string where any interpolated expression is a compile-time consta nt that evaluates
19 * to a numeric, string or boolean value or to {@code null}.</li> 19 * to a numeric, string or boolean value or to `null`.
20 * <li>{@code null}.</li> 20 * * `null`.
21 * <li>A reference to a static constant variable.</li> 21 * * A reference to a static constant variable.
22 * <li>An identifier expression that denotes a constant variable, a class or a t ype variable.</li> 22 * * An identifier expression that denotes a constant variable, a class or a typ e variable.
23 * <li>A constant constructor invocation.</li> 23 * * A constant constructor invocation.
24 * <li>A constant list literal.</li> 24 * * A constant list literal.
25 * <li>A constant map literal.</li> 25 * * A constant map literal.
26 * <li>A simple or qualified identifier denoting a top-level function or a stati c method.</li> 26 * * A simple or qualified identifier denoting a top-level function or a static method.
27 * <li>A parenthesized expression {@code (e)} where {@code e} is a constant expr ession.</li> 27 * * A parenthesized expression `(e)` where `e` is a constant expression.
28 * <li>An expression of one of the forms {@code identical(e1, e2)}, {@code e1 == e2},{@code e1 != e2} where {@code e1} and {@code e2} are constant expressions t hat evaluate to a 28 * * An expression of one of the forms `identical(e1, e2)`, `e1 == e2`,`e1 != e2 ` where `e1` and `e2` are constant expressions that evaluate to a
29 * numeric, string or boolean value or to {@code null}.</li> 29 * numeric, string or boolean value or to `null`.
30 * <li>An expression of one of the forms {@code !e}, {@code e1 && e2} or {@code e1 || e2}, where{@code e}, {@code e1} and {@code e2} are constant expressions th at evaluate to a boolean value or 30 * * An expression of one of the forms `!e`, `e1 && e2` or `e1 || e2`, where`e`, `e1` and `e2` are constant expressions that evaluate to a boolean value or
31 * to {@code null}.</li> 31 * to `null`.
32 * <li>An expression of one of the forms {@code ~e}, {@code e1 ^ e2}, {@code e1 & e2},{@code e1 | e2}, {@code e1 >> e2} or {@code e1 << e2}, where {@code e}, {@ code e1} and {@code e2}are constant expressions that evaluate to an integer valu e or to {@code null}.</li> 32 * * An expression of one of the forms `~e`, `e1 ^ e2`, `e1 & e2`,`e1 | e2`, `e1 >> e2` or `e1 << e2`, where `e`, `e1` and `e2`are constant expressions that eva luate to an integer value or to `null`.
33 * <li>An expression of one of the forms {@code -e}, {@code e1 + e2}, {@code e1 - e2},{@code e1 * e2}, {@code e1 / e2}, {@code e1 ~/ e2}, {@code e1 > e2}, {@cod e e1 < e2},{@code e1 >= e2}, {@code e1 <= e2} or {@code e1 % e2}, where {@code e }, {@code e1} and {@code e2}are constant expressions that evaluate to a numeric value or to {@code null}.</li> 33 * * An expression of one of the forms `-e`, `e1 + e2`, `e1 - e2`,`e1 * e2`, `e1 / e2`, `e1 ~/ e2`, `e1 > e2`, `e1 < e2`,`e1 >= e2`, `e1 <= e2` or `e1 % e2`, wh ere `e`, `e1` and `e2`are constant expressions that evaluate to a numeric value or to `null`.
34 * </ul> 34 *
35 * </blockquote> The values returned by instances of this class are therefore {@ code null} and 35 * </blockquote> The values returned by instances of this class are therefore `n ull` and
36 * instances of the classes {@code Boolean}, {@code BigInteger}, {@code Double}, {@code String}, and{@code DartObject}. 36 * instances of the classes `Boolean`, `BigInteger`, `Double`, `String`, and`Dar tObject`.
37 * <p> 37 *
38 * In addition, this class defines several values that can be returned to indica te various 38 * In addition, this class defines several values that can be returned to indica te various
39 * conditions encountered during evaluation. These are documented with the stati c field that define 39 * conditions encountered during evaluation. These are documented with the stati c field that define
40 * those values. 40 * those values.
41 */ 41 */
42 class ConstantEvaluator { 42 class ConstantEvaluator {
43 43
44 /** 44 /**
45 * The source containing the expression(s) that will be evaluated. 45 * The source containing the expression(s) that will be evaluated.
46 */ 46 */
47 Source _source; 47 Source _source;
(...skipping 12 matching lines...) Expand all
60 } 60 }
61 List<AnalysisError> errors = new List<AnalysisError>(); 61 List<AnalysisError> errors = new List<AnalysisError>();
62 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) { 62 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) {
63 ASTNode node = data.node; 63 ASTNode node = data.node;
64 errors.add(new AnalysisError.con2(_source, node.offset, node.length, data. errorCode, [])); 64 errors.add(new AnalysisError.con2(_source, node.offset, node.length, data. errorCode, []));
65 } 65 }
66 return EvaluationResult.forErrors(new List.from(errors)); 66 return EvaluationResult.forErrors(new List.from(errors));
67 } 67 }
68 } 68 }
69 /** 69 /**
70 * Instances of the class {@code EvaluationResult} represent the result of attem pting to evaluate an 70 * Instances of the class `EvaluationResult` represent the result of attempting to evaluate an
71 * expression. 71 * expression.
72 */ 72 */
73 class EvaluationResult { 73 class EvaluationResult {
74 74
75 /** 75 /**
76 * Return an evaluation result representing the result of evaluating an expres sion that is not a 76 * Return an evaluation result representing the result of evaluating an expres sion that is not a
77 * compile-time constant because of the given errors. 77 * compile-time constant because of the given errors.
78 * @param errors the errors that should be reported for the expression(s) that were evaluated 78 * @param errors the errors that should be reported for the expression(s) that were evaluated
79 * @return the result of evaluating an expression that is not a compile-time c onstant 79 * @return the result of evaluating an expression that is not a compile-time c onstant
80 */ 80 */
(...skipping 12 matching lines...) Expand all
93 */ 93 */
94 Object _value; 94 Object _value;
95 95
96 /** 96 /**
97 * The errors that should be reported for the expression(s) that were evaluate d. 97 * The errors that should be reported for the expression(s) that were evaluate d.
98 */ 98 */
99 List<AnalysisError> _errors; 99 List<AnalysisError> _errors;
100 100
101 /** 101 /**
102 * Initialize a newly created result object with the given state. Clients shou ld use one of the 102 * Initialize a newly created result object with the given state. Clients shou ld use one of the
103 * factory methods: {@link #forErrors(AnalysisError\[\])} and {@link #forValue (Object)}. 103 * factory methods: [forErrors] and [forValue].
104 * @param value the value of the expression 104 * @param value the value of the expression
105 * @param errors the errors that should be reported for the expression(s) that were evaluated 105 * @param errors the errors that should be reported for the expression(s) that were evaluated
106 */ 106 */
107 EvaluationResult(Object value, List<AnalysisError> errors) { 107 EvaluationResult(Object value, List<AnalysisError> errors) {
108 this._value = value; 108 this._value = value;
109 this._errors = errors; 109 this._errors = errors;
110 } 110 }
111 111
112 /** 112 /**
113 * Return an array containing the errors that should be reported for the expre ssion(s) that were 113 * Return an array containing the errors that should be reported for the expre ssion(s) that were
114 * evaluated. If there are no such errors, the array will be empty. The array can be empty even if 114 * evaluated. If there are no such errors, the array will be empty. The array can be empty even if
115 * the expression is not a valid compile time constant if the errors would hav e been reported by 115 * the expression is not a valid compile time constant if the errors would hav e been reported by
116 * other parts of the analysis engine. 116 * other parts of the analysis engine.
117 */ 117 */
118 List<AnalysisError> get errors => _errors == null ? AnalysisError.NO_ERRORS : _errors; 118 List<AnalysisError> get errors => _errors == null ? AnalysisError.NO_ERRORS : _errors;
119 119
120 /** 120 /**
121 * Return the value of the expression, or {@code null} if the expression evalu ated to {@code null}or if the expression could not be evaluated, either because it was not a compile-time constant 121 * Return the value of the expression, or `null` if the expression evaluated t o `null`or if the expression could not be evaluated, either because it was not a compile-time constant
122 * expression or because it would throw an exception when evaluated. 122 * expression or because it would throw an exception when evaluated.
123 * @return the value of the expression 123 * @return the value of the expression
124 */ 124 */
125 Object get value => _value; 125 Object get value => _value;
126 126
127 /** 127 /**
128 * Return {@code true} if the expression is a compile-time constant expression that would not 128 * Return `true` if the expression is a compile-time constant expression that would not
129 * throw an exception when evaluated. 129 * throw an exception when evaluated.
130 * @return {@code true} if the expression is a valid compile-time constant exp ression 130 * @return `true` if the expression is a valid compile-time constant expressio n
131 */ 131 */
132 bool isValid() => _errors == null; 132 bool isValid() => _errors == null;
133 } 133 }
134 /** 134 /**
135 * Instances of the class {@code ConstantFinder} are used to traverse the AST st ructures of all of 135 * Instances of the class `ConstantFinder` are used to traverse the AST structur es of all of
136 * the compilation units being resolved and build a table mapping constant varia ble elements to the 136 * the compilation units being resolved and build a table mapping constant varia ble elements to the
137 * declarations of those variables. 137 * declarations of those variables.
138 */ 138 */
139 class ConstantFinder extends RecursiveASTVisitor<Object> { 139 class ConstantFinder extends RecursiveASTVisitor<Object> {
140 140
141 /** 141 /**
142 * A table mapping constant variable elements to the declarations of those var iables. 142 * A table mapping constant variable elements to the declarations of those var iables.
143 */ 143 */
144 Map<VariableElement, VariableDeclaration> _variableMap = new Map<VariableEleme nt, VariableDeclaration>(); 144 Map<VariableElement, VariableDeclaration> _variableMap = new Map<VariableEleme nt, VariableDeclaration>();
145 145
146 /** 146 /**
147 * Return a table mapping constant variable elements to the declarations of th ose variables. 147 * Return a table mapping constant variable elements to the declarations of th ose variables.
148 * @return a table mapping constant variable elements to the declarations of t hose variables 148 * @return a table mapping constant variable elements to the declarations of t hose variables
149 */ 149 */
150 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap; 150 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap;
151 Object visitVariableDeclaration(VariableDeclaration node) { 151 Object visitVariableDeclaration(VariableDeclaration node) {
152 super.visitVariableDeclaration(node); 152 super.visitVariableDeclaration(node);
153 Expression initializer = node.initializer; 153 Expression initializer = node.initializer;
154 if (initializer != null && node.isConst()) { 154 if (initializer != null && node.isConst()) {
155 VariableElement element = node.element; 155 VariableElement element = node.element;
156 if (element != null) { 156 if (element != null) {
157 _variableMap[element] = node; 157 _variableMap[element] = node;
158 } 158 }
159 } 159 }
160 return null; 160 return null;
161 } 161 }
162 } 162 }
163 /** 163 /**
164 * Instances of the class {@code ConstantValueComputer} compute the values of co nstant variables in 164 * Instances of the class `ConstantValueComputer` compute the values of constant variables in
165 * one or more compilation units. The expected usage pattern is for the compilat ion units to be 165 * one or more compilation units. The expected usage pattern is for the compilat ion units to be
166 * added to this computer using the method {@link #add(CompilationUnit)} and the n for the method{@link #computeValues()} to invoked exactly once. Any use of an instance after invoking the 166 * added to this computer using the method [add] and then for the method[compute Values] to invoked exactly once. Any use of an instance after invoking the
167 * method {@link #computeValues()} will result in unpredictable behavior. 167 * method [computeValues] will result in unpredictable behavior.
168 */ 168 */
169 class ConstantValueComputer { 169 class ConstantValueComputer {
170 170
171 /** 171 /**
172 * The object used to find constant variables in the compilation units that we re added. 172 * The object used to find constant variables in the compilation units that we re added.
173 */ 173 */
174 ConstantFinder _constantFinder = new ConstantFinder(); 174 ConstantFinder _constantFinder = new ConstantFinder();
175 175
176 /** 176 /**
177 * A graph in which the nodes are the constant variables and the edges are fro m each variable to 177 * A graph in which the nodes are the constant variables and the edges are fro m each variable to
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 * Generate an error indicating that the given variable is not a valid compile -time constant 249 * Generate an error indicating that the given variable is not a valid compile -time constant
250 * because it references at least one of the variables in the given cycle, eac h of which directly 250 * because it references at least one of the variables in the given cycle, eac h of which directly
251 * or indirectly references the variable. 251 * or indirectly references the variable.
252 * @param variablesInCycle the variables in the cycle that includes the given variable 252 * @param variablesInCycle the variables in the cycle that includes the given variable
253 * @param variable the variable that is not a valid compile-time constant 253 * @param variable the variable that is not a valid compile-time constant
254 */ 254 */
255 void generateCycleError(List<VariableElement> variablesInCycle, VariableElemen t variable) { 255 void generateCycleError(List<VariableElement> variablesInCycle, VariableElemen t variable) {
256 } 256 }
257 } 257 }
258 /** 258 /**
259 * Instances of the class {@code ConstantVisitor} evaluate constant expressions to produce their 259 * Instances of the class `ConstantVisitor` evaluate constant expressions to pro duce their
260 * compile-time value. According to the Dart Language Specification: <blockquote > A constant 260 * compile-time value. According to the Dart Language Specification: <blockquote > A constant
261 * expression is one of the following: 261 * expression is one of the following:
262 * <ul> 262 *
263 * <li>A literal number.</li> 263 * * A literal number.
264 * <li>A literal boolean.</li> 264 * * A literal boolean.
265 * <li>A literal string where any interpolated expression is a compile-time cons tant that evaluates 265 * * A literal string where any interpolated expression is a compile-time consta nt that evaluates
266 * to a numeric, string or boolean value or to {@code null}.</li> 266 * to a numeric, string or boolean value or to `null`.
267 * <li>{@code null}.</li> 267 * * `null`.
268 * <li>A reference to a static constant variable.</li> 268 * * A reference to a static constant variable.
269 * <li>An identifier expression that denotes a constant variable, a class or a t ype variable.</li> 269 * * An identifier expression that denotes a constant variable, a class or a typ e variable.
270 * <li>A constant constructor invocation.</li> 270 * * A constant constructor invocation.
271 * <li>A constant list literal.</li> 271 * * A constant list literal.
272 * <li>A constant map literal.</li> 272 * * A constant map literal.
273 * <li>A simple or qualified identifier denoting a top-level function or a stati c method.</li> 273 * * A simple or qualified identifier denoting a top-level function or a static method.
274 * <li>A parenthesized expression {@code (e)} where {@code e} is a constant expr ession.</li> 274 * * A parenthesized expression `(e)` where `e` is a constant expression.
275 * <li>An expression of one of the forms {@code identical(e1, e2)}, {@code e1 == e2},{@code e1 != e2} where {@code e1} and {@code e2} are constant expressions t hat evaluate to a 275 * * An expression of one of the forms `identical(e1, e2)`, `e1 == e2`,`e1 != e2 ` where `e1` and `e2` are constant expressions that evaluate to a
276 * numeric, string or boolean value or to {@code null}.</li> 276 * numeric, string or boolean value or to `null`.
277 * <li>An expression of one of the forms {@code !e}, {@code e1 && e2} or {@code e1 || e2}, where{@code e}, {@code e1} and {@code e2} are constant expressions th at evaluate to a boolean value or 277 * * An expression of one of the forms `!e`, `e1 && e2` or `e1 || e2`, where`e`, `e1` and `e2` are constant expressions that evaluate to a boolean value or
278 * to {@code null}.</li> 278 * to `null`.
279 * <li>An expression of one of the forms {@code ~e}, {@code e1 ^ e2}, {@code e1 & e2},{@code e1 | e2}, {@code e1 >> e2} or {@code e1 << e2}, where {@code e}, {@ code e1} and {@code e2}are constant expressions that evaluate to an integer valu e or to {@code null}.</li> 279 * * An expression of one of the forms `~e`, `e1 ^ e2`, `e1 & e2`,`e1 | e2`, `e1 >> e2` or `e1 << e2`, where `e`, `e1` and `e2`are constant expressions that eva luate to an integer value or to `null`.
280 * <li>An expression of one of the forms {@code -e}, {@code e1 + e2}, {@code e1 - e2},{@code e1 * e2}, {@code e1 / e2}, {@code e1 ~/ e2}, {@code e1 > e2}, {@cod e e1 < e2},{@code e1 >= e2}, {@code e1 <= e2} or {@code e1 % e2}, where {@code e }, {@code e1} and {@code e2}are constant expressions that evaluate to a numeric value or to {@code null}.</li> 280 * * An expression of one of the forms `-e`, `e1 + e2`, `e1 - e2`,`e1 * e2`, `e1 / e2`, `e1 ~/ e2`, `e1 > e2`, `e1 < e2`,`e1 >= e2`, `e1 <= e2` or `e1 % e2`, wh ere `e`, `e1` and `e2`are constant expressions that evaluate to a numeric value or to `null`.
281 * </ul> 281 *
282 * </blockquote> 282 * </blockquote>
283 */ 283 */
284 class ConstantVisitor extends GeneralizingASTVisitor<EvaluationResultImpl> { 284 class ConstantVisitor extends GeneralizingASTVisitor<EvaluationResultImpl> {
285 EvaluationResultImpl visitAdjacentStrings(AdjacentStrings node) { 285 EvaluationResultImpl visitAdjacentStrings(AdjacentStrings node) {
286 EvaluationResultImpl result = null; 286 EvaluationResultImpl result = null;
287 for (StringLiteral string in node.strings) { 287 for (StringLiteral string in node.strings) {
288 if (result == null) { 288 if (result == null) {
289 result = string.accept(this); 289 result = string.accept(this);
290 } else { 290 } else {
291 result = result.concatenate(node, string.accept(this)); 291 result = result.concatenate(node, string.accept(this));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } else if (element is ExecutableElement) { 472 } else if (element is ExecutableElement) {
473 return new ValidResult(element); 473 return new ValidResult(element);
474 } else if (element is ClassElement) { 474 } else if (element is ClassElement) {
475 return ValidResult.RESULT_OBJECT; 475 return ValidResult.RESULT_OBJECT;
476 } 476 }
477 return error(node, null); 477 return error(node, null);
478 } 478 }
479 479
480 /** 480 /**
481 * Return the union of the errors encoded in the given results. 481 * Return the union of the errors encoded in the given results.
482 * @param leftResult the first set of errors, or {@code null} if there was no previous collection 482 * @param leftResult the first set of errors, or `null` if there was no previo us collection
483 * of errors 483 * of errors
484 * @param rightResult the errors to be added to the collection, or a valid res ult if there are no 484 * @param rightResult the errors to be added to the collection, or a valid res ult if there are no
485 * errors to be added 485 * errors to be added
486 * @return the union of the errors encoded in the given results 486 * @return the union of the errors encoded in the given results
487 */ 487 */
488 ErrorResult union(ErrorResult leftResult, EvaluationResultImpl rightResult) { 488 ErrorResult union(ErrorResult leftResult, EvaluationResultImpl rightResult) {
489 if (rightResult is ErrorResult) { 489 if (rightResult is ErrorResult) {
490 if (leftResult != null) { 490 if (leftResult != null) {
491 return new ErrorResult.con2(leftResult, (rightResult as ErrorResult)); 491 return new ErrorResult.con2(leftResult, (rightResult as ErrorResult));
492 } else { 492 } else {
493 return rightResult as ErrorResult; 493 return rightResult as ErrorResult;
494 } 494 }
495 } 495 }
496 return leftResult; 496 return leftResult;
497 } 497 }
498 } 498 }
499 /** 499 /**
500 * Instances of the class {@code DirectedGraph} implement a directed graph in wh ich the nodes are 500 * Instances of the class `DirectedGraph` implement a directed graph in which th e nodes are
501 * arbitrary (client provided) objects and edges are represented implicitly. The graph will allow an 501 * arbitrary (client provided) objects and edges are represented implicitly. The graph will allow an
502 * edge from any node to any other node, including itself, but will not represen t multiple edges 502 * edge from any node to any other node, including itself, but will not represen t multiple edges
503 * between the same pair of nodes. 503 * between the same pair of nodes.
504 * @param N the type of the nodes in the graph 504 * @param N the type of the nodes in the graph
505 */ 505 */
506 class DirectedGraph<N> { 506 class DirectedGraph<N> {
507 507
508 /** 508 /**
509 * The table encoding the edges in the graph. An edge is represented by an ent ry mapping the head 509 * The table encoding the edges in the graph. An edge is represented by an ent ry mapping the head
510 * to a set of tails. Nodes that are not the head of any edge are represented by an entry mapping 510 * to a set of tails. Nodes that are not the head of any edge are represented by an entry mapping
(...skipping 25 matching lines...) Expand all
536 * @param node the node to be added 536 * @param node the node to be added
537 */ 537 */
538 void addNode(N node) { 538 void addNode(N node) {
539 Set<N> tails = _edges[node]; 539 Set<N> tails = _edges[node];
540 if (tails == null) { 540 if (tails == null) {
541 _edges[node] = new Set<N>(); 541 _edges[node] = new Set<N>();
542 } 542 }
543 } 543 }
544 544
545 /** 545 /**
546 * Return a list of nodes that form a cycle, or {@code null} if there are no c ycles in this graph. 546 * Return a list of nodes that form a cycle, or `null` if there are no cycles in this graph.
547 * @return a list of nodes that form a cycle 547 * @return a list of nodes that form a cycle
548 */ 548 */
549 List<N> findCycle() => null; 549 List<N> findCycle() => null;
550 550
551 /** 551 /**
552 * Return the number of nodes in this graph. 552 * Return the number of nodes in this graph.
553 * @return the number of nodes in this graph 553 * @return the number of nodes in this graph
554 */ 554 */
555 int get nodeCount => _edges.length; 555 int get nodeCount => _edges.length;
556 556
557 /** 557 /**
558 * Return a set containing the tails of edges that have the given node as thei r head. The set will 558 * Return a set containing the tails of edges that have the given node as thei r head. The set will
559 * be empty if there are no such edges or if the node is not part of the graph . Clients must not 559 * be empty if there are no such edges or if the node is not part of the graph . Clients must not
560 * modify the returned set. 560 * modify the returned set.
561 * @param head the node at the head of all of the edges whose tails are to be returned 561 * @param head the node at the head of all of the edges whose tails are to be returned
562 * @return a set containing the tails of edges that have the given node as the ir head 562 * @return a set containing the tails of edges that have the given node as the ir head
563 */ 563 */
564 Set<N> getTails(N head) { 564 Set<N> getTails(N head) {
565 Set<N> tails = _edges[head]; 565 Set<N> tails = _edges[head];
566 if (tails == null) { 566 if (tails == null) {
567 return new Set<N>(); 567 return new Set<N>();
568 } 568 }
569 return tails; 569 return tails;
570 } 570 }
571 571
572 /** 572 /**
573 * Return {@code true} if this graph is empty. 573 * Return `true` if this graph is empty.
574 * @return {@code true} if this graph is empty 574 * @return `true` if this graph is empty
575 */ 575 */
576 bool isEmpty() => _edges.isEmpty; 576 bool isEmpty() => _edges.isEmpty;
577 577
578 /** 578 /**
579 * Remove all of the given nodes from this graph. As a consequence, any edges for which those 579 * Remove all of the given nodes from this graph. As a consequence, any edges for which those
580 * nodes were either a head or a tail will also be removed. 580 * nodes were either a head or a tail will also be removed.
581 * @param nodes the nodes to be removed 581 * @param nodes the nodes to be removed
582 */ 582 */
583 void removeAllNodes(List<N> nodes) { 583 void removeAllNodes(List<N> nodes) {
584 for (N node in nodes) { 584 for (N node in nodes) {
585 removeNode(node); 585 removeNode(node);
586 } 586 }
587 } 587 }
588 588
589 /** 589 /**
590 * Remove the edge from the given head node to the given tail node. If there w as no such edge then 590 * Remove the edge from the given head node to the given tail node. If there w as no such edge then
591 * the graph will be unmodified: the number of edges will be the same and the set of nodes will be 591 * the graph will be unmodified: the number of edges will be the same and the set of nodes will be
592 * the same (neither node will either be added or removed). 592 * the same (neither node will either be added or removed).
593 * @param head the node at the head of the edge 593 * @param head the node at the head of the edge
594 * @param tail the node at the tail of the edge 594 * @param tail the node at the tail of the edge
595 * @return {@code true} if the graph was modified as a result of this operatio n 595 * @return `true` if the graph was modified as a result of this operation
596 */ 596 */
597 void removeEdge(N head, N tail) { 597 void removeEdge(N head, N tail) {
598 Set<N> tails = _edges[head]; 598 Set<N> tails = _edges[head];
599 if (tails != null) { 599 if (tails != null) {
600 tails.remove(tail); 600 tails.remove(tail);
601 } 601 }
602 } 602 }
603 603
604 /** 604 /**
605 * Remove the given node from this graph. As a consequence, any edges for whic h that node was 605 * Remove the given node from this graph. As a consequence, any edges for whic h that node was
606 * either a head or a tail will also be removed. 606 * either a head or a tail will also be removed.
607 * @param node the node to be removed 607 * @param node the node to be removed
608 */ 608 */
609 void removeNode(N node) { 609 void removeNode(N node) {
610 _edges.remove(node); 610 _edges.remove(node);
611 for (Set<N> tails in _edges.values) { 611 for (Set<N> tails in _edges.values) {
612 tails.remove(node); 612 tails.remove(node);
613 } 613 }
614 } 614 }
615 615
616 /** 616 /**
617 * Find one node (referred to as a sink node) that has no outgoing edges (that is, for which there 617 * Find one node (referred to as a sink node) that has no outgoing edges (that is, for which there
618 * are no edges that have that node as the head of the edge) and remove it fro m this graph. Return 618 * are no edges that have that node as the head of the edge) and remove it fro m this graph. Return
619 * the node that was removed, or {@code null} if there are no such nodes eithe r because the graph 619 * the node that was removed, or `null` if there are no such nodes either beca use the graph
620 * is empty or because every node in the graph has at least one outgoing edge. As a consequence of 620 * is empty or because every node in the graph has at least one outgoing edge. As a consequence of
621 * removing the node from the graph any edges for which that node was a tail w ill also be removed. 621 * removing the node from the graph any edges for which that node was a tail w ill also be removed.
622 * @return the sink node that was removed 622 * @return the sink node that was removed
623 */ 623 */
624 N removeSink() { 624 N removeSink() {
625 N sink = findSink(); 625 N sink = findSink();
626 if (sink == null) { 626 if (sink == null) {
627 return null; 627 return null;
628 } 628 }
629 removeNode(sink); 629 removeNode(sink);
630 return sink; 630 return sink;
631 } 631 }
632 632
633 /** 633 /**
634 * Return one node that has no outgoing edges (that is, for which there are no edges that have 634 * Return one node that has no outgoing edges (that is, for which there are no edges that have
635 * that node as the head of the edge), or {@code null} if there are no such no des. 635 * that node as the head of the edge), or `null` if there are no such nodes.
636 * @return a sink node 636 * @return a sink node
637 */ 637 */
638 N findSink() { 638 N findSink() {
639 for (N key in _edges.keys) { 639 for (N key in _edges.keys) {
640 if (_edges[key].isEmpty) return key; 640 if (_edges[key].isEmpty) return key;
641 } 641 }
642 return null; 642 return null;
643 } 643 }
644 } 644 }
645 /** 645 /**
646 * Instances of the class {@code ErrorResult} represent the result of evaluating an expression that 646 * Instances of the class `ErrorResult` represent the result of evaluating an ex pression that
647 * is not a valid compile time constant. 647 * is not a valid compile time constant.
648 */ 648 */
649 class ErrorResult extends EvaluationResultImpl { 649 class ErrorResult extends EvaluationResultImpl {
650 650
651 /** 651 /**
652 * The errors that prevent the expression from being a valid compile time cons tant. 652 * The errors that prevent the expression from being a valid compile time cons tant.
653 */ 653 */
654 List<ErrorResult_ErrorData> _errors = new List<ErrorResult_ErrorData>(); 654 List<ErrorResult_ErrorData> _errors = new List<ErrorResult_ErrorData>();
655 655
656 /** 656 /**
(...skipping 23 matching lines...) Expand all
680 _errors.addAll(secondResult._errors); 680 _errors.addAll(secondResult._errors);
681 } 681 }
682 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper and) => rightOperand.addToError(node, this); 682 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper and) => rightOperand.addToError(node, this);
683 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.bitAndError(node, this); 683 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.bitAndError(node, this);
684 EvaluationResultImpl bitNot(Expression node) => this; 684 EvaluationResultImpl bitNot(Expression node) => this;
685 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp erand) => rightOperand.bitOrError(node, this); 685 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp erand) => rightOperand.bitOrError(node, this);
686 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.bitXorError(node, this); 686 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.bitXorError(node, this);
687 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp erand) => rightOperand.concatenateError(node, this); 687 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp erand) => rightOperand.concatenateError(node, this);
688 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.divideError(node, this); 688 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.divideError(node, this);
689 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe rand) => rightOperand.equalEqualError(node, this); 689 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe rand) => rightOperand.equalEqualError(node, this);
690 bool equalValues(EvaluationResultImpl result) => false;
690 List<ErrorResult_ErrorData> get errorData => _errors; 691 List<ErrorResult_ErrorData> get errorData => _errors;
691 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r ightOperand) => rightOperand.greaterThanError(node, this); 692 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r ightOperand) => rightOperand.greaterThanError(node, this);
692 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul tImpl rightOperand) => rightOperand.greaterThanOrEqualError(node, this); 693 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul tImpl rightOperand) => rightOperand.greaterThanOrEqualError(node, this);
693 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideError(node, this); 694 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideError(node, this);
694 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef tOperand) => this; 695 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef tOperand) => this;
695 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ tOperand) => rightOperand.lessThanError(node, this); 696 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ tOperand) => rightOperand.lessThanError(node, this);
696 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm pl rightOperand) => rightOperand.lessThanOrEqualError(node, this); 697 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm pl rightOperand) => rightOperand.lessThanOrEqualError(node, this);
697 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri ghtOperand) => rightOperand.logicalAndError(node, this); 698 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri ghtOperand) => rightOperand.logicalAndError(node, this);
698 EvaluationResultImpl logicalNot(Expression node) => this; 699 EvaluationResultImpl logicalNot(Expression node) => this;
699 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig htOperand) => rightOperand.logicalOrError(node, this); 700 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig htOperand) => rightOperand.logicalOrError(node, this);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 */ 775 */
775 ErrorCode get errorCode => _errorCode; 776 ErrorCode get errorCode => _errorCode;
776 777
777 /** 778 /**
778 * Return the node against which the error should be reported. 779 * Return the node against which the error should be reported.
779 * @return the node against which the error should be reported 780 * @return the node against which the error should be reported
780 */ 781 */
781 ASTNode get node => _node; 782 ASTNode get node => _node;
782 } 783 }
783 /** 784 /**
784 * Instances of the class {@code InternalResult} represent the result of attempt ing to evaluate a 785 * Instances of the class `InternalResult` represent the result of attempting to evaluate a
785 * expression. 786 * expression.
786 */ 787 */
787 abstract class EvaluationResultImpl { 788 abstract class EvaluationResultImpl {
788 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper and); 789 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper and);
789 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO perand); 790 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO perand);
790 EvaluationResultImpl bitNot(Expression node); 791 EvaluationResultImpl bitNot(Expression node);
791 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp erand); 792 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp erand);
792 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO perand); 793 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO perand);
793 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp erand); 794 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp erand);
794 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO perand); 795 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO perand);
795 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe rand); 796 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe rand);
797 bool equalValues(EvaluationResultImpl result);
796 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r ightOperand); 798 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r ightOperand);
797 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul tImpl rightOperand); 799 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul tImpl rightOperand);
798 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl rightOperand); 800 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl rightOperand);
799 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ tOperand); 801 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ tOperand);
800 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm pl rightOperand); 802 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm pl rightOperand);
801 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri ghtOperand); 803 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri ghtOperand);
802 EvaluationResultImpl logicalNot(Expression node); 804 EvaluationResultImpl logicalNot(Expression node);
803 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig htOperand); 805 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig htOperand);
804 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp erand); 806 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp erand);
805 EvaluationResultImpl negated(Expression node); 807 EvaluationResultImpl negated(Expression node);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe rand); 846 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe rand);
845 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe rand); 847 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe rand);
846 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe rand); 848 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe rand);
847 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe rand); 849 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe rand);
848 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp erand); 850 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp erand);
849 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp erand); 851 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp erand);
850 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand ); 852 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand );
851 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand ); 853 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand );
852 } 854 }
853 /** 855 /**
854 * Instances of the class {@code ReferenceFinder} add reference information for a given variable to 856 * Instances of the class `ReferenceFinder` add reference information for a give n variable to
855 * the bi-directional mapping used to order the evaluation of constants. 857 * the bi-directional mapping used to order the evaluation of constants.
856 */ 858 */
857 class ReferenceFinder extends RecursiveASTVisitor<Object> { 859 class ReferenceFinder extends RecursiveASTVisitor<Object> {
858 860
859 /** 861 /**
860 * The element representing the variable whose initializer will be visited. 862 * The element representing the variable whose initializer will be visited.
861 */ 863 */
862 VariableElement _source; 864 VariableElement _source;
863 865
864 /** 866 /**
(...skipping 21 matching lines...) Expand all
886 if (element is VariableElement) { 888 if (element is VariableElement) {
887 VariableElement variable = element as VariableElement; 889 VariableElement variable = element as VariableElement;
888 if (variable.isConst()) { 890 if (variable.isConst()) {
889 _referenceGraph.addEdge(_source, variable); 891 _referenceGraph.addEdge(_source, variable);
890 } 892 }
891 } 893 }
892 return null; 894 return null;
893 } 895 }
894 } 896 }
895 /** 897 /**
896 * Instances of the class {@code ValidResult} represent the result of attempting to evaluate a valid 898 * Instances of the class `ValidResult` represent the result of attempting to ev aluate a valid
897 * compile time constant expression. 899 * compile time constant expression.
898 */ 900 */
899 class ValidResult extends EvaluationResultImpl { 901 class ValidResult extends EvaluationResultImpl {
900 902
901 /** 903 /**
902 * A result object representing the value 'false'. 904 * A result object representing the value 'false'.
903 */ 905 */
904 static ValidResult RESULT_FALSE = new ValidResult(false); 906 static ValidResult RESULT_FALSE = new ValidResult(false);
905 907
906 /** 908 /**
907 * A result object representing the an object without specific type on which n o further operations 909 * A result object representing the an object without specific type on which n o further operations
908 * can be performed. 910 * can be performed.
909 */ 911 */
910 static ValidResult RESULT_DYNAMIC = new ValidResult(null); 912 static ValidResult RESULT_DYNAMIC = new ValidResult(null);
911 913
912 /** 914 /**
913 * A result object representing the an arbitrary integer on which no further o perations can be 915 * A result object representing the an arbitrary integer on which no further o perations can be
914 * performed. 916 * performed.
915 */ 917 */
916 static ValidResult RESULT_INT = new ValidResult(null); 918 static ValidResult RESULT_INT = new ValidResult(null);
917 919
918 /** 920 /**
919 * A result object representing the {@code null} value. 921 * A result object representing the `null` value.
920 */ 922 */
921 static ValidResult RESULT_NULL = new ValidResult(null); 923 static ValidResult RESULT_NULL = new ValidResult(null);
922 924
923 /** 925 /**
924 * A result object representing the an arbitrary numeric on which no further o perations can be 926 * A result object representing the an arbitrary numeric on which no further o perations can be
925 * performed. 927 * performed.
926 */ 928 */
927 static ValidResult RESULT_NUM = new ValidResult(null); 929 static ValidResult RESULT_NUM = new ValidResult(null);
928 930
929 /** 931 /**
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 } else if (_value is int) { 974 } else if (_value is int) {
973 return valueOf(~((_value as int))); 975 return valueOf(~((_value as int)));
974 } 976 }
975 return error(node); 977 return error(node);
976 } 978 }
977 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp erand) => rightOperand.bitOrValid(node, this); 979 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp erand) => rightOperand.bitOrValid(node, this);
978 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.bitXorValid(node, this); 980 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.bitXorValid(node, this);
979 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp erand) => rightOperand.concatenateValid(node, this); 981 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp erand) => rightOperand.concatenateValid(node, this);
980 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.divideValid(node, this); 982 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO perand) => rightOperand.divideValid(node, this);
981 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe rand) => rightOperand.equalEqualValid(node, this); 983 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe rand) => rightOperand.equalEqualValid(node, this);
984 bool equalValues(EvaluationResultImpl result) => identical(equalEqual(null, re sult), RESULT_TRUE);
982 Object get value => _value; 985 Object get value => _value;
983 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r ightOperand) => rightOperand.greaterThanValid(node, this); 986 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r ightOperand) => rightOperand.greaterThanValid(node, this);
984 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul tImpl rightOperand) => rightOperand.greaterThanOrEqualValid(node, this); 987 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul tImpl rightOperand) => rightOperand.greaterThanOrEqualValid(node, this);
985 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideValid(node, this); 988 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideValid(node, this);
986 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ tOperand) => rightOperand.lessThanValid(node, this); 989 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ tOperand) => rightOperand.lessThanValid(node, this);
987 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm pl rightOperand) => rightOperand.lessThanOrEqualValid(node, this); 990 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm pl rightOperand) => rightOperand.lessThanOrEqualValid(node, this);
988 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri ghtOperand) => rightOperand.logicalAndValid(node, this); 991 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri ghtOperand) => rightOperand.logicalAndValid(node, this);
989 EvaluationResultImpl logicalNot(Expression node) { 992 EvaluationResultImpl logicalNot(Expression node) {
990 if (isSomeBool()) { 993 if (isSomeBool()) {
991 return RESULT_BOOL; 994 return RESULT_BOOL;
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 * Checks if this result has type "bool", with known or unknown value. 1599 * Checks if this result has type "bool", with known or unknown value.
1597 */ 1600 */
1598 bool isAnyBool() => isSomeBool() || identical(this, RESULT_TRUE) || identical( this, RESULT_FALSE); 1601 bool isAnyBool() => isSomeBool() || identical(this, RESULT_TRUE) || identical( this, RESULT_FALSE);
1599 1602
1600 /** 1603 /**
1601 * Checks if this result has type "int", with known or unknown value. 1604 * Checks if this result has type "int", with known or unknown value.
1602 */ 1605 */
1603 bool isAnyInt() => identical(this, RESULT_INT) || _value is int; 1606 bool isAnyInt() => identical(this, RESULT_INT) || _value is int;
1604 1607
1605 /** 1608 /**
1606 * Checks if this result has one of the types - "bool", "num" or "string"; or may be {@code null}. 1609 * Checks if this result has one of the types - "bool", "num" or "string"; or may be `null`.
1607 */ 1610 */
1608 bool isAnyNullBoolNumString() => isNull() || isAnyBool() || isAnyNum() || _val ue is String; 1611 bool isAnyNullBoolNumString() => isNull() || isAnyBool() || isAnyNum() || _val ue is String;
1609 1612
1610 /** 1613 /**
1611 * Checks if this result has type "num", with known or unknown value. 1614 * Checks if this result has type "num", with known or unknown value.
1612 */ 1615 */
1613 bool isAnyNum() => isSomeNum() || _value is num; 1616 bool isAnyNum() => isSomeNum() || _value is num;
1614 1617
1615 /** 1618 /**
1616 * Checks if this result has type "bool", exact value of which we don't know. 1619 * Checks if this result has type "bool", exact value of which we don't know.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 */ 1660 */
1658 ValidResult valueOf3(double value) => new ValidResult(value); 1661 ValidResult valueOf3(double value) => new ValidResult(value);
1659 1662
1660 /** 1663 /**
1661 * Return a result object representing the given value. 1664 * Return a result object representing the given value.
1662 * @param value the value to be represented as a result object 1665 * @param value the value to be represented as a result object
1663 * @return a result object representing the given value 1666 * @return a result object representing the given value
1664 */ 1667 */
1665 ValidResult valueOf4(String value) => new ValidResult(value); 1668 ValidResult valueOf4(String value) => new ValidResult(value);
1666 } 1669 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/ast.dart ('k') | pkg/analyzer_experimental/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698