This commit is contained in:
2024-12-16 21:02:03 +00:00
10 changed files with 437 additions and 119 deletions

View File

@@ -1,6 +1,7 @@
#include <ivy/ident.h>
#include <blue/core/queue.h>
#include <blue/core/stringstream.h>
#include <blue/object/string.h>
#include <ivy/ident.h>
#include <stdlib.h>
#include <string.h>
@@ -23,9 +24,10 @@ void ivy_ident_destroy(struct ivy_ident *ident)
b_queue_iterator_begin(&ident->id_parts, &it);
while (b_queue_iterator_is_valid(&it)) {
struct ivy_ident_part *part = b_unbox(struct ivy_ident_part, it.entry, p_entry);
struct ivy_ident_part *part
= b_unbox(struct ivy_ident_part, it.entry, p_entry);
b_queue_iterator_erase(&it);
free(part->p_str);
free(part);
}
@@ -49,21 +51,22 @@ void ivy_ident_add_part(struct ivy_ident *ident, const char *s)
size_t ivy_ident_to_string(const struct ivy_ident *ident, char *out, size_t max)
{
b_strv_builder strv;
b_strv_builder_begin(&strv, out, max);
b_stringstream strv;
b_stringstream_begin(&strv, out, max);
int i = 0;
b_queue_iterator it = {0};
b_queue_foreach (&it, &ident->id_parts) {
if (i > 0) {
b_strv_builder_add(&strv, ".");
b_stringstream_add(&strv, ".");
}
struct ivy_ident_part *part = b_unbox(struct ivy_ident_part, it.entry, p_entry);
b_strv_builder_add(&strv, part->p_str);
struct ivy_ident_part *part
= b_unbox(struct ivy_ident_part, it.entry, p_entry);
b_stringstream_add(&strv, part->p_str);
i++;
}
/* TODO return string length. */
return 0;
}
}

View File

@@ -12,7 +12,6 @@ enum ivy_instr_id {
IVY_INSTR_SUB,
IVY_INSTR_MUL,
IVY_INSTR_DIV,
IVY_INSTR_CMP,
IVY_INSTR_C_EQ,
IVY_INSTR_C_NE,
IVY_INSTR_C_LT,
@@ -20,14 +19,8 @@ enum ivy_instr_id {
IVY_INSTR_C_GT,
IVY_INSTR_C_GE,
IVY_INSTR_BR,
IVY_INSTR_B_Z,
IVY_INSTR_B_NZ,
IVY_INSTR_B_EQ,
IVY_INSTR_B_NE,
IVY_INSTR_B_LT,
IVY_INSTR_B_LE,
IVY_INSTR_B_GT,
IVY_INSTR_B_GE,
IVY_INSTR_BR_T,
IVY_INSTR_BR_F,
IVY_INSTR_OB_C,
IVY_INSTR_OB_E,
IVY_INSTR_LAM_C,
@@ -49,7 +42,7 @@ enum ivy_opcode {
IVY_OP_LDR_SELF_CONST,
IVY_OP_LDR_POOL_REG,
IVY_OP_LDR_POOL_CONST,
IVY_OP_LDR_IMM,
IVY_OP_LDR_CONST,
IVY_OP_STR_SP_REG,
IVY_OP_STR_SP_CONST,
@@ -70,8 +63,6 @@ enum ivy_opcode {
IVY_OP_MUL,
IVY_OP_DIV,
IVY_OP_CMP,
IVY_OP_C_EQ,
IVY_OP_C_NE,
IVY_OP_C_LT,
@@ -80,19 +71,15 @@ enum ivy_opcode {
IVY_OP_C_GE,
IVY_OP_BR,
IVY_OP_B_Z,
IVY_OP_B_NZ,
IVY_OP_B_EQ,
IVY_OP_B_NE,
IVY_OP_B_LT,
IVY_OP_B_LE,
IVY_OP_B_GT,
IVY_OP_B_GE,
IVY_OP_BR_T,
IVY_OP_BR_F,
IVY_OP_OB_C,
IVY_OP_OB_C_REG,
IVY_OP_OB_C_CONST,
IVY_OP_OB_E,
IVY_OP_LAM_C,
IVY_OP_LAM_C_REG,
IVY_OP_LAM_C_CONST,
IVY_OP_IT_G,
IVY_OP_IT_N,