@Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   if (namespace != null) {
     namespace.toString(writer, localData);
     writer.append("::");
   } else {
     /*Namespace ns = constants.getMultiname(multinameIndex).getNamespace(constants);
     if ((ns != null)&&(ns.name_index!=0)) {
     ret =  hilight(ns.getName(constants) + "::")+ret;
     }*/
   }
   if (name != null) {
     writer.append("[");
     name.toString(writer, localData);
     writer.append("]");
   } else {
     AVM2ConstantPool constants = localData.constantsAvm2;
     List<DottedChain> fullyQualifiedNames =
         property ? new ArrayList<>() : localData.fullyQualifiedNames;
     if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) {
       writer.append(
           constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false));
     } else {
       writer.append("§§unknown_multiname");
     }
   }
   return writer;
 }
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   writer.append("printAsBitmapNum");
   writer.spaceBeforeCallParenthesies(2);
   writer.append("(");
   num.toString(writer, localData);
   writer.append(",");
   boundingBox.toString(writer, localData);
   return writer.append(")");
 }
 @Override
 public void translate(
     TranslateStack stack,
     List<GraphTargetItem> output,
     HashMap<Integer, String> regNames,
     HashMap<String, GraphTargetItem> variables,
     HashMap<String, GraphTargetItem> functions,
     int staticOperation,
     String path) {
   GraphTargetItem value = stack.peek();
   stack.push(new DuplicateItem(this, value));
   value.getMoreSrc().add(new GraphSourceItemPos(this, 0));
 }
Exemplo n.º 4
0
  public void getValueStr(
      Trait parent, GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames)
      throws InterruptedException {
    if (assignedValue != null) {
      if (parent instanceof TraitClass) {
        TraitClass tc = (TraitClass) parent;
        int traitInitId =
            abc.class_info.get(tc.class_info).static_traits.traits.size()
                + abc.instance_info.get(tc.class_info).instance_traits.traits.size()
                + 1;
        int initMethod = abc.class_info.get(tc.class_info).cinit_index;
        writer.startTrait(traitInitId);
        writer.startMethod(initMethod);
        if (Configuration.showMethodBodyId.get()) {
          writer.appendNoHilight("// method body id: ");
          writer.appendNoHilight(abc.findBodyIndex(initMethod));
          writer.newLine();
        }
      }
      assignedValue.toString(
          writer,
          LocalData.create(abc.constants, new HashMap<Integer, String>(), fullyQualifiedNames));
      if (parent instanceof TraitClass) {
        writer.endMethod();
        writer.endTrait();
      }
      return;
    }

    if (value_kind != 0) {
      ValueKind val = new ValueKind(value_index, value_kind);
      writer.hilightSpecial(val.toString(abc.constants), HighlightSpecialType.TRAIT_VALUE);
    }
  }
Exemplo n.º 5
0
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   writer.append(operator);
   if (value != null) {
     if (value.getPrecedence() > precedence) {
       writer.append("(");
       value.toString(writer, localData);
       writer.append(")");
     } else {
       value.toString(writer, localData);
     }
   } else {
     writer.append("null");
   }
   return writer;
 }
Exemplo n.º 6
0
 @Override
 public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
   if (dependencies.contains(value)) {
     return false;
   }
   dependencies.add(value);
   return value.isCompileTime(dependencies);
 }
 @Override
 public List<GraphSourceItem> toSource(
     SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
   return toSourceMerge(
       localData,
       generator,
       object.toSource(localData, generator),
       toSourceIgnoreReturnValue(localData, generator));
 }
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
   writer.append("fscommand");
   writer.spaceBeforeCallParenthesies(1);
   writer.append("(");
   try {
     command.appendTo(writer, localData);
   } catch (InterruptedException ex) {
     Logger.getLogger(FSCommandActionItem.class.getName()).log(Level.SEVERE, null, ex);
   }
   return writer.append(")");
 }
 public boolean isXML(
     ConstantPool constants,
     HashMap<Integer, String> localRegNames,
     List<String> fullyQualifiedNames)
     throws InterruptedException {
   String cname;
   if (name != null) {
     cname = name.toString(LocalData.create(constants, localRegNames, fullyQualifiedNames));
   } else {
     cname = (constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames));
   }
   String cns = "";
   if (namespace != null) {
     cns = namespace.toString(LocalData.create(constants, localRegNames, fullyQualifiedNames));
   } else {
     Namespace ns = constants.getMultiname(multinameIndex).getNamespace(constants);
     if ((ns != null) && (ns.name_index != 0)) {
       cns = ns.getName(constants);
     }
   }
   return cname.equals("XML") && cns.isEmpty();
 }
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   if (namespace != null) {
     namespace.toString(writer, localData);
     writer.append("::");
   } else {
     /*Namespace ns = constants.getMultiname(multinameIndex).getNamespace(constants);
     if ((ns != null)&&(ns.name_index!=0)) {
     ret =  hilight(ns.getName(constants) + "::")+ret;
     }*/
   }
   if (name != null) {
     writer.append("[");
     name.toString(writer, localData);
     writer.append("]");
   } else {
     ConstantPool constants = localData.constantsAvm2;
     List<String> fullyQualifiedNames = localData.fullyQualifiedNames;
     writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames));
   }
   return writer;
 }
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   String prefix = "gotoAndStop";
   if (playFlag) {
     prefix = "gotoAndPlay";
   }
   writer.append(prefix);
   writer.spaceBeforeCallParenthesies(1);
   writer.append("(");
   frame.toString(writer, localData);
   writer.append((sceneBiasFlag ? "," + sceneBias : ""));
   return writer.append(")");
 }
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   receiver.toString(writer, localData);
   writer.append(".");
   writer.append(methodName);
   writer.spaceBeforeCallParenthesies(arguments.size());
   writer.append("(");
   for (int a = 0; a < arguments.size(); a++) {
     if (a > 0) {
       writer.append(",");
     }
     arguments.get(a).toString(writer, localData);
   }
   return writer.append(")");
 }
