本文整理汇总了C#中Mono.Debugger.Frontend.ScriptingContext类的典型用法代码示例。如果您正苦于以下问题:C# ScriptingContext类的具体用法?C# ScriptingContext怎么用?C# ScriptingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScriptingContext类属于Mono.Debugger.Frontend命名空间,在下文中一共展示了ScriptingContext类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoEvaluateObject
protected override TargetObject DoEvaluateObject(ScriptingContext context)
{
StackFrame frame = context.CurrentFrame;
TargetAddress address = EvaluateAddress (context);
return context.CurrentLanguage.CreatePointer (frame, address);
}
示例2: DoResolve
protected override Expression DoResolve(ScriptingContext context)
{
expr = expr.Resolve (context);
if (expr == null)
return null;
resolved = true;
return this;
}
示例3: DoEvaluateType
protected override TargetType DoEvaluateType(ScriptingContext context)
{
TargetPointerType ptype = expr.EvaluateType (context)
as TargetPointerType;
if (ptype != null)
return ptype;
return context.CurrentLanguage.PointerType;
}
示例4: EvaluateAddress
public override TargetAddress EvaluateAddress(ScriptingContext context)
{
PointerExpression pexpr = expr as PointerExpression;
if (pexpr != null)
return pexpr.EvaluateAddress (context);
TargetObject obj = expr.EvaluateObject (context);
if ((obj == null) || !obj.HasAddress)
throw new ScriptingException (
"Cannot take address of expression `{0}'", expr.Name);
return obj.GetAddress (context.CurrentThread);
}
示例5: DoExecute
protected override object DoExecute(ScriptingContext context)
{
Backtrace backtrace = null;
if ((mode == Backtrace.Mode.Default) && (max_frames == -1))
backtrace = CurrentThread.CurrentBacktrace;
if (backtrace == null)
backtrace = CurrentThread.GetBacktrace (mode, max_frames);
for (int i = 0; i < backtrace.Count; i++) {
string prefix = i == backtrace.CurrentFrameIndex ? "(*)" : " ";
context.Print ("{0} {1}", prefix, backtrace [i]);
EmonicInterpreter.backtraceData bt = new EmonicInterpreter.backtraceData();
bt.frameNumber = backtrace[i].Level;
bt.currentFrame = i == backtrace.CurrentFrameIndex;
if (backtrace[i].Method != null) {
bt.method = backtrace[i].Method.Name;
if (bt.method == null)
bt.method = "";
} else {
if (backtrace[i].Name == null)
bt.method = "";
else {
bt.method = backtrace[i].Name.ToString();
if (bt.method == null)
bt.method = "";
}
}
if (backtrace[i].SourceAddress != null && backtrace[i].SourceAddress.SourceFile != null)
bt.file = backtrace[i].SourceAddress.SourceFile.FileName;
else
bt.file = "";
if (backtrace[i].SourceAddress != null)
bt.lineNumber = backtrace[i].SourceAddress.Row;
else
bt.lineNumber = -1;
if (i+1 < backtrace.Count)
bt.moreData = true;
else
bt.moreData = false;
EmonicInterpreter.backtraceList.Add(bt);
}
return backtrace;
}
示例6: 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);
}
}
示例7: DoCast
TargetObject DoCast(ScriptingContext context, Expression expr,
TargetType target_type)
{
TargetObject source = expr.EvaluateObject (context);
if (source == null)
return null;
if (target_type is TargetObjectType) {
if (((source is TargetClassObject) && !source.Type.IsByRef) ||
(source is TargetFundamentalObject))
return target_type.Language.CreateBoxedObject (context.CurrentThread, source);
if (source is TargetObjectObject)
return source;
throw new ScriptingException (
"Cannot box object `{0}': not a value-type", expr.Name);
}
if (target_type is TargetPointerType) {
TargetAddress address;
PointerExpression pexpr = expr as PointerExpression;
if (pexpr != null)
address = pexpr.EvaluateAddress (context);
else {
TargetPointerType ptype = expr.EvaluateType (context)
as TargetPointerType;
if ((ptype == null) || ptype.IsTypesafe)
return null;
pexpr = new AddressOfExpression (expr);
pexpr.Resolve (context);
address = pexpr.EvaluateAddress (context);
}
return ((TargetPointerType) target_type).GetObject (address);
}
if (target_type is TargetFundamentalType) {
TargetFundamentalObject fobj = expr.EvaluateObject (context)
as TargetFundamentalObject;
if (fobj == null)
return null;
TargetFundamentalType ftype = target_type as TargetFundamentalType;
return Convert.ExplicitFundamentalConversion (context, fobj, ftype);
}
TargetClassType ctype = Convert.ToClassType (target_type);
TargetClassObject source_cobj = Convert.ToClassObject (context.CurrentThread, source);
if (source_cobj == null)
throw new ScriptingException (
"Variable {0} is not a class type.", expr.Name);
return TryCast (context, source_cobj, ctype);
}
示例8: DoEvaluate
protected override object DoEvaluate(ScriptingContext context)
{
return val;
}
示例9: GetValue
private long GetValue(ScriptingContext context, Expression expr)
{
object val = expr.Evaluate (context);
again:
if (val is int)
return (long) (int) val;
else if (val is uint)
return (long) (uint) val;
else if (val is ulong)
return (long) (ulong) val;
else if (val is long)
return (long) val;
else if (val is TargetPointerObject) {
TargetPointerObject pobj = (TargetPointerObject) val;
return pobj.GetAddress (context.CurrentThread).Address;
} else if (val is TargetFundamentalObject) {
TargetFundamentalObject fobj = (TargetFundamentalObject) val;
val = fobj.GetObject (context.CurrentThread);
if (!(val is TargetFundamentalObject))
goto again;
}
throw new ScriptingException ("Cannot evaluate expression `{0}'", expr.Name);
}
示例10: TryCurrentCast
static TargetClassObject TryCurrentCast(ScriptingContext context,
TargetClassObject source,
TargetClassType target_type)
{
TargetClassObject current = source.GetCurrentObject (context.CurrentThread);
if (current == null)
return null;
return TryParentCast (context, current, current.Type, target_type);
}
示例11: TryParentCast
static TargetClassObject TryParentCast(ScriptingContext context,
TargetClassObject source,
TargetClassType source_type,
TargetClassType target_type)
{
if (source_type == target_type)
return source;
if (!source_type.HasParent)
return null;
TargetClassType parent_type = source_type.GetParentType (context.CurrentThread);
source = TryParentCast (context, source, parent_type, target_type);
if (source == null)
return null;
return source.GetParentObject (context.CurrentThread) as TargetClassObject;
}
示例12: TryCast
public static TargetObject TryCast(ScriptingContext context, TargetObject source,
TargetClassType target_type)
{
if (source.Type == target_type)
return source;
TargetClassObject sobj = Convert.ToClassObject (context.CurrentThread, source);
if (sobj == null)
return null;
TargetClassObject result = TryParentCast (context, sobj, sobj.Type, target_type);
if (result != null)
return result;
return TryCurrentCast (context, sobj, target_type);
}
示例13: ShowDisplays
public void ShowDisplays(StackFrame frame)
{
ScriptingContext context = new ScriptingContext (this);
context.CurrentFrame = frame;
foreach (Display d in Session.Displays)
context.ShowDisplay (d);
}