2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
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
10 * http://www.apache.org/licenses/LICENSE-2.0.
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.
18 package gov.nasa.jpf.jvm.bytecode;
20 import gov.nasa.jpf.vm.StackFrame;
21 import gov.nasa.jpf.vm.ThreadInfo;
23 import java.util.Iterator;
26 * common base for DRETURN and LRETURN
28 public abstract class LongReturn extends JVMReturnInstruction {
33 public int getReturnTypeSize() {
38 protected Object getReturnedOperandAttr (StackFrame frame) {
39 return frame.getLongOperandAttr();
43 protected void getAndSaveReturnValue (StackFrame frame) {
44 ret = frame.popLong();
48 protected void pushReturnValue (StackFrame frame) {
52 //--- attribute accessors
55 public boolean hasReturnAttr (ThreadInfo ti){
56 StackFrame frame = ti.getTopFrame();
57 return frame.hasLongOperandAttr();
60 public boolean hasReturnAttr (ThreadInfo ti, Class<?> type){
61 StackFrame frame = ti.getTopFrame();
62 return frame.hasLongOperandAttr(type);
66 * this returns all of them - use either if you know there will be only
67 * one attribute at a time, or check/process result with ObjectList
69 * obviously, this only makes sense from an instructionExecuted(), since
70 * the value is pushed during the enter(). Use ObjectList to access values
73 public Object getReturnAttr (ThreadInfo ti){
74 StackFrame frame = ti.getTopFrame();
75 return frame.getLongOperandAttr();
79 * this replaces all of them - use only if you know
80 * - there will be only one attribute at a time
81 * - you obtained the value you set by a previous getXAttr()
82 * - you constructed a multi value list with ObjectList.createList()
84 * we don't clone since pushing a return value already changed the caller frame
87 public void setReturnAttr (ThreadInfo ti, Object a){
88 StackFrame frame = ti.getModifiableTopFrame();
89 frame.setLongOperandAttr(a);
93 * this only returns the first attr of this type, there can be more
94 * if you don't use client private types or the provided type is too general
97 public <T> T getReturnAttr (ThreadInfo ti, Class<T> type){
98 StackFrame frame = ti.getTopFrame();
99 return frame.getLongOperandAttr(type);
102 public <T> T getNextReturnAttr (ThreadInfo ti, Class<T> type, Object prev){
103 StackFrame frame = ti.getTopFrame();
104 return frame.getNextLongOperandAttr(type, prev);
107 public Iterator returnAttrIterator (ThreadInfo ti){
108 StackFrame frame = ti.getTopFrame();
109 return frame.longOperandAttrIterator();
112 public <T> Iterator<T> returnAttrIterator (ThreadInfo ti, Class<T> type){
113 StackFrame frame = ti.getTopFrame();
114 return frame.longOperandAttrIterator(type);
118 public void addReturnAttr (ThreadInfo ti, Object attr){
119 StackFrame frame = ti.getModifiableTopFrame();
120 frame.addLongOperandAttr(attr);