Exemple #1
0
		public override ExecuteResult Execute(Space space) {
			var tempSpace = new Space(SpaceType.Loop, space);
			while (true) {
				tempSpace.Clear();
				var ret = _sentence.Execute(tempSpace);
				if (!IsSuccess(ret)) {
					ErrorLogger.LogRuntimeError(ErrorRuntimeCode.DoWhile, "The sentence execute failed!");
					return ExecuteResult.Failed;
				}
				if (ret == ExecuteResult.Break) {
					break;
				}
				if (ret == ExecuteResult.Return) {
					SetReturnValue((_sentence as SentenceReturn).returnValue);
					tempSpace.Clear();
					return ExecuteResult.Return;
				}
				if (!IsSuccess(_expression.Execute(space))) {
					ErrorLogger.LogRuntimeError(ErrorRuntimeCode.DoWhile, "The condition expression execute failed!");
					return ExecuteResult.Failed;
				}
				if (!ValueTool.ToLogic(_expression.value)) {
					break;
				}
			}
			tempSpace.Clear();
			return ExecuteResult.Successed;
		}
		public override ExecuteResult Execute(Space space) {
			if (!IsSuccess(_expression.Execute(space))) {
				ErrorLogger.LogRuntimeError(ErrorRuntimeCode.Condition, "The condition expression execute failed!");
				return ExecuteResult.Failed;
			}
			bool bTrue = ValueTool.ToLogic(_expression.value);
			var tempSentence = bTrue ? _sentenceTrue : _sentenceFalse;
			if (tempSentence) {
				var tempSpace = new Space(SpaceType.Condition, space);
				var executeRet = tempSentence.Execute(tempSpace);
				if (!IsSuccess(executeRet)) {
					ErrorLogger.LogRuntimeError(ErrorRuntimeCode.Condition, bTrue ? "The 'true' code sentence execute failed!" : "The 'false' code sentence execute failed!");
					return ExecuteResult.Failed;
				}
				if (executeRet == ExecuteResult.Return) {
					SetReturnValue((tempSentence as SentenceReturn).returnValue);
					return ExecuteResult.Return;
				}
				if (executeRet == ExecuteResult.Continue) {
					return ExecuteResult.Continue;
				}
				if (executeRet == ExecuteResult.Break) {
					return ExecuteResult.Break;
				}
				tempSpace.Clear();
			}
			
			return ExecuteResult.Successed;
		}
Exemple #3
0
		public override ExecuteResult Execute(Space space) {
			if (!IsSuccess(_expression.Execute(space))) {
				ErrorLogger.LogRuntimeError(ErrorRuntimeCode.ExpressionNot, "The [not-expression] execute failed!");
				return ExecuteResult.Failed;
			}

			var ret = ValueTool.ToLogic(_expression.value);
			SetValue(new ValueBool(!ret));

			return ExecuteResult.Successed;
		}
Exemple #4
0
		public override ExecuteResult Execute(Space space) {
			var tempSpace = new Space(SpaceType.Loop, space);
			if (_sentence0) {
				if (!IsSuccess(_sentence0.Execute(tempSpace))) {
					ErrorLogger.LogRuntimeError(ErrorRuntimeCode.For, "The 'sentence0' of 'for' execute failed!");
					return ExecuteResult.Failed;
				}
			}

			var contentSpace = new Space(SpaceType.Loop, tempSpace);
			while (true) {
				if (_expression0) {
					if (!IsSuccess(_expression0.Execute(tempSpace))) {
						ErrorLogger.LogRuntimeError(ErrorRuntimeCode.For, "The condition0-expression of 'for' execute failed!");
						return ExecuteResult.Failed;
					}
					if (!ValueTool.ToLogic(_expression0.value)) {
						break;
					}
				}
				if (_content) {
					contentSpace.Clear();
					var ret = _content.Execute(contentSpace);
					if (!IsSuccess(ret)) {
						ErrorLogger.LogRuntimeError(ErrorRuntimeCode.For, "The sentence of 'for' execute failed!");
						return ExecuteResult.Failed;
					}
					if (ret == ExecuteResult.Break) {
						break;
					}
					if (ret == ExecuteResult.Return) {
						SetReturnValue((_content as SentenceReturn).returnValue);
						tempSpace.Clear();
						return ExecuteResult.Return;
					}
				}
				if (_expression1) {
					if (!IsSuccess(_expression1.Execute(tempSpace))) {
						ErrorLogger.LogRuntimeError(ErrorRuntimeCode.For, "The condition1-expression of 'for' execute failed!");
						return ExecuteResult.Failed;
					}
				}
			}
			tempSpace.Clear();
			return ExecuteResult.Successed;
		}