* value of the last expression evaluated in the script.
*/
public Object evaluate(final String scriptstr)
throws InterpreterException {
final Context ctx = enterContext();
Script script = null;
Entry et = null;
Iterator it = compiledScripts.iterator();
// between nlog(n) and log(n) because it is
// an AbstractSequentialList
while (it.hasNext()) {
if ((et = (Entry)(it.next())).str.equals(scriptstr)) {
// if it is not at the end, remove it because
// it will change from place (it is faster
// to remove it now)
script = et.script;
it.remove();
break;
}
}
if (script == null) {
// this script has not been compiled yet or has been forgotten
// since the compilation:
// compile it and store it for future use.
script = (Script)AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
return ctx.compileReader(globalObject,
new StringReader(scriptstr),
SOURCE_NAME_SVG,
1, rhinoClassLoader);
} catch (IOException io) {
// Should never happen: we are using a string