| OLD | NEW |
| 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.outline_builder; | 5 library fasta.outline_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' show | 7 import 'package:kernel/ast.dart' show |
| 8 AsyncMarker, | 8 AsyncMarker, |
| 9 ProcedureKind; | 9 ProcedureKind; |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 Unhandled, | 37 Unhandled, |
| 38 UnhandledListener; | 38 UnhandledListener; |
| 39 | 39 |
| 40 import '../parser/error_kind.dart' show | 40 import '../parser/error_kind.dart' show |
| 41 ErrorKind; | 41 ErrorKind; |
| 42 | 42 |
| 43 import '../parser/dart_vm_native.dart' show | 43 import '../parser/dart_vm_native.dart' show |
| 44 removeNativeClause, | 44 removeNativeClause, |
| 45 skipNativeClause; | 45 skipNativeClause; |
| 46 | 46 |
| 47 import '../operator.dart' show | |
| 48 Operator, | |
| 49 operatorFromString, | |
| 50 operatorToString; | |
| 51 | |
| 52 enum MethodBody { | 47 enum MethodBody { |
| 53 Abstract, | 48 Abstract, |
| 54 Regular, | 49 Regular, |
| 55 RedirectingFactoryBody, | 50 RedirectingFactoryBody, |
| 56 } | 51 } |
| 57 | 52 |
| 58 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { | 53 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { |
| 59 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { | 54 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { |
| 60 if (starToken == null) { | 55 if (starToken == null) { |
| 61 return AsyncMarker.Sync; | 56 return AsyncMarker.Sync; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 debugEvent("Part"); | 149 debugEvent("Part"); |
| 155 String uri = pop(); | 150 String uri = pop(); |
| 156 List<MetadataBuilder> metadata = pop(); | 151 List<MetadataBuilder> metadata = pop(); |
| 157 library.addPart(metadata, uri); | 152 library.addPart(metadata, uri); |
| 158 checkEmpty(); | 153 checkEmpty(); |
| 159 } | 154 } |
| 160 | 155 |
| 161 @override | 156 @override |
| 162 void handleOperatorName(Token operatorKeyword, Token token) { | 157 void handleOperatorName(Token operatorKeyword, Token token) { |
| 163 debugEvent("OperatorName"); | 158 debugEvent("OperatorName"); |
| 164 push(operatorFromString(token.stringValue)); | 159 push(token.stringValue); |
| 165 } | 160 } |
| 166 | 161 |
| 167 @override | 162 @override |
| 168 void endIdentifierList(int count) { | 163 void endIdentifierList(int count) { |
| 169 debugEvent("endIdentifierList"); | 164 debugEvent("endIdentifierList"); |
| 170 push(popList(count) ?? NullValue.IdentifierList); | 165 push(popList(count) ?? NullValue.IdentifierList); |
| 171 } | 166 } |
| 172 | 167 |
| 173 @override | 168 @override |
| 174 void handleQualified(Token period) { | 169 void handleQualified(Token period) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 235 |
| 241 @override | 236 @override |
| 242 void handleFunctionBodySkipped(Token token) { | 237 void handleFunctionBodySkipped(Token token) { |
| 243 debugEvent("handleFunctionBodySkipped"); | 238 debugEvent("handleFunctionBodySkipped"); |
| 244 push(MethodBody.Regular); | 239 push(MethodBody.Regular); |
| 245 } | 240 } |
| 246 | 241 |
| 247 @override | 242 @override |
| 248 void endMethod(Token getOrSet, Token beginToken, Token endToken) { | 243 void endMethod(Token getOrSet, Token beginToken, Token endToken) { |
| 249 debugEvent("Method"); | 244 debugEvent("Method"); |
| 250 MethodBody bodyKind = pop(); | 245 MethodBody kind = pop(); |
| 251 if (bodyKind == MethodBody.RedirectingFactoryBody) { | 246 if (kind == MethodBody.RedirectingFactoryBody) { |
| 252 // This will cause an error later. | 247 // This will cause an error later. |
| 253 pop(); | 248 pop(); |
| 254 } | 249 } |
| 255 AsyncMarker asyncModifier = pop(); | 250 AsyncMarker asyncModifier = pop(); |
| 256 List<FormalParameterBuilder> formals = pop(); | 251 List<FormalParameterBuilder> formals = pop(); |
| 257 List<TypeVariableBuilder> typeVariables = pop(); | 252 List<TypeVariableBuilder> typeVariables = pop(); |
| 258 dynamic nameOrOperator = pop(); | 253 String name = pop(); |
| 259 if (Operator.Subtract == nameOrOperator && formals == null) { | 254 if (identical("-", name) && formals == null) { |
| 260 nameOrOperator = Operator.UnaryMinus; | 255 name = "unary-"; |
| 261 } | |
| 262 String name; | |
| 263 ProcedureKind kind; | |
| 264 if (nameOrOperator is Operator) { | |
| 265 name = operatorToString(nameOrOperator); | |
| 266 kind = ProcedureKind.Operator; | |
| 267 } else { | |
| 268 name = nameOrOperator; | |
| 269 kind = computeProcedureKind(getOrSet); | |
| 270 } | 256 } |
| 271 TypeBuilder returnType = pop(); | 257 TypeBuilder returnType = pop(); |
| 272 int modifiers = Modifier.validate(pop(), | 258 int modifiers = Modifier.validate(pop(), |
| 273 isAbstract: bodyKind == MethodBody.Abstract); | 259 isAbstract: kind == MethodBody.Abstract); |
| 274 List<MetadataBuilder> metadata = pop(); | 260 List<MetadataBuilder> metadata = pop(); |
| 275 library.addProcedure(metadata, modifiers, returnType, name, typeVariables, | 261 library.addProcedure(metadata, modifiers, returnType, name, typeVariables, |
| 276 formals, asyncModifier, kind); | 262 formals, asyncModifier, computeProcedureKind(getOrSet)); |
| 277 } | 263 } |
| 278 | 264 |
| 279 @override | 265 @override |
| 280 void endMixinApplication() { | 266 void endMixinApplication() { |
| 281 debugEvent("MixinApplication"); | 267 debugEvent("MixinApplication"); |
| 282 List<TypeBuilder> mixins = pop(); | 268 List<TypeBuilder> mixins = pop(); |
| 283 TypeBuilder supertype = pop(); | 269 TypeBuilder supertype = pop(); |
| 284 push(library.addMixinApplication(supertype, mixins)); | 270 push(library.addMixinApplication(supertype, mixins)); |
| 285 } | 271 } |
| 286 | 272 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 Link<Token> handleMemberName(Link<Token> identifiers) { | 551 Link<Token> handleMemberName(Link<Token> identifiers) { |
| 566 if (!isDartLibrary || identifiers.isEmpty) return identifiers; | 552 if (!isDartLibrary || identifiers.isEmpty) return identifiers; |
| 567 return removeNativeClause(identifiers); | 553 return removeNativeClause(identifiers); |
| 568 } | 554 } |
| 569 | 555 |
| 570 @override | 556 @override |
| 571 void debugEvent(String name) { | 557 void debugEvent(String name) { |
| 572 // printEvent(name); | 558 // printEvent(name); |
| 573 } | 559 } |
| 574 } | 560 } |
| OLD | NEW |