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

Issue 11967010: Internal libraries supported. (Closed)

Created:
7 years, 11 months ago by Johnni Winther
Modified:
7 years, 11 months ago
Reviewers:
ahe, ngeoffray, kasperl
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Internal libraries supported. Committed: https://code.google.com/p/dart/source/detail?r=17556

Patch Set 1 #

Total comments: 44

Patch Set 2 : Rebased #

Patch Set 3 : Updated cf. comments. #

Patch Set 4 : URI handling refactored. #

Patch Set 5 : Update MockCompiler #

Total comments: 28

Patch Set 6 : Rebased #

Patch Set 7 : Updated cf. comments. #

Patch Set 8 : Rebased #

Unified diffs Side-by-side diffs Delta from patch set Stats (+323 lines, -94 lines) Patch
M sdk/lib/_internal/compiler/implementation/apiimpl.dart View 1 2 3 4 5 6 7 4 chunks +71 lines, -21 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/compiler.dart View 1 2 3 4 5 6 7 3 chunks +26 lines, -3 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/dart_backend/emitter.dart View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/elements/elements.dart View 1 2 3 4 5 6 1 chunk +17 lines, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/elements/modelx.dart View 1 2 3 4 5 3 chunks +8 lines, -5 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/enqueue.dart View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/library_loader.dart View 1 2 3 4 5 6 8 chunks +126 lines, -23 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/native_handler.dart View 1 2 3 4 5 2 chunks +15 lines, -14 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/patch_parser.dart View 1 2 3 1 chunk +18 lines, -15 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/scanner/scanner_task.dart View 1 2 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/script.dart View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/source_file_provider.dart View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M tests/compiler/dart2js/mock_compiler.dart View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 0 comments Download
A + tests/compiler/dart2js_native/internal_library_test.dart View 1 2 1 chunk +7 lines, -4 lines 0 comments Download
A tests/language/internal_library_test.dart View 1 2 3 4 5 6 1 chunk +17 lines, -0 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
Johnni Winther
7 years, 11 months ago (2013-01-16 13:27:32 UTC) #1
ngeoffray
LGTM, but I would wait for Peter's comments. https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode149 sdk/lib/_internal/compiler/implementation/apiimpl.dart:149: if ...
7 years, 11 months ago (2013-01-16 15:40:57 UTC) #2
ahe
LGTM, if you get rid of the check for "_" in the beginning of uri.path ...
7 years, 11 months ago (2013-01-18 11:03:10 UTC) #3
Johnni Winther
https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode107 sdk/lib/_internal/compiler/implementation/apiimpl.dart:107: * used to grant access to private libraries for ...
7 years, 11 months ago (2013-01-21 09:27:54 UTC) #4
ahe
https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode153 sdk/lib/_internal/compiler/implementation/apiimpl.dart:153: if (sourceUri.scheme == 'dart' || sourceUri.scheme == 'patch') { ...
7 years, 11 months ago (2013-01-21 09:39:38 UTC) #5
Johnni Winther
https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode153 sdk/lib/_internal/compiler/implementation/apiimpl.dart:153: if (sourceUri.scheme == 'dart' || sourceUri.scheme == 'patch') { ...
7 years, 11 months ago (2013-01-21 09:45:55 UTC) #6
ahe
https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode153 sdk/lib/_internal/compiler/implementation/apiimpl.dart:153: if (sourceUri.scheme == 'dart' || sourceUri.scheme == 'patch') { ...
7 years, 11 months ago (2013-01-21 10:08:24 UTC) #7
Johnni Winther
https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode153 sdk/lib/_internal/compiler/implementation/apiimpl.dart:153: if (sourceUri.scheme == 'dart' || sourceUri.scheme == 'patch') { ...
7 years, 11 months ago (2013-01-21 10:15:15 UTC) #8
ahe
https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/1/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode153 sdk/lib/_internal/compiler/implementation/apiimpl.dart:153: if (sourceUri.scheme == 'dart' || sourceUri.scheme == 'patch') { ...
7 years, 11 months ago (2013-01-21 10:18:09 UTC) #9
Johnni Winther
PTAL Found a bug regarding package URIs and ended up cleaning up the use and ...
7 years, 11 months ago (2013-01-22 13:42:22 UTC) #10
ahe
Sorry, I just have a few comments. I'm not sure I have more mileage in ...
7 years, 11 months ago (2013-01-23 12:08:23 UTC) #11
ahe
LGTM! https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compiler/implementation/apiimpl.dart File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right): https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compiler/implementation/apiimpl.dart#newcode103 sdk/lib/_internal/compiler/implementation/apiimpl.dart:103: Uri resolveAbsoluteUri(elements.LibraryElement importingLibrary, Actually, this method name doesn't ...
7 years, 11 months ago (2013-01-24 10:00:57 UTC) #12
Johnni Winther
7 years, 11 months ago (2013-01-24 13:04:59 UTC) #13
Message was sent while issue was closed.
https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
File sdk/lib/_internal/compiler/implementation/apiimpl.dart (right):

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/apiimpl.dart:69: //
TODO(johnniwinther): Merge better with [translateDartUri] when
On 2013/01/23 12:08:23, ahe wrote:
> I don't understand this comment.

The lookup into LIBRARIES is done both here and in [translateDartUri] which also
calls this method. I want to avoid that.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/apiimpl.dart:103: Uri
resolveAbsoluteUri(elements.LibraryElement importingLibrary,
On 2013/01/24 10:00:57, ahe wrote:
> I think it would be nice with a documentation comment like:
> 
> /// See [leg.Compiler.resolveAbsoluteUri].
> 
> Or something like that to inform the reader to look there for documentation.
> When reading the library loader, it is nice to be able to go to leg.Compiler
and
> find documentation, but when reading this class, it's not so nice.

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/apiimpl.dart:103: Uri
resolveAbsoluteUri(elements.LibraryElement importingLibrary,
On 2013/01/24 10:00:57, ahe wrote:
> Actually, this method name doesn't really make sense. In terms of URI RFC
> (standard), resolving an absolute URI is a no-op. I'd rather call it
> "translate".

Good idea. Couldn't come up with a good name.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/apiimpl.dart:135: return new
leg.Script(readableUri, sourceFile);
On 2013/01/24 10:00:57, ahe wrote:
> Do you know why we use the "readableUri" here? I still get two different
> libraries if I use resourceUri when I import a package through different
paths:
> 
> import 'package:foo/foo.dart' as a;
> import 'packages/foo/foo.dart' as b;

We need to preserve the scheme in the script since is used for resolving
relative URIs mentioned in the script. Your example should result in two
different libraries (since the package root might not be the packages folder)
but importing 'foo.dart' in library 'a' must be the resolve to itself. That is,
the library loaded through the package scheme.

It was this subtlety that provoked the whole investigation into URIs.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/apiimpl.dart:168: reportError(node,
On 2013/01/24 10:00:57, ahe wrote:
> Could this be reportDiagnostic?

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/apiimpl.dart:174: path = null;
On 2013/01/24 10:00:57, ahe wrote:
> How about not setting path to null? The compiler will then resolve everything,
> but stop before codegen.

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
File sdk/lib/_internal/compiler/implementation/compiler.dart (right):

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/compiler.dart:956: * not accessible
from [importingLibrary] and returns [:null:] in this case.
On 2013/01/24 10:00:57, ahe wrote:
> Depending on how you respond to my comment in apiimpl line 174, this might
need
> to be tweaked.

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
File sdk/lib/_internal/compiler/implementation/dart2js.dart (right):

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/dart2js.dart:203: throw new
ArgumentError("Invalid uri '$uri'");
On 2013/01/24 10:00:57, ahe wrote:
> How about: "Unknown scheme in uri '$uri'"

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
File sdk/lib/_internal/compiler/implementation/elements/elements.dart (right):

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/elements/elements.dart:477: * library
for [:dart:x:] the canonical uri is [:patch:x:].
On 2013/01/24 10:00:57, ahe wrote:
> I thought you'd get rid of the "patch" scheme?

It is.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
File sdk/lib/_internal/compiler/implementation/library_loader.dart (right):

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/library_loader.dart:30: * ## Absolute
URI ##
On 2013/01/24 10:00:57, ahe wrote:
> I would call this "resolved".

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/library_loader.dart:67: * ## Readable
URI ##
On 2013/01/24 10:00:57, ahe wrote:
> I don't understand why we need both "readable URIs" and "resource URIs". Would
> it be possible to translate dart: and package: URIs at the same time?

Added a discussion of this.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/library_loader.dart:76: * name exacts
and in case of internal libraries whether access is granted.
On 2013/01/24 10:00:57, ahe wrote:
> exacts -> exists

Done.

https://codereview.chromium.org/11967010/diff/24001/sdk/lib/_internal/compile...
sdk/lib/_internal/compiler/implementation/library_loader.dart:86: *
'file:///current/working/dir/' then the package URI 'package:../foo/bar.dart'
On 2013/01/24 10:00:57, ahe wrote:
> This is a good example of something that shouldn't be allowed. A package URI
> should not start with ".." and generally should not be able to "escape" the
> package root.

Changed the example since that was not crucial to the point.

https://codereview.chromium.org/11967010/diff/24001/tests/language/internal_l...
File tests/language/internal_library_test.dart (right):

https://codereview.chromium.org/11967010/diff/24001/tests/language/internal_l...
tests/language/internal_library_test.dart:11: import 'patch:core'; /// 02:
compile-time error
On 2013/01/23 12:08:23, ahe wrote:
> Did you remove this scheme? If so, could you test that you cannot import
> 'dart:core_patch' or whatever it is called.

Patch libraries have no canonical URI - as before.

Powered by Google App Engine
This is Rietveld 408576698