Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2836483002: Snapshot DDC trained on itself (Closed)
Patch Set: Test/fix for windows Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 15 matching lines...) Expand all
26 import 'package:analyzer/src/summary/idl.dart' show UnlinkedUnit; 26 import 'package:analyzer/src/summary/idl.dart' show UnlinkedUnit;
27 import 'package:analyzer/src/summary/link.dart' as summary_link; 27 import 'package:analyzer/src/summary/link.dart' as summary_link;
28 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 28 import 'package:analyzer/src/summary/package_bundle_reader.dart';
29 import 'package:analyzer/src/summary/summarize_ast.dart' 29 import 'package:analyzer/src/summary/summarize_ast.dart'
30 show serializeAstUnlinked; 30 show serializeAstUnlinked;
31 import 'package:analyzer/src/summary/summarize_elements.dart' 31 import 'package:analyzer/src/summary/summarize_elements.dart'
32 show PackageBundleAssembler; 32 show PackageBundleAssembler;
33 import 'package:analyzer/src/summary/summary_sdk.dart'; 33 import 'package:analyzer/src/summary/summary_sdk.dart';
34 import 'package:analyzer/src/task/strong/ast_properties.dart' 34 import 'package:analyzer/src/task/strong/ast_properties.dart'
35 show isDynamicInvoke, setIsDynamicInvoke, getImplicitAssignmentCast; 35 show isDynamicInvoke, setIsDynamicInvoke, getImplicitAssignmentCast;
36 import 'package:path/path.dart' show relative, separator; 36 import 'package:path/path.dart' show isWithin, relative, separator;
37 37
38 import '../closure/closure_annotator.dart' show ClosureAnnotator; 38 import '../closure/closure_annotator.dart' show ClosureAnnotator;
39 import '../js_ast/js_ast.dart' as JS; 39 import '../js_ast/js_ast.dart' as JS;
40 import '../js_ast/js_ast.dart' show js; 40 import '../js_ast/js_ast.dart' show js;
41 import 'ast_builder.dart' show AstBuilder; 41 import 'ast_builder.dart' show AstBuilder;
42 import 'compiler.dart' show BuildUnit, CompilerOptions, JSModuleFile; 42 import 'compiler.dart' show BuildUnit, CompilerOptions, JSModuleFile;
43 import 'element_helpers.dart'; 43 import 'element_helpers.dart';
44 import 'extension_types.dart' show ExtensionTypeSet; 44 import 'extension_types.dart' show ExtensionTypeSet;
45 import 'js_interop.dart'; 45 import 'js_interop.dart';
46 import 'js_metalet.dart' as JS; 46 import 'js_metalet.dart' as JS;
(...skipping 5970 matching lines...) Expand 10 before | Expand all | Expand 10 after
6017 return uri.path; 6017 return uri.path;
6018 } 6018 }
6019 // TODO(vsm): This is not necessarily unique if '__' appears in a file name. 6019 // TODO(vsm): This is not necessarily unique if '__' appears in a file name.
6020 var encodedSeparator = '__'; 6020 var encodedSeparator = '__';
6021 String qualifiedPath; 6021 String qualifiedPath;
6022 if (uri.scheme == 'package') { 6022 if (uri.scheme == 'package') {
6023 // Strip the package name. 6023 // Strip the package name.
6024 // TODO(vsm): This is not unique if an escaped '/'appears in a filename. 6024 // TODO(vsm): This is not unique if an escaped '/'appears in a filename.
6025 // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide. 6025 // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide.
6026 qualifiedPath = uri.pathSegments.skip(1).join(encodedSeparator); 6026 qualifiedPath = uri.pathSegments.skip(1).join(encodedSeparator);
6027 } else if (uri.toFilePath().startsWith(libraryRoot)) { 6027 } else if (isWithin(libraryRoot, uri.toFilePath())) {
6028 qualifiedPath = uri.path 6028 qualifiedPath = uri.path
6029 .substring(libraryRoot.length) 6029 .substring(libraryRoot.length)
6030 .replaceAll(separator, encodedSeparator); 6030 .replaceAll(separator, encodedSeparator);
6031 } else { 6031 } else {
6032 // We don't have a unique name. 6032 // We don't have a unique name.
6033 throw 'Invalid library root. $libraryRoot does not contain ${uri 6033 throw 'Invalid library root. $libraryRoot does not contain ${uri
6034 .toFilePath()}'; 6034 .toFilePath()}';
6035 } 6035 }
6036 return pathToJSIdentifier(qualifiedPath); 6036 return pathToJSIdentifier(qualifiedPath);
6037 } 6037 }
6038 6038
6039 /// Debugger friendly name for a Dart Library. 6039 /// Debugger friendly name for a Dart Library.
6040 String jsLibraryDebuggerName(String libraryRoot, LibraryElement library) { 6040 String jsLibraryDebuggerName(String libraryRoot, LibraryElement library) {
6041 var uri = library.source.uri; 6041 var uri = library.source.uri;
6042 // For package: and dart: uris show the entire 6042 // For package: and dart: uris show the entire
6043 if (uri.scheme == 'dart' || uri.scheme == 'package') return uri.toString(); 6043 if (uri.scheme == 'dart' || uri.scheme == 'package') return uri.toString();
6044 6044
6045 var filePath = uri.toFilePath(); 6045 var filePath = uri.toFilePath();
6046 if (!filePath.startsWith(libraryRoot)) { 6046 if (!isWithin(libraryRoot, filePath)) {
6047 throw 'Invalid library root. $libraryRoot does not contain ${uri 6047 throw 'Invalid library root. $libraryRoot does not contain ${uri
6048 .toFilePath()}'; 6048 .toFilePath()}';
6049 } 6049 }
6050 // Relative path to the library. 6050 // Relative path to the library.
6051 return relative(filePath, from: libraryRoot); 6051 return relative(filePath, from: libraryRoot);
6052 } 6052 }
6053 6053
6054 String jsDebuggingLibraryName(String libraryRoot, LibraryElement library) { 6054 String jsDebuggingLibraryName(String libraryRoot, LibraryElement library) {
6055 var uri = library.source.uri; 6055 var uri = library.source.uri;
6056 if (uri.scheme == 'dart') { 6056 if (uri.scheme == 'dart') {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
6120 if (targetIdentifier.staticElement is! PrefixElement) return false; 6120 if (targetIdentifier.staticElement is! PrefixElement) return false;
6121 var prefix = targetIdentifier.staticElement as PrefixElement; 6121 var prefix = targetIdentifier.staticElement as PrefixElement;
6122 6122
6123 // The library the prefix is referring to must come from a deferred import. 6123 // The library the prefix is referring to must come from a deferred import.
6124 var containingLibrary = resolutionMap 6124 var containingLibrary = resolutionMap
6125 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 6125 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
6126 .library; 6126 .library;
6127 var imports = containingLibrary.getImportsWithPrefix(prefix); 6127 var imports = containingLibrary.getImportsWithPrefix(prefix);
6128 return imports.length == 1 && imports[0].isDeferred; 6128 return imports.length == 1 && imports[0].isDeferred;
6129 } 6129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698