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

Side by Side Diff: frog/await/awaitc.dart

Issue 10548047: Remove frog from the repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move test and update apidoc.gyp. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « frog/analyze_frame.dart ('k') | frog/await/checker.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Separate entrypoint for the frog compiler with experimental support for the
6 // 'await' keyword.
7
8 #import('../lang.dart');
9 #import('../minfrog.dart', prefix:'minfrog');
10 #source('nodeset.dart');
11 #source('checker.dart');
12 #source('normalizer.dart');
13 #source('transformation.dart');
14
15 /**
16 * The main entry point method - needed to ensure we handle correctly await
17 * expressions within main.
18 */
19 Member _mainMethod;
20
21 /**
22 * A phase in the compilation process that processes the entire AST and
23 * desugars await expressions.
24 */
25 awaitTransformation() {
26 _mainMethod =
27 world.findMainMethod(world.getOrAddLibrary(options.dartScript));
28 for (var lib in world.libraries.getValues()) {
29 for (var type in lib.types.getValues()) {
30 for (var member in type.members.getValues()) {
31 _process(member);
32 }
33 for (var member in type.constructors.getValues()) {
34 _process(member);
35 }
36 }
37 }
38 }
39
40 /** Analyze and transform a single member (method or property). */
41 _process(Member member) {
42 if (member.isConstructor || member.isMethod) {
43 _processFunction(member.definition);
44 } else if (member.isProperty) {
45 PropertyMember p = member;
46 if (p.getter != null) _process(p.getter);
47 if (p.setter != null) _process(p.setter);
48 }
49 }
50
51 /** Analyze and transform a function definition and nested definitions. */
52 _processFunction(FunctionDefinition func) {
53 AwaitChecker checker = new AwaitChecker();
54
55 // Run checker that collects nested functions and which nodes may contain
56 // await expressions.
57 func.visit(checker);
58
59 // Rewrite nested asynchronous functions first.
60 for (FunctionDefinition f in checker.nestedFunctions) {
61 _processFunction(f);
62 }
63
64 if (checker.haveAwait.contains(func)) {
65 // Normalize
66 func.visit(new AwaitNormalizer(checker.haveAwait));
67 // Re-run the checker to derive appropriate node information (this
68 // makes the normalizer simpler as we don't have to keep track of this
69 // information).
70 checker = new AwaitChecker();
71 func.visit(checker);
72
73 // Transform the code.
74 func.visit(new AwaitProcessor(checker.haveAwait));
75 }
76 }
77
78 /** Run frog, setting the await transformation correctly. */
79 void main() {
80 experimentalAwaitPhase = () {
81 world.withTiming('remove await expressions', awaitTransformation);
82 };
83 minfrog.main();
84 }
OLDNEW
« no previous file with comments | « frog/analyze_frame.dart ('k') | frog/await/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698