static void emit_load_struct_ref(Node *struc, Type *field, int off) { SAVE; switch (struc->kind) { case AST_LVAR: ensure_lvar_init(struc); emit_lload(field, "rbp", struc->loff + field->offset + off); break; case AST_GVAR: emit_gload(field, struc->glabel, field->offset + off); break; case AST_STRUCT_REF: emit_load_struct_ref(struc->struc, field, struc->ty->offset + off); break; case AST_DEREF: emit_expr(struc->operand); emit_lload(field, "rax", field->offset + off); break; default: error("internal error: %s", node2s(struc)); } }
static void emit_gvar(Node *node) { SAVE; emit_gload(node->ctype, node->glabel, 0); }