本文整理汇总了C#中Mono.Debugger.Frontend.ScriptingContext.FindMethod方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptingContext.FindMethod方法的具体用法?C# ScriptingContext.FindMethod怎么用?C# ScriptingContext.FindMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Debugger.Frontend.ScriptingContext
的用法示例。
在下文中一共展示了ScriptingContext.FindMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoResolve
protected override Expression DoResolve(ScriptingContext context)
{
if (context.HasFrame) {
StackFrame frame = context.CurrentFrame;
if ((frame.Method != null) && frame.Method.IsLoaded) {
TargetVariable var = GetVariableByName (frame, name);
if (var != null)
return new VariableAccessExpression (var);
}
Expression expr = Lookup (context, frame);
if (expr != null)
return expr;
TargetAddress address = context.CurrentProcess.LookupSymbol (name);
if (!address.IsNull)
return new NumberExpression (address.Address);
} else if (context.ImplicitInstance != null) {
MemberExpression member = StructAccessExpression.FindMember (
context.CurrentThread, context.ImplicitInstance.Type,
context.ImplicitInstance, name, true, true);
if (member != null)
return member;
string[] namespaces = context.GetNamespaces () ?? new string [0];
foreach (string ns in namespaces) {
string full_name = MakeFQN (ns, name);
member = StructAccessExpression.FindMember (
context.CurrentThread, context.ImplicitInstance.Type,
context.ImplicitInstance, full_name, true, true);
if (member != null)
return member;
}
}
SourceLocation location = context.FindMethod (name);
if (location != null)
return new SourceExpression (location);
Expression texpr = DoResolveType (context);
if (texpr != null)
return texpr;
throw new ScriptingException ("No symbol `{0}' in current context.", Name);
}
示例2: DoResolve
protected override bool DoResolve(ScriptingContext context)
{
int line = -1;
int pos = Argument.IndexOf (':');
if (pos >= 0) {
string filename = Argument.Substring (0, pos);
try {
line = (int) UInt32.Parse (Argument.Substring (pos+1));
} catch {
throw new ScriptingException ("Expected filename:line");
}
return FindFile (context, filename, line);
}
if (Argument == "") {
StackFrame frame = context.CurrentFrame;
if (frame.SourceAddress == null)
return false;
if (frame.SourceLocation != null)
location = frame.SourceLocation;
else
address = frame.SourceAddress;
return true;
}
try {
line = (int) UInt32.Parse (Argument);
} catch {
}
if (line != -1) {
location = context.CurrentLocation;
if (location.FileName == null)
throw new ScriptingException (
"Location doesn't have any source code.");
return FindFile (context, location.FileName, line);
}
MethodExpression mexpr;
try {
Expression expr = ParseExpression (context);
if (expr == null)
return false;
mexpr = expr.ResolveMethod (context, type);
} catch {
mexpr = null;
}
if (mexpr != null) {
TargetFunctionType func;
try {
func = mexpr.EvaluateMethod (context, type, null);
} catch {
func = null;
}
if (func != null)
method = func.GetSourceCode ();
location = mexpr.EvaluateSource (context);
} else
location = context.FindMethod (Argument);
if (location == null)
throw new ScriptingException (
"Location doesn't have any source code.");
return true;
}
示例3: DoParseExpression
protected SourceLocation DoParseExpression(ScriptingContext context,
LocationType type, string arg)
{
F.Expression expr = context.ParseExpression (arg);
MethodExpression mexpr = expr.ResolveMethod (context, type);
if (mexpr != null)
return mexpr.EvaluateSource (context);
else
return context.FindMethod (arg);
}
示例4: DoResolve
protected override bool DoResolve(ScriptingContext context)
{
// set whole method in a try-catch block: if anything goes wrong, an invalid breakpoint
// number is set and the semaphore is released.
try {
if (global) {
if (local)
throw new ScriptingException (
"Cannot use both -local and -global.");
if (Group != null)
throw new ScriptingException (
"Cannot use both -group and -global.");
tgroup = ThreadGroup.Global;
} else if (local) {
if (Group != null)
throw new ScriptingException (
"Cannot use both -group and -local.");
tgroup = context.Interpreter.GetThreadGroup (Group, false);
} else if (Group != null) {
tgroup = context.Interpreter.GetThreadGroup (Group, false);
} else {
tgroup = ThreadGroup.Global;
}
if (context.Interpreter.HasTarget) {
context.CurrentProcess = context.Interpreter.GetProcess (p_index);
context.CurrentThread = context.Interpreter.GetThread (t_index);
Mono.Debugger.Thread thread = context.CurrentThread;
if (!thread.IsStopped)
throw new Mono.Debugger.TargetException (TargetError.NotStopped);
Backtrace backtrace = thread.GetBacktrace ();
StackFrame frame;
if (f_index == -1)
frame = backtrace.CurrentFrame;
else {
if (f_index >= backtrace.Count)
throw new ScriptingException (
"No such frame: {0}", f_index);
frame = backtrace [f_index];
}
context.CurrentFrame = frame;
if (ExpressionParser.ParseLocation (
thread, thread.CurrentFrame, Argument, out location))
return true;
}
if (Argument.IndexOf (':') > 0)
return true;
try {
UInt32.Parse (Argument);
return true;
} catch {
}
Expression expr = context.Interpreter.ExpressionParser.Parse (Argument);
if (expr == null)
throw new ScriptingException ("Cannot resolve expression `{0}'.", Argument);
if (expr is PointerExpression) {
address = ((PointerExpression) expr).EvaluateAddress (context);
return true;
}
if (!context.Interpreter.HasTarget)
return true;
MethodExpression mexpr;
try {
mexpr = expr.ResolveMethod (context, type);
} catch {
if (lazy)
return true;
throw new ScriptingException ("No such method: `{0}'.", Argument);
}
if (mexpr != null)
location = mexpr.EvaluateSource (context);
else
location = context.FindMethod (Argument);
if (lazy)
return true;
if (location == null)
throw new ScriptingException ("No such method: `{0}'.", Argument);
return true;
} catch {
EmonicInterpreter.breakpointNumber = -1;
EmonicInterpreter.breakpointSem.Release();
//.........这里部分代码省略.........