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

📄 taclist.h

📁 一个面向对像语言的编译器
💻 H
字号:
/*
 * File: taclist.h
 * ----------------
 * Simple list class for storing a linear collection of TAC instructions. It
 * supports operations similar in name to the CS107 DArray -- nth, insert,
 * append, remove, etc.  This class is nothing more than a very thin
 * cover of a STL deque, with some added range-checking. Given not everyone
 * is familiar with the C++ templates, this class provides a more familiar
 * interface. 
 * 
 */

#ifndef _H_taclist
#define _H_taclist

#include "utility.h"

#define MaxTac 1024
  
class Tac;

class TacList {

 private:
	Tac * tacs[MaxDecla];
	int loc;
 public:
           // Create a new empty list
    TacList() {loc=0;}

           // Returns count of elements currently in list
    int NumElements()
	{ return loc;}

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

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

          // Adds Tac to list end
    void Append(Tac *in)
	{ 
		tacs[loc]=in;
		loc++;
	}

         // Removes Tac 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++)
		tacs[i]=tacs[i+1];
	  loc--;
	 }
};

#endif

⌨️ 快捷键说明

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