diff options
Diffstat (limited to '')
-rw-r--r-- | src/lj_bcwrite.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/lj_bcwrite.c b/src/lj_bcwrite.c index 7580a8ea..c5c042e0 100644 --- a/src/lj_bcwrite.c +++ b/src/lj_bcwrite.c | |||
@@ -62,7 +62,7 @@ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) | |||
62 | if (num == (lua_Number)k) { /* -0 is never a constant. */ | 62 | if (num == (lua_Number)k) { /* -0 is never a constant. */ |
63 | *p++ = BCDUMP_KTAB_INT; | 63 | *p++ = BCDUMP_KTAB_INT; |
64 | p = lj_strfmt_wuleb128(p, k); | 64 | p = lj_strfmt_wuleb128(p, k); |
65 | setsbufP(&ctx->sb, p); | 65 | ctx->sb.w = p; |
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | } | 68 | } |
@@ -73,7 +73,7 @@ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) | |||
73 | lj_assertBCW(tvispri(o), "unhandled type %d", itype(o)); | 73 | lj_assertBCW(tvispri(o), "unhandled type %d", itype(o)); |
74 | *p++ = BCDUMP_KTAB_NIL+~itype(o); | 74 | *p++ = BCDUMP_KTAB_NIL+~itype(o); |
75 | } | 75 | } |
76 | setsbufP(&ctx->sb, p); | 76 | ctx->sb.w = p; |
77 | } | 77 | } |
78 | 78 | ||
79 | /* Write a template table. */ | 79 | /* Write a template table. */ |
@@ -97,7 +97,7 @@ static void bcwrite_ktab(BCWriteCtx *ctx, char *p, const GCtab *t) | |||
97 | /* Write number of array slots and hash slots. */ | 97 | /* Write number of array slots and hash slots. */ |
98 | p = lj_strfmt_wuleb128(p, narray); | 98 | p = lj_strfmt_wuleb128(p, narray); |
99 | p = lj_strfmt_wuleb128(p, nhash); | 99 | p = lj_strfmt_wuleb128(p, nhash); |
100 | setsbufP(&ctx->sb, p); | 100 | ctx->sb.w = p; |
101 | if (narray) { /* Write array entries (may contain nil). */ | 101 | if (narray) { /* Write array entries (may contain nil). */ |
102 | MSize i; | 102 | MSize i; |
103 | TValue *o = tvref(t->array); | 103 | TValue *o = tvref(t->array); |
@@ -172,7 +172,7 @@ static void bcwrite_kgc(BCWriteCtx *ctx, GCproto *pt) | |||
172 | } | 172 | } |
173 | #endif | 173 | #endif |
174 | } | 174 | } |
175 | setsbufP(&ctx->sb, p); | 175 | ctx->sb.w = p; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
@@ -206,7 +206,7 @@ static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt) | |||
206 | p = lj_strfmt_wuleb128(p, o->u32.hi); | 206 | p = lj_strfmt_wuleb128(p, o->u32.hi); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | setsbufP(&ctx->sb, p); | 209 | ctx->sb.w = p; |
210 | } | 210 | } |
211 | 211 | ||
212 | /* Write bytecode instructions. */ | 212 | /* Write bytecode instructions. */ |
@@ -281,7 +281,7 @@ static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt) | |||
281 | /* Write bytecode instructions and upvalue refs. */ | 281 | /* Write bytecode instructions and upvalue refs. */ |
282 | p = bcwrite_bytecode(ctx, p, pt); | 282 | p = bcwrite_bytecode(ctx, p, pt); |
283 | p = lj_buf_wmem(p, proto_uv(pt), pt->sizeuv*2); | 283 | p = lj_buf_wmem(p, proto_uv(pt), pt->sizeuv*2); |
284 | setsbufP(&ctx->sb, p); | 284 | ctx->sb.w = p; |
285 | 285 | ||
286 | /* Write constants. */ | 286 | /* Write constants. */ |
287 | bcwrite_kgc(ctx, pt); | 287 | bcwrite_kgc(ctx, pt); |
@@ -291,16 +291,16 @@ static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt) | |||
291 | if (sizedbg) { | 291 | if (sizedbg) { |
292 | p = lj_buf_more(&ctx->sb, sizedbg); | 292 | p = lj_buf_more(&ctx->sb, sizedbg); |
293 | p = lj_buf_wmem(p, proto_lineinfo(pt), sizedbg); | 293 | p = lj_buf_wmem(p, proto_lineinfo(pt), sizedbg); |
294 | setsbufP(&ctx->sb, p); | 294 | ctx->sb.w = p; |
295 | } | 295 | } |
296 | 296 | ||
297 | /* Pass buffer to writer function. */ | 297 | /* Pass buffer to writer function. */ |
298 | if (ctx->status == 0) { | 298 | if (ctx->status == 0) { |
299 | MSize n = sbuflen(&ctx->sb) - 5; | 299 | MSize n = sbuflen(&ctx->sb) - 5; |
300 | MSize nn = (lj_fls(n)+8)*9 >> 6; | 300 | MSize nn = (lj_fls(n)+8)*9 >> 6; |
301 | char *q = sbufB(&ctx->sb) + (5 - nn); | 301 | char *q = ctx->sb.b + (5 - nn); |
302 | p = lj_strfmt_wuleb128(q, n); /* Fill in final size. */ | 302 | p = lj_strfmt_wuleb128(q, n); /* Fill in final size. */ |
303 | lj_assertBCW(p == sbufB(&ctx->sb) + 5, "bad ULEB128 write"); | 303 | lj_assertBCW(p == ctx->sb.b + 5, "bad ULEB128 write"); |
304 | ctx->status = ctx->wfunc(sbufL(&ctx->sb), q, nn+n, ctx->wdata); | 304 | ctx->status = ctx->wfunc(sbufL(&ctx->sb), q, nn+n, ctx->wdata); |
305 | } | 305 | } |
306 | } | 306 | } |
@@ -324,8 +324,8 @@ static void bcwrite_header(BCWriteCtx *ctx) | |||
324 | p = lj_strfmt_wuleb128(p, len); | 324 | p = lj_strfmt_wuleb128(p, len); |
325 | p = lj_buf_wmem(p, name, len); | 325 | p = lj_buf_wmem(p, name, len); |
326 | } | 326 | } |
327 | ctx->status = ctx->wfunc(sbufL(&ctx->sb), sbufB(&ctx->sb), | 327 | ctx->status = ctx->wfunc(sbufL(&ctx->sb), ctx->sb.b, |
328 | (MSize)(p - sbufB(&ctx->sb)), ctx->wdata); | 328 | (MSize)(p - ctx->sb.b), ctx->wdata); |
329 | } | 329 | } |
330 | 330 | ||
331 | /* Write footer of bytecode dump. */ | 331 | /* Write footer of bytecode dump. */ |