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.src.generated.sdk; | 5 library analyzer.src.generated.sdk; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 return sdkMap.values.first; | 117 return sdkMap.values.first; |
118 } | 118 } |
119 | 119 |
120 /** | 120 /** |
121 * Return the Dart SDK that is appropriate for the given analysis [options]. | 121 * Return the Dart SDK that is appropriate for the given analysis [options]. |
122 * If such an SDK has not yet been created, then the [sdkCreator] will be | 122 * If such an SDK has not yet been created, then the [sdkCreator] will be |
123 * invoked to create it. | 123 * invoked to create it. |
124 */ | 124 */ |
125 DartSdk getSdkForOptions(AnalysisOptions options) { | 125 DartSdk getSdkForOptions(AnalysisOptions options) { |
126 int encoding = options.encodeCrossContextOptions(); | 126 int encoding = options.encodeCrossContextOptions(); |
127 DartSdk sdk = sdkMap[encoding]; | 127 return sdkMap.putIfAbsent(encoding, () => sdkCreator(options)); |
Brian Wilkerson
2016/06/01 04:16:51
This is just code clean-up. I'm happy to back it o
pquitslund
2016/06/01 04:28:17
I'm all of keeping it. Yay for opportunistic clea
| |
128 if (sdk == null) { | |
129 sdk = sdkCreator(options); | |
130 sdkMap[encoding] = sdk; | |
131 } | |
132 return sdk; | |
133 } | 128 } |
134 } | 129 } |
135 | 130 |
136 /** | 131 /** |
137 * A map from Dart library URI's to the [SdkLibraryImpl] representing that | 132 * A map from Dart library URI's to the [SdkLibraryImpl] representing that |
138 * library. | 133 * library. |
139 */ | 134 */ |
140 class LibraryMap { | 135 class LibraryMap { |
141 /** | 136 /** |
142 * A table mapping Dart library URI's to the library. | 137 * A table mapping Dart library URI's to the library. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 _platforms |= DART2JS_PLATFORM; | 438 _platforms |= DART2JS_PLATFORM; |
444 } | 439 } |
445 | 440 |
446 /** | 441 /** |
447 * Record that this library can be run on the VM. | 442 * Record that this library can be run on the VM. |
448 */ | 443 */ |
449 void setVmLibrary() { | 444 void setVmLibrary() { |
450 _platforms |= VM_PLATFORM; | 445 _platforms |= VM_PLATFORM; |
451 } | 446 } |
452 } | 447 } |
OLD | NEW |