1210 } |
1210 } |
1211 |
1211 |
1212 public List<VarSymbol> params() { |
1212 public List<VarSymbol> params() { |
1213 owner.complete(); |
1213 owner.complete(); |
1214 if (params == null) { |
1214 if (params == null) { |
1215 List<Name> names = savedParameterNames; |
1215 // If ClassReader.saveParameterNames has been set true, then |
|
1216 // savedParameterNames will be set to a list of names that |
|
1217 // matches the types in type.getParameterTypes(). If any names |
|
1218 // were not found in the class file, those names in the list will |
|
1219 // be set to the empty name. |
|
1220 // If ClassReader.saveParameterNames has been set false, then |
|
1221 // savedParameterNames will be null. |
|
1222 List<Name> paramNames = savedParameterNames; |
1216 savedParameterNames = null; |
1223 savedParameterNames = null; |
1217 if (names == null) { |
1224 // discard the provided names if the list of names is the wrong size. |
1218 names = List.nil(); |
1225 if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) |
1219 int i = 0; |
1226 paramNames = List.nil(); |
1220 for (Type t : type.getParameterTypes()) |
|
1221 names = names.prepend(name.table.fromString("arg" + i++)); |
|
1222 names = names.reverse(); |
|
1223 } |
|
1224 ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>(); |
1227 ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>(); |
|
1228 List<Name> remaining = paramNames; |
|
1229 // assert: remaining and paramNames are both empty or both |
|
1230 // have same cardinality as type.getParameterTypes() |
|
1231 int i = 0; |
1225 for (Type t : type.getParameterTypes()) { |
1232 for (Type t : type.getParameterTypes()) { |
1226 buf.append(new VarSymbol(PARAMETER, names.head, t, this)); |
1233 Name paramName; |
1227 names = names.tail; |
1234 if (remaining.isEmpty()) { |
|
1235 // no names for any parameters available |
|
1236 paramName = createArgName(i, paramNames); |
|
1237 } else { |
|
1238 paramName = remaining.head; |
|
1239 remaining = remaining.tail; |
|
1240 if (paramName.isEmpty()) { |
|
1241 // no name for this specific parameter |
|
1242 paramName = createArgName(i, paramNames); |
|
1243 } |
|
1244 } |
|
1245 buf.append(new VarSymbol(PARAMETER, paramName, t, this)); |
|
1246 i++; |
1228 } |
1247 } |
1229 params = buf.toList(); |
1248 params = buf.toList(); |
1230 } |
1249 } |
1231 return params; |
1250 return params; |
|
1251 } |
|
1252 |
|
1253 // Create a name for the argument at position 'index' that is not in |
|
1254 // the exclude list. In normal use, either no names will have been |
|
1255 // provided, in which case the exclude list is empty, or all the names |
|
1256 // will have been provided, in which case this method will not be called. |
|
1257 private Name createArgName(int index, List<Name> exclude) { |
|
1258 String prefix = "arg"; |
|
1259 while (true) { |
|
1260 Name argName = name.table.fromString(prefix + index); |
|
1261 if (!exclude.contains(argName)) |
|
1262 return argName; |
|
1263 prefix += "$"; |
|
1264 } |
1232 } |
1265 } |
1233 |
1266 |
1234 public Symbol asMemberOf(Type site, Types types) { |
1267 public Symbol asMemberOf(Type site, Types types) { |
1235 return new MethodSymbol(flags_field, name, types.memberType(site, this), owner); |
1268 return new MethodSymbol(flags_field, name, types.memberType(site, this), owner); |
1236 } |
1269 } |