| 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( |
| 182 metadata, | 183 metadata, |
| 183 modifiers & ~abstractMask, | 184 modifiers & ~abstractMask, |
| 184 returnType, | 185 returnType, |
| 185 name, | 186 name, |
| 186 typeVariables, | 187 typeVariables, |
| 187 formals, | 188 formals, |
| 188 this, | 189 this, |
| 189 charOffset, | 190 charOffset, |
| 191 charOpenParenOffset, |
| 190 charEndOffset, | 192 charEndOffset, |
| 191 nativeMethodName); | 193 nativeMethodName); |
| 192 } else { | 194 } else { |
| 193 procedure = new KernelProcedureBuilder( | 195 procedure = new KernelProcedureBuilder( |
| 194 metadata, | 196 metadata, |
| 195 modifiers, | 197 modifiers, |
| 196 returnType, | 198 returnType, |
| 197 name, | 199 name, |
| 198 typeVariables, | 200 typeVariables, |
| 199 formals, | 201 formals, |
| 200 asyncModifier, | 202 asyncModifier, |
| 201 kind, | 203 kind, |
| 202 this, | 204 this, |
| 203 charOffset, | 205 charOffset, |
| 206 charOpenParenOffset, |
| 204 charEndOffset, | 207 charEndOffset, |
| 205 nativeMethodName); | 208 nativeMethodName); |
| 206 } | 209 } |
| 207 addBuilder(name, procedure, charOffset); | 210 addBuilder(name, procedure, charOffset); |
| 208 if (nativeMethodName != null) { | 211 if (nativeMethodName != null) { |
| 209 addNativeMethod(procedure); | 212 addNativeMethod(procedure); |
| 210 } | 213 } |
| 211 } | 214 } |
| 212 | 215 |
| 213 void addFactoryMethod( | 216 void addFactoryMethod( |
| 214 List<MetadataBuilder> metadata, | 217 List<MetadataBuilder> metadata, |
| 215 int modifiers, | 218 int modifiers, |
| 216 ConstructorReferenceBuilder constructorName, | 219 ConstructorReferenceBuilder constructorName, |
| 217 List<FormalParameterBuilder> formals, | 220 List<FormalParameterBuilder> formals, |
| 218 AsyncMarker asyncModifier, | 221 AsyncMarker asyncModifier, |
| 219 ConstructorReferenceBuilder redirectionTarget, | 222 ConstructorReferenceBuilder redirectionTarget, |
| 220 int charOffset, | 223 int charOffset, |
| 224 int charOpenParenOffset, |
| 221 int charEndOffset, | 225 int charEndOffset, |
| 222 String nativeMethodName) { | 226 String nativeMethodName) { |
| 223 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. | 227 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. |
| 224 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = | 228 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = |
| 225 endNestedDeclaration(); | 229 endNestedDeclaration(); |
| 226 String name = constructorName.name; | 230 String name = constructorName.name; |
| 227 if (isConstructorName(name, currentDeclaration.name)) { | 231 if (isConstructorName(name, currentDeclaration.name)) { |
| 228 name = computeConstructorName(name); | 232 name = computeConstructorName(name); |
| 229 } | 233 } |
| 230 assert(constructorName.suffix == null); | 234 assert(constructorName.suffix == null); |
| 231 KernelProcedureBuilder procedure = new KernelProcedureBuilder( | 235 KernelProcedureBuilder procedure = new KernelProcedureBuilder( |
| 232 metadata, | 236 metadata, |
| 233 staticMask | modifiers, | 237 staticMask | modifiers, |
| 234 null, | 238 null, |
| 235 name, | 239 name, |
| 236 <TypeVariableBuilder>[], | 240 <TypeVariableBuilder>[], |
| 237 formals, | 241 formals, |
| 238 asyncModifier, | 242 asyncModifier, |
| 239 ProcedureKind.Factory, | 243 ProcedureKind.Factory, |
| 240 this, | 244 this, |
| 241 charOffset, | 245 charOffset, |
| 246 charOpenParenOffset, |
| 242 charEndOffset, | 247 charEndOffset, |
| 243 nativeMethodName, | 248 nativeMethodName, |
| 244 redirectionTarget); | 249 redirectionTarget); |
| 245 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration); | 250 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration); |
| 246 addBuilder(name, procedure, charOffset); | 251 addBuilder(name, procedure, charOffset); |
| 247 if (nativeMethodName != null) { | 252 if (nativeMethodName != null) { |
| 248 addNativeMethod(procedure); | 253 addNativeMethod(procedure); |
| 249 } | 254 } |
| 250 } | 255 } |
| 251 | 256 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 432 } |
| 428 } | 433 } |
| 429 | 434 |
| 430 bool isConstructorName(String name, String className) { | 435 bool isConstructorName(String name, String className) { |
| 431 if (name.startsWith(className)) { | 436 if (name.startsWith(className)) { |
| 432 if (name.length == className.length) return true; | 437 if (name.length == className.length) return true; |
| 433 if (name.startsWith(".", className.length)) return true; | 438 if (name.startsWith(".", className.length)) return true; |
| 434 } | 439 } |
| 435 return false; | 440 return false; |
| 436 } | 441 } |
| OLD | NEW |