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

Issue 10332196: Start working on unparse validation. (Closed)

Created:
8 years, 7 months ago by Anton Muhin
Modified:
8 years, 7 months ago
Reviewers:
ahe, floitsch, ngeoffray, kasperl
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Start working on unparse validation. R=ahe@google.com Committed: https://code.google.com/p/dart/source/detail?r=7858

Patch Set 1 #

Total comments: 8

Patch Set 2 : Next iteration #

Total comments: 13

Patch Set 3 : Last iteration #

Patch Set 4 : #

Patch Set 5 : Start working on unparse validation. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+57 lines, -3 lines) Patch
M lib/compiler/implementation/apiimpl.dart View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M lib/compiler/implementation/compiler.dart View 1 2 4 chunks +6 lines, -2 lines 0 comments Download
M lib/compiler/implementation/dart2js.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M lib/compiler/implementation/leg.dart View 1 1 chunk +1 line, -0 lines 0 comments Download
A lib/compiler/implementation/unparse_validator.dart View 1 2 1 chunk +47 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Anton Muhin
And another RFC. The plan is to run some subset (say, co19 or maybe the ...
8 years, 7 months ago (2012-05-16 16:00:58 UTC) #1
ahe
https://chromiumcodereview.appspot.com/10332196/diff/1/lib/compiler/implementation/compiler.dart File lib/compiler/implementation/compiler.dart (right): https://chromiumcodereview.appspot.com/10332196/diff/1/lib/compiler/implementation/compiler.dart#newcode602 lib/compiler/implementation/compiler.dart:602: void checkUnparse(Element element, Compiler compiler) { I don't like ...
8 years, 7 months ago (2012-05-21 16:53:29 UTC) #2
Anton Muhin
PTAL https://chromiumcodereview.appspot.com/10332196/diff/1/lib/compiler/implementation/compiler.dart File lib/compiler/implementation/compiler.dart (right): https://chromiumcodereview.appspot.com/10332196/diff/1/lib/compiler/implementation/compiler.dart#newcode602 lib/compiler/implementation/compiler.dart:602: void checkUnparse(Element element, Compiler compiler) { On 2012/05/21 ...
8 years, 7 months ago (2012-05-21 19:14:38 UTC) #3
ahe
LGTM. I removed the R line, feel free to add it back, but please only ...
8 years, 7 months ago (2012-05-22 08:49:04 UTC) #4
Anton Muhin
Peter, thanks a lot for review. I'll address remaining comments once in the office. https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart ...
8 years, 7 months ago (2012-05-22 08:56:32 UTC) #5
ahe
https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart File lib/compiler/implementation/unparse_validator.dart (right): https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart#newcode44 lib/compiler/implementation/unparse_validator.dart:44: final oldHandler = compiler.handler; On 2012/05/22 08:56:32, antonmuhin wrote: ...
8 years, 7 months ago (2012-05-22 09:04:45 UTC) #6
Anton Muhin
https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart File lib/compiler/implementation/unparse_validator.dart (right): https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart#newcode14 lib/compiler/implementation/unparse_validator.dart:14: if (!validateUnparse) { On 2012/05/22 08:49:04, ahe wrote: > ...
8 years, 7 months ago (2012-05-22 15:34:32 UTC) #7
ahe
https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart File lib/compiler/implementation/unparse_validator.dart (right): https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implementation/unparse_validator.dart#newcode44 lib/compiler/implementation/unparse_validator.dart:44: final oldHandler = compiler.handler; Shoot. I forgot about the ...
8 years, 7 months ago (2012-05-22 15:50:55 UTC) #8
Anton Muhin
8 years, 7 months ago (2012-05-22 19:16:57 UTC) #9
https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implem...
File lib/compiler/implementation/unparse_validator.dart (right):

https://chromiumcodereview.appspot.com/10332196/diff/4001/lib/compiler/implem...
lib/compiler/implementation/unparse_validator.dart:44: final oldHandler =
compiler.handler;
I am sorry, I've already submitted w/o it.  Sending you hopefully better
variant.

On 2012/05/22 15:50:56, ahe wrote:
> Shoot. I forgot about the compiler API. It would be cleaner with a compiler
> subclass for the validation, but your hack works for now. So please keep it. I
> think it is important that the error message is correct in this case.
Otherwise
> it will be pretty hard to figure out what went wrong.
> 
> On 2012/05/22 15:34:32, antonmuhin wrote:
> > As far as I understand it goes like this:
> > 
> > we get into Compiler.cancel with null for a node and proper token. 
Therefore
> we
> > construct SourceSpan with offsets of synthesized tokens, but with URI of
> > original file (because we use it for synthesizedLib).  Now SourceSpan has no
> > notion of original SourceFile and hence error handler refetches it from a
> > sourceFile map in dart2js.
> > 
> > If I make a fake URI, error handler will just choke as there will be no
> > corresponding entry.
> > 
> > I would fix it by passing SourceFile instead of uri into error handler.
> > 
> > However, I suspect it was done differently as that minimized compiler
API---in
> > compiler API there is no notion of SourceFile, but ironically dart2js
imports
> > it.
> > 
> > Another option would be to pass fully formatted message into error handler.
> > 
> > What will be your preferences?
> > 
> > And in any event, I'll land this change w/ error handling overrides and
defer
> it
> > to future CL (with corresponding TODO).
> > 
> > On 2012/05/22 09:04:45, ahe wrote:
> > > On 2012/05/22 08:56:32, antonmuhin wrote:
> > > > The old handler will lookup SourceFile via uri and will find the full
> > version
> > > of
> > > > the file.  Therefore span would be incorrect.  Example, js_helper has
> > > > stringToString function with wrongly unparsed construct (is!)  When we
> parse
> > > > unparsed code, span woud point into copyright header of js_helper.dart
:)
> > > > 
> > > > With overridden handler:
> > > > 
> > > >
> > >
> >
>
file:///usr/local/google/home/antonm/dart-all/dart/lib/compiler/implementation/lib/js_helper.dart:1:68:
> > > > unexpected token '!'                                                    
 
