Commit 7c2b0663 authored by Benoît Simonneaux's avatar Benoît Simonneaux

compiler/parser: Add val_imm_debug_data().

parent 07e1aeed
......@@ -20,6 +20,7 @@
#include "common/utils.h"
#include "ast.h"
#include "debug.h"
#include "parser.h"
#include "parser_priv.h"
......@@ -44,6 +45,42 @@ static int val_imm_dtor(struct bm_ast_node *node)
return 0;
}
static int val_imm_debug_data(const struct bm_ast_node *node, int indent_lvl)
{
const struct bm_ast_node_data_val_imm *data = &node->data.as_val_imm;
wprintf(L",\n%*ls\"value_type\": \"%ls\"", indent_lvl * 2, L"", debug_val_imm_type(data->type));
wprintf(L",\n%*ls\"value\": ", indent_lvl * 2, L"");
switch (data->type)
{
case BM_AST_VALUE_IMM_BOOL:
wprintf(L"%ls", debug_bool(data->data.as_imm_bool));
break;
case BM_AST_VALUE_IMM_CHAR:
wprintf(L"\"%lc\"", data->data.as_imm_char);
break;
case BM_AST_VALUE_IMM_FLOAT:
wprintf(L"%f", data->data.as_imm_float);
break;
case BM_AST_VALUE_IMM_INT:
wprintf(L"%d", data->data.as_imm_int);
break;
case BM_AST_VALUE_IMM_STRING:
wprintf(L"\"%ls\"", data->data.as_imm_string);
break;
case BM_AST_VALUE_IMM_UINT:
wprintf(L"%u", data->data.as_imm_uint);
break;
}
return 0;
}
static int parse_val_imm(struct parser_ctx *ctx, unsigned long *cur_tok_id, struct bm_ast_node *out)
{
unsigned long i = *cur_tok_id;
......@@ -51,6 +88,7 @@ static int parse_val_imm(struct parser_ctx *ctx, unsigned long *cur_tok_id, stru
parser_node_init(&val, BM_AST_NODE_VAL_IMM);
val.dtor = val_imm_dtor;
val.debug_data = val_imm_debug_data;
switch (ctx->in->tokens[i].type)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment