blob: 5c3ef65802a3e94c6a2389630f128f83f4ef4954 [file] [log] [blame]
#!/usr/bin/env dart
// 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.
import 'dart:io';
import 'package:kernel/error_formatter.dart';
import 'package:kernel/naive_type_checker.dart';
import 'package:kernel/src/tool/command_line_util.dart';
void usage() {
print("Type checker that can be used to find type errors in Kernel files.");
print("Usage: dart <script> dillFile.dill");
print("The given argument should be an existing file");
print("that is valid to load as a dill file.");
void main(List<String> args) {
CommandLineHelper.requireExactlyOneArgument(args, usage,
requireFileExists: true);
final binary = CommandLineHelper.tryLoadDill(args[0]);
ErrorFormatter errorFormatter = new ErrorFormatter();
new NaiveTypeChecker(errorFormatter, binary)..checkComponent(binary);
if (errorFormatter.numberOfFailures > 0) {
print('------- Found ${errorFormatter.numberOfFailures} errors -------');