// Script to refresh all custom globals & types from Ghidra
// @category _Reman3
// @menupath Reman3.Redump Globals and Types

import ghidra.app.script.GhidraScript;
import re3lib.GlobalDumper;
import re3lib.RemanConfig;
import re3lib.TypeDumper;
import re3lib.FunctionDatabase;

public class DumpGlobals extends GhidraScript {
  @Override
  protected void run() throws Exception {
    RemanConfig.INSTANCE = new RemanConfig(this);
    RemanConfig.INSTANCE.createDirectories();

    try (FunctionDatabase functionDatabase = new FunctionDatabase(this)) {
      GlobalDumper globalDumper = new GlobalDumper(this, functionDatabase);
      globalDumper.loadGlobalManifest();

      globalDumper.dumpGlobals();
      globalDumper.saveGlobalManifest();
      
      TypeDumper dumper = new TypeDumper(this);
      dumper.run();
    }
  }
}
