mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 20:43:40 +00:00
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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:"
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user