diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java index d226d7c2e..fc23757b0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.treemodel.GetTimeTreeItem; import com.jpexs.decompiler.flash.action.treemodel.SimpleActionTreeItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; @@ -36,6 +37,6 @@ public class ActionGetTime extends Action { @Override public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { - stack.push(new SimpleActionTreeItem(this, "getTimer()")); + stack.push(new GetTimeTreeItem(this)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CharToAsciiTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CharToAsciiTreeItem.java index 218e8b9f0..a3f30ca6f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CharToAsciiTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/CharToAsciiTreeItem.java @@ -40,4 +40,38 @@ public class CharToAsciiTreeItem extends TreeItem { ret.addAll(value.getNeededSources()); return ret; } + + @Override + public boolean isCompileTime() { + if (value instanceof DirectValueTreeItem) { + DirectValueTreeItem dv = (DirectValueTreeItem) value; + if (dv.value instanceof String) { + String s = (String) dv.value; + if (s.length() > 0) { + return true; + } + } + } + return false; + } + + @Override + public double toNumber() { + if (value instanceof DirectValueTreeItem) { + DirectValueTreeItem dv = (DirectValueTreeItem) value; + if (dv.value instanceof String) { + String s = (String) dv.value; + if (s.length() > 0) { + char c = s.charAt(0); + return (int) c; + } + } + } + return 0; + } + + @Override + public boolean toBoolean() { + return toNumber() != 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetTimeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetTimeTreeItem.java new file mode 100644 index 000000000..74043d880 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/GetTimeTreeItem.java @@ -0,0 +1,47 @@ +/* + * 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.treemodel; + +import com.jpexs.decompiler.flash.graph.GraphSourceItem; +import java.util.Random; + +public class GetTimeTreeItem extends TreeItem { + + public GetTimeTreeItem(GraphSourceItem instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } + + @Override + public String toString(ConstantPool constants) { + return hilight("getTimer()"); + } + + @Override + public boolean isCompileTime() { + return true; + } + + @Override + public double toNumber() { + return new Random().nextInt(10000) + 1000; + } + + @Override + public boolean toBoolean() { + return true; + } +}