| 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 library analyzer.context.declared_variables; | 5 library analyzer.context.declared_variables; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/constant/value.dart'; | 9 import 'package:analyzer/dart/constant/value.dart'; |
| 10 import 'package:analyzer/src/dart/constant/value.dart'; | 10 import 'package:analyzer/src/dart/constant/value.dart'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A table mapping the names of declared variables to their values. | 21 * A table mapping the names of declared variables to their values. |
| 22 */ | 22 */ |
| 23 HashMap<String, String> _declaredVariables = new HashMap<String, String>(); | 23 HashMap<String, String> _declaredVariables = new HashMap<String, String>(); |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Return the names of the variables for which a value has been defined. | 26 * Return the names of the variables for which a value has been defined. |
| 27 */ | 27 */ |
| 28 Iterable<String> get variableNames => _declaredVariables.keys; | 28 Iterable<String> get variableNames => _declaredVariables.keys; |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Add all variables of [other] to this object. |
| 32 */ |
| 33 void addAll(DeclaredVariables other) { |
| 34 _declaredVariables.addAll(other._declaredVariables); |
| 35 } |
| 36 |
| 37 /** |
| 31 * Define a variable with the given [name] to have the given [value]. | 38 * Define a variable with the given [name] to have the given [value]. |
| 32 */ | 39 */ |
| 33 void define(String name, String value) { | 40 void define(String name, String value) { |
| 34 _declaredVariables[name] = value; | 41 _declaredVariables[name] = value; |
| 35 } | 42 } |
| 36 | 43 |
| 37 /** | 44 /** |
| 38 * Return the raw string value of the variable with the given [name], | 45 * Return the raw string value of the variable with the given [name], |
| 39 * or `null` of the variable is not defined. | 46 * or `null` of the variable is not defined. |
| 40 */ | 47 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 */ | 97 */ |
| 91 DartObject getString(TypeProvider typeProvider, String name) { | 98 DartObject getString(TypeProvider typeProvider, String name) { |
| 92 String value = _declaredVariables[name]; | 99 String value = _declaredVariables[name]; |
| 93 if (value == null) { | 100 if (value == null) { |
| 94 return new DartObjectImpl( | 101 return new DartObjectImpl( |
| 95 typeProvider.stringType, StringState.UNKNOWN_VALUE); | 102 typeProvider.stringType, StringState.UNKNOWN_VALUE); |
| 96 } | 103 } |
| 97 return new DartObjectImpl(typeProvider.stringType, new StringState(value)); | 104 return new DartObjectImpl(typeProvider.stringType, new StringState(value)); |
| 98 } | 105 } |
| 99 } | 106 } |
| OLD | NEW |