コード例 #1
0
ファイル: DebuggedProcess.cs プロジェクト: Ourpalm/ILRuntime
        IProperty ResolveIndexAccessExpression(IStackFrame frame, IndexAccessExpression exp, uint dwTimeout)
        {
            IProperty body = Resolve(frame, exp.Body, dwTimeout);
            IProperty prop = null;

            if (body != null)
            {
                VariableReference reference = body.GetVariableReference();
                if (reference != null)
                {
                    uint threadHash;

                    if (reference.Type < VariableTypes.Error)
                    {
                        var idxExp            = exp.Index;
                        VariableReference idx = null;
                        if (idxExp is NameExpression)
                        {
                            int idxInt;
                            var content = ((NameExpression)idxExp).Content;
                            if (content == "true")
                            {
                                idx = VariableReference.True;
                            }
                            else if (content == "false")
                            {
                                idx = VariableReference.False;
                            }
                            else if (content == "null")
                            {
                                idx = VariableReference.Null;
                            }
                            else if (int.TryParse(content, out idxInt))
                            {
                                idx = VariableReference.GetInteger(idxInt);
                            }
                            else
                            {
                                var info = ResolveNameExpression(frame, (NameExpression)idxExp, dwTimeout);
                                idx = info.GetVariableReference();
                            }
                        }
                        else if (idxExp is StringLiteralExpression)
                        {
                            idx = VariableReference.GetString(((StringLiteralExpression)idxExp).Content);
                        }
                        else
                        {
                            var info = Resolve(frame, idxExp, dwTimeout);
                            idx = info.GetVariableReference();
                        }
                        if (idx != null && idx.Type < VariableTypes.Error)
                        {
                            if (exp.IsRoot)
                            {
                                var info = ResolveIndexAccess(reference, idx, frame.ThreadID, frame.Index, dwTimeout);
                                prop            = CreateProperty(frame, info);
                                prop.Parent     = body;
                                prop.Parameters = new VariableReference[] { idx };
                            }
                            else
                            {
                                var info = VariableInfo.FromObject(null);
                                info.Type       = VariableTypes.IndexAccess;
                                prop            = CreateProperty(frame, info);
                                prop.Parent     = body;
                                prop.Parameters = new VariableReference[] { idx };
                            }
                        }
                    }
                }
            }
            else
            {
                prop = CreateProperty(frame, VariableInfo.NullReferenceExeption);
            }
            return(prop);
        }