[FORM_BOOL] = "Bool",
[FORM_INT] = "Int",
[FORM_REAL] = "Real",
- [FORM_STRING] = "char*"
+ [FORM_STRING] = "Byte*"
};
static char* Operators[] = {
}
else if (sym->type->form == FORM_RECORD)
{
- printf("char %s[%d]", name, sym->type->size);
+ printf("Byte %s[%d]", name, sym->type->size);
}
else
{
};
if (type->form == FORM_RECORD)
{
- printf(" char* %s", name);
+ printf(" Byte* %s", name);
}
else
{
}
else if (a->mode == ITEM_FIELD)
{
- snprintf(name, sizeof(name), "*((%s)_T%d)", typetoptr(a->type), a->reg);
+ snprintf(name, sizeof(name), "*((%s)(_T%d + %d))", typetoptr(a->type), a->reg, a->offset);
}
else
{
item->reg = declare_temp(p, item->type, isref);
if (item->type->form == FORM_RECORD)
{
- printf(" = (char*)&%s[0];\n", item->imm.s);
+ printf(" = (Byte*)&%s[0];\n", item->imm.s);
}
else
{
void codegen_startmod(Parser* p)
{
(void)p;
+ printf("typedef char Byte;\n");
printf("typedef _Bool Bool;\n");
printf("typedef long Int;\n");
printf("typedef double Real;\n");
+ puts("");
}
void codegen_endmod(Parser* p)
else if (a->mode == ITEM_FIELD)
{
load_var(p, b);
-// printf(" *((%s)%s) = %s;\n", typetoptr(a->type), temp(a), temp(b));
printf(" %s = %s;\n", temp(a), temp(b));
}
else
Field* f = get_field(p, record->type, name);
record->mode = ITEM_FIELD;
record->type = f->type;
- printf(" char* _T%d", p->curr_reg);
- p->curr_reg++;
- printf(" = _T%d + %ld;\n", record->reg, f->offset);
- record->reg = p->curr_reg-1;
+ record->offset += f->offset;
}