fn combine_return_types(&mut self, sig: &P<MuFuncSig>, vm: &VM) -> P<MuType> {
        let (res, new_res) = match self.combined_return_types.get(&sig.id()) {
            Some(ty) => (ty.clone(), false),
            None => {
                let n = sig.ret_tys.len();

                (
                    if n == 0 {
                        VOID_TYPE.clone()
                    } else if n == 1 {
                        sig.ret_tys[0].clone()
                    } else {
                        //declare_type(&self, entity: MuEntityHeader, ty: MuType_)
                        let id = new_internal_id();
                        let name = Arc::new(format!("return_type:#{}", id));
                        let header = MuEntityHeader::named(new_internal_id(), name.clone());
                        vm.declare_type(header, MuType_::mustruct(name, sig.ret_tys.to_vec()))
                    },
                    true
                )
            }
        };
        if new_res {
            self.combined_return_types.insert(sig.id(), res.clone());
        }
        res
    }
// Note: if tys has more than 1 element, then this will return a new struct type
// , but each call will generate a different name for this struct type
// (but the layout will be identical)
if tys has more than 1 element, then this will return a new struct type
, but each call will generate a different name for this struct type
(but the layout will be identical)
if tys has more than 1 element then this will return a new struct type but each call will generate a different name for this struct type ( but the layout will be identical )
fn combine_return_types(&mut self, sig: &P<MuFuncSig>, vm: &VM) -> P<MuType> {
        let (res, new_res) = match self.combined_return_types.get(&sig.id()) {
            Some(ty) => (ty.clone(), false),
            None => {
                let n = sig.ret_tys.len();
                (
                    if n == 0 {
                        VOID_TYPE.clone()
                    } else if n == 1 {
                        sig.ret_tys[0].clone()
                    } else {
                        //declare_type(&self, entity: MuEntityHeader, ty: MuType_)
                        let id = new_internal_id();
                        let name = Arc::new(format!("return_type:#{}", id));
                        let header = MuEntityHeader::named(new_internal_id(), name.clone());
                        vm.declare_type(header, MuType_::mustruct(name, sig.ret_tys.to_vec()))
                    },
                    true
                )
            }
        };
        if new_res {
            self.combined_return_types.insert(sig.id(), res.clone());
        }
        res
    }
fn combine_return_types ( & mut self , sig : & P < MuFuncSig > , vm : & VM ) -> P < MuType > { let ( res , new_res ) = match self . combined_return_types . get ( & sig . id ( ) ) { Some ( ty ) => ( ty . clone ( ) , false ) , None => { let n = sig . ret_tys . len ( ) ; ( if n == 0 { VOID_TYPE . clone ( ) } else if n == 1 { sig . ret_tys [ 0 ] . clone ( ) } else { //declare_type(&self, entity: MuEntityHeader, ty: MuType_) let id = new_internal_id ( ) ; let name = Arc :: new ( format ! ( " " id ) ) ; let header = MuEntityHeader :: named ( new_internal_id ( ) , name . clone ( ) ) ; vm . declare_type ( header , MuType_ :: mustruct ( name , sig . ret_tys . to_vec ( ) ) ) } , true ) } } ; if new_res { self . combined_return_types . insert ( sig . id ( ) , res . clone ( ) ) ; } res }
Note: if tys has more than 1 element, then this will return a new struct type
, but each call will generate a different name for this struct type
(but the layout will be identical)
Note : if tys has more than 1 element then this will return a new struct type but each call will generate a different name for this struct type ( but the layout will be identical )
&mut self
sig
&P<MuFuncSig>
vm
&VM
&mut self
sig
&P<MuFuncSig>
vm
&VM