#349 AS3 - better handling of declarations

This commit is contained in:
Jindra Petřík
2021-02-08 20:15:19 +01:00
parent 6f19d50572
commit 43885a1a40
28 changed files with 397 additions and 105 deletions
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -63,6 +65,12 @@ public class ClassActionItem extends ActionItem implements Block {
return ret;
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
public ClassActionItem(GraphTargetItem className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, List<MyEntry<GraphTargetItem, GraphTargetItem>> traits, List<Boolean> traitsStatic) {
super(null, null, NOPRECEDENCE);
this.className = className;
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SWF;
@@ -35,6 +36,7 @@ import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.Loop;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
@@ -66,6 +68,22 @@ public class ForInActionItem extends LoopActionItem implements Block {
return ret;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
visitor.visit(variableName);
visitor.visit(enumVariable);
visitor.visitAll(commands);
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(variableName);
visitor.visit(enumVariable);
}
public ForInActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, GraphTargetItem variableName, GraphTargetItem enumVariable, List<GraphTargetItem> commands) {
super(instruction, lineStartIns, loop);
this.variableName = variableName;
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -46,6 +48,19 @@ public class IfFrameLoadedActionItem extends ActionItem implements Block {
this.frame = frame;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
visitor.visit(frame);
visitor.visitAll(actions);
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(frame);
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("ifFrameLoaded");
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SWF;
@@ -39,6 +40,7 @@ import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -76,6 +78,26 @@ public class TryActionItem extends ActionItem implements Block {
return ret;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
if (tryCommands != null) {
visitor.visitAll(tryCommands);
}
for (List<GraphTargetItem> cc : catchCommands) {
visitor.visitAll(cc);
}
if (finallyCommands != null) {
visitor.visitAll(finallyCommands);
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
public TryActionItem(List<GraphTargetItem> tryCommands, List<GraphTargetItem> catchExceptionNames, List<GraphTargetItem> catchExceptionTypes, List<List<GraphTargetItem>> catchCommands, List<GraphTargetItem> finallyCommands) {
super(null, null, NOPRECEDENCE);
this.tryCommands = tryCommands;