예제 #1
0
        // Parses a text-based expression for evaluation.
        // The engine sample only supports locals and parameters so the only task here is to check the names in those collections.
        int IDebugExpressionContext2.ParseText(string pszCode,
                                               enum_PARSEFLAGS dwFlags,
                                               uint nRadix,
                                               out IDebugExpression2 ppExpr,
                                               out string pbstrError,
                                               out uint pichError)
        {
            pbstrError = "";
            pichError  = 0;
            ppExpr     = null;

            if (_parameters != null)
            {
                foreach (var currVariable in _parameters)
                {
                    if (String.CompareOrdinal(currVariable.Expression, pszCode) == 0)
                    {
                        ppExpr = new UncalculatedAD7Expression(this, currVariable.Expression, true);
                        return(VSConstants.S_OK);
                    }
                }
            }

            if (_locals != null)
            {
                foreach (var currVariable in _locals)
                {
                    if (String.CompareOrdinal(currVariable.Expression, pszCode) == 0)
                    {
                        ppExpr = new UncalculatedAD7Expression(this, currVariable.Expression, true);
                        return(VSConstants.S_OK);
                    }
                }
            }

            string errorMsg;

            if (!_stackFrame.TryParseText(pszCode, out errorMsg))
            {
                pbstrError = "Error: " + errorMsg;
                pichError  = (uint)pbstrError.Length;
            }

            ppExpr = new UncalculatedAD7Expression(this, pszCode);
            return(VSConstants.S_OK);
        }