aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-08-03 16:24:47 +0200
committerAyke <[email protected]>2022-08-04 12:18:32 +0200
commitc7a23183e822b9eebb639902414a0e08a09fbba0 (patch)
tree894a03fe2f4980a728c8401604d8a2c17503fde5 /transform
parentf936125658e8aef885a0e31d8fc343859defe63c (diff)
downloadtinygo-c7a23183e822b9eebb639902414a0e08a09fbba0.tar.gz
tinygo-c7a23183e822b9eebb639902414a0e08a09fbba0.zip
all: format code according to Go 1.19 rules
Go 1.19 started reformatting code in a way that makes it more obvious how it will be rendered on pkg.go.dev. It gets it almost right, but not entirely. Therefore, I had to modify some of the comments so that they are formatted correctly.
Diffstat (limited to 'transform')
-rw-r--r--transform/interrupt.go6
-rw-r--r--transform/reflect.go9
-rw-r--r--transform/reflect_test.go4
-rw-r--r--transform/rtcalls.go6
4 files changed, 14 insertions, 11 deletions
diff --git a/transform/interrupt.go b/transform/interrupt.go
index 49ee6ee6d..3ffe7048c 100644
--- a/transform/interrupt.go
+++ b/transform/interrupt.go
@@ -12,9 +12,9 @@ import (
//
// The operation is as follows. The compiler creates the following during IR
// generation:
-// * calls to runtime/interrupt.callHandlers with an interrupt number.
-// * runtime/interrupt.handle objects that store the (constant) interrupt ID and
-// interrupt handler func value.
+// - calls to runtime/interrupt.callHandlers with an interrupt number.
+// - runtime/interrupt.handle objects that store the (constant) interrupt ID and
+// interrupt handler func value.
//
// This pass then replaces those callHandlers calls with calls to the actual
// interrupt handlers. If there are no interrupt handlers for the given call,
diff --git a/transform/reflect.go b/transform/reflect.go
index 49bd449ac..fd70ccb7d 100644
--- a/transform/reflect.go
+++ b/transform/reflect.go
@@ -366,10 +366,13 @@ func (state *typeCodeAssignmentState) getNonBasicTypeCode(class string, typecode
// getClassAndValueFromTypeCode takes a typecode (a llvm.Value of type
// runtime.typecodeID), looks at the name, and extracts the typecode class and
// value from it. For example, for a typecode with the following name:
-// reflect/types.type:pointer:named:reflect.ValueError
+//
+// reflect/types.type:pointer:named:reflect.ValueError
+//
// It extracts:
-// class = "pointer"
-// value = "named:reflect.ValueError"
+//
+// class = "pointer"
+// value = "named:reflect.ValueError"
func getClassAndValueFromTypeCode(typecode llvm.Value) (class, value string) {
typecodeName := typecode.Name()
const prefix = "reflect/types.type:"
diff --git a/transform/reflect_test.go b/transform/reflect_test.go
index 06c304067..242337024 100644
--- a/transform/reflect_test.go
+++ b/transform/reflect_test.go
@@ -15,13 +15,13 @@ type reflectAssert struct {
// Test reflect lowering. This code looks at IR like this:
//
-// call void @main.assertType(i32 ptrtoint (%runtime.typecodeID* @"reflect/types.type:basic:int" to i32), i8* inttoptr (i32 3 to i8*), i32 4, i8* undef, i8* undef)
+// call void @main.assertType(i32 ptrtoint (%runtime.typecodeID* @"reflect/types.type:basic:int" to i32), i8* inttoptr (i32 3 to i8*), i32 4, i8* undef, i8* undef)
//
// and verifies that the ptrtoint constant (the first parameter of
// @main.assertType) is replaced with the correct type code. The expected
// output is this:
//
-// call void @main.assertType(i32 4, i8* inttoptr (i32 3 to i8*), i32 4, i8* undef, i8* undef)
+// call void @main.assertType(i32 4, i8* inttoptr (i32 3 to i8*), i32 4, i8* undef, i8* undef)
//
// The first and third parameter are compared and must match, the second
// parameter is ignored.
diff --git a/transform/rtcalls.go b/transform/rtcalls.go
index 6cd5cc4c9..2edfd6554 100644
--- a/transform/rtcalls.go
+++ b/transform/rtcalls.go
@@ -12,7 +12,7 @@ import (
// OptimizeStringToBytes transforms runtime.stringToBytes(...) calls into const
// []byte slices whenever possible. This optimizes the following pattern:
//
-// w.Write([]byte("foo"))
+// w.Write([]byte("foo"))
//
// where Write does not store to the slice.
func OptimizeStringToBytes(mod llvm.Module) {
@@ -91,12 +91,12 @@ func OptimizeStringEqual(mod llvm.Module) {
// OptimizeReflectImplements optimizes the following code:
//
-// implements := someType.Implements(someInterfaceType)
+// implements := someType.Implements(someInterfaceType)
//
// where someType is an arbitrary reflect.Type and someInterfaceType is a
// reflect.Type of interface kind, to the following code:
//
-// _, implements := someType.(interfaceType)
+// _, implements := someType.(interfaceType)
//
// if the interface type is known at compile time (that is, someInterfaceType is
// a LLVM constant aggregate). This optimization is especially important for the