mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
factor out record coercion; modernize management of coercion "map"
This commit is contained in:
parent
5f5ba3881c
commit
91c2e05099
3 changed files with 27 additions and 24 deletions
|
@ -1170,21 +1170,24 @@ protected:
|
|||
class RecordCoerceExpr final : public UnaryExpr {
|
||||
public:
|
||||
RecordCoerceExpr(ExprPtr op, RecordTypePtr r);
|
||||
~RecordCoerceExpr() override;
|
||||
|
||||
// Optimization-related:
|
||||
ExprPtr Duplicate() override;
|
||||
|
||||
const std::vector<int>& Map() const { return map; }
|
||||
|
||||
protected:
|
||||
ValPtr InitVal(const zeek::Type* t, ValPtr aggr) const override;
|
||||
ValPtr Fold(Val* v) const override;
|
||||
|
||||
// For each super-record slot, gives subrecord slot with which to
|
||||
// fill it.
|
||||
int* map;
|
||||
int map_size; // equivalent to Type()->AsRecordType()->NumFields()
|
||||
std::vector<int> map;
|
||||
};
|
||||
|
||||
extern RecordValPtr coerce_to_record(RecordTypePtr rt, Val* v,
|
||||
const std::vector<int>& map);
|
||||
|
||||
class TableCoerceExpr final : public UnaryExpr {
|
||||
public:
|
||||
TableCoerceExpr(ExprPtr op, TableTypePtr r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue