Skip to content

Commit 085deb8

Browse files
nshahanCommit Queue
authored andcommitted
[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 <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]> Reviewed-by: Nate Biggs <[email protected]>
1 parent 26ce00d commit 085deb8

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

pkg/dev_compiler/lib/ddc.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:bazel_worker/bazel_worker.dart';
1616
import 'package:kernel/ast.dart' show clearDummyTreeNodesParentPointer;
1717

1818
import 'src/command/arguments.dart';
19+
import 'src/command/result.dart';
1920
import 'src/compiler/shared_command.dart';
2021
import 'src/kernel/command.dart';
2122
import 'src/kernel/expression_compiler_worker.dart';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2024, 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+
import 'package:front_end/src/api_unstable/ddc.dart'
6+
show InitializedCompilerState;
7+
8+
/// The result of a single `dartdevc` compilation.
9+
///
10+
/// Typically used for exiting the process with [exitCode] or checking the
11+
/// [success] of the compilation.
12+
///
13+
/// For batch/worker compilations, the [compilerState] provides an opportunity
14+
/// to reuse state from the previous run, if the options/input summaries are
15+
/// equivalent. Otherwise it will be discarded.
16+
class CompilerResult {
17+
/// Optionally provides the front_end state from the previous compilation,
18+
/// which can be passed to [compile] to potentially speed up the next
19+
/// compilation.
20+
final InitializedCompilerState? kernelState;
21+
22+
/// The process exit code of the compiler.
23+
final int exitCode;
24+
25+
CompilerResult(this.exitCode, {this.kernelState});
26+
27+
/// Gets the kernel compiler state, if any.
28+
Object? get compilerState => kernelState;
29+
30+
/// Whether the program compiled without any fatal errors (equivalent to
31+
/// [exitCode] == 0).
32+
bool get success => exitCode == 0;
33+
34+
/// Whether the compiler crashed (i.e. threw an unhandled exception,
35+
/// typically indicating an internal error in DDC itself or its front end).
36+
bool get crashed => exitCode == 70;
37+
}

pkg/dev_compiler/lib/src/compiler/shared_command.dart

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import 'dart:io';
66

77
import 'package:front_end/src/api_prototype/macros.dart' as macros
88
show isMacroLibraryUri;
9-
import 'package:front_end/src/api_unstable/ddc.dart'
10-
show InitializedCompilerState;
119
import 'package:path/path.dart' as p;
1210

1311
// 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,
121119
map['file'] != null ? makeRelative(map['file'] as String) : null;
122120
return map;
123121
}
124-
125-
/// The result of a single `dartdevc` compilation.
126-
///
127-
/// Typically used for exiting the process with [exitCode] or checking the
128-
/// [success] of the compilation.
129-
///
130-
/// For batch/worker compilations, the [compilerState] provides an opportunity
131-
/// to reuse state from the previous run, if the options/input summaries are
132-
/// equivalent. Otherwise it will be discarded.
133-
class CompilerResult {
134-
/// Optionally provides the front_end state from the previous compilation,
135-
/// which can be passed to [compile] to potentially speed up the next
136-
/// compilation.
137-
final InitializedCompilerState? kernelState;
138-
139-
/// The process exit code of the compiler.
140-
final int exitCode;
141-
142-
CompilerResult(this.exitCode, {this.kernelState});
143-
144-
/// Gets the kernel compiler state, if any.
145-
Object? get compilerState => kernelState;
146-
147-
/// Whether the program compiled without any fatal errors (equivalent to
148-
/// [exitCode] == 0).
149-
bool get success => exitCode == 0;
150-
151-
/// Whether the compiler crashed (i.e. threw an unhandled exception,
152-
/// typically indicating an internal error in DDC itself or its front end).
153-
bool get crashed => exitCode == 70;
154-
}

pkg/dev_compiler/lib/src/kernel/command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'package:source_maps/source_maps.dart' show SourceMapBuilder;
2121

2222
import '../command/arguments.dart';
2323
import '../command/options.dart';
24+
import '../command/result.dart';
2425
import '../compiler/js_names.dart' as js_ast;
2526
import '../compiler/module_builder.dart';
2627
import '../compiler/shared_command.dart';

0 commit comments

Comments
 (0)