예제 #1
0
        /// <summary>
        /// Discards completed data from the buffers.
        /// </summary>
        internal void DiscardCompleted()
        {
            var output = new DiscardCompletedJobOutput();

            new DiscardCompletedJob
            {
                Output           = &output,
                Tokens           = m_Data->Tokens,
                TokenNextIndex   = m_Data->TokenNextIndex,
                TokenParentIndex = m_Data->TokenParentIndex,
                Handles          = m_Data->Handles,
                Buffer           = m_Data->Buffer,
                BufferPosition   = m_Data->BufferPosition
            }
            .Run();

            if (output.Result == k_ResultStackOverflow)
            {
#if !NET_DOTS
                throw new StackOverflowException();
#else
                throw new Exception("Stack Overflow");
#endif
            }

            m_Data->TokenNextIndex   = output.TokenNextIndex;
            m_Data->TokenParentIndex = output.TokenParentIndex;
            m_Data->BufferPosition   = output.BufferPosition;
        }
예제 #2
0
        public void DiscardCompleted(int depth)
        {
            if (m_Data->TokenNextIndex == 0)
            {
                return;
            }

            var output = new DiscardCompletedJobOutput();

            new DiscardCompletedJob
            {
                Output               = &output,
                JsonTokens           = m_Data->JsonTokens,
                Remap                = m_Data->DiscardRemap,
                JsonTokenParentIndex = m_Data->TokenParentIndex,
                JsonTokenNextIndex   = m_Data->TokenNextIndex,
                StackSize            = depth
            }.Run();

            if (output.Result == k_ResultStackOverflow)
            {
                throw new StackOverflowException($"Tokenization depth limit of {depth} exceeded.");
            }

            m_Data->TokenNextIndex   = output.NextTokenIndex;
            m_Data->TokenParentIndex = output.ParentTokenIndex;
        }
예제 #3
0
        public unsafe void DiscardCompleted(int depth)
        {
            var output = new DiscardCompletedJobOutput();

            new DiscardCompletedJob
            {
                Output               = &output,
                JsonTokens           = (Token *)m_JsonTokens.GetUnsafePtr(),
                Remap                = (int *)m_DiscardRemap.GetUnsafePtr(),
                JsonTokenParentIndex = m_TokenParentIndex,
                JsonTokenNextIndex   = m_TokenNextIndex,
                StackSize            = depth
            }.Run();

            if (output.Result == k_ResultStackOverflow)
            {
                throw new StackOverflowException($"Tokenization depth limit of {depth} exceeded.");
            }

            m_TokenNextIndex   = output.NextTokenIndex;
            m_TokenParentIndex = output.ParentTokenIndex;
        }