Ejemplo n.º 1
0
        public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr,
            out string pbstrError, out uint pichError)
        {
            pbstrError = "";
            pichError = 0;
            ppExpr = null;
            string lookup = pszCode;


            LocalVariable result = ThreadContext.GetVisibleVariableByName(lookup);
            if (result != null)
            {
                ppExpr = new AD7Expression(new MonoProperty(ThreadContext, result));
                return VSConstants.S_OK;
            }

            pbstrError = "Unsupported Expression";
            pichError = (uint)pbstrError.Length;
            return VSConstants.S_FALSE;
        }
Ejemplo n.º 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;
            ppExpr = null;

            if(IsDebuggingNPL())
            {
                VariableInformation varInfo = VariableInformation.Create(m_engine.DebuggedProcess, pszCode);
                if (varInfo!=null)
                {
                    ppExpr = new AD7Expression(varInfo);
                    return Constants.S_OK;
                }
                else
                {
                    return Constants.S_FALSE;
                }
            }

            try
            {
                if (m_parameters != null)
                {
                    foreach (VariableInformation currVariable in m_parameters)
                    {
                        if (String.CompareOrdinal(currVariable.m_name, pszCode) == 0)
                        {
                            ppExpr = new AD7Expression(currVariable);
                            return Constants.S_OK;
                        }
                    }
                }

                if (m_locals != null)
                {
                    foreach (VariableInformation currVariable in m_locals)
                    {
                        if (String.CompareOrdinal(currVariable.m_name, pszCode) == 0)
                        {
                            ppExpr = new AD7Expression(currVariable);
                            return Constants.S_OK;
                        }
                    }
                }

                pbstrError = "Invalid Expression";
                pichError = (uint)pbstrError.Length;
                return Constants.S_FALSE;
            }
            catch (ComponentException e)
            {
                return e.HResult;
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
        }