yast2-core
|
#include <YBlock.h>
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 } |
![]() | |
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 SymbolTable * | table () const |
get our whole symbol table? More... | |
virtual Y2Function * | createFunctionCall (const string name, constFunctionTypePtr type) |
const Point * | point () const |
const string | name () const |
what namespace do we implement More... | |
void | setName (const string &name) |
const Y2Namespace * | nameSpace () const |
Y2Namespace * | nameSpace () |
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) |
TableEntry * | newEntry (const char *name, SymbolEntry::category_t cat, constTypePtr type, unsigned int line) |
TableEntry * | newNamespace (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 |
![]() | |
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) |
![]() | |
Rep () | |
Rep (const Rep &) | |
Rep & | operator= (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 |
![]() | |
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_t * | m_tenvironment |
yTElist_t * | m_last_tparm |
const Point * | m_point |
stmtlist_t * | m_statements |
stmtlist_t * | m_last_statement |
stringlist_t * | m_includes |
constTypePtr | m_type |
bool | m_running |
Additional Inherited Members | |
![]() | |
static string | toString (ykind kind) |
![]() | |
static void | ref (const Rep *obj_r) |
static void | unref (const Rep *obj_r) |
![]() | |
typedef vector< SymbolEntryPtr > | symbols_t |
![]() | |
virtual void | ref_to (unsigned) const |
virtual void | unref_to (unsigned) const |
![]() | |
unsigned int | addSymbol (SymbolEntryPtr sentry) |
void | enterSymbol (SymbolEntryPtr sentry, Point *point=0) |
SymbolEntryPtr | lookupSymbol (const char *name) const |
void | releaseSymbol (unsigned int position) |
![]() | |
const char * | comment_before |
const char * | comment_after |
![]() | |
SymbolTable * | m_table |
unsigned int | m_symbolcount |
symbols_t | m_symbols |
bool | m_initialized |
block (-> list of statements, list of symbols)
|
private |
|
private |
List of all included files so far.
|
private |
enum YBlock::blockkind_t |
YBlock::YBlock | ( | const std::string & | filename, |
YBlock::blockkind_t | kind = b_unknown |
||
) |
References Y2Namespace::addSymbol(), SymbolEntry::c_filename, m_point, nameSpace(), Type::Unspec, and y2debug.
YBlock::YBlock | ( | const Point * | point | ) |
YBlock::YBlock | ( | bytecodeistream & | str | ) |
References Y2Namespace::addSymbol(), attachEntry(), b_module, Y2Namespace::createTable(), SymbolTable::enter(), isModule(), m_kind, m_last_statement, m_name, m_point, m_statements, Y2Namespace::m_table, nameSpace(), YBlock::stmtlist::next, SymbolTable::openXRefs(), Bytecode::popUptoNamespace(), Bytecode::pushNamespace(), Bytecode::readCode(), Bytecode::readInt32(), Bytecode::readString(), Y2Namespace::symbolEntry(), Y2Namespace::SymbolTable, y2debug, and y2error.
YBlock::~YBlock | ( | ) |
References b_file, m_includes, m_kind, m_point, m_statements, m_tenvironment, YBlock::yTElist::next, YBlock::stmtlist::next, and y2debug.
void YBlock::addIncluded | ( | string | includename | ) |
References m_includes.
void YBlock::attachEntry | ( | TableEntry * | entry | ) |
References m_last_tparm, m_tenvironment, YBlock::yTElist::next, YBlock::yTElist::tentry, y2debug, and y2error.
Referenced by newEntry(), and YBlock().
void YBlock::attachStatement | ( | YStatementPtr | statement | ) |
References m_last_statement, m_statements, YBlock::stmtlist::next, YBlock::stmtlist::stmt, and y2debug.
Referenced by switch().
YBlock::blockkind_t YBlock::bkind | ( | ) | const |
References m_kind.
|
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.
name | name of the required function |
type | the type of the function (needed for overloading) |
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 | ( | ) |
References m_point, Point::point(), point(), Point::toString(), y2debug, and y2error.
string YBlock::environmentToString | ( | ) | const |
References m_tenvironment, YBlock::yTElist::next, TableEntry::sentry(), Y2Namespace::symbolsToString(), YBlock::yTElist::tentry, and TableEntry::toString().
Referenced by detachEnvironment(), newNamespace(), toString(), and toStringSwitch().
|
virtual |
called when evaluating the import statement
Implements Y2Namespace.
References b_statement, Debugger::c_continue, Debugger::c_next, YaST::ee, YaST::ExecutionEnvironment::filename(), filename(), isModule(), YCPElement::isNull(), Debugger::lastCommand(), m_kind, m_running, m_statements, YBlock::stmtlist::next, Debugger::popBlock(), Y2Namespace::popFromStack(), Debugger::processInput(), Debugger::pushBlock(), Y2Namespace::pushToStack(), YaST::ExecutionEnvironment::setFilename(), YaST::ExecutionEnvironment::setStatement(), Debugger::setTracing(), YBlock::stmtlist::stmt, toString(), Debugger::tracing(), y2debug, and YCode::ysFunction.
YCPValue YBlock::evaluate | ( | int | statement_index, |
bool | skip_initial_imports = true |
||
) |
References m_statements, YBlock::stmtlist::next, YBlock::stmtlist::stmt, y2debug, y2milestone, and YCode::ysImport.
YCPValue YBlock::evaluateFrom | ( | int | statement_index | ) |
References b_statement, YaST::ee, YaST::ExecutionEnvironment::filename(), filename(), isModule(), YCPElement::isNull(), m_kind, m_running, m_statements, YBlock::stmtlist::next, Y2Namespace::popFromStack(), Y2Namespace::pushToStack(), YaST::ExecutionEnvironment::setFilename(), YaST::ExecutionEnvironment::setStatement(), YBlock::stmtlist::stmt, toString(), and y2debug.
|
virtual |
used for error reporting
Implements Y2Namespace.
References Point::filename(), and m_point.
Referenced by evaluate(), evaluateFrom(), and toString().
void YBlock::finishBlock | ( | ) |
|
inlinevirtual |
yes
Reimplemented from YCode.
|
inline |
References b_definition, and m_kind.
|
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.
|
inline |
References b_module, and m_kind.
Referenced by evaluate(), evaluateFrom(), toStream(), toString(), toXml(), and YBlock().
|
inline |
References b_namespace, and m_kind.
|
inlinevirtual |
Is this a YCP statement (e.g. if, while, ...)
Reimplemented from YCode.
References b_statement, and m_kind.
YSReturnPtr YBlock::justReturn | ( | ) | const |
References m_statements, YBlock::stmtlist::stmt, and YCode::ysReturn.
|
inlinevirtual |
Kind of this YCode. This method must be reimplemented in the inherited classes.
Implements YCode.
References YCode::yeBlock.
Referenced by setKind().
|
virtual |
what namespace do we implement
Reimplemented from Y2Namespace.
References m_name.
Referenced by newValue(), and setName().
|
inline |
Referenced by newEntry(), newValue(), toStream(), toXml(), and YBlock().
|
inline |
TableEntry * YBlock::newEntry | ( | const char * | name, |
SymbolEntry::category_t | cat, | ||
constTypePtr | type, | ||
unsigned int | line | ||
) |
References Y2Namespace::addSymbol(), attachEntry(), SymbolEntry::c_filename, Y2Namespace::lookupSymbol(), m_point, nameSpace(), point(), Y2Namespace::symbolCount(), Y2Namespace::toString(), and y2debug.
Referenced by newNamespace().
TableEntry * YBlock::newNamespace | ( | const string & | name, |
Y2Namespace * | name_space, | ||
int | line | ||
) |
References SymbolEntry::c_module, environmentToString(), newEntry(), Type::Unspec, and y2debug.
unsigned int YBlock::newValue | ( | constTypePtr | type, |
YCodePtr | code | ||
) |
References Y2Namespace::addSymbol(), SymbolEntry::c_const, name(), nameSpace(), Y2Namespace::symbolCount(), and y2debug.
const Point * YBlock::point | ( | void | ) | const |
References m_point.
Referenced by endInclude(), and newEntry().
void YBlock::pretachStatement | ( | YStatementPtr | statement | ) |
References m_statements, YBlock::stmtlist::stmt, and y2debug.
|
private |
void YBlock::setKind | ( | YBlock::blockkind_t | kind | ) |
void YBlock::setName | ( | const string & | name | ) |
References m_name, and name().
Referenced by StaticDeclaration::registerDeclarations().
int YBlock::statementCount | ( | ) | const |
References m_statements, and YBlock::stmtlist::next.
Referenced by toStream(), toStringSwitch(), and toXmlSwitch().
|
virtual |
get our whole symbol table?
Reimplemented from Y2Namespace.
References Y2Namespace::m_table, and y2debug.
Referenced by createFunctionCall(), detachEnvironment(), and StaticDeclaration::registerDeclarations().
|
virtual |
Write YCP code to a byte stream (bytecode implementation). Every class inheriting from YCode must reimplement this method.
str | byte stream to store into |
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.
|
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().
References environmentToString(), m_statements, YBlock::stmtlist::next, statementCount(), and YBlock::stmtlist::stmt.
|
virtual |
Write YCP code as XML representation. Every class inheriting from YCode must reimplement this method.
str | string stream to store into |
indend | indentation level for pretty print |
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 |
References m_statements, YBlock::stmtlist::next, Xmlcode::spaces(), statementCount(), YBlock::stmtlist::stmt, and str.
|
inlinevirtual |
|
private |
Referenced by addIncluded(), isIncluded(), and ~YBlock().
|
private |
Referenced by bkind(), evaluate(), evaluateFrom(), isDefinition(), isFile(), isModule(), isNamespace(), isStatement(), isValue(), setKind(), toStream(), toString(), toXml(), YBlock(), and ~YBlock().
|
private |
Referenced by attachStatement(), and YBlock().
|
private |
Referenced by attachEntry(), and detachEnvironment().
|
private |
Referenced by name(), setName(), toStream(), toString(), toXml(), and YBlock().
|
private |
Referenced by endInclude(), filename(), newEntry(), point(), toStream(), toXml(), YBlock(), and ~YBlock().
|
private |
Referenced by evaluate(), and evaluateFrom().
|
private |
Referenced by attachStatement(), evaluate(), evaluateFrom(), justReturn(), pretachStatement(), statementCount(), toStream(), toString(), toStringSwitch(), toXml(), toXmlSwitch(), YBlock(), and ~YBlock().
|
private |
Referenced by attachEntry(), detachEnvironment(), environmentToString(), toStream(), toXml(), and ~YBlock().