Skip to content

Commit

Permalink
Generate better bytecode for primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Sep 27, 2021
1 parent c3c9983 commit ac35794
Showing 1 changed file with 8 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,22 +659,6 @@ ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle ar
return method.load((String) param);
}
};
} else if (param instanceof Integer) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Integer.class, "valueOf", Integer.class, int.class),
method.load((Integer) param));
}
};
} else if (param instanceof Boolean) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Boolean.class, "valueOf", Boolean.class, boolean.class),
method.load((Boolean) param));
}
};
} else if (param instanceof URL) {
String url = ((URL) param).toExternalForm();
return new DeferredParameter() {
Expand Down Expand Up @@ -757,126 +741,62 @@ ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle ar
}
};
}
} else if (expectedType == boolean.class) {
} else if (expectedType == boolean.class || expectedType == Boolean.class || param instanceof Boolean) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((boolean) param);
}
};
} else if (expectedType == Boolean.class) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Boolean.class, "valueOf", Boolean.class, boolean.class),
method.load((boolean) param));
}
};
} else if (expectedType == int.class) {
} else if (expectedType == int.class || expectedType == Integer.class || param instanceof Integer) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((int) param);
}
};
} else if (expectedType == Integer.class) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Integer.class, "valueOf", Integer.class, int.class),
method.load((int) param));
}
};
} else if (expectedType == short.class) {
} else if (expectedType == short.class || expectedType == Short.class || param instanceof Short) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((short) param);
}
};
} else if (expectedType == Short.class || param instanceof Short) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Short.class, "valueOf", Short.class, short.class),
method.load((short) param));
}
};
} else if (expectedType == byte.class) {
} else if (expectedType == byte.class || expectedType == Byte.class || param instanceof Byte) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((byte) param);
}
};
} else if (expectedType == Byte.class || param instanceof Byte) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Byte.class, "valueOf", Byte.class, byte.class),
method.load((byte) param));
}
};
} else if (expectedType == char.class) {
} else if (expectedType == char.class || expectedType == Character.class || param instanceof Character) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((char) param);
}
};
} else if (expectedType == Character.class || param instanceof Character) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Character.class, "valueOf", Character.class, char.class),
method.load((char) param));
}
};
} else if (expectedType == long.class) {
} else if (expectedType == long.class || expectedType == Long.class || param instanceof Long) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((long) param);
}
};
} else if (expectedType == Long.class || param instanceof Long) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Long.class, "valueOf", Long.class, long.class),
method.load((long) param));
}
};
} else if (expectedType == float.class) {
} else if (expectedType == float.class || expectedType == Float.class || param instanceof Float) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((float) param);
}
};
} else if (expectedType == Float.class || param instanceof Float) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Float.class, "valueOf", Float.class, float.class),
method.load((float) param));
}
};
} else if (expectedType == double.class) {
} else if (expectedType == double.class || expectedType == Double.class || param instanceof Double) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.load((double) param);
}
};
} else if (expectedType == Double.class || param instanceof Double) {
return new DeferredParameter() {
@Override
ResultHandle doLoad(MethodContext context, MethodCreator method, ResultHandle array) {
return method.invokeStaticMethod(ofMethod(Double.class, "valueOf", Double.class, double.class),
method.load((double) param));
}
};
} else if (expectedType.isArray()) {
int length = Array.getLength(param);
DeferredParameter[] components = new DeferredParameter[length];
Expand Down

0 comments on commit ac35794

Please sign in to comment.