Top Description Fields Constructors Methods
bsh

public Class CallStack

extends Object
Class Inheritance
Imports
java.util.Vector

A stack of NameSpaces representing the call path. Each method invocation, for example, pushes a new NameSpace onto the stack. The top of the stack is always the current namespace of evaluation.

This is used to support the this.caller magic reference and to print script "stack traces" when evaluation errors occur.

Note

it would be awefully nice to use the java.util.Stack here. Sigh... have to stay 1.1 compatible.

Note

How can this be thread safe, you might ask? Wouldn't a thread executing various beanshell methods be mutating the callstack? Don't we need one CallStack per Thread in the interpreter? The answer is that we do. Any java.lang.Thread enters our script via an external (hard) Java reference via a This type interface, e.g. the Runnable interface implemented by This or an arbitrary interface implemented by XThis. In that case the This invokeMethod() method (called by any interface that it exposes) creates a new CallStack for each external call.

Field Summary

Modifier and TypeField and Description
private Vector<E>

Constructor Summary

AccessConstructor and Description
public
public
CallStack(NameSpace namespace)

Method Summary

Modifier and TypeMethod and Description
public void
public CallStack
copy()

Occasionally we need to freeze the callstack for error reporting purposes, etc.

public int
public NameSpace
get(int depth)

zero based.

public NameSpace
pop()

public void
public void
set(int depth, NameSpace ns)

This is kind of crazy, but used by the setNameSpace command.

public NameSpace
swap(NameSpace newTop)

Swap in the value as the new top of the stack and return the old value.

public NameSpace[]
public NameSpace
top()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

stackback to summary
private Vector<E> stack

Constructor Detail

CallStackback to summary
public CallStack()
CallStackback to summary
public CallStack(NameSpace namespace)

Method Detail

clearback to summary
public void clear()
copyback to summary
public CallStack copy()

Occasionally we need to freeze the callstack for error reporting purposes, etc.

depthback to summary
public int depth()
getback to summary
public NameSpace get(int depth)

zero based.

popback to summary
public NameSpace pop()
pushback to summary
public void push(NameSpace ns)
setback to summary
public void set(int depth, NameSpace ns)

This is kind of crazy, but used by the setNameSpace command. zero based.

swapback to summary
public NameSpace swap(NameSpace newTop)

Swap in the value as the new top of the stack and return the old value.

toArrayback to summary
public NameSpace[] toArray()
topback to summary
public NameSpace top()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.