/// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
            out IDebugProperty2 ppResult)
        {
            ppResult = null;
            int idx = _index;

            if (string.IsNullOrEmpty(_castExpr))
            {
                var reg = _stackFrame.GetRegistersAsync().Await((int) dwTimeout)
                                     .FirstOrDefault(r => r.Name == _registerType + _index);
                if (reg != null)
                {
                    ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
                    return VSConstants.S_OK;
                }
            }
            else
            {
                var tag = GetTagFromString(_castExpr);

                if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
                {
                    // this evaluation has "side effects" in that it might crash the VM
                    // if the cast is to "object" or "string", but the register does not 
                    // hold an object or string.
                    ppResult = new DebugConstProperty(_expression, "(this cast might crash the VM if the register is not of the casted type)", _castExpr, null)
                                                     { HasSideEffects = true };
                    return VSConstants.E_FAIL;
                }

                var isParam = _registerType == "p";

                if (isParam)
                {
                    var loc = _stackFrame.GetDocumentLocationAsync().Await((int) dwTimeout);
                    if (loc == null)
                        return VSConstants.E_FAIL;
                    var methodDiss = _stackFrame.Thread.Program.DisassemblyProvider.GetFromLocation(loc);
                    if (methodDiss == null)
                        return VSConstants.E_FAIL;
                    idx += methodDiss.Method.Body.Registers.Count - methodDiss.Method.Body.IncomingArguments;
                }

                var reg = _stackFrame.GetRegistersAsync(false, tag, idx).Await((int) dwTimeout);

                if (reg != null && reg.Count > 0)
                {
                    ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
                    {
                        HasSideEffects = !tag.IsPrimitive()
                    };
                    return VSConstants.S_OK;
                }
            }

            return VSConstants.E_FAIL;
        }
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
                                out IDebugProperty2 ppResult)
        {
            ppResult = null;

            if (string.IsNullOrEmpty(_castExpr))
            {
                var reg = _stackFrame.GetRegistersAsync().Await((int)dwTimeout)
                          .FirstOrDefault(r => r.Name == _registerType + _index);
                if (reg != null)
                {
                    ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
                    return(VSConstants.S_OK);
                }
            }
            else
            {
                var tag = GetTagFromString(_castExpr);

                if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
                {
                    // this evaluation has "side effects" in that it might crash the VM
                    // if the cast is to "object" or "string", but the register does not
                    // hold an object or string.
                    ppResult = new DebugConstProperty(_expression, "(this cast might crash a DalvikVM if the register is not of the casted type)", _castExpr, null)
                    {
                        HasSideEffects = true
                    };
                    return(VSConstants.E_FAIL);
                }

                var regNames = _stackFrame.GetRegisterNamesAsync().Await((int)dwTimeout);
                var vmIdx    = regNames.GetVmIndex(_registerType == "p", _index);

                if (vmIdx < 0)
                {
                    return(VSConstants.E_FAIL);
                }

                var reg = _stackFrame.GetRegistersAsync(false, tag, vmIdx).Await((int)dwTimeout);

                if (reg != null && reg.Count > 0)
                {
                    ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
                    {
                        HasSideEffects = !tag.IsPrimitive()
                    };
                    return(VSConstants.S_OK);
                }
            }

            return(VSConstants.E_FAIL);
        }
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
            out IDebugProperty2 ppResult)
        {
            ppResult = null;

            if (string.IsNullOrEmpty(_castExpr))
            {
                var reg = _stackFrame.GetRegistersAsync().Await((int) dwTimeout)
                                     .FirstOrDefault(r => r.Name == _registerType + _index);
                if (reg != null)
                {
                    ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
                    return VSConstants.S_OK;
                }
            }
            else
            {
                var tag = GetTagFromString(_castExpr);

                if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
                {
                    // this evaluation has "side effects" in that it might crash the VM
                    // if the cast is to "object" or "string", but the register does not
                    // hold an object or string.
                    ppResult = new DebugConstProperty(_expression, "(this cast might crash a DalvikVM if the register is not of the casted type)", _castExpr, null)
                                                     { HasSideEffects = true };
                    return VSConstants.E_FAIL;
                }

                var regNames = _stackFrame.GetRegisterNamesAsync().Await((int)dwTimeout);
                var vmIdx = regNames.GetVmIndex(_registerType == "p", _index);

                if (vmIdx < 0)
                    return VSConstants.E_FAIL;

                var reg = _stackFrame.GetRegistersAsync(false, tag, vmIdx).Await((int)dwTimeout);

                if (reg != null && reg.Count > 0)
                {
                    ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
                    {
                        HasSideEffects = !tag.IsPrimitive()
                    };
                    return VSConstants.S_OK;
                }
            }

            return VSConstants.E_FAIL;
        }