17 "Unexpected token where is expected a bitfield statement."
27 if (size < 0 || size > 512) {
33 "Bitfield size should be between 0 and 512."
40 if (! isupper(name[0])) {
46 "Bitfield name should start with upper case."
64 "Bitfield body declaration expected here."
70 int64_t total_size = 0;
79 total_size += field_size;
82 if (size != total_size) {
88 "Bitfield size should be equal to the sum of all field sizes."
void eval_bitfield(mir_t *mir, module_t *module, ast_node_t *ast)
Evaluates a bitfield statement.
int64_t eval_expression(hashtable_t *variables, module_t *module, ast_node_t *ast)
Evaluates a mathetical expression.
mir_bitfield_field_t * mir_bitfield_add_field(mir_bitfield_t *bitfield, const char *name, uint32_t size)
Add a new field to a bitfield declaration.
mir_bitfield_t * mir_add_bitfield(mir_t *mir, const char *name, uint32_t size)
Add a new bitfield declaration.
void module_add_error(module_t *module, unsigned int line, unsigned int column, unsigned int length, const char *message)
Add error for the given module.
unsigned int children_count
struct ast_node * children
unsigned int length
The length of the string.
char * data
Pointer for the raw string content (a normal C string).
Mya in-memory intermediate representation.
hashtable_t variables
Hashtable of variables.
Struct that represents a Mya module.
long long int value
Integer value of the token.
dstring_t lexeme
Lexeme of the token.
unsigned int line
Token line inside the module.
unsigned int column
Column of the token position on the line.
struct ast_node ast_node_t
struct mir_bitfield mir_bitfield_t
A bitfield declaration.
struct mir mir_t
Mya in-memory intermediate representation.
struct module module_t
Struct that represents a Mya module.