fn transpile_type_rhs(&mut self, ty: &ParsedType, opts: TypeOpts) {
        let is_func_ret = opts.contains(TypeOpts::FUNCTION_RETURN);
        match ty {
            ParsedType::Array { inner, len } if !is_func_ret => {
                self.builder += "[";
                self.transpile_expr(len);
                self.builder += "]";
                self.transpile_type_rhs(&inner, opts);
                // just chuck the []
            }
            ParsedType::Pointer(inner) | ParsedType::Array { inner, .. } => {
                if let ParsedType::Array { .. } = **inner {
                    if !is_func_ret {
                        self.builder += ")";
                    }
                }
                self.transpile_type_rhs(&inner, opts);
            }
            ParsedType::Var { .. } | ParsedType::Fresh { .. } | ParsedType::Unknown => { /* no op */
            }
            ParsedType::Func { args, ret, .. } => {
                self.builder += ")(";
                if !args.is_empty() {
                    for (i, arg) in args.iter().enumerate() {
                        self.transpile_type(&arg, opts & !TypeOpts::SIMPLE_VAR_SPACE);
                        if i < args.len() - 1 {
                            self.builder += ", ";
                        }
                    }
                } else {
                    self.builder += "void";
                }
                self.builder += ")";
                self.transpile_type_rhs(&ret, opts | TypeOpts::FUNCTION_RETURN);
            }
        }
    }
// NOTE: we do inner after ourselves in rhs
we do inner after ourselves in rhs
we do inner after ourselves in rhs
fn transpile_type_rhs(&mut self, ty: &ParsedType, opts: TypeOpts) {
        let is_func_ret = opts.contains(TypeOpts::FUNCTION_RETURN);
        match ty {
            ParsedType::Array { inner, len } if !is_func_ret => {
                self.builder += "[";
                self.transpile_expr(len);
                self.builder += "]";
                self.transpile_type_rhs(&inner, opts);
                // just chuck the []
            }
            ParsedType::Pointer(inner) | ParsedType::Array { inner, .. } => {
                if let ParsedType::Array { .. } = **inner {
                    if !is_func_ret {
                        self.builder += ")";
                    }
                }
                self.transpile_type_rhs(&inner, opts);
            }
            ParsedType::Var { .. } | ParsedType::Fresh { .. } | ParsedType::Unknown => { /* no op */
            }
            ParsedType::Func { args, ret, .. } => {
                self.builder += ")(";
                if !args.is_empty() {
                    for (i, arg) in args.iter().enumerate() {
                        self.transpile_type(&arg, opts & !TypeOpts::SIMPLE_VAR_SPACE);
                        if i < args.len() - 1 {
                            self.builder += ", ";
                        }
                    }
                } else {
                    self.builder += "void";
                }
                self.builder += ")";
                self.transpile_type_rhs(&ret, opts | TypeOpts::FUNCTION_RETURN);
            }
        }
    }
fn transpile_type_rhs ( & mut self , ty : & ParsedType , opts : TypeOpts ) { let is_func_ret = opts . contains ( TypeOpts :: FUNCTION_RETURN ) ; match ty { ParsedType :: Array { inner , len } if ! is_func_ret => { self . builder += " " ; self . transpile_expr ( len ) ; self . builder += " " ; self . transpile_type_rhs ( & inner , opts ) ; // just chuck the [] } ParsedType :: Pointer ( inner ) | ParsedType :: Array { inner , .. } => { if let ParsedType :: Array { .. } = * * inner { if ! is_func_ret { self . builder += " " ; } } self . transpile_type_rhs ( & inner , opts ) ; } ParsedType :: Var { .. } | ParsedType :: Fresh { .. } | ParsedType :: Unknown => { /* no op */ } ParsedType :: Func { args , ret , .. } => { self . builder += " " ; if ! args . is_empty ( ) { for ( i , arg ) in args . iter ( ) . enumerate ( ) { self . transpile_type ( & arg , opts & ! TypeOpts :: SIMPLE_VAR_SPACE ) ; if i < args . len ( ) - 1 { self . builder += " " ; } } } else { self . builder += " " ; } self . builder += " " ; self . transpile_type_rhs ( & ret , opts | TypeOpts :: FUNCTION_RETURN ) ; } } }
NOTE: we do inner after ourselves in rhs
NOTE : we do inner after ourselves in rhs
&mut self
ty
&ParsedType
opts
TypeOpts