public FlowScriptBinary Build()
        {
            // Pad out this section first before building the string section header
            if (mStringSection != null)
            {
                while ((mStringSection.Count % 16) != 0)
                {
                    mStringSection.Add(0);
                }
            }

            var binary = new FlowScriptBinary
            {
                mHeader         = BuildHeader(),
                mSectionHeaders = BuildSectionHeaders(),
                mFormatVersion  = mFormatVersion
            };

            // Copy the section data to the binary
            if (mProcedureLabelSection != null)
            {
                binary.mProcedureLabelSection = mProcedureLabelSection.ToArray();
            }

            if (mJumpLabelSection != null)
            {
                binary.mJumpLabelSection = mJumpLabelSection.ToArray();
            }

            if (mTextSection != null)
            {
                binary.mTextSection = mTextSection.ToArray();
            }

            if (mMessageScriptSection != null)
            {
                binary.mMessageScriptSection = mMessageScriptSection;
            }

            if (mStringSection != null)
            {
                binary.mStringSection = mStringSection.ToArray();
            }

            return(binary);
        }
        public FlowScriptBinary Build()
        {
            // Pad out this section first before building the string section header
            if (mStringSection != null)
            {
                while ((mStringSection.Count % 16) != 0)
                {
                    mStringSection.Add(0);
                }
            }

            if (mMatching)
            {
                // add return instruction at end
                mTextSection.Add(new BinaryInstruction()
                {
                    Opcode = Opcode.END
                });

                // apply string section padding
                while (mStringSection.Count < 0xF0)
                {
                    mStringSection.Add(0);
                }
            }

            var binary = new FlowScriptBinary
            {
                mHeader         = BuildHeader(),
                mSectionHeaders = BuildSectionHeaders(),
                mFormatVersion  = mFormatVersion
            };

            // Copy the section data to the binary
            if (mProcedureLabelSection != null)
            {
                binary.mProcedureLabelSection = mProcedureLabelSection.ToArray();
            }

            if (mJumpLabelSection != null)
            {
                binary.mJumpLabelSection = mJumpLabelSection.ToArray();
            }

            if (mTextSection != null)
            {
                binary.mTextSection = mTextSection.ToArray();
            }

            if (mMessageScriptSection != null)
            {
                binary.mMessageScriptSection = mMessageScriptSection;
            }

            if (mStringSection != null)
            {
                binary.mStringSection = mStringSection.ToArray();
            }

            return(binary);
        }