fn defined_str(node: &Node) -> &'static str {
    match &node.kind {
        NodeKind::LocalVar(..) => "local-variable",
        NodeKind::Ident(_) => "method",
        NodeKind::GlobalVar(..) => "global-variable",
        NodeKind::ClassVar(..) => "class variable",
        NodeKind::Const { .. } | NodeKind::Scope(..) => "constant",
        NodeKind::InstanceVar(..) => "instance-variable",
        NodeKind::MulAssign(mlhs, _) => {
            if mlhs.len() != 1 {
                "assignment"
            } else if let NodeKind::Index { .. } = mlhs[0].kind {
                "method"
            } else {
                "assignment"
            }
        }
        NodeKind::AssignOp(..) => "assignment",
        NodeKind::BinOp(..)
        | NodeKind::UnOp(..)
        | NodeKind::Index { .. }
        | NodeKind::Send { .. } => "method",
        NodeKind::Bool(true) => "true",
        NodeKind::Bool(false) => "false",
        NodeKind::Nil => "nil",
        NodeKind::SelfValue => "self",
        _ => "expression",
    }
}
This method returns str corresponding to the type of `self` for `defined?`.
ruruby/src/codegen/defined.rs