Generator.def 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. DEFINITION MODULE Generator; (* gf 05.01.89 *)
  2. FROM Scanner IMPORT STRING;
  3. FROM Interpreter IMPORT INSTR, Command;
  4. (* EXPORT QUALIFIED Label,
  5. Gen, GenL, GenS, Gens,
  6. GetNewLabel, SetLabel,
  7. CodeStore,
  8. InitGenerator;
  9. *)
  10. CONST maxadr = 1023;
  11. TYPE Label;
  12. VAR CodeStore : ARRAY[0..maxadr] OF INSTR;
  13. PROCEDURE GetNewLabel() : Label;
  14. (* get a new label to be used by GenL and SetLabel. *)
  15. PROCEDURE SetLabel(lab: Label);
  16. (* inserts label 'lab' at current code position. *)
  17. (* fixes all instuctions which contain this label *)
  18. (* in their 'val' field, i.e. all instructions *)
  19. (* which are genereated by GenL(.., .., lab). *)
  20. PROCEDURE Gen(fct: Command; lev, val: CARDINAL);
  21. (* emmit instruction *)
  22. PROCEDURE GenL(fct: Command; lev: CARDINAL; lab: Label);
  23. (* emmit instruction. the 'val' field contains the *)
  24. (* address of label 'lab'. if the address of 'lab' *)
  25. (* is unknown, the 'val' field will be fixed by *)
  26. (* SetLabel. *)
  27. PROCEDURE GenS(fct: Command; len: CARDINAL; str: STRING);
  28. (* emmit instruction. to be used to generate *)
  29. (* instructions which are followed by a string *)
  30. (* literal. the length of the string is stored in *)
  31. (* the 'val' field. *)
  32. PROCEDURE Gens(fct: Command);
  33. (* short form of Gen, == Gen(fct, 0, 0) *)
  34. PROCEDURE InitGenerator;
  35. END Generator.