yast2-core
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
YCode Class Referenceabstract

YCode for precompiled ycp code. More...

#include <YCode.h>

Inheritance diagram for YCode:
Rep YBlock YBreakpoint YConst YEBinary YEBracket YEBuiltin YECall YECompare YEIs YEList YELocale YEMap YEPropagate YEReference YEReturn YETerm YETriple YEUnary YEVariable YFunction YLocale YStatement

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)
 
- Public Member Functions inherited from Rep
 Rep ()
 
 Rep (const Rep &)
 
Repoperator= (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 Public Member Functions inherited from Rep
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

- Protected Member Functions inherited from Rep
virtual void ref_to (unsigned) const
 
virtual void unref_to (unsigned) const
 

Detailed Description

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.

Member Enumeration Documentation

Enumerator
yxError 
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 

Constructor & Destructor Documentation

YCode::YCode ( )

Creates a new YCode element

References comment_after, and comment_before.

YCode::~YCode ( )
virtual

Destructor

References comment_after, and comment_before.

Member Function Documentation

std::string YCode::commentToXml ( ) const
std::ostream & YCode::commentToXml ( std::ostream &  str) const

Writes comment attributes to a xml stream

References commentToXml().

YCPValue YCode::evaluate ( bool  cse = false)
virtual

Execute YCP code to get the resulting YCPValue. Every inherited class of YCode should reimplement this method.

Returns
YCPValue after executing the code
Parameters
cseshould 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.

bool YCode::isBlock ( ) const
virtual

Is this a YCP block?

Returns
true if the YCode represents a block

Reimplemented in YBlock, and YBreakpoint.

Referenced by YECall::finalize().

bool YCode::isConstant ( ) const
virtual

Is this code constant?

Returns
true if the YCode represents a constant

Reimplemented in YConst, and YBreakpoint.

bool YCode::isError ( ) const

Is this code a representation of an error?

Returns
true if the YCode represents an error

Referenced by evaluate().

bool YCode::isReferenceable ( ) const
virtual

Can this code be stored in a variable of a type reference?

Returns
true if the YCode represents something we can reference to

Reimplemented in YBreakpoint, and YEVariable.

bool YCode::isStatement ( ) const
virtual

Is this a YCP statement (e.g. if, while, ...)

Returns
true if the YCode represents a statement

Reimplemented in YBlock, YBreakpoint, and YStatement.

virtual ykind YCode::kind ( ) const
pure virtual
YCode::REP_BODY ( YCode  )
private
void YCode::setCommentAfter ( const char *  comment)

Setter for comment after code Take care about deallocation of pointer.

Parameters
commentpointer 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.

Parameters
commentpointer to comment

References comment, comment_before, toString(), and y2debug.

std::ostream & YCode::toStream ( std::ostream &  str) const
pure virtual
string YCode::toString ( void  ) const
virtual
string YCode::toString ( ykind  kind)
static

String representation of the YCode kind value. For debugging purposes.

Parameters
kindwhich kind representation should be returned
Returns
string representation

References kind(), names, and y2error.

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.

Parameters
strstring stream to store into
indendindentation level for pretty print
Returns
string stream for chaining writing XML (str)

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.

constTypePtr YCode::type ( ) const
virtual

Return type of this YCP code (interesting mostly for function calls).

Returns
type of the value to be returned after calling evaluate

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.

Member Data Documentation

const char* YCode::comment_after
mutableprotected
const char* YCode::comment_before
mutableprotected

The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.8.8