Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pcy
fnaglsl
Commits
f6156952
Commit
f6156952
authored
Jun 19, 2020
by
pcy
Browse files
... and don't forget files
parent
e7478816
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ILUtil.cs
0 → 100644
View file @
f6156952
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
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment