mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
parsing of new []-style captures, and creation of associated data structures
This commit is contained in:
parent
f673f85acc
commit
955384291d
3 changed files with 107 additions and 13 deletions
26
src/Type.h
26
src/Type.h
|
@ -10,6 +10,7 @@
|
|||
#include <optional>
|
||||
|
||||
#include "zeek/Obj.h"
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/Attr.h"
|
||||
#include "zeek/ZeekList.h"
|
||||
#include "zeek/IntrusivePtr.h"
|
||||
|
@ -540,6 +541,29 @@ public:
|
|||
const std::vector<Prototype>& Prototypes() const
|
||||
{ return prototypes; }
|
||||
|
||||
/**
|
||||
* A single lambda "capture" (outer variable used in a lambda's body).
|
||||
*/
|
||||
struct Capture {
|
||||
detail::IDPtr id;
|
||||
bool deep_copy;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets this function's set of captures. Only valid for lambdas.
|
||||
*
|
||||
* @param captures if non-nil, a list of the lambda's captures
|
||||
*/
|
||||
void SetCaptures(std::vector<Capture*>* captures);
|
||||
|
||||
/**
|
||||
* Returns the captures declared for this function, or nil if none.
|
||||
*
|
||||
* @return a vector giving the captures
|
||||
*/
|
||||
const std::vector<Capture*>* GetCaptures() const
|
||||
{ return captures; }
|
||||
|
||||
protected:
|
||||
friend FuncTypePtr make_intrusive<FuncType>();
|
||||
|
||||
|
@ -549,6 +573,8 @@ protected:
|
|||
TypePtr yield;
|
||||
FunctionFlavor flavor;
|
||||
std::vector<Prototype> prototypes;
|
||||
|
||||
std::vector<Capture*>* captures; // if nil then no captures specified
|
||||
};
|
||||
|
||||
class TypeType final : public Type {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue