本文整理汇总了C#中Mono.Debugger.Soft.Value类的典型用法代码示例。如果您正苦于以下问题:C# Value类的具体用法?C# Value怎么用?C# Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Value类属于Mono.Debugger.Soft命名空间,在下文中一共展示了Value类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PropertyValueReference
public PropertyValueReference (EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, Value[] indexerArgs): base (ctx)
{
this.property = property;
this.obj = obj;
this.declaringType = declaringType;
this.indexerArgs = indexerArgs;
flags = ObjectValueFlags.Property;
if (property.GetSetMethod (true) == null)
flags |= ObjectValueFlags.ReadOnly;
MethodMirror getter = property.GetGetMethod (true);
if (getter.IsStatic)
flags |= ObjectValueFlags.Global;
if (getter.IsPublic)
flags |= ObjectValueFlags.Public;
else if (getter.IsPrivate)
flags |= ObjectValueFlags.Private;
else if (getter.IsFamily)
flags |= ObjectValueFlags.Protected;
else if (getter.IsFamilyAndAssembly)
flags |= ObjectValueFlags.Internal;
else if (getter.IsFamilyOrAssembly)
flags |= ObjectValueFlags.InternalProtected;
if (property.DeclaringType.IsValueType)
flags |= ObjectValueFlags.ReadOnly; // Setting property values on structs is not supported by sdb
}
示例2: SetValues
public void SetValues (IList<FieldInfoMirror> fields, Value[] values) {
if (fields == null)
throw new ArgumentNullException ("fields");
if (values == null)
throw new ArgumentNullException ("values");
foreach (FieldInfoMirror f in fields) {
if (f == null)
throw new ArgumentNullException ("field");
CheckMirror (f);
}
foreach (Value v in values) {
if (v == null)
throw new ArgumentNullException ("values");
CheckMirror (v);
}
long[] ids = new long [fields.Count];
for (int i = 0; i < fields.Count; ++i)
ids [i] = fields [i].Id;
try {
vm.conn.Object_SetValues (id, ids, vm.EncodeValues (values));
} catch (CommandException ex) {
if (ex.ErrorCode == ErrorCode.INVALID_FIELDID)
throw new ArgumentException ("One of the fields is not valid for this type.", "fields");
else if (ex.ErrorCode == ErrorCode.INVALID_ARGUMENT)
throw new ArgumentException ("One of the values is not valid for its field.", "values");
else
throw;
}
}
示例3: SetValues
public void SetValues (int index, Value[] values) {
if (values == null)
throw new ArgumentNullException ("values");
// FIXME: Multiple dimensions
if (index < 0 || index > Length - values.Length)
throw new IndexOutOfRangeException ();
vm.conn.Array_SetValues (id, index, vm.EncodeValues (values));
}
示例4: PropertyValueReference
public PropertyValueReference (EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs): base (ctx)
{
this.property = property;
this.obj = obj;
this.declaringType = declaringType;
this.indexerArgs = indexerArgs;
flags = GetFlags (property, getter);
}
示例5: NormalizeValue
Value NormalizeValue (EvaluationContext ctx, Value value)
{
if (variable.Type.IsPointer) {
long addr = (long) ((PrimitiveValue) value).Value;
return new PointerValue (value.VirtualMachine, variable.Type, addr);
}
return ctx.Adapter.IsNull (ctx, value) ? null : value;
}
示例6: PropertyValueReference
public PropertyValueReference (EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs): base (ctx)
{
this.declaringType = declaringType;
this.indexerArgs = indexerArgs;
this.property = property;
this.getter = getter;
this.obj = obj;
var objectMirror = obj as ObjectMirror;
if (objectMirror != null)
EnsureContextHasDomain (objectMirror.Domain);
flags = GetFlags (property, getter);
}
示例7: CreateBoxedValue
public ObjectMirror CreateBoxedValue (Value value) {
if (value == null)
throw new ArgumentNullException ("value");
if (!(value is PrimitiveValue) && !(value is StructMirror))
throw new ArgumentException ("Value must be a PrimitiveValue or a StructMirror", "value");
if ((value is PrimitiveValue) && (value as PrimitiveValue).Value == null)
return null;
TypeMirror t = null;
if (value is PrimitiveValue)
t = GetCorrespondingType ((value as PrimitiveValue).Value.GetType ());
else
t = (value as StructMirror).Type;
return vm.GetObject<ObjectMirror> (vm.conn.Domain_CreateBoxedValue (id, t.Id, vm.EncodeValue (value)));
}
示例8: BeginInvokeMethod
internal static IInvokeAsyncResult BeginInvokeMethod (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options, AsyncCallback callback, object state) {
if (thread == null)
throw new ArgumentNullException ("thread");
if (method == null)
throw new ArgumentNullException ("method");
if (arguments == null)
arguments = new Value [0];
InvokeFlags f = InvokeFlags.NONE;
if ((options & InvokeOptions.DisableBreakpoints) != 0)
f |= InvokeFlags.DISABLE_BREAKPOINTS;
if ((options & InvokeOptions.SingleThreaded) != 0)
f |= InvokeFlags.SINGLE_THREADED;
if ((options & InvokeOptions.ReturnOutThis) != 0)
f |= InvokeFlags.OUT_THIS;
if ((options & InvokeOptions.ReturnOutArgs) != 0)
f |= InvokeFlags.OUT_ARGS;
InvokeAsyncResult r = new InvokeAsyncResult { AsyncState = state, AsyncWaitHandle = new ManualResetEvent (false), VM = vm, Thread = thread, Callback = callback };
thread.InvalidateFrames ();
r.ID = vm.conn.VM_BeginInvokeMethod (thread.Id, method.Id, this_obj != null ? vm.EncodeValue (this_obj) : vm.EncodeValue (vm.CreateValue (null)), vm.EncodeValues (arguments), f, InvokeCB, r);
return r;
}
示例9: InvokeMethod
internal static Value InvokeMethod (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options) {
return EndInvokeMethodInternal (BeginInvokeMethod (vm, thread, method, this_obj, arguments, options, null, null));
}
示例10: RuntimeInvoke
public Value RuntimeInvoke (MethodMirror method, object target, Value[] values)
{
if (values != null) {
// Some arguments may need to be boxed
var mparams = method.GetParameters ();
if (mparams.Length != values.Length)
throw new EvaluatorException ("Invalid number of arguments when calling: " + method.Name);
for (int n = 0; n < mparams.Length; n++) {
var tm = mparams[n].ParameterType;
if (tm.IsValueType || tm.IsPrimitive)
continue;
var type = Adapter.GetValueType (this, values[n]);
var argTypeMirror = type as TypeMirror;
var argType = type as Type;
if (IsValueTypeOrPrimitive (argTypeMirror) || IsValueTypeOrPrimitive (argType)) {
// A value type being assigned to a parameter which is not a value type. The value has to be boxed.
try {
values[n] = Thread.Domain.CreateBoxedValue (values [n]);
} catch (NotSupportedException) {
// This runtime doesn't support creating boxed values
throw new EvaluatorException ("This runtime does not support creating boxed values.");
}
}
}
}
if (!method.IsStatic && method.DeclaringType.IsClass && !IsValueTypeOrPrimitive (method.DeclaringType)) {
object type = Adapter.GetValueType (this, target);
var targetTypeMirror = type as TypeMirror;
var targetType = type as Type;
if ((target is StructMirror && ((StructMirror) target).Type != method.DeclaringType) ||
(IsValueTypeOrPrimitive (targetTypeMirror) || IsValueTypeOrPrimitive (targetType))) {
// A value type being assigned to a parameter which is not a value type. The value has to be boxed.
try {
target = Thread.Domain.CreateBoxedValue ((Value) target);
} catch (NotSupportedException) {
// This runtime doesn't support creating boxed values
throw new EvaluatorException ("This runtime does not support creating boxed values.");
}
}
}
try {
return method.Evaluate (target is TypeMirror ? null : (Value) target, values);
} catch (NotSupportedException) {
AssertTargetInvokeAllowed ();
var mc = new MethodCall (this, method, target, values);
Adapter.AsyncExecute (mc, Options.EvaluationTimeout);
return mc.ReturnValue;
}
}
示例11: SetValue
public void SetValue (FieldInfoMirror field, Value value) {
SetValues (new FieldInfoMirror [] { field }, new Value [] { value });
}
示例12: SetThis
// Since protocol version 2.44
public void SetThis (Value value) {
if (value == null)
throw new ArgumentNullException ("value");
if (Method.IsStatic || !Method.DeclaringType.IsValueType)
throw new InvalidOperationException ("The frame's method needs to be a valuetype instance method.");
vm.conn.StackFrame_SetThis (thread.Id, Id, vm.EncodeValue (value));
}
示例13: VariableValueReference
public VariableValueReference (EvaluationContext ctx, string name, LocalVariable variable, Value value) : base (ctx)
{
this.variable = variable;
this.value = value;
this.name = name;
}
示例14: EnumMirror
internal EnumMirror (VirtualMachine vm, TypeMirror type, Value[] fields) : base (vm, type, fields) {
}
示例15: Evaluate
public Value Evaluate (Value this_val, Value[] args) {
var body = method.GetMethodBody ();
// Implement only the IL opcodes required to evaluate mcs compiled property accessors:
// IL_0000: nop
// IL_0001: ldarg.0
// IL_0002: ldfld int32 Tests::field_i
// IL_0007: stloc.0
// IL_0008: br IL_000d
// IL_000d: ldloc.0
// IL_000e: ret
if (args != null && args.Length != 0)
throw new NotSupportedException ();
if (method.IsStatic || method.DeclaringType.IsValueType || this_val == null || !(this_val is ObjectMirror))
throw new NotSupportedException ();
var instructions = body.Instructions;
if (instructions.Count > 16)
throw new NotSupportedException ();
Value[] stack = new Value [16];
Value locals_0 = null;
Value res = null;
int sp = 0;
int ins_count = 0;
var ins = instructions [0];
while (ins != null) {
if (ins_count > 16)
throw new NotImplementedException ();
ins_count ++;
var next = ins.Next;
var op = ins.OpCode;
if (op == OpCodes.Nop) {
} else if (op == OpCodes.Ldarg_0) {
if (sp > 0)
throw new NotSupportedException ();
stack [sp++] = this_val;
} else if (op == OpCodes.Ldfld) {
if (sp != 1)
throw new NotSupportedException ();
var obj = (ObjectMirror)stack [--sp];
var field = (FieldInfoMirror)ins.Operand;
stack [sp++] = obj.GetValue (field);
} else if (op == OpCodes.Stloc_0) {
if (sp != 1)
throw new NotSupportedException ();
locals_0 = stack [--sp];
} else if (op == OpCodes.Br) {
next = (ILInstruction)ins.Operand;
} else if (op == OpCodes.Ldloc_0) {
if (sp != 0)
throw new NotSupportedException ();
stack [sp++] = locals_0;
} else if (op == OpCodes.Ret) {
if (sp == 0)
res = null;
else
res = stack [--sp];
break;
}
ins = next;
}
return res;
}