mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
removing direct instruction references
This commit is contained in:
parent
2f9970dc14
commit
d551d4b9cf
2 changed files with 18 additions and 22 deletions
|
@ -1151,7 +1151,7 @@ const ZAMStmt ZAMCompiler::ConstructTable(const NameExpr* n, const Expr* e) {
|
||||||
auto tt = cast_intrusive<TableType>(n->GetType());
|
auto tt = cast_intrusive<TableType>(n->GetType());
|
||||||
auto width = tt->GetIndices()->GetTypes().size();
|
auto width = tt->GetIndices()->GetTypes().size();
|
||||||
|
|
||||||
auto z = GenInst(OP_CONSTRUCT_TABLE_V, n, width);
|
auto z = GenInst(OP_CONSTRUCT_TABLE_Vi, n, width);
|
||||||
z.aux = InternalBuildVals(con, width + 1);
|
z.aux = InternalBuildVals(con, width + 1);
|
||||||
z.t = tt;
|
z.t = tt;
|
||||||
ASSERT(e->Tag() == EXPR_TABLE_CONSTRUCTOR);
|
ASSERT(e->Tag() == EXPR_TABLE_CONSTRUCTOR);
|
||||||
|
@ -1190,7 +1190,7 @@ const ZAMStmt ZAMCompiler::ConstructSet(const NameExpr* n, const Expr* e) {
|
||||||
auto tt = n->GetType()->AsTableType();
|
auto tt = n->GetType()->AsTableType();
|
||||||
auto width = tt->GetIndices()->GetTypes().size();
|
auto width = tt->GetIndices()->GetTypes().size();
|
||||||
|
|
||||||
auto z = GenInst(OP_CONSTRUCT_SET_V, n, width);
|
auto z = GenInst(OP_CONSTRUCT_SET_Vi, n, width);
|
||||||
z.aux = InternalBuildVals(con, width);
|
z.aux = InternalBuildVals(con, width);
|
||||||
z.t = e->GetType();
|
z.t = e->GetType();
|
||||||
ASSERT(e->Tag() == EXPR_SET_CONSTRUCTOR);
|
ASSERT(e->Tag() == EXPR_SET_CONSTRUCTOR);
|
||||||
|
|
|
@ -256,23 +256,19 @@ macro BuildVal(v, t) ZVal(v, t)
|
||||||
# Returns a memory-managed-if-necessary copy of an existing value.
|
# Returns a memory-managed-if-necessary copy of an existing value.
|
||||||
macro CopyVal(v) (ZVal::IsManagedType(z.t) ? BuildVal((v).ToVal(z.t), z.t) : (v))
|
macro CopyVal(v) (ZVal::IsManagedType(z.t) ? BuildVal((v).ToVal(z.t), z.t) : (v))
|
||||||
|
|
||||||
# Managed assignments to "lhs" (generally, frame[z.v1]).
|
# Managed assignments to the given target.
|
||||||
macro AssignV1T(lhs, v, t) {
|
macro AssignTarget(target, v) {
|
||||||
if ( z.is_managed )
|
if ( z.is_managed )
|
||||||
{
|
{
|
||||||
/* It's important to hold a reference to v here prior
|
/* It's important to hold a reference to v here prior
|
||||||
to the deletion in case lhs points to v. */
|
to the deletion in case target points to v. */
|
||||||
auto v2 = v;
|
auto v2 = v;
|
||||||
ZVal::DeleteManagedType(lhs);
|
ZVal::DeleteManagedType(target);
|
||||||
lhs = v2;
|
target = v2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lhs = v;
|
target = v;
|
||||||
}
|
}
|
||||||
# Convenience macro for when the value of the assigned type comes from
|
|
||||||
# the instruction.
|
|
||||||
macro AssignV1(v) AssignV1T(frame[z.v1], v, z.t)
|
|
||||||
macro AssignTarget(target, v) AssignV1T(target, v, z.t)
|
|
||||||
|
|
||||||
macro BRANCH(target) { DO_ZAM_PROFILE; pc = target; continue; }
|
macro BRANCH(target) { DO_ZAM_PROFILE; pc = target; continue; }
|
||||||
|
|
||||||
|
@ -293,7 +289,7 @@ op-type X
|
||||||
set-type $$
|
set-type $$
|
||||||
set-type2 $1
|
set-type2 $1
|
||||||
eval auto v = $1.ToVal(z.t2)->Clone();
|
eval auto v = $1.ToVal(z.t2)->Clone();
|
||||||
AssignV1(BuildVal(v, z.t))
|
AssignTarget($$, BuildVal(v, z.t))
|
||||||
|
|
||||||
unary-expr-op Size
|
unary-expr-op Size
|
||||||
no-const
|
no-const
|
||||||
|
@ -439,7 +435,7 @@ macro EvalCast(lhs, rhs)
|
||||||
std::string error;
|
std::string error;
|
||||||
auto res = cast_value(rhs, z.t, error);
|
auto res = cast_value(rhs, z.t, error);
|
||||||
if ( res )
|
if ( res )
|
||||||
AssignV1T(lhs, BuildVal(res, z.t), z.t)
|
AssignTarget(lhs, BuildVal(res, z.t))
|
||||||
else
|
else
|
||||||
ZAM_run_time_error(z.loc, error.c_str());
|
ZAM_run_time_error(z.loc, error.c_str());
|
||||||
|
|
||||||
|
@ -1180,12 +1176,12 @@ eval auto lv = $1.any_val->AsListVal();
|
||||||
# using information from their expression specifics.
|
# using information from their expression specifics.
|
||||||
direct-unary-op Table-Constructor ConstructTable
|
direct-unary-op Table-Constructor ConstructTable
|
||||||
|
|
||||||
macro ConstructTableOrSetPre()
|
macro ConstructTableOrSetPre(width)
|
||||||
auto tt = cast_intrusive<TableType>(z.t);
|
auto tt = cast_intrusive<TableType>(z.t);
|
||||||
auto new_t = new TableVal(tt, z.aux->attrs);
|
auto new_t = new TableVal(tt, z.aux->attrs);
|
||||||
auto aux = z.aux;
|
auto aux = z.aux;
|
||||||
auto n = aux->n;
|
auto n = aux->n;
|
||||||
auto ind_width = z.v2;
|
auto ind_width = width;
|
||||||
|
|
||||||
macro ConstructTableOrSetPost(lhs)
|
macro ConstructTableOrSetPost(lhs)
|
||||||
auto& t = lhs.table_val;
|
auto& t = lhs.table_val;
|
||||||
|
@ -1193,8 +1189,8 @@ macro ConstructTableOrSetPost(lhs)
|
||||||
t = new_t;
|
t = new_t;
|
||||||
|
|
||||||
internal-op Construct-Table
|
internal-op Construct-Table
|
||||||
type V
|
type Vi
|
||||||
eval ConstructTableOrSetPre()
|
eval ConstructTableOrSetPre($1)
|
||||||
for ( auto i = 0; i < n; ++i )
|
for ( auto i = 0; i < n; ++i )
|
||||||
{
|
{
|
||||||
auto indices = aux->ToIndices(frame, i, ind_width);
|
auto indices = aux->ToIndices(frame, i, ind_width);
|
||||||
|
@ -1216,8 +1212,8 @@ eval auto& tbl = $1.table_val;
|
||||||
direct-unary-op Set-Constructor ConstructSet
|
direct-unary-op Set-Constructor ConstructSet
|
||||||
|
|
||||||
internal-op Construct-Set
|
internal-op Construct-Set
|
||||||
type V
|
type Vi
|
||||||
eval ConstructTableOrSetPre()
|
eval ConstructTableOrSetPre($1)
|
||||||
for ( auto i = 0; i < n; i += ind_width )
|
for ( auto i = 0; i < n; i += ind_width )
|
||||||
{
|
{
|
||||||
auto indices = aux->ToIndices(frame, i, ind_width);
|
auto indices = aux->ToIndices(frame, i, ind_width);
|
||||||
|
@ -1861,9 +1857,9 @@ eval EvalReturn(&$$, ret_type = z.t;)
|
||||||
|
|
||||||
macro EvalSwitchBody(index, branch, cases, postscript)
|
macro EvalSwitchBody(index, branch, cases, postscript)
|
||||||
{
|
{
|
||||||
auto t = cases[z.v2];
|
auto t = cases[index];
|
||||||
if ( t.find(v) == t.end() )
|
if ( t.find(v) == t.end() )
|
||||||
pc = z.v3;
|
pc = branch;
|
||||||
else
|
else
|
||||||
pc = t[v];
|
pc = t[v];
|
||||||
postscript
|
postscript
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue