Skip to content

Commit

Permalink
fix #620, infer the input files from sources
Browse files Browse the repository at this point in the history
also simplifies build of packages used by our tests
this caused a bunch of tests that use parts to start passing

R=nweiz@google.com

Review URL: https://codereview.chromium.org/2234343003 .
  • Loading branch information
John Messerly committed Aug 11, 2016
1 parent 3d43b1d commit 0aa5cbd
Show file tree
Hide file tree
Showing 40 changed files with 1,301 additions and 8,827 deletions.
8 changes: 1 addition & 7 deletions pkg/dev_compiler/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ module.exports = function(config) {
files: [
'lib/runtime/dart_*.js',
// {pattern: 'test/browser/*.js', included: false}
'gen/codegen_output/async_helper/async_helper.js',
'gen/codegen_output/expect/expect.js',
'gen/codegen_output/path/path.js',
'gen/codegen_output/stack_trace/stack_trace.js',
'gen/codegen_output/js/js.js',
'gen/codegen_output/matcher/matcher.js',
'gen/codegen_output/unittest/unittest.js',
'gen/codegen_output/pkg/*.js',
'gen/codegen_output/language/**.js',
'gen/codegen_output/language/**.err',
'gen/codegen_output/corelib/**.js',
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/compiler/code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class CodeGenerator extends GeneralizingAstVisitor
items.add(new JS.ExportDeclaration(
js.call('const # = Object.create(null)', [libraryTemp])));

// dart:_runtime has a magic module that holds extenstion method symbols.
// dart:_runtime has a magic module that holds extension method symbols.
// TODO(jmesserly): find a cleaner design for this.
if (_isDartRuntime(library)) {
items.add(new JS.ExportDeclaration(
Expand Down
64 changes: 28 additions & 36 deletions pkg/dev_compiler/lib/src/compiler/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
// 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:collection' show HashSet;
import 'package:args/args.dart' show ArgParser, ArgResults;
import 'package:args/src/usage_exception.dart' show UsageException;
import 'dart:collection' show HashSet, Queue;
import 'package:analyzer/dart/element/element.dart' show LibraryElement;
import 'package:analyzer/analyzer.dart'
show
AnalysisError,
CompilationUnit,
CompileTimeErrorCode,
ErrorSeverity,
StaticWarningCode;
show AnalysisError, CompilationUnit, ErrorSeverity;
import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
import 'package:analyzer/src/generated/source.dart' show DartUriResolver;
import 'package:analyzer/src/generated/source_io.dart'
show Source, SourceKind, UriResolver;
import 'package:analyzer/src/summary/package_bundle_reader.dart'
show InSummarySource;
import 'package:args/args.dart' show ArgParser, ArgResults;
import 'package:args/src/usage_exception.dart' show UsageException;
import 'package:func/func.dart' show Func1;
import 'package:path/path.dart' as path;

Expand Down Expand Up @@ -76,14 +74,15 @@ class ModuleCompiler {
var trees = <CompilationUnit>[];
var errors = <AnalysisError>[];

// Validate that all parts were explicitly passed in.
// If not, it's an error.
var explicitParts = new HashSet<Source>();
var usedParts = new HashSet<Source>();
var librariesToCompile = new Queue<LibraryElement>();

var compilingSdk = false;
for (var sourcePath in unit.sources) {
var sourceUri = Uri.parse(sourcePath);
if (sourceUri.scheme == '') {
sourceUri = path.toUri(path.absolute(sourcePath));
} else if (sourceUri.scheme == 'dart') {
compilingSdk = true;
}
Source source = context.sourceFactory.forUri2(sourceUri);

Expand All @@ -101,31 +100,32 @@ class ModuleCompiler {

// Ignore parts. They need to be handled in the context of their library.
if (context.computeKindOf(source) == SourceKind.PART) {
explicitParts.add(source);
continue;
}

var resolvedTree = context.resolveCompilationUnit2(source, source);
trees.add(resolvedTree);
errors.addAll(context.computeErrors(source));
librariesToCompile.add(context.computeLibraryElement(source));
}

var libraries = new HashSet<LibraryElement>();
while (librariesToCompile.isNotEmpty) {
var library = librariesToCompile.removeFirst();
if (library.source is InSummarySource) continue;
if (!compilingSdk && library.source.isInSystemLibrary) continue;
if (!libraries.add(library)) continue;

librariesToCompile.addAll(library.importedLibraries);
librariesToCompile.addAll(library.exportedLibraries);

var tree = context.resolveCompilationUnit(library.source, library);
trees.add(tree);
errors.addAll(context.computeErrors(library.source));

var library = resolvedTree.element.library;
for (var part in library.parts) {
if (!library.isInSdk) usedParts.add(part.source);
trees.add(context.resolveCompilationUnit(part.source, library));
errors.addAll(context.computeErrors(part.source));
}
}

// Check if all parts were explicitly passed in.
// Also verify all explicitly parts were used.
var missingParts = usedParts.difference(explicitParts);
var unusedParts = explicitParts.difference(usedParts);
errors.addAll(missingParts
.map((s) => new AnalysisError(s, 0, 0, missingPartErrorCode)));
errors.addAll(unusedParts
.map((s) => new AnalysisError(s, 0, 0, unusedPartWarningCode)));

sortErrors(context, errors);
var messages = <String>[];
for (var e in errors) {
Expand Down Expand Up @@ -365,11 +365,3 @@ class JSModuleFile {
return map;
}
}

/// (Public for tests) the error code used when a part is missing.
final missingPartErrorCode = const CompileTimeErrorCode(
'MISSING_PART', 'The part was not supplied as an input to the compiler.');

/// (Public for tests) the error code used when a part is unused.
final unusedPartWarningCode = const StaticWarningCode('UNUSED_PART',
'The part was not used by any libraries being compiled.', null, false);
3 changes: 2 additions & 1 deletion pkg/dev_compiler/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,5 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.10"
sdk: ">=1.17.0-dev.6.2 <2.0.0"
sdks:
dart: ">=1.17.0-dev.6.2 <2.0.0"
20 changes: 2 additions & 18 deletions pkg/dev_compiler/test/browser/language_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
'generic_field_mixin4_test': skip_fail,
'generic_field_mixin5_test': skip_fail,
'generic_field_mixin_test': skip_fail,
'generic_instanceof_test': fail, // runtime strong mode reject
'generic_instanceof2_test': skip_fail,
'generic_is_check_test': skip_fail,
'getter_closure_execution_order_test': skip_fail,
Expand Down Expand Up @@ -338,7 +339,6 @@
'abstract_runtime_error_test_03_multi': notyetstrong,
'abstract_syntax_test_00_multi': notyetstrong,
'abstract_syntax_test_01_multi': notyetstrong,
'application_test': notyetstrong,
'argument_definition_test_01_multi': notyetstrong,
'arithmetic_test': notyetstrong,
'assign_static_type_test_01_multi': notyetstrong,
Expand Down Expand Up @@ -937,9 +937,6 @@
'enum_syntax_test_30_multi': notyetstrong,
'error_stacktrace_test': notyetstrong,
'example_constructor_test': notyetstrong,
'export_double_same_main_test': notyetstrong,
'export_main_override_test': notyetstrong,
'export_main_test': notyetstrong,
'external_test_01_multi': notyetstrong,
'external_test_02_multi': notyetstrong,
'external_test_11_multi': notyetstrong,
Expand Down Expand Up @@ -1118,7 +1115,6 @@
'generic_constructor_mixin_test': notyetstrong,
'generic_field_mixin6_test_01_multi': notyetstrong,
'generic_field_mixin6_test_none_multi': notyetstrong,
'generic_instanceof_test': notyetstrong,
'generic_list_checked_test': notyetstrong,
'generic_test': notyetstrong,
'generics_test': notyetstrong,
Expand Down Expand Up @@ -1157,7 +1153,6 @@
'getter_setter_in_lib_test': notyetstrong,
'getters_setters2_test_02_multi': notyetstrong,
'getters_setters2_test_03_multi': notyetstrong,
'hello_script_test': notyetstrong,
'hidden_import_test_01_multi': notyetstrong,
'hidden_import_test_02_multi': notyetstrong,
'identical_const_test_01_multi': notyetstrong,
Expand Down Expand Up @@ -1239,7 +1234,6 @@
'inferrer_this_access_test': notyetstrong,
'inline_effect_context_test': notyetstrong,
'inline_in_for_initializer_and_bailout_test': notyetstrong,
'inline_super_test': notyetstrong,
'inline_test_context_test': notyetstrong,
'inline_value_context_test': notyetstrong,
'inlined_throw_test': notyetstrong,
Expand Down Expand Up @@ -1281,7 +1275,6 @@
'keyword_type_expression_test_02_multi': notyetstrong,
'keyword_type_expression_test_03_multi': notyetstrong,
'label_test': notyetstrong,
'lazy_static6_test': notyetstrong,
'least_upper_bound_expansive_test_01_multi': notyetstrong,
'least_upper_bound_expansive_test_02_multi': notyetstrong,
'least_upper_bound_expansive_test_03_multi': notyetstrong,
Expand All @@ -1305,15 +1298,12 @@
'least_upper_bound_test_29_multi': notyetstrong,
'least_upper_bound_test_30_multi': notyetstrong,
'least_upper_bound_test_32_multi': notyetstrong,
'library1_test': notyetstrong,
'library_ambiguous_test_00_multi': notyetstrong,
'library_ambiguous_test_01_multi': notyetstrong,
'library_ambiguous_test_02_multi': notyetstrong,
'library_ambiguous_test_03_multi': notyetstrong,
'library_ambiguous_test_04_multi': notyetstrong,
'library_ambiguous_test_05_multi': notyetstrong,
'library_juxtaposition_test': notyetstrong,
'library_prefixes_test': notyetstrong,
'list_double_index_in_loop2_test': notyetstrong,
'list_double_index_in_loop_test': notyetstrong,
'list_literal1_test_01_multi': notyetstrong,
Expand Down Expand Up @@ -1565,8 +1555,6 @@
'mixin_type_parameters_super_extends_test': notyetstrong,
'mixin_type_parameters_super_test': notyetstrong,
'mixin_with_two_implicit_constructors_test': notyetstrong,
'multi_pass2_test': notyetstrong,
'multi_pass_test': notyetstrong,
'multiline_newline_test_01_multi': notyetstrong,
'multiline_newline_test_02_multi': notyetstrong,
'multiline_newline_test_03_multi': notyetstrong,
Expand Down Expand Up @@ -1754,7 +1742,6 @@
'parameter_initializer_test': notyetstrong,
'parser_quirks_test': notyetstrong,
'part2_test': notyetstrong,
'part_test': notyetstrong,
'positional_parameters_type_test_01_multi': notyetstrong,
'positional_parameters_type_test_02_multi': notyetstrong,
'prefix14_test': notyetstrong,
Expand All @@ -1771,7 +1758,6 @@
'prefix_identifier_reference_test_05_multi': notyetstrong,
'prefix_unqualified_invocation_test_01_multi': notyetstrong,
'prefix_unqualified_invocation_test_02_multi': notyetstrong,
'private2_test': notyetstrong,
'private3_test': notyetstrong,
'private_access_test_01_multi': notyetstrong,
'private_access_test_02_multi': notyetstrong,
Expand Down Expand Up @@ -2051,10 +2037,8 @@
'this_test_07_multi': notyetstrong,
'this_test_08_multi': notyetstrong,
'throw_expr_test': notyetstrong,
'top_level_entry_test': notyetstrong,
'top_level_getter_no_setter1_test_01_multi': notyetstrong,
'top_level_getter_no_setter2_test_01_multi': notyetstrong,
'top_level_multiple_files_test': notyetstrong,
'toplevel_collision1_test_00_multi': notyetstrong,
'toplevel_collision1_test_01_multi': notyetstrong,
'toplevel_collision1_test_02_multi': notyetstrong,
Expand Down Expand Up @@ -2496,7 +2480,7 @@
'package_resource_test': notyetstrong,
'print_test_01_multi': notyetstrong,
'print_test_none_multi': notyetstrong,
'set_test': notyetstrong,
'set_test': fail, // runtime strong mode reject
'splay_tree_test': notyetstrong,
'string_base_vm_test': notyetstrong,
'string_from_environment3_test_01_multi': notyetstrong,
Expand Down

This file was deleted.

15 changes: 15 additions & 0 deletions pkg/dev_compiler/test/codegen_expected/destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ dart_library.library('destructuring', null, /* Imports */[
const dart = dart_sdk.dart;
const dartx = dart_sdk.dartx;
const destructuring = Object.create(null);
const src__varargs = Object.create(null);
let intAnddynamic__Todynamic = () => (intAnddynamic__Todynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic], [dart.dynamic])))();
let intAnddynamic__Todynamic$ = () => (intAnddynamic__Todynamic$ = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic], {c: dart.dynamic})))();
let intAnddynamicTodynamic = () => (intAnddynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic])))();
let intAnddynamicAnddynamicTodynamic = () => (intAnddynamicAnddynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic, dart.dynamic])))();
let __Todynamic = () => (__Todynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [], [core.int, dart.dynamic, dart.dynamic])))();
let __Todynamic$ = () => (__Todynamic$ = dart.constFn(dart.definiteFunctionType(dart.dynamic, [], {let: core.int, function: dart.dynamic, arguments: dart.dynamic})))();
let __Todynamic$0 = () => (__Todynamic$0 = dart.constFn(dart.definiteFunctionType(dart.dynamic, [], {constructor: core.int, valueOf: dart.dynamic, hasOwnProperty: dart.dynamic})))();
let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic])))();
destructuring.f = function(a, b, c = 1) {
destructuring.f(a, b, c);
};
Expand Down Expand Up @@ -71,6 +73,19 @@ dart_library.library('destructuring', null, /* Imports */[
destructuring.f(constructor, valueOf, hasOwnProperty);
};
dart.fn(destructuring.names_clashing_with_object_props, __Todynamic$0());
src__varargs._Rest = class _Rest extends core.Object {
new() {
}
};
dart.setSignature(src__varargs._Rest, {
constructors: () => ({new: dart.definiteFunctionType(src__varargs._Rest, [])})
});
src__varargs.rest = dart.const(new src__varargs._Rest());
src__varargs.spread = function(args) {
dart.throw(new core.StateError('The spread function cannot be called, ' + 'it should be compiled away.'));
};
dart.fn(src__varargs.spread, dynamicTodynamic());
// Exports:
exports.destructuring = destructuring;
exports.src__varargs = src__varargs;
});
Loading

0 comments on commit 0aa5cbd

Please sign in to comment.