Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of tree; | 5 part of tree; |
| 6 | 6 |
| 7 abstract class Visitor<R> { | 7 abstract class Visitor<R> { |
| 8 const Visitor(); | 8 const Visitor(); |
| 9 | 9 |
| 10 R visitNode(Node node); | 10 R visitNode(Node node); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 R visitEmptyStatement(EmptyStatement node) => visitStatement(node); | 27 R visitEmptyStatement(EmptyStatement node) => visitStatement(node); |
| 28 R visitEnum(Enum node) => visitNode(node); | 28 R visitEnum(Enum node) => visitNode(node); |
| 29 R visitExport(Export node) => visitLibraryDependency(node); | 29 R visitExport(Export node) => visitLibraryDependency(node); |
| 30 R visitExpression(Expression node) => visitNode(node); | 30 R visitExpression(Expression node) => visitNode(node); |
| 31 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node); | 31 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node); |
| 32 R visitFor(For node) => visitLoop(node); | 32 R visitFor(For node) => visitLoop(node); |
| 33 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node); | 33 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node); |
| 34 R visitFunctionExpression(FunctionExpression node) => visitExpression(node); | 34 R visitFunctionExpression(FunctionExpression node) => visitExpression(node); |
| 35 R visitGotoStatement(GotoStatement node) => visitStatement(node); | 35 R visitGotoStatement(GotoStatement node) => visitStatement(node); |
| 36 R visitIdentifier(Identifier node) => visitExpression(node); | 36 R visitIdentifier(Identifier node) => visitExpression(node); |
| 37 R visitIf(If node) => visitStatement(node); | 37 R visitDottedName(DottedName node) => visitExpression(node); |
| 38 R visitImport(Import node) => visitLibraryDependency(node); | 38 R visitIf(If node) => visitStatement(node);dotteDependency(node); |
|
Johnni Winther
2015/10/13 08:44:29
Remove `dotteDependency(node);`
floitsch
2015/10/13 21:01:44
thanks!
| |
| 39 R visitConditionalUri(ConditionalUri node) => visitNode(node); | |
| 39 R visitLabel(Label node) => visitNode(node); | 40 R visitLabel(Label node) => visitNode(node); |
| 40 R visitLabeledStatement(LabeledStatement node) => visitStatement(node); | 41 R visitLabeledStatement(LabeledStatement node) => visitStatement(node); |
| 41 R visitLibraryDependency(LibraryDependency node) => visitLibraryTag(node); | 42 R visitLibraryDependency(LibraryDependency node) => visitLibraryTag(node); |
| 42 R visitLibraryName(LibraryName node) => visitLibraryTag(node); | 43 R visitLibraryName(LibraryName node) => visitLibraryTag(node); |
| 43 R visitLibraryTag(LibraryTag node) => visitNode(node); | 44 R visitLibraryTag(LibraryTag node) => visitNode(node); |
| 44 R visitLiteral(Literal node) => visitExpression(node); | 45 R visitLiteral(Literal node) => visitExpression(node); |
| 45 R visitLiteralBool(LiteralBool node) => visitLiteral(node); | 46 R visitLiteralBool(LiteralBool node) => visitLiteral(node); |
| 46 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node); | 47 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node); |
| 47 R visitLiteralInt(LiteralInt node) => visitLiteral(node); | 48 R visitLiteralInt(LiteralInt node) => visitLiteral(node); |
| 48 R visitLiteralList(LiteralList node) => visitExpression(node); | 49 R visitLiteralList(LiteralList node) => visitExpression(node); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 Await asAwait() => null; | 153 Await asAwait() => null; |
| 153 Block asBlock() => null; | 154 Block asBlock() => null; |
| 154 BreakStatement asBreakStatement() => null; | 155 BreakStatement asBreakStatement() => null; |
| 155 Cascade asCascade() => null; | 156 Cascade asCascade() => null; |
| 156 CascadeReceiver asCascadeReceiver() => null; | 157 CascadeReceiver asCascadeReceiver() => null; |
| 157 CaseMatch asCaseMatch() => null; | 158 CaseMatch asCaseMatch() => null; |
| 158 CatchBlock asCatchBlock() => null; | 159 CatchBlock asCatchBlock() => null; |
| 159 ClassNode asClassNode() => null; | 160 ClassNode asClassNode() => null; |
| 160 Combinator asCombinator() => null; | 161 Combinator asCombinator() => null; |
| 161 Conditional asConditional() => null; | 162 Conditional asConditional() => null; |
| 163 ConditionalUri asConditionalUri() => null; | |
| 162 ContinueStatement asContinueStatement() => null; | 164 ContinueStatement asContinueStatement() => null; |
| 165 DottedName asDottedName() => null; | |
| 163 DoWhile asDoWhile() => null; | 166 DoWhile asDoWhile() => null; |
| 164 EmptyStatement asEmptyStatement() => null; | 167 EmptyStatement asEmptyStatement() => null; |
| 165 Enum asEnum() => null; | 168 Enum asEnum() => null; |
| 166 ErrorExpression asErrorExpression() => null; | 169 ErrorExpression asErrorExpression() => null; |
| 167 Export asExport() => null; | 170 Export asExport() => null; |
| 168 Expression asExpression() => null; | 171 Expression asExpression() => null; |
| 169 ExpressionStatement asExpressionStatement() => null; | 172 ExpressionStatement asExpressionStatement() => null; |
| 170 For asFor() => null; | 173 For asFor() => null; |
| 171 SyncForIn asSyncForIn() => null; | 174 SyncForIn asSyncForIn() => null; |
| 172 AsyncForIn asAsyncForIn() => null; | 175 AsyncForIn asAsyncForIn() => null; |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 Token getBeginToken() { | 1018 Token getBeginToken() { |
| 1016 if (constKeyword != null) return constKeyword; | 1019 if (constKeyword != null) return constKeyword; |
| 1017 return firstBeginToken(typeArguments, elements); | 1020 return firstBeginToken(typeArguments, elements); |
| 1018 } | 1021 } |
| 1019 | 1022 |
| 1020 Token getEndToken() => elements.getEndToken(); | 1023 Token getEndToken() => elements.getEndToken(); |
| 1021 } | 1024 } |
| 1022 | 1025 |
| 1023 class LiteralSymbol extends Expression { | 1026 class LiteralSymbol extends Expression { |
| 1024 final Token hashToken; | 1027 final Token hashToken; |
| 1028 // TODO: this could be a DottedNamed. | |
| 1025 final NodeList identifiers; | 1029 final NodeList identifiers; |
| 1026 | 1030 |
| 1027 LiteralSymbol(this.hashToken, this.identifiers); | 1031 LiteralSymbol(this.hashToken, this.identifiers); |
| 1028 | 1032 |
| 1029 LiteralSymbol asLiteralSymbol() => this; | 1033 LiteralSymbol asLiteralSymbol() => this; |
| 1030 | 1034 |
| 1031 void visitChildren(Visitor visitor) { | 1035 void visitChildren(Visitor visitor) { |
| 1032 if (identifiers != null) identifiers.accept(visitor); | 1036 if (identifiers != null) identifiers.accept(visitor); |
| 1033 } | 1037 } |
| 1034 | 1038 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1060 | 1064 |
| 1061 accept(Visitor visitor) => visitor.visitIdentifier(this); | 1065 accept(Visitor visitor) => visitor.visitIdentifier(this); |
| 1062 | 1066 |
| 1063 visitChildren(Visitor visitor) {} | 1067 visitChildren(Visitor visitor) {} |
| 1064 | 1068 |
| 1065 Token getBeginToken() => token; | 1069 Token getBeginToken() => token; |
| 1066 | 1070 |
| 1067 Token getEndToken() => token; | 1071 Token getEndToken() => token; |
| 1068 } | 1072 } |
| 1069 | 1073 |
| 1074 // TODO(floitsch): a dotted identifier isn't really an expression. Should it | |
| 1075 // inherit from Node instead? | |
| 1076 class DottedName extends Expression { | |
| 1077 final Token token; | |
| 1078 final NodeList identifiers; | |
| 1079 | |
| 1080 DottedName(this.token, this.identifiers); | |
| 1081 | |
| 1082 DottedName asDottedName() => this; | |
| 1083 | |
| 1084 void visitChildren(Visitor visitor) { | |
| 1085 identifiers.accept(visitor); | |
| 1086 } | |
| 1087 | |
| 1088 accept(Visitor visitor) => visitor.visitDottedName(this); | |
| 1089 | |
| 1090 Token getBeginToken() => token; | |
| 1091 Token getEndToken() => identifiers.getEndToken(); | |
| 1092 | |
| 1093 String get slowNameString { | |
| 1094 Unparser unparser = new Unparser(); | |
| 1095 unparser.unparseNodeListOfIdentifiers(identifiers); | |
| 1096 return unparser.result; | |
| 1097 } | |
| 1098 } | |
| 1099 | |
| 1070 class Operator extends Identifier { | 1100 class Operator extends Identifier { |
| 1071 static const COMPLEX_OPERATORS = | 1101 static const COMPLEX_OPERATORS = |
| 1072 const ["--", "++", '+=', "-=", "*=", "/=", "%=", "&=", "|=", "~/=", "^=", | 1102 const ["--", "++", '+=', "-=", "*=", "/=", "%=", "&=", "|=", "~/=", "^=", |
| 1073 ">>=", "<<=", "??="]; | 1103 ">>=", "<<=", "??="]; |
| 1074 | 1104 |
| 1075 static const INCREMENT_OPERATORS = const <String>["++", "--"]; | 1105 static const INCREMENT_OPERATORS = const <String>["++", "--"]; |
| 1076 | 1106 |
| 1077 Operator(Token token) : super(token); | 1107 Operator(Token token) : super(token); |
| 1078 | 1108 |
| 1079 Operator asOperator() => this; | 1109 Operator asOperator() => this; |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1957 Token getEndToken() => name.getEndToken().next; | 1987 Token getEndToken() => name.getEndToken().next; |
| 1958 } | 1988 } |
| 1959 | 1989 |
| 1960 /** | 1990 /** |
| 1961 * This tag describes a dependency between one library and the exported | 1991 * This tag describes a dependency between one library and the exported |
| 1962 * identifiers of another library. The other library is specified by the [uri]. | 1992 * identifiers of another library. The other library is specified by the [uri]. |
| 1963 * Combinators filter away some identifiers from the other library. | 1993 * Combinators filter away some identifiers from the other library. |
| 1964 */ | 1994 */ |
| 1965 abstract class LibraryDependency extends LibraryTag { | 1995 abstract class LibraryDependency extends LibraryTag { |
| 1966 final StringNode uri; | 1996 final StringNode uri; |
| 1997 final NodeList conditionalUris; | |
| 1967 final NodeList combinators; | 1998 final NodeList combinators; |
| 1968 | 1999 |
| 1969 LibraryDependency(this.uri, | 2000 LibraryDependency(this.uri, |
| 2001 this.conditionalUris, | |
| 1970 this.combinators, | 2002 this.combinators, |
| 1971 List<MetadataAnnotation> metadata) | 2003 List<MetadataAnnotation> metadata) |
| 1972 : super(metadata); | 2004 : super(metadata); |
| 1973 | 2005 |
| 1974 LibraryDependency asLibraryDependency() => this; | 2006 LibraryDependency asLibraryDependency() => this; |
| 2007 | |
| 2008 bool get hasConditionalUris => conditionalUris != null; | |
| 1975 } | 2009 } |
| 1976 | 2010 |
| 1977 /** | 2011 /** |
| 1978 * An [:import:] library tag. | 2012 * An [:import:] library tag. |
| 1979 * | 2013 * |
| 1980 * An import tag is dependency on another library where the exported identifiers | 2014 * An import tag is dependency on another library where the exported identifiers |
| 1981 * are put into the import scope of the importing library. The import scope is | 2015 * are put into the import scope of the importing library. The import scope is |
| 1982 * only visible inside the library. | 2016 * only visible inside the library. |
| 1983 */ | 2017 */ |
| 1984 class Import extends LibraryDependency { | 2018 class Import extends LibraryDependency { |
| 1985 final Identifier prefix; | 2019 final Identifier prefix; |
| 1986 final Token importKeyword; | 2020 final Token importKeyword; |
| 1987 final bool isDeferred; | 2021 final bool isDeferred; |
| 1988 | 2022 |
| 1989 Import(this.importKeyword, StringNode uri, | 2023 Import(this.importKeyword, StringNode uri, NodeList conditionalUris, |
| 1990 this.prefix, NodeList combinators, | 2024 this.prefix, NodeList combinators, |
| 1991 List<MetadataAnnotation> metadata, | 2025 List<MetadataAnnotation> metadata, |
| 1992 {this.isDeferred}) | 2026 {this.isDeferred}) |
| 1993 : super(uri, combinators, metadata); | 2027 : super(uri, conditionalUris, combinators, metadata); |
| 1994 | 2028 |
| 1995 bool get isImport => true; | 2029 bool get isImport => true; |
| 1996 | 2030 |
| 1997 Import asImport() => this; | 2031 Import asImport() => this; |
| 1998 | 2032 |
| 1999 accept(Visitor visitor) => visitor.visitImport(this); | 2033 accept(Visitor visitor) => visitor.visitImport(this); |
| 2000 | 2034 |
| 2001 visitChildren(Visitor visitor) { | 2035 visitChildren(Visitor visitor) { |
| 2002 uri.accept(visitor); | 2036 uri.accept(visitor); |
| 2003 if (prefix != null) prefix.accept(visitor); | 2037 if (prefix != null) prefix.accept(visitor); |
| 2004 if (combinators != null) combinators.accept(visitor); | 2038 if (combinators != null) combinators.accept(visitor); |
| 2005 } | 2039 } |
| 2006 | 2040 |
| 2007 Token getBeginToken() => importKeyword; | 2041 Token getBeginToken() => importKeyword; |
| 2008 | 2042 |
| 2009 Token getEndToken() { | 2043 Token getEndToken() { |
| 2010 if (combinators != null) return combinators.getEndToken().next; | 2044 if (combinators != null) return combinators.getEndToken().next; |
| 2011 if (prefix != null) return prefix.getEndToken().next; | 2045 if (prefix != null) return prefix.getEndToken().next; |
| 2046 if (conditionalUris != null) return conditionalUris.getEndToken().next; | |
| 2012 return uri.getEndToken().next; | 2047 return uri.getEndToken().next; |
| 2013 } | 2048 } |
| 2014 } | 2049 } |
| 2015 | 2050 |
| 2016 /** | 2051 /** |
| 2052 * A conditional uri inside an import or export clause. | |
| 2053 * | |
| 2054 * Example: | |
| 2055 * | |
| 2056 * import 'foo.dart' | |
| 2057 * if (some.condition == "someValue") 'bar.dart' | |
| 2058 * if (other.condition) 'gee.dart'; | |
| 2059 */ | |
| 2060 class ConditionalUri extends Node { | |
| 2061 final Token ifToken; | |
| 2062 final DottedName key; | |
| 2063 // Value may be null. | |
| 2064 final LiteralString value; | |
| 2065 final StringNode uri; | |
| 2066 | |
| 2067 ConditionalUri(this.ifToken, this.key, this.value, this.uri); | |
| 2068 | |
| 2069 ConditionalUri asConditionalUri() => this; | |
| 2070 | |
| 2071 accept(Visitor visitor) => visitor.visitConditionalUri(this); | |
| 2072 | |
| 2073 visitChildren(Visitor visitor) { | |
| 2074 key.accept(visitor); | |
| 2075 if (value != null) value.accept(visitor); | |
| 2076 uri.accept(visitor); | |
| 2077 } | |
| 2078 | |
| 2079 Token getBeginToken() => ifToken; | |
| 2080 | |
| 2081 Token getEndToken() => uri.getEndToken(); | |
| 2082 } | |
| 2083 | |
| 2084 /** | |
| 2017 * An `enum` declaration. | 2085 * An `enum` declaration. |
| 2018 * | 2086 * |
| 2019 * An `enum` defines a number of named constants inside a non-extensible class | 2087 * An `enum` defines a number of named constants inside a non-extensible class |
| 2020 */ | 2088 */ |
| 2021 class Enum extends Node { | 2089 class Enum extends Node { |
| 2022 /** The name of the enum class. */ | 2090 /** The name of the enum class. */ |
| 2023 final Identifier name; | 2091 final Identifier name; |
| 2024 /** The names of the enum constants. */ | 2092 /** The names of the enum constants. */ |
| 2025 final NodeList names; | 2093 final NodeList names; |
| 2026 final Token enumToken; | 2094 final Token enumToken; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2045 * | 2113 * |
| 2046 * An export tag is dependency on another library where the exported identifiers | 2114 * An export tag is dependency on another library where the exported identifiers |
| 2047 * are put into the export scope of the exporting library. The export scope is | 2115 * are put into the export scope of the exporting library. The export scope is |
| 2048 * not visible inside the library. | 2116 * not visible inside the library. |
| 2049 */ | 2117 */ |
| 2050 class Export extends LibraryDependency { | 2118 class Export extends LibraryDependency { |
| 2051 final Token exportKeyword; | 2119 final Token exportKeyword; |
| 2052 | 2120 |
| 2053 Export(this.exportKeyword, | 2121 Export(this.exportKeyword, |
| 2054 StringNode uri, | 2122 StringNode uri, |
| 2123 NodeList conditionalUris, | |
| 2055 NodeList combinators, | 2124 NodeList combinators, |
| 2056 List<MetadataAnnotation> metadata) | 2125 List<MetadataAnnotation> metadata) |
| 2057 : super(uri, combinators, metadata); | 2126 : super(uri, conditionalUris, combinators, metadata); |
| 2058 | 2127 |
| 2059 bool get isExport => true; | 2128 bool get isExport => true; |
| 2060 | 2129 |
| 2061 Export asExport() => this; | 2130 Export asExport() => this; |
| 2062 | 2131 |
| 2063 accept(Visitor visitor) => visitor.visitExport(this); | 2132 accept(Visitor visitor) => visitor.visitExport(this); |
| 2064 | 2133 |
| 2065 visitChildren(Visitor visitor) { | 2134 visitChildren(Visitor visitor) { |
| 2066 uri.accept(visitor); | 2135 uri.accept(visitor); |
| 2067 if (combinators != null) combinators.accept(visitor); | 2136 if (combinators != null) combinators.accept(visitor); |
| 2068 } | 2137 } |
| 2069 | 2138 |
| 2070 Token getBeginToken() => exportKeyword; | 2139 Token getBeginToken() => exportKeyword; |
| 2071 | 2140 |
| 2072 Token getEndToken() { | 2141 Token getEndToken() { |
| 2073 if (combinators != null) return combinators.getEndToken().next; | 2142 if (combinators != null) return combinators.getEndToken().next; |
| 2143 if (conditionalUris != null) return conditionalUris.getEndToken().next; | |
| 2074 return uri.getEndToken().next; | 2144 return uri.getEndToken().next; |
| 2075 } | 2145 } |
| 2076 } | 2146 } |
| 2077 | 2147 |
| 2078 class Part extends LibraryTag { | 2148 class Part extends LibraryTag { |
| 2079 final StringNode uri; | 2149 final StringNode uri; |
| 2080 | 2150 |
| 2081 final Token partKeyword; | 2151 final Token partKeyword; |
| 2082 | 2152 |
| 2083 Part(this.partKeyword, this.uri, List<MetadataAnnotation> metadata) | 2153 Part(this.partKeyword, this.uri, List<MetadataAnnotation> metadata) |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2373 | 2443 |
| 2374 // VariableDefinitions. | 2444 // VariableDefinitions. |
| 2375 get metadata => null; | 2445 get metadata => null; |
| 2376 get type => null; | 2446 get type => null; |
| 2377 | 2447 |
| 2378 // Typedef. | 2448 // Typedef. |
| 2379 get typeParameters => null; | 2449 get typeParameters => null; |
| 2380 get formals => null; | 2450 get formals => null; |
| 2381 get typedefKeyword => null; | 2451 get typedefKeyword => null; |
| 2382 } | 2452 } |
| OLD | NEW |