Spicy
hilti
toolchain
include
ast
expressions
assign.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/expression.h>
9
#include <hilti/ast/type.h>
10
11
namespace
hilti::expression {
12
14
class
Assign
:
public
Expression
{
15
public
:
16
auto
target()
const
{
return
child<Expression>(0); }
17
auto
source()
const
{
return
child<Expression>(1); }
18
19
QualifiedType
*
type
() const final {
return
target()->type(); }
20
21
void
setSource(
ASTContext
* ctx,
Expression
* src) {
setChild
(ctx, 1, src); }
22
29
Expression
*
removeSource
() {
return
clearChild
(1)->
as
<
Expression
>(); }
30
31
static
auto
create(
ASTContext
* ctx,
Expression
* target,
Expression
* src,
Meta
meta
= {}) {
32
return
ctx->
make
<Assign>(ctx, {target, src}, std::move(
meta
));
33
}
34
35
protected
:
36
Assign(ASTContext* ctx, Nodes
children
, Meta
meta
)
37
: Expression(ctx, NodeTags, std::move(
children
), std::move(
meta
)) {}
38
39
HILTI_NODE_1(expression::Assign, Expression,
final
);
40
};
41
42
}
// namespace hilti::expression
hilti::ASTContext
Definition:
ast-context.h:128
hilti::ASTContext::make
T * make(Args &&... args)
Definition:
ast-context.h:382
hilti::Expression
Definition:
expression.h:15
hilti::Meta
Definition:
meta.h:30
hilti::Node::clearChild
Node * clearChild(int i)
Definition:
node.h:662
hilti::Node::as
T * as() const
Definition:
node.h:733
hilti::Node::setChild
void setChild(ASTContext *ctx, size_t idx, Node *n)
Definition:
node.h:631
hilti::Node::children
const auto & children() const
Definition:
node.h:382
hilti::Node::meta
const auto & meta() const
Definition:
node.h:324
hilti::QualifiedType
Definition:
type.h:365
hilti::expression::Assign
Definition:
assign.h:14
hilti::expression::Assign::type
QualifiedType * type() const final
Definition:
assign.h:19
hilti::expression::Assign::removeSource
Expression * removeSource()
Definition:
assign.h:29
Generated by
1.9.1