mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Merge remote-tracking branch 'origin/topic/vern/cpp-maint-dec21'
* origin/topic/vern/cpp-maint-dec21: fixes for vector operations flag globals initialized to opaque values as non-compilable skip type signatures for lambdas fix for translating filenames beginning with numbers to C++ variable names remove unnecessary includes
This commit is contained in:
commit
56b421db9f
10 changed files with 47 additions and 31 deletions
10
CHANGES
10
CHANGES
|
@ -1,3 +1,13 @@
|
||||||
|
4.2.0-dev.442 | 2021-12-10 13:12:43 -0700
|
||||||
|
|
||||||
|
* fixes for vector operations (Vern Paxson, Corelight)
|
||||||
|
|
||||||
|
* flag globals initialized to opaque values as non-compilable (Vern Paxson, Corelight)
|
||||||
|
|
||||||
|
* skip type signatures for lambdas (Vern Paxson, Corelight)
|
||||||
|
|
||||||
|
* fix for translating filenames beginning with numbers to C++ variable names (Vern Paxson, Corelight)
|
||||||
|
|
||||||
4.2.0-dev.436 | 2021-12-10 13:11:36 -0700
|
4.2.0-dev.436 | 2021-12-10 13:11:36 -0700
|
||||||
|
|
||||||
* update script-to-C++ compilation for new record constructor internals (Vern Paxson, Corelight)
|
* update script-to-C++ compilation for new record constructor internals (Vern Paxson, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.2.0-dev.436
|
4.2.0-dev.442
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "zeek/script_opt/CPP/Compile.h"
|
#include "zeek/script_opt/CPP/Compile.h"
|
||||||
|
|
||||||
namespace zeek::detail
|
namespace zeek::detail
|
||||||
|
@ -73,7 +69,7 @@ void CPPCompile::CreateFunction(const FuncTypePtr& ft, const ProfileFunc* pf, co
|
||||||
|
|
||||||
func_index[fname] = cast;
|
func_index[fname] = cast;
|
||||||
|
|
||||||
if ( casting_index.count(cast) == 0 )
|
if ( ! l && casting_index.count(cast) == 0 )
|
||||||
{
|
{
|
||||||
casting_index[cast] = func_casting_glue.size();
|
casting_index[cast] = func_casting_glue.size();
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "zeek/script_opt/CPP/Compile.h"
|
#include "zeek/script_opt/CPP/Compile.h"
|
||||||
|
|
||||||
namespace zeek::detail
|
namespace zeek::detail
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "zeek/RE.h"
|
#include "zeek/RE.h"
|
||||||
#include "zeek/script_opt/CPP/Compile.h"
|
#include "zeek/script_opt/CPP/Compile.h"
|
||||||
#include "zeek/script_opt/ProfileFunc.h"
|
#include "zeek/script_opt/ProfileFunc.h"
|
||||||
|
@ -607,7 +603,7 @@ string CPPCompile::GenArithCoerceExpr(const Expr* e, GenType gt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_vec )
|
if ( is_vec )
|
||||||
return string("vec_coerce_") + cast_name + "__CPP(" + GenExpr(op, GEN_NATIVE) + ", " +
|
return string("vec_coerce_to_") + cast_name + "__CPP(" + GenExpr(op, GEN_NATIVE) + ", " +
|
||||||
GenTypeName(t) + ")";
|
GenTypeName(t) + ")";
|
||||||
|
|
||||||
return NativeToGT(cast_name + "(" + GenExpr(op, GEN_NATIVE) + ")", t, gt);
|
return NativeToGT(cast_name + "(" + GenExpr(op, GEN_NATIVE) + ")", t, gt);
|
||||||
|
@ -810,7 +806,7 @@ string CPPCompile::GenBinary(const Expr* e, GenType gt, const char* op, const ch
|
||||||
|
|
||||||
if ( t->Tag() == TYPE_VECTOR && t->Yield()->Tag() == TYPE_STRING &&
|
if ( t->Tag() == TYPE_VECTOR && t->Yield()->Tag() == TYPE_STRING &&
|
||||||
op2->GetType()->Tag() == TYPE_VECTOR )
|
op2->GetType()->Tag() == TYPE_VECTOR )
|
||||||
return string("vec_str_op_") + vec_op + "__CPP(" + gen1 + ", " + gen2 + ")";
|
return string("str_vec_op_") + vec_op + "__CPP(" + gen1 + ", " + gen2 + ")";
|
||||||
|
|
||||||
return GenVectorOp(e, gen1, gen2, vec_op);
|
return GenVectorOp(e, gen1, gen2, vec_op);
|
||||||
}
|
}
|
||||||
|
@ -1129,9 +1125,21 @@ string CPPCompile::GenVectorOp(const Expr* e, string op, const char* vec_op)
|
||||||
|
|
||||||
string CPPCompile::GenVectorOp(const Expr* e, string op1, string op2, const char* vec_op)
|
string CPPCompile::GenVectorOp(const Expr* e, string op1, string op2, const char* vec_op)
|
||||||
{
|
{
|
||||||
|
auto& op1_t = e->GetOp1()->GetType();
|
||||||
|
auto& op2_t = e->GetOp2()->GetType();
|
||||||
|
|
||||||
|
if ( op1_t->Tag() != TYPE_VECTOR || op2_t->Tag() != TYPE_VECTOR )
|
||||||
|
{
|
||||||
|
// This is a deprecated mixed-scalar-and-vector operation.
|
||||||
|
// We don't support these. Arrange for linking errors.
|
||||||
|
reporter->Error(
|
||||||
|
"C++ generation does not support deprecated scalar-mixed-with-vector operations");
|
||||||
|
return "vec_scalar_mixed_with_vector()";
|
||||||
|
}
|
||||||
|
|
||||||
auto invoke = string(vec_op) + "__CPP(" + op1 + ", " + op2 + ")";
|
auto invoke = string(vec_op) + "__CPP(" + op1 + ", " + op2 + ")";
|
||||||
|
|
||||||
if ( e->GetOp1()->GetType()->Yield()->Tag() == TYPE_STRING )
|
if ( op2_t->Yield()->Tag() == TYPE_STRING )
|
||||||
return string("str_vec_op_") + invoke;
|
return string("str_vec_op_") + invoke;
|
||||||
|
|
||||||
auto gen = string("vec_op_") + invoke;
|
auto gen = string("vec_op_") + invoke;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "zeek/script_opt/CPP/Compile.h"
|
#include "zeek/script_opt/CPP/Compile.h"
|
||||||
|
|
||||||
namespace zeek::detail
|
namespace zeek::detail
|
||||||
|
@ -210,6 +206,10 @@ string CPPCompile::BodyName(const FuncInfo& func)
|
||||||
string fns = fn;
|
string fns = fn;
|
||||||
transform(fns.begin(), fns.end(), fns.begin(), canonicalize);
|
transform(fns.begin(), fns.end(), fns.begin(), canonicalize);
|
||||||
|
|
||||||
|
if ( ! isalpha(fns[0]) )
|
||||||
|
// This can happen for filenames beginning with numbers.
|
||||||
|
fns = "_" + fns;
|
||||||
|
|
||||||
fname = fns + "__" + fname;
|
fname = fns + "__" + fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "zeek/module_util.h"
|
#include "zeek/module_util.h"
|
||||||
#include "zeek/script_opt/CPP/Compile.h"
|
#include "zeek/script_opt/CPP/Compile.h"
|
||||||
#include "zeek/script_opt/IDOptInfo.h"
|
#include "zeek/script_opt/IDOptInfo.h"
|
||||||
|
|
|
@ -323,7 +323,8 @@ GlobalInitInfo::GlobalInitInfo(CPPCompile* c, const ID* g, string _CPP_name)
|
||||||
{
|
{
|
||||||
Zeek_name = g->Name();
|
Zeek_name = g->Name();
|
||||||
|
|
||||||
auto gi = c->RegisterType(g->GetType());
|
auto& gt = g->GetType();
|
||||||
|
auto gi = c->RegisterType(gt);
|
||||||
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
||||||
type = gi->Offset();
|
type = gi->Offset();
|
||||||
|
|
||||||
|
@ -338,7 +339,15 @@ GlobalInitInfo::GlobalInitInfo(CPPCompile* c, const ID* g, string _CPP_name)
|
||||||
|
|
||||||
exported = g->IsExport();
|
exported = g->IsExport();
|
||||||
|
|
||||||
val = ValElem(c, g->GetVal());
|
auto v = g->GetVal();
|
||||||
|
if ( v && gt->Tag() == TYPE_OPAQUE )
|
||||||
|
{
|
||||||
|
reporter->Error("cannot compile to C++ global \"%s\" initialized to opaque value",
|
||||||
|
g->Name());
|
||||||
|
v = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = ValElem(c, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalInitInfo::InitializerVals(std::vector<std::string>& ivs) const
|
void GlobalInitInfo::InitializerVals(std::vector<std::string>& ivs) const
|
||||||
|
|
|
@ -80,4 +80,9 @@ extern VectorValPtr vec_coerce_to_bro_int_t__CPP(const VectorValPtr& v, TypePtr
|
||||||
extern VectorValPtr vec_coerce_to_bro_uint_t__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_bro_uint_t__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
|
|
||||||
|
// A dummy function used during code generation for unsupported operations
|
||||||
|
// that mix vector and scalar arguments. We don't define it in RuntimeVec.cc
|
||||||
|
// so that it'll generate a linking error.
|
||||||
|
extern VectorValPtr vec_scalar_mixed_with_vector();
|
||||||
|
|
||||||
} // namespace zeek::detail
|
} // namespace zeek::detail
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "zeek/script_opt/CPP/Compile.h"
|
#include "zeek/script_opt/CPP/Compile.h"
|
||||||
#include "zeek/script_opt/ProfileFunc.h"
|
#include "zeek/script_opt/ProfileFunc.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue