asm: fix compiler warnings

This commit is contained in:
2024-12-14 21:03:44 +00:00
parent 462f67c6aa
commit a167dd2af5
8 changed files with 150 additions and 117 deletions

View File

@@ -1,40 +1,44 @@
#include "parse.h"
#include <ivy/selector.h>
#include <ivy/asm/bin.h>
#include <ivy/asm/assembler.h>
#include <ivy/asm/bin.h>
#include <ivy/asm/lex.h>
#include <ivy/selector.h>
struct selector_parser_state {
struct parser_state s_base;
unsigned int s_prev_token;
unsigned int s_paren_depth;
struct ivy_asm_token *s_prev_label;
struct ivy_selector *s_sel;
};
static enum ivy_status init_state(
struct ivy_asm_parser *ctx, struct parser_state *s)
static void init_state(struct ivy_asm_parser *ctx, struct parser_state *s)
{
struct selector_parser_state *state = (struct selector_parser_state *)s;
state->s_prev_token = IVY_ASM_SYM_LEFT_PAREN;
return ivy_selector_create(&state->s_sel);
ivy_selector_create(&state->s_sel);
}
static enum ivy_status parse_ident(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct selector_parser_state *state = (struct selector_parser_state *)asm_parser_get_state(ctx);
struct selector_parser_state *state
= (struct selector_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token == IVY_ASM_TOK_LABEL && state->s_prev_label) {
ivy_selector_add_arg(state->s_sel, state->s_prev_label->t_str, tok->t_str);
ivy_selector_add_arg(
state->s_sel, state->s_prev_label->t_str, tok->t_str);
ivy_asm_token_destroy(tok);
ivy_asm_token_destroy(state->s_prev_label);
state->s_prev_label = tok;
state->s_prev_token = IVY_ASM_TOK_LABEL;
return IVY_OK;
}
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN && state->s_prev_token != IVY_ASM_SYM_HYPHEN && state->s_prev_token != IVY_ASM_SYM_PLUS) {
}
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN
&& state->s_prev_token != IVY_ASM_SYM_HYPHEN
&& state->s_prev_token != IVY_ASM_SYM_PLUS) {
return IVY_ERR_BAD_SYNTAX;
}
@@ -48,11 +52,12 @@ static enum ivy_status parse_ident(
static enum ivy_status parse_label(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct selector_parser_state *state = (struct selector_parser_state *)asm_parser_get_state(ctx);
struct selector_parser_state *state
= (struct selector_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN
&& state->s_prev_token != IVY_ASM_TOK_LABEL
&& state->s_prev_token != IVY_ASM_SYM_HYPHEN
&& state->s_prev_token != IVY_ASM_SYM_PLUS) {
&& state->s_prev_token != IVY_ASM_TOK_LABEL
&& state->s_prev_token != IVY_ASM_SYM_HYPHEN
&& state->s_prev_token != IVY_ASM_SYM_PLUS) {
return IVY_ERR_BAD_SYNTAX;
}
@@ -71,37 +76,40 @@ static enum ivy_status parse_label(
static enum ivy_status parse_hyphen(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct selector_parser_state *state = (struct selector_parser_state *)asm_parser_get_state(ctx);
struct selector_parser_state *state
= (struct selector_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN) {
return IVY_ERR_BAD_SYNTAX;
}
ivy_selector_set_recipient(state->s_sel, IVY_SEL_OBJECT);
state->s_prev_token = IVY_ASM_SYM_HYPHEN;
return IVY_OK;
}
static enum ivy_status parse_plus(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct selector_parser_state *state = (struct selector_parser_state *)asm_parser_get_state(ctx);
struct selector_parser_state *state
= (struct selector_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN) {
return IVY_ERR_BAD_SYNTAX;
}
ivy_selector_set_recipient(state->s_sel, IVY_SEL_CLASS);
state->s_prev_token = IVY_ASM_SYM_PLUS;
return IVY_OK;
}
static enum ivy_status parse_left_paren(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct selector_parser_state *state = (struct selector_parser_state *)asm_parser_get_state(ctx);
struct selector_parser_state *state
= (struct selector_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_TOK_IDENT) {
return IVY_ERR_BAD_SYNTAX;
@@ -120,9 +128,12 @@ static enum ivy_status parse_left_paren(
static enum ivy_status parse_right_paren(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct selector_parser_state *state = (struct selector_parser_state *)asm_parser_get_state(ctx);
struct selector_parser_state *state
= (struct selector_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_TOK_IDENT && state->s_prev_token != IVY_ASM_TOK_LABEL && state->s_prev_token != IVY_ASM_SYM_RIGHT_PAREN) {
if (state->s_prev_token != IVY_ASM_TOK_IDENT
&& state->s_prev_token != IVY_ASM_TOK_LABEL
&& state->s_prev_token != IVY_ASM_SYM_RIGHT_PAREN) {
return IVY_ERR_BAD_SYNTAX;
}
@@ -154,4 +165,4 @@ struct parser_state_type selector_parser_state_type = {
SYM_PARSER(LEFT_PAREN, parse_left_paren),
SYM_PARSER(RIGHT_PAREN, parse_right_paren),
},
};
};