YCP Constant. More...
#include <YCode.h>
Public Member Functions | |
YConst (ykind kind, YCPValue value) | |
YConst (ykind kind, bytecodeistream &str) | |
~YConst () | |
YCPValue | value () const |
virtual ykind | kind () const |
string | toString () const |
std::ostream & | toStream (std::ostream &str) const |
std::ostream & | toXml (std::ostream &str, int indent) const |
virtual bool | isConstant () const |
YCPValue | evaluate (bool cse=false) |
constTypePtr | type () const |
Private Member Functions | |
REP_BODY (YConst) | |
Private Attributes | |
ykind | m_kind |
YCPValue | m_value |
YCP Constant.
The base class for YCP constants (YCPValue).
YConst::YConst | ( | ykind | kind, | |
bytecodeistream & | str | |||
) |
References YCPElement::isNull(), m_value, Bytecode::readBool(), Bytecode::readEntry(), YCode::toString(), y2debug, y2error, y2warning, YCode::ycBoolean, YCode::ycByteblock, YCode::ycEntry, YCode::ycFloat, YCode::ycInteger, YCode::ycList, YCode::ycMap, YCode::ycPath, YCode::ycString, YCode::ycSymbol, YCode::ycTerm, and YCode::ycVoid.
YConst::~YConst | ( | ) | [inline] |
YCPValue YConst::evaluate | ( | bool | cse = false |
) | [virtual] |
Execute YCP code to get the resulting YCPValue. Every inherited class of YCode should reimplement this method.
cse | should the evaluation be done for parse time evaluation (i.e. constant subexpression elimination) |
Reimplemented from YCode.
References YCPElement::isNull(), m_value, toString(), and y2debug.
virtual bool YConst::isConstant | ( | ) | const [inline, virtual] |
yes
Reimplemented from YCode.
YCode::ykind YConst::kind | ( | ) | const [virtual] |
YConst::REP_BODY | ( | YConst | ) | [private] |
std::ostream & YConst::toStream | ( | std::ostream & | str | ) | const [virtual] |
Write YCP code to a byte stream (bytecode implementation). Every class inheriting from YCode must reimplement this method.
str | byte stream to store into |
Implements YCode.
References YCPElement::isNull(), m_kind, m_value, Bytecode::writeBool(), y2error, and YCode::ycConstant.
string YConst::toString | ( | void | ) | const [virtual] |
Return ASCII represtation of this YCP code.
Reimplemented from YCode.
References YCPElement::isNull(), m_kind, m_value, YCode::ycBoolean, YCode::ycByteblock, YCode::ycFloat, YCode::ycInteger, YCode::ycList, YCode::ycLocale, YCode::ycMap, YCode::ycPath, YCode::ycString, YCode::ycSymbol, YCode::ycTerm, YCode::ycVoid, YCode::yeBlock, and YCode::yeLocale.
Referenced by evaluate().
std::ostream & YConst::toXml | ( | std::ostream & | str, | |
int | indent | |||
) | const [virtual] |
Write YCP code as XML representation. Every class inheriting from YCode must reimplement this method.
str | string stream to store into | |
indend | indentation level for pretty print |
Implements YCode.
References YCPElement::isNull(), m_kind, m_value, y2error, and YCode::ycConstant.
constTypePtr YConst::type | ( | ) | const [virtual] |
Return type of this YCP code (interesting mostly for function calls).
Reimplemented from YCode.
References Type::ConstAny, Type::ConstBoolean, Type::ConstByteblock, Type::ConstFloat, Type::ConstInteger, Type::ConstLocale, Type::ConstPath, Type::ConstString, Type::ConstSymbol, Type::ConstTerm, Type::ConstVoid, Type::ListUnspec, m_kind, Type::MapUnspec, Type::Unspec, YCode::ycBoolean, YCode::ycByteblock, YCode::ycFloat, YCode::ycInteger, YCode::ycList, YCode::ycLocale, YCode::ycMap, YCode::ycPath, YCode::ycString, YCode::ycSymbol, YCode::ycTerm, YCode::ycVoid, and YCode::yeBlock.
ykind YConst::m_kind [private] |
Referenced by kind(), toStream(), toString(), toXml(), and type().
YCPValue YConst::m_value [private] |
Referenced by evaluate(), toStream(), toString(), toXml(), value(), and YConst().