本文整理汇总了C++中SymTab::end方法的典型用法代码示例。如果您正苦于以下问题:C++ SymTab::end方法的具体用法?C++ SymTab::end怎么用?C++ SymTab::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymTab
的用法示例。
在下文中一共展示了SymTab::end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typeCheck
Type* GlobalEntry::typeCheck(){
SymTab* st = this->symTab();
for(SymTab::iterator i = st->begin(); i != st->end(); ++i){
(*i)->typeCheck();
}
//Loops over all Rules
for(unsigned int x = 0; x < rules_.size();++x){
rules_[x]->typeCheck();
}
return NULL;
}
示例2: generateDecls
/* generate declarations for global variables used in the program */
void generateDecls( const SymTab &curSymTab )
{
for ( SymTab::const_iterator curSym = curSymTab.begin( );
curSym != curSymTab.end( ); ++curSym ) {
if ( curSym -> second.isReg( ) == true
|| curSym -> second.Type( ) == FUNC
|| curSym -> second.isLocal( ) )
continue;
curSym -> second.declare( curSym -> first );
}
cout << "\n\n";
}
示例3: memAlloc
void EventEntry::memAlloc(MemoryMgr &mm){
memory_mgr_ = MemoryMgr();
//cout << "Event memAlloc" << endl;
SymTab* st = this->symTab();
if(st!=NULL){
for(SymTab::iterator i = st->begin(); i != st->end();++i){
if((*i)->kind()==SymTabEntry::Kind::VARIABLE_KIND){
VariableEntry* ve = (VariableEntry*) (*i);
if(ve->varKind()==VariableEntry::VarKind::PARAM_VAR){
ve->offSet(memory_mgr_.getNextAddress());
}
}
}
}
}
示例4: visit
void
Doxygen::annotate(SgProject *n)
{
typedef map<string, map<SgDeclarationStatement *, list<DoxygenComment *> *> > SymTab;
/* The first pass finds declarations in the AST, adds them to a
* rudimentary symbol table and attaches any doxygen comments situated next
* to the declaration. The advantage of building our own symbol table
* is that we do not need to know the exact type of overloaded functions.
* This comes in handy when doing inexact matches (3rd pass).
*/
SymTab symTab;
list<DoxygenComment *> commentList;
PureDocumentationFileListAttribute *attr = new PureDocumentationFileListAttribute();
//Find declarations in the AST with doxygen comments attached. This will not find the
//detached comments in a separate .docs file.
class CollectDeclarations : public AstSimpleProcessing
{
public:
SymTab *symTab;
virtual void visit(SgNode *n)
{
SgDeclarationStatement *st = isSgDeclarationStatement(n);
if (!st)
{
return;
}
if (!isRecognizedDeclaration(st))
{
return;
}
string proto = getProtoName(st);
SgDeclarationStatement *dxSt = getDoxygenAttachedDeclaration(st);
if ((*symTab)[proto].count(dxSt) == 0)
{
DoxygenCommentListAttribute *attr = new DoxygenCommentListAttribute();
// King84 (2010.08.03) : This seems to be called with the same node multiple times.
// From what I can tell, this is because a single function has been documented multiple times.
// At the moment this function is AssemblerX86::AssemblerX86() from src/frontend/Disassemblers/AssemblerX86.h
// For now, we will print out a warning and use the new documentation (instead of addNewAttribute we use setAttribute).
if (dxSt->attributeExists("DoxygenCommentList"))
{
std::cerr << "Warning: Multiple Doxygen comments found for function " << dxSt->get_mangled_name().getString() << " at file " << dxSt->get_file_info()->get_filenameString() << ":" << dxSt->get_file_info()->get_line() << "," << dxSt->get_file_info()->get_col() << ". Picking the last." << std::endl;
}
dxSt->setAttribute("DoxygenCommentList", attr);
// dxSt->addNewAttribute("DoxygenCommentList", attr);
(*symTab)[proto][dxSt] = &(attr->commentList);
}
list<DoxygenComment *> *commentList = (*symTab)[proto][dxSt];
AttachedPreprocessingInfoType *info = st->getAttachedPreprocessingInfo();
if (info)
{
for (AttachedPreprocessingInfoType::iterator i = info->begin(); i != info->end(); ++i)
{
PreprocessingInfo *pi = *i;
if (pi->getRelativePosition() == PreprocessingInfo::before && DoxygenComment::isDoxygenComment(pi))
{
commentList->push_back(new DoxygenComment(st, pi));
}
}
}
}
};
//Find the detached comments in .docs files
class FindDetachedComments : public AstSimpleProcessing
{
public:
list<DoxygenComment *> *commentList;
map<string, DoxygenFile *> *docsList;
virtual void
visit(SgNode *n)
{
SgVariableDeclaration *vd = isSgVariableDeclaration(n);
if (!vd)
{
return;
}
if (isRecognizedDeclaration(vd))
{
return;
}
AttachedPreprocessingInfoType *info = vd->getAttachedPreprocessingInfo();
if (info)
{
DoxygenFile *f = new DoxygenFile(vd);
DoxygenGroup *currentGroup = 0;
DoxygenComment *groupComment = 0;
(*docsList)[vd->get_file_info()->get_filenameString()] = f;
for (AttachedPreprocessingInfoType::iterator i = info->begin(); i != info->end(); ++i)
{
PreprocessingInfo *pi = *i;
//.........这里部分代码省略.........
示例5: codeGen
CodeBlock* GlobalEntry::codeGen(){
CodeBlock* main_block = new CodeBlock();
//--------------Init stack and base pointers--------------
ICode set_stack(ICode::ICodeType::MOVI,new Value(0,Type::TypeTag::UINT),&MemoryMgr::stackPointerRegister());
ICode set_base(ICode::ICodeType::MOVI,new Value(0,Type::TypeTag::UINT),&MemoryMgr::basePointerRegister());
main_block->append(set_stack);
main_block->append(set_base);
//----------------------Declarations----------------------
//Loops over all declarations
SymTab* st = this->symTab();
//Separates FunctionEntries from the other types
vector<CodeBlock*> function_blocks;
vector<CodeBlock*> other_blocks;
for(SymTab::iterator i = st->begin(); i != st->end(); ++i){
CodeBlock* cb = (*i)->codeGen();
if((*i)->kind() == SymTabEntry::Kind::FUNCTION_KIND){
function_blocks.push_back(cb);
} else {
other_blocks.push_back(cb);
}
}
for(unsigned int x = 0; x < other_blocks.size();++x){
main_block->append(other_blocks[x]);
}
ICode jmp_start(ICode::ICodeType::JMP,parse_label_);
main_block->append(jmp_start);
for(unsigned int x = 0; x < function_blocks.size();++x){
main_block->append(function_blocks[x]);
}
//---------------------Event Matching---------------------
// Reads in character
CodeBlock* input_block = new CodeBlock();
ICode read_in(ICode::ICodeType::IN,&in_reg_);
//If negative, then reached end of file
ICode* check_neg = new ICode(ICode::ICodeType::GT,new Value(0,Type::TypeTag::INT),&in_reg_);
ICode end_jmp(ICode::ICodeType::JMPC,check_neg,end_label_);
input_block->append(read_in);
input_block->append(end_jmp);
input_block->setStartLabel(parse_label_);
CodeBlock* rule_block;
// Named rules
for(unsigned int i = 0; i < rule_names_.size(); ++i){
rule_block = new CodeBlock();
// Moves the string constant to the register
ICode mov_string(ICode::ICodeType::MOVI,new Value((int)(rule_names_[i].at(0)),Type::TypeTag::INT),&comp_reg_);
// Comparison
ICode* compare = new ICode(ICode::ICodeType::EQ,&comp_reg_,&in_reg_);
//Conditionally jumps
ICode jmpc(ICode::ICodeType::JMPC,compare,rule_labels_[i]);
rule_block->append(mov_string);
rule_block->append(jmpc);
rule_block->setEndLabel(rule_return_labels_[i]);
input_block->append(rule_block);
}
// "Any" rules
for(unsigned int i = 0; i < any_labels_.size(); ++i){
rule_block = new CodeBlock();
//Jumps to any rule body
ICode jmp(ICode::ICodeType::JMP,any_labels_[i]);
rule_block->append(jmp);
rule_block->setEndLabel(any_return_labels_[i]);
input_block->append(rule_block);
}
input_block->append(jmp_start);
main_block->append(input_block);
//------------------------Rules------------------------
//Loops over all Rules
for(unsigned int x = 0; x < rules_.size();++x){
main_block->append(rules_[x]->codeGen());
}
//---------------------End program---------------------
//Do the end jump here
CodeBlock* end_block = new CodeBlock();
ICode print_end(ICode::ICodeType::PRTS,new Value("PROGRAM END\\n"));
end_block->setStartLabel(end_label_);
end_block->append(print_end);
main_block->append(end_block);
//.........这里部分代码省略.........