Skip to content

Commit

Permalink
[parser] register if a micheline is the unit value
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Sep 11, 2024
1 parent 964865f commit a28c335
Show file tree
Hide file tree
Showing 31 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions app/src/parser/micheline_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ tz_micheline_parser_init(tz_parser_state *state)

m->frame = m->stack;
m->stack[0].step = TZ_MICHELINE_STEP_TAG;
m->is_unit = false;
}

/**
Expand Down Expand Up @@ -373,6 +374,12 @@ tz_micheline_parser_step(tz_parser_state *state)
}
m->frame->step = TZ_MICHELINE_STEP_PRIM_NAME;
m->frame->step_prim.op = op;
// clang-format off
m->is_unit = ((m->frame == m->stack)
&& (op == TZ_MICHELSON_OP_Unit)
&& (m->frame->step_prim.nargs == 0)
&& (!m->frame->step_prim.annot));
// clang-format on
break;
case TZ_MICHELINE_STEP_PRIM_NAME:
if (m->frame->step_prim.wrap && m->frame->step_prim.first) {
Expand Down
1 change: 1 addition & 0 deletions app/src/parser/micheline_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ typedef struct {
stack[TZ_MICHELINE_STACK_DEPTH]; /// stack of frames
tz_micheline_parser_frame *frame; /// current frame
/// init == stack, NULL when done
bool is_unit; /// indicates whether the micheline read is a unit
} tz_micheline_state;
3 changes: 3 additions & 0 deletions app/src/parser/operation_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ tz_step_read_micheline(tz_parser_state *state)
}
tz_micheline_parser_step(state);
if (state->errno == TZ_BLO_DONE) {
if (state->micheline.is_unit) {
state->field_info.is_field_complex = false;
}
if ((op->frame->stop != 0) && (state->ofs != op->frame->stop)) {
tz_raise(TOO_LARGE);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
6 changes: 3 additions & 3 deletions tests/unit/ctest/tests_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ CTEST2(operation_parser, check_stake_complexity)
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
{"Parameter", false, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand All @@ -324,7 +324,7 @@ CTEST2(operation_parser, check_unstake_complexity)
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
{"Parameter", false, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand All @@ -344,7 +344,7 @@ CTEST2(operation_parser, check_finalize_unstake_complexity)
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
{"Parameter", false, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand Down

0 comments on commit a28c335

Please sign in to comment.