To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

def_use.rs 727 Bytes
Newer Older
qinsoon's avatar
qinsoon committed
1
2
3
4
5
6
7
8
9
10
use ast::ir::*;
use vm::context::VMContext;

use compiler::CompilerPass;

pub struct DefUsePass {
    name: &'static str,
}

impl DefUsePass {
11
    pub fn new(name: &'static str) -> DefUsePass {
qinsoon's avatar
qinsoon committed
12
13
14
15
16
17
18
19
20
        DefUsePass{name: name}
    }
}

impl CompilerPass for DefUsePass {
    fn name(&self) -> &'static str {
        self.name
    }
    
21
22
23
24
25
26
27
28
29
    fn visit_inst(&mut self, vm_context: &VMContext, node: &mut TreeNode) {
        match node.v {
            TreeNode_::Instruction(ref inst) => {
                for p_node in inst.list_operands() {
                    p_node.use_count.set(p_node.use_count.get() + 1)
                }
            },
            TreeNode_::Value(_) => panic!("expected instruction node")
        }
qinsoon's avatar
qinsoon committed
30
31
    }
}