YBlock Class Reference

#include <YBlock.h>

Inheritance diagram for YBlock:

YCode Y2Namespace Rep

List of all members.

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 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
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
virtual SymbolTabletable () const
 get our whole symbol table?
virtual Y2FunctioncreateFunctionCall (const string name, constFunctionTypePtr type)
const Pointpoint () const
const string name () const
 what namespace do we implement
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
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

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


Detailed Description

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

Member Typedef Documentation

typedef struct stmtlist YBlock::stmtlist_t [read, private]

typedef std::list<std::string> YBlock::stringlist_t [private]

List of all included files so far.

typedef struct yTElist YBlock::yTElist_t [read, 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:
name name of the required function
type the 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 ( int  statement_index,
bool  skip_initial_imports = true 
)

YCPValue YBlock::evaluate ( bool  cse = false  )  [virtual]

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 [inline, virtual]

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 [inline, virtual]

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 [inline, virtual]

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

Returns:
the YCode kind

Implements YCode.

References YCode::yeBlock.

const string YBlock::name (  )  const [virtual]

what namespace do we implement

Reimplemented from Y2Namespace.

References m_name.

Referenced by newValue().

Y2Namespace* YBlock::nameSpace (  )  [inline]

const Y2Namespace* YBlock::nameSpace (  )  const [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  ) 

References m_statements, and y2debug.

YBlock::REP_BODY ( YBlock   )  [private]

void YBlock::setKind ( YBlock::blockkind_t  kind  ) 

References m_kind, and y2debug.

void YBlock::setName ( const string &  name  ) 

void YBlock::setType ( constTypePtr  type  ) 

References m_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(), 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:
str byte 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::stmtlist::next, YBlock::yTElist::next, Bytecode::popUptoNamespace(), Bytecode::pushNamespace(), statementCount(), YBlock::stmtlist::stmt, Y2Namespace::symbolCount(), Y2Namespace::symbolEntry(), YBlock::yTElist::tentry, Point::toStream(), TableEntry::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:
str string stream to store into
indend indentation 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, isModule(), m_kind, m_name, m_point, m_statements, m_tenvironment, nameSpace(), YBlock::stmtlist::next, YBlock::yTElist::next, Xmlcode::popUptoNamespace(), Xmlcode::pushNamespace(), Xmlcode::spaces(), YBlock::stmtlist::stmt, 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 [inline, 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 m_type.


Member Data Documentation

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

Referenced by attachStatement(), and YBlock().

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

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