Created
August 23, 2010 15:55
-
-
Save mckamey/545752 to your computer and use it in GitHub Desktop.
Port of Rhino fix for bug 386997
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: Projects/EcmaScript.NET/Debugging/DebugFrame.cs | |
=================================================================== | |
--- Projects/EcmaScript.NET/Debugging/DebugFrame.cs (revision 56306) | |
+++ Projects/EcmaScript.NET/Debugging/DebugFrame.cs (working copy) | |
@@ -58,5 +58,11 @@ | |
/// exception object if about to throw exception | |
/// </param> | |
void OnExit (Context cx, bool byThrow, object resultOrException); | |
+ | |
+ /// <summary> | |
+ /// Called when the function or script executes a 'debugger' statement. | |
+ /// </summary> | |
+ /// <param name="cx">current Context for this thread</param> | |
+ void OnDebuggerStatement(Context cx); | |
} | |
} | |
\ No newline at end of file | |
Index: Projects/EcmaScript.NET/Interpreter.cs | |
=================================================================== | |
--- Projects/EcmaScript.NET/Interpreter.cs (revision 56306) | |
+++ Projects/EcmaScript.NET/Interpreter.cs (working copy) | |
@@ -80,9 +80,12 @@ | |
const int Icode_LEAVEDQ = -54; | |
const int Icode_TAIL_CALL = -55; | |
const int Icode_LOCAL_CLEAR = -56; | |
- const int MIN_ICODE = -56; | |
+ const int Icode_DEBUGGER = -57; | |
+ // Last icode | |
+ const int MIN_ICODE = -57; | |
+ | |
// data for parsing | |
CompilerEnvirons compilerEnv; | |
@@ -431,6 +434,9 @@ | |
case Icode_LOCAL_CLEAR: | |
return "LOCAL_CLEAR"; | |
+ | |
+ case Icode_DEBUGGER: | |
+ return "DEBUGGER"; | |
} | |
// icode without name | |
@@ -697,6 +703,10 @@ | |
} | |
break; | |
+ case Token.DEBUGGER: | |
+ updateLineNumber (node); | |
+ addIcode (Icode_DEBUGGER); | |
+ break; | |
case Token.SWITCH: | |
updateLineNumber (node); { | |
@@ -4001,6 +4011,13 @@ | |
} | |
goto case Icode_LINE; | |
+ case Icode_DEBUGGER: { | |
+ if (frame.debuggerFrame != null) { | |
+ frame.debuggerFrame.OnDebuggerStatement(cx); | |
+ } | |
+ break; | |
+ } | |
+ | |
case Icode_LINE: | |
frame.pcSourceLineStart = frame.pc; | |
if (frame.debuggerFrame != null) { | |
Index: Projects/EcmaScript.NET/NodeFactory.cs | |
=================================================================== | |
--- Projects/EcmaScript.NET/NodeFactory.cs (revision 56306) | |
+++ Projects/EcmaScript.NET/NodeFactory.cs (working copy) | |
@@ -227,6 +227,12 @@ | |
return expr == null ? new Node (Token.RETURN, lineno) : new Node (Token.RETURN, expr, lineno); | |
} | |
+ /// <summary> Debugger</summary> | |
+ internal Node CreateDebugger(int lineno) | |
+ { | |
+ return new Node(Token.DEBUGGER, lineno); | |
+ } | |
+ | |
/// <summary> Label</summary> | |
internal Node CreateLabel (int lineno) | |
{ | |
Index: Projects/EcmaScript.NET/Parser.cs | |
=================================================================== | |
--- Projects/EcmaScript.NET/Parser.cs (revision 56306) | |
+++ Projects/EcmaScript.NET/Parser.cs (working copy) | |
@@ -1190,6 +1190,11 @@ | |
break; | |
} | |
+ case Token.DEBUGGER: | |
+ consumeToken(); | |
+ decompiler.AddToken(Token.DEBUGGER); | |
+ pn = nf.CreateDebugger(ts.Lineno); | |
+ break; | |
case Token.LC: | |
consumeToken(); | |
Index: Projects/EcmaScript.NET/Token.cs | |
=================================================================== | |
--- Projects/EcmaScript.NET/Token.cs (revision 56306) | |
+++ Projects/EcmaScript.NET/Token.cs (working copy) | |
@@ -205,10 +205,10 @@ | |
public const int SETCONSTVAR = LAST_BYTECODE_TOKEN + 75; | |
public const int CONDCOMMENT = LAST_BYTECODE_TOKEN + 76; // JScript conditional comment | |
public const int KEEPCOMMENT = LAST_BYTECODE_TOKEN + 77; // /*! ... */ comment | |
+ public const int DEBUGGER = LAST_BYTECODE_TOKEN + 78; | |
+ public const int LAST_TOKEN = LAST_BYTECODE_TOKEN + 79; | |
- public const int LAST_TOKEN = LAST_BYTECODE_TOKEN + 78; | |
- | |
public static string name (int token) | |
{ | |
//if (!printNames) { | |
@@ -658,6 +658,7 @@ | |
case SETCONSTVAR: return "SETCONSTVAR"; | |
case CONDCOMMENT: return "CONDCOMMENT"; | |
case KEEPCOMMENT: return "KEEPCOMMENT"; | |
+ case DEBUGGER: return "DEBUGGER"; | |
default: return "UNKNOWN Token Type"; | |
} | |
Index: Projects/EcmaScript.NET/TokenStream.cs | |
=================================================================== | |
--- Projects/EcmaScript.NET/TokenStream.cs (revision 56306) | |
+++ Projects/EcmaScript.NET/TokenStream.cs (working copy) | |
@@ -1233,7 +1233,7 @@ | |
private const int Id_char = EcmaScript.NET.Token.RESERVED; | |
private const int Id_class = EcmaScript.NET.Token.RESERVED; | |
private const int Id_const = EcmaScript.NET.Token.RESERVED; | |
- private const int Id_debugger = EcmaScript.NET.Token.RESERVED; | |
+ private const int Id_debugger = EcmaScript.NET.Token.DEBUGGER; | |
private const int Id_double = EcmaScript.NET.Token.RESERVED; | |
private const int Id_enum = EcmaScript.NET.Token.RESERVED; | |
private const int Id_extends = EcmaScript.NET.Token.RESERVED; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Port of Rhino fix for bug 386997
(This is a snippet from an email I sent over a year ago to the owners of EcmaScript.NET. It has been patched version for over a year now.)
When using EcmaScript.NET, everything works great with the exception that
debugger
statements are flagged as syntax errors. This is a deal breaker for me because I get syntax errors if a dev even temporarily adds "debugger;
".I did some hunting around and it turns out this bug goes all the way back to Rhino but was fixed in Rhino 1.7R1. I looked up the bug that got fixed and it included a CVS patch. I manually ported the patch to EcmaScript.NET.modified and it works great.
If you could apply the included patch, I'd really appreciate it.