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();
}