#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 } |
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 SymbolTable * | table () const |
| get our whole symbol table? | |
| virtual Y2Function * | createFunctionCall (const string name, constFunctionTypePtr type) |
| const Point * | point () const |
| const string | name () const |
| what namespace do we implement | |
| 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 | |
| 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_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 |
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] |
| 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.
| 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.
| 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().
| 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::evaluate | ( | bool | cse = false |
) | [virtual] |
called when evaluating the import statement
Implements Y2Namespace.
References b_statement, ExecutionEnvironment::filename(), filename(), isModule(), YCPElement::isNull(), m_kind, m_running, m_statements, YBlock::stmtlist::next, Y2Namespace::popFromStack(), Y2Namespace::pushToStack(), ExecutionEnvironment::setFilename(), ExecutionEnvironment::setStatement(), YBlock::stmtlist::stmt, toString(), and y2debug.
| YCPValue YBlock::evaluateFrom | ( | int | statement_index | ) |
References b_statement, ExecutionEnvironment::filename(), filename(), isModule(), YCPElement::isNull(), m_kind, m_running, m_statements, YBlock::stmtlist::next, Y2Namespace::popFromStack(), Y2Namespace::pushToStack(), ExecutionEnvironment::setFilename(), ExecutionEnvironment::setStatement(), YBlock::stmtlist::stmt, toString(), and y2debug.
| 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] |
| 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, ...)
Reimplemented from YCode.
References b_statement, and m_kind.
| YSReturnPtr YBlock::justReturn | ( | ) | const |
References m_statements, YBlock::stmtlist::stmt, and YCode::ysReturn.
| virtual ykind YBlock::kind | ( | ) | const [inline, virtual] |
Kind of this YCode. This method must be reimplemented in the inherited classes.
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] |
Referenced by newEntry(), newValue(), toStream(), toXml(), and YBlock().
| 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 |
| void YBlock::pretachStatement | ( | YStatementPtr | statement | ) |
References m_statements, and y2debug.
| YBlock::REP_BODY | ( | YBlock | ) | [private] |
| void YBlock::setKind | ( | YBlock::blockkind_t | kind | ) |
| void YBlock::setName | ( | const string & | name | ) |
| void YBlock::setType | ( | constTypePtr | type | ) |
References m_type.
| int YBlock::statementCount | ( | ) | const |
References m_statements, and YBlock::stmtlist::next.
Referenced by toStream(), toStringSwitch(), and toXmlSwitch().
| 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.
| str | byte stream to store into |
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().
References environmentToString(), m_statements, YBlock::stmtlist::next, statementCount(), and YBlock::stmtlist::stmt.
| 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.
| 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, 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 |
References m_statements, YBlock::stmtlist::next, Xmlcode::spaces(), statementCount(), and YBlock::stmtlist::stmt.
| constTypePtr YBlock::type | ( | ) | const [inline, virtual] |
stringlist_t* YBlock::m_includes [private] |
Referenced by addIncluded(), isIncluded(), and ~YBlock().
blockkind_t YBlock::m_kind [private] |
Referenced by bkind(), evaluate(), evaluateFrom(), isDefinition(), isFile(), isModule(), isNamespace(), isStatement(), isValue(), setKind(), toStream(), toString(), toXml(), YBlock(), and ~YBlock().
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] |
Referenced by name(), setName(), toStream(), toString(), toXml(), and YBlock().
const Point* YBlock::m_point [private] |
Referenced by endInclude(), filename(), newEntry(), point(), toStream(), toXml(), YBlock(), and ~YBlock().
bool YBlock::m_running [private] |
Referenced by evaluate(), and evaluateFrom().
stmtlist_t* YBlock::m_statements [private] |
Referenced by attachStatement(), evaluate(), evaluateFrom(), justReturn(), pretachStatement(), statementCount(), toStream(), toString(), toStringSwitch(), toXml(), toXmlSwitch(), YBlock(), and ~YBlock().
yTElist_t* YBlock::m_tenvironment [private] |
Referenced by attachEntry(), detachEnvironment(), environmentToString(), toStream(), toXml(), and ~YBlock().
constTypePtr YBlock::m_type [private] |
1.5.9