Spicy
hilti
toolchain
include
ast
statements
for.h
1
// Copyright (c) 2020-now by the Zeek Project. See LICENSE for details.
2
3
#pragma once
4
5
#include <memory>
6
#include <utility>
7
8
#include <hilti/ast/declarations/local-variable.h>
9
#include <hilti/ast/expression.h>
10
#include <hilti/ast/statement.h>
11
12
namespace
hilti::statement {
13
15
class
For
:
public
Statement
{
16
public
:
17
auto
local()
const
{
return
child<hilti::declaration::LocalVariable>(0); }
18
auto
sequence()
const
{
return
child<::hilti::Expression>(1); }
19
auto
body()
const
{
return
child<hilti::Statement>(2); }
20
21
static
auto
create(
ASTContext
* ctx,
const
hilti::ID
&
id
,
hilti::Expression
* seq,
Statement
* body,
Meta
meta
= {}) {
22
auto
* local = declaration::LocalVariable::create(ctx,
id
,
meta
);
23
return
ctx->
make
<
For
>(ctx, {local, seq, body}, std::move(
meta
));
24
}
25
26
protected
:
27
For
(
ASTContext
* ctx,
Nodes
children
,
Meta
meta
) :
Statement
(ctx, NodeTags, std::move(
children
), std::move(
meta
)) {}
28
29
HILTI_NODE_1(
statement::For
,
Statement
,
final
);
30
};
31
32
}
// namespace hilti::statement
hilti::ASTContext
Definition:
ast-context.h:121
hilti::ASTContext::make
T * make(Args &&... args)
Definition:
ast-context.h:366
hilti::Expression
Definition:
expression.h:15
hilti::ID
Definition:
id.h:15
hilti::Meta
Definition:
meta.h:30
hilti::Node::children
const auto & children() const
Definition:
node.h:364
hilti::Node::meta
const auto & meta() const
Definition:
node.h:306
hilti::Nodes
Definition:
forward.h:758
hilti::Statement
Definition:
statement.h:15
hilti::statement::For
Definition:
for.h:15
Generated by
1.9.1