diff --git a/src/org/mozilla/javascript/Decompiler.java b/src/org/mozilla/javascript/Decompiler.java index 787b8ebee9..db8a64dbd6 100644 --- a/src/org/mozilla/javascript/Decompiler.java +++ b/src/org/mozilla/javascript/Decompiler.java @@ -287,10 +287,12 @@ private String sourceToString(int offset) * @param indentGap the identation offset for case labels * */ - static String decompile(String source, - boolean justFunctionBody, - int indent, int indentGap, int caseGap) + public static String decompile(Object sourceObj, + boolean justFunctionBody, + int indent, int indentGap, int caseGap) { + String source = (String)sourceObj; + int length = source.length(); if (length == 0) { return ""; } diff --git a/src/org/mozilla/javascript/InterpretedFunction.java b/src/org/mozilla/javascript/InterpretedFunction.java index a35d7eecbb..f2f313ca7f 100644 --- a/src/org/mozilla/javascript/InterpretedFunction.java +++ b/src/org/mozilla/javascript/InterpretedFunction.java @@ -61,7 +61,7 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, this, itsData); } - public String getEncodedSource() + public Object getEncodedSource() { return Interpreter.getEncodedSource(itsData); } diff --git a/src/org/mozilla/javascript/InterpretedScript.java b/src/org/mozilla/javascript/InterpretedScript.java index 5b245830ba..7703ee5a8f 100644 --- a/src/org/mozilla/javascript/InterpretedScript.java +++ b/src/org/mozilla/javascript/InterpretedScript.java @@ -64,7 +64,7 @@ public Object call(Context cx, Scriptable scope, this, itsData); } - public String getEncodedSource() + public Object getEncodedSource() { return Interpreter.getEncodedSource(itsData); } diff --git a/src/org/mozilla/javascript/Interpreter.java b/src/org/mozilla/javascript/Interpreter.java index e79918c66f..03dec63efe 100644 --- a/src/org/mozilla/javascript/Interpreter.java +++ b/src/org/mozilla/javascript/Interpreter.java @@ -1596,7 +1596,7 @@ static int[] getLineNumbers(InterpreterData data) { return presentLines.getKeys(); } - static String getEncodedSource(InterpreterData idata) + static Object getEncodedSource(InterpreterData idata) { if (idata.encodedSource == null) { return null; diff --git a/src/org/mozilla/javascript/NativeFunction.java b/src/org/mozilla/javascript/NativeFunction.java index 578d2fad19..0082d29d9f 100644 --- a/src/org/mozilla/javascript/NativeFunction.java +++ b/src/org/mozilla/javascript/NativeFunction.java @@ -57,7 +57,7 @@ public class NativeFunction extends BaseFunction */ public String decompile(Context cx, int indent, boolean justbody) { - String encodedSource = getEncodedSource(); + Object encodedSource = getEncodedSource(); if (encodedSource == null) { return super.decompile(cx, indent, justbody); } else { @@ -97,22 +97,9 @@ public String jsGet_name() /** * Get encoded source string. */ - public String getEncodedSource() + public Object getEncodedSource() { - // The following is used only by optimizer, but is here to avoid - // introduction of 2 additional classes there - Class cl = getClass(); - try { - Method m = cl.getDeclaredMethod("getEncodedSourceImpl", - new Class[0]); - return (String)m.invoke(null, ScriptRuntime.emptyArgs); - } catch (NoSuchMethodException ex) { - // No source implementation - return null; - } catch (Exception ex) { - // Wrap the rest of exceptions including possible SecurityException - throw ScriptRuntime.throwAsUncheckedException(ex); - } + return null; } /** diff --git a/src/org/mozilla/javascript/optimizer/Codegen.java b/src/org/mozilla/javascript/optimizer/Codegen.java index b1eeff6ae9..70a188b453 100644 --- a/src/org/mozilla/javascript/optimizer/Codegen.java +++ b/src/org/mozilla/javascript/optimizer/Codegen.java @@ -729,8 +729,8 @@ private void generateInit(Context cx, String superClassName) // Change Parser if changing ordering. if (mainCodegen.encodedSource != null) { - // generate - // public static String getEncodedSourceImpl() + // Override NativeFunction.getEncodedSourceg() with + // public String getEncodedSource() // { // return main_class.getEncodedSourceImpl(START, END); // } @@ -738,9 +738,9 @@ private void generateInit(Context cx, String superClassName) | ClassFileWriter.ACC_STATIC; String getSourceMethodStr = "getEncodedSourceImpl"; String mainImplSig = "(II)Ljava/lang/String;"; - classFile.startMethod(getSourceMethodStr, - "()Ljava/lang/String;", - (short)flags); + classFile.startMethod("getEncodedSource", + "()Ljava/lang/Object;", + ClassFileWriter.ACC_PUBLIC); push(scriptOrFn.getEncodedSourceStart()); push(scriptOrFn.getEncodedSourceEnd()); classFile.addInvoke(ByteCode.INVOKESTATIC, @@ -748,8 +748,8 @@ private void generateInit(Context cx, String superClassName) getSourceMethodStr, mainImplSig); addByteCode(ByteCode.ARETURN); - // 0: no this and no argument - classFile.stopMethod((short)0, null); + // 1: this and no argument or locals + classFile.stopMethod((short)1, null); if (isMainCodegen) { // generate // public static String getEncodedSourceImpl(int start, int end)