Beispiel #1
0
        /// <inheritdoc />
        protected override EvaluationResult DoEval(Context context, ModuleLiteral env, EvaluationStackFrame frame)
        {
            var condition = Condition.Eval(context, env, frame);

            if (condition.IsErrorValue)
            {
                return(condition);
            }

            // TODO:ST: I don't think this condition is correct.
            // In this case the result would be 1: const x = 1; const y = if (false) {x++;}else{x++;}
            // if statement is a statement, the result always should be void or undefined.
            return(Expression.IsTruthy(condition)
                ? ThenStatement.Eval(context, env, frame)
                : ((ElseStatement == null) ? EvaluationResult.Undefined : ElseStatement.Eval(context, env, frame)));
        }