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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/diet_listener.dart

Issue 2723113002: Consolidate analyzer dependencies. (Closed)
Patch Set: Remove new dependency on AsyncMarker. Created 3 years, 9 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.diet_listener; 5 library fasta.diet_listener;
6 6
7 import 'package:kernel/ast.dart' show AsyncMarker; 7 import 'package:kernel/ast.dart' show AsyncMarker;
8 8
9 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; 9 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
10 10
(...skipping 11 matching lines...) Expand all
22 import '../util/link.dart' show Link; 22 import '../util/link.dart' show Link;
23 23
24 import '../errors.dart' show Crash, InputError, inputError, internalError; 24 import '../errors.dart' show Crash, InputError, inputError, internalError;
25 25
26 import 'stack_listener.dart' show StackListener; 26 import 'stack_listener.dart' show StackListener;
27 27
28 import '../kernel/body_builder.dart' show BodyBuilder; 28 import '../kernel/body_builder.dart' show BodyBuilder;
29 29
30 import '../builder/builder.dart'; 30 import '../builder/builder.dart';
31 31
32 import '../analyzer/analyzer.dart';
33
34 import '../builder/scope.dart' show Scope; 32 import '../builder/scope.dart' show Scope;
35 33
36 import '../ast_kind.dart' show AstKind;
37
38 import 'source_library_builder.dart' show SourceLibraryBuilder; 34 import 'source_library_builder.dart' show SourceLibraryBuilder;
39 35
40 import '../kernel/kernel_library_builder.dart' show isConstructorName; 36 import '../kernel/kernel_library_builder.dart' show isConstructorName;
41 37
42 class DietListener extends StackListener { 38 class DietListener extends StackListener {
43 final SourceLibraryBuilder library; 39 final SourceLibraryBuilder library;
44 40
45 final ElementStore elementStore;
46
47 final ClassHierarchy hierarchy; 41 final ClassHierarchy hierarchy;
48 42
49 final CoreTypes coreTypes; 43 final CoreTypes coreTypes;
50 44
51 final AstKind astKind;
52
53 final bool isDartLibrary; 45 final bool isDartLibrary;
54 46
55 ClassBuilder currentClass; 47 ClassBuilder currentClass;
56 48
57 /// For top-level declarations, this is the library scope. For class members, 49 /// For top-level declarations, this is the library scope. For class members,
58 /// this is the instance scope of [currentClass]. 50 /// this is the instance scope of [currentClass].
59 Scope memberScope; 51 Scope memberScope;
60 52
61 @override 53 @override
62 Uri uri; 54 Uri uri;
63 55
64 DietListener(SourceLibraryBuilder library, this.elementStore, this.hierarchy, 56 DietListener(SourceLibraryBuilder library, this.hierarchy, this.coreTypes)
65 this.coreTypes, this.astKind)
66 : library = library, 57 : library = library,
67 uri = library.fileUri, 58 uri = library.fileUri,
68 memberScope = library.scope, 59 memberScope = library.scope,
69 isDartLibrary = library.uri.scheme == "dart"; 60 isDartLibrary = library.uri.scheme == "dart";
70 61
71 void discard(int n) { 62 void discard(int n) {
72 for (int i = 0; i < n; i++) { 63 for (int i = 0; i < n; i++) {
73 pop(); 64 pop();
74 } 65 }
75 } 66 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 checkEmpty(beginToken.charOffset); 364 checkEmpty(beginToken.charOffset);
374 if (bodyToken == null) { 365 if (bodyToken == null) {
375 return; 366 return;
376 } 367 }
377 buildFunctionBody(bodyToken, lookupBuilder(beginToken, getOrSet, name)); 368 buildFunctionBody(bodyToken, lookupBuilder(beginToken, getOrSet, name));
378 } 369 }
379 370
380 StackListener createListener( 371 StackListener createListener(
381 MemberBuilder builder, Scope memberScope, bool isInstanceMember, 372 MemberBuilder builder, Scope memberScope, bool isInstanceMember,
382 [Scope formalParameterScope]) { 373 [Scope formalParameterScope]) {
383 switch (astKind) { 374 return new BodyBuilder(library, builder, memberScope, formalParameterScope,
384 case AstKind.Kernel: 375 hierarchy, coreTypes, currentClass, isInstanceMember, uri);
385 return new BodyBuilder(
386 library,
387 builder,
388 memberScope,
389 formalParameterScope,
390 hierarchy,
391 coreTypes,
392 currentClass,
393 isInstanceMember,
394 uri);
395
396 case AstKind.Analyzer:
397 return new AstBuilder(library, builder, elementStore, memberScope, uri);
398 }
399
400 return internalError("Unknown $astKind");
401 } 376 }
402 377
403 void buildFunctionBody(Token token, ProcedureBuilder builder) { 378 void buildFunctionBody(Token token, ProcedureBuilder builder) {
404 Scope typeParameterScope = builder.computeTypeParameterScope(memberScope); 379 Scope typeParameterScope = builder.computeTypeParameterScope(memberScope);
405 Scope formalParameterScope = 380 Scope formalParameterScope =
406 builder.computeFormalParameterScope(typeParameterScope); 381 builder.computeFormalParameterScope(typeParameterScope);
407 assert(typeParameterScope != null); 382 assert(typeParameterScope != null);
408 assert(formalParameterScope != null); 383 assert(formalParameterScope != null);
409 parseFunctionBody( 384 parseFunctionBody(
410 createListener(builder, typeParameterScope, builder.isInstanceMember, 385 createListener(builder, typeParameterScope, builder.isInstanceMember,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 455 }
481 return super.handleUnrecoverableError(token, kind, arguments); 456 return super.handleUnrecoverableError(token, kind, arguments);
482 } 457 }
483 458
484 @override 459 @override
485 Link<Token> handleMemberName(Link<Token> identifiers) { 460 Link<Token> handleMemberName(Link<Token> identifiers) {
486 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 461 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
487 return removeNativeClause(identifiers); 462 return removeNativeClause(identifiers);
488 } 463 }
489 464
465 AsyncMarker getAsyncMarker(StackListener listener) => listener.pop();
466
490 void parseFunctionBody(StackListener listener, Token token) { 467 void parseFunctionBody(StackListener listener, Token token) {
491 try { 468 try {
492 Parser parser = new Parser(listener); 469 Parser parser = new Parser(listener);
493 token = parser.parseFormalParametersOpt(token); 470 token = parser.parseFormalParametersOpt(token);
494 var formals = listener.pop(); 471 var formals = listener.pop();
495 listener.checkEmpty(token.charOffset); 472 listener.checkEmpty(token.charOffset);
496 listener.prepareInitializers(); 473 listener.prepareInitializers();
497 token = parser.parseInitializersOpt(token); 474 token = parser.parseInitializersOpt(token);
498 token = parser.parseAsyncModifier(token); 475 token = parser.parseAsyncModifier(token);
499 AsyncMarker asyncModifier = 476 AsyncMarker asyncModifier = getAsyncMarker(listener);
500 astKind == AstKind.Analyzer ? null : listener.pop();
501 bool isExpression = false; 477 bool isExpression = false;
502 bool allowAbstract = true; 478 bool allowAbstract = true;
503 parser.parseFunctionBody(token, isExpression, allowAbstract); 479 parser.parseFunctionBody(token, isExpression, allowAbstract);
504 var body = listener.pop(); 480 var body = listener.pop();
505 listener.checkEmpty(token.charOffset); 481 listener.checkEmpty(token.charOffset);
506 listener.finishFunction(formals, asyncModifier, body); 482 listener.finishFunction(formals, asyncModifier, body);
507 } on InputError { 483 } on InputError {
508 rethrow; 484 rethrow;
509 } catch (e, s) { 485 } catch (e, s) {
510 throw new Crash(uri, token.charOffset, e, s); 486 throw new Crash(uri, token.charOffset, e, s);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 bool get isTargetingDartVm { 536 bool get isTargetingDartVm {
561 // TODO(ahe): Find a more reliable way to check if this is the Dart VM. 537 // TODO(ahe): Find a more reliable way to check if this is the Dart VM.
562 return !coreTypes.containsLibrary("dart:_js_helper"); 538 return !coreTypes.containsLibrary("dart:_js_helper");
563 } 539 }
564 540
565 @override 541 @override
566 void debugEvent(String name) { 542 void debugEvent(String name) {
567 // printEvent(name); 543 // printEvent(name);
568 } 544 }
569 } 545 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/keyword.dart ('k') | pkg/front_end/lib/src/fasta/source/source_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698