>  
> >  
> > >  
> > > >                       
> > > > String stringToString(var value){var res=value.toString();
> > > if(resis!String)throw
> > > > new IllegalArgumentException(value); return res;}                       
 
>  
> >  
> > >  
> > > >                                              
> > > >                                                                    ^    
 
>  
> >  
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > > info: compiler cancelled: unexpected token '!'                          
 
>  
> >  
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > > 
> > > > w/o it:
> > > > 
> > > > lib/compiler/implementation/lib/js_helper.dart:1:68: unexpected token
'!' 
>  
> >  
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > > // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS
> > file 
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > >                                                                    ^    
 
>  
> >  
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > > info: compiler cancelled: unexpected token '!'                          
 
>  
> >  
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > > info: compilation failed                                                
 
>  
> >  
> > >  
> > > >                                                                         
 
>  
> >  
> > >  
> > > >                                              
> > > > 
> > > > On 2012/05/22 08:49:04, ahe wrote:
> > > > > On 2012/05/21 19:14:39, antonmuhin wrote:
> > > > > > this trick is sketchy, but allows nice diagnostics.
> > > > > > 
> > > > > > I can probably make it less sketchy with proper tweaking of
> > > > reportDiagnostics
> > > > > if
> > > > > > you prefer it this way.
> > > > > 
> > > > > I don't understand why you have to do this. How is your new handler
> > > different?
> > > > 
> > > 
> > > The source file should be found in the "currentElement" of the compiler.
So
> it
> > > should be possible to remove your custom handler.
> > > 
> > > If that still doesn't work, the element stored in lib is not setup
correctly
> > and
> > > we should figure out what is wrong.
> > 
>

Powered by Google App Engine
This is Rietveld 408576698