Esempio n. 1
0
 /// <summary>
 /// 表达式式执行
 /// </summary>
 public IOperand Execute()
 {
     Analyze();
     return(_eval.ExpressionEvaluate(_link_OP.Head, _link_OP.Tail));
 }
Esempio n. 2
0
        /// <summary>
        /// IF语句语法 if(JudgeExpression,TrueExpression,FalseExpression)
        /// JudgeExpression 为 true 返回 TrueExpression 否则 返回 FalseExpression
        /// </summary>
        /// <param name="startLink">语句开始标记</param>
        /// <param name="endLink">语句结束标记</param>
        /// <returns></returns>
        public IOperand Key_IF(TOKENLink startLink, out TOKENLink endLink)
        {
            //分离表达式
            IOperand         result;
            List <TOKENLink> commaList;

            Key_Analyze(startLink.Next, out endLink, out commaList);

            //执行 JudgeExpression 表达式 - 此处必需表达式有值
            IOperand judgeResult = _eval.ExpressionEvaluate(startLink.Next.Next, commaList[0].Prev);

            if (judgeResult != null && judgeResult.Type == EDataType.Dbool && ((Operand <bool>)judgeResult).TValue == true)
            {
                //执行 TrueExpression 表达式
                result = _eval.ExpressionEvaluate(commaList[0].Next, commaList[1].Prev);
            }
            else
            {
                //执行 FalseExpression 表达式
                result = _eval.ExpressionEvaluate(commaList[1].Next, endLink.Prev);
            }

            return(result);
        }