private void CollapsPushActions(ArrayList actionRecord)
{
int i = 0;
bool isPush;
while (i<(actionRecord.Count-1)) {
isPush = actionRecord[i] is ActionPush;
if (isPush) {
int j = i;
int count = 1;
do {
i++;
if (i<actionRecord.Count) {
isPush=(actionRecord[i] is ActionPush);
if (isPush) count++;
}
} while ((isPush)&&(i<actionRecord.Count));
if (count>1) {
ActionPush[] pushList = new ActionPush[count];
actionRecord.CopyTo(j,pushList,0,count);
actionRecord.RemoveRange(j,count);
ActionPushList pl = new ActionPushList(pushList);
actionRecord.Insert(j,pl);
i=j+1;
}
} else {
// recursively step through functions inner actions
ActionDefineFunction f = actionRecord[i] as ActionDefineFunction;
if (f!=null) CollapsPushActions(f.ActionRecord);
// and function2 of course
ActionDefineFunction2 f2 = actionRecord[i] as ActionDefineFunction2;
if (f2!=null) CollapsPushActions(f2.ActionRecord);
i++;
}
}
}