use of com.oracle.svm.hosted.c.info.SizableInfo.ElementKind in project graal by oracle.
the class InfoTreeBuilder method createEnumValueInfo.
private void createEnumValueInfo(EnumInfo enumInfo, ResolvedJavaMethod method) {
if (!Modifier.isNative(method.getModifiers()) || Modifier.isStatic(method.getModifiers())) {
nativeLibs.addError("Method annotated with @" + CEnumValue.class.getSimpleName() + " must be a non-static native method", method);
return;
}
if (method.getSignature().getParameterCount(false) != 0) {
nativeLibs.addError("Method annotated with @" + CEnumValue.class.getSimpleName() + " cannot have parameters", method);
return;
}
ElementKind elementKind = elementKind((ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass()));
if (elementKind != ElementKind.INTEGER) {
nativeLibs.addError("Method annotated with @" + CEnumValue.class.getSimpleName() + " must have an integer return type", method);
return;
}
EnumValueInfo valueInfo = new EnumValueInfo(method);
enumInfo.adoptChild(valueInfo);
nativeLibs.registerElementInfo(method, valueInfo);
}
use of com.oracle.svm.hosted.c.info.SizableInfo.ElementKind in project graal by oracle.
the class InfoTreeBuilder method createConstantInfo.
protected void createConstantInfo(ResolvedJavaMethod method) {
int actualParamCount = method.getSignature().getParameterCount(false);
if (actualParamCount != 0) {
nativeLibs.addError("Wrong number of parameters: expected 0; found " + actualParamCount, method);
return;
}
ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
if (returnType.getJavaKind() == JavaKind.Void || (returnType.getJavaKind() == JavaKind.Object && !nativeLibs.isString(returnType) && !nativeLibs.isByteArray(returnType) && !nativeLibs.isWordBase(returnType))) {
nativeLibs.addError("Wrong return type: expected a primitive type, String, or a Word type; found " + returnType.toJavaName(true), method);
return;
}
String constantName = getConstantName(method);
ElementKind elementKind = elementKind(returnType);
ConstantInfo constantInfo = new ConstantInfo(constantName, elementKind, method);
nativeCodeInfo.adoptChild(constantInfo);
nativeLibs.registerElementInfo(method, constantInfo);
}
use of com.oracle.svm.hosted.c.info.SizableInfo.ElementKind in project graal by oracle.
the class InfoTreeBuilder method elementKind.
private ElementKind elementKind(Collection<AccessorInfo> accessorInfos) {
ElementKind overallKind = ElementKind.UNKNOWN;
AccessorInfo overallKindAccessor = null;
for (AccessorInfo accessorInfo : accessorInfos) {
ResolvedJavaMethod method = (ResolvedJavaMethod) accessorInfo.getAnnotatedElement();
ElementKind newKind;
switch(accessorInfo.getAccessorKind()) {
case GETTER:
newKind = elementKind((ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass()));
break;
case SETTER:
newKind = elementKind((ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.valueParameterNumber(false), method.getDeclaringClass()));
break;
default:
continue;
}
if (overallKind == ElementKind.UNKNOWN) {
overallKind = newKind;
overallKindAccessor = accessorInfo;
} else if (overallKind != newKind) {
nativeLibs.addError("Accessor methods mix integer, floating point, and pointer kinds", overallKindAccessor.getAnnotatedElement(), method);
}
}
return overallKind;
}
Aggregations