Exemple #1
0
        public override Local GetLocalForField(Field f)
        {
            DebugFieldNode debugField = f as DebugFieldNode;

            if (debugField != null)
            {
                Local loc = (Local)this.Locals[debugField.index + 1];
                if (loc == null)
                {
                    this.Locals[debugField.index + 1] = loc = new Local(debugField.Name, debugField.Type);
                }
                loc.Index = debugField.index;
                return(loc);
            }
            return(null);
        }
Exemple #2
0
        public override MemberList GetMembersNamed(Identifier name)
        {
            MemberList      returnList = new MemberList();
            CDebugClassType classType  = this.GetDebugType as CDebugClassType;

            if (classType != null)
            {
                IEnumSymbol members = classType.GetMembers(name.Name, true, SymbolKind.Field | SymbolKind.Property, SymbolModifiers.All);
                if (members != null)
                {
                    while (members.Current != null)
                    {
                        if (members.Current.Name == name.Name)
                        {
                            Field           fieldMember = new DebugFieldNode(this.debugEnv, members.Current, name, this.Value, this, 0);
                            SymbolModifiers modifier    = members.Current.Modifiers;
                            if ((modifier & SymbolModifiers.Abstract) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.None;
                            }
                            if ((modifier & SymbolModifiers.Final) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.None;
                            }
                            if ((modifier & SymbolModifiers.Private) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.Private;
                            }
                            if ((modifier & SymbolModifiers.Public) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.Public;
                            }
                            if ((modifier & SymbolModifiers.Static) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.Static;
                            }
                            returnList.Add(fieldMember);
                            break;
                        }
                        members.MoveNext();
                    }
                }
            }

            return(returnList);
        }
Exemple #3
0
        public override MemberList GetMembersNamed(Identifier name)
        {
            MemberList   returnList = new MemberList();
            IDebugSymbol container  = this.debugEnv.context.GetContainer();

            CDebugMethodSymbol methodSymbol = null;

            if ((methodSymbol = container as CDebugMethodSymbol) != null)
            {
                if (name.Name == "this")
                {
                    returnList.Add(new DebugFieldNode(this.debugEnv, methodSymbol.GetThis(), name, null, null, 0));
                }
                else
                {
                    IEnumSymbol locals = methodSymbol.GetLocals();
                    if (locals != null)
                    {
                        for (int i = 0; ; i++)
                        {
                            if (locals.Current == null)
                            {
                                break;
                            }
                            if (locals.Current.Name == name.Name)
                            {
                                Field localField = new DebugFieldNode(this.debugEnv, locals.Current, name, null, this, i);
                                localField.DeclaringType = this;
                                returnList.Add(localField);
                                break;
                            }
                            locals.MoveNext();
                        }
                    }
                }
            }
            return(returnList);
        }
Exemple #4
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));
        }
Exemple #5
0
        public DebugFieldNode(DebugEnvironment envr, IDebugSymbol symbol, Identifier name, IDebugValue container, TypeNode declaringType, int id)
        {
            this.debugEnv      = envr;
            this.Symbol        = symbol;
            this.Container     = container;
            this.Name          = name;
            this.index         = id;
            this.DeclaringType = declaringType;
            switch (symbol.Type.Kind)
            {
            case TypeKind.Class:
                this.Type = new DebugClassNode(this.debugEnv, this.Symbol.Type, ((IDebugFieldSymbol )symbol).GetValue(Container));
                break;

            case TypeKind.Stream:
                this.Type = symbol.Type.CompilerType;
                break;

            case TypeKind.Tuple:
                StructTypes sType = ((IDebugStructuralType)this.Symbol.Type).StructuralType;
                switch (sType)
                {
                case StructTypes.Tuple:
                    FieldList   list    = new FieldList();
                    IEnumSymbol symbols = ((IDebugStructuralType)this.Symbol.Type).GetMembers(null, true, SymbolKind.Field, SymbolModifiers.All);
                    if (symbols != null)
                    {
                        while (symbols.Current != null)
                        {
                            Field           fieldMember = new DebugFieldNode(this.debugEnv, symbols.Current, new Identifier(symbols.Current.Name), ((IDebugFieldSymbol )symbol).GetValue(Container), null, 0);
                            SymbolModifiers modifier    = symbols.Current.Modifiers;
                            if ((modifier & SymbolModifiers.Abstract) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.None;
                            }
                            if ((modifier & SymbolModifiers.Final) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.None;
                            }
                            if ((modifier & SymbolModifiers.Private) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.Private;
                            }
                            if ((modifier & SymbolModifiers.Public) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.Public;
                            }
                            if ((modifier & SymbolModifiers.Static) != 0)
                            {
                                fieldMember.Flags |= FieldFlags.Static;
                            }
                            list.Add(fieldMember);
                            symbols.MoveNext();
                        }
                    }
                    Class dummy = new Class();
                    dummy.DeclaringModule = new Module();
                    this.Type             = TupleType.For(list, dummy);
                    break;

                case StructTypes.Union:
                    // HACK: Need a better way for identifying return types
                    this.Type = TypeUnion.For(SymbolHelper.GetTypeList(this.Symbol.Type.FullName, this.debugEnv.context), new Module());
                    break;

                case StructTypes.Intersection:
                    // TODO: Need to figure out Intersection Types, I think depends on figuring out return Type
                    //this.Type = TypeIntersection.For(typeList, new Module());
                    this.Type = new Class();
                    break;
                }

                /*FieldList list = new FieldList();
                 * IEnumSymbol symbols = ((IDebugStructuralType) this.Symbol.Type).GetMembers(null, true, SymbolKind.Field, SymbolModifiers.All);
                 * if (symbols != null){
                 * while(symbols.Current != null){
                 *  list.Add(new DebugFieldNode(this.debugEnv, symbols.Current, new Identifier(symbols.Current.Name), null, null, 0));
                 *  symbols.MoveNext();
                 * }
                 * }
                 * Class dummy = new Class();
                 * dummy.DeclaringModule = new Module();
                 * this.Type = TupleType.For(list, dummy);*/
                break;

            case TypeKind.Primitive:
                switch (this.Symbol.Type.TypeCode)
                {
                case TypeCode.Boolean:
                    this.Type = SystemTypes.Boolean;
                    break;

                case TypeCode.Char:
                    this.Type = SystemTypes.Char;
                    break;

                case TypeCode.Int16:
                    this.Type = SystemTypes.Int16;
                    break;

                case TypeCode.UInt16:
                    this.Type = SystemTypes.UInt32;
                    break;

                case TypeCode.Int32:
                    this.Type = SystemTypes.Int32;
                    break;

                case TypeCode.UInt32:
                    this.Type = SystemTypes.UInt32;
                    break;

                case TypeCode.Int64:
                    this.Type = SystemTypes.Int64;
                    break;

                case TypeCode.UInt64:
                    this.Type = SystemTypes.UInt64;
                    break;

                case TypeCode.Double:
                    this.Type = SystemTypes.Double;
                    break;

                case TypeCode.Single:
                    this.Type = SystemTypes.Single;
                    break;

                case TypeCode.SByte:
                    this.Type = SystemTypes.Int8;
                    break;

                case TypeCode.Byte:
                    this.Type = SystemTypes.UInt8;
                    break;

                case TypeCode.String:
                    this.Type = SystemTypes.String;
                    break;
                }
                break;

            case TypeKind.Enum:
                this.Type = new DebugEnumNode(this.debugEnv, this.Symbol.Type);
                break;
            }
        }