diff options
Diffstat (limited to 'src/lj_bcwrite.c')
-rw-r--r-- | src/lj_bcwrite.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lj_bcwrite.c b/src/lj_bcwrite.c index de200ef4..ec6f13c8 100644 --- a/src/lj_bcwrite.c +++ b/src/lj_bcwrite.c | |||
@@ -71,6 +71,8 @@ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) | |||
71 | *p++ = BCDUMP_KTAB_NUM; | 71 | *p++ = BCDUMP_KTAB_NUM; |
72 | p = lj_strfmt_wuleb128(p, o->u32.lo); | 72 | p = lj_strfmt_wuleb128(p, o->u32.lo); |
73 | p = lj_strfmt_wuleb128(p, o->u32.hi); | 73 | p = lj_strfmt_wuleb128(p, o->u32.hi); |
74 | } else if (tvistab(o)) { /* Write the nil value marker as a nil. */ | ||
75 | *p++ = BCDUMP_KTAB_NIL; | ||
74 | } else { | 76 | } else { |
75 | lj_assertBCW(tvispri(o), "unhandled type %d", itype(o)); | 77 | lj_assertBCW(tvispri(o), "unhandled type %d", itype(o)); |
76 | *p++ = BCDUMP_KTAB_NIL+~itype(o); | 78 | *p++ = BCDUMP_KTAB_NIL+~itype(o); |
@@ -133,7 +135,7 @@ static void bcwrite_ktab_sorted_hash(BCWriteCtx *ctx, Node *node, MSize nhash) | |||
133 | TValue **heap = ctx->heap; | 135 | TValue **heap = ctx->heap; |
134 | MSize i = nhash; | 136 | MSize i = nhash; |
135 | for (;; node--) { /* Build heap. */ | 137 | for (;; node--) { /* Build heap. */ |
136 | if (!tvisnil(&node->key)) { | 138 | if (!tvisnil(&node->val)) { |
137 | bcwrite_ktabk_heap_insert(heap, --i, nhash, &node->key); | 139 | bcwrite_ktabk_heap_insert(heap, --i, nhash, &node->key); |
138 | if (i == 0) break; | 140 | if (i == 0) break; |
139 | } | 141 | } |
@@ -163,7 +165,7 @@ static void bcwrite_ktab(BCWriteCtx *ctx, char *p, const GCtab *t) | |||
163 | MSize i, hmask = t->hmask; | 165 | MSize i, hmask = t->hmask; |
164 | Node *node = noderef(t->node); | 166 | Node *node = noderef(t->node); |
165 | for (i = 0; i <= hmask; i++) | 167 | for (i = 0; i <= hmask; i++) |
166 | nhash += !tvisnil(&node[i].key); | 168 | nhash += !tvisnil(&node[i].val); |
167 | } | 169 | } |
168 | /* Write number of array slots and hash slots. */ | 170 | /* Write number of array slots and hash slots. */ |
169 | p = lj_strfmt_wuleb128(p, narray); | 171 | p = lj_strfmt_wuleb128(p, narray); |
@@ -184,7 +186,7 @@ static void bcwrite_ktab(BCWriteCtx *ctx, char *p, const GCtab *t) | |||
184 | } else { | 186 | } else { |
185 | MSize i = nhash; | 187 | MSize i = nhash; |
186 | for (;; node--) | 188 | for (;; node--) |
187 | if (!tvisnil(&node->key)) { | 189 | if (!tvisnil(&node->val)) { |
188 | bcwrite_ktabk(ctx, &node->key, 0); | 190 | bcwrite_ktabk(ctx, &node->key, 0); |
189 | bcwrite_ktabk(ctx, &node->val, 1); | 191 | bcwrite_ktabk(ctx, &node->val, 1); |
190 | if (--i == 0) break; | 192 | if (--i == 0) break; |