buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java

Print this page
rev 745 : 8029332: Do not require nasgen-generated functions to return Object
Reviewed-by: lagergren, jlaskey, hannesw


 262             }
 263 
 264             if (argTypes.length > 2) {
 265                 for (int i = 2; i < argTypes.length - 1; i++) {
 266                     if (! argTypes[i].toString().equals(OBJECT_DESC)) {
 267                         error(i + "'th argument should be of Object type, found " + argTypes[i]);
 268                     }
 269                 }
 270 
 271                 final String lastArgType = argTypes[argTypes.length - 1].toString();
 272                 final boolean isVarArg = lastArgType.equals(OBJECT_ARRAY_DESC);
 273                 if (!lastArgType.equals(OBJECT_DESC) && !isVarArg) {
 274                     error("last argument is neither Object nor Object[] type: " + lastArgType);
 275                 }
 276 
 277                 if (isVarArg && argTypes.length > 3) {
 278                     error("vararg constructor has more than 3 arguments");
 279                 }
 280             }
 281         } else if (kind == Kind.FUNCTION) {
 282             final Type returnType = Type.getReturnType(javaDesc);
 283             if (! returnType.toString().equals(OBJECT_DESC)) {
 284                 error("return value should be of Object type, found" + returnType);
 285             }
 286             final Type[] argTypes = Type.getArgumentTypes(javaDesc);
 287             if (argTypes.length < 1) {
 288                 error("function methods should have at least 1 arg");
 289             }
 290             if (! argTypes[0].toString().equals(OBJECT_DESC)) {
 291                 error("first argument should be of Object type, found" + argTypes[0]);
 292             }
 293 
 294             if (argTypes.length > 1) {
 295                 for (int i = 1; i < argTypes.length - 1; i++) {
 296                     if (! argTypes[i].toString().equals(OBJECT_DESC)) {
 297                         error(i + "'th argument should be of Object type, found " + argTypes[i]);
 298                     }
 299                 }
 300 
 301                 final String lastArgType = argTypes[argTypes.length - 1].toString();
 302                 final boolean isVarArg = lastArgType.equals(OBJECT_ARRAY_DESC);
 303                 if (!lastArgType.equals(OBJECT_DESC) && !isVarArg) {
 304                     error("last argument is neither Object nor Object[] type: " + lastArgType);
 305                 }




 262             }
 263 
 264             if (argTypes.length > 2) {
 265                 for (int i = 2; i < argTypes.length - 1; i++) {
 266                     if (! argTypes[i].toString().equals(OBJECT_DESC)) {
 267                         error(i + "'th argument should be of Object type, found " + argTypes[i]);
 268                     }
 269                 }
 270 
 271                 final String lastArgType = argTypes[argTypes.length - 1].toString();
 272                 final boolean isVarArg = lastArgType.equals(OBJECT_ARRAY_DESC);
 273                 if (!lastArgType.equals(OBJECT_DESC) && !isVarArg) {
 274                     error("last argument is neither Object nor Object[] type: " + lastArgType);
 275                 }
 276 
 277                 if (isVarArg && argTypes.length > 3) {
 278                     error("vararg constructor has more than 3 arguments");
 279                 }
 280             }
 281         } else if (kind == Kind.FUNCTION) {




 282             final Type[] argTypes = Type.getArgumentTypes(javaDesc);
 283             if (argTypes.length < 1) {
 284                 error("function methods should have at least 1 arg");
 285             }
 286             if (! argTypes[0].toString().equals(OBJECT_DESC)) {
 287                 error("first argument should be of Object type, found" + argTypes[0]);
 288             }
 289 
 290             if (argTypes.length > 1) {
 291                 for (int i = 1; i < argTypes.length - 1; i++) {
 292                     if (! argTypes[i].toString().equals(OBJECT_DESC)) {
 293                         error(i + "'th argument should be of Object type, found " + argTypes[i]);
 294                     }
 295                 }
 296 
 297                 final String lastArgType = argTypes[argTypes.length - 1].toString();
 298                 final boolean isVarArg = lastArgType.equals(OBJECT_ARRAY_DESC);
 299                 if (!lastArgType.equals(OBJECT_DESC) && !isVarArg) {
 300                     error("last argument is neither Object nor Object[] type: " + lastArgType);
 301                 }