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.
 
 

43 lines
830 B

export enum LocType {
REGISTER = "register",
TEMPORARY = "temporary",
VARIABLE = "variable",
}
export class Loc {
type: LocType
name: string
constructor(type: LocType, name: string) {
this.type = type
this.name = name
}
toString(): string {
let sigil = ''
switch (this.type) {
case 'register':
sigil = '%'
break
case 'temporary':
sigil = '#'
break
}
return sigil + this.name
}
static vari(name: string): Loc {
return new Loc(LocType.VARIABLE, name)
}
static temp(name: string): Loc {
return new Loc(LocType.TEMPORARY, name)
}
static reg(name: string): Loc {
return new Loc(LocType.REGISTER, name)
}
}