Exemplo n.º 13
0
  @Override
  public void translate(
      boolean isStatic,
      int scriptIndex,
      int classIndex,
      HashMap<Integer, GraphTargetItem> localRegs,
      TranslateStack stack,
      ScopeStack scopeStack,
      AVM2ConstantPool constants,
      AVM2Instruction ins,
      List<MethodInfo> method_info,
      List<GraphTargetItem> output,
      MethodBody body,
      ABC abc,
      HashMap<Integer, String> localRegNames,
      List<DottedChain> fullyQualifiedNames,
      String path,
      HashMap<Integer, Integer> localRegsAssignmentIps,
      int ip,
      HashMap<Integer, List<Integer>> refs,
      AVM2Code code) {
    int slotIndex = ins.operands[0];
    GraphTargetItem value = stack.pop();
    GraphTargetItem obj = stack.pop(); // scopeId
    GraphTargetItem objnoreg = obj;
    obj = obj.getThroughRegister();
    Multiname slotname = null;
    if (obj instanceof NewActivationAVM2Item) {
      ((NewActivationAVM2Item) obj).slots.put(slotIndex, value);
    }

    if (obj instanceof ExceptionAVM2Item) {
      slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index);
    } else if (obj instanceof ClassAVM2Item) {
      slotname = ((ClassAVM2Item) obj).className;
    } else if (obj instanceof ThisAVM2Item) {
      slotname = ((ThisAVM2Item) obj).className;
    } else if (obj instanceof ScriptAVM2Item) {
      for (int t = 0;
          t < abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.size();
          t++) {
        Trait tr = abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.get(t);
        if (tr instanceof TraitWithSlot) {
          if (((TraitWithSlot) tr).getSlotIndex() == slotIndex) {
            slotname = tr.getName(abc);
          }
        }
      }
    } else if (obj instanceof NewActivationAVM2Item) {

      for (int t = 0; t < body.traits.traits.size(); t++) {
        if (body.traits.traits.get(t) instanceof TraitWithSlot) {
          if (((TraitWithSlot) body.traits.traits.get(t)).getSlotIndex() == slotIndex) {
            slotname = body.traits.traits.get(t).getName(abc);
          }
        }
      }
    }

    if (slotname != null) {
      if (value instanceof LocalRegAVM2Item) {
        LocalRegAVM2Item lr = (LocalRegAVM2Item) value;
        String slotNameStr = slotname.getName(constants, fullyQualifiedNames, true);
        if (localRegNames.containsKey(lr.regIndex)) {
          if (localRegNames.get(lr.regIndex).equals(slotNameStr)) {
            return; // Register with same name to slot
          }
        }
      }
    }

    if (value.getNotCoerced().getThroughDuplicate() instanceof IncrementAVM2Item) {
      GraphTargetItem inside =
          ((IncrementAVM2Item) value.getNotCoerced())
              .value
              .getThroughRegister()
              .getNotCoerced()
              .getThroughDuplicate();
      if (inside instanceof GetSlotAVM2Item) {
        GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside;
        if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister())
            && (slotItem.slotName == slotname)) {
          if (stack.size() > 0) {
            GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate();
            if (top == inside) {
              stack.pop();
              stack.push(new PostIncrementAVM2Item(ins, inside));
            } else if ((top instanceof IncrementAVM2Item)
                && (((IncrementAVM2Item) top).value == inside)) {
              stack.pop();
              stack.push(new PreIncrementAVM2Item(ins, inside));
            } else {
              output.add(new PostIncrementAVM2Item(ins, inside));
            }
          } else {
            output.add(new PostIncrementAVM2Item(ins, inside));
          }
          return;
        }
      }
    }

    if (value.getNotCoerced().getThroughDuplicate() instanceof DecrementAVM2Item) {
      GraphTargetItem inside =
          ((DecrementAVM2Item) value.getNotCoerced())
              .value
              .getThroughRegister()
              .getNotCoerced()
              .getThroughDuplicate();
      if (inside instanceof GetSlotAVM2Item) {
        GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside;
        if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister())
            && (slotItem.slotName == slotname)) {
          if (stack.size() > 0) {
            GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate();
            if (top == inside) {
              stack.pop();
              stack.push(new PostDecrementAVM2Item(ins, inside));
            } else if ((top instanceof DecrementAVM2Item)
                && (((DecrementAVM2Item) top).value == inside)) {
              stack.pop();
              stack.push(new PreDecrementAVM2Item(ins, inside));
            } else {
              output.add(new PostDecrementAVM2Item(ins, inside));
            }
          } else {
            output.add(new PostDecrementAVM2Item(ins, inside));
          }
          return;
        }
      }
    }

    output.add(new SetSlotAVM2Item(ins, obj, slotname, value));
  }
  public boolean compareSame(FullMultinameAVM2Item other) {
    if (multinameIndex != other.multinameIndex) {
      return false;
    }
    GraphTargetItem tiName = name;
    if (name != null) {
      name = name.getThroughDuplicate();
    }
    while (tiName instanceof LocalRegAVM2Item) {
      if (((LocalRegAVM2Item) tiName).computedValue != null) {
        tiName =
            ((LocalRegAVM2Item) tiName)
                .computedValue
                .getThroughNotCompilable()
                .getThroughDuplicate();
      } else {
        break;
      }
    }

    GraphTargetItem tiName2 = other.name;
    if (tiName2 != null) {
      tiName2 = tiName2.getThroughDuplicate();
    }
    while (tiName2 instanceof LocalRegAVM2Item) {
      if (((LocalRegAVM2Item) tiName2).computedValue != null) {
        tiName2 =
            ((LocalRegAVM2Item) tiName2)
                .computedValue
                .getThroughNotCompilable()
                .getThroughDuplicate();
      } else {
        break;
      }
    }
    if (tiName != tiName2) {
      return false;
    }

    GraphTargetItem tiNameSpace = namespace;
    if (tiNameSpace != null) {
      tiNameSpace = tiNameSpace.getThroughDuplicate();
    }
    while (tiNameSpace instanceof LocalRegAVM2Item) {
      if (((LocalRegAVM2Item) tiNameSpace).computedValue != null) {
        tiNameSpace =
            ((LocalRegAVM2Item) tiNameSpace)
                .computedValue
                .getThroughNotCompilable()
                .getThroughDuplicate();
      }
    }

    GraphTargetItem tiNameSpace2 = other.namespace;
    if (tiNameSpace2 != null) {
      tiNameSpace2 = tiNameSpace2.getThroughDuplicate();
    }
    while (tiNameSpace2 instanceof LocalRegAVM2Item) {
      if (((LocalRegAVM2Item) tiNameSpace2).computedValue != null) {
        tiNameSpace2 =
            ((LocalRegAVM2Item) tiNameSpace2)
                .computedValue
                .getThroughNotCompilable()
                .getThroughDuplicate();
      }
    }
    if (tiNameSpace != tiNameSpace2) {
      return false;
    }
    return true;
  }
  @Override
  public void translate(
      TranslateStack stack,
      List<GraphTargetItem> output,
      HashMap<Integer, String> regNames,
      HashMap<String, GraphTargetItem> variables,
      HashMap<String, GraphTargetItem> functions,
      int staticOperation,
      String path) {
    GraphTargetItem value = stack.pop();
    RegisterNumber rn = new RegisterNumber(registerNumber);
    if (regNames.containsKey(registerNumber)) {
      rn.name = regNames.get(registerNumber);
    }
    value.getMoreSrc().add(new GraphSourceItemPos(this, 0));
    if (variables.containsKey("__register" + registerNumber)) {
      if (variables.get("__register" + registerNumber) instanceof TemporaryRegister) {
        variables.remove("__register" + registerNumber);
      }
    }
    boolean define = !variables.containsKey("__register" + registerNumber);
    if (regNames.containsKey(registerNumber)) {
      define = false;
    }
    variables.put("__register" + registerNumber, value);
    if (value instanceof DirectValueActionItem) {
      if (((DirectValueActionItem) value).value instanceof RegisterNumber) {
        if (((RegisterNumber) ((DirectValueActionItem) value).value).number == registerNumber) {
          stack.push(value);
          return;
        }
      }
    }
    if (value instanceof StoreRegisterActionItem) {
      if (((StoreRegisterActionItem) value).register.number == registerNumber) {
        stack.push(value);
        return;
      }
    }

    if (value instanceof IncrementActionItem) {
      GraphTargetItem obj = ((IncrementActionItem) value).object;
      if (!stack.isEmpty()) {
        if (stack.peek().valueEquals(obj)) {
          stack.pop();
          stack.push(new PostIncrementActionItem(this, obj));
          stack.push(obj);
          return;
        }
      }
    }
    if (value instanceof DecrementActionItem) {
      GraphTargetItem obj = ((DecrementActionItem) value).object;
      if (!stack.isEmpty()) {
        if (stack.peek().valueEquals(obj)) {
          stack.pop();
          stack.push(new PostDecrementActionItem(this, obj));
          stack.push(obj);
          return;
        }
      }
    }
    stack.push(new StoreRegisterActionItem(this, rn, value, define));
  }
