/// <summary> /// Undumps the debug info for a <code>Proto</code>. </summary> /// <param name="proto"> The Proto instance to which debug info will be added. </param> private void debug(Proto proto) { // lineinfo int n = intLoad(); int[] lineinfo = new int[n]; for (int i = 0; i < n; ++i) { lineinfo[i] = intLoad(); } // locvars n = intLoad(); LocVar[] locvar = new LocVar[n]; for (int i = 0; i < n; ++i) { string s = @string(); int start = intLoad(); int end = intLoad(); locvar[i] = new LocVar(s, start, end); } // upvalue (names) n = intLoad(); string[] upvalue = new string[n]; for (int i = 0; i < n; ++i) { upvalue[i] = @string(); } proto.debug(lineinfo, locvar, upvalue); return; }
/// <summary> /// Trim locvar array to specified size. </summary> internal void closeLocvars(int n) { if (n == locvars_Renamed.Length) { return; } LocVar[] newArray = new LocVar[n]; Array.Copy(locvars_Renamed, 0, newArray, 0, n); locvars_Renamed = newArray; sizelocvars = n; }
internal void ensureLocvars(Lua L, int atleast, int limit) { if (atleast + 1 > sizelocvars) { int newsize = atleast * 2 + 1; if (newsize > limit) { newsize = limit; } if (atleast + 1 > newsize) { L.gRunerror("too many local variables"); } LocVar[] newlocvars = new LocVar [newsize]; Array.Copy(locvars_Renamed, 0, newlocvars, 0, sizelocvars); for (int i = sizelocvars; i < newsize; i++) { newlocvars[i] = new LocVar(); } locvars_Renamed = newlocvars; sizelocvars = newsize; } }