1
Vote

Permits disabling Optimizations for debuging purposes

description

I have giving strange errors to my scipts executed.

After this patch all is working ok.

I see problem with multiple returns inside a function

like

function foo ()
{
if (some condition)
{
   return 123
}
return 456;
}

and problems with an c# object derived from an ObjectInstance that have an function that returns an ObjectInstance that sometimes is an ArrayInstance, and sometimes is an ObjectInstance, and sometimes is an BooleanInstance (this function can return any type)...

modified ScriptEngine atached.

Added:
    /// <summary>
    /// Gets or sets whether Optimization is disable by the script engine.  If this is set to 
    /// <c>true</c>, script are not optimized by script engine.
    /// </summary>
    /// <remarks>
    /// <para>This property is intended to prevent optimization for debug purposes.</para>
    /// </remarks>
    public bool DisableOptmization
    {
        get;
        set;
    } 
and inside Execute and inside Evaluate modified

from
            if (this.OptimizationStarted != null)
                this.OptimizationStarted(this, EventArgs.Empty);
            methodGen.Optimize();
to
        if (!DisableOptmization)
        {
            if (this.OptimizationStarted != null)
                this.OptimizationStarted(this, EventArgs.Empty);
            methodGen.Optimize();
        }

file attachments

comments

paulbartrum wrote Feb 2, 2012 at 9:54 PM

There was a bug with multiple return statements, but I believe this bug is fixed in the latest source code - can you try building from source and see if the bug still exists?

cmcbf wrote Feb 3, 2012 at 2:29 AM

Not Fixed.

I am using last changeset (39608d99435c - 18/12/2011)

Also there are other bugs that do not appears when optimization is disabled.