< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/Utils.java

Print this page




 226 
 227     public static Function getFunction(Type t) {
 228         switch (t.kind()) {
 229             case Unexposed:
 230             case Typedef:
 231             case Elaborated:
 232                 return parseFunctionInternal(t.canonicalType());
 233             case FunctionProto:
 234             case FunctionNoProto:
 235                 return parseFunctionInternal(t);
 236             default:
 237                 throw new IllegalArgumentException(
 238                         "Unsupported type kind: " + t.kind());
 239         }
 240     }
 241 
 242     private static Function parseFunctionInternal(Type t) {
 243         final int argSize = t.numberOfArgs();
 244         Layout[] args = new Layout[argSize];
 245         for (int i = 0; i < argSize; i++) {
 246             args[i] = getLayout(t.argType(i));

 247         }
 248         if (t.resultType().kind() == TypeKind.Void) {
 249             return Function.ofVoid(t.isVariadic(), args);
 250         } else {
 251             return Function.of(getLayout(t.resultType()), t.isVariadic(), args);
 252         }
 253     }
 254 
 255     public static Layout getLayout(Type t) {
 256         switch(t.kind()) {
 257             case Bool:
 258                 return Types.BOOLEAN;
 259             case Int:
 260                 return Types.INT;
 261             case UInt:
 262                 return Types.UNSIGNED.INT;
 263             case Int128:
 264                 return Types.INT128;
 265             case UInt128:
 266                 return Types.UNSIGNED.INT128;




 226 
 227     public static Function getFunction(Type t) {
 228         switch (t.kind()) {
 229             case Unexposed:
 230             case Typedef:
 231             case Elaborated:
 232                 return parseFunctionInternal(t.canonicalType());
 233             case FunctionProto:
 234             case FunctionNoProto:
 235                 return parseFunctionInternal(t);
 236             default:
 237                 throw new IllegalArgumentException(
 238                         "Unsupported type kind: " + t.kind());
 239         }
 240     }
 241 
 242     private static Function parseFunctionInternal(Type t) {
 243         final int argSize = t.numberOfArgs();
 244         Layout[] args = new Layout[argSize];
 245         for (int i = 0; i < argSize; i++) {
 246             Layout l = getLayout(t.argType(i));
 247             args[i] = l instanceof Sequence? Address.ofLayout(64, ((Sequence)l).element()) : l;
 248         }
 249         if (t.resultType().kind() == TypeKind.Void) {
 250             return Function.ofVoid(t.isVariadic(), args);
 251         } else {
 252             return Function.of(getLayout(t.resultType()), t.isVariadic(), args);
 253         }
 254     }
 255 
 256     public static Layout getLayout(Type t) {
 257         switch(t.kind()) {
 258             case Bool:
 259                 return Types.BOOLEAN;
 260             case Int:
 261                 return Types.INT;
 262             case UInt:
 263                 return Types.UNSIGNED.INT;
 264             case Int128:
 265                 return Types.INT128;
 266             case UInt128:
 267                 return Types.UNSIGNED.INT128;


< prev index next >