@@ -24,7 +24,7 @@ use std::fmt;
2424
2525use galileo:: expr:: {
2626 ControlPoint , CubicBezierInterpolation , ExponentialInterpolation , Expr , ExprGeometryType ,
27- ExprValue , LinearInterpolation , MatchCase , MatchExpr ,
27+ ExprValue , LinearInterpolation , MatchCase , MatchExpr , SelectCase , SelectExpr ,
2828} ;
2929use serde:: de:: { self , SeqAccess , Visitor } ;
3030use serde:: { Deserialize , Deserializer , Serialize } ;
@@ -883,6 +883,35 @@ impl MlExpr {
883883 . collect :: < Option < Vec < _ > > > ( ) ?,
884884 fallback : fallback. to_galileo_expr ( ) ?,
885885 } ) ) ,
886+ MlExpr :: Step {
887+ input,
888+ default_output,
889+ stops,
890+ } => {
891+ let last_stop = stops. iter ( ) . last ( ) ?;
892+ let mut cases = vec ! [ ] ;
893+ let boxed_input = Box :: new ( input. to_galileo_expr ( ) ?) ;
894+
895+ let mut prev_out = default_output. to_galileo_expr ( ) ?;
896+ for stop in stops {
897+ cases. push ( SelectCase {
898+ condition : Expr :: Lte ( boxed_input. clone ( ) , Box :: new ( stop. 0 . into ( ) ) ) ,
899+ out : prev_out,
900+ } ) ;
901+
902+ prev_out = stop. 1 . to_galileo_expr ( ) ?;
903+ }
904+
905+ cases. push ( SelectCase {
906+ condition : Expr :: Gte ( boxed_input. clone ( ) , Box :: new ( last_stop. 0 . into ( ) ) ) ,
907+ out : prev_out,
908+ } ) ;
909+
910+ Expr :: Select ( Box :: new ( SelectExpr {
911+ cases,
912+ fallback : default_output. to_galileo_expr ( ) ?,
913+ } ) )
914+ }
886915 _ => {
887916 log:: debug!( "{UNSUPPORTED} Expression {self:?} is not supported yet" ) ;
888917 return None ;
0 commit comments