/*
* 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.model;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class DirectValueActionItem extends ActionItem {
public Object value;
public List constants;
public GraphTargetItem computedRegValue;
public DirectValueActionItem(Object o) {
this(null, 0, o, new ArrayList());
}
public DirectValueActionItem(GraphSourceItem instruction, int instructionPos, Object value, List constants) {
super(instruction, PRECEDENCE_PRIMARY);
this.constants = constants;
this.value = value;
this.pos = instructionPos;
}
@Override
public boolean isVariableComputed() {
if (computedRegValue != null) {
return true;
}
return false;
}
@Override
public Object getResult() {
if (computedRegValue != null) {
return computedRegValue.getResult();
}
if (value instanceof Double) {
return (Double) value;
}
if (value instanceof Float) {
return (double) (Float) value;
}
if (value instanceof Long) {
return (double) (Long) value;
}
if (value instanceof Boolean) {
return value;
}
if (value instanceof String) {
return value;
}
if (value instanceof ConstantIndex) {
return (this.constants.get(((ConstantIndex) value).index));
}
if (value instanceof RegisterNumber) {
return new Undefined(); //has not computed value
}
return value;
}
@Override
public String toStringNoQuotes(boolean highlight, List