Clean up parsing for AstAsmMemoryOperand

This commit is contained in:
gingerBill
2026-08-12 09:38:55 +01:00
parent 612b25a425
commit a87f5dd5e9

View File

@@ -2451,16 +2451,18 @@ gb_internal Ast *parse_asm_operand(AstFile *f, bool allow_memory_operand) {
base = parse_asm_operand(f, false);
// [base]
// [base + index]
// [base + index + disp]
// [base + index*scale] // *, <<, >>
// [base + index*scale + disp]
if (allow_token(f, Token_Add)) {
Ast *possible_index = parse_asm_operand(f, false);
index = parse_asm_operand(f, false);
if (allow_token(f, Token_Mul) ||
allow_token(f, Token_Shl) ||
allow_token(f, Token_Shr)) {
scale_op = f->prev_token;
index = possible_index;
scale = parse_asm_operand(f, false);
} else {
index = possible_index;
}
if (allow_token(f, Token_Add)) {
disp = parse_asm_operand(f, false);
@@ -2469,6 +2471,7 @@ gb_internal Ast *parse_asm_operand(AstFile *f, bool allow_memory_operand) {
Token close = expect_token(f, Token_CloseBracket);
// [...]:type
if (allow_token(f, Token_Colon)) {
type = parse_type(f);
}