Commit f6156952 authored by pcy's avatar pcy
Browse files

... and don't forget files

parent e7478816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
namespace PoroCYon.FNAGLSL {
public static class ILUtil {
// TODO: other useful insns?
static ILUtil() {
var cpblk = new DynamicMethod("_Cpblk_IL",
MethodAttributes.Public|MethodAttributes.Static,
CallingConventions.Standard,
null, new [] { typeof(IntPtr), typeof(IntPtr), typeof(IntPtr) },
typeof(ILUtil), true);
var gen = cpblk.GetILGenerator();
gen.Emit(OpCodes.Ldarg_0);
gen.Emit(OpCodes.Ldarg_1);
gen.Emit(OpCodes.Ldarg_2);
gen.Emit(OpCodes.Cpblk);
gen.Emit(OpCodes.Ret);
_Cpblk = (Action<IntPtr, IntPtr, IntPtr>)cpblk.CreateDelegate(
typeof(Action<IntPtr, IntPtr, IntPtr>));
var initblk = new DynamicMethod("_Initblk_IL",
MethodAttributes.Public|MethodAttributes.Static,
CallingConventions.Standard,
null, new [] { typeof(IntPtr), typeof(byte), typeof(IntPtr) },
typeof(ILUtil), true);
gen = initblk.GetILGenerator();
gen.Emit(OpCodes.Ldarg_0);
gen.Emit(OpCodes.Ldarg_1);
gen.Emit(OpCodes.Ldarg_2);
gen.Emit(OpCodes.Initblk);
gen.Emit(OpCodes.Ret);
_Initblk = (Action<IntPtr, byte, IntPtr>)initblk.CreateDelegate(
typeof(Action<IntPtr, byte, IntPtr>));
}
static Action<IntPtr, IntPtr, IntPtr> _Cpblk;
public static void Cpblk(IntPtr dst, IntPtr src, IntPtr size) { // memcpy args order
_Cpblk(dst, src, size);
}
static Action<IntPtr, byte, IntPtr> _Initblk;
public static void Initblk(IntPtr ptr, byte val, IntPtr size) { // memset args order
_Initblk(ptr, val, size);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment