insert stackvar sorted
This commit is contained in:
parent
da2a298baf
commit
d144537c3b
|
|
@ -6,6 +6,7 @@ extern panic
|
|||
extern vec_extend
|
||||
extern vec_get
|
||||
extern vec_push
|
||||
extern vec_insert_sorted
|
||||
extern vec_init_with
|
||||
|
||||
global codegen_function
|
||||
|
|
@ -285,7 +286,9 @@ codegen_function:
|
|||
mov [rsp + 24], rax ; current_stack_size += size_of::<u64>
|
||||
lea rdi, [rsp + 32] ; stack-vars
|
||||
lea rsi, [rsp + 88] ; &(index, offset)
|
||||
call vec_push
|
||||
mov rdx, stackvar_cmp
|
||||
mov rcx, 0
|
||||
call vec_insert_sorted
|
||||
inc r14
|
||||
jmp .arg_loop
|
||||
|
||||
|
|
@ -293,9 +296,9 @@ codegen_function:
|
|||
|
||||
mov rdi, [rsp] ; ctx
|
||||
lea rsi, [rsp + 24] ; &function_ctx
|
||||
mov rdx, [rbx + 48] ; AstFunction.body
|
||||
call codegen_block
|
||||
|
||||
|
||||
; TODO: generate function body
|
||||
|
||||
; push "ret\n"
|
||||
|
|
@ -317,5 +320,6 @@ codegen_function:
|
|||
|
||||
;; rdi: ctx
|
||||
;; rsi: &function_ctx
|
||||
;; rdx: block index
|
||||
codegen_block:
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -88,15 +88,15 @@ fn main() {
|
|||
};
|
||||
}
|
||||
|
||||
// print_ast(
|
||||
// b"fn main(a: u32) -> void {
|
||||
// let y: u32 = a + 4;
|
||||
// {
|
||||
// let y: u32 = 10;
|
||||
// }
|
||||
// let y: *u32 = &y;
|
||||
// return *y;
|
||||
// }",
|
||||
// |ast| unsafe { parse_func(ast) },
|
||||
// );
|
||||
print_ast(
|
||||
b"fn main(a: u32) -> void {
|
||||
let y: u32 = a + 4;
|
||||
{
|
||||
let y: u32 = 10;
|
||||
}
|
||||
let y: *u32 = &y;
|
||||
return *y;
|
||||
}",
|
||||
|ast| unsafe { parse_func(ast) },
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue