yast2-core
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
YBlock Class Reference

#include <YBlock.h>

Inheritance diagram for YBlock:
YCode Y2Namespace Rep

Classes

struct  stmtlist
 
struct  yTElist
 

Public Types

enum  blockkind_t {
  b_unknown = 0, b_module, b_file, b_statement,
  b_definition, b_value, b_namespace, b_using
}
 
- 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
}
 

Public Member Functions

 YBlock (const std::string &filename, blockkind_t kind=b_unknown)
 
 YBlock (const Point *point)
 
 YBlock (bytecodeistream &str)
 
 ~YBlock ()
 
virtual bool isBlock () const
 
virtual ykind kind () const
 
constTypePtr type () const
 
void setType (constTypePtr type)
 
void finishBlock ()
 
virtual YCPValue evaluate (bool cse=false)
 called when evaluating the import statement More...
 
YCPValue evaluateFrom (int statement_index)
 
YCPValue evaluate (int statement_index, bool skip_initial_imports=true)
 
virtual const std::string filename () const
 used for error reporting More...
 
virtual SymbolTabletable () const
 get our whole symbol table? More...
 
virtual Y2FunctioncreateFunctionCall (const string name, constFunctionTypePtr type)
 
const Pointpoint () const
 
const string name () const
 what namespace do we implement More...
 
void setName (const string &name)
 
const Y2NamespacenameSpace () const
 
Y2NamespacenameSpace ()
 
void setKind (blockkind_t kind)
 
blockkind_t bkind () const
 
bool isModule () const
 
bool isFile () const
 
bool isStatement () const
 
bool isDefinition () const
 
bool isValue () const
 
bool isNamespace () const
 
unsigned int newValue (constTypePtr type, YCodePtr code)
 
TableEntrynewEntry (const char *name, SymbolEntry::category_t cat, constTypePtr type, unsigned int line)
 
TableEntrynewNamespace (const string &name, Y2Namespace *name_space, int line)
 
void attachEntry (TableEntry *entry)
 
void detachEnvironment (SymbolTable *table)
 
void attachStatement (YStatementPtr statement)
 
void pretachStatement (YStatementPtr statement)
 
int statementCount () const
 
YSReturnPtr justReturn () const
 
void endInclude ()
 
bool isIncluded (string includename) const
 
void addIncluded (string includename)
 
string toString () const
 unparse. useful for debugging More...
 
string environmentToString () const
 
string toStringSwitch (map< YCPValue, int, ycp_less > cases, int defaultcase) const
 
std::ostream & toStream (std::ostream &str) const
 
std::ostream & toXml (std::ostream &str, int indent) const
 
std::ostream & toXmlSwitch (map< YCPValue, int, ycp_less > cases, int defaultcase, std::ostream &str, int indent) 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 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
 
- Public Member Functions inherited from Y2Namespace
 Y2Namespace ()
 
virtual ~Y2Namespace ()
 
void finish ()
 
virtual unsigned int symbolCount () const
 gives the number of symbol declarations More...
 
virtual SymbolEntryPtr symbolEntry (unsigned int position) const
 access to definitions of this namespace More...
 
string symbolsToString () const
 
void createTable ()
 
void pushToStack ()
 
void popFromStack ()
 
virtual void initialize ()
 

Private Types

typedef struct yTElist yTElist_t
 
typedef struct stmtlist stmtlist_t
 
typedef std::list< std::string > stringlist_t
 

Private Member Functions

 REP_BODY (YBlock)
 

Private Attributes

blockkind_t m_kind
 
string m_name
 
yTElist_tm_tenvironment
 
yTElist_tm_last_tparm
 
const Pointm_point
 
stmtlist_tm_statements
 
stmtlist_tm_last_statement
 
stringlist_tm_includes
 
constTypePtr m_type
 
bool m_running
 

Additional Inherited Members

- 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 Types inherited from Y2Namespace
typedef vector< SymbolEntryPtr > symbols_t
 
- Protected Member Functions inherited from Rep
virtual void ref_to (unsigned) const
 
virtual void unref_to (unsigned) const
 
