MCPcopy Create free account
hub / github.com/bytedance/bolt / flattenInput

Function flattenInput

bolt/expression/ExprCompiler.cpp:164–175  ·  view source on GitHub ↗

Recursively flattens nested ANDs, ORs or eligible callable expressions into a vector of their inputs. Recursive flattening ceases exploring an input branch if it encounters either an expression different from 'flattenCall' or its inputs are not the same type. Examples: flattenCall: AND in: a AND (b AND (c AND d)) out: [a, b, c, d] flattenCall: OR in: (a OR b) OR (c OR d) out: [a, b, c, d] flatte

Source from the content-addressed store, hash-verified

162// in: (array1, concat(array2, concat(array2, intVal))
163// out: [array1, array2, concat(array2, intVal)]
164void flattenInput(
165 const TypedExprPtr& input,
166 const std::string& flattenCall,
167 std::vector<TypedExprPtr>& flat) {
168 if (isCall(input, flattenCall) && allInputTypesEquivalent(input)) {
169 for (auto& child : input->inputs()) {
170 flattenInput(child, flattenCall, flat);
171 }
172 } else {
173 flat.emplace_back(input);
174 }
175}
176
177ExprPtr getAlreadyCompiled(const ITypedExpr* expr, ExprDedupMap* visited) {
178 auto iter = visited->find(expr);

Callers 1

compileInputsFunction · 0.85

Calls 2

isCallFunction · 0.85
allInputTypesEquivalentFunction · 0.85

Tested by

no test coverage detected