mie: implement value type initialiser functions
This commit is contained in:
26
mie/const.c
Normal file
26
mie/const.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <mie/const.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void mie_int_init(struct mie_int *out, long long val, unsigned int nr_bits)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
mie_value_init(&out->i_base.c_base, MIE_VALUE_CONST);
|
||||
|
||||
out->i_base.c_type = MIE_CONST_INT;
|
||||
out->i_value = val;
|
||||
out->i_width = nr_bits;
|
||||
}
|
||||
|
||||
struct mie_int *mie_int_create(long long val, unsigned int nr_bits)
|
||||
{
|
||||
struct mie_int *out = malloc(sizeof *out);
|
||||
|
||||
if (!out) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mie_int_init(out, val, nr_bits);
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user