@@ -18,8 +18,8 @@ use crate::ops::constant::{CustomCheckFailure, CustomConst, ValueName};
18
18
use crate :: ops:: { NamedOp , Value } ;
19
19
use crate :: types:: type_param:: { TypeArg , TypeParam } ;
20
20
use crate :: types:: {
21
- CustomType , FuncValueType , PolyFuncType , PolyFuncTypeRV , Signature , SumType , Type , TypeBound ,
22
- TypeName , TypeRV , TypeRow , TypeRowRV ,
21
+ CustomType , FuncValueType , PolyFuncType , PolyFuncTypeRV , Signature , SumType , Term , Type ,
22
+ TypeBound , TypeName , TypeRV , TypeRow , TypeRowRV ,
23
23
} ;
24
24
use crate :: utils:: sorted_consts;
25
25
use crate :: { Extension , type_row} ;
@@ -678,27 +678,21 @@ impl MakeExtensionOp for MakeTuple {
678
678
if def != TupleOpDef :: MakeTuple {
679
679
return Err ( OpLoadError :: NotMember ( ext_op. unqualified_id ( ) . to_string ( ) ) ) ?;
680
680
}
681
- let [ TypeArg :: List { elems } ] = ext_op. args ( ) else {
681
+ let [ TypeArg :: List ( elems) ] = ext_op. args ( ) else {
682
682
return Err ( SignatureError :: InvalidTypeArgs ) ?;
683
683
} ;
684
684
let tys: Result < Vec < Type > , _ > = elems
685
685
. iter ( )
686
686
. map ( |a| match a {
687
- TypeArg :: Type { ty } => Ok ( ty. clone ( ) ) ,
687
+ TypeArg :: Type ( ty ) => Ok ( ty. clone ( ) ) ,
688
688
_ => Err ( SignatureError :: InvalidTypeArgs ) ,
689
689
} )
690
690
. collect ( ) ;
691
691
Ok ( Self ( tys?. into ( ) ) )
692
692
}
693
693
694
694
fn type_args ( & self ) -> Vec < TypeArg > {
695
- vec ! [ TypeArg :: List {
696
- elems: self
697
- . 0
698
- . iter( )
699
- . map( |t| TypeArg :: Type { ty: t. clone( ) } )
700
- . collect( ) ,
701
- } ]
695
+ vec ! [ Term :: new_list( self . 0 . iter( ) . map( |t| t. clone( ) . into( ) ) ) ]
702
696
}
703
697
}
704
698
@@ -739,27 +733,21 @@ impl MakeExtensionOp for UnpackTuple {
739
733
if def != TupleOpDef :: UnpackTuple {
740
734
return Err ( OpLoadError :: NotMember ( ext_op. unqualified_id ( ) . to_string ( ) ) ) ?;
741
735
}
742
- let [ TypeArg :: List { elems } ] = ext_op. args ( ) else {
736
+ let [ Term :: List ( elems) ] = ext_op. args ( ) else {
743
737
return Err ( SignatureError :: InvalidTypeArgs ) ?;
744
738
} ;
745
739
let tys: Result < Vec < Type > , _ > = elems
746
740
. iter ( )
747
741
. map ( |a| match a {
748
- TypeArg :: Type { ty } => Ok ( ty. clone ( ) ) ,
742
+ Term :: Type ( ty ) => Ok ( ty. clone ( ) ) ,
749
743
_ => Err ( SignatureError :: InvalidTypeArgs ) ,
750
744
} )
751
745
. collect ( ) ;
752
746
Ok ( Self ( tys?. into ( ) ) )
753
747
}
754
748
755
- fn type_args ( & self ) -> Vec < TypeArg > {
756
- vec ! [ TypeArg :: List {
757
- elems: self
758
- . 0
759
- . iter( )
760
- . map( |t| TypeArg :: Type { ty: t. clone( ) } )
761
- . collect( ) ,
762
- } ]
749
+ fn type_args ( & self ) -> Vec < Term > {
750
+ vec ! [ Term :: new_list( self . 0 . iter( ) . map( |t| t. clone( ) . into( ) ) ) ]
763
751
}
764
752
}
765
753
@@ -863,14 +851,14 @@ impl MakeExtensionOp for Noop {
863
851
Self : Sized ,
864
852
{
865
853
let _def = NoopDef :: from_def ( ext_op. def ( ) ) ?;
866
- let [ TypeArg :: Type { ty } ] = ext_op. args ( ) else {
854
+ let [ TypeArg :: Type ( ty ) ] = ext_op. args ( ) else {
867
855
return Err ( SignatureError :: InvalidTypeArgs ) ?;
868
856
} ;
869
857
Ok ( Self ( ty. clone ( ) ) )
870
858
}
871
859
872
860
fn type_args ( & self ) -> Vec < TypeArg > {
873
- vec ! [ TypeArg :: Type { ty : self . 0 . clone( ) } ]
861
+ vec ! [ self . 0 . clone( ) . into ( ) ]
874
862
}
875
863
}
876
864
@@ -969,13 +957,13 @@ impl MakeExtensionOp for Barrier {
969
957
{
970
958
let _def = BarrierDef :: from_def ( ext_op. def ( ) ) ?;
971
959
972
- let [ TypeArg :: List { elems } ] = ext_op. args ( ) else {
960
+ let [ TypeArg :: List ( elems) ] = ext_op. args ( ) else {
973
961
return Err ( SignatureError :: InvalidTypeArgs ) ?;
974
962
} ;
975
963
let tys: Result < Vec < Type > , _ > = elems
976
964
. iter ( )
977
965
. map ( |a| match a {
978
- TypeArg :: Type { ty } => Ok ( ty. clone ( ) ) ,
966
+ TypeArg :: Type ( ty ) => Ok ( ty. clone ( ) ) ,
979
967
_ => Err ( SignatureError :: InvalidTypeArgs ) ,
980
968
} )
981
969
. collect ( ) ;
@@ -985,13 +973,9 @@ impl MakeExtensionOp for Barrier {
985
973
}
986
974
987
975
fn type_args ( & self ) -> Vec < TypeArg > {
988
- vec ! [ TypeArg :: List {
989
- elems: self
990
- . type_row
991
- . iter( )
992
- . map( |t| TypeArg :: Type { ty: t. clone( ) } )
993
- . collect( ) ,
994
- } ]
976
+ vec ! [ TypeArg :: new_list(
977
+ self . type_row. iter( ) . map( |t| t. clone( ) . into( ) ) ,
978
+ ) ]
995
979
}
996
980
}
997
981
@@ -1009,6 +993,7 @@ impl MakeRegisteredOp for Barrier {
1009
993
mod test {
1010
994
use crate :: builder:: inout_sig;
1011
995
use crate :: std_extensions:: arithmetic:: float_types:: { ConstF64 , float64_type} ;
996
+ use crate :: types:: Term ;
1012
997
use crate :: {
1013
998
Hugr , Wire ,
1014
999
builder:: { DFGBuilder , Dataflow , DataflowHugr , endo_sig} ,
@@ -1132,9 +1117,8 @@ mod test {
1132
1117
1133
1118
let err = b. add_load_value ( error_val) ;
1134
1119
1135
- const TYPE_ARG_NONE : TypeArg = TypeArg :: List { elems : vec ! [ ] } ;
1136
1120
let op = PRELUDE
1137
- . instantiate_extension_op ( & EXIT_OP_ID , [ TYPE_ARG_NONE , TYPE_ARG_NONE ] )
1121
+ . instantiate_extension_op ( & EXIT_OP_ID , [ Term :: new_list ( [ ] ) , Term :: new_list ( [ ] ) ] )
1138
1122
. unwrap ( ) ;
1139
1123
1140
1124
b. add_dataflow_op ( op, [ err] ) . unwrap ( ) ;
@@ -1146,10 +1130,8 @@ mod test {
1146
1130
/// test the panic operation with input and output wires
1147
1131
fn test_panic_with_io ( ) {
1148
1132
let error_val = ConstError :: new ( 42 , "PANIC" ) ;
1149
- let type_arg_q: TypeArg = TypeArg :: Type { ty : qb_t ( ) } ;
1150
- let type_arg_2q: TypeArg = TypeArg :: List {
1151
- elems : vec ! [ type_arg_q. clone( ) , type_arg_q] ,
1152
- } ;
1133
+ let type_arg_q: Term = qb_t ( ) . into ( ) ;
1134
+ let type_arg_2q: Term = Term :: new_list ( [ type_arg_q. clone ( ) , type_arg_q] ) ;
1153
1135
let panic_op = PRELUDE
1154
1136
. instantiate_extension_op ( & PANIC_OP_ID , [ type_arg_2q. clone ( ) , type_arg_2q. clone ( ) ] )
1155
1137
. unwrap ( ) ;
0 commit comments