private void OptimizeFunction(OptFunctionNode theFunction) { if (theFunction.fnode.RequiresActivation()) { return; } inDirectCallFunction = theFunction.IsTargetOfDirectCall(); this.theFunction = theFunction; ObjArray statementsArray = new ObjArray(); BuildStatementList_r(theFunction.fnode, statementsArray); Node[] theStatementNodes = new Node[statementsArray.Size()]; statementsArray.ToArray(theStatementNodes); Block.RunFlowAnalyzes(theFunction, theStatementNodes); if (!theFunction.fnode.RequiresActivation()) { parameterUsedInNumberContext = false; foreach (Node theStatementNode in theStatementNodes) { RewriteForNumberVariables(theStatementNode, NumberType); } theFunction.SetParameterNumberContext(parameterUsedInNumberContext); } }
/// <summary>Returns an array of all functions in the given script.</summary> /// <remarks>Returns an array of all functions in the given script.</remarks> private static DebuggableScript[] GetAllFunctions(DebuggableScript function) { ObjArray functions = new ObjArray(); CollectFunctions_r(function, functions); DebuggableScript[] result = new DebuggableScript[functions.Size()]; functions.ToArray(result); return result; }
private void InitScriptNodesData(ScriptNode scriptOrFn) { ObjArray x = new ObjArray(); CollectScriptNodes_r(scriptOrFn, x); int count = x.Size(); scriptOrFnNodes = new ScriptNode[count]; x.ToArray(scriptOrFnNodes); scriptOrFnIndexes = new ObjToIntMap(count); for (int i = 0; i != count; ++i) { scriptOrFnIndexes.Put(scriptOrFnNodes[i], i); } }