mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-02 21:00:56 +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))
|
ops.add(PatchSymOp(Op(code, arguments), patches))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun lastOp(): StubOp? = ops.lastOrNull()
|
||||||
|
|
||||||
fun annotate(text: String) {
|
fun annotate(text: String) {
|
||||||
annotations.add(StubOpAnnotation(symbol, nextOpInst(), text))
|
annotations.add(StubOpAnnotation(symbol, nextOpInst(), text))
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,9 @@ class IrStubOpEmitter(val irDefinition: IrDefinition, val code: CodeBuilder) : I
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun final() {
|
fun final() {
|
||||||
code.emit(Opcode.Return)
|
if (code.lastOp()?.op?.code != Opcode.Return) {
|
||||||
code.emit(Opcode.End)
|
code.emit(Opcode.Return)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolve(symbol: IrSymbol): Loadable = code.localState.resolve(symbol)
|
private fun resolve(symbol: IrSymbol): Loadable = code.localState.resolve(symbol)
|
||||||
|
Loading…
Reference in New Issue
Block a user