mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-02 12:50:55 +00:00
elide double returns and get rid of function end emits
This commit is contained in:
parent
1d664e807b
commit
b451f74239
@ -40,6 +40,8 @@ class CodeBuilder(val symbol: CompilableSymbol) {
|
||||
ops.add(PatchSymOp(Op(code, arguments), patches))
|
||||
}
|
||||
|
||||
fun lastOp(): StubOp? = ops.lastOrNull()
|
||||
|
||||
fun annotate(text: String) {
|
||||
annotations.add(StubOpAnnotation(symbol, nextOpInst(), text))
|
||||
}
|
||||
|
@ -17,8 +17,9 @@ class IrStubOpEmitter(val irDefinition: IrDefinition, val code: CodeBuilder) : I
|
||||
}
|
||||
|
||||
fun final() {
|
||||
code.emit(Opcode.Return)
|
||||
code.emit(Opcode.End)
|
||||
if (code.lastOp()?.op?.code != Opcode.Return) {
|
||||
code.emit(Opcode.Return)
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolve(symbol: IrSymbol): Loadable = code.localState.resolve(symbol)
|
||||
|
Loading…
Reference in New Issue
Block a user