| 165 | } |
| 166 | |
| 167 | absl::Status AddFloatingPointDecls(TypeCheckerBuilder& builder) { |
| 168 | // Rounding |
| 169 | CEL_ASSIGN_OR_RETURN( |
| 170 | auto ceil_decl, |
| 171 | MakeFunctionDecl( |
| 172 | "math.ceil", |
| 173 | MakeOverloadDecl("math_ceil_double", DoubleType(), DoubleType()))); |
| 174 | |
| 175 | CEL_ASSIGN_OR_RETURN( |
| 176 | auto floor_decl, |
| 177 | MakeFunctionDecl( |
| 178 | "math.floor", |
| 179 | MakeOverloadDecl("math_floor_double", DoubleType(), DoubleType()))); |
| 180 | |
| 181 | CEL_ASSIGN_OR_RETURN( |
| 182 | auto round_decl, |
| 183 | MakeFunctionDecl( |
| 184 | "math.round", |
| 185 | MakeOverloadDecl("math_round_double", DoubleType(), DoubleType()))); |
| 186 | CEL_ASSIGN_OR_RETURN( |
| 187 | auto trunc_decl, |
| 188 | MakeFunctionDecl( |
| 189 | "math.trunc", |
| 190 | MakeOverloadDecl("math_trunc_double", DoubleType(), DoubleType()))); |
| 191 | |
| 192 | // FP helpers |
| 193 | CEL_ASSIGN_OR_RETURN( |
| 194 | auto is_inf_decl, |
| 195 | MakeFunctionDecl( |
| 196 | "math.isInf", |
| 197 | MakeOverloadDecl("math_isInf_double", BoolType(), DoubleType()))); |
| 198 | |
| 199 | CEL_ASSIGN_OR_RETURN( |
| 200 | auto is_nan_decl, |
| 201 | MakeFunctionDecl( |
| 202 | "math.isNaN", |
| 203 | MakeOverloadDecl("math_isNaN_double", BoolType(), DoubleType()))); |
| 204 | |
| 205 | CEL_ASSIGN_OR_RETURN( |
| 206 | auto is_finite_decl, |
| 207 | MakeFunctionDecl( |
| 208 | "math.isFinite", |
| 209 | MakeOverloadDecl("math_isFinite_double", BoolType(), DoubleType()))); |
| 210 | |
| 211 | CEL_RETURN_IF_ERROR(builder.AddFunction(ceil_decl)); |
| 212 | CEL_RETURN_IF_ERROR(builder.AddFunction(floor_decl)); |
| 213 | CEL_RETURN_IF_ERROR(builder.AddFunction(round_decl)); |
| 214 | CEL_RETURN_IF_ERROR(builder.AddFunction(trunc_decl)); |
| 215 | CEL_RETURN_IF_ERROR(builder.AddFunction(is_inf_decl)); |
| 216 | CEL_RETURN_IF_ERROR(builder.AddFunction(is_nan_decl)); |
| 217 | CEL_RETURN_IF_ERROR(builder.AddFunction(is_finite_decl)); |
| 218 | |
| 219 | return absl::OkStatus(); |
| 220 | } |
| 221 | |
| 222 | absl::Status AddBitwiseDecls(TypeCheckerBuilder& builder) { |
| 223 | const Type kBitwiseTypes[] = {IntType(), UintType()}; |
no test coverage detected