fixes for compiling lambdas to C++

This commit is contained in:
Vern Paxson 2023-08-16 17:03:37 -07:00
parent 4991693a9c
commit 6af0014a7b
3 changed files with 9 additions and 2 deletions

View file

@ -77,8 +77,9 @@ void CPPCompile::Compile(bool report_uncompilable)
continue; continue;
} }
if ( is_when_lambda(f) ) if ( is_lambda(f) || is_when_lambda(f) )
{ {
// We deal with these separately.
func.SetSkip(true); func.SetSkip(true);
continue; continue;
} }

View file

@ -58,6 +58,11 @@ void analyze_when_lambda(LambdaExpr* l)
when_lambdas.insert(l->PrimaryFunc().get()); when_lambdas.insert(l->PrimaryFunc().get());
} }
bool is_lambda(const ScriptFunc* f)
{
return lambdas.count(f) > 0;
}
bool is_when_lambda(const ScriptFunc* f) bool is_when_lambda(const ScriptFunc* f)
{ {
return when_lambdas.count(f) > 0; return when_lambdas.count(f) > 0;

View file

@ -174,7 +174,8 @@ extern void analyze_lambda(LambdaExpr* f);
// has already been called. // has already been called.
extern void analyze_when_lambda(LambdaExpr* f); 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); extern bool is_when_lambda(const ScriptFunc* f);
// Analyze the given top-level statement(s) for optimization. Returns // Analyze the given top-level statement(s) for optimization. Returns