View Javadoc

1   /*
2    * @(#) FRETURN.java Jan 8, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.interpreter.operations;
11  
12  import java.lang.reflect.Method;
13  
14  import nl.tudelft.simulation.dsol.interpreter.Frame;
15  import nl.tudelft.simulation.language.concurrent.Monitor;
16  
17  /***
18   * The FRETURN operation as defined in <a
19   * href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc4.html">
20   * http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc4.html
21   * </a>.
22   * <p>
23   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24   * University of Technology </a>, the Netherlands. <br>
25   * See for project information <a
26   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
27   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28   * License (GPL) </a>, no warranty <br>
29   * 
30   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
31   *         Jacobs </a><a
32   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
33   *         Verbraeck </a>
34   * @version 1.3 Apr 6, 2004
35   * @since 1.4
36   */
37  public class FRETURN extends ReturnOperation
38  {
39  	/*** OP refers to the operand code */
40  	public static final int OP = 174;
41  
42  	/***
43  	 * constructs a new FRETURN
44  	 */
45  	public FRETURN()
46  	{
47  		super();
48  	}
49  
50  	/***
51  	 * @see nl.tudelft.simulation.dsol.interpreter.operations.ReturnOperation
52  	 *      #execute(nl.tudelft.simulation.dsol.interpreter.Frame)
53  	 */
54  	public Object execute(final Frame frame)
55  	{
56  		if (ReturnOperation.isSynchronized(frame.getMethodDescriptor()
57  				.getMethod()))
58  		{
59  			Object monitor = null;
60  			if (ReturnOperation.isStatic(frame.getMethodDescriptor()
61  					.getMethod()))
62  			{
63  				monitor = ((Method) frame.getMethodDescriptor().getMethod())
64  						.getDeclaringClass();
65  			} else
66  			{
67  				monitor = frame.getLocalVariables()[0].getValue();
68  			}
69  			Monitor.unlock(monitor);
70  		}
71  		return frame.getOperandStack().pop();
72  	}
73  
74  	/***
75  	 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getByteLength()
76  	 */
77  	public int getByteLength()
78  	{
79  		return OPCODE_BYTE_LENGTH;
80  	}
81  
82  	/***
83  	 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getOpcode()
84  	 */
85  	public int getOpcode()
86  	{
87  		return FRETURN.OP;
88  	}
89  }