| 278 | } |
| 279 | |
| 280 | void captureFieldReference( |
| 281 | FieldReference* reference, |
| 282 | const ITypedExpr* fieldAccess, |
| 283 | Scope* const referenceScope) { |
| 284 | auto& field = reference->field(); |
| 285 | for (auto* scope = referenceScope; scope->parent; scope = scope->parent) { |
| 286 | const auto& locals = scope->locals; |
| 287 | auto& capture = scope->capture; |
| 288 | if (std::find(locals.begin(), locals.end(), field) != locals.end() || |
| 289 | std::find(capture.begin(), capture.end(), field) != capture.end()) { |
| 290 | // Return if the field is defined or captured in this scope. |
| 291 | return; |
| 292 | } |
| 293 | scope->addCapture(reference, fieldAccess); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | std::shared_ptr<Expr> compileLambda( |
| 298 | const core::LambdaTypedExpr* lambda, |
no test coverage detected