use of org.mozilla.javascript.debug.Debugger in project Auto.js by hyb1996.
the class Dim method do_eval.
/**
* Evaluates script in the given stack frame.
*/
private static String do_eval(Context cx, StackFrame frame, String expr) {
String resultString;
Debugger saved_debugger = cx.getDebugger();
Object saved_data = cx.getDebuggerContextData();
int saved_level = cx.getOptimizationLevel();
cx.setDebugger(null, null);
cx.setOptimizationLevel(-1);
cx.setGeneratingDebug(false);
try {
Callable script = (Callable) cx.compileString(expr, "", 0, null);
Object result = script.call(cx, frame.scope, frame.thisObj, ScriptRuntime.emptyArgs);
if (result == Undefined.instance) {
resultString = "";
} else {
resultString = ScriptRuntime.toString(result);
}
} catch (Exception exc) {
resultString = exc.getMessage();
} finally {
cx.setGeneratingDebug(true);
cx.setOptimizationLevel(saved_level);
cx.setDebugger(saved_debugger, saved_data);
}
if (resultString == null) {
resultString = "null";
}
return resultString;
}
use of org.mozilla.javascript.debug.Debugger in project servoy-client by Servoy.
the class WebServiceScriptable method getScript.
private static Script getScript(Context context, URL serverScript, IApplication app) throws URISyntaxException, IOException {
Pair<Script, Long> pair = scripts.get(serverScript.toURI());
long lastModified = -1;
URLConnection connection = serverScript.openConnection();
connection.setUseCaches(false);
if (connection instanceof JarURLConnection) {
try (JarFile jarFile = ((JarURLConnection) connection).getJarFile()) {
lastModified = new File(jarFile.getName()).lastModified();
}
} else
lastModified = connection.getLastModified();
if (pair == null || pair.getRight().longValue() < lastModified) {
String name = "";
URI uri = serverScript.toURI();
if ("file".equals(uri.getScheme())) {
File file = new File(uri);
if (file.exists()) {
name = file.getAbsolutePath();
}
}
Debugger debugger = null;
int lvl = context.getOptimizationLevel();
Script script;
try {
if (app instanceof IDebugClient) {
if ("".endsWith(name)) {
context.setGeneratingDebug(false);
debugger = context.getDebugger();
if (debugger != null) {
context.setOptimizationLevel(9);
context.setDebugger(null, null);
}
} else if (context.getDebugger() == null) {
// this is a refresh/recreate forms, could be because of a server side script edit/change
// then the debugger is not attached because it is not the event thread. make sure that
// code optimization level is disabled.
context.setGeneratingDebug(true);
context.setOptimizationLevel(-1);
}
} else {
// in none debug client, don't compile to a java file (classloading problems)
// but also don't generate debug info
context.setGeneratingDebug(false);
context.setOptimizationLevel(-1);
}
context.setGeneratingSource(false);
script = context.compileString(Utils.getURLContent(serverScript), name, 1, null);
} finally {
if (debugger != null) {
context.setDebugger(debugger, null);
context.setOptimizationLevel(lvl);
}
}
pair = new Pair<Script, Long>(script, Long.valueOf(lastModified));
scripts.put(uri, pair);
}
return pair.getLeft();
}
use of org.mozilla.javascript.debug.Debugger in project servoy-client by Servoy.
the class ScriptVariableScope method put.
/*
* @see Scriptable#put(String, Scriptable, Object)
*/
@Override
public void put(String name, Scriptable arg1, Object value) {
if (value instanceof Function) {
super.put(name, arg1, value);
} else {
try {
Context currentContext = Context.getCurrentContext();
if (currentContext != null) {
Debugger debugger = currentContext.getDebugger();
if (debugger != null) {
if (debugger instanceof IDebuggerWithWatchPoints) {
IDebuggerWithWatchPoints wp = (IDebuggerWithWatchPoints) debugger;
wp.modification(name, this);
}
}
}
put(name, value);
} catch (RuntimeException re) {
throw new WrappedException(re);
}
}
}
use of org.mozilla.javascript.debug.Debugger in project servoy-client by Servoy.
the class LazyCompilationScope method get.
@Override
public Object get(String name, Scriptable start) {
Object o = getImpl(name, start);
if (o != Scriptable.NOT_FOUND) {
Context currentContext = Context.getCurrentContext();
if (currentContext != null) {
Debugger debugger = currentContext.getDebugger();
if (debugger instanceof IDebuggerWithWatchPoints) {
IDebuggerWithWatchPoints wp = (IDebuggerWithWatchPoints) debugger;
wp.access(name, this);
}
}
}
return o;
}
use of org.mozilla.javascript.debug.Debugger in project servoy-client by Servoy.
the class FormDialog method setVisible.
@Override
public void setVisible(boolean b) {
for (IWindowVisibleChangeListener l : visibleChangeListeners.toArray(new IWindowVisibleChangeListener[visibleChangeListeners.size()])) l.beforeVisibleChange(this, b);
if (!b) {
// For future implementation of case 286968 change
// if (persistBounds)
// {
// super.setVisible(false);
// }
// else
// {
String name = getName();
// the parent will not save the bounds this way in Servoy.properties
setName(null);
super.setVisible(false);
setName(name);
// }
} else {
Context context = null;
Debugger debugger = null;
Object debuggerContextData = null;
if (isModal() && Utils.isAppleMacOS()) {
context = Context.enter();
debugger = context.getDebugger();
debuggerContextData = context.getDebuggerContextData();
context.setDebugger(null, null);
}
try {
super.setVisible(true);
} finally {
if (isModal() && Utils.isAppleMacOS()) {
context.setDebugger(debugger, debuggerContextData);
Context.exit();
}
}
}
}
Aggregations