Cr0a3/asc

[BUG] CodeGeneration get func dosn't work

Closed this issue · 0 comments

let mut func_scope = false;

        let mut func_scope_name = String::new();

        for token in tokens {
            match token {
                Token::RET => {
                    if func_scope {
                        print!("ret");
                        let func = self.functs.get_mut(&func_scope_name).unwrap();  // wrong function dosn't get the correct refernece
                        func.asm_ret();
                    }
                },
                Token::IDENT(x) => {
                    if !func_scope {
                        let mut func = self.builder.add_function(x.clone().as_str()).to_owned();
                        self.functs.insert(x.clone(), func);
                        func_scope = true;
                        func_scope_name = x;
                    } else {

                    }
                }

                _ => {}
            }