souffle  2.0.2-371-g6315b36
SubroutineArgument.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 SubroutineArgument.h
12  *
13  * Defines a class for evaluating values in the Relational Algebra Machine
14  *
15  ************************************************************************/
16 
17 #pragma once
18 
19 #include "ram/Expression.h"
20 #include "ram/Node.h"
21 #include <cstdlib>
22 #include <ostream>
23 
24 namespace souffle::ram {
25 
26 /**
27  * @class SubroutineArgument
28  * @brief Access argument of a subroutine
29  *
30  * Arguments are number from zero 0 to n-1
31  * where n is the number of arguments of the
32  * subroutine.
33  */
34 class SubroutineArgument : public Expression {
35 public:
37 
38  /** @brief Get argument */
39  size_t getArgument() const {
40  return number;
41  }
42 
43  SubroutineArgument* clone() const override {
44  return new SubroutineArgument(number);
45  }
46 
47 protected:
48  void print(std::ostream& os) const override {
49  os << "argument(" << number << ")";
50  }
51 
52  bool equal(const Node& node) const override {
53  const auto& other = static_cast<const SubroutineArgument&>(node);
54  return number == other.number;
55  }
56 
57  /** Argument number */
58  const size_t number;
59 };
60 
61 } // namespace souffle::ram
souffle::ram::SubroutineArgument::print
void print(std::ostream &os) const override
Print RAM node.
Definition: SubroutineArgument.h:54
souffle::ram::SubroutineArgument::getArgument
size_t getArgument() const
Get argument.
Definition: SubroutineArgument.h:45
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::SubroutineArgument::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: SubroutineArgument.h:58
souffle::ram::Node
Node is a superclass for all RAM IR classes.
Definition: Node.h:42
Node.h
souffle::ram::SubroutineArgument::SubroutineArgument
SubroutineArgument(size_t number)
Definition: SubroutineArgument.h:42
Expression.h
souffle::ram::SubroutineArgument
Access argument of a subroutine.
Definition: SubroutineArgument.h:40
souffle::ram::SubroutineArgument::number
const size_t number
Argument number.
Definition: SubroutineArgument.h:64
souffle::ram::SubroutineArgument::clone
SubroutineArgument * clone() const override
Create a clone (i.e.
Definition: SubroutineArgument.h:49