public static int sizestring(TString s) { return(((int)s.len + 1) * GetUnmanagedSize(typeof(char))); }
public static Node hashstr(Table t, TString str) { return(hashpow2(t, str.tsv.hash)); }
public TStringPtrRef(TString tsv) { this.tsv = tsv; }
public void set(TString v) { this.tsv.u.hnext = v; }
//#define setsvalue2n setsvalue public static void setsvalue2n(lua_State L, TValue obj, TString x) { setsvalue(L, obj, x); }
public void set(TString v) { this.arr[this.index] = v; }
//#define setsvalue2s setsvalue internal static void setsvalue2s(lua_State L, TValue obj, TString x) { setsvalue(L, obj, x); }
public static CharPtr getstr(TString ts) { return(ts.str); }
/* ** equality for short strings, which are always internalized */ public static bool eqshrstr(TString a, TString b) { return((bool)check_exp(a.tt == LUA_TSHRSTR, (a) == (b))); }
private static CharPtr getobjname(lua_State L, CallInfo ci, int reg, ref CharPtr name) { Proto p; int lastpc, pc; CharPtr what = null; lua_assert(isLua(ci)); p = ci_func(ci).l.p; lastpc = currentpc(ci); 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_GETGLOBAL: { if (reg == a) { int g = GETARG_Bx(i); if (g != 0) { g--; } else { g = GETARG_Ax(p.code[++pc]); } lua_assert(ttisstring(p.k[g])); name = svalue(p.k[g]); what = "global"; } break; } 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_GETTABLE: { if (reg == a) { int k = GETARG_C(i); /* key index */ name = kname(p, k); what = "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_LOADNIL: { int b = GETARG_B(i); /* move from 'b' to 'a' */ if (a <= reg && reg <= b) /* set registers from 'a' to 'b' */ { what = null; } break; } case OpCode.OP_SELF: { if (reg == a) { int k = GETARG_C(i); /* key index */ name = kname(p, k); 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; } default: if (testAMode(op) != 0 && reg == a) { what = null; } break; } } return(what); }
} //FIXME:changed /* ** test whether a string is a reserved word */ public static bool isreserved(TString s) { return(s.tt == LUA_TSHRSTR && s.extra > 0); }
//#define setsvalue2n setsvalue internal static void SetSValue2N(LuaState L, Lua.LuaTypeValue obj, TString x) { SetSValue(L, obj, x); }
/* ** as all string are internalized, string equality becomes ** pointer equality */ public static bool eqstr(TString a, TString b) { return((a) == (b)); }
public static string getstr(TString ts) { return(ts.str); }
public static void stringmark(TString s) { reset2bits(ref s.tsv.marked, WHITE0BIT, WHITE1BIT); }