private void checkDialog(DlgResource dialog) {
   List<StructEntry> flatList = dialog.getFlatList();
   for (int i = 0; i < flatList.size(); i++) {
     if (flatList.get(i) instanceof StringRef) {
       StringRef ref = (StringRef) flatList.get(i);
       if (ref.getValue() >= 0 && ref.getValue() < strUsed.length) strUsed[ref.getValue()] = true;
     } else if (flatList.get(i) instanceof AbstractCode) {
       AbstractCode code = (AbstractCode) flatList.get(i);
       try {
         String compiled =
             infinity.resource.bcs.Compiler.getInstance()
                 .compileDialogCode(code.toString(), code instanceof Action);
         if (code instanceof Action) Decompiler.decompileDialogAction(compiled, true);
         else Decompiler.decompileDialogTrigger(compiled, true);
         Set<Integer> used = Decompiler.getStringRefsUsed();
         for (final Integer stringRef : used) {
           int u = stringRef.intValue();
           if (u >= 0 && u < strUsed.length) strUsed[u] = true;
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
 private void checkScript(BcsResource script) {
   Decompiler.decompile(script.getCode(), true);
   Set<Integer> used = Decompiler.getStringRefsUsed();
   for (final Integer stringRef : used) {
     int u = stringRef.intValue();
     if (u >= 0 && u < strUsed.length) strUsed[u] = true;
   }
 }
Example #3
0
  public DecompilerIfBlock(
      Block block,
      Decompiler decompiler,
      List<DecompilerBlock> thenBranch,
      List<DecompilerBlock> elseBranch,
      PrintStream infoStream) {
    super(block, decompiler);
    this.thenBranch = thenBranch;
    this.elseBranch = elseBranch;
    this.infoStream = infoStream;
    this.head = new DecompilerBasicBlock(block, decompiler, decompiler.getSchedule());

    if (!(thenBranch.isEmpty() == false
            && head.getBlock().getSuccessors().contains(thenBranch.get(0).getBlock())
        || (elseBranch.isEmpty() == false
            && head.getBlock().getSuccessors().contains(elseBranch.get(0).getBlock())))) {
      // first block of then / else MUST be a successor of the head!
      throw new AssertionError(decompiler.contexInformation);
    }
  }