本文整理汇总了C#中Mono.Debugger.Frontend.ScriptingContext.ParseExpression方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptingContext.ParseExpression方法的具体用法?C# ScriptingContext.ParseExpression怎么用?C# ScriptingContext.ParseExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Debugger.Frontend.ScriptingContext
的用法示例。
在下文中一共展示了ScriptingContext.ParseExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EvaluateExpression
public string EvaluateExpression(ScriptingContext context, string text,
DisplayFormat format)
{
F.Expression expression = context.ParseExpression (text);
try {
expression = expression.Resolve (context);
} catch (ScriptingException ex) {
throw new ScriptingException ("Cannot resolve expression `{0}': {1}",
text, ex.Message);
} catch {
throw new ScriptingException ("Cannot resolve expression `{0}'.", text);
}
try {
object retval = expression.Evaluate (context);
return context.FormatObject (retval, format);
} catch (ScriptingException ex) {
throw new ScriptingException ("Cannot evaluate expression `{0}': {1}",
text, ex.Message);
} catch {
throw new ScriptingException ("Cannot evaluate expression `{0}'.", text);
}
}
示例2: DoResolve
protected override bool DoResolve(ScriptingContext context)
{
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);
}
if (!gui && !lazy && context.Interpreter.HasTarget) {
Thread thread = context.CurrentThread;
if (!thread.IsStopped)
throw new 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 (context.Interpreter.ExpressionParser.ParseLocation (context, Argument, out location))
return true;
}
uint line;
int pos = Argument.IndexOf (':');
if (pos == 0)
throw new ScriptingException ("Invalid breakpoint expression");
else if (pos > 0) {
string tmp = Argument.Substring (pos+1);
if (!UInt32.TryParse (tmp, out line))
throw new ScriptingException ("Invalid breakpoint expression");
return true;
}
if (UInt32.TryParse (Argument, out line)) {
if (!context.Interpreter.HasTarget)
throw new ScriptingException ("Cannot insert breakpoint by line: no current source file.");
return true;
}
Expression expr = context.ParseExpression (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 {
mexpr = null;
}
if (mexpr != null)
location = mexpr.EvaluateSource (context);
else {
location = context.FindMethod (Argument);
if (location != null)
return true;
address = context.CurrentProcess.LookupSymbol (Argument);
if (!address.IsNull)
return true;
}
if (lazy || gui)
return true;
//.........这里部分代码省略.........
示例3: DoParseExpression
protected Expression DoParseExpression(ScriptingContext context, string arg)
{
return context.ParseExpression (arg);
}
示例4: EvaluateExpressionType
TargetType EvaluateExpressionType(ScriptingContext context, string expression)
{
try {
Expression expr = context.ParseExpression (expression);
Expression resolved = expr.TryResolveType (context);
if (resolved != null)
expr = resolved;
else
expr = expr.Resolve (context);
if (expr == null)
Assert.Fail ("Cannot resolve expression `{0}'.", expression);
return expr.EvaluateType (context);
} catch (ScriptingException) {
throw;
} catch (AssertionException) {
throw;
} catch (Exception ex) {
Assert.Fail ("Failed to evalaute type of expression `{0}': {1}",
expression, ex);
return null;
}
}
示例5: EvaluateExpression
object EvaluateExpression(ScriptingContext context, string expression)
{
try {
Expression expr = context.ParseExpression (expression);
expr = expr.Resolve (context);
if (expr == null)
Assert.Fail ("Cannot resolve expression `{0}'.", expression);
object obj = expr.Evaluate (context);
if (obj == null)
Assert.Fail ("Failed to evaluate expression `{0}.", expression);
return obj;
} catch (ScriptingException) {
throw;
} catch (AssertionException) {
throw;
} catch (Exception ex) {
Assert.Fail ("Failed to evalaute expression `{0}': {1}",
expression, ex);
return null;
}
}
示例6: 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);
}