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

Side by Side Diff: pkg/compiler/lib/src/parser/parser_task.dart

Issue 1388523002: dart2js: add support for configuration-specific imports. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments and add flag. Created 5 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 dart2js.parser.task; 5 library dart2js.parser.task;
6 6
7 import '../common/tasks.dart' show 7 import '../common/tasks.dart' show
8 CompilerTask; 8 CompilerTask;
9 import '../compiler.dart' show 9 import '../compiler.dart' show
10 Compiler; 10 Compiler;
11 import '../diagnostics/invariant.dart' show 11 import '../diagnostics/invariant.dart' show
12 invariant; 12 invariant;
13 import '../elements/modelx.dart' show 13 import '../elements/modelx.dart' show
14 ElementX; 14 ElementX;
15 import '../tokens/token.dart' show 15 import '../tokens/token.dart' show
16 Token; 16 Token;
17 import '../tree/tree.dart' show 17 import '../tree/tree.dart' show
18 Node; 18 Node;
19 19
20 import 'listener.dart' show 20 import 'listener.dart' show
21 ParserError; 21 ParserError;
22 import 'node_listener.dart' show 22 import 'node_listener.dart' show
23 NodeListener; 23 NodeListener;
24 import 'parser.dart' show 24 import 'parser.dart' show
25 Parser; 25 Parser;
26 26
27 class ParserTask extends CompilerTask { 27 class ParserTask extends CompilerTask {
28 ParserTask(Compiler compiler) : super(compiler); 28 final bool _enableConditionalDirectives;
29
30 ParserTask(Compiler compiler,
31 {bool enableConditionalDirectives: false})
32 : this._enableConditionalDirectives = enableConditionalDirectives,
33 super(compiler);
34
29 String get name => 'Parser'; 35 String get name => 'Parser';
30 36
31 Node parse(ElementX element) { 37 Node parse(ElementX element) {
32 return measure(() => element.parseNode(compiler.parsing)); 38 return measure(() => element.parseNode(compiler.parsing));
33 } 39 }
34 40
35 Node parseCompilationUnit(Token token) { 41 Node parseCompilationUnit(Token token) {
36 return measure(() { 42 return measure(() {
37 NodeListener listener = new NodeListener(compiler, null); 43 NodeListener listener = new NodeListener(compiler, null);
38 Parser parser = new Parser(listener); 44 print("parser: $_enableConditionalDirectives");
Johnni Winther 2015/10/14 07:21:52 Remove debug code.
floitsch 2015/12/10 19:38:43 Done.
45 Parser parser = new Parser(
46 listener, enableConditionalDirectives: _enableConditionalDirectives);
39 try { 47 try {
40 parser.parseUnit(token); 48 parser.parseUnit(token);
41 } on ParserError catch(_) { 49 } on ParserError catch(_) {
42 assert(invariant(token, compiler.compilationFailed)); 50 assert(invariant(token, compiler.compilationFailed));
43 return listener.makeNodeList(0, null, null, '\n'); 51 return listener.makeNodeList(0, null, null, '\n');
44 } 52 }
45 Node result = listener.popNode(); 53 Node result = listener.popNode();
46 assert(listener.nodes.isEmpty); 54 assert(listener.nodes.isEmpty);
47 return result; 55 return result;
48 }); 56 });
49 } 57 }
50 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698