[ddc] Create new result.dart library
This is a step towards organizing the code from shared_command.dart and
eventually deleting it.
- Move `CompilerResult` from shared_command.dart.
Change-Id: Ibe4b8bbd5c6deb2558392255f3818773fa4ea80e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388049
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
diff --git a/pkg/dev_compiler/lib/ddc.dart b/pkg/dev_compiler/lib/ddc.dart
index 87e3b18..e688b31 100755
--- a/pkg/dev_compiler/lib/ddc.dart
+++ b/pkg/dev_compiler/lib/ddc.dart
@@ -16,6 +16,7 @@
import 'package:kernel/ast.dart' show clearDummyTreeNodesParentPointer;
import 'src/command/arguments.dart';
+import 'src/command/result.dart';
import 'src/compiler/shared_command.dart';
import 'src/kernel/command.dart';
import 'src/kernel/expression_compiler_worker.dart';
diff --git a/pkg/dev_compiler/lib/src/command/result.dart b/pkg/dev_compiler/lib/src/command/result.dart
new file mode 100644
index 0000000..8a3e969
--- /dev/null
+++ b/pkg/dev_compiler/lib/src/command/result.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2024, 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.
+
+import 'package:front_end/src/api_unstable/ddc.dart'
+ show InitializedCompilerState;
+
+/// The result of a single `dartdevc` compilation.
+///
+/// Typically used for exiting the process with [exitCode] or checking the
+/// [success] of the compilation.
+///
+/// For batch/worker compilations, the [compilerState] provides an opportunity
+/// to reuse state from the previous run, if the options/input summaries are
+/// equivalent. Otherwise it will be discarded.
+class CompilerResult {
+ /// Optionally provides the front_end state from the previous compilation,
+ /// which can be passed to [compile] to potentially speed up the next
+ /// compilation.
+ final InitializedCompilerState? kernelState;
+
+ /// The process exit code of the compiler.
+ final int exitCode;
+
+ CompilerResult(this.exitCode, {this.kernelState});
+
+ /// Gets the kernel compiler state, if any.
+ Object? get compilerState => kernelState;
+
+ /// Whether the program compiled without any fatal errors (equivalent to
+ /// [exitCode] == 0).
+ bool get success => exitCode == 0;
+
+ /// Whether the compiler crashed (i.e. threw an unhandled exception,
+ /// typically indicating an internal error in DDC itself or its front end).
+ bool get crashed => exitCode == 70;
+}
diff --git a/pkg/dev_compiler/lib/src/compiler/shared_command.dart b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
index de80824..cc6595d 100644
--- a/pkg/dev_compiler/lib/src/compiler/shared_command.dart
+++ b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
@@ -6,8 +6,6 @@
import 'package:front_end/src/api_prototype/macros.dart' as macros
show isMacroLibraryUri;
-import 'package:front_end/src/api_unstable/ddc.dart'
- show InitializedCompilerState;
import 'package:path/path.dart' as p;
// TODO(nshahan) Merge all of this file the locations where they are used in
@@ -121,34 +119,3 @@
map['file'] != null ? makeRelative(map['file'] as String) : null;
return map;
}
-
-/// The result of a single `dartdevc` compilation.
-///
-/// Typically used for exiting the process with [exitCode] or checking the
-/// [success] of the compilation.
-///
-/// For batch/worker compilations, the [compilerState] provides an opportunity
-/// to reuse state from the previous run, if the options/input summaries are
-/// equivalent. Otherwise it will be discarded.
-class CompilerResult {
- /// Optionally provides the front_end state from the previous compilation,
- /// which can be passed to [compile] to potentially speed up the next
- /// compilation.
- final InitializedCompilerState? kernelState;
-
- /// The process exit code of the compiler.
- final int exitCode;
-
- CompilerResult(this.exitCode, {this.kernelState});
-
- /// Gets the kernel compiler state, if any.
- Object? get compilerState => kernelState;
-
- /// Whether the program compiled without any fatal errors (equivalent to
- /// [exitCode] == 0).
- bool get success => exitCode == 0;
-
- /// Whether the compiler crashed (i.e. threw an unhandled exception,
- /// typically indicating an internal error in DDC itself or its front end).
- bool get crashed => exitCode == 70;
-}
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index 39bcc25..8b3b7bb 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -21,6 +21,7 @@
import '../command/arguments.dart';
import '../command/options.dart';
+import '../command/result.dart';
import '../compiler/js_names.dart' as js_ast;
import '../compiler/module_builder.dart';
import '../compiler/shared_command.dart';