From 6af0014a7b4aa4db4c085a73581a8d8e20ffc3f5 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Wed, 16 Aug 2023 17:03:37 -0700 Subject: [PATCH] fixes for compiling lambdas to C++ --- src/script_opt/CPP/Driver.cc | 3 ++- src/script_opt/ScriptOpt.cc | 5 +++++ src/script_opt/ScriptOpt.h | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/script_opt/CPP/Driver.cc b/src/script_opt/CPP/Driver.cc index a93b0f603b..2cecb4923c 100644 --- a/src/script_opt/CPP/Driver.cc +++ b/src/script_opt/CPP/Driver.cc @@ -77,8 +77,9 @@ void CPPCompile::Compile(bool report_uncompilable) continue; } - if ( is_when_lambda(f) ) + if ( is_lambda(f) || is_when_lambda(f) ) { + // We deal with these separately. func.SetSkip(true); continue; } diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index f01ae2db1f..1b085a9dc2 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -58,6 +58,11 @@ void analyze_when_lambda(LambdaExpr* l) when_lambdas.insert(l->PrimaryFunc().get()); } +bool is_lambda(const ScriptFunc* f) + { + return lambdas.count(f) > 0; + } + bool is_when_lambda(const ScriptFunc* f) { return when_lambdas.count(f) > 0; diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index 0e8e0ed09f..1a6145f243 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -174,7 +174,8 @@ extern void analyze_lambda(LambdaExpr* f); // has already been called. extern void analyze_when_lambda(LambdaExpr* f); -// Whether a given script function is a "when" lambda. +// Whether a given script function is a lambda or (separately) a "when" lambda. +extern bool is_lambda(const ScriptFunc* f); extern bool is_when_lambda(const ScriptFunc* f); // Analyze the given top-level statement(s) for optimization. Returns