
com.offbynull.coroutines.user.MethodState Maven / Gradle / Ivy
Show all versions of user Show documentation
/*
* Copyright (c) 2015, Kasra Faghihi, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.offbynull.coroutines.user;
import java.io.Serializable;
/**
* Do not use -- for internal use only.
*
* Holds on to the state of a method frame.
* @author Kasra Faghihi
*/
public final class MethodState implements Serializable {
private static final long serialVersionUID = 2L;
private final int continuationPoint;
private final Object[] stack;
private final Object[] localTable;
private final LockState lockState;
/**
* Do not use -- for internal use only.
*
* Constructs a {@link MethodState} object.
* @param continuationPoint point in the code at which state was saved (does not refer to offset, just an id that's generated by the
* instrumenter to mark that point)
* @param stack operand stack at the point which state was saved
* @param localTable local variable table at the point which state was saved
* @param lockState monitors entered at the point which state was saved (may be {@code null})
*/
public MethodState(int continuationPoint, Object[] stack, Object[] localTable, LockState lockState) {
if (continuationPoint < 0) {
throw new IllegalArgumentException();
}
if (stack == null || localTable == null) {
throw new NullPointerException();
}
this.continuationPoint = continuationPoint;
this.stack = stack;
this.localTable = localTable;
this.lockState = lockState;
}
/**
* Do not use -- for internal use only.
*
* Get the point in the code at which state was saved (does not refer to offset, just an id that's generated by the
* instrumenter to mark that point)
* @return point in the code at which state was saved
*/
public int getContinuationPoint() {
return continuationPoint;
}
/**
* Do not use -- for internal use only.
*
* Get the operand stack at the point which state was saved.
* @return operand stack at the point which state was saved
*/
public Object[] getStack() {
return stack;
}
/**
* Do not use -- for internal use only.
*
* Get the local variable table at the point which state was saved.
* @return local variable table at the point which state was saved
*/
public Object[] getLocalTable() {
return localTable;
}
/**
* Do not use -- for internal use only.
*
* Get the monitors entered at the point which state was saved.
* @return monitors entered at the point which state was saved
*/
public LockState getLockState() {
return lockState;
}
}