Esempio n. 1
0
 private AbstractStackState <VariabilityInfo> HandleNewarr(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
 {
     return(pre
            .Pop()
            .Push(VariabilityInfo.CreateBySingleDef(EVariability.ExternVariable, ili.Index))
            .UniqueSuccessor());
 }
Esempio n. 2
0
        private AbstractStackState <VariabilityInfo> HandleBinOp(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            VariabilityInfo a = pre[0];
            VariabilityInfo b = pre[1];
            VariabilityInfo r = VariabilityInfo.MergeByNewDef(a, b, ili.Index);

            return(pre.Pop().Pop().Push(r).UniqueSuccessor());
        }
Esempio n. 3
0
        private AbstractStackState <VariabilityInfo> HandleCpobj(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            VariabilityInfo source = pre[0];
            VariabilityInfo dest   = pre[1];
            AbstractStackState <VariabilityInfo> next = UpdateStackState(ili, source, pre);

            next = next.Pop().Pop();
            return(next.UniqueSuccessor());
        }
Esempio n. 4
0
        private AbstractStackState <VariabilityInfo> HandleCall(ILInstruction ili, AbstractStackState <VariabilityInfo> pre, bool isCalli)
        {
            MethodBase   callee  = (MethodBase)ili.Operand;
            bool         hasThis = callee.CallingConvention.HasFlag(CallingConventions.HasThis);
            EVariability callVar = EVariability.Constant;

            ParameterInfo[] args        = callee.GetParameters();
            MethodFacts     myFacts     = FactUniverse.Instance.GetFacts(Method);
            MethodFacts     calleeFacts = FactUniverse.Instance.GetFacts(callee);
            AbstractStackState <VariabilityInfo> next = pre;

            if (hasThis)
            {
                callVar = VariabilityOperations.Stronger(callVar, pre[0].Variability);
                next    = pre.Pop();
            }
            for (int i = 0; i < args.Length; i++)
            {
                callVar = VariabilityOperations.Stronger(callVar, next[0].Variability);
                next    = next.Pop();
            }
            if (!calleeFacts.IsSideEffectFree)
            {
                callVar = EVariability.ExternVariable;
            }
            if (calleeFacts.IsStaticEvaluation)
            {
                callVar = EVariability.Constant;
            }
            if (isCalli)
            {
                next = pre.Pop();
            }
            VariabilityInfo callVarI = VariabilityInfo.CreateBySingleDef(callVar, ili.Index);

            next = UpdateStackState(ili, callVarI, next);
            Type returnType;

            if (callee.IsFunction(out returnType))
            {
                next = next.Push(callVarI);
            }
            return(next.UniqueSuccessor());
        }
Esempio n. 5
0
        private AbstractStackState <VariabilityInfo> HandleLdfld(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            FieldInfo field = (FieldInfo)ili.Operand;
            int       index = Array.IndexOf(_localizedFields, field);

            if (index >= 0)
            {
                return(HandleLdloc(null, pre.Pop(), _localizedFieldsBaseIndex + index));
            }
            else
            {
                FieldFacts   fieldFacts = FactUniverse.Instance.GetFacts(field);
                EVariability fieldVar   = fieldFacts.IsWritten || fieldFacts.IsSubMutated ?
                                          EVariability.ExternVariable : EVariability.Constant;
                VariabilityInfo newVar = VariabilityInfo.CreateBySingleDef(fieldVar, ili.Index);
                return(pre
                       .Pop()
                       .Push(newVar)
                       .UniqueSuccessor());
            }
        }
Esempio n. 6
0
        private AbstractStackState <VariabilityInfo> HandleRet(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            Type returnType;

            if (Method.IsFunction(out returnType))
            {
                return(pre.Pop().UniqueSuccessor());
            }
            else
            {
                return(pre.UniqueSuccessor());
            }
        }
Esempio n. 7
0
        private AbstractStackState <VariabilityInfo> HandleNewobj(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            ConstructorInfo ctor = (ConstructorInfo)ili.Operand;

            ParameterInfo[] args = ctor.GetParameters();
            AbstractStackState <VariabilityInfo> next = pre;

            for (int i = 0; i < args.Length; i++)
            {
                next = next.Pop();
            }
            return(next
                   .Push(VariabilityInfo.CreateBySingleDef(EVariability.ExternVariable, ili.Index))
                   .UniqueSuccessor());
        }
Esempio n. 8
0
        private AbstractStackState <VariabilityInfo> HandleUnBranch(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            VariabilityInfo c    = pre[0];
            var             next = pre.Pop();

            if (c.Variability == EVariability.Constant)
            {
                next = next.UniqueSuccessor();
            }
            else
            {
                next = next.AmbiguousSuccessor();
            }
            return(next);
        }
Esempio n. 9
0
        private AbstractStackState <VariabilityInfo> HandleBinBranch(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
        {
            VariabilityInfo a    = pre[0];
            VariabilityInfo b    = pre[1];
            var             next = pre.Pop().Pop();

            if (VariabilityOperations.Stronger(a.Variability, b.Variability) == EVariability.Constant)
            {
                next = next.UniqueSuccessor();
            }
            else
            {
                next = next.AmbiguousSuccessor();
            }
            return(next);
        }
Esempio n. 10
0
 private AbstractStackState <VariabilityInfo> HandleLdind(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
 {
     return(PushV(ili, pre.Pop()));
 }
Esempio n. 11
0
 private AbstractStackState <VariabilityInfo> Pop3(ILInstruction ili, AbstractStackState <VariabilityInfo> pre)
 {
     return(pre.Pop().Pop().Pop().UniqueSuccessor());
 }