- Protected Member Functions inherited from Y2Namespace
unsigned int addSymbol (SymbolEntryPtr sentry)
 
void enterSymbol (SymbolEntryPtr sentry, Point *point=0)
 
SymbolEntryPtr lookupSymbol (const char *name) const
 
void releaseSymbol (unsigned int position)
 
- Protected Attributes inherited from YCode
const char * comment_before
 
const char * comment_after
 
- Protected Attributes inherited from Y2Namespace
SymbolTablem_table
 
unsigned int m_symbolcount
 
symbols_t m_symbols
 
bool m_initialized
 

Detailed Description

block (-> list of statements, list of symbols)

Member Typedef Documentation

typedef struct stmtlist YBlock::stmtlist_t
private
typedef std::list<std::string> YBlock::stringlist_t
private

List of all included files so far.

typedef struct yTElist YBlock::yTElist_t
private

Member Enumeration Documentation

Enumerator
b_unknown 
b_module 
b_file 
b_statement 
b_definition 
b_value 
b_namespace 
b_using 

Constructor & Destructor Documentation

YBlock::YBlock ( const std::string &  filename,
YBlock::blockkind_t  kind = b_unknown 
)
YBlock::YBlock ( const Point point)
YBlock::YBlock ( bytecodeistream str)
YBlock::~YBlock ( )

Member Function Documentation

void YBlock::addIncluded ( string  includename)

References m_includes.

void YBlock::attachEntry ( TableEntry entry)
void YBlock::attachStatement ( YStatementPtr  statement)
YBlock::blockkind_t YBlock::bkind ( ) const

References m_kind.

Y2Function * YBlock::createFunctionCall ( const string  name,
constFunctionTypePtr  type 
)
virtual

Creates a function call instance, which can be used to call a function from this namespace. The object is NOT owned anymore by this instance, the caller can (and should) delete it.

Parameters
namename of the required function
typethe type of the function (needed for overloading)
Returns
an object, that can be used to call the function, or NULL on error

Implements Y2Namespace.

References SymbolEntry::c_function, SymbolTable::find(), Y2Namespace::m_symbolcount, Y2Namespace::m_symbols, TableEntry::sentry(), table(), and y2debug.

void YBlock::detachEnvironment ( SymbolTable table)
void YBlock::endInclude ( )
string YBlock::environmentToString ( ) const
YCPValue YBlock::evaluate ( bool  cse = false)
virtual
YCPValue YBlock::evaluate ( int  statement_index,
bool  skip_initial_imports = true 
)
YCPValue YBlock::evaluateFrom ( int  statement_index)
const std::string YBlock::filename ( ) const
virtual

used for error reporting

Implements Y2Namespace.

References Point::filename(), and m_point.

Referenced by evaluate(), evaluateFrom(), and toString().

void YBlock::finishBlock ( )
virtual bool YBlock::isBlock ( ) const
inlinevirtual

yes

Reimplemented from YCode.

bool YBlock::isDefinition ( ) const
inline

References b_definition, and m_kind.

bool YBlock::isFile ( ) const
inline

References b_file, and m_kind.

Referenced by toString().

bool YBlock::isIncluded ( string  includename) const

Checks, if the given include name is already included in the current block.

References m_includes.

bool YBlock::isModule ( ) const
inline

References b_module, and m_kind.

Referenced by evaluate(), evaluateFrom(), toStream(), toString(), toXml(), and YBlock().

bool YBlock::isNamespace ( ) const
inline

References b_namespace, and m_kind.

bool YBlock::isStatement ( ) const
inlinevirtual

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

Returns
true if the YCode represents a statement

Reimplemented from YCode.

References b_statement, and m_kind.

bool YBlock::isValue ( ) const
inline

References b_value, and m_kind.

YSReturnPtr YBlock::justReturn ( ) const
virtual ykind YBlock::kind ( ) const
inlinevirtual

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

Returns
the YCode kind

Implements YCode.

References YCode::yeBlock.

Referenced by setKind().

const string YBlock::name ( ) const
virtual

what namespace do we implement

Reimplemented from Y2Namespace.

References m_name.

