< prev index next >

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/CallingSequence.java

Print this page

 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package jdk.internal.foreign.abi;
 26 
 27 import jdk.incubator.foreign.FunctionDescriptor;
 28 
 29 import java.lang.invoke.MethodType;
 30 import java.util.List;
 31 import java.util.stream.Stream;
 32 
 33 public class CallingSequence {
 34     private final MethodType mt;
 35     private final FunctionDescriptor desc;
 36     private final boolean isTrivial;



 37 
 38     private final List<Binding> returnBindings;
 39     private final List<List<Binding>> argumentBindings;
 40 
 41     public CallingSequence(MethodType mt, FunctionDescriptor desc,
 42                            boolean isTrivial, List<List<Binding>> argumentBindings, List<Binding> returnBindings) {

 43         this.mt = mt;
 44         this.desc = desc;
 45         this.isTrivial = isTrivial;



 46         this.returnBindings = returnBindings;
 47         this.argumentBindings = argumentBindings;
 48     }
 49 
 50     public int argumentCount() {
 51         return argumentBindings.size();
 52     }
 53 
 54     public List<Binding> argumentBindings(int i) {
 55         return argumentBindings.get(i);
 56     }
 57 
 58     public Stream<Binding> argumentBindings() {
 59         return argumentBindings.stream().flatMap(List::stream);
 60     }
 61 
 62     public List<Binding> returnBindings() {
 63         return returnBindings;
 64     }
 65 

 75         }
 76         if (mt.returnType() != void.class) {
 77             sb.append("    ").append("Return: ").append(returnBindings).append("\n");
 78         }
 79         sb.append("}\n");
 80 
 81         return sb.toString();
 82     }
 83 
 84     public MethodType methodType() {
 85         return mt;
 86     }
 87 
 88     public FunctionDescriptor functionDesc() {
 89         return desc;
 90     }
 91 
 92     public boolean isTrivial() {
 93         return isTrivial;
 94     }












 95 }

 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package jdk.internal.foreign.abi;
 26 
 27 import jdk.incubator.foreign.FunctionDescriptor;
 28 
 29 import java.lang.invoke.MethodType;
 30 import java.util.List;
 31 import java.util.stream.Stream;
 32 
 33 public class CallingSequence {
 34     private final MethodType mt;
 35     private final FunctionDescriptor desc;
 36     private final boolean isTrivial;
 37     private final boolean needsReturnBuffer;
 38     private final long returnBufferSize;
 39     private final long allocationSize;
 40 
 41     private final List<Binding> returnBindings;
 42     private final List<List<Binding>> argumentBindings;
 43 
 44     public CallingSequence(MethodType mt, FunctionDescriptor desc,
 45                            boolean isTrivial, boolean needsReturnBuffer, long returnBufferSize, long allocationSize,
 46                            List<List<Binding>> argumentBindings, List<Binding> returnBindings) {
 47         this.mt = mt;
 48         this.desc = desc;
 49         this.isTrivial = isTrivial;
 50         this.needsReturnBuffer = needsReturnBuffer;
 51         this.returnBufferSize = returnBufferSize;
 52         this.allocationSize = allocationSize;
 53         this.returnBindings = returnBindings;
 54         this.argumentBindings = argumentBindings;
 55     }
 56 
 57     public int argumentCount() {
 58         return argumentBindings.size();
 59     }
 60 
 61     public List<Binding> argumentBindings(int i) {
 62         return argumentBindings.get(i);
 63     }
 64 
 65     public Stream<Binding> argumentBindings() {
 66         return argumentBindings.stream().flatMap(List::stream);
 67     }
 68 
 69     public List<Binding> returnBindings() {
 70         return returnBindings;
 71     }
 72 

 82         }
 83         if (mt.returnType() != void.class) {
 84             sb.append("    ").append("Return: ").append(returnBindings).append("\n");
 85         }
 86         sb.append("}\n");
 87 
 88         return sb.toString();
 89     }
 90 
 91     public MethodType methodType() {
 92         return mt;
 93     }
 94 
 95     public FunctionDescriptor functionDesc() {
 96         return desc;
 97     }
 98 
 99     public boolean isTrivial() {
100         return isTrivial;
101     }
102 
103     public boolean needsReturnBuffer() {
104         return needsReturnBuffer;
105     }
106 
107     public long returnBufferSize() {
108         return returnBufferSize;
109     }
110 
111     public long allocationSize() {
112         return allocationSize;
113     }
114 }
< prev index next >