1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/* $Id$
*
* ImmediateOperand: An operand with a value.
*
* Copyright (C) 2008-2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#ifndef __IMMEDIATE_OPERAND_HPP_INCLUDED
#define __IMMEDIATE_OPERAND_HPP_INCLUDED
#include "frontend/ast/Types.hpp"
#include "intermediate/operands/Operand.hpp"
namespace intermediate {
//! immediate operand.
/** This class represents an immediate operand. This means, that the operand
* must be a value (either int or real).
*/
class ImmediateOperand : public Operand {
public:
//! c'tor for const integer operands
/** @param val universal_integer value
*/
ImmediateOperand(
universal_integer val
) : Operand(OP_TYPE_INTEGER),
iValue(val) {}
//! c'tior for const real operands
/** @param val universal_real value
*/
ImmediateOperand(
universal_real val
) : Operand(OP_TYPE_REAL),
rValue(val) {}
//! Accept a Visitor.
/** All intermediate code nodes need to implement this method.
*
* @param v the Visitor that can visit this node.
*/
virtual void accept(Visitor &v) {
v.visit(*this);
}
//! integer value
universal_integer iValue;
//! real value
universal_real rValue;
//! return the ImmediateOperand for zero.
static ImmediateOperand *
getZero(void);
//! return the ImmediateOperand for one.
static ImmediateOperand *
getOne(void);
private:
//! universal integer 0.
static ImmediateOperand *zero;
//! universal integer 1.
static ImmediateOperand *one;
};
}; /* namespace intermediate */
#endif /* __IMMEDIATE_OPERAND_HPP_INCLUDED */
|