yast2-core
|
YCode for precompiled ycp code. More...
#include <YCode.h>
Public Types | |
enum | ykind { yxError = 0, ycVoid, ycBoolean, ycInteger, ycFloat, ycString, ycByteblock, ycPath, ycSymbol, ycList, ycMap, ycTerm, ycEntry, ycConstant, ycLocale, ycFunction, yePropagate, yeUnary, yeBinary, yeTriple, yeCompare, yeLocale, yeList, yeMap, yeTerm, yeIs, yeBracket, yeBlock, yeReturn, yeVariable, yeBuiltin, yeFunction, yeReference, yeFunctionPointer, yeExpression, ysTypedef, ysVariable, ysFunction, ysAssign, ysBracket, ysIf, ysWhile, ysDo, ysRepeat, ysExpression, ysReturn, ysBreak, ysContinue, ysTextdomain, ysInclude, ysFilename, ysImport, ysBlock, ysSwitch, ysStatement, yiBreakpoint } |
Public Member Functions | |
YCode () | |
virtual | ~YCode () |
virtual ykind | kind () const =0 |
virtual string | toString () const |
virtual std::ostream & | toStream (std::ostream &str) const =0 |
virtual std::ostream & | toXml (std::ostream &str, int indent) const =0 |
std::string | commentToXml () const |
std::ostream & | commentToXml (std::ostream &str) const |
virtual bool | isConstant () const |
bool | isError () const |
virtual bool | isStatement () const |
virtual bool | isBlock () const |
virtual bool | isReferenceable () const |
virtual YCPValue | evaluate (bool cse=false) |
virtual constTypePtr | type () const |
void | setCommentBefore (const char *comment) |
void | setCommentAfter (const char *comment) |
![]() | |
Rep () | |
Rep (const Rep &) | |
Rep & | operator= (const Rep &) |
virtual | ~Rep () |
void | ref () const |
void | unref () const |
unsigned | refCount () const |
virtual const char * | repName () const |
virtual std::ostream & | dumpOn (std::ostream &str) const |
Static Public Member Functions | |
static string | toString (ykind kind) |
![]() | |
static void | ref (const Rep *obj_r) |
static void | unref (const Rep *obj_r) |
Protected Attributes | |
const char * | comment_before |
const char * | comment_after |
Private Member Functions | |
REP_BODY (YCode) | |
Additional Inherited Members | |
![]() | |
virtual void | ref_to (unsigned) const |
virtual void | unref_to (unsigned) const |
YCode for precompiled ycp code.
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
References comment_after, and comment_before.
|
virtual |
Destructor
References comment_after, and comment_before.
std::string YCode::commentToXml | ( | ) | const |
References comment_after, comment_before, and Xmlcode::xmlify().
Referenced by commentToXml(), YEVariable::toXml(), YStatement::toXml(), YEReference::toXml(), YSBreak::toXml(), YSContinue::toXml(), YETerm::toXml(), YECompare::toXml(), YELocale::toXml(), YSReturn::toXml(), YEList::toXml(), YSTypedef::toXml(), YEMap::toXml(), YSFunction::toXml(), YEPropagate::toXml(), YSAssign::toXml(), YEUnary::toXml(), YBlock::toXml(), YEBinary::toXml(), YConst::toXml(), YSBracket::toXml(), YETriple::toXml(), YSIf::toXml(), YEIs::toXml(), YSWhile::toXml(), YEReturn::toXml(), YLocale::toXml(), YEBracket::toXml(), YSRepeat::toXml(), YSDo::toXml(), YEBuiltin::toXml(), YSTextdomain::toXml(), YSInclude::toXml(), YECall::toXml(), YSImport::toXml(), and YSSwitch::toXml().
std::ostream & YCode::commentToXml | ( | std::ostream & | str | ) | const |
Writes comment attributes to a xml stream
References commentToXml().
|
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 YSSwitch, YEFunctionPointer, YSFilename, YEFunction, YSImport, YSInclude, YSTextdomain, YFunction, YEBuiltin, YSDo, YSRepeat, YEBracket, YLocale, YSWhile, YEReturn, YEIs, YSIf, YETriple, YSBracket, YConst, YEBinary, YEUnary, YSAssign, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YBlock, YSBlock, YECompare, YSExpression, YBreakpoint, YSContinue, YETerm, YSBreak, YEReference, YStatement, and YEVariable.
References isError(), toString(), y2debug, and y2error.
|
virtual |
Is this a YCP block?
Reimplemented in YBlock, and YBreakpoint.
Referenced by YECall::finalize().
|
virtual |
Is this code constant?
Reimplemented in YConst, and YBreakpoint.
bool YCode::isError | ( | ) | const |
Is this code a representation of an error?
Referenced by evaluate().
|
virtual |
Can this code be stored in a variable of a type reference?
Reimplemented in YBreakpoint, and YEVariable.
|
virtual |
Is this a YCP statement (e.g. if, while, ...)
Reimplemented in YBlock, YBreakpoint, and YStatement.
|
pure virtual |
Kind of this YCode. This method must be reimplemented in the inherited classes.
Implemented in YSSwitch, YEFunctionPointer, YSFilename, YEFunction, YSImport, YSInclude, YSTextdomain, YFunction, YEBuiltin, YSDo, YSRepeat, YEBracket, YLocale, YEReturn, YSWhile, YEIs, YSIf, YETriple, YConst, YSBracket, YEBinary, YSVariable, YEUnary, YSAssign, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YSBlock, YBlock, YECompare, YSExpression, YSContinue, YETerm, YSBreak, YEReference, YEVariable, and YBreakpoint.
Referenced by YStatement::toStream(), toStream(), toString(), toXml(), and YStatement::YStatement().
|
private |
void YCode::setCommentAfter | ( | const char * | comment | ) |
Setter for comment after code Take care about deallocation of pointer.
comment | pointer to comment |
References comment, comment_after, toString(), and y2debug.
void YCode::setCommentBefore | ( | const char * | comment | ) |
Setter for comment before code Take care about deallocation of pointer.
comment | pointer to comment |
References comment, comment_before, toString(), and y2debug.
|
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 YSSwitch, YSFilename, YSImport, YECall, YSInclude, YSTextdomain, YFunction, YEBuiltin, YSDo, YEBracket, YSRepeat, YLocale, YEReturn, YSWhile, YEIs, YSIf, YETriple, YConst, YSBracket, YEBinary, YBlock, YEUnary, YSAssign, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YSBlock, YECompare, YSExpression, YETerm, YSContinue, YSBreak, YEReference, YBreakpoint, YEVariable, and YStatement.
References kind(), toString(), and y2debug.
Referenced by YEVariable::toStream(), YStatement::toStream(), YEReference::toStream(), YETerm::toStream(), YECompare::toStream(), YELocale::toStream(), YEList::toStream(), YEMap::toStream(), YEPropagate::toStream(), YEUnary::toStream(), YBlock::toStream(), YEBinary::toStream(), YConst::toStream(), YETriple::toStream(), YEIs::toStream(), YEReturn::toStream(), YLocale::toStream(), YEBracket::toStream(), YEBuiltin::toStream(), YFunction::toStream(), and YECall::toStream().
|
virtual |
Return ASCII represtation of this YCP code.
Reimplemented in YSSwitch, YSFilename, YSImport, YECall, YSInclude, YSTextdomain, YFunction, YEBuiltin, YSDo, YSRepeat, YEBracket, YLocale, YEReturn, YSWhile, YEIs, YSIf, YETriple, YConst, YSBracket, YEBinary, YSVariable, YBlock, YEUnary, YSAssign, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YSBlock, YECompare, YSExpression, YETerm, YSContinue, YSBreak, YEReference, YStatement, YBreakpoint, and YEVariable.
References kind().
Referenced by evaluate(), YEBuiltin::evaluate(), Bytecode::readValue(), setCommentAfter(), setCommentBefore(), toStream(), toXml(), and YConst::YConst().
|
static |
|
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 YSSwitch, YSFilename, YSImport, YECall, YSInclude, YSTextdomain, YFunction, YEBuiltin, YSDo, YEBracket, YSRepeat, YLocale, YEReturn, YSWhile, YEIs, YSIf, YETriple, YConst, YSBracket, YEBinary, YBlock, YEUnary, YSAssign, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YSBlock, YECompare, YSExpression, YETerm, YSContinue, YSBreak, YEReference, YBreakpoint, YEVariable, and YStatement.
References kind(), toString(), and y2debug.
|
virtual |
Return type of this YCP code (interesting mostly for function calls).
Reimplemented in YSSwitch, YSFilename, YSImport, YECall, YSInclude, YSTextdomain, YFunction, YEBuiltin, YSDo, YSRepeat, YEBracket, YLocale, YEReturn, YSWhile, YEIs, YSIf, YETriple, YSBracket, YConst, YEBinary, YEUnary, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YSBlock, YBlock, YECompare, YSExpression, YBreakpoint, YETerm, YEReference, YStatement, and YEVariable.
References Type::Unspec.
|
mutableprotected |
Referenced by commentToXml(), setCommentAfter(), YSExpression::toXml(), YCode(), and ~YCode().
|
mutableprotected |
Referenced by commentToXml(), setCommentBefore(), YSExpression::toXml(), YCode(), and ~YCode().