public static InterpretatorEndState Iterpretate(string pseudobfProgram, out bool[,] resultMatrix)
		{
			resultMatrix = null;
			if (pseudobfProgram.Length > MaxProgramLength)
				return InterpretatorEndState.TooBigProgramFail;

			var compiled = CompileSource(pseudobfProgram);
			var state = new InterpretatorState();

			while (state.IterationsCount < 10000)
			{
				if (state.ProgramPosition >= compiled.Count)
				{
					resultMatrix = state.Matrix;
					return InterpretatorEndState.Success;
				}

				if (compiled[state.ProgramPosition] == null)
				{
					if (state.Values[state.ValueIdx] == 0)
					{
						resultMatrix = state.Matrix;
						return InterpretatorEndState.Success;
					}

					state.DoNothing();
					continue;
				}

				compiled[state.ProgramPosition](state);
			}

			return InterpretatorEndState.TooMuchTimeFail;
		}
Exemple #2
0
        public static InterpretatorEndState Iterpretate(string pseudobfProgram, out bool[,] resultMatrix)
        {
            resultMatrix = null;
            if (pseudobfProgram.Length > MaxProgramLength)
            {
                return(InterpretatorEndState.TooBigProgramFail);
            }

            var compiled = CompileSource(pseudobfProgram);
            var state    = new InterpretatorState();

            while (state.IterationsCount < 10000)
            {
                if (state.ProgramPosition >= compiled.Count)
                {
                    resultMatrix = state.Matrix;
                    return(InterpretatorEndState.Success);
                }

                if (compiled[state.ProgramPosition] == null)
                {
                    if (state.Values[state.ValueIdx] == 0)
                    {
                        resultMatrix = state.Matrix;
                        return(InterpretatorEndState.Success);
                    }

                    state.DoNothing();
                    continue;
                }

                compiled[state.ProgramPosition](state);
            }

            return(InterpretatorEndState.TooMuchTimeFail);
        }