From 3313decb6898d28bf8a54c4d1a2bd9b37dff7314 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 24 May 2019 15:00:40 +0200 Subject: [PATCH] compiler,runtime: make panic functions camelCase Rename panic functions to be runtime.nilPanic, runtime.lookupPanic, and runtime.slicePanic. --- compiler/asserts.go | 6 +++--- compiler/func-lowering.go | 8 ++++---- src/runtime/panic.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/asserts.go b/compiler/asserts.go index 743ac46a..171dc8e6 100644 --- a/compiler/asserts.go +++ b/compiler/asserts.go @@ -42,7 +42,7 @@ func (c *Compiler) emitLookupBoundsCheck(frame *Frame, arrayLen, index llvm.Valu // Fail: this is a nil pointer, exit with a panic. c.builder.SetInsertPointAtEnd(faultBlock) - c.createRuntimeCall("lookuppanic", nil, "") + c.createRuntimeCall("lookupPanic", nil, "") c.builder.CreateUnreachable() // Ok: this is a valid pointer. @@ -103,7 +103,7 @@ func (c *Compiler) emitSliceBoundsCheck(frame *Frame, capacity, low, high llvm.V // Fail: this is a nil pointer, exit with a panic. c.builder.SetInsertPointAtEnd(faultBlock) - c.createRuntimeCall("slicepanic", nil, "") + c.createRuntimeCall("slicePanic", nil, "") c.builder.CreateUnreachable() // Ok: this is a valid pointer. @@ -146,7 +146,7 @@ func (c *Compiler) emitNilCheck(frame *Frame, ptr llvm.Value, blockPrefix string // Fail: this is a nil pointer, exit with a panic. c.builder.SetInsertPointAtEnd(faultBlock) - c.createRuntimeCall("nilpanic", nil, "") + c.createRuntimeCall("nilPanic", nil, "") c.builder.CreateUnreachable() // Ok: this is a valid pointer. diff --git a/compiler/func-lowering.go b/compiler/func-lowering.go index 02363f9b..a774b23a 100644 --- a/compiler/func-lowering.go +++ b/compiler/func-lowering.go @@ -154,17 +154,17 @@ func (c *Compiler) LowerFuncValues() { // What we'll do is transform the following: // rawPtr := runtime.getFuncPtr(fn) // if func.rawPtr == nil { - // runtime.nilpanic() + // runtime.nilPanic() // } // result := func.rawPtr(...args, func.context) // into this: // if false { - // runtime.nilpanic() + // runtime.nilPanic() // } // var result // Phi // switch fn.id { // case 0: - // runtime.nilpanic() + // runtime.nilPanic() // case 1: // result = call first implementation... // case 2: @@ -222,7 +222,7 @@ func (c *Compiler) LowerFuncValues() { // The 0 case, which is actually a nil check. nilBlock := llvm.InsertBasicBlock(nextBlock, "func.nil") c.builder.SetInsertPointAtEnd(nilBlock) - c.createRuntimeCall("nilpanic", nil, "") + c.createRuntimeCall("nilPanic", nil, "") c.builder.CreateUnreachable() sw.AddCase(llvm.ConstInt(c.uintptrType, 0, false), nilBlock) diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 8bf80d86..a297795e 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -36,16 +36,16 @@ func isnil(ptr *uint8) bool { } // Panic when trying to dereference a nil pointer. -func nilpanic() { +func nilPanic() { runtimePanic("nil pointer dereference") } // Panic when trying to acces an array or slice out of bounds. -func lookuppanic() { +func lookupPanic() { runtimePanic("index out of range") } // Panic when trying to slice a slice out of bounds. -func slicepanic() { +func slicePanic() { runtimePanic("slice out of range") }