コード例 #1
0
ファイル: MSILAnalysis.cs プロジェクト: cephdon/systemsharp
        private IEnumerable <ReferenceInfo> HandleCall(ILInstruction ili, ControlFlowGraph <ILInstruction> cfg)
        {
            MethodBase mb = (MethodBase)ili.Operand;
            List <ReferenceInfo.EMode> modes = new List <ReferenceInfo.EMode>();

            if (!mb.IsStatic && !mb.IsConstructor)
            {
                modes.Add(ReferenceInfo.EMode.Read | ReferenceInfo.EMode.Write);
            }
            ParameterInfo[] pis = mb.GetParameters();
            foreach (ParameterInfo pi in pis)
            {
                if (pi.ParameterType.IsByRef)
                {
                    if (pi.IsOut)
                    {
                        modes.Add(ReferenceInfo.EMode.Write);
                    }
                    else
                    {
                        modes.Add(ReferenceInfo.EMode.Read |
                                  ReferenceInfo.EMode.Write);
                    }
                }
                else
                {
                    modes.Add(ReferenceInfo.EMode.NoAccess);
                }
            }
            if (ili.Code.Equals(OpCodes.Calli))
            {
                modes.Add(ReferenceInfo.EMode.Read | ReferenceInfo.EMode.Write);
            }
            return(modes.Select((m, i) => new ReferenceInfo(m, ReferenceInfo.EKind.Indirect,
                                                            StackInfluenceAnalysis.GetStackElementDefinitions(ili.Index, i - modes.Count + 1, (MethodCode)cfg))));
        }
コード例 #2
0
ファイル: MethodFacts.cs プロジェクト: cephdon/systemsharp
 /// <summary>
 /// Returns all instructions which might define a stack element at a certain program location
 /// </summary>
 /// <param name="ilIndex">instruction index</param>
 /// <param name="stackLevel">stack index (0 is top)</param>
 /// <returns>all instructions which might define given program location</returns>
 public IEnumerable <int> GetStackElementDefinitions(int ilIndex, int stackLevel)
 {
     return(StackInfluenceAnalysis.GetStackElementDefinitions(ilIndex, stackLevel, CFG));
 }
コード例 #3
0
ファイル: MSILAnalysis.cs プロジェクト: cephdon/systemsharp
 private IEnumerable <ReferenceInfo> HandleStind(ILInstruction ili, ControlFlowGraph <ILInstruction> cfg)
 {
     yield return(new ReferenceInfo(ReferenceInfo.EMode.Write, ReferenceInfo.EKind.Assignment,
                                    StackInfluenceAnalysis.GetStackElementDefinitions(ili.Index, -1, (MethodCode)cfg)));
 }