commit | 61b29a99dadf33c48a0a063f50f61e877fb419b8 | [log] [tgz] |
---|---|---|
author | Ian Lance Taylor <iant@golang.org> | Thu Oct 19 19:34:31 2023 -0700 |
committer | Ian Lance Taylor <iant@golang.org> | Tue Dec 19 01:05:33 2023 +0000 |
tree | ef9a572b928f0b505459b31377949e4621f4c09f | |
parent | f5d708fd905d3f91d848a0ea25c77119f8af0c36 [diff] |
compiler: move lowering pass after check types pass This change moves the lowering pass after the type determination and the type checking passes. This lets us simplify some of the code that determines the type of an expression, which previously had to work correctly both before and after type determination. I'm doing this to help with future generic support. For example, with generics, we can see code like func ident[T any](v T) T { return v } func F() int32 { s := int32(1) return ident(s) } Before this change, we would type check return statements in the lowering pass (see Return_statement::do_lower). With a generic example like the above, that means we have to determine the type of s, and use that to infer the type arguments passed to ident, and use that to determine the result type of ident. That is too much to do at lowering time. Of course we can change the way that return statements work, but similar issues arise with index expressions, the types of closures for function literals, and probably other cases as well. Rather than try to deal with all those cases, we move the lowering pass after type checking. This requires a bunch of changes, notably for determining constant types. We have to add type checking for various constructs that formerly disappeared in the lowering pass. So it's a lot of shuffling. Sorry for the size of the patch. Change-Id: Ic269e816f324c87feb708ca4cde0eff7f2f70c7b Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536643 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Ian Lance Taylor Last update 15 June 2014
This is a compiler frontend for the Go programming language. The frontend was originally developed at Google, and was released in November 2009. It was originally written by Ian Lance Taylor.
It was originally written for GCC. As of this writing it only supports GCC, but the GCC support has been separated from the rest of the frontend, so supporting another compiler is feasible.
The go subdirectory holds the frontend source code. This is mirrored to the gcc/go subdirectory in the GCC repository.
The libgo subdirectory holds the library source code. This is a copy of the main Go library with various changes appropriate for this compiler. The main Go library is hosted at http://go.googlesource.com/go, in the src directory. The libgo subdirectory is mirrored to the libgo subdirectory in the gcc repository.
To contribute patches to the files in this directory, please see Contributing to the gccgo frontend.
The master copy of these files is hosted in Gerrit (there is a mirror at Github). Changes to these files require signing a Google contributor license agreement. If you are the copyright holder, you will need to agree to the Google Individual Contributor License Agreement. This agreement can be completed online.
If your organization is the copyright holder, the organization will need to agree to the Google Software Grant and Corporate Contributor License Agreement.
If the copyright holder for your code has already completed the agreement in connection with another Google open source project, it does not need to be completed again.
The authors of these files may be found in the AUTHORS and CONTRIBUTORS files.