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

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

Issue 2432603002: Revert "Fix library name insert and access inconsistency on windows" (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 import 'package:analyzer/src/summary/idl.dart' show UnlinkedUnit; 24 import 'package:analyzer/src/summary/idl.dart' show UnlinkedUnit;
25 import 'package:analyzer/src/summary/link.dart' as summary_link; 25 import 'package:analyzer/src/summary/link.dart' as summary_link;
26 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 26 import 'package:analyzer/src/summary/package_bundle_reader.dart';
27 import 'package:analyzer/src/summary/summarize_ast.dart' 27 import 'package:analyzer/src/summary/summarize_ast.dart'
28 show serializeAstUnlinked; 28 show serializeAstUnlinked;
29 import 'package:analyzer/src/summary/summarize_elements.dart' 29 import 'package:analyzer/src/summary/summarize_elements.dart'
30 show PackageBundleAssembler; 30 show PackageBundleAssembler;
31 import 'package:analyzer/src/summary/summary_sdk.dart'; 31 import 'package:analyzer/src/summary/summary_sdk.dart';
32 import 'package:analyzer/src/task/strong/ast_properties.dart' 32 import 'package:analyzer/src/task/strong/ast_properties.dart'
33 show isDynamicInvoke, setIsDynamicInvoke, getImplicitAssignmentCast; 33 show isDynamicInvoke, setIsDynamicInvoke, getImplicitAssignmentCast;
34 import 'package:path/path.dart' show separator, isWithin, fromUri; 34 import 'package:path/path.dart' show separator;
35 35
36 import '../closure/closure_annotator.dart' show ClosureAnnotator; 36 import '../closure/closure_annotator.dart' show ClosureAnnotator;
37 import '../js_ast/js_ast.dart' as JS; 37 import '../js_ast/js_ast.dart' as JS;
38 import '../js_ast/js_ast.dart' show js; 38 import '../js_ast/js_ast.dart' show js;
39 import 'ast_builder.dart' show AstBuilder; 39 import 'ast_builder.dart' show AstBuilder;
40 import 'compiler.dart' show BuildUnit, CompilerOptions, JSModuleFile; 40 import 'compiler.dart' show BuildUnit, CompilerOptions, JSModuleFile;
41 import 'element_helpers.dart'; 41 import 'element_helpers.dart';
42 import 'element_loader.dart' show ElementLoader; 42 import 'element_loader.dart' show ElementLoader;
43 import 'extension_types.dart' show ExtensionTypeSet; 43 import 'extension_types.dart' show ExtensionTypeSet;
44 import 'js_field_storage.dart' show checkForPropertyOverride, getSuperclasses; 44 import 'js_field_storage.dart' show checkForPropertyOverride, getSuperclasses;
(...skipping 5400 matching lines...) Expand 10 before | Expand all | Expand 10 after
5445 /// Choose a canonical name from the [library] element. 5445 /// Choose a canonical name from the [library] element.
5446 /// 5446 ///
5447 /// This never uses the library's name (the identifier in the `library` 5447 /// This never uses the library's name (the identifier in the `library`
5448 /// declaration) as it doesn't have any meaningful rules enforced. 5448 /// declaration) as it doesn't have any meaningful rules enforced.
5449 String jsLibraryName(String libraryRoot, LibraryElement library) { 5449 String jsLibraryName(String libraryRoot, LibraryElement library) {
5450 var uri = library.source.uri; 5450 var uri = library.source.uri;
5451 if (uri.scheme == 'dart') { 5451 if (uri.scheme == 'dart') {
5452 return uri.path; 5452 return uri.path;
5453 } 5453 }
5454 // TODO(vsm): This is not necessarily unique if '__' appears in a file name. 5454 // TODO(vsm): This is not necessarily unique if '__' appears in a file name.
5455 var customSeparator = '__'; 5455 var separator = '__';
5456 String qualifiedPath; 5456 String qualifiedPath;
5457 if (uri.scheme == 'package') { 5457 if (uri.scheme == 'package') {
5458 // Strip the package name. 5458 // Strip the package name.
5459 // TODO(vsm): This is not unique if an escaped '/'appears in a filename. 5459 // TODO(vsm): This is not unique if an escaped '/'appears in a filename.
5460 // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide. 5460 // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide.
5461 qualifiedPath = uri.pathSegments.skip(1).join(customSeparator); 5461 qualifiedPath = uri.pathSegments.skip(1).join(separator);
5462 } else if (isWithin(libraryRoot, uri.toFilePath())) { 5462 } else if (uri.toFilePath().startsWith(libraryRoot)) {
5463 qualifiedPath = fromUri(uri) 5463 qualifiedPath =
5464 .substring(libraryRoot.length) 5464 uri.path.substring(libraryRoot.length).replaceAll('/', separator);
5465 .replaceAll(separator, customSeparator);
5466 } else { 5465 } else {
5467 // We don't have a unique name. 5466 // We don't have a unique name.
5468 throw 'Invalid library root. $libraryRoot does not contain ${uri 5467 throw 'Invalid library root. $libraryRoot does not contain ${uri
5469 .toFilePath()}'; 5468 .toFilePath()}';
5470 } 5469 }
5471 return pathToJSIdentifier(qualifiedPath); 5470 return pathToJSIdentifier(qualifiedPath);
5472 } 5471 }
5473 5472
5474 /// Shorthand for identifier-like property names. 5473 /// Shorthand for identifier-like property names.
5475 /// For now, we emit them as strings and the printer restores them to 5474 /// For now, we emit them as strings and the printer restores them to
(...skipping 21 matching lines...) Expand all
5497 } 5496 }
5498 5497
5499 bool isLibraryPrefix(Expression node) => 5498 bool isLibraryPrefix(Expression node) =>
5500 node is SimpleIdentifier && node.staticElement is PrefixElement; 5499 node is SimpleIdentifier && node.staticElement is PrefixElement;
5501 5500
5502 LibraryElement _getLibrary(AnalysisContext c, String uri) => 5501 LibraryElement _getLibrary(AnalysisContext c, String uri) =>
5503 c.computeLibraryElement(c.sourceFactory.forUri(uri)); 5502 c.computeLibraryElement(c.sourceFactory.forUri(uri));
5504 5503
5505 bool _isDartRuntime(LibraryElement l) => 5504 bool _isDartRuntime(LibraryElement l) =>
5506 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 5505 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698