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

Side by Side Diff: dart/frog/leg/tree/nodes.dart

Issue 8999015: Generate AST node for factory methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix type errors Created 9 years 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 | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/presubmit.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitClassNode(ClassNode node); 7 R visitClassNode(ClassNode node);
8 R visitConditional(Conditional node); 8 R visitConditional(Conditional node);
9 R visitDoWhile(DoWhile node); 9 R visitDoWhile(DoWhile node);
10 R visitExpressionStatement(ExpressionStatement node); 10 R visitExpressionStatement(ExpressionStatement node);
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 801
802 final NodeList nodes; 802 final NodeList nodes;
803 /** Bit pattern to easy check what modifiers are present. */ 803 /** Bit pattern to easy check what modifiers are present. */
804 final int flags; 804 final int flags;
805 805
806 static final int FLAG_STATIC = 1; 806 static final int FLAG_STATIC = 1;
807 static final int FLAG_ABSTRACT = FLAG_STATIC << 1; 807 static final int FLAG_ABSTRACT = FLAG_STATIC << 1;
808 static final int FLAG_FINAL = FLAG_ABSTRACT << 1; 808 static final int FLAG_FINAL = FLAG_ABSTRACT << 1;
809 static final int FLAG_VAR = FLAG_FINAL << 1; 809 static final int FLAG_VAR = FLAG_FINAL << 1;
810 static final int FLAG_CONST = FLAG_VAR << 1; 810 static final int FLAG_CONST = FLAG_VAR << 1;
811 static final int FLAG_FACTORY = FLAG_CONST << 1;
811 812
812 Modifiers(NodeList nodes) 813 Modifiers(NodeList nodes)
813 : this.nodes = nodes, flags = computeFlags(nodes.nodes); 814 : this.nodes = nodes, flags = computeFlags(nodes.nodes);
814 815
815 static int computeFlags(Link<Node> nodes) { 816 static int computeFlags(Link<Node> nodes) {
816 int flags = 0; 817 int flags = 0;
817 for (; !nodes.isEmpty(); nodes = nodes.tail) { 818 for (; !nodes.isEmpty(); nodes = nodes.tail) {
818 String value = nodes.head.asIdentifier().source.stringValue; 819 String value = nodes.head.asIdentifier().source.stringValue;
819 if (value === 'static') flags += FLAG_STATIC; 820 if (value === 'static') flags += FLAG_STATIC;
820 else if (value === 'abstract') flags += FLAG_ABSTRACT; 821 else if (value === 'abstract') flags += FLAG_ABSTRACT;
821 else if (value === 'final') flags += FLAG_FINAL; 822 else if (value === 'final') flags += FLAG_FINAL;
822 else if (value === 'var') flags += FLAG_VAR; 823 else if (value === 'var') flags += FLAG_VAR;
823 else if (value === 'const') flags += FLAG_CONST; 824 else if (value === 'const') flags += FLAG_CONST;
825 else if (value === 'factory') flags += FLAG_FACTORY;
826 else throw 'internal error: ${nodes.head}';
824 } 827 }
825 return flags; 828 return flags;
826 } 829 }
827 830
828 Modifiers asModifiers() => this; 831 Modifiers asModifiers() => this;
829 Token getBeginToken() => nodes.getBeginToken(); 832 Token getBeginToken() => nodes.getBeginToken();
830 Token getEndToken() => nodes.getEndToken(); 833 Token getEndToken() => nodes.getEndToken();
831 accept(Visitor visitor) => visitor.visitModifiers(this); 834 accept(Visitor visitor) => visitor.visitModifiers(this);
832 visitChildren(Visitor visitor) => nodes.accept(visitor); 835 visitChildren(Visitor visitor) => nodes.accept(visitor);
833 836
834 bool isStatic() => (flags & FLAG_STATIC) != 0; 837 bool isStatic() => (flags & FLAG_STATIC) != 0;
835 bool isAbstract() => (flags & FLAG_ABSTRACT) != 0; 838 bool isAbstract() => (flags & FLAG_ABSTRACT) != 0;
836 bool isFinal() => (flags & FLAG_FINAL) != 0; 839 bool isFinal() => (flags & FLAG_FINAL) != 0;
837 bool isVar() => (flags & FLAG_VAR) != 0; 840 bool isVar() => (flags & FLAG_VAR) != 0;
838 bool isConst() => (flags & FLAG_CONST) != 0; 841 bool isConst() => (flags & FLAG_CONST) != 0;
842 bool isFactory() => (flags & FLAG_FACTORY) != 0;
839 } 843 }
840 844
841 class StringInterpolation extends Expression { 845 class StringInterpolation extends Expression {
842 final LiteralString string; 846 final LiteralString string;
843 final NodeList parts; 847 final NodeList parts;
844 848
845 StringInterpolation(this.string, this.parts); 849 StringInterpolation(this.string, this.parts);
846 850
847 StringInterpolation asStringInterpolation() => this; 851 StringInterpolation asStringInterpolation() => this;
848 852
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 902
899 UnimplementedStatement(this.description, List<Node> nodes) 903 UnimplementedStatement(this.description, List<Node> nodes)
900 : this.nodes = new NodeList(null, new Link<Node>.fromList(nodes)); 904 : this.nodes = new NodeList(null, new Link<Node>.fromList(nodes));
901 905
902 toString() => '$description($nodes)'; 906 toString() => '$description($nodes)';
903 907
904 Token getBeginToken() => nodes.getBeginToken(); 908 Token getBeginToken() => nodes.getBeginToken();
905 909
906 Token getEndToken() => nodes.getEndToken(); 910 Token getEndToken() => nodes.getEndToken();
907 } 911 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/presubmit.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698