Esempio n. 1
0
        /// <summary>
        /// Executes the compiled script.
        /// </summary>
        /// <param name="engine"> The script engine to use to execute the script. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="engine"/> is a <c>null</c> reference. </exception>
        public void Execute(ScriptEngine engine)
        {
            try
            {
                methodGen.Execute(engine);

                // Execute any pending callbacks.
                engine.ExecutePostExecuteSteps();
            }
            finally
            {
                // Ensure the list of post-execute steps is cleared if there is an exception.
                engine.ClearPostExecuteSteps();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the compiled eval code.
        /// </summary>
        /// <param name="engine"> The script engine to use to execute the script. </param>
        /// <returns> The result of the eval. </returns>
        /// <exception cref="ArgumentNullException"> <paramref name="engine"/> is a <c>null</c> reference. </exception>
        public object Evaluate(ScriptEngine engine)
        {
            try
            {
                object result = methodGen.Execute(engine, RuntimeScope.CreateGlobalScope(engine), engine.Global);

                // Execute any pending callbacks.
                engine.ExecutePostExecuteSteps();

                return(TypeUtilities.NormalizeValue(result));
            }
            finally
            {
                // Ensure the list of post-execute steps is cleared if there is an exception.
                engine.ClearPostExecuteSteps();
            }
        }