Exemplo n.º 1
0
        public DebugMethod(DebugEnvironment envr, CDebugMethodSymbol method, DebugMethodScope scope)
        {
            this.debugEnv      = envr;
            this.methodSymbol  = method;
            this.DeclaringType = method.GetDeclaringType().CompilerType;
            SymbolModifiers modifier = this.methodSymbol.Modifiers;

            if ((modifier & SymbolModifiers.Abstract) != 0)
            {
                this.Flags |= MethodFlags.Abstract;
            }
            if ((modifier & SymbolModifiers.Final) != 0)
            {
                this.Flags |= MethodFlags.Final;
            }
            if ((modifier & SymbolModifiers.Private) != 0)
            {
                this.Flags |= MethodFlags.Private;
            }
            if ((modifier & SymbolModifiers.Public) != 0)
            {
                this.Flags |= MethodFlags.Public;
            }
            if ((modifier & SymbolModifiers.Static) != 0)
            {
                this.Flags |= MethodFlags.Static;
            }

            this.Scope = scope;
            if (this.methodSymbol != null)
            {
                IDebugFieldSymbol thisSymbol = this.methodSymbol.GetThis();
                if (thisSymbol != null)
                {
                    this.ThisParameter = new This(new DebugClassNode(this.debugEnv, thisSymbol.Type, thisSymbol.GetValue(null)));
                }
                ParameterList pList = new ParameterList();
                IEnumSymbol   param = methodSymbol.GetParameters();
                if (param != null)
                {
                    for (int i = 1; ; i++)
                    {
                        if (param.Current == null)
                        {
                            break;
                        }
                        ParameterField paramField = new DebugParameterField(this.debugEnv, param.Current, new Identifier(param.Current.Name), null, scope);
                        paramField.DeclaringType = scope;
                        pList[i] = new Parameter(paramField.Name, paramField.Type);
                        pList[i].ArgumentListIndex = i;
                        param.MoveNext();
                    }
                }
                this.Parameters = pList;
            }
        }
Exemplo n.º 2
0
        public virtual BaseProperty MakeProperty(IDebugFieldSymbol symbol, IDebugProperty parent, IDebugValue containerValue)
        {
            IDebugType  staticType = symbol.Type;
            IDebugValue value      = symbol.GetValue(containerValue);

            if (symbol.Name == "this value: ")
            {
                return(this.MakeProperty("this", symbol.Type, value, parent));
            }
            return(this.MakeProperty(symbol.Name, symbol.Type, value, parent));
        }
Exemplo n.º 3
0
 public DebugMethodScope(DebugEnvironment envr, CDebugMethodSymbol method)
 {
     this.debugEnv = envr;
     if (method != null)
     {
         this.methodSymbol = method;
         IDebugFieldSymbol thisSymbol = method.GetThis();
         if (thisSymbol != null)
         {
             this.ThisType  = new DebugClassNode(this.debugEnv, thisSymbol.Type, thisSymbol.GetValue(null));
             this.BaseClass = new DebugTypeScope(this.debugEnv, null, this.ThisType);
         }
         else
         {
             IDebugClassType classType = method.GetDeclaringType();
             if (classType != null)
             {
                 Class declaringType = new DebugClassNode(this.debugEnv, classType, null);
                 this.BaseClass = new DebugTypeScope(this.debugEnv, null, declaringType);
             }
         }
         this.DeclaringMethod = new DebugMethod(this.debugEnv, this.methodSymbol, this);
     }
 }
Exemplo n.º 4
0
 public virtual BaseProperty MakeProperty(IDebugFieldSymbol symbol, IDebugProperty parent, IDebugValue containerValue){
   IDebugType staticType = symbol.Type;
   IDebugValue value = symbol.GetValue(containerValue);
   if (symbol.Name == "this value: ")
     return this.MakeProperty("this", symbol.Type, value, parent);
   return this.MakeProperty(symbol.Name, symbol.Type, value, parent);
 }
