Website Summary Files Commits Branches @commit @diff @stats
path: root / assembler / src / parser / semantic.rs
blob: 47ba2017ad9ef376d9d9eaf32dbc3fb4bdcb2772 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use super::{ Address, Program };

impl Program {
    pub(crate) fn remove_definition_addresses(&mut self) {
        for instr in &mut self.instructions {
            for arg in &mut instr.args {
                if let Address::Definitions(name) = arg {
                    *arg = self.definitions[name].clone();
                }
            }
        }
        self.definitions.clear();
    }

    pub(crate) fn analyze(&self) {
        for instr in &self.instructions {
            let result = instr.check_args();
            if result.is_err() {
                panic!("Instruction '{}' error: {:?}", instr.name, result.err().unwrap());
            }
        }
    }
}