001: //
002: //This file is part of the prose package.
003: //
004: //The contents of this file are subject to the Mozilla Public License
005: //Version 1.1 (the "License"); you may not use this file except in
006: //compliance with the License. You may obtain a copy of the License at
007: //http://www.mozilla.org/MPL/
008: //
009: //Software distributed under the License is distributed on an "AS IS" basis,
010: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: //for the specific language governing rights and limitations under the
012: //License.
013: //
014: //The Original Code is prose.
015: //
016: // Contributor(s):
017: // $Id$
018: // =====================================================================
019: //
020: //(history at end)
021: //
022:
023: package ch.ethz.inf.iks.jvmai.jvmdi;
024:
025: import ch.ethz.jvmai.MethodExitJoinPoint;
026:
027: /**
028: * Concrete implementation of a MethodExitJoinPoint for the Jikes RVM.
029: *
030: * @author Angela Nicoara
031: * @author Gerald Linhofer
032: * @version $Revision$
033: */
034: public class HotSwapMethodExitJoinPointImpl extends
035: HotSwapMethodJoinPointImpl implements MethodExitJoinPoint {
036:
037: private int resultSlot;
038: private int resultTypeCode;
039: private boolean resultTypeInitialized;
040:
041: /**
042: * Constructs an uninitialized instance.
043: * To use it {@link #init(int,Object,int)} must be called
044: * after construction.
045: */
046: HotSwapMethodExitJoinPointImpl() {
047: super ();
048: }
049:
050: /**
051: * Constructs an initialized join point object.
052: * @param id method identifier to which this join point belongs.
053: * @param tag AOP tag associated with this join point.
054: * @param resultSlot local variable table index of the result.
055: */
056: HotSwapMethodExitJoinPointImpl(int id, Object tag, int resultSlot) {
057: super (id, tag);
058: this .resultSlot = resultSlot;
059: resultTypeInitialized = false;
060: }
061:
062: /**
063: * Throws a RuntimeException (use {@link #init(int,Object,int)})
064: *
065: * @throws RuntimeException illigal method: dont call this method
066: */
067: public void init(int id, Object tag) {
068: throw new RuntimeException(
069: "You must use <void init(int,Object,Object,int) to initialize an "
070: + this .getClass().getName());
071: }
072:
073: /**
074: * (Re)Initialize this join point.
075: *
076: * @param id method identifier to which this join point belongs.
077: * @param tag AOP tag associated with this join point.
078: * @param resultSlot local variable table index of the result.
079: */
080: public void init(int id, Object tag, int resultSlot) {
081: super .init(id, tag);
082: this .resultSlot = resultSlot;
083: resultTypeInitialized = false;
084: }
085:
086: public String getKind() {
087: return KIND_METHOD_EXIT_JP;
088: }
089:
090: public int getMask() {
091: return MASK_CODE_JP | MASK_METHOD_EXIT_JP;
092: }
093:
094: /**
095: * Returns the result of the target
096: */
097: public Object getResult() {
098: if (!resultTypeInitialized)
099: initResultType();
100:
101: //System.out.println("getResult()");
102: if (ARG_TYPE_VOID == resultTypeCode)
103: return new Object();
104: return doGetLocalVar(resultSlot, resultTypeCode, Thread
105: .currentThread(), height);
106: }
107:
108: /**
109: * Modifies the result of the target method.
110: *
111: * @param value new value of the result.
112: *
113: * @throws ch.ethz.jvmai.InvalidIdException can not find
114: * the stack frame of the caller in current thread.
115: */
116: public void setResult(Object value) {
117: if (!resultTypeInitialized)
118: initResultType();
119:
120: //System.out.println("entering setResult(" + value + ")");
121: if (ARG_TYPE_VOID == resultTypeCode)
122: return;
123: doSetLocalVar(resultSlot, resultTypeCode, value, Thread
124: .currentThread(), height);
125: //System.out.println("setResult() terminated");
126: }
127:
128: protected void initResultType() {
129: resultTypeCode = encodeArgType(getMethod().getReturnType());
130: resultTypeInitialized = true;
131: }
132:
133: }
134:
135: //======================================================================
136: //
137: //$Log$
138: //
|