Example #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 = String.Empty;
            pichError  = 0;

            IEnumerable <NodeEvaluationResult> evaluationResults = _stackFrame.Locals.Union(_stackFrame.Parameters);

            foreach (NodeEvaluationResult currVariable in evaluationResults)
            {
                if (String.CompareOrdinal(currVariable.Expression, pszCode) == 0)
                {
                    ppExpr = new UncalculatedAD7Expression(this, currVariable.Expression);
                    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);
        }
Example #2
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;

            if (_parameters != null)
            {
                foreach (NodeEvaluationResult currVariable in _parameters)
                {
                    if (String.CompareOrdinal(currVariable.Name, pszCode) == 0)
                    {
                        ppExpr = new AD7Expression(this, currVariable.Name);
                        return(VSConstants.S_OK);
                    }
                }
            }

            if (_locals != null)
            {
                foreach (NodeEvaluationResult currVariable in _locals)
                {
                    if (String.CompareOrdinal(currVariable.Name, pszCode) == 0)
                    {
                        ppExpr = new AD7Expression(this, currVariable.Name);
                        return(VSConstants.S_OK);
                    }
                }
            }

            string errorMsg;

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

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