yast2-core
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions
YCode Class Reference

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

List of all members.

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
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
- 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)

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

YCode::~YCode ( )
virtual

Destructor


Member Function Documentation

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, YEBuiltin, YSDo, YFunction, YSRepeat, YEBracket, YSWhile, YEReturn, YEIs, YLocale, YSIf, YETriple, YSBracket, YEBinary, YConst, 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
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.

Parameters:
strbyte stream to store into
Returns:
byte stream for chaining writing bytecode (str)

Implemented in YSSwitch, YSFilename, YSImport, YECall, YSInclude, YSTextdomain, YEBuiltin, YSDo, YFunction, YEBracket, YSRepeat, YEReturn, YSWhile, YEIs, YLocale, YSIf, YETriple, YSBracket, YEBinary, YBlock, YConst, 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.

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, YEBuiltin, YSDo, YFunction, YEBracket, YSRepeat, YEReturn, YSWhile, YEIs, YLocale, YSIf, YETriple, YSBracket, YEBinary, YBlock, YConst, 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, YEBuiltin, YSDo, YFunction, YSRepeat, YEBracket, YEReturn, YSWhile, YEIs, YLocale, YSIf, YETriple, YSBracket, YEBinary, YConst, YEUnary, YEPropagate, YSFunction, YEMap, YSTypedef, YEList, YSReturn, YELocale, YSBlock, YBlock, YECompare, YSExpression, YBreakpoint, YETerm, YEReference, YStatement, and YEVariable.

References Type::Unspec.


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

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