TemplateMips.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package target.mips;
  7. import java.util.HashMap;
  8. import template.TPLInterface;
  9. import template.TemplateCtx;
  10. /**
  11. *
  12. * @author EUGENIO CARVALHO
  13. */
  14. public class TemplateMips extends template.Template {
  15. protected static HashMap<String, TPLInterface> templates = new HashMap<>();
  16. public TemplateMips(String template, TemplateCtx gctx) {
  17. super(template, gctx);
  18. }
  19. public TemplateMips() {
  20. }
  21. @Override
  22. public String Render(TemplateCtx ctx) {
  23. if (templates.isEmpty()) {
  24. templates.put("bin.R", New("{[codop]}{[RBIN(rs,5)]}{[RBIN(rt,5)]}{[RBIN(rd,5)]}{[BIN(sa,5)]}{[func]}", gctx));
  25. templates.put("bin.I", New("{[codop]}{[RBIN(rs,5)]}{[RBIN(rt,5)]}{[BIN(offset,16)]}", gctx));
  26. templates.put("bin.J", New("{[codop]}{[target]}", gctx));
  27. templates.put("bin.S", New("{[txt]}", gctx));
  28. }
  29. TListenerMips listener = new TListenerMips(ctx, gctx);
  30. // listener.AddressGap = 4;
  31. listener.templates = templates;
  32. walker.walk(listener, tree);
  33. return listener.toString();
  34. }
  35. @Override
  36. public TPLInterface New(String tpl, TemplateCtx gctx) {
  37. return new TemplateMips(tpl, gctx);
  38. }
  39. }