fn wrapup_type_builtin(bt: &BuiltinType) -> (Builtin, Vec<Builtin>) {
    let bi = Builtin::new(Def::Type(bt.id), bt.name).ty(bt.ty.clone());
    let mut aux = Vec::new();

    // Add the usual predefined operators that all types get.
    match bt.ty {
        Ty::Enum(_) => enum_type_builtins(&bt.named_ty(), &mut aux),
        Ty::Int(_) => integer_type_builtins(&bt.named_ty(), &mut aux),
        Ty::Physical(_) => physical_type_builtins(&bt.named_ty(), &mut aux),
        Ty::Array(ref at) => array_type_builtins(&bt.named_ty(), at, &mut aux),
        _ => (),
    }

    // Add the predefined operators for BIT and BOOLEAN.
    if bt.id == BOOLEAN_TYPE.id || bt.id == BIT_TYPE.id {
        // The type `(T) return T`.
        let unary_ty = SubprogTy::new(
            vec![SubprogTyArg::positional(bt.named_ty())],
            Some(bt.named_ty()),
        );

        // The type `(T, T) return T`.
        let binary_ty = SubprogTy::new(
            vec![
                SubprogTyArg::positional(bt.named_ty()),
                SubprogTyArg::positional(bt.named_ty()),
            ],
            Some(bt.named_ty()),
        );

        aux.push(Builtin::operator(UnaryOp::Not).ty(unary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::And)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Or)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Nand)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Nor)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Xor)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Xnor)).ty(binary_ty.clone()));
    }

    // Add the predefined `??` operator for BIT.
    if bt.id == BIT_TYPE.id {
        // The type `(T) return BOOLEAN`.
        let op_ty = SubprogTy::new(
            vec![SubprogTyArg::positional(bt.named_ty())],
            Some(BOOLEAN_TYPE.named_ty()),
        );
        aux.push(Builtin::operator(UnaryOp::Cond).ty(op_ty.clone()));
    }

    (bi, aux)
}
/// Takes a builtin type and produces the builtin and its auxiliary defs.
Takes a builtin type and produces the builtin and its auxiliary defs.
Takes a builtin type and produces the builtin and its auxiliary defs .
fn wrapup_type_builtin(bt: &BuiltinType) -> (Builtin, Vec<Builtin>) {
    let bi = Builtin::new(Def::Type(bt.id), bt.name).ty(bt.ty.clone());
    let mut aux = Vec::new();
    // Add the usual predefined operators that all types get.
    match bt.ty {
        Ty::Enum(_) => enum_type_builtins(&bt.named_ty(), &mut aux),
        Ty::Int(_) => integer_type_builtins(&bt.named_ty(), &mut aux),
        Ty::Physical(_) => physical_type_builtins(&bt.named_ty(), &mut aux),
        Ty::Array(ref at) => array_type_builtins(&bt.named_ty(), at, &mut aux),
        _ => (),
    }
    // Add the predefined operators for BIT and BOOLEAN.
    if bt.id == BOOLEAN_TYPE.id || bt.id == BIT_TYPE.id {
        // The type `(T) return T`.
        let unary_ty = SubprogTy::new(
            vec![SubprogTyArg::positional(bt.named_ty())],
            Some(bt.named_ty()),
        );
        // The type `(T, T) return T`.
        let binary_ty = SubprogTy::new(
            vec![
                SubprogTyArg::positional(bt.named_ty()),
                SubprogTyArg::positional(bt.named_ty()),
            ],
            Some(bt.named_ty()),
        );
        aux.push(Builtin::operator(UnaryOp::Not).ty(unary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::And)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Or)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Nand)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Nor)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Xor)).ty(binary_ty.clone()));
        aux.push(Builtin::operator(BinaryOp::Logical(LogicalOp::Xnor)).ty(binary_ty.clone()));
    }
    // Add the predefined `??` operator for BIT.
    if bt.id == BIT_TYPE.id {
        // The type `(T) return BOOLEAN`.
        let op_ty = SubprogTy::new(
            vec![SubprogTyArg::positional(bt.named_ty())],
            Some(BOOLEAN_TYPE.named_ty()),
        );
        aux.push(Builtin::operator(UnaryOp::Cond).ty(op_ty.clone()));
    }
    (bi, aux)
}
fn wrapup_type_builtin ( bt : & BuiltinType ) -> ( Builtin , Vec < Builtin > ) { let bi = Builtin :: new ( Def :: Type ( bt . id ) , bt . name ) . ty ( bt . ty . clone ( ) ) ; let mut aux = Vec :: new ( ) ; // Add the usual predefined operators that all types get. match bt . ty { Ty :: Enum ( _ ) => enum_type_builtins ( & bt . named_ty ( ) , & mut aux ) , Ty :: Int ( _ ) => integer_type_builtins ( & bt . named_ty ( ) , & mut aux ) , Ty :: Physical ( _ ) => physical_type_builtins ( & bt . named_ty ( ) , & mut aux ) , Ty :: Array ( ref at ) => array_type_builtins ( & bt . named_ty ( ) , at , & mut aux ) , _ => ( ) , } // Add the predefined operators for BIT and BOOLEAN. if bt . id == BOOLEAN_TYPE . id || bt . id == BIT_TYPE . id { // The type `(T) return T`. let unary_ty = SubprogTy :: new ( vec ! [ SubprogTyArg positional ( bt named_ty ( ) ) ] , Some ( bt . named_ty ( ) ) , ) ; // The type `(T, T) return T`. let binary_ty = SubprogTy :: new ( vec ! [ SubprogTyArg positional ( bt named_ty ( ) ) SubprogTyArg positional ( bt named_ty ( ) ) ] , Some ( bt . named_ty ( ) ) , ) ; aux . push ( Builtin :: operator ( UnaryOp :: Not ) . ty ( unary_ty . clone ( ) ) ) ; aux . push ( Builtin :: operator ( BinaryOp :: Logical ( LogicalOp :: And ) ) . ty ( binary_ty . clone ( ) ) ) ; aux . push ( Builtin :: operator ( BinaryOp :: Logical ( LogicalOp :: Or ) ) . ty ( binary_ty . clone ( ) ) ) ; aux . push ( Builtin :: operator ( BinaryOp :: Logical ( LogicalOp :: Nand ) ) . ty ( binary_ty . clone ( ) ) ) ; aux . push ( Builtin :: operator ( BinaryOp :: Logical ( LogicalOp :: Nor ) ) . ty ( binary_ty . clone ( ) ) ) ; aux . push ( Builtin :: operator ( BinaryOp :: Logical ( LogicalOp :: Xor ) ) . ty ( binary_ty . clone ( ) ) ) ; aux . push ( Builtin :: operator ( BinaryOp :: Logical ( LogicalOp :: Xnor ) ) . ty ( binary_ty . clone ( ) ) ) ; } // Add the predefined `??` operator for BIT. if bt . id == BIT_TYPE . id { // The type `(T) return BOOLEAN`. let op_ty = SubprogTy :: new ( vec ! [ SubprogTyArg positional ( bt named_ty ( ) ) ] , Some ( BOOLEAN_TYPE . named_ty ( ) ) , ) ; aux . push ( Builtin :: operator ( UnaryOp :: Cond ) . ty ( op_ty . clone ( ) ) ) ; } ( bi , aux ) }
Takes a builtin type and produces the builtin and its auxiliary defs.
Takes a builtin type and produces the builtin and its auxiliary defs .
bt
&BuiltinType
bt
&BuiltinType