Browse Source

Synchronous eval calls

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1680 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
5d6fec85b5
  1. 16
      src/AddIns/Misc/Debugger/Debugger.BooInterpreter/Project/Src/DebugeeInterpreterContext.cs
  2. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  3. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

16
src/AddIns/Misc/Debugger/Debugger.BooInterpreter/Project/Src/DebugeeInterpreterContext.cs

@ -65,8 +65,8 @@ namespace Debugger
assembly = LoadAssembly(path); assembly = LoadAssembly(path);
// Debugger.BooInterpreter.dll // Debugger.BooInterpreter.dll
assembly = LoadAssembly(typeof(DebugeeInteractiveInterpreter).Assembly.Location); assembly = LoadAssembly(typeof(DebugeeInteractiveInterpreter).Assembly.Location);
Variable interpreterType = Eval.NewString(debugger, typeof(DebugeeInteractiveInterpreter).FullName).EvaluateNow(); Variable interpreterType = Eval.NewString(debugger, typeof(DebugeeInteractiveInterpreter).FullName);
interpreter = Eval.CallFunction(debugger, typeof(Assembly), "CreateInstance", assembly, new Variable[] {interpreterType}).EvaluateNow(); interpreter = Eval.CallFunction(debugger, typeof(Assembly), "CreateInstance", assembly, new Variable[] {interpreterType});
interpreter_localVariable = interpreter.Value.SubVariables["localVariable"]; interpreter_localVariable = interpreter.Value.SubVariables["localVariable"];
RunCommand( RunCommand(
"import System\n" + "import System\n" +
@ -80,16 +80,16 @@ namespace Debugger
Variable LoadAssembly(string path) Variable LoadAssembly(string path)
{ {
Variable assemblyPath = Eval.NewString(debugger, path).EvaluateNow(); Variable assemblyPath = Eval.NewString(debugger, path);
Variable assembly = Eval.CallFunction(debugger, typeof(Assembly), "LoadFrom", null, new Variable[] {assemblyPath}).EvaluateNow(); Variable assembly = Eval.CallFunction(debugger, typeof(Assembly), "LoadFrom", null, new Variable[] {assemblyPath});
return assembly; return assembly;
} }
public override void RunCommand(string code) public override void RunCommand(string code)
{ {
if (CanLoadInterpreter) { if (CanLoadInterpreter) {
Variable cmd = Eval.NewString(debugger, code).EvaluateNow(); Variable cmd = Eval.NewString(debugger, code);
Eval.CallFunction(debugger, typeof(InteractiveInterpreter), "LoopEval", interpreter, new Variable[] {cmd}).EvaluateNow(); Eval.CallFunction(debugger, typeof(InteractiveInterpreter), "LoopEval", interpreter, new Variable[] {cmd});
} }
} }
@ -101,8 +101,8 @@ namespace Debugger
public override string[] SuggestCodeCompletion(string code) public override string[] SuggestCodeCompletion(string code)
{ {
if (CanLoadInterpreter) { if (CanLoadInterpreter) {
Variable cmd = Eval.NewString(debugger, code).EvaluateNow(); Variable cmd = Eval.NewString(debugger, code);
Eval.CallFunction(debugger, typeof(AbstractInterpreter), "SuggestCodeCompletion", interpreter, new Variable[] {cmd}).EvaluateNow(); Eval.CallFunction(debugger, typeof(AbstractInterpreter), "SuggestCodeCompletion", interpreter, new Variable[] {cmd});
return null; return null;
} else { } else {
return null; return null;

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -75,7 +75,10 @@ namespace Debugger
OnChanged(new EvalEventArgs(this)); OnChanged(new EvalEventArgs(this));
} }
public static Eval CallFunction(NDebugger debugger, Type type, string functionName, Variable thisValue, Variable[] args) /// <summary>
/// Synchronously calls a function and returns its return value
/// </summary>
public static Variable CallFunction(NDebugger debugger, Type type, string functionName, Variable thisValue, Variable[] args)
{ {
string moduleName = System.IO.Path.GetFileName(type.Assembly.Location); string moduleName = System.IO.Path.GetFileName(type.Assembly.Location);
Module module = debugger.GetModule(moduleName); Module module = debugger.GetModule(moduleName);
@ -88,27 +91,33 @@ namespace Debugger
new IMutable[] {}, new IMutable[] {},
corFunction, corFunction,
thisValue, thisValue,
args); args).EvaluateNow();
} }
public static Eval NewString(NDebugger debugger, string textToCreate) /// <summary>
/// Synchronously creates a new string
/// </summary>
public static Variable NewString(NDebugger debugger, string textToCreate)
{ {
return new NewStringEval(debugger, return new NewStringEval(debugger,
"New string: " + textToCreate, "New string: " + textToCreate,
Variable.Flags.Default, Variable.Flags.Default,
new IExpirable[] {}, new IExpirable[] {},
new IMutable[] {}, new IMutable[] {},
textToCreate); textToCreate).EvaluateNow();
} }
public static Eval NewObject(NDebugger debugger, ICorDebugClass classToCreate) /// <summary>
/// Synchronously creates a new object
/// </summary>
public static Variable NewObject(NDebugger debugger, ICorDebugClass classToCreate)
{ {
return new NewObjectEval(debugger, return new NewObjectEval(debugger,
"New object: " + classToCreate.Token, "New object: " + classToCreate.Token,
Variable.Flags.Default, Variable.Flags.Default,
new IExpirable[] {}, new IExpirable[] {},
new IMutable[] {}, new IMutable[] {},
classToCreate); classToCreate).EvaluateNow();
} }
protected override ICorDebugValue RawCorValue { protected override ICorDebugValue RawCorValue {
@ -129,7 +138,8 @@ namespace Debugger
public void ScheduleEvaluation() public void ScheduleEvaluation()
{ {
if (Evaluated || State == EvalState.WaitingForRequest) { if (Evaluated || State == EvalState.WaitingForRequest) {
debugger.PerformEval(this); debugger.ScheduleEval(this);
debugger.MTA2STA.AsyncCall(delegate { debugger.StartEvaluation(); });
SetState(EvalState.EvaluationScheduled, null, null); SetState(EvalState.EvaluationScheduled, null, null);
} }
} }

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs

@ -30,13 +30,10 @@ namespace Debugger
/// <summary> /// <summary>
/// Adds eval to a list of pending evals. /// Adds eval to a list of pending evals.
/// The evaluation of pending evals should be started by calling StartEvaluation in paused stated.
/// The the debugger will continue until all evals are done and will stop with PausedReason.AllEvalsComplete
/// </summary> /// </summary>
internal void PerformEval(Eval eval) internal void ScheduleEval(Eval eval)
{ {
pendingEvalsCollection.Enqueue(eval); pendingEvalsCollection.Enqueue(eval);
this.MTA2STA.AsyncCall(delegate { StartEvaluation(); });
} }
public void StartEvaluation() public void StartEvaluation()

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -310,7 +310,7 @@ namespace Debugger
if (corValue.Is<ICorDebugReferenceValue>()) { if (corValue.Is<ICorDebugReferenceValue>()) {
if (newCorValue.Is<ICorDebugObjectValue>()) { if (newCorValue.Is<ICorDebugObjectValue>()) {
ICorDebugClass corClass = newCorValue.As<ICorDebugObjectValue>().Class; ICorDebugClass corClass = newCorValue.As<ICorDebugObjectValue>().Class;
ICorDebugValue box = Eval.NewObject(debugger, corClass).EvaluateNow().RawCorValue; ICorDebugValue box = Eval.NewObject(debugger, corClass).RawCorValue;
newCorValue = box; newCorValue = box;
} }
corValue.CastTo<ICorDebugReferenceValue>().SetValue(newCorValue.CastTo<ICorDebugReferenceValue>().Value); corValue.CastTo<ICorDebugReferenceValue>().SetValue(newCorValue.CastTo<ICorDebugReferenceValue>().Value);

Loading…
Cancel
Save