Составители:
Рубрика:
BitConverter.ToUInt32(cilStream,offset);
offset += 4;
int[] targets = new int[num];
for (int i = 0; i < num; i++)
{
targets[i] =
BitConverter.ToInt32(cilStream,offset);
offset += 4;
}
for (int i = 0; i < num; i++)
targets[i] += offset;
ins.Operand = targets;
break;
default: /* token */
byte b1 = cilStream[offset++],
b2 = cilStream[offset++],
b3 = cilStream[offset++],
b4 = cilStream[offset++];
ins.Operand = ((int)b1 << 24) | ((int)b2 << 16) |
((int)b3 << 8) | (int)b4;
break;
}
instructions.Add(ins);
}
Instruction[] instrArray = new Instruction [instructions.Count];
instructions.CopyTo(instrArray);
return instrArray;
}
public static byte[] EncodeCil(Instruction[] instructions)
{
ArrayList Result = new ArrayList();
foreach(Instruction ins in instructions)
{
short codeValue = ins.Code.Value;
Исходный код программы CilCodec
295
break;
case OperandType.InlineBrTarget: /* int32 */
ins.Operand = offset + 4 +
BitConverter.ToInt32(cilStream,offset);
offset += 4;
break;
case OperandType.InlineI8: /* int64 */
ins.Operand =
BitConverter.ToInt64(cilStream,offset);
offset += 8;
break;
case OperandType.ShortInlineI: /* int8 */
ins.Operand = (sbyte)cilStream[offset++];
break;
case OperandType.ShortInlineVar: /* unsigned int8 */
ins.Operand = cilStream[offset++];
break;
case OperandType.InlineVar: /* unsigned int16 */
ins.Operand =
BitConverter.ToUInt16(cilStream,offset);
offset += 2;
break;
case OperandType.ShortInlineR: /* float32 */
ins.Operand =
BitConverter.ToSingle(cilStream,offset);
offset += 4;
break;
case OperandType.InlineR: /* float64 */
ins.Operand =
BitConverter.ToDouble(cilStream,offset);
offset += 8;
break;
case OperandType.InlineSwitch: /* switch */
uint num =
294
CIL и системное программирование в Microsoft .NET
294 CIL и системное программирование в Microsoft .NET Исходный код программы CilCodec 295
break; BitConverter.ToUInt32(cilStream,offset);
offset += 4;
case OperandType.InlineBrTarget: /* int32 */ int[] targets = new int[num];
ins.Operand = offset + 4 + for (int i = 0; i < num; i++)
BitConverter.ToInt32(cilStream,offset); {
offset += 4; targets[i] =
break; BitConverter.ToInt32(cilStream,offset);
offset += 4;
case OperandType.InlineI8: /* int64 */ }
ins.Operand =
BitConverter.ToInt64(cilStream,offset); for (int i = 0; i < num; i++)
offset += 8; targets[i] += offset;
break;
ins.Operand = targets;
case OperandType.ShortInlineI: /* int8 */ break;
ins.Operand = (sbyte)cilStream[offset++];
break; default: /* token */
byte b1 = cilStream[offset++],
case OperandType.ShortInlineVar: /* unsigned int8 */ b2 = cilStream[offset++],
ins.Operand = cilStream[offset++]; b3 = cilStream[offset++],
break; b4 = cilStream[offset++];
case OperandType.InlineVar: /* unsigned int16 */ ins.Operand = ((int)b1 << 24) | ((int)b2 << 16) |
ins.Operand = ((int)b3 << 8) | (int)b4;
BitConverter.ToUInt16(cilStream,offset); break;
offset += 2; }
break;
instructions.Add(ins);
case OperandType.ShortInlineR: /* float32 */ }
ins.Operand =
BitConverter.ToSingle(cilStream,offset); Instruction[] instrArray = new Instruction [instructions.Count];
offset += 4; instructions.CopyTo(instrArray);
break; return instrArray;
}
case OperandType.InlineR: /* float64 */
ins.Operand = public static byte[] EncodeCil(Instruction[] instructions)
BitConverter.ToDouble(cilStream,offset); {
offset += 8; ArrayList Result = new ArrayList();
break;
foreach(Instruction ins in instructions)
case OperandType.InlineSwitch: /* switch */ {
uint num = short codeValue = ins.Code.Value;
Страницы
- « первая
- ‹ предыдущая
- …
- 152
- 153
- 154
- 155
- 156
- …
- следующая ›
- последняя »