Referenced by newValue(), and setName().

const Y2Namespace* YBlock::nameSpace ( ) const
inline
Y2Namespace* YBlock::nameSpace ( )
inline
TableEntry * YBlock::newEntry ( const char *  name,
SymbolEntry::category_t  cat,
constTypePtr  type,
unsigned int  line 
)
TableEntry * YBlock::newNamespace ( const string &  name,
Y2Namespace name_space,
int  line 
)
unsigned int YBlock::newValue ( constTypePtr  type,
YCodePtr  code 
)
const Point * YBlock::point ( void  ) const

References m_point.

Referenced by endInclude(), and newEntry().

void YBlock::pretachStatement ( YStatementPtr  statement)
YBlock::REP_BODY ( YBlock  )
private
void YBlock::setKind ( YBlock::blockkind_t  kind)

References kind(), m_kind, and y2debug.

void YBlock::setName ( const string &  name)

References m_name, and name().

Referenced by StaticDeclaration::registerDeclarations().

void YBlock::setType ( constTypePtr  type)

References m_type, and type().

int YBlock::statementCount ( ) const
SymbolTable * YBlock::table ( ) const
virtual

get our whole symbol table?

Reimplemented from Y2Namespace.

References Y2Namespace::m_table, and y2debug.

Referenced by createFunctionCall(), detachEnvironment(), and StaticDeclaration::registerDeclarations().

std::ostream & YBlock::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 isModule(), m_kind, m_name, m_point, m_statements, m_tenvironment, nameSpace(), YBlock::yTElist::next, YBlock::stmtlist::next, Bytecode::popUptoNamespace(), Bytecode::pushNamespace(), statementCount(), YBlock::stmtlist::stmt, str, Y2Namespace::symbolCount(), Y2Namespace::symbolEntry(), YBlock::yTElist::tentry, Point::toStream(), TableEntry::toStream(), YCode::toStream(), Bytecode::writeInt32(), Bytecode::writeString(), and y2debug.

string YBlock::toString ( void  ) const
virtual

unparse. useful for debugging

Reimplemented from Y2Namespace.

References b_using, environmentToString(), filename(), isFile(), isModule(), m_kind, m_name, m_statements, YBlock::stmtlist::next, and YBlock::stmtlist::stmt.

Referenced by evaluate(), and evaluateFrom().

string YBlock::toStringSwitch ( map< YCPValue, int, ycp_less cases,
int  defaultcase 
) const
std::ostream & YBlock::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 b_definition, b_file, b_module, b_namespace, b_statement, b_unknown, b_using, b_value, YCode::commentToXml(), isModule(), m_kind, m_name, m_point, m_statements, m_tenvironment, nameSpace(), YBlock::yTElist::next, YBlock::stmtlist::next, Xmlcode::popUptoNamespace(), Xmlcode::pushNamespace(), Xmlcode::spaces(), YBlock::stmtlist::stmt, str, Y2Namespace::symbolCount(), Y2Namespace::symbolEntry(), YBlock::yTElist::tentry, Point::toXml(), and TableEntry::toXml().

std::ostream & YBlock::toXmlSwitch ( map< YCPValue, int, ycp_less cases,
int  defaultcase,
std::ostream &  str,
int  indent 
) const
constTypePtr YBlock::type ( ) const
inlinevirtual

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 m_type.

Referenced by setType().

Member Data Documentation

stringlist_t* YBlock::m_includes
private

Referenced by addIncluded(), isIncluded(), and ~YBlock().

blockkind_t YBlock::m_kind
private
stmtlist_t* YBlock::m_last_statement
private

Referenced by attachStatement(), and YBlock().

yTElist_t* YBlock::m_last_tparm
private

Referenced by attachEntry(), and detachEnvironment().

string YBlock::m_name
private
const Point* YBlock::m_point
private
bool YBlock::m_running
private

Referenced by evaluate(), and evaluateFrom().

stmtlist_t* YBlock::m_statements
private
yTElist_t* YBlock::m_tenvironment
private
constTypePtr YBlock::m_type
private

Referenced by setType(), and type().


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

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