public virtual void  encode(ActionList actionList)
        {
            // write the actions
            for (int i = 0; i < actionList.size(); i++)
            {
                Action a = actionList.getAction(i);

                switch (a.code)
                {
                // don't update actionCount for synthetic opcodes
                case ActionList.sactionLabel:
                    a.visit(this);
                    break;

                case ActionList.sactionLineRecord:
                    if (debug != null)
                    {
                        debug.offset(writer.Pos, (LineRecord)a);
                    }
                    break;


                case ActionList.sactionRegisterRecord:
                    if (debug != null)
                    {
                        debug.registers(writer.Pos, (RegisterRecord)a);
                    }
                    break;

                // the remaining types need counting

                case flash.swf.ActionConstants_Fields.sactionPush:
                    i = encodePush((Push)a, i, actionList);
                    actionCount++;
                    break;

                default:
                    if (a.code < 0x80)
                    {
                        writer.writeUI8(a.code);
                    }
                    else
                    {
                        a.visit(this);
                    }
                    actionCount++;
                    break;
                }
            }

            patchForwardBranches();
        }
        /// <summary> encode a run of push actions into one action record.  The player
        /// supports this compact encoding since push is such a common
        /// opcode.  the format is:
        ///
        /// sactionPush type1 value1 type2 value2 ...
        ///
        /// </summary>
        /// <param name="push">
        /// </param>
        /// <param name="j">the index of the starting push action
        /// </param>
        /// <param name="actions">
        /// </param>
        /// <returns> the index of the last push action encoded.  the next action will
        /// not be a push action.
        /// </returns>
        public virtual int encodePush(Push push, int j, ActionList actions)
        {
            int updatePos = encodeActionHeader(push);

            do
            {
                System.Object value_Renamed = push.value_Renamed;
                int           type          = Push.getTypeCode(value_Renamed);
                writer.writeUI8(type);

                switch (type)
                {
                case 0:                          // string
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    writer.writeString(value_Renamed.ToString());
                    break;

                case 1:                          // float
                    //UPGRADE_ISSUE: Method 'java.lang.Float.floatToIntBits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangFloatfloatToIntBits_float'"
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    int bits = Float.floatToIntBits((float)((System.Single)value_Renamed));
                    writer.write32(bits);
                    break;

                case 2:                          // null
                    break;

                case 3:                          // undefined
                    break;

                case 4:                          // register
                    writer.writeUI8((int)((System.SByte)value_Renamed) & 0xFF);
                    break;

                case 5:                          // boolean
                    writer.writeUI8(((System.Boolean)value_Renamed)?1:0);
                    break;

                case 6:                          // double
                    double d = ((System.Double)value_Renamed);
                    //UPGRADE_ISSUE: Method 'java.lang.Double.doubleToLongBits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangDoubledoubleToLongBits_double'"
                    long num = Double.doubleToLongBits(d);
                    writer.write32((int)(num >> 32));
                    writer.write32((int)num);
                    break;

                case 7:                          // integer
                    writer.write32(((System.Int32)value_Renamed));
                    break;

                case 8:                          // const8
                    writer.writeUI8((int)((System.Int16)value_Renamed));
                    break;

                case 9:                          // const16
                    writer.writeUI16((int)((System.Int16)value_Renamed) & 0xFFFF);
                    break;
                }

                if (debug == null)
                {
                    // ignore line records if we aren't debugging
                    while (j + 1 < actions.size() && actions.getAction(j + 1).code == ActionList.sactionLineRecord)
                    {
                        j++;
                    }
                }

                Action a;
                if (++j < actions.size() && (a = actions.getAction(j)).code == flash.swf.ActionConstants_Fields.sactionPush)
                {
                    push = (Push)a;
                }
                else
                {
                    push = null;
                }
            }while (push != null);
            updateActionHeader(updatePos);
            return(j - 1);
        }
		/// <summary> encode a run of push actions into one action record.  The player
		/// supports this compact encoding since push is such a common
		/// opcode.  the format is:
		/// 
		/// sactionPush type1 value1 type2 value2 ...
		/// 
		/// </summary>
		/// <param name="push">
		/// </param>
		/// <param name="j">the index of the starting push action
		/// </param>
		/// <param name="actions">
		/// </param>
		/// <returns> the index of the last push action encoded.  the next action will
		/// not be a push action.
		/// </returns>
		public virtual int encodePush(Push push, int j, ActionList actions)
		{
			int updatePos = encodeActionHeader(push);
			do 
			{
				System.Object value_Renamed = push.value_Renamed;
				int type = Push.getTypeCode(value_Renamed);
				writer.writeUI8(type);
				
				switch (type)
				{
					
					case 0:  // string
						//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
						writer.writeString(value_Renamed.ToString());
						break;
					
					case 1:  // float
						//UPGRADE_ISSUE: Method 'java.lang.Float.floatToIntBits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangFloatfloatToIntBits_float'"
						//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
						int bits = Float.floatToIntBits((float) ((System.Single) value_Renamed));
						writer.write32(bits);
						break;
					
					case 2:  // null
						break;
					
					case 3:  // undefined
						break;
					
					case 4:  // register
						writer.writeUI8((int) ((System.SByte) value_Renamed) & 0xFF);
						break;
					
					case 5:  // boolean
						writer.writeUI8(((System.Boolean) value_Renamed)?1:0);
						break;
					
					case 6:  // double
						double d = ((System.Double) value_Renamed);
						//UPGRADE_ISSUE: Method 'java.lang.Double.doubleToLongBits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangDoubledoubleToLongBits_double'"
						long num = Double.doubleToLongBits(d);
						writer.write32((int) (num >> 32));
						writer.write32((int) num);
						break;
					
					case 7:  // integer
						writer.write32(((System.Int32) value_Renamed));
						break;
					
					case 8:  // const8
						writer.writeUI8((int) ((System.Int16) value_Renamed));
						break;
					
					case 9:  // const16
						writer.writeUI16((int) ((System.Int16) value_Renamed) & 0xFFFF);
						break;
					}
				
				if (debug == null)
				{
					// ignore line records if we aren't debugging
					while (j + 1 < actions.size() && actions.getAction(j + 1).code == ActionList.sactionLineRecord)
						j++;
				}
				
				Action a;
				if (++j < actions.size() && (a = actions.getAction(j)).code == flash.swf.ActionConstants_Fields.sactionPush)
				{
					push = (Push) a;
				}
				else
				{
					push = null;
				}
			}
			while (push != null);
			updateActionHeader(updatePos);
			return j - 1;
		}
		public virtual void  encode(ActionList actionList)
		{
			// write the actions
			for (int i = 0; i < actionList.size(); i++)
			{
				Action a = actionList.getAction(i);
				
				switch (a.code)
				{
					
					// don't update actionCount for synthetic opcodes
					case ActionList.sactionLabel: 
						a.visit(this);
						break;
					
					case ActionList.sactionLineRecord: 
						if (debug != null)
							debug.offset(writer.Pos, (LineRecord) a);
						break;
					
					
					case ActionList.sactionRegisterRecord: 
						if (debug != null)
							debug.registers(writer.Pos, (RegisterRecord) a);
						break;
						
						// the remaining types need counting
					
					case flash.swf.ActionConstants_Fields.sactionPush: 
						i = encodePush((Push) a, i, actionList);
						actionCount++;
						break;
					
					default: 
						if (a.code < 0x80)
							writer.writeUI8(a.code);
						else
							a.visit(this);
						actionCount++;
						break;
					
				}
			}
			
			patchForwardBranches();
		}