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

Unified Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 294903015: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index ef4fd68d0605e31dd219aa041666f58f3e5c6c14..b5c986d0e83076c7ab53a6fe33caf321d2520a65 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -1722,6 +1722,78 @@ class DartObjectImpl implements DartObject {
}
/**
+ * Instances of the class `DeclaredVariables` provide access to the values of variables that
+ * have been defined on the command line using the `-D` option.
+ */
+class DeclaredVariables {
+ /**
+ * A table mapping the names of declared variables to their values.
+ */
+ Map<String, String> _declaredVariables = new Map<String, String>();
+
+ /**
+ * Define a variable with the given name to have the given value.
+ *
+ * @param variableName the name of the variable being defined
+ * @param value the value of the variable
+ */
+ void define(String variableName, String value) {
+ _declaredVariables[variableName] = value;
+ }
+
+ /**
+ * Return the value of the variable with the given name interpreted as a boolean value, or
+ * `null` if the variable is not defined.
+ *
+ * @param typeProvider the type provider used to find the type 'bool'
+ * @param variableName the name of the variable whose value is to be returned
+ */
+ DartObject getBool(TypeProvider typeProvider, String variableName) {
+ String value = _declaredVariables[variableName];
+ if (value == null) {
+ return null;
+ }
+ if (value == "true") {
+ return new DartObjectImpl(typeProvider.boolType, BoolState.from(true));
+ } else if (value == "false") {
+ return new DartObjectImpl(typeProvider.boolType, BoolState.from(false));
+ }
+ return null;
+ }
+
+ /**
+ * Return the value of the variable with the given name interpreted as an integer value, or
+ * `null` if the variable is not defined.
+ *
+ * @param typeProvider the type provider used to find the type 'int'
+ * @param variableName the name of the variable whose value is to be returned
+ * @throws NumberFormatException if the value of the variable is not a valid integer value
+ */
+ DartObject getInt(TypeProvider typeProvider, String variableName) {
+ String value = _declaredVariables[variableName];
+ if (value == null) {
+ return null;
+ }
+ return new DartObjectImpl(typeProvider.intType, new IntState(int.parse(value)));
+ }
+
+ /**
+ * Return the value of the variable with the given name interpreted as a String value, or
+ * `null` if the variable is not defined.
+ *
+ * @param typeProvider the type provider used to find the type 'String'
+ * @param variableName the name of the variable whose value is to be returned
+ */
+ DartObject getString(TypeProvider typeProvider, String variableName) {
+ String value = _declaredVariables[variableName];
+ if (value == null) {
+ return null;
+ }
+ return new DartObjectImpl(typeProvider.stringType, new StringState(value));
+ }
+}
+
+/**
* Instances of the class `DoubleState` represent the state of an object representing a
* double.
*/
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698