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

Unified Diff: pkg/front_end/lib/src/fasta/compiler_context.dart

Issue 2704753002: Implement line and column numbers. (Closed)
Patch Set: Undo whitespace change. Created 3 years, 10 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
Index: pkg/front_end/lib/src/fasta/compiler_context.dart
diff --git a/pkg/front_end/lib/src/fasta/compiler_context.dart b/pkg/front_end/lib/src/fasta/compiler_context.dart
new file mode 100644
index 0000000000000000000000000000000000000000..60ddbb8bbd4eb03c8e0df1a43c9e72f1323d5d2c
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/compiler_context.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library fasta.compiler_context;
+
+import 'dart:async' show
+ Zone,
+ runZoned;
+
+import 'package:kernel/ast.dart' show
+ Source;
+
+import 'compiler_command_line.dart' show
+ CompilerCommandLine;
+
+final Object compilerContextKey = new Object();
+
+final CompilerContext rootContext =
+ new CompilerContext(CompilerCommandLine.forRootContext());
+
+class CompilerContext {
+ final CompilerCommandLine options;
+
+ final Map<String, Source> uriToSource = <String, Source>{};
+
+ CompilerContext(this.options);
+
+ static CompilerContext get current {
+ return Zone.current[compilerContextKey] ?? rootContext;
+ }
+
+ static dynamic withGlobalOptions(CompilerCommandLine cl,
+ 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
+ CompilerContext c = new CompilerContext(cl);
+ return runZoned(() => f(c), zoneValues: {compilerContextKey: c});
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698