Files
sdk/pkg/front_end/test/binary_md_git_test.dart
T
Nate Biggs 991f1aa248 [cfe] Add offset serialization to remaining Expression nodes without them.
Expressions missing offsets were:
- LogicalExpression
- ConditionalExpression
- Not
- BlockExpression
- Instantiation
- TypedefTearOff*

* I'm not sure how TypedefTearOff is actually being used, I don't see reference to it in the VM runtime. Unless the CFE lowers it before the VM gets it.

I also added a test on `binary.md` that ensures all expressions include a file offset in their serialized format. This can be expanded to statements if offsets are added to the remaining statement nodes without offsets.

TEST=Added binary_md_git_test.dart to ensure all expressions contain offset data going forward.


Change-Id: Ieaf80545f388b209f76be44db86ef07e80c8ad66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331540
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-10-30 16:05:27 +00:00

43 lines
1.3 KiB
Dart

// Copyright (c) 2023, 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 'dart:io' show File;
import 'binary_md_dill_reader.dart' show BinaryMdDillReader;
import 'utils/io_utils.dart' show computeRepoDir;
Future<void> main() async {
File binaryMd = new File("$repoDir/pkg/kernel/binary.md");
String binaryMdContent = binaryMd.readAsStringSync();
BinaryMdDillReader binaryMdDillReader =
new BinaryMdDillReader(binaryMdContent, const <int>[]);
binaryMdDillReader.setup();
List<String> errors = [];
binaryMdDillReader.readingInstructions.forEach((clazz, fields) {
if (binaryMdDillReader.isA(clazz, "Expression") &&
!binaryMdDillReader.isAbstract(clazz)) {
bool foundOffset = false;
for (String field in fields) {
if (field == 'FileOffset fileOffset;') {
foundOffset = true;
break;
}
}
if (!foundOffset) {
errors.add("$clazz missing required field 'fileOffset'.");
}
}
});
if (errors.isNotEmpty) {
throw Exception(
'Found the following errors with binary.md: ${errors.join('\n')}');
}
}
final String repoDir = computeRepoDir();