@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
35 lines (33 loc) • 1.02 kB
JavaScript
import { ProgramCounter } from './ProgramCounter';
export class LastProgramCounter extends ProgramCounter {
constructor(startPC, offset = 0) {
super();
this.startPC = startPC;
this.offset = offset;
this.mutableChildren = [];
}
plus(offset) {
const pc = new LastProgramCounter(this.startPC, this.offset + offset);
this.mutableChildren.push(pc);
if (this.mutablePC !== undefined) {
pc.setPC(this.mutablePC);
}
return pc;
}
equals(other) {
return other instanceof LastProgramCounter && this.startPC === other.startPC && this.offset === other.offset;
}
setPC(pc) {
this.mutablePC = pc;
this.mutableChildren.forEach((child) => {
child.setPC(pc);
});
}
getPC() {
if (this.mutablePC === undefined) {
throw new Error('Unknown PC');
}
return this.mutablePC + this.offset;
}
}
//# sourceMappingURL=LastProgramCounter.js.map