mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
fixes for compiling function calls that return non-error nil ValPtr's
This commit is contained in:
parent
b6bff8aa37
commit
5480dc8869
2 changed files with 7 additions and 1 deletions
|
@ -351,7 +351,7 @@ string CPPCompile::GenCallExpr(const CallExpr* c, GenType gt, bool top_level)
|
||||||
|
|
||||||
if ( is_async )
|
if ( is_async )
|
||||||
invoke_func = "when_invoke__CPP";
|
invoke_func = "when_invoke__CPP";
|
||||||
else if ( t->Tag() == TYPE_VOID )
|
else if ( top_level || t->Tag() == TYPE_VOID )
|
||||||
{
|
{
|
||||||
ASSERT(top_level);
|
ASSERT(top_level);
|
||||||
invoke_func = "invoke_void__CPP";
|
invoke_func = "invoke_void__CPP";
|
||||||
|
|
|
@ -444,10 +444,16 @@ void CPPCompile::GenWhenStmt(const WhenStmt* w)
|
||||||
|
|
||||||
if ( ret_type && ret_type->Tag() != TYPE_VOID )
|
if ( ret_type && ret_type->Tag() != TYPE_VOID )
|
||||||
{
|
{
|
||||||
|
// Note, ret_type can be active but we *still* don't have
|
||||||
|
// a return type, due to the faked-up "any" return type
|
||||||
|
// associated with "when" lambdas, so check for that case.
|
||||||
|
Emit("if ( curr_t )");
|
||||||
|
StartBlock();
|
||||||
Emit("ValPtr retval = {NewRef{}, curr_t->Lookup(curr_assoc)};");
|
Emit("ValPtr retval = {NewRef{}, curr_t->Lookup(curr_assoc)};");
|
||||||
Emit("if ( ! retval )");
|
Emit("if ( ! retval )");
|
||||||
Emit("\tthrow CPPDelayedCallException();");
|
Emit("\tthrow CPPDelayedCallException();");
|
||||||
Emit("return %s;", GenericValPtrToGT("retval", ret_type, GEN_NATIVE));
|
Emit("return %s;", GenericValPtrToGT("retval", ret_type, GEN_NATIVE));
|
||||||
|
EndBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
Emit("}");
|
Emit("}");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue