as expr (tree walk)

This commit is contained in:
janis 2025-11-05 15:45:16 +01:00
parent 192c123373
commit fe350da24d
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8
3 changed files with 11 additions and 1 deletions

View file

@ -1853,6 +1853,14 @@ ast_walk_for_each:
je .if_expr je .if_expr
cmp bl, AST_CALL cmp bl, AST_CALL
je .call je .call
cmp bl, AST_AS
je .as_expr
jmp .check_scope
.as_expr:
mov rbx, [rax + 8] ; AstNode.data = *AstAsExpr
mov rax, [rbx + 0] ; AstCallExpr.expr
push rax ; push expr index
jmp .check_scope jmp .check_scope
.call: .call:

View file

@ -133,7 +133,7 @@ return main(1);
print_ast( print_ast(
b"fn main(a: u32) -> void { b"fn main(a: u32) -> void {
return 1 as u8; return a as u8;
}", }",
|ast| unsafe { parse_func(ast) }, |ast| unsafe { parse_func(ast) },
); );

View file

@ -324,6 +324,8 @@ pub struct Operand {
pub register: u8, pub register: u8,
pub width: u16, pub width: u16,
pub len: u16, pub len: u16,
pub align: u8,
pub bitset: u8,
pub value: u64, pub value: u64,
} }