souffle  2.0.2-371-g6315b36
SignedConstant.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 SignedConstant.h
12  *
13  * Defines a class for evaluating values in the Relational Algebra Machine
14  *
15  ************************************************************************/
16 
17 #pragma once
18 
19 #include "ram/Constant.h"
20 #include "souffle/RamTypes.h"
21 #include <ostream>
22 
23 namespace souffle::ram {
24 
25 /**
26  * @class SignedConstant
27  * @brief Represents a signed constant
28  *
29  * For example:
30  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  * number(5)
32  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
33  */
34 class SignedConstant : public Constant {
35 public:
36  explicit SignedConstant(RamDomain val) : Constant(val) {}
37 
38  /** @brief Get value of the constant. */
39  RamDomain getValue() const {
40  return constant;
41  }
42 
43  /** Create clone */
44  SignedConstant* clone() const override {
45  return new SignedConstant(getValue());
46  }
47 
48 protected:
49  void print(std::ostream& os) const override {
50  os << "number(" << constant << ")";
51  }
52 };
53 
54 } // namespace souffle::ram
Constant.h
souffle::RamDomain
int32_t RamDomain
Definition: RamTypes.h:56
souffle::ram::SignedConstant::SignedConstant
SignedConstant(RamDomain val)
Definition: SignedConstant.h:42
souffle::ram::SignedConstant::clone
SignedConstant * clone() const override
Create clone.
Definition: SignedConstant.h:50
souffle::ram::Constant::Constant
Constant(RamDomain constant)
Definition: Constant.h:44
souffle::ram::SignedConstant
Represents a signed constant.
Definition: SignedConstant.h:40
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::Constant::constant
const RamDomain constant
Constant value.
Definition: Constant.h:52
souffle::ram::SignedConstant::getValue
RamDomain getValue() const
Get value of the constant.
Definition: SignedConstant.h:45
RamTypes.h
souffle::ram::SignedConstant::print
void print(std::ostream &os) const override
Print RAM node.
Definition: SignedConstant.h:55