[BUG] Repaired types on some parameters.

[FEAT] Implemented struct, still testing.
[FEAT] Implemented var, still testing.
This commit is contained in:
2021-05-04 10:24:35 +02:00
parent c99d5ab781
commit 567710779a
10 changed files with 96 additions and 27 deletions

View File

@@ -53,14 +53,14 @@ void scope_close_block() {
while (local.variables.size() > size_before_block) local.variables.pop_back();
}
const int scope_declare_variable(const std::string name, const int type, const int length) {
const int scope_declare_variable(const std::string name, const uint32_t type, const uint32_t length) {
t_scope& scope = (are_we_inside_local ? local : global);
if (are_we_inside_local) {
for (int i = blocks.top(); i < scope.variables.size(); i++ ) if (scope.variables[i].name == name) return -1;
} else {
for (t_variable v : scope.variables) if (v.name == name) return -1;
}
const int address = scope.total_size;
const uint32_t address = scope.total_size;
const t_variable var {name, type, length, address};
scope.variables.push_back(var);
scope.total_size += types_get_length(type) + (length == 0 ? 1 : length);