yast2-core
Public Member Functions | Private Member Functions | Private Attributes | List of all members
YEBuiltin Class Reference

#include <YExpression.h>

Inheritance diagram for YEBuiltin:
YCode Rep

Public Member Functions

 YEBuiltin (declaration_t *decl, YBlockPtr parameterblock=0, constTypePtr type=0)
 
 YEBuiltin (bytecodeistream &str)
 
 ~YEBuiltin ()
 
virtual ykind kind () const
 
declaration_tdecl () const
 
constTypePtr finalize (Logger *problem_logger)
 
void closeParameters ()
 
constTypePtr attachParameter (YCodePtr code, constTypePtr type=Type::Unspec)
 
constTypePtr attachSymVariable (const char *name, constTypePtr type, unsigned int line, TableEntry *&tentry)
 
string toString () const
 
YCPValue evaluate (bool cse=false)
 
std::ostream & toStream (std::ostream &str) const
 
std::ostream & toXml (std::ostream &str, int indent) const
 
constTypePtr type () const
 
constTypePtr completeType () const
 
YBlockPtr parameterBlock () const
 
- Public Member Functions inherited from YCode
 YCode ()
 
virtual ~YCode ()
 
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
 
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
 

Private Member Functions

 REP_BODY (YEBuiltin)
 

Private Attributes

declaration_tm_decl
 
constFunctionTypePtr m_type
 
YBlockPtr m_parameterblock
 
ycodelist_tm_parameters
 

Additional Inherited Members

- Public Types inherited from YCode
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
}
 
- Static Public Member Functions inherited from YCode
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 Member Functions inherited from Rep
virtual void ref_to (unsigned) const
 
virtual void unref_to (unsigned) const
 
- Protected Attributes inherited from YCode
const char * comment_before
 
const char * comment_after
 

Constructor & Destructor Documentation

YEBuiltin::YEBuiltin ( declaration_t decl,
YBlockPtr  parameterblock = 0,
constTypePtr  type = 0 
)
YEBuiltin::YEBuiltin ( bytecodeistream str)
YEBuiltin::~YEBuiltin ( )

References m_parameters, and ycodelist::next.

Member Function Documentation

constTypePtr YEBuiltin::attachParameter ( YCodePtr  code,
constTypePtr  type = Type::Unspec 
)

Attach parameter to external function call

Parameters
codeparameter code
typeparameter type
Returns
NULL if success, != NULL (expected type) if wrong parameter type Type::Unspec if bad code (NULL or isError) Type::Error if excessive parameter

References ycodelist::code, m_parameters, m_type, ycodelist::next, Type::Unspec, and y2debug.

Referenced by attachSymVariable().

constTypePtr YEBuiltin::attachSymVariable ( const char *  name,
constTypePtr  type,
unsigned int  line,
TableEntry *&  tentry 
)
void YEBuiltin::closeParameters ( )

References m_parameterblock, and y2debug.

constTypePtr YEBuiltin::completeType ( ) const

References m_type.

declaration_t * YEBuiltin::decl ( ) const

References m_decl.

Referenced by attachSymVariable(), and finalize().

YCPValue YEBuiltin::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 from YCode.

References YCPList::add(), ycodelist::code, StaticDeclaration::Decl2String(), DECL_CALL_HANDLER, DECL_NIL, DECL_NOEVAL, declaration::flags, if(), YCPElement::isNull(), kind(), m_decl, m_parameterblock, m_parameters, declaration::name, declaration::name_space, ycodelist::next, declaration::ptr, YCode::toString(), toString(), declaration::type, type(), y2debug, YCode::ycEntry, and ycp2error.

constTypePtr YEBuiltin::finalize ( Logger problem_logger)

'close' function, perform final parameter check if ok, return 0 if wrong signature (wrong parameter count, template mismatch) return expected signature if undefined, return Type::Error (wrong type was already reported in attachParameter())

'close' function, perform final parameter check if ok, return 0 if bad signature, return expected signature (i.e. if non-matching template) if undefined, return Type::Error (wrong type was already reported in attachParameter())

References ycodelist::code, decl(), StaticDeclaration::Decl2String(), DECL_FLEX, DECL_FORMATTED, Type::determineFlexType(), Logger::error(), Type::Error, StaticDeclaration::errorNoMatch(), StaticDeclaration::findDeclaration(), declaration::flags, m_decl, m_parameters, m_type, ycodelist::next, static_declarations, declaration::type, Logger::warning(), y2debug, YCode::ycLocale, and YCode::ycString.

virtual ykind YEBuiltin::kind ( ) const
inlinevirtual

Kind of this YCode. This method must be reimplemented in the inherited classes.

Returns
the YCode kind

Implements YCode.

References YEVariable::evaluate(), YEVariable::name(), str, YEVariable::toStream(), YEVariable::toString(), YEVariable::toXml(), YEVariable::type(), Type::Unspec, and YCode::yeBuiltin.

Referenced by evaluate().

YBlockPtr YEBuiltin::parameterBlock ( ) const

References m_parameterblock.

YEBuiltin::REP_BODY ( YEBuiltin  )
private
std::ostream & YEBuiltin::toStream ( std::ostream &  str) const
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)

Implements YCode.

References m_decl, m_parameterblock, m_parameters, m_type, Bytecode::popNamespace(), Bytecode::pushNamespace(), static_declarations, str, YCode::toStream(), Bytecode::writeBool(), StaticDeclaration::writeDeclaration(), Bytecode::writeType(), and Bytecode::writeYCodelist().

string YEBuiltin::toString ( void  ) const
virtual

Return ASCII represtation of this YCP code.

Returns
ASCII string representation

Reimplemented from YCode.

References ycodelist::code, StaticDeclaration::Decl2String(), m_decl, m_parameters, and ycodelist::next.

Referenced by evaluate().

std::ostream & YEBuiltin::toXml ( std::ostream &  str,
int  indent 
) const
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)

Implements YCode.

References ycodelist::code, YCode::commentToXml(), DECL_SYMBOL, declaration::flags, m_decl, m_parameterblock, m_parameters, declaration::name, declaration::name_space, ycodelist::next, Xmlcode::popNamespace(), Xmlcode::pushNamespace(), Xmlcode::writeYCodelist(), Xmlcode::xmlify(), and YCode::ycEntry.

constTypePtr YEBuiltin::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 from YCode.

References Type::Error, m_decl, m_type, declaration::type, and y2debug.

Referenced by evaluate().

Member Data Documentation

declaration_t* YEBuiltin::m_decl
private
YBlockPtr YEBuiltin::m_parameterblock
private
ycodelist_t* YEBuiltin::m_parameters
private
constFunctionTypePtr YEBuiltin::m_type
private

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

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