[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>
This commit is contained in:
committed by
Commit Queue
parent
26ce00d68c
commit
085deb8bc4
@@ -16,6 +16,7 @@ import 'package:bazel_worker/bazel_worker.dart';
|
||||
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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import 'dart:io';
|
||||
|
||||
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<String, Object?> placeSourceMap(Map<String, Object?> sourceMap,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import 'package:source_maps/source_maps.dart' show SourceMapBuilder;
|
||||
|
||||
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';
|
||||
|
||||
Reference in New Issue
Block a user