#include <YCode.h>
A class representing parsed YCP code. This is an abstract base class for implementing any YCP language feature. kind uniquely identifies the type of the class. The class provides infrastructure for dumping a bytecode representation (toStream), XML representation (toXML) and ASCII representation (toString).
The represented YCP code is executed via invoking evaluate.
enum YCode::ykind |
YCode::YCode | ( | ) |
Creates a new YCode element
YCode::~YCode | ( | ) | [virtual] |
Destructor
YCPValue YCode::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 in YBlock, YConst, YLocale, YFunction, YEVariable, YEReference, YETerm, YECompare, YELocale, YEList, YEMap, YEPropagate, YEUnary, YEBinary, YETriple, YEIs, YEReturn, YEBracket, YEBuiltin, YEFunction, YEFunctionPointer, YStatement, YSBreak, YSContinue, YSExpression, YSBlock, YSReturn, YSTypedef, YSFunction, YSAssign, YSBracket, YSIf, YSWhile, YSRepeat, YSDo, YSTextdomain, YSInclude, YSImport, YSFilename, and YSSwitch.
References isError(), toString(), y2debug, and y2error.
bool YCode::isBlock | ( | ) | const [virtual] |
Is this a YCP block?
Reimplemented in YBlock.
Referenced by YECall::finalize().
bool YCode::isConstant | ( | ) | const [virtual] |
bool YCode::isError | ( | ) | const |
Is this code a representation of an error?
Referenced by evaluate().
bool YCode::isReferenceable | ( | ) | const [virtual] |
Can this code be stored in a variable of a type reference?
Reimplemented in YEVariable.
bool YCode::isStatement | ( | ) | const [virtual] |
Is this a YCP statement (e.g. if, while, ...)
Reimplemented in YBlock, and YStatement.
virtual ykind YCode::kind | ( | ) | const [pure virtual] |
Kind of this YCode. This method must be reimplemented in the inherited classes.
Implemented in YBlock, YConst, YLocale, YFunction, YEVariable, YEReference, YETerm, YECompare, YELocale, YEList, YEMap, YEPropagate, YEUnary, YEBinary, YETriple, YEIs, YEReturn, YEBracket, YEBuiltin, YEFunction, YEFunctionPointer, YSBreak, YSContinue, YSExpression, YSBlock, YSReturn, YSTypedef, YSFunction, YSAssign, YSVariable, YSBracket, YSIf, YSWhile, YSRepeat, YSDo, YSTextdomain, YSInclude, YSImport, YSFilename, and YSSwitch.
Referenced by YStatement::toStream(), toStream(), toString(), toXml(), and YStatement::YStatement().
YCode::REP_BODY | ( | YCode | ) | [private] |
std::ostream & YCode::toStream | ( | std::ostream & | str | ) | const [pure 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 |
Implemented in YBlock, YConst, YLocale, YFunction, YEVariable, YEReference, YETerm, YECompare, YELocale, YEList, YEMap, YEPropagate, YEUnary, YEBinary, YETriple, YEIs, YEReturn, YEBracket, YEBuiltin, YECall, YStatement, YSBreak, YSContinue, YSExpression, YSBlock, YSReturn, YSTypedef, YSFunction, YSAssign, YSBracket, YSIf, YSWhile, YSRepeat, YSDo, YSTextdomain, YSInclude, YSImport, YSFilename, and YSSwitch.
References kind(), toString(), and y2debug.
string YCode::toString | ( | ykind | kind | ) | [static] |
string YCode::toString | ( | void | ) | const [virtual] |
Return ASCII represtation of this YCP code.
Reimplemented in YBlock, YConst, YLocale, YFunction, YEVariable, YEReference, YETerm, YECompare, YELocale, YEList, YEMap, YEPropagate, YEUnary, YEBinary, YETriple, YEIs, YEReturn, YEBracket, YEBuiltin, YECall, YStatement, YSBreak, YSContinue, YSExpression, YSBlock, YSReturn, YSTypedef, YSFunction, YSAssign, YSVariable, YSBracket, YSIf, YSWhile, YSRepeat, YSDo, YSTextdomain, YSInclude, YSImport, YSFilename, and YSSwitch.
References kind().
Referenced by YEBuiltin::evaluate(), evaluate(), Bytecode::readValue(), toStream(), toXml(), and YConst::YConst().
std::ostream & YCode::toXml | ( | std::ostream & | str, | |
int | indent | |||
) | const [pure 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 |
Implemented in YBlock, YConst, YLocale, YFunction, YEVariable, YEReference, YETerm, YECompare, YELocale, YEList, YEMap, YEPropagate, YEUnary, YEBinary, YETriple, YEIs, YEReturn, YEBracket, YEBuiltin, YECall, YStatement, YSBreak, YSContinue, YSExpression, YSBlock, YSReturn, YSTypedef, YSFunction, YSAssign, YSBracket, YSIf, YSWhile, YSRepeat, YSDo, YSTextdomain, YSInclude, YSImport, YSFilename, and YSSwitch.
References kind(), toString(), and y2debug.
constTypePtr YCode::type | ( | ) | const [virtual] |
Return type of this YCP code (interesting mostly for function calls).
Reimplemented in YBlock, YConst, YLocale, YFunction, YEVariable, YEReference, YETerm, YECompare, YELocale, YEList, YEMap, YEPropagate, YEUnary, YEBinary, YETriple, YEIs, YEReturn, YEBracket, YEBuiltin, YECall, YStatement, YSExpression, YSBlock, YSReturn, YSTypedef, YSFunction, YSBracket, YSIf, YSWhile, YSRepeat, YSDo, YSTextdomain, YSInclude, YSImport, YSFilename, and YSSwitch.
References Type::Unspec.