mirror of
				https://github.com/GayPizzaSpecifications/pork.git
				synced 2025-11-03 17:39:38 +00:00 
			
		
		
		
	elide double returns and get rid of function end emits
This commit is contained in:
		@ -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() {
 | 
				
			||||||
 | 
					    if (code.lastOp()?.op?.code != Opcode.Return) {
 | 
				
			||||||
      code.emit(Opcode.Return)
 | 
					      code.emit(Opcode.Return)
 | 
				
			||||||
    code.emit(Opcode.End)
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private fun resolve(symbol: IrSymbol): Loadable = code.localState.resolve(symbol)
 | 
					  private fun resolve(symbol: IrSymbol): Loadable = code.localState.resolve(symbol)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user