private bool IsSideEffectFreePush(int index)
{
if (code[index].opcode == OpCodes.Ldstr)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldnull)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldsfld)
{
// Here we are considering BeforeFieldInit to mean that we really don't care about
// when the type is initialized (which is what we mean in the rest of the IKVM code as well)
// but it is good to point it out here because strictly speaking we're violating the
// BeforeFieldInit contract here by considering dummy loads not to be field accesses.
FieldInfo field = code[index].FieldInfo;
if (field != null && (field.DeclaringType.Attributes & TypeAttributes.BeforeFieldInit) != 0)
{
return true;
}
else
{
return false;
}
}
else if (code[index].opcode == OpCodes.Ldc_I4)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldc_I8)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldc_R4)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldc_R8)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldloc)
{
return true;
}
else if (code[index].opcode == OpCodes.Ldarg)
{
return true;
}
else
{
return false;
}
}