Exemplo n.º 16
0
 public PushItem(GraphTargetItem value) {
   super(value.getSrc(), value.getLineStartItem(), value.getPrecedence(), value);
 }
 @Override
 public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData)
     throws InterruptedException {
   object.toString(writer, localData);
   return writer.append("++");
 }
Exemplo n.º 18
0
 @Override
 public boolean hasSideEffect() {
   return value.hasSideEffect();
 }
Exemplo n.º 19
0
 @Override
 public List<GraphSourceItemPos> getNeededSources() {
   List<GraphSourceItemPos> ret = super.getNeededSources();
   ret.addAll(value.getNeededSources());
   return ret;
 }
Exemplo n.º 20
0
 @Override
 public boolean isVariableComputed() {
   return value.isVariableComputed();
 }
Exemplo n.º 21
0
 public DuplicateItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem value) {
   super(src, lineStartIns, value.getPrecedence(), value);
 }
Exemplo n.º 22
0
  @Override
  public void translate(
      TranslateStack stack,
      List<GraphTargetItem> output,
      HashMap<Integer, String> regNames,
      HashMap<String, GraphTargetItem> variables,
      HashMap<String, GraphTargetItem> functions,
      int staticOperation,
      String path) {
    GraphTargetItem targetString = stack.pop();
    GraphTargetItem urlString = stack.pop();
    Integer num = null;
    if (targetString.isCompileTime()) {
      Object res = targetString.getResult();
      if (res instanceof String) {
        String tarStr = (String) res;
        String levelPrefix = "_level";
        if (tarStr.startsWith(levelPrefix)) {
          try {
            num = Integer.valueOf(tarStr.substring(levelPrefix.length()));
          } catch (NumberFormatException nfe) {
          }
        }
      }
    }
    if (loadVariablesFlag) {
      if (num != null) {
        output.add(
            new LoadVariablesNumActionItem(
                this,
                urlString,
                new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<>()),
                sendVarsMethod));
      } else {
        output.add(new LoadVariablesActionItem(this, urlString, targetString, sendVarsMethod));
      }
    } else if (loadTargetFlag) {
      if ((urlString instanceof DirectValueActionItem) && (urlString.getResult().equals(""))) {
        output.add(new UnLoadMovieActionItem(this, targetString));
      } else {
        output.add(new LoadMovieActionItem(this, urlString, targetString, sendVarsMethod));
      }
    } else {
      String printPrefix = "print:#";
      String printAsBitmapPrefix = "printasbitmap:#";
      String urlStr = null;
      if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) {
        urlStr = (String) urlString.getResult();
      }

      if (num != null) {
        if ("".equals(urlStr)) {
          output.add(
              new UnLoadMovieNumActionItem(
                  this,
                  new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<>())));
        } else if (urlStr != null && urlStr.startsWith(printPrefix)) {
          output.add(
              new PrintNumActionItem(
                  this,
                  new DirectValueActionItem((Long) (long) (int) num),
                  new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
        } else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
          output.add(
              new PrintAsBitmapNumActionItem(
                  this,
                  new DirectValueActionItem((Long) (long) (int) num),
                  new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
        } else {
          output.add(
              new LoadMovieNumActionItem(
                  this,
                  urlString,
                  new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<>()),
                  sendVarsMethod));
        }
      } else {
        if (urlStr != null && urlStr.startsWith(printPrefix)) {
          output.add(
              new PrintActionItem(
                  this,
                  targetString,
                  new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
        } else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
          output.add(
              new PrintAsBitmapActionItem(
                  this,
                  targetString,
                  new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
        } else {
          output.add(new GetURL2ActionItem(this, urlString, targetString, sendVarsMethod));
        }
      }
    }
  }