souffle  2.0.2-371-g6315b36
ExecutionOrder.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 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 ExecutionOrder.h
12  *
13  * Defines the execution order class
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/Node.h"
20 #include "parser/SrcLocation.h"
22 #include <ostream>
23 #include <string>
24 #include <utility>
25 #include <vector>
26 
27 namespace souffle::ast {
28 
29 /**
30  * @class ExecutionOrder
31  * @brief An execution order for atoms within a clause;
32  * one or more execution orders form a plan.
33  */
34 class ExecutionOrder : public Node {
35 public:
36  using ExecOrder = std::vector<unsigned int>;
37 
38  ExecutionOrder(ExecOrder order = {}, SrcLocation loc = {}) : order(std::move(order)) {
39  setSrcLoc(std::move(loc));
40  }
41 
42  /** Get order */
43  const ExecOrder& getOrder() const {
44  return order;
45  }
46 
47  ExecutionOrder* clone() const override {
48  return new ExecutionOrder(order, getSrcLoc());
49  }
50 
51 protected:
52  void print(std::ostream& out) const override {
53  out << "(" << join(order) << ")";
54  }
55 
56  bool equal(const Node& node) const override {
57  const auto& other = static_cast<const ExecutionOrder&>(node);
58  return order == other.order;
59  }
60 
61 private:
62  /** Literal order of body (starting from 1) */
64 };
65 
66 } // namespace souffle::ast
souffle::ast::ExecutionOrder
An execution order for atoms within a clause; one or more execution orders form a plan.
Definition: ExecutionOrder.h:40
souffle::ast::ExecutionOrder::equal
bool equal(const Node &node) const override
Abstract equality check for two AST nodes.
Definition: ExecutionOrder.h:62
SrcLocation.h
souffle::ast::ExecutionOrder::ExecOrder
std::vector< unsigned int > ExecOrder
Definition: ExecutionOrder.h:42
souffle::join
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
Definition: StreamUtil.h:175
souffle::ast::ExecutionOrder::ExecutionOrder
ExecutionOrder(ExecOrder order={}, SrcLocation loc={})
Definition: ExecutionOrder.h:44
Node.h
souffle::ast::ExecutionOrder::clone
ExecutionOrder * clone() const override
Create a clone (i.e.
Definition: ExecutionOrder.h:53
souffle::ast::ExecutionOrder::getOrder
const ExecOrder & getOrder() const
Get order.
Definition: ExecutionOrder.h:49
souffle::ast::Node
Abstract class for syntactic elements in an input program.
Definition: Node.h:40
souffle::ast::Node::setSrcLoc
void setSrcLoc(SrcLocation l)
Set source location for the Node.
Definition: Node.h:51
StreamUtil.h
souffle::ast::ExecutionOrder::print
void print(std::ostream &out) const override
Output to a given output stream.
Definition: ExecutionOrder.h:58
souffle::ast::Node::getSrcLoc
const SrcLocation & getSrcLoc() const
Return source location of the Node.
Definition: Node.h:46
souffle::ast
Definition: Aggregator.h:35
souffle::ast::ExecutionOrder::order
ExecOrder order
Literal order of body (starting from 1)
Definition: ExecutionOrder.h:69