Пример #1
0
 protected internal override void VisitLdObj(LdObj inst)
 {
     if (inst.Target.MatchLdLoca(thisVariable))
     {
         inst.ReplaceWith(target.Clone());
         return;
     }
     base.VisitLdObj(inst);
 }
Пример #2
0
 internal static bool LdObjToLdLoc(LdObj inst, ILTransformContext context)
 {
     if (inst.Target.MatchLdLoca(out ILVariable v) &&
         TypeUtils.IsCompatibleTypeForMemoryAccess(v.Type, inst.Type) &&
         inst.UnalignedPrefix == 0 &&
         !inst.IsVolatile)
     {
         context.Step($"ldobj(ldloca {v.Name}) => ldloc {v.Name}", inst);
         inst.ReplaceWith(new LdLoc(v).WithILRange(inst));
         return(true);
     }
     return(false);
 }
Пример #3
0
 protected internal override void VisitLdObj(LdObj inst)
 {
     base.VisitLdObj(inst);
     EarlyExpressionTransforms.AddressOfLdLocToLdLoca(inst, context);
     if (EarlyExpressionTransforms.LdObjToLdLoc(inst, context))
     {
         return;
     }
     if (TransformDecimalFieldToConstant(inst, out LdcDecimal decimalConstant))
     {
         context.Step("TransformDecimalFieldToConstant", inst);
         inst.ReplaceWith(decimalConstant);
         return;
     }
 }
Пример #4
0
 internal static bool LdObjToLdLoc(LdObj inst, ILTransformContext context)
 {
     if (inst.Target.MatchLdLoca(out ILVariable v) &&
         TypeUtils.IsCompatibleTypeForMemoryAccess(v.Type, inst.Type) &&
         inst.UnalignedPrefix == 0 &&
         !inst.IsVolatile)
     {
         context.Step($"ldobj(ldloca {v.Name}) => ldloc {v.Name}", inst);
         ILInstruction replacement = new LdLoc(v).WithILRange(inst);
         if (v.StackType == StackType.Unknown && inst.Type.Kind != TypeKind.Unknown)
         {
             replacement = new Conv(replacement, inst.Type.ToPrimitiveType(),
                                    checkForOverflow: false, Sign.None);
         }
         inst.ReplaceWith(replacement);
         return(true);
     }
     return(false);
 }