/** * Return DebuggableScript instance if any associated with the script. * If callable supports DebuggableScript implementation, the method * returns it. Otherwise null is returned. */ public static DebuggableScript getDebuggableView(Script script) { if (script instanceof NativeFunction) { return ((NativeFunction)script).getDebuggableView(); } return null; }
/** * @deprecated Use {@link BaseFunction#getFunctionName()} instead. * For backwards compatibility keep an old method name used by * Batik and possibly others. */ public String jsGet_name() { return getFunctionName(); }
/** * Decompile the script. * <p> * The canonical source of the script is returned. * * @param script the script to decompile * @param indent the number of spaces to indent the result * @return a string representing the script source */ public final String decompileScript(Script script, int indent) { NativeFunction scriptImpl = (NativeFunction) script; return scriptImpl.decompile(indent, 0); }
@Override public int getLength() { int paramCount = getParamCount(); if (getLanguageVersion() != Context.VERSION_1_2) { return paramCount; } Context cx = Context.getContext(); NativeCall activation = ScriptRuntime.findFunctionActivation(cx, this); if (activation == null) { return paramCount; } return activation.originalArgs.length; }
final Object result = f.call(cx, scope, scope, functionArgs); return Context.toString(result);
public Arguments(NativeCall activation) { this.activation = activation; Scriptable parent = activation.getParentScope(); setParentScope(parent); setPrototype(ScriptableObject.getObjectPrototype(parent)); args = activation.originalArgs; lengthObj = Integer.valueOf(args.length); NativeFunction f = activation.function; calleeObj = f; int version = f.getLanguageVersion(); if (version <= Context.VERSION_1_3 && version != Context.VERSION_DEFAULT) { callerObj = null; } else { callerObj = NOT_FOUND; } }
/** * @param indent How much to indent the decompiled result * * @param flags Flags specifying format of decompilation output */ @Override final String decompile(int indent, int flags) { String encodedSource = getEncodedSource(); if (encodedSource == null) { return super.decompile(indent, flags); } else { UintMap properties = new UintMap(1); properties.put(Decompiler.INITIAL_INDENT_PROP, indent); return Decompiler.decompile(encodedSource, flags, properties); } }
final Object result = f.call(cx, scope, scope, functionArgs); return Context.toString(result);
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE); for (Map.Entry<String, Object> scopeEntry : bindings.entrySet()) { Object value = scopeEntry.getValue(); String name = scopeEntry.getKey(); if (value instanceof NativeFunction) { log.info("Function -> " + name); NativeFunction function = NativeFunction.class.cast(value); DebuggableScript debuggableFunction = function.getDebuggableView(); for (int i = 0; i < debuggableFunction.getParamAndVarCount(); i++) { log.info("First level arg: " + debuggableFunction.getParamOrVarName(i)); } } else if (value instanceof Undefined || value instanceof String || value instanceof Number) { log.info("Global arg -> " + name); } }
String name = function.getFunctionName(); if (name != null && name.length() != 0) { if (!fromEvalCode) { String name = function.getFunctionName(); if (name != null && name.length() != 0) {
final Object result = f.call(cx, scope, scope, functionArgs); return Context.toString(result);
@Override String decompile(int indent, int flags) { if (script instanceof NativeFunction) { return ((NativeFunction)script).decompile(indent, flags); } return super.decompile(indent, flags); }
if (o instanceof NativeFunction) { final NativeFunction f = (NativeFunction) o; if (f.getDebuggableView() == this.functionOrScript_) { return s;
private static String stringValue(final Object arg) { if (arg instanceof NativeFunction) { // Don't return the string value of the function, because it's usually // multiple lines of content and messes up the log. final String name = StringUtils.defaultIfEmpty(((NativeFunction) arg).getFunctionName(), "anonymous"); return "[function " + name + "]"; } else if (arg instanceof IdFunctionObject) { return "[function " + ((IdFunctionObject) arg).getFunctionName() + "]"; } else if (arg instanceof Function) { return "[function anonymous]"; } String asString = null; try { // try to get the js representation asString = Context.toString(arg); if (arg instanceof Event) { asString += "<" + ((Event) arg).getType() + ">"; } } catch (final Throwable e) { // seems to be a bug (many bugs) in rhino (TODO: investigate it) asString = String.valueOf(arg); } return asString; }
final Object result = f.call(cx, scope, scope, functionArgs); return Context.toString(result);
if (o instanceof NativeFunction) { final NativeFunction f = (NativeFunction) o; if (f.getDebuggableView() == this.functionOrScript_) { return s;
private String stringValue(final Object arg) { if (arg instanceof NativeFunction) { // Don't return the string value of the function, because it's usually // multiple lines of content and messes up the log. final String name = StringUtils.defaultIfEmpty(((NativeFunction) arg).getFunctionName(), "anonymous"); return "[function " + name + "]"; } else if (arg instanceof IdFunctionObject) { return "[function " + ((IdFunctionObject) arg).getFunctionName() + "]"; } else if (arg instanceof Function) { return "[function anonymous]"; } String asString = null; try { // try to get the js representation asString = Context.toString(arg); if (arg instanceof Event) { asString += "<" + ((Event) arg).jsxGet_type() + ">"; } } catch (final Throwable e) { // seems to be a bug (many bugs) in rhino (TODO: investigate it) asString = String.valueOf(arg); } return asString; }
final Object result = f.call(cx, scope, scope, functionArgs); return Context.toString(result);
if (f.getDebuggableView() == functionOrScript_) { return s;
private String stringValue(final Object arg) { if (arg instanceof NativeFunction) { // Don't return the string value of the function, because it's usually // multiple lines of content and messes up the log. final String name = StringUtils.defaultIfEmpty(((NativeFunction) arg).getFunctionName(), "anonymous"); return "[function " + name + "]"; } else if (arg instanceof IdFunctionObject) { return "[function " + ((IdFunctionObject) arg).getFunctionName() + "]"; } else if (arg instanceof Function) { return "[function anonymous]"; } String asString = null; try { // try to get the js representation asString = Context.toString(arg); if (arg instanceof Event) { asString += "<" + ((Event) arg).jsxGet_type() + ">"; } } catch (final Throwable e) { // seems to be a bug (many bugs) in rhino (TODO: investigate it) asString = String.valueOf(arg); } return asString; }