示例#1
0
        /// <summary>
        /// Run the interpretation
        /// </summary>
        internal override void Execute()
        {
            var conditionResult = false;

            if (Statement._initializationStatement != null)
            {
                ParentInterpreter.RunStatement(Statement._initializationStatement);
                if (ParentInterpreter.FailedOrStop)
                {
                    return;
                }
            }

            _IterationLoop:

            if (!Statement._conditionAfterBody)
            {
                conditionResult = RunCondition();
                if (!conditionResult)
                {
                    return;
                }
            }

            var block = new BlockInterpreter(Statement._statements, DebugMode, ParentInterpreter.ParentProgramInterpreter, ParentInterpreter.ParentMethodInterpreter, ParentInterpreter.ParentBlockInterpreter, ParentInterpreter.ParentClassInterpreter);
            block.OnGetParentInterpreter += new Func<BlockInterpreter>(() => ParentInterpreter);
            block.StateChanged += ParentInterpreter.ChangeState;
            block.Initialize();
            ReturnOccured = block.Run();
            block.StateChanged -= ParentInterpreter.ChangeState;
            block.Dispose();

            if (ReturnOccured || ParentInterpreter.FailedOrStop)
            {
                return;
            }

            if (Statement._incrementStatement != null)
            {
                ParentInterpreter.RunStatement(Statement._incrementStatement);
            }
            if (ParentInterpreter.FailedOrStop)
            {
                return;
            }

            if (Statement._conditionAfterBody)
            {
                conditionResult = RunCondition();
            }

            if (conditionResult)
            {
                goto _IterationLoop;
            }
        }