Exemplo n.º 1
0
        /// <summary>
        /// Gets the return value from calling a function.
        /// </summary>
        /// <param name="scope">The scope object containing variable values.</param>
        /// <param name="result">[out] The new expression containing the function result.</param>
        /// <returns>
        ///   <c>true</c> if invocation was successful, <c>false</c> if something went wrong, in which case <paramref name="result" /> will likely be a <see cref="ParseErrorExpression" />.
        /// </returns>
        public bool Evaluate(InterpreterScope scope, out ExpressionBase result)
        {
            bool inAssignment = (scope.GetInterpreterContext <AssignmentExpression>() != null);

            if (inAssignment && _fullyExpanded)
            {
                // this function call is already fully expanded, allow it to be assigned without re-evaluating
                result = this;
            }
            else
            {
                if (!Evaluate(scope, inAssignment, out result))
                {
                    return(false);
                }
            }

            return(true);
        }