⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decllist.h

📁 一个面向对像语言的编译器
💻 H
字号:
/*
 *decllist.h
 *----------
 *decllist类定义.不要修改此文件。
*/
#ifndef _H_DeclList
#define _H_DeclList

#include "utility.h"
#include "hashtable.h"
#include "declaration.h"

class Declaration;

class DeclList {

 private:
    Declaration * decls[MaxDecla];
	int loc;
 public:
           // Create a new empty list
    DeclList() {loc=0;}

           // Returns count of elements currently in list

    int NumElements()
	{ return loc;}

          // Returns declaration at index in list. Indexing is 0-based.
          // Raises an assert if index is out of range.
    Declaration *Nth(int index)
	{ Assert(index >= 0 && index < loc);
	  return decls[index];}

          // Inserts declaration at index, shuffling over others
          // Raises assert if index out of range
    void InsertAt(Declaration *d, int index)
	{ Assert(index >= 0 && index <= loc);
	  for(int i=loc+1;i>index;i--)
			decls[i]=decls[i-1];
	  decls[index]=d;
	  loc++;
	}

          // Adds declaration to list end
    void Append(Declaration *d)
	{ 
		decls[loc]=d;
		loc++;
	}

         // Removes declaration at index, shuffling down others
         // Raises assert if index out of range
    void RemoveAt(int index)
	{ Assert(index >= 0 && index < loc);
	  for(int i=index;i<loc;i++)
		decls[i]=decls[i+1];
	  loc--;
	}
    void PrintList(const char *first, const char *separator)
	{ if (first) printf("%s", first);
	  for (int i = 0; i < NumElements(); i++) 
	    printf("%s%s", i != 0 || first ? separator: "", Nth(i)->GetName());
	}
	  

};


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -