[FEAT] Working on array and struct support on expressions
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
struct t_struct {
|
||||
std::string name;
|
||||
int size;
|
||||
uint32_t size;
|
||||
std::vector<t_variable> members;
|
||||
};
|
||||
static std::vector<t_struct> types;
|
||||
@@ -17,7 +17,7 @@ void types_init() {
|
||||
|
||||
const int types_add(const std::string name) {
|
||||
for (auto t : types) if (t.name == name) return -1;
|
||||
t_struct new_type; new_type.name = name;
|
||||
t_struct new_type {name, 0};
|
||||
types.push_back(new_type);
|
||||
return types.size()-1;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ const int types_get_length(const uint32_t type) {
|
||||
const int types_add_member(const uint32_t type, const std::string name, const uint32_t var_type, const uint32_t length) {
|
||||
if (type >= types.size()) return -1; // ERROR INTERN: No deuria donar-se mai
|
||||
for (auto m : types[type].members) if (m.name == name) return -1;
|
||||
const t_variable new_var {name, var_type, length};
|
||||
const t_variable new_var {name, var_type, length, types[type].size};
|
||||
types[type].members.push_back(new_var);
|
||||
types[type].size += types_get_length(var_type) + length;
|
||||
return types[type].members.size()-1;
|
||||
|
||||
Reference in New Issue
Block a user