public static decimal FromDecimal(Proto.Seto.Decimal sDecimal) { var val = new decimal(sDecimal.Value); // Annoyingly, there is no integer exponentiation var divisor = new decimal((long)Math.Pow(10, sDecimal.Exponent)); return Math.Round(val / divisor, (int)sDecimal.Exponent); }
public static void LuaFFreeProto(LuaState L, Proto f) { LuaMFreeArray<Instruction>(L, f.code); LuaMFreeArray<Proto>(L, f.p); LuaMFreeArray<TValue>(L, f.k); LuaMFreeArray<Int32>(L, f.lineinfo); LuaMFreeArray<LocVar>(L, f.locvars); LuaMFreeArray<TString>(L, f.upvalues); LuaMFree(L, f); }
public static void luaF_freeproto(lua_State L, Proto f) { luaM_freearray<Instruction>(L, f.code); luaM_freearray<Proto>(L, f.p); luaM_freearray<TValue>(L, f.k); luaM_freearray<Int32>(L, f.lineinfo); luaM_freearray<LocVar>(L, f.locvars); luaM_freearray<TString>(L, f.upvalues); luaM_free(L, f); }
internal static MarketQuotes FromSeto(Proto.Seto.MarketQuotes setoQuotes) { var quantityType = Quantity.QuantityTypeFromSeto(setoQuotes.QuantityType); var priceType = Price.PriceTypeFromSeto(setoQuotes.PriceType); return new MarketQuotes( Uid.FromUuid128(setoQuotes.Market), ContractQuotesMap.FromSeto( setoQuotes.ContractQuotes, priceType, quantityType), priceType, quantityType); }
/* ** Look for n-th local variable at line `line' in function `func'. ** Returns null if not found. */ public static CharPtr LuaFGetLocalName(Proto f, int local_number, int pc) { int i; for (i = 0; i<f.sizelocvars && f.locvars[i].startpc <= pc; i++) { if (pc < f.locvars[i].endpc) { /* is variable active? */ local_number--; if (local_number == 0) return GetStr(f.locvars[i].varname); } } return null; /* not found */ }
public static int LuaUDump(LuaState L, Proto f, lua_Writer w, object data, int strip) { DumpState D = new DumpState(); D.L=L; D.writer=w; D.data=data; D.strip=strip; D.status=0; DumpHeader(D); DumpFunction(f,null,D); return D.status; }
public static void PrintFunction(Proto f, int full) { int i,n=f.sizep; PrintHeader(f); PrintCode(f); if (full != 0) { PrintConstants(f); PrintLocals(f); PrintUpvalues(f); } for (i=0; i<n; i++) PrintFunction(f.p[i],full); }
private static void PrintConstant(Proto f, int i) { /*const*/ TValue o=f.k[i]; switch (TType(o)) { case LUA_TNIL: printf("nil"); break; case LUA_TBOOLEAN: printf(BValue(o) != 0 ? "true" : "false"); break; case LUA_TNUMBER: printf(LUA_NUMBER_FMT,NValue(o)); break; case LUA_TSTRING: PrintString(RawTSValue(o)); break; default: /* cannot happen */ printf("? type=%d",TType(o)); break; } }
/// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary> public static Proto.Test.Nullables.MyMessage Deserialize(byte[] buffer, Proto.Test.Nullables.MyMessage instance) { using (var ms = new MemoryStream(buffer)) Deserialize(ms, instance); return instance; }
/// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary> public static Proto.Test.Nullables.Data DeserializeLength(Stream stream, int length, Proto.Test.Nullables.Data instance) { var br = new BinaryReader(stream); long limit = stream.Position + length; while (true) { if (stream.Position >= limit) { if (stream.Position == limit) break; else throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit"); } int keyByte = stream.ReadByte(); if (keyByte == -1) throw new System.IO.EndOfStreamException(); // Optimized reading of known fields with field ID < 16 switch (keyByte) { // Field 1 Fixed64 case 9: instance.Somefield = br.ReadDouble(); continue; } var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
/// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary> public static Proto.Test.Nullables.Container.Nested Deserialize(byte[] buffer, Proto.Test.Nullables.Container.Nested instance) { using (var ms = new MemoryStream(buffer)) Deserialize(ms, instance); return instance; }
public static int checkopenop(Proto pt, int pc) { return(luaG_checkopenop(pt.code[pc + 1])); }
/* ** try to find last instruction before 'lastpc' that modified register 'reg' */ private static int findsetreg(Proto p, int lastpc, int reg) { int pc; int setreg = -1; /* keep last instruction that changed 'reg' */ for (pc = 0; pc < lastpc; pc++) { Instruction i = p.code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); switch (op) { case OpCode.OP_LOADNIL: { int b = GETARG_B(i); if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ { setreg = pc; } break; } case OpCode.OP_TFORCALL: { if (reg >= a + 2) { setreg = pc; /* affect all regs above its base */ } break; } case OpCode.OP_CALL: case OpCode.OP_TAILCALL: { if (reg >= a) { setreg = pc; /* affect all registers above base */ } break; } case OpCode.OP_JMP: { int b = GETARG_sBx(i); int dest = pc + 1 + b; /* jump is forward and do not skip `lastpc'? */ if (pc < dest && dest <= lastpc) { pc += b; /* do the jump */ } break; } case OpCode.OP_TEST: { if (reg == a) { setreg = pc; /* jumped code can change 'a' */ } break; } default: if (testAMode(op) != 0 && reg == a) /* any instruction that set A */ { setreg = pc; } break; } } return(setreg); }
private static void PrintCode(Proto f) { Instruction[] code = f.code; int pc, n = f.sizecode; for (pc = 0; pc < n; pc++) { Instruction i = f.code[pc]; OpCode o = GET_OPCODE(i); int a = GETARG_A(i); int b = GETARG_B(i); int c = GETARG_C(i); int bx = GETARG_Bx(i); int sbx = GETARG_sBx(i); int line = getline(f, pc); printf("\t%d\t", pc + 1); if (line > 0) { printf("[%d]\t", line); } else { printf("[-]\t"); } printf("%-9s\t", luaP_opnames[(int)o]); switch (getOpMode(o)) { case OpMode.iABC: printf("%d", a); if (getBMode(o) != OpArgMask.OpArgN) { printf(" %d", (ISK(b) != 0) ? (-1 - INDEXK(b)) : b); } if (getCMode(o) != OpArgMask.OpArgN) { printf(" %d", (ISK(c) != 0) ? (-1 - INDEXK(c)) : c); } break; case OpMode.iABx: if (getBMode(o) == OpArgMask.OpArgK) { printf("%d %d", a, -1 - bx); } else { printf("%d %d", a, bx); } break; case OpMode.iAsBx: if (o == OpCode.OP_JMP) { printf("%d", sbx); } else { printf("%d %d", a, sbx); } break; } switch (o) { case OpCode.OP_LOADK: printf("\t; "); PrintConstant(f, bx); break; case OpCode.OP_GETUPVAL: case OpCode.OP_SETUPVAL: printf("\t; %s", (f.sizeupvalues > 0) ? getstr(f.upvalues[b]) : "-"); break; case OpCode.OP_GETGLOBAL: case OpCode.OP_SETGLOBAL: printf("\t; %s", svalue(f.k[bx])); break; case OpCode.OP_GETTABLE: case OpCode.OP_SELF: if (ISK(c) != 0) { printf("\t; "); PrintConstant(f, INDEXK(c)); } break; case OpCode.OP_SETTABLE: case OpCode.OP_ADD: case OpCode.OP_SUB: case OpCode.OP_MUL: case OpCode.OP_DIV: case OpCode.OP_POW: case OpCode.OP_EQ: case OpCode.OP_LT: case OpCode.OP_LE: if (ISK(b) != 0 || ISK(c) != 0) { printf("\t; "); if (ISK(b) != 0) { PrintConstant(f, INDEXK(b)); } else { printf("-"); } printf(" "); if (ISK(c) != 0) { PrintConstant(f, INDEXK(c)); } else { printf("-"); } } break; case OpCode.OP_JMP: case OpCode.OP_FORLOOP: case OpCode.OP_FORPREP: printf("\t; to %d", sbx + pc + 2); break; case OpCode.OP_CLOSURE: printf("\t; %p", VOID(f.p[bx])); break; case OpCode.OP_SETLIST: if (c == 0) { printf("\t; %d", (int)code[++pc]); } else { printf("\t; %d", c); } break; default: break; } printf("\n"); } }
//#define setptvalue2s setptvalue internal static void SetPTValue2S(LuaState L, TValue obj, Proto x) { SetPTValue(L, obj, x); }
/* ** returns true if function has been executed (C function) */ public static int luaD_precall(lua_State L, StkId func, int nresults) { LClosure cl; ptrdiff_t funcr; if (!ttisfunction(func)) /* `func' is not a function? */ { func = tryfuncTM(L, func); /* check the `function' tag method */ } funcr = savestack(L, func); cl = clvalue(func).l; L.ci.nresults = (short)nresults; //FIXME:??? if (cl.isC == 0) /* Lua function? prepare its call */ { CallInfo ci; int nparams, nargs; StkId base_; Proto p = cl.p; luaD_checkstack(L, p.maxstacksize); func = restorestack(L, funcr); nargs = cast_int(L.top - func) - 1; /* number of real arguments */ nparams = p.numparams; /* number of expected parameters */ for (; nargs < nparams; nargs++) { setnilvalue(lua_TValue.inc(ref L.top)); /* complete missing arguments */ } if (p.is_vararg == 0) /* no varargs? */ { base_ = L.stack[func + 1]; } else /* vararg function */ { base_ = adjust_varargs(L, p, nargs); } ci = next_ci(L); /* now `enter' new function */ ci.func = func; ci.u.l.base_ = base_; ci.top = base_ + p.maxstacksize; lua_assert(ci.top <= L.stack_last); ci.u.l.savedpc = new InstructionPtr(p.code, 0); /* starting point */ //FIXME:??? //FIXME:??? ci.u.l.tailcalls = 0; ci.callstatus = CIST_LUA; L.top = ci.top; if ((L.hookmask & LUA_MASKCALL) != 0) { InstructionPtr.inc(ref ci.u.l.savedpc); /* hooks assume 'pc' is already incremented */ luaD_callhook(L, LUA_HOOKCALL, -1); InstructionPtr.dec(ref ci.u.l.savedpc); /* correct 'pc' */ } return(0); } else /* if is a C function, call it */ { CallInfo ci; int n; luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ ci = next_ci(L); /* now `enter' new function */ ci.func = restorestack(L, funcr); ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); ci.callstatus = 0; if ((L.hookmask & LUA_MASKCALL) != 0) { luaD_callhook(L, LUA_HOOKCALL, -1); } lua_unlock(L); n = curr_func(L).c.f(L); /* do the actual call */ lua_lock(L); luaD_poscall(L, L.top - n); return(1); } }
private static void DumpCode(Proto f, DumpState D) { DumpVector(f.code, f.sizecode, D); } //FIXME:no sizeof(Instruction)
//#undef check //#undef checkjump //#undef checkreg /* }====================================================== */ public static int LuaGCheckCode(Proto pt) { return((SymbExec(pt, pt.sizecode, NO_REG) != 0) ? 1 : 0); }
public static int luaD_precall(LuaState L, StkId func, int nresults) { LClosure cl; ptrdiff_t funcr; if (!ttisfunction(func)) /* `func' is not a function? */ { func = tryfuncTM(L, func); /* check the `function' tag method */ } funcr = savestack(L, func); cl = clvalue(func).l; L.ci.savedpc = InstructionPtr.Assign(L.savedpc); if (cl.isC == 0) { /* Lua function? prepare its call */ CallInfo ci; StkId st, base_; Proto p = cl.p; luaD_checkstack(L, p.maxstacksize); func = restorestack(L, funcr); if (p.is_vararg == 0) { /* no varargs? */ base_ = L.stack[func + 1]; if (L.top > base_ + p.numparams) { L.top = base_ + p.numparams; } } else { /* vararg function */ int nargs = L.top - func - 1; base_ = adjust_varargs(L, p, nargs); func = restorestack(L, funcr); /* previous call may change the stack */ } ci = inc_ci(L); /* now `enter' new function */ ci.func = func; L.base_ = ci.base_ = base_; ci.top = L.base_ + p.maxstacksize; lua_assert(ci.top <= L.stack_last); L.savedpc = new InstructionPtr(p.code, 0); /* starting point */ ci.tailcalls = 0; ci.nresults = nresults; for (st = L.top; st < ci.top; StkId.inc(ref st)) { setnilvalue(st); } L.top = ci.top; if ((L.hookmask & LUA_MASKCALL) != 0) { InstructionPtr.inc(ref L.savedpc); /* hooks assume 'pc' is already incremented */ luaD_callhook(L, LUA_HOOKCALL, -1); InstructionPtr.dec(ref L.savedpc); /* correct 'pc' */ } return(PCRLUA); } else { /* if is a C function, call it */ CallInfo ci; int n; luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ ci = inc_ci(L); /* now `enter' new function */ ci.func = restorestack(L, funcr); L.base_ = ci.base_ = ci.func + 1; ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); ci.nresults = nresults; if ((L.hookmask & LUA_MASKCALL) != 0) { luaD_callhook(L, LUA_HOOKCALL, -1); } lua_unlock(L); n = curr_func(L).c.f(L); /* do the actual call */ lua_lock(L); if (n < 0) /* yielding? */ { return(PCRYIELD); } else { luaD_poscall(L, L.top - n); return(PCRC); } } }
private static Instruction SymbExec(Proto pt, int lastpc, int reg) { int pc; int last; /* stores position of last instruction that changed `reg' */ int dest; last = pt.sizecode - 1; /* points to final return (a `neutral' instruction) */ if (PreCheck(pt) == 0) { return(0); } for (pc = 0; pc < lastpc; pc++) { Instruction i = pt.code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); int b = 0; int c = 0; if (!((int)op < NUM_OPCODES)) { return(0); } CheckReg(pt, a); switch (getOpMode(op)) { case OpMode.iABC: { b = GETARG_B(i); c = GETARG_C(i); if (CheckArgMode(pt, b, getBMode(op)) == 0) { return(0); } if (CheckArgMode(pt, c, getCMode(op)) == 0) { return(0); } break; } case OpMode.iABx: { b = GETARG_Bx(i); if (getBMode(op) == OpArgMask.OpArgK) { if (!(b < pt.sizek)) { return(0); } } break; } case OpMode.iAsBx: { b = GETARG_sBx(i); if (getBMode(op) == OpArgMask.OpArgR) { dest = pc + 1 + b; if (!((0 <= dest && dest < pt.sizecode))) { return(0); } if (dest > 0) { int j; /* check that it does not jump to a setlist count; this * is tricky, because the count from a previous setlist may * have the same value of an invalid setlist; so, we must * go all the way back to the first of them (if any) */ for (j = 0; j < dest; j++) { Instruction d = pt.code[dest - 1 - j]; if (!(GET_OPCODE(d) == OpCode.OP_SETLIST && GETARG_C(d) == 0)) { break; } } /* if 'j' is even, previous value is not a setlist (even if * it looks like one) */ if ((j & 1) != 0) { return(0); } } } break; } } if (testAMode(op) != 0) { if (a == reg) { last = pc; /* change register `a' */ } } if (testTMode(op) != 0) { if (!(pc + 2 < pt.sizecode)) { return(0); /* check skip */ } if (!(GET_OPCODE(pt.code[pc + 1]) == OpCode.OP_JMP)) { return(0); } } switch (op) { case OpCode.OP_LOADBOOL: { if (c == 1) /* does it jump? */ { if (!(pc + 2 < pt.sizecode)) { return(0); /* check its jump */ } if (!(GET_OPCODE(pt.code[pc + 1]) != OpCode.OP_SETLIST || GETARG_C(pt.code[pc + 1]) != 0)) { return(0); } } break; } case OpCode.OP_LOADNIL: { if (a <= reg && reg <= b) { last = pc; /* set registers from `a' to `b' */ } break; } case OpCode.OP_GETUPVAL: case OpCode.OP_SETUPVAL: { if (!(b < pt.nups)) { return(0); } break; } case OpCode.OP_GETGLOBAL: case OpCode.OP_SETGLOBAL: { if (!(TTIsString(pt.k[b]))) { return(0); } break; } case OpCode.OP_SELF: { CheckReg(pt, a + 1); if (reg == a + 1) { last = pc; } break; } case OpCode.OP_CONCAT: { if (!(b < c)) { return(0); /* at least two operands */ } break; } case OpCode.OP_TFORLOOP: { if (!(c >= 1)) { return(0); /* at least one result (control variable) */ } CheckReg(pt, a + 2 + c); /* space for results */ if (reg >= a + 2) { last = pc; /* affect all regs above its base */ } break; } case OpCode.OP_FORLOOP: case OpCode.OP_FORPREP: CheckReg(pt, a + 3); /* go through ...no, on second thoughts don't, because this is C# */ dest = pc + 1 + b; /* not full check and jump is forward and do not skip `lastpc'? */ if (reg != NO_REG && pc < dest && dest <= lastpc) { pc += b; /* do the jump */ } break; case OpCode.OP_JMP: { dest = pc + 1 + b; /* not full check and jump is forward and do not skip `lastpc'? */ if (reg != NO_REG && pc < dest && dest <= lastpc) { pc += b; /* do the jump */ } break; } case OpCode.OP_CALL: case OpCode.OP_TAILCALL: { if (b != 0) { CheckReg(pt, a + b - 1); } c--; /* c = num. returns */ if (c == LUA_MULTRET) { if (CheckOpenOp(pt, pc) == 0) { return(0); } } else if (c != 0) { CheckReg(pt, a + c - 1); } if (reg >= a) { last = pc; /* affect all registers above base */ } break; } case OpCode.OP_RETURN: { b--; /* b = num. returns */ if (b > 0) { CheckReg(pt, a + b - 1); } break; } case OpCode.OP_SETLIST: { if (b > 0) { CheckReg(pt, a + b); } if (c == 0) { pc++; if (!(pc < pt.sizecode - 1)) { return(0); } } break; } case OpCode.OP_CLOSURE: { int nup, j; if (!(b < pt.sizep)) { return(0); } nup = pt.p[b].nups; if (!(pc + nup < pt.sizecode)) { return(0); } for (j = 1; j <= nup; j++) { OpCode op1 = GET_OPCODE(pt.code[pc + j]); if (!(op1 == OpCode.OP_GETUPVAL || op1 == OpCode.OP_MOVE)) { return(0); } } if (reg != NO_REG) /* tracing? */ { pc += nup; /* do not 'execute' these pseudo-instructions */ } break; } case OpCode.OP_VARARG: { if (!((pt.is_vararg & VARARG_ISVARARG) != 0 && (pt.is_vararg & VARARG_NEEDSARG) == 0)) { return(0); } b--; if (b == LUA_MULTRET) { if (CheckOpenOp(pt, pc) == 0) { return(0); } } CheckReg(pt, a + b - 1); break; } default: break; } } return(pt.code[last]); }
public static int CheckOpenOp(Proto pt, int pc) { return(LuaGCheckOpenOp(pt.code[pc + 1])); }
private static void DumpCode(Proto f, DumpState D) { DumpVector(f.code, f.sizecode, D); }
internal static void setptvalue(lua_State L, TValue obj, Proto x) { obj.value.gc = x; obj.tt = LUA_TPROTO; checkliveness(G(L), obj); }
private void Spawn(Vector3 position, Quaternion rotation, Transform parent) { var gameData = StaticReplayScript.gameData; Proto proto = StaticReplayScript.proto; // Choose the Andy model for the Trackable that got hit. // Instantiate Andy model at the hit pose. fieldObject = Instantiate(this.field, position, rotation); // Compensate for the hitPose rotation facing away from the raycast (i.e. camera). fieldObject.transform.Rotate(0, k_ModelRotation, 0, Space.Self); // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical // world evolves. rootObject = new GameObject("Field/Car Anchor"); // Make Andy model a child of the anchor. rootObject.transform.parent = parent; rootObject.transform.localPosition = new Vector3(0f, 0f, 0f); rootObject.transform.localScale = new Vector3(1 / scaleFactor, 1 / scaleFactor, 1 / scaleFactor); fieldObject.transform.parent = rootObject.transform; fieldObject.transform.localPosition = new Vector3(0f, -10f, 0f); fieldObject.transform.localScale = new Vector3(65 * 1000 / scaleFactor, 65 * 1000 / scaleFactor, 65 * 1000 / scaleFactor); fieldObject.transform.localRotation = Quaternion.Euler(0f, -90f, 0f); for (int i = 0; i < gameData.players.Count; i++) { float x = (float)(double)gameData.players[i][0][0] / localScale; float y = (float)(double)gameData.players[i][0][2] / localScale; float z = (float)(double)gameData.players[i][0][1] / localScale; var car = Instantiate(prefab, new Vector3(0f, 0f, 0f), Quaternion.identity); car.transform.parent = rootObject.transform; car.transform.localPosition = new Vector3(x, y, z); //car.transform.localScale = new Vector3(120 * 1000 / scaleFactor, 120 * 1000 / scaleFactor, 120 * 1000 / scaleFactor); var renderer = car.transform.Find("carrosserie").GetComponent <Renderer>(); var materials = renderer.materials; materials[0] = gameData.colors[i] == 0 ? blueCar : orangeCar; renderer.materials = materials; var animatable = car.transform.Find("Animatable"); foreach (Transform child in animatable) { var childRenderer = child.GetComponent <Renderer>(); var childMaterials = childRenderer.materials; childMaterials[0] = gameData.colors[i] == 0 ? blueCar : orangeCar; childRenderer.materials = childMaterials; } //car.GetComponent<Renderer>().material = gameData.colors[i] == 0 ? blueCar : orangeCar; car.name = gameData.names[i]; cars.Add(car); var boostObj = Instantiate(this.boost, new Vector3(0f, 0f, 0f), Quaternion.identity); boostObj.transform.parent = car.transform; boostObj.transform.localPosition = new Vector3(0f, 0f, 0f); boostObj.transform.localRotation = Quaternion.Euler(-180f, 0f, 0f); var boostScale = 50f; boostObj.transform.localScale = new Vector3(1 / boostScale, 1 / boostScale, 1 / boostScale); boostObj.GetComponent <ParticleSystem>().Stop(); boosts.Add(boostObj); var name = Instantiate(namePrefab, new Vector3(0f, 0f, 0f), Quaternion.identity); name.GetComponent <TextMesh>().text = gameData.names[i]; name.transform.parent = rootObject.transform; name.transform.localPosition = new Vector3(x, y + 1.0f, z); names.Add(name); // needed so we can look at camera all the time Debug.Log("Count " + (proto == null)); Debug.Log(proto.players[i]); Debug.Log(proto.players[i].isOrange); playerTeamMap[proto.players[i].id.id] = proto.players[i].isOrange; } ballObject = Instantiate(ball, new Vector3(0f, 0f, 0f), Quaternion.identity); ballObject.transform.parent = rootObject.transform; ballObject.transform.localPosition = new Vector3(0f, 0f, 0f); ballObject.transform.localScale = new Vector3(10 * 1000 / scaleFactor, 10 * 1000 / scaleFactor, 10 * 1000 / scaleFactor); goalExplosionObject = Instantiate(goalExplosion, new Vector3(0f, 0f, 0f), Quaternion.identity); goalExplosionObject.transform.parent = rootObject.transform; goalExplosionObject.transform.localScale = new Vector3(4 / scaleFactor, 4 / scaleFactor, 4 / scaleFactor); goalExplosionObject.Stop(); currentTime = (float)gameData.frames[0][2]; }
private static void DumpDebug(Proto f, DumpState D) { int i,n; n= (D.strip != 0) ? 0 : f.sizelineinfo; DumpVector(f.lineinfo, n, D); n= (D.strip != 0) ? 0 : f.sizelocvars; DumpInt(n,D); for (i=0; i<n; i++) { DumpString(f.locvars[i].varname,D); DumpInt(f.locvars[i].startpc,D); DumpInt(f.locvars[i].endpc,D); } n= (D.strip != 0) ? 0 : f.sizeupvalues; DumpInt(n,D); for (i=0; i<n; i++) DumpString(f.upvalues[i],D); }
public async Task Clear() { (await Proto.SendReceive("Clear")).Should().Be(ProtocolMessages.TagListClearConfirmation); }
private static void DumpConstants(Proto f, DumpState D) { int i,n=f.sizek; DumpInt(n,D); for (i=0; i<n; i++) { /*const*/ TValue o=f.k[i]; DumpChar(TType(o),D); switch (TType(o)) { case LUA_TNIL: break; case LUA_TBOOLEAN: DumpChar(BValue(o),D); break; case LUA_TNUMBER: DumpNumber(NValue(o),D); break; case LUA_TSTRING: DumpString(RawTSValue(o),D); break; default: LuaAssert(0); /* cannot happen */ break; } } n=f.sizep; DumpInt(n,D); for (i=0; i<n; i++) DumpFunction(f.p[i],f.source,D); }
public void Register(int responseId, Proto proto, Action <DDNode> handler) { var nrcb = new NetRecivedCallBack(proto.s2cdt, handler); handlerDic.Add(responseId, nrcb); }
private static void LoadConstants(LoadState S, Proto f) { int i,n; n=LoadInt(S); f.k = luaM_newvector<TValue>(S.L, n); f.sizek=n; for (i=0; i<n; i++) setnilvalue(f.k[i]); for (i=0; i<n; i++) { TValue o=f.k[i]; int t=LoadChar(S); switch (t) { case LUA_TNIL: setnilvalue(o); break; case LUA_TBOOLEAN: setbvalue(o, LoadChar(S)); break; case LUA_TNUMBER: setnvalue(o, LoadNumber(S)); break; case LUA_TSTRING: setsvalue2n(S.L, o, LoadString(S)); break; default: error(S,"bad constant"); break; } } n=LoadInt(S); f.p=luaM_newvector<Proto>(S.L,n); f.sizep=n; for (i=0; i<n; i++) f.p[i]=null; for (i=0; i<n; i++) f.p[i]=LoadFunction(S,f.source); }
public static void luaU_print(Proto f, int full) { PrintFunction(f, full); }
public async Task AutoModeReset() { (await Proto.SendReceive("AutoModeReset")).Should().Be(ProtocolMessages.AutoModeResetConfirmation); }
private static void DumpCode(Proto f, DumpState D) { DumpInt(f.sizecode, D); DumpVector(f.code, (uint)f.sizecode, D); }
internal void Update(Proto.Seto.OrderCancelled message) { State.Update(message); OnStateUpdated(); }
/* ** All marks are conditional because a GC may happen while the ** prototype is still being created */ private static void traverseproto(global_State g, Proto f) { int i; if (f.source != null) stringmark(f.source); for (i=0; i<f.sizek; i++) /* mark literals */ markvalue(g, f.k[i]); for (i=0; i<f.sizeupvalues; i++) { /* mark upvalue names */ if (f.upvalues[i] != null) stringmark(f.upvalues[i]); } for (i=0; i<f.sizep; i++) { /* mark nested protos */ if (f.p[i] != null) markobject(g, f.p[i]); } for (i=0; i<f.sizelocvars; i++) { /* mark local-variable names */ if (f.locvars[i].varname != null) stringmark(f.locvars[i].varname); } }
public void OnGUI() { var width = Screen.width; var height = Screen.height; // Scoreboard int offset = 100; Color orange = new Color(1F, 0.64F, 0F); var halfway = width / 2; GUIStyle timeStyle = new GUIStyle(); timeStyle.fontSize = 40; timeStyle.fontStyle = FontStyle.Bold; timeStyle.normal.textColor = Color.gray; timeStyle.alignment = TextAnchor.MiddleCenter; int timeRemaining = 300; if (StaticReplayScript.gameData != null) { timeRemaining = (int)StaticReplayScript.gameData.frames[currentFrame][1]; } //int timeRemaining = 175; int minRemaining = timeRemaining / 60; int secondsRemaining; if (minRemaining > 0) { secondsRemaining = timeRemaining % (minRemaining * 60); } else { secondsRemaining = timeRemaining; } GUI.Label(new Rect(halfway, 35, 50, 50), String.Format("{0}:{1:D2}", minRemaining, secondsRemaining), timeStyle); var team0Score = 0; var team1Score = 0; if (StaticReplayScript.proto != null) { foreach (Goal g in StaticReplayScript.proto.gameMetadata.goals) { if (g.frameNumber < currentFrame) { int playerTeam = playerTeamMap[g.playerId.id]; if (playerTeam == 0) { team0Score += 1; } else { team1Score += 1; } } } } for (int i = 0; i < 2; i++) { Color teamColor = (i == 0) ? Color.blue : (orange); var offsetX = (float)width / 2 - offset + (i * offset * 2); Rect position = new Rect(offsetX, 35, 50, 50); DrawQuad(position, teamColor); GUIStyle style = new GUIStyle(); ///style.font = new Font("Liberation Sans"); style.fontSize = 40; style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.white; style.alignment = TextAnchor.MiddleCenter; GUI.Label(position, (i == 0 ? team0Score : team1Score).ToString(), style); //Color oldColor = GUI.backgroundColor; //GUI.backgroundColor = (i == 0) ? Color.blue : Color.red*Color.yellow; //GUI.backgroundColor = oldColor; } RootObject gameData = StaticReplayScript.gameData; Proto proto = StaticReplayScript.proto; if (gameData != null && proto != null && fieldObject != null) { // Slider Styling GUIStyle thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb); GUIStyle sliderStyle = new GUIStyle(GUI.skin.horizontalSlider); sliderStyle.padding = new RectOffset(width / 10, width / 10, width / 10, width / 10); var logoWidth = width / 60; var nextFrame = (int)GUI.HorizontalSlider(new Rect(0, 19 / 20f * height, width, height / 20f), currentFrame, 0, gameData.frames.Count); if (nextFrame != currentFrame) { currentFrame = nextFrame; currentTime = (float)gameData.frames[nextFrame][2]; } for (int i = 0; i < proto.gameMetadata.goals.Count; i++) { Goal g = proto.gameMetadata.goals[i]; var frame = g.frameNumber; var size = new Rect((width * frame / (float)gameData.frames.Count) - logoWidth / 2, 18 / 20f * height, logoWidth, logoWidth); if (playerTeamMap.ContainsKey(g.playerId.id)) { Color teamColor = playerTeamMap[g.playerId.id] == 0 ? Color.blue : (orange); DrawQuad(size, teamColor); } else { Debug.Log(string.Format("{0} is not in {1}", g.playerId.id, playerTeamMap.Keys.Count)); } GUI.Box(size, goalIndicator); } } GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.fontSize = 30; // Button var back = GUI.Button(new Rect(25, 25, width / 10, width / 25), "Back to Menu", buttonStyle); if (back) { SceneManager.LoadScene("Menu"); } var zoomOut = GUI.Button(new Rect(width * 2 / 10, 25, width / 25, width / 25), "-", buttonStyle); var zoomIn = GUI.Button(new Rect(width * 3 / 10, 25, width / 25, width / 25), "+", buttonStyle); if (zoomOut) { scaleFactor += 100; rootObject.transform.localScale = new Vector3(1 / scaleFactor, 1 / scaleFactor, 1 / scaleFactor); } else if (zoomIn) { scaleFactor -= 100; rootObject.transform.localScale = new Vector3(1 / scaleFactor, 1 / scaleFactor, 1 / scaleFactor); } if (dataMsg != null) { var style = new GUIStyle(); style.fontSize = 20; style.fontStyle = FontStyle.Bold; GUI.Label(new Rect(0, width / 10, width / 5, width / 10), dataMsg, style); } if (protoMsg != null) { var style = new GUIStyle(); style.fontSize = 20; style.fontStyle = FontStyle.Bold; GUI.Label(new Rect(0, 0, width / 5, width / 10), protoMsg, style); } }
//#undef check //#undef checkjump //#undef checkreg /* }====================================================== */ public static int luaG_checkcode(Proto pt) { return((symbexec(pt, pt.sizecode, NO_REG) != 0) ? 1 : 0); }
internal void Update(Proto.Seto.OrderExecuted message) { State.Update(message); OnStateUpdated(); }
private static CharPtr getobjname(lua_State L, CallInfo ci, int reg, ref CharPtr name) { Proto p = ci_func(ci).p; CharPtr what = null; int lastpc = currentpc(ci); int pc; name = luaF_getlocalname(p, reg + 1, lastpc); if (name != null) /* is a local? */ { return("local"); } /* else try symbolic execution */ for (pc = 0; pc < lastpc; pc++) { Instruction i = p.code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); switch (op) { case OpCode.OP_MOVE: { if (reg == a) { int b = GETARG_B(i); /* move from 'b' to 'a' */ if (b < a) { what = getobjname(L, ci, b, ref name); /* get name for 'b' */ } else { what = null; } } break; } case OpCode.OP_GETTABUP: case OpCode.OP_GETTABLE: { if (reg == a) { int k = GETARG_C(i); /* key index */ int t = GETARG_B(i); CharPtr vn = (op == OpCode.OP_GETTABLE) /* name of indexed variable */ ? luaF_getlocalname(p, t + 1, pc) : getstr(p.upvalues[t].name); kname(L, ci, k, a, what, ref name); what = (vn != null && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"; } break; } case OpCode.OP_GETUPVAL: { if (reg == a) { int u = GETARG_B(i); /* upvalue index */ TString tn = p.upvalues[u].name; name = tn != null?getstr(tn) : "?"; what = "upvalue"; } break; } case OpCode.OP_LOADK: case OpCode.OP_LOADKX: { if (reg == a) { int b = (op == OpCode.OP_LOADK) ? GETARG_Bx(i) : GETARG_Ax(p.code[pc + 1]); if (ttisstring(p.k[b])) { what = "constant"; name = svalue(p.k[b]); } } break; } case OpCode.OP_LOADNIL: { int b = GETARG_B(i); if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ { what = null; } break; } case OpCode.OP_SELF: { if (reg == a) { int k = GETARG_C(i); /* key index */ kname(L, ci, k, a, what, ref name); what = "method"; } break; } case OpCode.OP_TFORCALL: { if (reg >= a + 2) { what = null; /* affect all regs above its base */ } break; } case OpCode.OP_CALL: case OpCode.OP_TAILCALL: { if (reg >= a) { what = null; /* affect all registers above base */ } break; } case OpCode.OP_JMP: { int b = GETARG_sBx(i); int dest = pc + 1 + b; /* jump is forward and do not skip `lastpc'? */ if (pc < dest && dest <= lastpc) { pc += b; /* do the jump */ } break; } case OpCode.OP_TEST: { if (reg == a) { what = null; /* jumped code can change 'a' */ } break; } default: if (testAMode(op) != 0 && reg == a) { what = null; } break; } } return(what); }
internal static Order FromSeto( Proto.Seto.OrderState state, Proto.Seto.PriceType priceType, uint price, Proto.Seto.Uuid128 market, Proto.Seto.Uuid128 contract, Proto.Seto.Side side) { return new Order( new Price(priceType, price), OrderState.FromSeto(state), Uid.FromUuid128(market), Uid.FromUuid128(contract), SetoMap.Sides.FromSeto(side)); }
/* ** Try to find a name for a function based on the code that called it. ** (Only works when function was called by a Lua function.) ** Returns what the name is (e.g., "for iterator", "method", ** "metamethod") and sets '*name' to point to the name. */ private static CharPtr funcnamefromcode(lua_State L, CallInfo ci, ref CharPtr name) { TMS tm = (TMS)0; /* (initial value avoids warnings) */ //FIXME:added, = 0 Proto p = ci_func(ci).p; /* calling function */ int pc = currentpc(ci); /* calling instruction index */ Instruction i = p.code[pc]; /* calling instruction */ if (0 != (ci.callstatus & CIST_HOOKED)) /* was it called inside a hook? */ { name = "?"; return("hook"); } switch (GET_OPCODE(i)) { case OpCode.OP_CALL: case OpCode.OP_TAILCALL: return(getobjname(p, pc, GETARG_A(i), ref name)); /* get function name */ case OpCode.OP_TFORCALL: { /* for iterator */ name = "for iterator"; return("for iterator"); } /* other instructions can do calls through metamethods */ case OpCode.OP_SELF: case OpCode.OP_GETTABUP: case OpCode.OP_GETTABLE: tm = TMS.TM_INDEX; break; case OpCode.OP_SETTABUP: case OpCode.OP_SETTABLE: tm = TMS.TM_NEWINDEX; break; case OpCode.OP_ADD: case OpCode.OP_SUB: case OpCode.OP_MUL: case OpCode.OP_MOD: case OpCode.OP_POW: case OpCode.OP_DIV: case OpCode.OP_IDIV: case OpCode.OP_BAND: case OpCode.OP_BOR: case OpCode.OP_BXOR: case OpCode.OP_SHL: case OpCode.OP_SHR: { int offset = cast_int(GET_OPCODE(i)) - cast_int(OpCode.OP_ADD); /* ORDER OP */ tm = (TMS)(offset + cast_int(TMS.TM_ADD)); /* ORDER TM */ break; } case OpCode.OP_UNM: tm = TMS.TM_UNM; break; case OpCode.OP_BNOT: tm = TMS.TM_BNOT; break; case OpCode.OP_LEN: tm = TMS.TM_LEN; break; case OpCode.OP_CONCAT: tm = TMS.TM_CONCAT; break; case OpCode.OP_EQ: tm = TMS.TM_EQ; break; case OpCode.OP_LT: tm = TMS.TM_LT; break; case OpCode.OP_LE: tm = TMS.TM_LE; break; default: return(null); /* cannot find a reasonable name */ } name = getstr(G(L).tmname[(int)tm]); //FIXME:(int) return("metamethod"); }
/// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary> public static Proto.Test.Nullables.LongMessage DeserializeLength(Stream stream, int length, Proto.Test.Nullables.LongMessage instance) { long limit = stream.Position + length; while (true) { if (stream.Position >= limit) { if (stream.Position == limit) break; else throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit"); } int keyByte = stream.ReadByte(); if (keyByte == -1) throw new System.IO.EndOfStreamException(); var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); case 32: if(key.WireType != global::SilentOrbit.ProtocolBuffers.Wire.Varint) break; instance.FieldX1 = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream); continue; case 64: if(key.WireType != global::SilentOrbit.ProtocolBuffers.Wire.Varint) break; instance.FieldX2 = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream); continue; case 96: if(key.WireType != global::SilentOrbit.ProtocolBuffers.Wire.Varint) break; instance.FieldX3 = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream); continue; case 100: if(key.WireType != global::SilentOrbit.ProtocolBuffers.Wire.Varint) break; instance.FieldX4 = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream); continue; default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
} //FIXME:changed, ref->return //#if !defined(luai_verifycode) public static Proto luai_verifycode(lua_State L, Mbuffer b, Proto f) { return(f); }
/// <summary>Takes the remaining content of the stream and deserialze it into the instance.</summary> public static Proto.Test.Nullables.Container Deserialize(Stream stream, Proto.Test.Nullables.Container instance) { while (true) { int keyByte = stream.ReadByte(); if (keyByte == -1) break; // Optimized reading of known fields with field ID < 16 switch (keyByte) { // Field 1 LengthDelimited case 10: if (instance.MyNestedMessage == null) instance.MyNestedMessage = Proto.Test.Nullables.Container.Nested.DeserializeLengthDelimited(stream); else Proto.Test.Nullables.Container.Nested.DeserializeLengthDelimited(stream, instance.MyNestedMessage); continue; // Field 2 LengthDelimited case 18: if (instance.NestedField == null) instance.NestedField = Proto.Test.Nullables.Container.Nested.DeserializeLengthDelimited(stream); else Proto.Test.Nullables.Container.Nested.DeserializeLengthDelimited(stream, instance.NestedField); continue; } var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
/* ** try to find last instruction before 'lastpc' that modified register 'reg' */ private static int findsetreg(Proto p, int lastpc, int reg) { int pc; int setreg = -1; /* keep last instruction that changed 'reg' */ int jmptarget = 0; /* any code before this address is conditional */ for (pc = 0; pc < lastpc; pc++) { Instruction i = p.code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); switch (op) { case OpCode.OP_LOADNIL: { int b = GETARG_B(i); if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ { setreg = filterpc(pc, jmptarget); } break; } case OpCode.OP_TFORCALL: { if (reg >= a + 2) /* affect all regs above its base */ { setreg = filterpc(pc, jmptarget); } break; } case OpCode.OP_CALL: case OpCode.OP_TAILCALL: { if (reg >= a) { setreg = pc; /* affect all registers above base */ } break; } case OpCode.OP_JMP: { int b = GETARG_sBx(i); int dest = pc + 1 + b; /* jump is forward and do not skip `lastpc'? */ if (pc < dest && dest <= lastpc) { if (dest > jmptarget) { jmptarget = dest; /* update 'jmptarget' */ } } break; } default: if (testAMode(op) != 0 && reg == a) /* any instruction that set A */ { setreg = filterpc(pc, jmptarget); } break; } } return(setreg); }
/// <summary>Read the VarInt length prefix and the given number of bytes from the stream and deserialze it into the instance.</summary> public static Proto.Test.Nullables.Container.Nested DeserializeLengthDelimited(Stream stream, Proto.Test.Nullables.Container.Nested instance) { long limit = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt32(stream); limit += stream.Position; while (true) { if (stream.Position >= limit) { if (stream.Position == limit) break; else throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit"); } int keyByte = stream.ReadByte(); if (keyByte == -1) throw new System.IO.EndOfStreamException(); // Optimized reading of known fields with field ID < 16 switch (keyByte) { // Field 1 LengthDelimited case 10: if (instance.NestedData == null) instance.NestedData = Proto.Test.Nullables.Data.DeserializeLengthDelimited(stream); else Proto.Test.Nullables.Data.DeserializeLengthDelimited(stream, instance.NestedData); continue; } var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
private static CharPtr getobjname(Proto p, int lastpc, int reg, ref CharPtr name) { int pc; name = luaF_getlocalname(p, reg + 1, lastpc); if (name != null) /* is a local? */ { return("local"); } /* else try symbolic execution */ pc = findsetreg(p, lastpc, reg); if (pc != -1) /* could find instruction? */ { Instruction i = p.code[pc]; OpCode op = GET_OPCODE(i); switch (op) { case OpCode.OP_MOVE: { int b = GETARG_B(i); /* move from 'b' to 'a' */ if (b < GETARG_A(i)) { return(getobjname(p, pc, b, ref name)); /* get name for 'b' */ } break; } case OpCode.OP_GETTABUP: case OpCode.OP_GETTABLE: { int k = GETARG_C(i); /* key index */ int t = GETARG_B(i); /* table index */ CharPtr vn = (op == OpCode.OP_GETTABLE) /* name of indexed variable */ ? luaF_getlocalname(p, t + 1, pc) : upvalname(p, t); kname(p, pc, k, ref name); return((vn != null && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"); } case OpCode.OP_GETUPVAL: { name = upvalname(p, GETARG_B(i)); return("upvalue"); } case OpCode.OP_LOADK: case OpCode.OP_LOADKX: { int b = (op == OpCode.OP_LOADK) ? GETARG_Bx(i) : GETARG_Ax(p.code[pc + 1]); if (ttisstring(p.k[b])) { name = svalue(p.k[b]); return("constant"); } break; } case OpCode.OP_SELF: { int k = GETARG_C(i); /* key index */ kname(p, pc, k, ref name); return("method"); } default: break; /* go through to return NULL */ } } return(null); /* could not find reasonable name */ }
/// <summary>Read the given number of bytes from the stream and deserialze it into the instance.</summary> public static Proto.Test.Nullables.MyMessage DeserializeLength(Stream stream, int length, Proto.Test.Nullables.MyMessage instance) { long limit = stream.Position + length; while (true) { if (stream.Position >= limit) { if (stream.Position == limit) break; else throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit"); } int keyByte = stream.ReadByte(); if (keyByte == -1) throw new System.IO.EndOfStreamException(); // Optimized reading of known fields with field ID < 16 switch (keyByte) { // Field 1 Varint case 8: instance.Foo = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream); continue; // Field 2 LengthDelimited case 18: instance.Bar = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream); continue; } var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
/* ** returns true if function has been executed (C function) */ public static int luaD_precall(lua_State L, StkId func, int nresults) { lua_CFunction f; CallInfo ci; int n; /* number of arguments (Lua) or returns (C) */ ptrdiff_t funcr = savestack(L, func); switch (ttype(func)) { case LUA_TLCF: /* light C function */ f = fvalue(func); //goto Cfunc; //FIXME:removed, see below luaC_checkGC(L); /* stack grow uses memory */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ ci = next_ci(L); /* now 'enter' new function */ ci.nresults = (short)nresults; //FIXME:added, (short) ci.func = restorestack(L, funcr); ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); ci.callstatus = 0; if ((L.hookmask & LUA_MASKCALL) != 0) { luaD_hook(L, LUA_HOOKCALL, -1); } lua_unlock(L); n = f(L); /* do the actual call */ lua_lock(L); api_checknelems(L, n); luaD_poscall(L, L.top - n, n); return(1); case LUA_TCCL: { /* C closure */ f = clCvalue(func).f; //Cfunc: //FIXME:removed, see upper luaC_checkGC(L); /* stack grow uses memory */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ ci = next_ci(L); /* now 'enter' new function */ ci.nresults = (short)nresults; //FIXME:added, (short) ci.func = restorestack(L, funcr); ci.top = L.top + LUA_MINSTACK; lua_assert(ci.top <= L.stack_last); ci.callstatus = 0; if ((L.hookmask & LUA_MASKCALL) != 0) { luaD_hook(L, LUA_HOOKCALL, -1); } lua_unlock(L); n = f(L); /* do the actual call */ lua_lock(L); api_checknelems(L, n); luaD_poscall(L, L.top - n, n); return(1); } case LUA_TLCL: { /* Lua function: prepare its call */ StkId base_; Proto p = clLvalue(func).p; n = cast_int(L.top - func) - 1; /* number of real arguments */ luaC_checkGC(L); /* stack grow uses memory */ luaD_checkstack(L, p.maxstacksize); for (; n < p.numparams; n++) { setnilvalue(lua_TValue.inc(ref L.top)); /* complete missing arguments */ } if (0 == p.is_vararg) { func = restorestack(L, funcr); base_ = func + 1; } else { base_ = adjust_varargs(L, p, n); func = restorestack(L, funcr); /* previous call can change stack */ } ci = next_ci(L); /* now `enter' new function */ ci.nresults = (short)nresults; //FIXME:added, (short) ci.func = func; ci.u.l.base_ = base_; ci.top = base_ + p.maxstacksize; lua_assert(ci.top <= L.stack_last); ci.u.l.savedpc = new InstructionPtr(p.code, 0); /* starting point */ //FIXME:??? //FIXME:??? ci.callstatus = CIST_LUA; L.top = ci.top; if ((L.hookmask & LUA_MASKCALL) != 0) { callhook(L, ci); } return(0); } default: { /* not a function */ luaD_checkstack(L, 1); /* ensure space for metamethod */ func = restorestack(L, funcr); /* previous call may change stack */ tryfuncTM(L, func); /* try to get '__call' metamethod */ return(luaD_precall(L, func, nresults)); /* now it must be a function */ } } }
//#define setptvalue2s setptvalue internal static void setptvalue2s(lua_State L, TValue obj, Proto x) { setptvalue(L, obj, x); }
private static void DumpFunction(Proto f, TString p, DumpState D) { DumpString( ((f.source==p) || (D.strip!=0)) ? null : f.source, D); DumpInt(f.linedefined,D); DumpInt(f.lastlinedefined,D); DumpChar(f.nups,D); DumpChar(f.numparams,D); DumpChar(f.is_vararg,D); DumpChar(f.maxstacksize,D); DumpCode(f,D); DumpConstants(f,D); DumpDebug(f,D); }
private static void DumpCode(Proto f,DumpState D) { DumpVector(f.code, f.sizecode, D); }
public static int pcRel(InstructionPtr pc, Proto p) { Debug.Assert(pc.codes == p.code); return(pc.pc - 1); }
internal static void SetPTValue(LuaState L, TValue obj, Proto x) { obj.value.gc = x; obj.tt = LUATPROTO; CheckLiveness(G(L), obj); }
public static int getfuncline(Proto f, int pc) { return((f.lineinfo != null) ? f.lineinfo[pc] : 0); }
private static void LoadCode(LoadState S, Proto f) { int n=LoadInt(S); f.code = luaM_newvector<Instruction>(S.L, n); f.sizecode=n; f.code = (Instruction[])LoadVector(S, typeof(Instruction), n); }
private void OnDestroy() { Proto.CallLeave(); Net.Close(); }
private static void LoadDebug(LoadState S, Proto f) { int i,n; n=LoadInt(S); f.lineinfo=luaM_newvector<int>(S.L,n); f.sizelineinfo=n; f.lineinfo = (int[])LoadVector(S, typeof(int), n); n=LoadInt(S); f.locvars=luaM_newvector<LocVar>(S.L,n); f.sizelocvars=n; for (i=0; i<n; i++) f.locvars[i].varname=null; for (i=0; i<n; i++) { f.locvars[i].varname=LoadString(S); f.locvars[i].startpc=LoadInt(S); f.locvars[i].endpc=LoadInt(S); } n=LoadInt(S); f.upvalues=luaM_newvector<TString>(S.L, n); f.sizeupvalues=n; for (i=0; i<n; i++) f.upvalues[i]=null; for (i=0; i<n; i++) f.upvalues[i]=LoadString(S); }
public async Task RfModulation() { (await Proto.SendReceive("RFModulation = DRM")).Should().Be("RFModulation = DRM"); (await Proto.SendReceive("RFModulation?")).Should().Be("RFModulation = DRM"); }