本文整理汇总了C#中KopiLua.InstructionPtr类的典型用法代码示例。如果您正苦于以下问题:C# InstructionPtr类的具体用法?C# InstructionPtr怎么用?C# InstructionPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstructionPtr类属于KopiLua命名空间,在下文中一共展示了InstructionPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: arith_op
public static void arith_op(lua_State L, op_delegate op, TMS tm, StkId base_, Instruction i, TValue[] k, StkId ra, InstructionPtr pc)
{
TValue rb = RKB(L, base_, i, k);
TValue rc = RKC(L, base_, i, k);
if (ttisnumber(rb) && ttisnumber(rc))
{
lua_Number nb = nvalue(rb), nc = nvalue(rc);
setnvalue(ra, op(nb, nc));
}
else
{
//Protect(
L.savedpc = InstructionPtr.Assign(pc);
Arith(L, ra, rb, rc, tm);
base_ = L.base_;
//);
}
}
示例2: traceexec
private static void traceexec (LuaState L, InstructionPtr pc) {
lu_byte mask = L.hookmask;
InstructionPtr oldpc = InstructionPtr.Assign(L.savedpc);
L.savedpc = InstructionPtr.Assign(pc);
if (((mask & LUA_MASKCOUNT) != 0) && (L.hookcount == 0)) {
ResetHookCount(L);
LuaDCallHook(L, LUA_HOOKCOUNT, -1);
}
if ((mask & LUA_MASKLINE) != 0) {
Proto p = CIFunc(L.ci).l.p;
int npc = PCRel(pc, p);
int newline = GetLine(p, npc);
/* call linehook when enter a new function, when jump back (loop),
or when enter a new line */
if (npc == 0 || pc <= oldpc || newline != GetLine(p, PCRel(oldpc, p)))
LuaDCallHook(L, LUA_HOOKLINE, newline);
}
}
示例3: traceexec
private static void traceexec (lua_State L, InstructionPtr pc) {
lu_byte mask = L.hookmask;
InstructionPtr oldpc = InstructionPtr.Assign(L.savedpc);
L.savedpc = InstructionPtr.Assign(pc);
if (((mask & LUA_MASKCOUNT) != 0) && (L.hookcount == 0)) {
resethookcount(L);
luaD_callhook(L, LUA_HOOKCOUNT, -1);
}
if ((mask & LUA_MASKLINE) != 0) {
Proto p = ci_func(L.ci).l.p;
int npc = pcRel(pc, p);
int newline = getline(p, npc);
/* call linehook when enter a new function, when jump back (loop),
or when enter a new line */
if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p)))
luaD_callhook(L, LUA_HOOKLINE, newline);
}
}
示例4: GetJumpControl
private static InstructionPtr GetJumpControl (FuncState fs, int pc) {
InstructionPtr pi = new InstructionPtr(fs.f.code, pc);
if (pc >= 1 && (testTMode(GET_OPCODE(pi[-1]))!=0))
return new InstructionPtr(pi.codes, pi.pc-1);
else
return new InstructionPtr(pi.codes, pi.pc);
}
示例5: FixJump
private static void FixJump (FuncState fs, int pc, int dest) {
InstructionPtr jmp = new InstructionPtr(fs.f.code, pc);
int offset = dest-(pc+1);
LuaAssert(dest != NO_JUMP);
if (Math.Abs(offset) > MAXARG_sBx)
LuaXSyntaxError(fs.ls, "control structure too long");
SETARG_sBx(jmp, offset);
}
示例6: LuaKNil
public static void LuaKNil (FuncState fs, int from, int n) {
InstructionPtr previous;
if (fs.pc > fs.lasttarget) { /* no jumps to current position? */
if (fs.pc == 0) { /* function start? */
if (from >= fs.nactvar)
return; /* positions are already clean */
}
else {
previous = new InstructionPtr(fs.f.code, fs.pc-1);
if (GET_OPCODE(previous) == OpCode.OP_LOADNIL) {
int pfrom = GETARG_A(previous);
int pto = GETARG_B(previous);
if (pfrom <= from && from <= pto+1) { /* can connect both? */
if (from+n-1 > pto)
SETARG_B(previous, from+n-1);
return;
}
}
}
}
LuaKCodeABC(fs, OpCode.OP_LOADNIL, from, from + n - 1, 0); /* else no optimization */
}
示例7: SET_OPCODE
internal static void SET_OPCODE(InstructionPtr i, OpCode opcode)
{
SET_OPCODE(ref i.codes[i.pc], opcode);
}
示例8: SETARG_sBx
internal static void SETARG_sBx(InstructionPtr i, int b)
{
SETARG_Bx(i, b + MAXARG_sBx);
}
示例9: SETARG_C
internal static void SETARG_C(InstructionPtr i, int b)
{
i[0] = (Instruction)((i[0] & MASK0(SIZE_C, POS_C)) | ((b << POS_C) & MASK1(SIZE_C, POS_C)));
}
示例10: dojump
public static void dojump(LuaState L, InstructionPtr pc, int i) { pc.pc += i; LuaIThreadYield(L); }
示例11: GET_OPCODE
internal static OpCode GET_OPCODE(InstructionPtr i)
{
return GET_OPCODE(i[0]);
}
示例12: GETARG_sBx
internal static int GETARG_sBx(InstructionPtr i)
{
return GETARG_sBx(i[0]);
}
示例13: dojump
public static void dojump(lua_State L, InstructionPtr pc, int i)
{
pc.pc += i; luai_threadyield(L);
}
示例14: PCRel
public static int PCRel(InstructionPtr pc, Proto p)
{
Debug.Assert(pc.codes == p.code);
return pc.pc - 1;
}
示例15: Assign
public static InstructionPtr Assign(InstructionPtr ptr)
{
if (ptr == null) return null;
return new InstructionPtr(ptr.codes, ptr.pc);
}