asm: assembler: constpool value indices are now used and enforced
constpool values must be defined in ascending sequence, each index must be greater than the last. any gaps in the sequence will automatically be filled with null values.
This commit is contained in:
@@ -287,7 +287,7 @@ enum ivy_status ivy_assembler_end_scope(struct ivy_assembler *as)
|
|||||||
|
|
||||||
enum ivy_status ivy_assembler_put_pval(
|
enum ivy_status ivy_assembler_put_pval(
|
||||||
struct ivy_assembler *as, enum ivy_assembler_pval_type type,
|
struct ivy_assembler *as, enum ivy_assembler_pval_type type,
|
||||||
const void *val, ivy_extended_data_key *key)
|
size_t slot, const void *val, ivy_extended_data_key *key)
|
||||||
{
|
{
|
||||||
struct assembler_scope *scope = as->as_scope;
|
struct assembler_scope *scope = as->as_scope;
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ enum ivy_status ivy_assembler_put_pval(
|
|||||||
return IVY_ERR_NOT_SUPPORTED;
|
return IVY_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return type_info->s_put_pval(as, scope, type, val, key);
|
return type_info->s_put_pval(as, scope, type, slot, val, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ivy_status ivy_assembler_put_xval(
|
enum ivy_status ivy_assembler_put_xval(
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ struct assembler_scope_type {
|
|||||||
|
|
||||||
enum ivy_status (*s_put_pval)(
|
enum ivy_status (*s_put_pval)(
|
||||||
struct ivy_assembler *, struct assembler_scope *,
|
struct ivy_assembler *, struct assembler_scope *,
|
||||||
enum ivy_assembler_pval_type, const void *,
|
enum ivy_assembler_pval_type, size_t, const void *,
|
||||||
ivy_extended_data_key *key);
|
ivy_extended_data_key *key);
|
||||||
|
|
||||||
enum ivy_status (*s_put_xval)(
|
enum ivy_status (*s_put_xval)(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
struct constpool_assembler_scope {
|
struct constpool_assembler_scope {
|
||||||
struct assembler_scope s_base;
|
struct assembler_scope s_base;
|
||||||
b_dict *s_strings;
|
b_dict *s_strings;
|
||||||
|
size_t s_next_slot;
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum ivy_status init_scope(
|
static enum ivy_status init_scope(
|
||||||
@@ -26,6 +27,7 @@ static enum ivy_status init_scope(
|
|||||||
struct constpool_assembler_scope *c
|
struct constpool_assembler_scope *c
|
||||||
= (struct constpool_assembler_scope *)scope;
|
= (struct constpool_assembler_scope *)scope;
|
||||||
c->s_strings = b_dict_create();
|
c->s_strings = b_dict_create();
|
||||||
|
c->s_next_slot = 0;
|
||||||
|
|
||||||
return IVY_OK;
|
return IVY_OK;
|
||||||
}
|
}
|
||||||
@@ -151,12 +153,18 @@ static ivy_extended_data_key write_ident(
|
|||||||
|
|
||||||
static enum ivy_status put_pval(
|
static enum ivy_status put_pval(
|
||||||
struct ivy_assembler *as, struct assembler_scope *scope,
|
struct ivy_assembler *as, struct assembler_scope *scope,
|
||||||
enum ivy_assembler_pval_type type, const void *val,
|
enum ivy_assembler_pval_type type, size_t slot, const void *val,
|
||||||
ivy_extended_data_key *key)
|
ivy_extended_data_key *key)
|
||||||
{
|
{
|
||||||
struct ivy_bin_constpool_table_entry entry = {0};
|
struct ivy_bin_constpool_table_entry entry = {0};
|
||||||
uintptr_t i = *(uintptr_t *)val;
|
uintptr_t i = *(uintptr_t *)val;
|
||||||
ivy_extended_data_key k = IVY_EX_DATA_KEY_NULL;
|
ivy_extended_data_key k = IVY_EX_DATA_KEY_NULL;
|
||||||
|
struct constpool_assembler_scope *s
|
||||||
|
= (struct constpool_assembler_scope *)assembler_get_scope(as);
|
||||||
|
|
||||||
|
if (slot < s->s_next_slot) {
|
||||||
|
return IVY_ERR_NAME_EXISTS;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case IVY_ASM_PVAL_STRING:
|
case IVY_ASM_PVAL_STRING:
|
||||||
@@ -195,7 +203,13 @@ static enum ivy_status put_pval(
|
|||||||
*key = k;
|
*key = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (size_t i = s->s_next_slot; i < slot; i++) {
|
||||||
|
struct ivy_bin_constpool_table_entry null_entry = {0};
|
||||||
|
assembler_write_data(as, &null_entry, sizeof null_entry);
|
||||||
|
}
|
||||||
|
|
||||||
assembler_write_data(as, &entry, sizeof entry);
|
assembler_write_data(as, &entry, sizeof entry);
|
||||||
|
s->s_next_slot = slot + 1;
|
||||||
return IVY_OK;
|
return IVY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ IVY_API enum ivy_status ivy_assembler_end_scope(struct ivy_assembler *as);
|
|||||||
|
|
||||||
IVY_API enum ivy_status ivy_assembler_put_pval(
|
IVY_API enum ivy_status ivy_assembler_put_pval(
|
||||||
struct ivy_assembler *as, enum ivy_assembler_pval_type type,
|
struct ivy_assembler *as, enum ivy_assembler_pval_type type,
|
||||||
const void *val, ivy_extended_data_key *key);
|
size_t slot, const void *val, ivy_extended_data_key *key);
|
||||||
IVY_API enum ivy_status ivy_assembler_put_xval(
|
IVY_API enum ivy_status ivy_assembler_put_xval(
|
||||||
struct ivy_assembler *as, enum ivy_assembler_xval_type type,
|
struct ivy_assembler *as, enum ivy_assembler_xval_type type,
|
||||||
const ivy_assembler_attrib_table attrib);
|
const ivy_assembler_attrib_table attrib);
|
||||||
|
|||||||
Reference in New Issue
Block a user