Exemplo n.º 5
0
        private IDebugProperty EvaluateExpression(uint evalFlags, uint timeout, IDebugContext context, String resultType)
        {
            if (this.debugContext == null)
            {
                this.debugContext = new DebugEnvironment();
            }
            this.debugContext.context = context;
            BlockScope    scope  = new DebugBlockScope(this.debugContext);
            ErrorNodeList errors = new ErrorNodeList();

            if (this.cciExpr.compiledExpression == null)
            {
                this.cciExpr.compiledExpression = (Expression)this.cciExpr.EE.ExprCompiler.CompileParseTree(this.cciExpr.ParsedExpr, scope, new Module(), errors);
                if (errors.Count > 0)
                {
                    this.cciExpr.compiledExpression = null;
                }
            }
            if (this.cciExpr.compiledExpression != null)
            {
                StackFrame         currentFrame = new StackFrame();
                IDebugMethodSymbol methodSym    = this.debugContext.context.GetContainer() as CDebugMethodSymbol;
                if (methodSym != null)
                {
                    IDebugFieldSymbol thisSymbol = methodSym.GetThis();
                    if (thisSymbol != null)
                    {
                        currentFrame.thisObject = new Literal(thisSymbol.GetValue(null), ((MethodScope )scope.BaseClass).ThisType);
                    }
                    else
                    {
                        currentFrame.thisObject = null;
                    }
                    currentFrame.parameters[0] = currentFrame.thisObject;
                    IEnumSymbol locals = methodSym.GetLocals();
                    if (locals != null)
                    {
                        for (int i = 0; ; i++)
                        {
                            if (locals.Current == null)
                            {
                                break;
                            }
                            Field localField = new DebugFieldNode(this.debugContext, locals.Current, new Identifier(locals.Current.Name), null, null, i);
                            currentFrame.locals[i] = localField.GetValue(null);
                            locals.MoveNext();
                        }
                    }
                    IEnumSymbol param = methodSym.GetParameters();
                    if (param != null)
                    {
                        for (int i = 1; ; i++)
                        {
                            if (param.Current == null)
                            {
                                break;
                            }
                            Field paramField = new DebugFieldNode(this.debugContext, param.Current, new Identifier(param.Current.Name), null, null, i);
                            currentFrame.parameters[i] = paramField.GetValue(null);
                            param.MoveNext();
                        }
                    }
                }
                if (this.cciExpr.EE.ExprEvaluator == null)
                {
                    this.cciExpr.EE.ExprEvaluator = new Evaluator();
                }
                this.cciExpr.EE.ExprEvaluator.stackFrame = currentFrame;
                Literal resultExpr = this.cciExpr.EE.ExprEvaluator.VisitExpression(this.cciExpr.compiledExpression) as Literal;
                if (resultExpr != null)
                {
                    if (resultExpr.Value is IDebugValue && resultExpr.Type is IDebugInfo) //already wrapped for use by debugger
                    {
                        return(this.cciExpr.EE.MakeProperty(this.cciExpr.Expr, ((IDebugInfo)resultExpr.Type).GetDebugType, (IDebugValue)resultExpr.Value, null));
                    }
                    else if (resultExpr.Value is IDebugValue)
                    {
                        return(this.cciExpr.EE.MakeProperty(this.cciExpr.Expr, ((IDebugValue)resultExpr.Value).RuntimeType(), (IDebugValue)resultExpr.Value, null));
                    }
                    if (resultExpr.Value != null)
                    {
                        return(new ExpressionEvalProperty(this.cciExpr.Expr, resultExpr.Type.FullName, resultExpr.Value.ToString(), resultExpr, this.cciExpr.EE));
                    }
                }
                else
                {
                    return(new ExpressionEvalProperty(this.cciExpr.Expr, String.Empty, "Error Evaluating Expression.", null, this.cciExpr.EE));
                }
            }
            else if (errors.Count > 0)
            {
                return(new ExpressionEvalProperty(this.cciExpr.Expr, String.Empty, errors[0].GetMessage(), null, this.cciExpr.EE));
            }
            return(new ExpressionEvalProperty(this.cciExpr.Expr, String.Empty, "Unknown Compiler Error.", null, this.cciExpr.EE));
        }