< prev index next >

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/TypeClass.java

Print this page
*** 23,14 ***
   * questions.
   */
  package jdk.internal.foreign.abi.x64.sysv;
  
  import jdk.incubator.foreign.GroupLayout;
  import jdk.incubator.foreign.MemoryLayout;
  import jdk.incubator.foreign.SequenceLayout;
  import jdk.incubator.foreign.ValueLayout;
- import jdk.internal.foreign.PlatformLayouts;
  import jdk.internal.foreign.Utils;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.stream.Collectors;
--- 23,14 ---
   * questions.
   */
  package jdk.internal.foreign.abi.x64.sysv;
  
  import jdk.incubator.foreign.GroupLayout;
+ import jdk.incubator.foreign.MemoryAddress;
  import jdk.incubator.foreign.MemoryLayout;
  import jdk.incubator.foreign.SequenceLayout;
  import jdk.incubator.foreign.ValueLayout;
  import jdk.internal.foreign.Utils;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.stream.Collectors;

*** 105,15 ***
                  .mapToObj(i -> ArgumentClassImpl.MEMORY)
                  .collect(Collectors.toCollection(ArrayList::new));
      }
  
      private static ArgumentClassImpl argumentClassFor(MemoryLayout layout) {
!         return switch (PlatformLayouts.getKind(layout)) {
!             case CHAR, SHORT, INT, LONG, LONG_LONG -> ArgumentClassImpl.INTEGER;
!             case FLOAT, DOUBLE -> ArgumentClassImpl.SSE;
!             case POINTER -> ArgumentClassImpl.POINTER;
!         };
      }
  
      // TODO: handle zero length arrays
      private static List<ArgumentClassImpl> classifyStructType(GroupLayout type) {
          List<ArgumentClassImpl>[] eightbytes = groupByEightBytes(type);
--- 105,21 ---
                  .mapToObj(i -> ArgumentClassImpl.MEMORY)
                  .collect(Collectors.toCollection(ArrayList::new));
      }
  
      private static ArgumentClassImpl argumentClassFor(MemoryLayout layout) {
!         Class<?> carrier = ((ValueLayout)layout).carrier();
!         if (carrier == boolean.class || carrier == byte.class || carrier == char.class ||
!                 carrier == short.class || carrier == int.class || carrier == long.class) {
!             return ArgumentClassImpl.INTEGER;
!         } else if (carrier == float.class || carrier == double.class) {
+             return ArgumentClassImpl.SSE;
+         } else if (carrier == MemoryAddress.class) {
+             return ArgumentClassImpl.POINTER;
+         } else {
+             throw new IllegalStateException("Cannot get here: " + carrier.getName());
+         }
      }
  
      // TODO: handle zero length arrays
      private static List<ArgumentClassImpl> classifyStructType(GroupLayout type) {
          List<ArgumentClassImpl>[] eightbytes = groupByEightBytes(type);
< prev index next >