Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017, 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 library fasta.compiler_context; | |
| 6 | |
| 7 import 'dart:async' show | |
| 8 Zone, | |
| 9 runZoned; | |
| 10 | |
| 11 import 'package:kernel/ast.dart' show | |
| 12 Source; | |
| 13 | |
| 14 import 'compiler_command_line.dart' show | |
| 15 CompilerCommandLine; | |
| 16 | |
| 17 final Object compilerContextKey = new Object(); | |
| 18 | |
| 19 final CompilerContext rootContext = | |
| 20 new CompilerContext(CompilerCommandLine.forRootContext()); | |
| 21 | |
| 22 class CompilerContext { | |
| 23 final CompilerCommandLine options; | |
| 24 | |
| 25 final Map<String, Source> uriToSource = <String, Source>{}; | |
| 26 | |
| 27 CompilerContext(this.options); | |
| 28 | |
| 29 static CompilerContext get current { | |
| 30 return Zone.current[compilerContextKey] ?? rootContext; | |
| 31 } | |
| 32 | |
| 33 static dynamic withGlobalOptions(CompilerCommandLine cl, | |
| 34 dynamic f(CompilerContext c)) { | |
|
karlklose
2017/02/20 08:06:19
Can you come up with a more descriptive name for '
ahe
2017/02/20 08:47:02
I think the problem was lack of documentation, so
| |
| 35 CompilerContext c = new CompilerContext(cl); | |
| 36 return runZoned(() => f(c), zoneValues: {compilerContextKey: c}); | |
| 37 } | |
| 38 } | |
| OLD | NEW |