pub fn default_value_for_type(&self, ty: &Ty) -> Result<&'ctx Const> {
        match *ty {
            Ty::Named(_, ty) => self.default_value_for_type(self.ty(ty)?),
            Ty::Null => Ok(self.intern_const(Const::Null)),
            Ty::Enum(ref _ty) => {
                // TODO: Replace with the first literal in the enum.
                Ok(self.intern_const(Const::Null))
            }
            Ty::Physical(ref ty) => Ok(self.intern_const(ConstInt::new(
                Some(ty.base.clone()),
                ty.base.left_bound.clone(),
            ))),
            Ty::Int(ref ty) => {
                Ok(self.intern_const(ConstInt::new(Some(ty.clone()), ty.left_bound.clone())))
            }
            Ty::UniversalInt => panic!("universal integer has no default value"),
            Ty::UnboundedInt => panic!("unbounded integer has no default value"),
            Ty::Subprog(..) => panic!("subprogram type has no default value"),
            Ty::Access(_) => Ok(self.intern_const(Const::Null)),
            Ty::Array(ref ty) => {
                self.emit(DiagBuilder2::bug(format!(
                    "default value for type `{}` not implemented",
                    ty
                )));
                // TODO: Use the correct default value.
                Ok(self.intern_const(Const::Null))
            }
            Ty::File(ref ty) => {
                self.emit(DiagBuilder2::bug(format!(
                    "default value for type `{}` not implemented",
                    ty
                )));
                // TODO: Use the correct default value.
                Ok(self.intern_const(Const::Null))
            }
            Ty::Record(ref ty) => {
                self.emit(DiagBuilder2::bug(format!(
                    "default value for type `{}` not implemented",
                    ty
                )));
                // TODO: Use the correct default value.
                Ok(self.intern_const(Const::Null))
            }
        }
    }
/// Calculate the implicit default value for a type.
Calculate the implicit default value for a type.
Calculate the implicit default value for a type .
pub fn default_value_for_type(&self, ty: &Ty) -> Result<&'ctx Const> {
        match *ty {
            Ty::Named(_, ty) => self.default_value_for_type(self.ty(ty)?),
            Ty::Null => Ok(self.intern_const(Const::Null)),
            Ty::Enum(ref _ty) => {
                // TODO: Replace with the first literal in the enum.
                Ok(self.intern_const(Const::Null))
            }
            Ty::Physical(ref ty) => Ok(self.intern_const(ConstInt::new(
                Some(ty.base.clone()),
                ty.base.left_bound.clone(),
            ))),
            Ty::Int(ref ty) => {
                Ok(self.intern_const(ConstInt::new(Some(ty.clone()), ty.left_bound.clone())))
            }
            Ty::UniversalInt => panic!("universal integer has no default value"),
            Ty::UnboundedInt => panic!("unbounded integer has no default value"),
            Ty::Subprog(..) => panic!("subprogram type has no default value"),
            Ty::Access(_) => Ok(self.intern_const(Const::Null)),
            Ty::Array(ref ty) => {
                self.emit(DiagBuilder2::bug(format!(
                    "default value for type `{}` not implemented",
                    ty
                )));
                // TODO: Use the correct default value.
                Ok(self.intern_const(Const::Null))
            }
            Ty::File(ref ty) => {
                self.emit(DiagBuilder2::bug(format!(
                    "default value for type `{}` not implemented",
                    ty
                )));
                // TODO: Use the correct default value.
                Ok(self.intern_const(Const::Null))
            }
            Ty::Record(ref ty) => {
                self.emit(DiagBuilder2::bug(format!(
                    "default value for type `{}` not implemented",
                    ty
                )));
                // TODO: Use the correct default value.
                Ok(self.intern_const(Const::Null))
            }
        }
    }
pub fn default_value_for_type ( & self , ty : & Ty ) -> Result < & ' ctx Const > { match * ty { Ty :: Named ( _ , ty ) => self . default_value_for_type ( self . ty ( ty ) ? ) , Ty :: Null => Ok ( self . intern_const ( Const :: Null ) ) , Ty :: Enum ( ref _ty ) => { // TODO: Replace with the first literal in the enum. Ok ( self . intern_const ( Const :: Null ) ) } Ty :: Physical ( ref ty ) => Ok ( self . intern_const ( ConstInt :: new ( Some ( ty . base . clone ( ) ) , ty . base . left_bound . clone ( ) , ) ) ) , Ty :: Int ( ref ty ) => { Ok ( self . intern_const ( ConstInt :: new ( Some ( ty . clone ( ) ) , ty . left_bound . clone ( ) ) ) ) } Ty :: UniversalInt => panic ! ( " " ) , Ty :: UnboundedInt => panic ! ( " " ) , Ty :: Subprog ( .. ) => panic ! ( " " ) , Ty :: Access ( _ ) => Ok ( self . intern_const ( Const :: Null ) ) , Ty :: Array ( ref ty ) => { self . emit ( DiagBuilder2 :: bug ( format ! ( " " ty ) ) ) ; // TODO: Use the correct default value. Ok ( self . intern_const ( Const :: Null ) ) } Ty :: File ( ref ty ) => { self . emit ( DiagBuilder2 :: bug ( format ! ( " " ty ) ) ) ; // TODO: Use the correct default value. Ok ( self . intern_const ( Const :: Null ) ) } Ty :: Record ( ref ty ) => { self . emit ( DiagBuilder2 :: bug ( format ! ( " " ty ) ) ) ; // TODO: Use the correct default value. Ok ( self . intern_const ( Const :: Null ) ) } } }
Calculate the implicit default value for a type.
Calculate the implicit default value for a type .
&self
ty
&Ty
&self
ty
&Ty