OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 /// Properties that result from Strong Mode analysis on an AST. | |
6 /// | |
7 /// These properties are not public, but provided by use of back-ends such as | |
8 /// Dart Dev Compiler. | |
9 | |
10 import 'package:analyzer/analyzer.dart'; | |
11 import 'package:analyzer/dart/element/type.dart'; | |
12 | |
13 const String _implicitCast = '_implicitCast'; | |
14 const String _hasImplicitCasts = '_hasImplicitCasts'; | |
15 const String _isDynamicInvoke = '_isDynamicInvoke'; | |
16 | |
17 /// True if this compilation unit has any implicit casts, otherwise false. | |
18 /// | |
19 /// See also [getImplicitCast]. | |
20 bool hasImplicitCasts(CompilationUnit node) { | |
Jennifer Messerly
2016/06/10 22:59:24
testing out the DDC side, I realized this short-ci
Jennifer Messerly
2016/06/10 23:13:12
FYI -- DDC side is passing now. That CL is here: h
| |
21 return node.getProperty/*<bool>*/(_hasImplicitCasts) ?? false; | |
22 } | |
23 | |
24 /// Sets [hasImplicitCasts] property for this compilation unit. | |
25 void setHasImplicitCasts(CompilationUnit node, bool value) { | |
26 node.setProperty(_hasImplicitCasts, value == true ? true : null); | |
27 } | |
28 | |
29 /// If this expression has an implicit cast, returns the type it is coerced to, | |
30 /// otherwise returns null. | |
31 DartType getImplicitCast(Expression node) { | |
32 return node.getProperty/*<DartType>*/(_implicitCast); | |
33 } | |
34 | |
35 /// Sets the result of [getImplicitCast] for this node. | |
36 void setImplicitCast(Expression node, DartType type) { | |
37 node.setProperty(_implicitCast, type); | |
38 } | |
39 | |
40 /// True if this node is a dynamic operation that requires dispatch and/or | |
41 /// checking at runtime. | |
42 bool isDynamicInvoke(Expression node) { | |
43 return node.getProperty/*<bool>*/(_isDynamicInvoke) ?? false; | |
44 } | |
45 | |
46 /// Sets [isDynamicInvoke] property for this expression | |
47 void setIsDynamicInvoke(Expression node, bool value) { | |
48 node.setProperty(_isDynamicInvoke, value == true ? true : null); | |
49 } | |
OLD | NEW |