private void Transform(ScriptNode tree)
{
InitOptFunctions_r(tree);
int optLevel = compilerEnv.GetOptimizationLevel();
IDictionary<string, OptFunctionNode> possibleDirectCalls = null;
if (optLevel > 0)
{
if (tree.GetType() == Token.SCRIPT)
{
int functionCount = tree.GetFunctionCount();
for (int i = 0; i != functionCount; ++i)
{
OptFunctionNode ofn = OptFunctionNode.Get(tree, i);
if (ofn.fnode.GetFunctionType() == FunctionNode.FUNCTION_STATEMENT)
{
string name = ofn.fnode.GetName();
if (name.Length != 0)
{
if (possibleDirectCalls == null)
{
possibleDirectCalls = new Dictionary<string, OptFunctionNode>();
}
possibleDirectCalls.Put(name, ofn);
}
}
}
}
}
if (possibleDirectCalls != null)
{
directCallTargets = new ObjArray();
}
OptTransformer ot = new OptTransformer(possibleDirectCalls, directCallTargets);
ot.Transform(tree);
if (optLevel > 0)
{
(new Rhino.Optimizer.Optimizer()).Optimize(tree);
}
}