# Doing
-* Cleanup the lexer
+* Fix array access in structs
# Up Next
-* Fix array access in structs
+* Implement symbol file generation and import
* Implement module scoped identifiers
* Implement an SSA backend
* Implement pointers
# Backlog
+* Cleanup the lexer
* Implement record extension
* Implement logical operators: and, or, not
* Implement string types
if (sym->type->form == FORM_ARRAY)
{
Type* type = sym->type;
- for (; type->form == FORM_ARRAY; type = type->base);
- printf("%s %s", TypeNames[type->form], name);
- for (type = sym->type; type->form == FORM_ARRAY; type = type->base)
+ long size = 1;
+ for (; type->form == FORM_ARRAY; type = type->base)
{
- printf("[%d]", type->size);
+ size = size * type->size;
}
+ size = size * type->size;
+ printf("Byte %s[%ld]", name, size);
}
else if (sym->type->form == FORM_RECORD)
{
.name = name,
.type = type,
};
- if (type->form == FORM_RECORD)
+ if ((type->form == FORM_RECORD) || (type->form == FORM_ARRAY))
{
printf(" Byte* %s", name);
}
void codegen_index(Parser* p, Item* array, Item* index)
{
- /* load array and index if not already */
- load_var(p, index);
load_var(p, array);
+ load_var(p, index);
/* perform range checking */
if (index->mode == ITEM_CONST)
printf(" __CHECK_RANGE(%s < %d);\n", temp(index), array->type->size);
}
- /* emit the operation */
+ /* emit the operation to calculate offset */
array->type = array->type->base;
array->mode = ITEM_INDEX;
- int dest_reg = declare_temp(p, array->type, 1);
- printf(" = &%s[%s];\n", temp(array), temp(index));
- array->reg = dest_reg;
+
+// int dest_reg = declare_temp(p, array->type, 1);
+// printf(" = &%s[%s];\n", temp(array), temp(index));
+// array->reg = dest_reg;
}
Field* get_field(Parser* p, Type* type, char* name)