@@ -35,6 +35,7 @@ pub enum Function {
3535 SubstrIndex ,
3636 Sub ,
3737 GSub ,
38+ GenSub ,
3839 EscapeCSV ,
3940 EscapeTSV ,
4041 JoinCols ,
@@ -203,6 +204,7 @@ static_map!(
203204 [ "match" , Function :: Match ] ,
204205 [ "sub" , Function :: Sub ] ,
205206 [ "gsub" , Function :: GSub ] ,
207+ [ "gensub" , Function :: GenSub ] ,
206208 [ "substr" , Function :: Substr ] ,
207209 [ "int" , Function :: ToInt ] ,
208210 [ "hex" , Function :: HexToInt ] ,
@@ -298,6 +300,7 @@ impl Function {
298300 ctx. nw . add_dep ( v, arr, Constraint :: ValIn ( ( ) ) ) ;
299301 ctx. nw . add_dep ( arr, v, Constraint :: Val ( ( ) ) ) ;
300302 }
303+ // TODO: GenSub?
301304 Function :: Sub | Function :: GSub => {
302305 let out_str = args[ 2 ] ;
303306 let str_const = ctx. constant ( Scalar ( BaseTy :: Str ) . abs ( ) ) ;
@@ -425,6 +428,7 @@ impl Function {
425428 Length => ( smallvec ! [ incoming[ 0 ] ] , Int ) ,
426429 Close => ( smallvec ! [ Str ] , Str ) ,
427430 Sub | GSub => ( smallvec ! [ Str , Str , Str ] , Int ) ,
431+ GenSub => ( smallvec ! [ Str , Str , Str , Str ] , Str ) ,
428432 ToUpper | ToLower | EscapeCSV | EscapeTSV => ( smallvec ! [ Str ] , Str ) ,
429433 Substr => ( smallvec ! [ Str , Int , Int ] , Str ) ,
430434 Match => ( smallvec ! [ Str , Str ] , Int ) ,
@@ -456,6 +460,7 @@ impl Function {
456460 SetFI | SubstrIndex | Match | Setcol | Binop ( _) => 2 ,
457461 JoinCSV | JoinTSV | Delete | Contains => 2 ,
458462 IncMap | JoinCols | Substr | Sub | GSub | Split => 3 ,
463+ GenSub => 4 ,
459464 } )
460465 }
461466
@@ -493,7 +498,7 @@ impl Function {
493498 | ReadErrCmd | ReadErrStdin | Contains | Delete | Match | Sub | GSub | ToInt
494499 | System | HexToInt => Ok ( Scalar ( BaseTy :: Int ) . abs ( ) ) ,
495500 ToUpper | ToLower | JoinCSV | JoinTSV | JoinCols | EscapeCSV | EscapeTSV | Substr
496- | Unop ( Column ) | Binop ( Concat ) | Nextline | NextlineCmd | NextlineStdin => {
501+ | Unop ( Column ) | Binop ( Concat ) | Nextline | NextlineCmd | NextlineStdin | GenSub => {
497502 Ok ( Scalar ( BaseTy :: Str ) . abs ( ) )
498503 }
499504 IncMap => Ok ( step_arith ( & types:: val_of ( & args[ 0 ] ) ?, & args[ 2 ] ) ) ,
0 commit comments