souffle  2.0.2-371-g6315b36
Sequence.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file Sequence.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/ListStatement.h"
18 #include "ram/Statement.h"
20 #include <memory>
21 #include <ostream>
22 #include <utility>
23 #include <vector>
24 
25 namespace souffle::ram {
26 
27 /**
28  * @class Sequence
29  * @brief Sequence of RAM statements
30  *
31  * Execute statement one by one from an ordered list of statements.
32  */
33 class Sequence : public ListStatement {
34 public:
35  Sequence(VecOwn<Statement> statements) : ListStatement(std::move(statements)) {}
36  Sequence() : ListStatement() {}
37  template <typename... Stmts>
38  Sequence(Own<Statement> first, Own<Stmts>... rest)
39  : ListStatement(std::move(first), std::move(rest)...) {}
40 
41  Sequence* clone() const override {
42  auto* res = new Sequence();
43  for (auto& cur : statements) {
44  res->statements.push_back(souffle::clone(cur));
45  }
46  return res;
47  }
48 
49 protected:
50  void print(std::ostream& os, int tabpos) const override {
51  for (const auto& stmt : statements) {
52  Statement::print(stmt.get(), os, tabpos);
53  }
54  }
55 };
56 
57 } // namespace souffle::ram
souffle::Own
std::unique_ptr< A > Own
Definition: ContainerUtil.h:42
souffle::ram::ListStatement::ListStatement
ListStatement()=default
ListStatement.h
MiscUtil.h
souffle::ram::Sequence::Sequence
Sequence()
Definition: Sequence.h:40
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::ListStatement::statements
VecOwn< Statement > statements
Ordered list of RAM statements.
Definition: ListStatement.h:77
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
souffle::ram::Sequence::Sequence
Sequence(Own< Statement > first, Own< Stmts >... rest)
Definition: Sequence.h:42
souffle::ram::Statement::print
void print(std::ostream &os) const override
Print RAM node.
Definition: Statement.h:42
std
Definition: Brie.h:3053
Statement.h
souffle::ram::ListStatement
Abstract class for a list of RAM statements.
Definition: ListStatement.h:36
souffle::ram::Sequence::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: Sequence.h:54
souffle::ram::Sequence::clone
Sequence * clone() const override
Create a clone (i.e.
Definition: Sequence.h:45
souffle::ram::Sequence
Sequence of RAM statements.
Definition: Sequence.h:37