public static object DoTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
if (scope == null)
{
throw new ArgumentException();
}
if (cx.topCallScope != null)
{
throw new InvalidOperationException();
}
object result;
cx.topCallScope = ScriptableObject.GetTopLevelScope(scope);
cx.useDynamicScope = cx.HasFeature(Context.FEATURE_DYNAMIC_SCOPE);
ContextFactory f = cx.GetFactory();
try
{
result = f.DoTopCall(callable, cx, scope, thisObj, args);
}
finally
{
cx.topCallScope = null;
// Cleanup cached references
cx.cachedXMLLib = null;
if (cx.currentActivationCall != null)
{
// Function should always call exitActivationFunction
// if it creates activation record
throw new InvalidOperationException();
}
}
return result;
}