| 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.kernel_library_builder; | 5 library fasta.kernel_library_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart'; | 7 import 'package:kernel/ast.dart'; |
| 8 | 8 |
| 9 import 'package:kernel/clone.dart' show CloneVisitor; | 9 import 'package:kernel/clone.dart' show CloneVisitor; |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void addProcedure( | 162 void addProcedure( |
| 163 List<MetadataBuilder> metadata, | 163 List<MetadataBuilder> metadata, |
| 164 int modifiers, | 164 int modifiers, |
| 165 KernelTypeBuilder returnType, | 165 KernelTypeBuilder returnType, |
| 166 String name, | 166 String name, |
| 167 List<TypeVariableBuilder> typeVariables, | 167 List<TypeVariableBuilder> typeVariables, |
| 168 List<FormalParameterBuilder> formals, | 168 List<FormalParameterBuilder> formals, |
| 169 AsyncMarker asyncModifier, | 169 AsyncMarker asyncModifier, |
| 170 ProcedureKind kind, | 170 ProcedureKind kind, |
| 171 int charOffset, | 171 int charOffset, |
| 172 int charOpenParenOffset, |
| 172 int charEndOffset, | 173 int charEndOffset, |
| 173 String nativeMethodName, | 174 String nativeMethodName, |
| 174 {bool isTopLevel}) { | 175 {bool isTopLevel}) { |
| 175 // Nested declaration began in `OutlineBuilder.beginMethod` or | 176 // Nested declaration began in `OutlineBuilder.beginMethod` or |
| 176 // `OutlineBuilder.beginTopLevelMethod`. | 177 // `OutlineBuilder.beginTopLevelMethod`. |
| 177 endNestedDeclaration().resolveTypes(typeVariables, this); | 178 endNestedDeclaration().resolveTypes(typeVariables, this); |
| 178 ProcedureBuilder procedure; | 179 ProcedureBuilder procedure; |
| 179 if (!isTopLevel && isConstructorName(name, currentDeclaration.name)) { | 180 if (!isTopLevel && isConstructorName(name, currentDeclaration.name)) { |
| 180 name = computeConstructorName(name); | 181 name = computeConstructorName(name); |
| 181 procedure = new KernelConstructorBuilder( | 182 procedure = new KernelConstructorBuilder( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 194 metadata, | 195 metadata, |
| 195 modifiers, | 196 modifiers, |
| 196 returnType, | 197 returnType, |
| 197 name, | 198 name, |
| 198 typeVariables, | 199 typeVariables, |
| 199 formals, | 200 formals, |
| 200 asyncModifier, | 201 asyncModifier, |
| 201 kind, | 202 kind, |
| 202 this, | 203 this, |
| 203 charOffset, | 204 charOffset, |
| 205 charOpenParenOffset, |
| 204 charEndOffset, | 206 charEndOffset, |
| 205 nativeMethodName); | 207 nativeMethodName); |
| 206 } | 208 } |
| 207 addBuilder(name, procedure, charOffset); | 209 addBuilder(name, procedure, charOffset); |
| 208 if (nativeMethodName != null) { | 210 if (nativeMethodName != null) { |
| 209 addNativeMethod(procedure); | 211 addNativeMethod(procedure); |
| 210 } | 212 } |
| 211 } | 213 } |
| 212 | 214 |
| 213 void addFactoryMethod( | 215 void addFactoryMethod( |
| 214 List<MetadataBuilder> metadata, | 216 List<MetadataBuilder> metadata, |
| 215 int modifiers, | 217 int modifiers, |
| 216 ConstructorReferenceBuilder constructorName, | 218 ConstructorReferenceBuilder constructorName, |
| 217 List<FormalParameterBuilder> formals, | 219 List<FormalParameterBuilder> formals, |
| 218 AsyncMarker asyncModifier, | 220 AsyncMarker asyncModifier, |
| 219 ConstructorReferenceBuilder redirectionTarget, | 221 ConstructorReferenceBuilder redirectionTarget, |
| 220 int charOffset, | 222 int charOffset, |
| 223 int charOpenParenOffset, |
| 221 int charEndOffset, | 224 int charEndOffset, |
| 222 String nativeMethodName) { | 225 String nativeMethodName) { |
| 223 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. | 226 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. |
| 224 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = | 227 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = |
| 225 endNestedDeclaration(); | 228 endNestedDeclaration(); |
| 226 String name = constructorName.name; | 229 String name = constructorName.name; |
| 227 if (isConstructorName(name, currentDeclaration.name)) { | 230 if (isConstructorName(name, currentDeclaration.name)) { |
| 228 name = computeConstructorName(name); | 231 name = computeConstructorName(name); |
| 229 } | 232 } |
| 230 assert(constructorName.suffix == null); | 233 assert(constructorName.suffix == null); |
| 231 KernelProcedureBuilder procedure = new KernelProcedureBuilder( | 234 KernelProcedureBuilder procedure = new KernelProcedureBuilder( |
| 232 metadata, | 235 metadata, |
| 233 staticMask | modifiers, | 236 staticMask | modifiers, |
| 234 null, | 237 null, |
| 235 name, | 238 name, |
| 236 <TypeVariableBuilder>[], | 239 <TypeVariableBuilder>[], |
| 237 formals, | 240 formals, |
| 238 asyncModifier, | 241 asyncModifier, |
| 239 ProcedureKind.Factory, | 242 ProcedureKind.Factory, |
| 240 this, | 243 this, |
| 241 charOffset, | 244 charOffset, |
| 245 charOpenParenOffset, |
| 242 charEndOffset, | 246 charEndOffset, |
| 243 nativeMethodName, | 247 nativeMethodName, |
| 244 redirectionTarget); | 248 redirectionTarget); |
| 245 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration); | 249 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration); |
| 246 addBuilder(name, procedure, charOffset); | 250 addBuilder(name, procedure, charOffset); |
| 247 if (nativeMethodName != null) { | 251 if (nativeMethodName != null) { |
| 248 addNativeMethod(procedure); | 252 addNativeMethod(procedure); |
| 249 } | 253 } |
| 250 } | 254 } |
| 251 | 255 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 437 } |
| 434 } | 438 } |
| 435 | 439 |
| 436 bool isConstructorName(String name, String className) { | 440 bool isConstructorName(String name, String className) { |
| 437 if (name.startsWith(className)) { | 441 if (name.startsWith(className)) { |
| 438 if (name.length == className.length) return true; | 442 if (name.length == className.length) return true; |
| 439 if (name.startsWith(".", className.length)) return true; | 443 if (name.startsWith(".", className.length)) return true; |
| 440 } | 444 } |
| 441 return false; | 445 return false; |
| 442 } | 446 } |
| OLD | NEW |