mirror of
https://github.com/janet-lang/janet
synced 2025-10-24 12:17:41 +00:00
Update marsh for functions still WIP.
This commit is contained in:
@@ -203,7 +203,7 @@ static void marshal_one(MarshalState *st, Dst x, int flags) {
|
|||||||
/* Check reference */
|
/* Check reference */
|
||||||
{
|
{
|
||||||
Dst check = dst_table_get(&st->seen, x);
|
Dst check = dst_table_get(&st->seen, x);
|
||||||
if (!dst_checktype(check, DST_NIL)) {
|
if (dst_checktype(check, DST_INTEGER)) {
|
||||||
pushbyte(st, LB_REFERENCE);
|
pushbyte(st, LB_REFERENCE);
|
||||||
pushint(st, dst_unwrap_integer(check));
|
pushint(st, dst_unwrap_integer(check));
|
||||||
return;
|
return;
|
||||||
@@ -548,14 +548,14 @@ static const uint8_t *unmarshal_one_def(
|
|||||||
for (int32_t i = 0; i < def->bytecode_length; i++) {
|
for (int32_t i = 0; i < def->bytecode_length; i++) {
|
||||||
if (data + 4 > st->end) longjmp(st->err, UMR_EOS);
|
if (data + 4 > st->end) longjmp(st->err, UMR_EOS);
|
||||||
def->bytecode[i] =
|
def->bytecode[i] =
|
||||||
data[0] |
|
(uint32_t)(data[0]) |
|
||||||
(data[1] << 8) |
|
((uint32_t)(data[1]) << 8) |
|
||||||
(data[2] << 16) |
|
((uint32_t)(data[2]) << 16) |
|
||||||
(data[3] << 24);
|
((uint32_t)(data[3]) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unmarshal environments */
|
/* Unmarshal environments */
|
||||||
if (def->environments_length) {
|
if (def->flags & DST_FUNCDEF_FLAG_HASENVS) {
|
||||||
def->environments = malloc(sizeof(int32_t) * def->environments_length);
|
def->environments = malloc(sizeof(int32_t) * def->environments_length);
|
||||||
if (!def->environments) {
|
if (!def->environments) {
|
||||||
DST_OUT_OF_MEMORY;
|
DST_OUT_OF_MEMORY;
|
||||||
@@ -568,7 +568,7 @@ static const uint8_t *unmarshal_one_def(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Unmarshal sub funcdefs */
|
/* Unmarshal sub funcdefs */
|
||||||
if (def->defs_length) {
|
if (def->flags & DST_FUNCDEF_FLAG_HASDEFS) {
|
||||||
def->defs = malloc(sizeof(DstFuncDef *) * def->defs_length);
|
def->defs = malloc(sizeof(DstFuncDef *) * def->defs_length);
|
||||||
if (!def->defs) {
|
if (!def->defs) {
|
||||||
DST_OUT_OF_MEMORY;
|
DST_OUT_OF_MEMORY;
|
||||||
@@ -665,6 +665,7 @@ static const uint8_t *unmarshal_one(
|
|||||||
case LB_BUFFER:
|
case LB_BUFFER:
|
||||||
case LB_REGISTRY:
|
case LB_REGISTRY:
|
||||||
{
|
{
|
||||||
|
data++;
|
||||||
int32_t len = readint(st, &data);
|
int32_t len = readint(st, &data);
|
||||||
EXTRA(len);
|
EXTRA(len);
|
||||||
if (lead == LB_STRING) {
|
if (lead == LB_STRING) {
|
||||||
@@ -707,6 +708,7 @@ static const uint8_t *unmarshal_one(
|
|||||||
case LB_TABLE_PROTO:
|
case LB_TABLE_PROTO:
|
||||||
/* Things that open with integers */
|
/* Things that open with integers */
|
||||||
{
|
{
|
||||||
|
data++;
|
||||||
int32_t len = readint(st, &data);
|
int32_t len = readint(st, &data);
|
||||||
if (lead == LB_ARRAY) {
|
if (lead == LB_ARRAY) {
|
||||||
/* Array */
|
/* Array */
|
||||||
|
|||||||
Reference in New Issue
Block a user