示例#1
0
        /// <summary> Copy the acutal value from some other Value object </summary>
        public void SetValue(Thread evalThread, Value newValue)
        {
            ICorDebugValue newCorValue = newValue.CorValue;

            if (this.CorValue is ICorDebugReferenceValue)
            {
                if (!(newCorValue is ICorDebugReferenceValue))
                {
                    newCorValue = newValue.Box(evalThread).CorValue;
                }
                ((ICorDebugReferenceValue)this.CorValue).SetValue(((ICorDebugReferenceValue)newCorValue).GetValue());
            }
            else
            {
                this.CorGenericValue.SetRawValue(newValue.CorGenericValue.GetRawValue());
            }
        }
示例#2
0
        /// <summary> Copy the acutal value from some other Value object </summary>
        public void SetValue(Value newValue)
        {
            ICorDebugValue newCorValue = newValue.CorValue;

            if (this.IsReference)
            {
                if (!newCorValue.Is <ICorDebugReferenceValue>())
                {
                    newCorValue = newValue.Box().CorValue;
                }
                corValue.CastTo <ICorDebugReferenceValue>().SetValue(newCorValue.CastTo <ICorDebugReferenceValue>().Value);
            }
            else
            {
                corValue.CastTo <ICorDebugGenericValue>().RawValue = newValue.CorGenericValue.RawValue;
            }
        }
示例#3
0
		/// <summary> Copy the acutal value from some other Value object </summary>
		public void SetValue(Thread evalThread, Value newValue)
		{
			ICorDebugValue newCorValue = newValue.CorValue;
			
			if (this.CorValue is ICorDebugReferenceValue) {
				if (!(newCorValue is ICorDebugReferenceValue))
					newCorValue = newValue.Box(evalThread).CorValue;
				((ICorDebugReferenceValue)this.CorValue).SetValue(((ICorDebugReferenceValue)newCorValue).GetValue());
			} else {
				this.CorGenericValue.SetRawValue(newValue.CorGenericValue.GetRawValue());
			}
		}
示例#4
0
		/// <summary> Copy the acutal value from some other Value object </summary>
		public void SetValue(Value newValue)
		{
			ICorDebugValue newCorValue = newValue.CorValue;
			
			if (this.IsReference) {
				if (!newCorValue.Is<ICorDebugReferenceValue>()) {
					newCorValue = newValue.Box().CorValue;
				}
				corValue.CastTo<ICorDebugReferenceValue>().SetValue(newCorValue.CastTo<ICorDebugReferenceValue>().Value);
			} else {
				corValue.CastTo<ICorDebugGenericValue>().RawValue = newValue.CorGenericValue.RawValue;
			}
		}
示例#5
0
        /// <exception cref="GetValueException"><c>GetValueException</c>.</exception>
        static void MethodInvokeStarter(Eval eval, DebugMethodInfo method, Value thisValue, Value[] args)
        {
            List <ICorDebugValue> corArgs = new List <ICorDebugValue>();

            args = args ?? new Value[0];
            if (args.Length != method.ParameterCount)
            {
                throw new GetValueException("Invalid parameter count");
            }
            if (!method.IsStatic)
            {
                if (thisValue == null)
                {
                    throw new GetValueException("'this' is null");
                }
                if (thisValue.IsNull)
                {
                    throw new GetValueException("Null reference");
                }
                // if (!(thisValue.IsObject)) // eg Can evaluate on array
                if (!method.DeclaringType.IsInstanceOfType(thisValue))
                {
                    throw new GetValueException(
                              "Can not evaluate because the object is not of proper type.  " +
                              "Expected: " + method.DeclaringType.FullName + "  Seen: " + thisValue.Type.FullName
                              );
                }
                corArgs.Add(thisValue.CorValue);
            }
            for (int i = 0; i < args.Length; i++)
            {
                Value     arg       = args[i];
                DebugType paramType = (DebugType)method.GetParameters()[i].ParameterType;
                if (!arg.Type.CanImplicitelyConvertTo(paramType))
                {
                    throw new GetValueException("Inncorrect parameter type");
                }
                // Implicitely convert to correct primitve type
                if (paramType.IsPrimitive && args[i].Type != paramType)
                {
                    object oldPrimVal = arg.PrimitiveValue;
                    object newPrimVal = Convert.ChangeType(oldPrimVal, paramType.PrimitiveType);
                    arg = CreateValue(method.AppDomain, newPrimVal);
                }
                // It is importatnt to pass the parameted in the correct form (boxed/unboxed)
                if (paramType.IsValueType)
                {
                    corArgs.Add(arg.CorGenericValue);
                }
                else
                {
                    if (args[i].Type.IsValueType)
                    {
                        corArgs.Add(arg.Box().CorValue);
                    }
                    else
                    {
                        corArgs.Add(arg.CorValue);
                    }
                }
            }

            ICorDebugType[] genericArgs = ((DebugType)method.DeclaringType).GenericArgumentsAsCorDebugType;
            eval.CorEval2.CallParameterizedFunction(
                method.CorFunction,
                (uint)genericArgs.Length, genericArgs,
                (uint)corArgs.Count, corArgs.ToArray()
                );
        }