MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / AddArithmeticOps

Function AddArithmeticOps

checker/standard_library.cc:125–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125absl::Status AddArithmeticOps(TypeCheckerBuilder& builder) {
126 FunctionDecl add_op;
127 add_op.set_name(StandardFunctions::kAdd);
128 CEL_RETURN_IF_ERROR(add_op.AddOverload(MakeOverloadDecl(
129 StandardOverloadIds::kAddInt, IntType(), IntType(), IntType())));
130 CEL_RETURN_IF_ERROR(add_op.AddOverload(
131 MakeOverloadDecl(StandardOverloadIds::kAddDouble, DoubleType(),
132 DoubleType(), DoubleType())));
133 CEL_RETURN_IF_ERROR(add_op.AddOverload(MakeOverloadDecl(
134 StandardOverloadIds::kAddUint, UintType(), UintType(), UintType())));
135 // timestamp math
136 CEL_RETURN_IF_ERROR(add_op.AddOverload(
137 MakeOverloadDecl(StandardOverloadIds::kAddDurationDuration,
138 DurationType(), DurationType(), DurationType())));
139 CEL_RETURN_IF_ERROR(add_op.AddOverload(
140 MakeOverloadDecl(StandardOverloadIds::kAddDurationTimestamp,
141 TimestampType(), DurationType(), TimestampType())));
142 CEL_RETURN_IF_ERROR(add_op.AddOverload(
143 MakeOverloadDecl(StandardOverloadIds::kAddTimestampDuration,
144 TimestampType(), TimestampType(), DurationType())));
145 // string concat
146 CEL_RETURN_IF_ERROR(add_op.AddOverload(MakeOverloadDecl(
147 StandardOverloadIds::kAddBytes, BytesType(), BytesType(), BytesType())));
148 CEL_RETURN_IF_ERROR(add_op.AddOverload(
149 MakeOverloadDecl(StandardOverloadIds::kAddString, StringType(),
150 StringType(), StringType())));
151 // list concat
152 CEL_RETURN_IF_ERROR(add_op.AddOverload(MakeOverloadDecl(
153 StandardOverloadIds::kAddList, ListOfA(), ListOfA(), ListOfA())));
154
155 CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(add_op)));
156
157 FunctionDecl subtract_op;
158 subtract_op.set_name(StandardFunctions::kSubtract);
159 CEL_RETURN_IF_ERROR(subtract_op.AddOverload(MakeOverloadDecl(
160 StandardOverloadIds::kSubtractInt, IntType(), IntType(), IntType())));
161 CEL_RETURN_IF_ERROR(subtract_op.AddOverload(MakeOverloadDecl(
162 StandardOverloadIds::kSubtractUint, UintType(), UintType(), UintType())));
163 CEL_RETURN_IF_ERROR(subtract_op.AddOverload(
164 MakeOverloadDecl(StandardOverloadIds::kSubtractDouble, DoubleType(),
165 DoubleType(), DoubleType())));
166 // Timestamp math
167 CEL_RETURN_IF_ERROR(subtract_op.AddOverload(
168 MakeOverloadDecl(StandardOverloadIds::kSubtractDurationDuration,
169 DurationType(), DurationType(), DurationType())));
170 CEL_RETURN_IF_ERROR(subtract_op.AddOverload(
171 MakeOverloadDecl(StandardOverloadIds::kSubtractTimestampDuration,
172 TimestampType(), TimestampType(), DurationType())));
173 CEL_RETURN_IF_ERROR(subtract_op.AddOverload(
174 MakeOverloadDecl(StandardOverloadIds::kSubtractTimestampTimestamp,
175 DurationType(), TimestampType(), TimestampType())));
176
177 CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(subtract_op)));
178
179 FunctionDecl multiply_op;
180 multiply_op.set_name(StandardFunctions::kMultiply);
181 CEL_RETURN_IF_ERROR(multiply_op.AddOverload(MakeOverloadDecl(
182 StandardOverloadIds::kMultiplyInt, IntType(), IntType(), IntType())));

Callers 1

AddStandardLibraryDeclsFunction · 0.85

Calls 12

MakeOverloadDeclFunction · 0.85
ListOfAFunction · 0.85
AddOverloadMethod · 0.80
IntTypeClass · 0.50
DoubleTypeClass · 0.50
UintTypeClass · 0.50
DurationTypeClass · 0.50
TimestampTypeClass · 0.50
BytesTypeClass · 0.50
StringTypeClass · 0.50
set_nameMethod · 0.45
AddFunctionMethod · 0.45

Tested by

no test coverage detected