/*
* Copyright (C) 2010-2013 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.jpexs.decompiler.flash.action.swf7;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.parser.ASMParser;
import com.jpexs.decompiler.flash.action.parser.FlasmLexer;
import com.jpexs.decompiler.flash.action.parser.Label;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.special.ActionContainer;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
import com.jpexs.decompiler.flash.action.treemodel.FunctionTreeItem;
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
import com.jpexs.decompiler.flash.helpers.Helper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionDefineFunction2 extends Action implements ActionContainer {
public String functionName;
public List paramNames = new ArrayList();
public List paramRegisters = new ArrayList();
public boolean preloadParentFlag;
public boolean preloadRootFlag;
public boolean suppressSuperFlag;
public boolean preloadSuperFlag;
public boolean suppressArgumentsFlag;
public boolean preloadArgumentsFlag;
public boolean suppressThisFlag;
public boolean preloadThisFlag;
public boolean preloadGlobalFlag;
public int registerCount;
public int codeSize;
public List code;
private int version;
public List constantPool;
public void setConstantPool(List constantPool) {
this.constantPool = constantPool;
for (Action a : code) {
if (a instanceof ActionPush) {
((ActionPush) a).constantPool = constantPool;
}
if (a instanceof ActionDefineFunction2) {
((ActionDefineFunction2) a).setConstantPool(constantPool);
}
if (a instanceof ActionDefineFunction) {
((ActionDefineFunction) a).setConstantPool(constantPool);
}
}
}
public ActionDefineFunction2(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8E, actionLength);
this.version = version;
functionName = sis.readString();
int numParams = sis.readUI16();
registerCount = sis.readUI8();
preloadParentFlag = sis.readUB(1) == 1;
preloadRootFlag = sis.readUB(1) == 1;
suppressSuperFlag = sis.readUB(1) == 1;
preloadSuperFlag = sis.readUB(1) == 1;
suppressArgumentsFlag = sis.readUB(1) == 1;
preloadArgumentsFlag = sis.readUB(1) == 1;
suppressThisFlag = sis.readUB(1) == 1;
preloadThisFlag = sis.readUB(1) == 1;
sis.readUB(7);//reserved
preloadGlobalFlag = sis.readUB(1) == 1;
for (int i = 0; i < numParams; i++) {
paramRegisters.add(sis.readUI8());
paramNames.add(sis.readString());
}
codeSize = sis.readUI16();
//code = new ArrayList();
code = (new SWFInputStream(new ByteArrayInputStream(sis.readBytes(codeSize)), version)).readActionList();
}
public ActionDefineFunction2(boolean ignoreNops, List