/// <summary>
        /// Parses an expression in text form for later evaluation.
        /// </summary>
        public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError)
        {
            DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.ParseText");
            ppExpr     = null;
            pbstrError = null;
            pichError  = 0;

            // special registers group?
            if (pszCode.StartsWith("$reg", StringComparison.InvariantCultureIgnoreCase))
            {
                ppExpr = new DebugExpression(new DebugRegisterGroupProperty(this, false));
                return(VSConstants.S_OK);
            }

            // Try to match a local variable
            try
            {
                var locals        = GetValues();
                var localVariable = locals == null ? null : locals.FirstOrDefault(x => x.Name == pszCode);
                if (localVariable != null)
                {
                    ppExpr = new DebugExpression(new DebugStackFrameValueProperty(localVariable, null, this));
                    return(VSConstants.S_OK);
                }
            }
            catch
            {
            }

            // try to match any of the registers.
            var match = castRegisterExpression.Match(pszCode);

            if (match.Success)
            {
                var castExpr     = match.Groups[1].Value.Trim();
                var registerType = match.Groups[2].Value;
                int index        = int.Parse(match.Groups[3].Value);

                ppExpr = new DebugRegisterExpression(this, pszCode, registerType, index, castExpr);
                return(VSConstants.S_OK);
            }

            // try to match opcode help (in disassembly)
            var opHelp = Opcodes.Lookup(pszCode);

            if (opHelp != null)
            {
                ppExpr = new DebugExpression(new DebugConstProperty(pszCode, opHelp.Syntax + "\r\n\r\n" + opHelp.Arguments + "\r\n\r\n" + opHelp.Description, "(opcode)", null));
                return(VSConstants.S_OK);
            }

            return(VSConstants.E_FAIL);
        }
Beispiel #2
0
        /// <summary>
        /// Parses an expression in text form for later evaluation.
        /// </summary>
        public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError)
        {
            DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.ParseText");
            ppExpr = null;
            pbstrError = null;
            pichError = 0;

            // special registers group?
            if (pszCode.StartsWith("$reg", StringComparison.InvariantCultureIgnoreCase))
            {
                ppExpr = new DebugExpression(new DebugRegisterGroupProperty(this, false));
                return VSConstants.S_OK;
            }

            // Try to match a local variable
            try
            {
                var locals = GetValues();
                var localVariable = locals == null ? null : locals.FirstOrDefault(x => x.Name == pszCode);
                if (localVariable != null)
                {
                    ppExpr = new DebugExpression(new DebugStackFrameValueProperty(localVariable, null, this));
                    return VSConstants.S_OK;
                }
            }
            catch
            {
            }

            // try to match any of the registers.
            var match = castRegisterExpression.Match(pszCode);
            if (match.Success)
            {
                var castExpr = match.Groups[1].Value.Trim();
                var registerType = match.Groups[2].Value;
                int index = int.Parse(match.Groups[3].Value);

                ppExpr = new DebugRegisterExpression(this, pszCode, registerType, index, castExpr);
                return VSConstants.S_OK;
            }

            // try to match opcode help (in disassembly)
            var opHelp = Opcodes.Lookup(pszCode);
            if (opHelp != null)
            {
                ppExpr = new DebugExpression(new DebugConstProperty(pszCode, opHelp.Syntax + "\r\n\r\n" + opHelp.Arguments + "\r\n\r\n" + opHelp.Description, "(opcode)", null));
                return VSConstants.S_OK;
            }

            return VSConstants.E_FAIL;
        }