First of all, I'm using .Net Framework v1.1 with VS.NET 2003
I have made some tests, and I realized that "ldelema [mscorlib]System.Byte"
doesn't work on my Pocket PC device if my buffer is declared as follow even
if typeof(buffer) is Byte[]:
SetDouble(class [mscorlib]System.Array buffer,...
It does work if the buffer is declared as follow:
SetDouble(unsigned int8[] buffer,...
Here is the code of my method. It works on Win32 and Compact Framwork in the
emulator, but not on my Pocket PC device
.method public hidebysig static void
SetDouble(class [mscorlib]System.Array buffer,
// SetDouble(unsigned int8[] buffer,
int32 offset,
float64 'value') cil managed
{
.locals (int32 nIndex, unsigned int8* pValue, unsigned int8* pBuffer)
ldc.i4.0 // 0
stloc.0 // nIndex = 0
ldarga.s 2 // &value
stloc.1 // pValue = &value;
ldarg.0 // buffer
ldarg.1 // offset
ldelema [mscorlib]System.Byte // &buffer[offset]
stloc.2 // pBuffer = &buffer[offset]
LOOP:
ldloc.2 // pBuffer
ldloc.0 // nIndex
add // pBuffer + nIndex
ldloc.1 // pValue
ldloc.0 // nIndex
add // &pValue[nIndex]
ldind.i1 // pValue[nIndex]
stind.i1 // pBuffer[nIndex] = pValue[nIndex]
ldloc.0 // nIndex
ldc.i4.1 // 1
add // nIndex++
stloc.0 // ->nIndex
ldloc.0 // nIndex
ldc.i4.8 // 8
blt.s LOOP // if (nIndex < 8) goto LOOP
ret
} // end of method Buffer::SetDouble
John Perks and Sarah Mount - 16 Nov 2005 17:42 GMT
> ldelema [mscorlib]System.Byte // &buffer[offset]
What about if you replace this with
ldelema unsigned int8
?
I seem to recall that full names for primitives shouldn't be used
From ECMA 335:
"22.2.15 Short Form Signatures
The general specification for signatures leaves some leeway in how to
encode certain items. For example, it
appears legal to encode a String as either
long-form: ( ELEMENT_TYPE_CLASS, TypeRef-to-System.String )
short-form: ELEMENT_TYPE_STRING
Only the short form is valid. The following table shows which
short-forms should be used in place of each
long-form item. "
The table then lists System.Byte's shortform as U1, which corresponds to
unsigned int8.
On this subject (sort of) is it guaranteed to work that if you have the
following:
il.Emit(Opcodes.Unbox, aType);
il.Emit(Opcodes.Ldobj, aType);
even if aType is a primitive (so one could have used, e.g.
Opcodes.Ldind_u1), or an enum? If aType were an enum, to what extent
could one swap it with its underlying type (or the Ldind_* shorthand for
that type) in the above code?
Thanks
John
Luc Vaillant - 17 Nov 2005 06:56 GMT
> What about if you replace this with
>
> ldelema unsigned int8
LVT : It works on the emulator but not on the device (like ldelema
[mscorlib]System.Byte)
Thanks
> > ldelema [mscorlib]System.Byte // &buffer[offset]
>
[quoted text clipped - 35 lines]
>
> John