A "high-level" language for the Gameboy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
659 B

  1. import type { AbsInsn2 } from "./insn"
  2. import type { Loc } from "./loc"
  3. export class BasicBlock {
  4. insns: Array<AbsInsn2>
  5. constructor(insns: Array<AbsInsn2>) {
  6. this.insns = insns
  7. }
  8. locs(): Set<Loc> {
  9. return new Set(
  10. this.insns.flatMap(insn => {
  11. const insnLocs = []
  12. if (insn.type === "copy" || insn.type === "unary") {
  13. insnLocs.push(insn.dest)
  14. if (typeof insn.source !== "number") {
  15. insnLocs.push(insn.source)
  16. }
  17. }
  18. return insnLocs
  19. })
  20. )
  21. }
  22. }