public ActionList(bool keepOffsets, int capacity)
		{
			if (keepOffsets)
				offsets = new int[capacity];
			actions = new Action[capacity];
			size_Renamed_Field = 0;
		}
Esempio n. 2
0
 public ActionList(bool keepOffsets, int capacity)
 {
     if (keepOffsets)
     {
         offsets = new int[capacity];
     }
     actions            = new Action[capacity];
     size_Renamed_Field = 0;
 }
Esempio n. 3
0
        public virtual void  append(Action a)
        {
            int i = size_Renamed_Field;

            if (i == actions.Length)
            {
                grow(size_Renamed_Field * 2);
            }
            actions[i]         = a;
            size_Renamed_Field = i + 1;
        }
Esempio n. 4
0
        public virtual void  grow(int capacity)
        {
            if (offsets != null)
            {
                int[] newoffsets = new int[capacity];
                Array.Copy(offsets, 0, newoffsets, 0, size_Renamed_Field);
                offsets = newoffsets;
            }

            Action[] newactions = new Action[capacity];
            Array.Copy(actions, 0, newactions, 0, size_Renamed_Field);
            actions = newactions;
        }
Esempio n. 5
0
        /// <summary> Return the index within this action list of the first
        /// occurence of the specified actionCode, searching backward
        /// starting at the given index
        /// </summary>
        public virtual int lastIndexOf(int actionCode, int startAt)
        {
            int at = -1;

            for (int i = startAt; at < 0 && i >= 0; i--)
            {
                Action a = getAction(i);
                if (a != null && a.code == actionCode)
                {
                    at = i;
                }
            }
            return(at);
        }
Esempio n. 6
0
        /// <summary> Return the index within this action list of the first
        /// occurence of the specified actionCode, searching foward
        /// starting at the given index
        /// </summary>
        public virtual int indexOf(int actionCode, int startAt)
        {
            int at = -1;

            for (int i = startAt; at < 0 && i < actions.Length; i++)
            {
                Action a = getAction(i);
                if (a != null && a.code == actionCode)
                {
                    at = i;
                }
            }
            return(at);
        }
Esempio n. 7
0
        public virtual void  insert(int offset, Action a)
        {
            if (size_Renamed_Field == actions.Length)
            {
                grow(size_Renamed_Field * 2);
            }
            int i;

            if (size_Renamed_Field == 0 || offsets == null && offset == size_Renamed_Field || offsets != null && offset > offsets[size_Renamed_Field - 1])
            {
                // appending.
                i = size_Renamed_Field;
            }
            else
            {
                i = find(offset);
                if (i < 0)
                {
                    // offset not used yet.  compute insertion point
                    i = -i - 1;
                }
                else
                {
                    // offset already used.  if we are inserting a real action, make it be last
                    if (a.code < 256)
                    {
                        // this is a real action, we want it to be last at this offset
                        while (i < size_Renamed_Field && offsets[i] == offset)
                        {
                            i++;
                        }
                    }
                }
                if (offsets != null)
                {
                    Array.Copy(offsets, i, offsets, i + 1, size_Renamed_Field - i);
                }
                Array.Copy(actions, i, actions, i + 1, size_Renamed_Field - i);
            }
            if (offsets != null)
            {
                offsets[i] = offset;
            }
            actions[i] = a;
            size_Renamed_Field++;
        }
Esempio n. 8
0
 public virtual void  visit(ActionHandler handler, int startIndex, int endIndex)
 {
     endIndex = (endIndex < 0)?size_Renamed_Field - 1:endIndex;
     for (int j = startIndex; j <= endIndex; j++)
     {
         Action a = actions[j];
         if (a.code != sactionLabel && a.code != sactionLineRecord)
         {
             // don't call this for labels
             if (offsets != null)
             {
                 handler.setActionOffset(offsets[j], a);
             }
             else
             {
                 handler.setActionOffset(j, a);
             }
         }
         a.visit(handler);
     }
 }
Esempio n. 9
0
 public override void  setActionOffset(int offset, Action a)
 {
     insert(offset, a);
 }
Esempio n. 10
0
 public virtual void  setAction(int i, Action action)
 {
     actions[i] = action;
 }
Esempio n. 11
0
		public virtual void  grow(int capacity)
		{
			if (offsets != null)
			{
				int[] newoffsets = new int[capacity];
				Array.Copy(offsets, 0, newoffsets, 0, size_Renamed_Field);
				offsets = newoffsets;
			}
			
			Action[] newactions = new Action[capacity];
			Array.Copy(actions, 0, newactions, 0, size_Renamed_Field);
			actions = newactions;
		}
Esempio n. 12
0
		public override void  setActionOffset(int offset, Action a)
		{
			insert(offset, a);
		}
Esempio n. 13
0
		public virtual void  setAction(int i, Action action)
		{
			actions[i] = action;
		}
Esempio n. 14
0
		public virtual void  append(Action a)
		{
			int i = size_Renamed_Field;
			if (i == actions.Length)
				grow(size_Renamed_Field * 2);
			actions[i] = a;
			size_Renamed_Field = i + 1;
		}
Esempio n. 15
0
		public virtual void  insert(int offset, Action a)
		{
			if (size_Renamed_Field == actions.Length)
				grow(size_Renamed_Field * 2);
			int i;
			if (size_Renamed_Field == 0 || offsets == null && offset == size_Renamed_Field || offsets != null && offset > offsets[size_Renamed_Field - 1])
			{
				// appending.
				i = size_Renamed_Field;
			}
			else
			{
				i = find(offset);
				if (i < 0)
				{
					// offset not used yet.  compute insertion point
					i = - i - 1;
				}
				else
				{
					// offset already used.  if we are inserting a real action, make it be last
					if (a.code < 256)
					{
						// this is a real action, we want it to be last at this offset
						while (i < size_Renamed_Field && offsets[i] == offset)
							i++;
					}
				}
				if (offsets != null)
					Array.Copy(offsets, i, offsets, i + 1, size_Renamed_Field - i);
				Array.Copy(actions, i, actions, i + 1, size_Renamed_Field - i);
			}
			if (offsets != null)
				offsets[i] = offset;
			actions[i] = a;
			size_Renamed_Field++;
		}