Fixing a subtle bug: the method isParameterWithType() did not consider arbitrary...
[jpf-core.git] / src / main / gov / nasa / jpf / jvm / JVMDirectCallStackFrame.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18
19 package gov.nasa.jpf.jvm;
20
21 import gov.nasa.jpf.vm.DirectCallStackFrame;
22 import gov.nasa.jpf.vm.MethodInfo;
23
24 /**
25  * a direct call stackframe that supports JVM calling conventions
26  */
27 public class JVMDirectCallStackFrame extends DirectCallStackFrame {
28   
29   JVMDirectCallStackFrame (MethodInfo miDirectCall, MethodInfo callee){
30     super( miDirectCall, callee);
31   }
32
33   //--- return value handling
34   
35   @Override
36   public int getResult(){
37     return pop();
38   }
39   
40   @Override
41   public int getReferenceResult(){
42     return pop();
43   }
44   
45   @Override
46   public long getLongResult(){
47     return popLong();
48   }
49
50   @Override
51   public Object getResultAttr(){
52     return getOperandAttr();
53   }
54   
55   @Override
56   public Object getLongResultAttr(){
57     return getLongOperandAttr();
58   }
59
60   @Override
61   public void setExceptionReference (int exRef){
62     clearOperandStack();
63     pushRef( exRef);
64   }
65   
66   @Override
67   public int getExceptionReference(){
68     return pop();
69   }
70
71   @Override
72   public void setExceptionReferenceAttribute (Object attr){
73     setOperandAttr(attr);
74   }
75   
76   @Override
77   public Object getExceptionReferenceAttribute (){
78     return getOperandAttr();
79   }
80   
81   //--- direct call argument initialization
82   // NOTE - we don't support out-of-order arguments yet, i.e. the slotIdx is ignored
83   
84   
85   @Override
86   public int setArgument (int slotIdx, int v, Object attr){
87     push(v);
88     if (attr != null){
89       setOperandAttr(attr);
90     }
91     
92     return slotIdx+1;
93   }
94   
95   @Override
96   public int setReferenceArgument (int slotIdx, int ref, Object attr){
97     pushRef(ref);
98     if (attr != null){
99       setOperandAttr(attr);
100     }
101     
102     return slotIdx+1;
103   }
104   
105   @Override
106   public int setLongArgument (int slotIdx, long v, Object attr){
107     pushLong(v);
108     if (attr != null){
109       setLongOperandAttr(attr);
110     } 
111     
112     return slotIdx+2;
113   }
114   
115   //--- DirectCallStackFrame methods don't have arguments
116   
117   @Override
118   public void setArgumentLocal (int argIdx, int v, Object attr){
119     throw new UnsupportedOperationException("direct call methods don't have arguments");
120   }
121   @Override
122   public void setReferenceArgumentLocal (int argIdx, int v, Object attr){
123     throw new UnsupportedOperationException("direct call methods don't have arguments");
124   }
125   @Override
126   public void setLongArgumentLocal (int argIdx, long v, Object attr){
127     throw new UnsupportedOperationException("direct call methods don't have arguments");
128   }
129 }