Browse Source

Synchronous eval calls

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1680 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 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 @@ -65,8 +65,8 @@ namespace Debugger
assembly = LoadAssembly(path);
// Debugger.BooInterpreter.dll
assembly = LoadAssembly(typeof(DebugeeInteractiveInterpreter).Assembly.Location);
Variable interpreterType = Eval.NewString(debugger, typeof(DebugeeInteractiveInterpreter).FullName).EvaluateNow();
interpreter = Eval.CallFunction(debugger, typeof(Assembly), "CreateInstance", assembly, new Variable[] {interpreterType}).EvaluateNow();
Variable interpreterType = Eval.NewString(debugger, typeof(DebugeeInteractiveInterpreter).FullName);
interpreter = Eval.CallFunction(debugger, typeof(Assembly), "CreateInstance", assembly, new Variable[] {interpreterType});
interpreter_localVariable = interpreter.Value.SubVariables["localVariable"];
RunCommand(
"import System\n" +
@ -80,16 +80,16 @@ namespace Debugger @@ -80,16 +80,16 @@ namespace Debugger
Variable LoadAssembly(string path)
{
Variable assemblyPath = Eval.NewString(debugger, path).EvaluateNow();
Variable assembly = Eval.CallFunction(debugger, typeof(Assembly), "LoadFrom", null, new Variable[] {assemblyPath}).EvaluateNow();
Variable assemblyPath = Eval.NewString(debugger, path);
Variable assembly = Eval.CallFunction(debugger, typeof(Assembly), "LoadFrom", null, new Variable[] {assemblyPath});
return assembly;
}
public override void RunCommand(string code)
{
if (CanLoadInterpreter) {
Variable cmd = Eval.NewString(debugger, code).EvaluateNow();
Eval.CallFunction(debugger, typeof(InteractiveInterpreter), "LoopEval", interpreter, new Variable[] {cmd}).EvaluateNow();
Variable cmd = Eval.NewString(debugger, code);
Eval.CallFunction(debugger, typeof(InteractiveInterpreter), "LoopEval", interpreter, new Variable[] {cmd});
}
}
@ -101,8 +101,8 @@ namespace Debugger @@ -101,8 +101,8 @@ namespace Debugger
public override string[] SuggestCodeCompletion(string code)
{
if (CanLoadInterpreter) {
Variable cmd = Eval.NewString(debugger, code).EvaluateNow();
Eval.CallFunction(debugger, typeof(AbstractInterpreter), "SuggestCodeCompletion", interpreter, new Variable[] {cmd}).EvaluateNow();
Variable cmd = Eval.NewString(debugger, code);
Eval.CallFunction(debugger, typeof(AbstractInterpreter), "SuggestCodeCompletion", interpreter, new Variable[] {cmd});
return null;
} else {
return null;

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

@ -75,7 +75,10 @@ namespace Debugger @@ -75,7 +75,10 @@ namespace Debugger
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);
Module module = debugger.GetModule(moduleName);
@ -88,27 +91,33 @@ namespace Debugger @@ -88,27 +91,33 @@ namespace Debugger
new IMutable[] {},
corFunction,
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,
"New string: " + textToCreate,
Variable.Flags.Default,
new IExpirable[] {},
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,
"New object: " + classToCreate.Token,
Variable.Flags.Default,
new IExpirable[] {},
new IMutable[] {},
classToCreate);
classToCreate).EvaluateNow();
}
protected override ICorDebugValue RawCorValue {
@ -129,7 +138,8 @@ namespace Debugger @@ -129,7 +138,8 @@ namespace Debugger
public void ScheduleEvaluation()
{
if (Evaluated || State == EvalState.WaitingForRequest) {
debugger.PerformEval(this);
debugger.ScheduleEval(this);
debugger.MTA2STA.AsyncCall(delegate { debugger.StartEvaluation(); });
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 @@ -30,13 +30,10 @@ namespace Debugger
/// <summary>
/// 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>
internal void PerformEval(Eval eval)
internal void ScheduleEval(Eval eval)
{
pendingEvalsCollection.Enqueue(eval);
this.MTA2STA.AsyncCall(delegate { StartEvaluation(); });
}
public void StartEvaluation()

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

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

Loading…
Cancel
Save