Damian Gryski
e7bd22edf2
reflect: print struct tags in Type.String() (with a caveat)
2023-03-30 21:10:54 +02:00
Damian Gryski
3fbd3c4d93
compiler,reflect: support channel directions
2023-03-30 21:10:54 +02:00
Damian Gryski
57b0c21492
reflect: tweak Type.String() for interfaces to make encoding/xml happy
2023-03-19 13:50:38 -07:00
Damian Gryski
8fb5877d9e
reflect: fix isBinary() for float types
2023-03-19 13:49:55 -07:00
Damian Gryski
6fbe6fa2ae
reflect: tweak Type.String() to match what encoding/json expects for empty structs
2023-03-19 20:37:57 +01:00
Damian Gryski
24b4dc31a4
reflect: stub MapOf()
2023-03-19 19:12:34 +01:00
Damian Gryski
229f479a7d
reflect: make sure pointerTo() works for named types
2023-03-19 17:45:43 +01:00
Damian Gryski
876f08979f
compiler,reflect: sort out pkg path vs pkg name for named types
2023-03-19 17:45:43 +01:00
Damian Gryski
f2cc98caa5
compiler,reflect: adjust struct layout for type info
2023-03-19 17:45:43 +01:00
Damian Gryski
569817a514
refect: Type.String() should use a shortened package name
2023-03-19 17:45:43 +01:00
Damian Gryski
7a96f0f609
compiler,reflect: add reflect.Type.NumMethods()
2023-03-19 17:45:43 +01:00
Damian Gryski
344e493ac8
compiler,reflect: fix pkgpath for struct fields
2023-03-15 21:53:57 +01:00
Damian Gryski
1626b50457
reflect: set PkgPath in StructField
2023-03-15 21:53:57 +01:00
Damian Gryski
93fb897feb
compiler, reflect: properly handle embedded structs
2023-03-15 21:53:57 +01:00
Damian Gryski
fa4f361ca7
reflect: add FieldByName(), and FieldByIndex()
2023-03-15 21:53:57 +01:00
Damian Gryski
9f02340a26
reflect: fix Type.Name to return empty string for non-named types
...
// Name returns the type's name within its package for a defined type.
// For other (non-defined) types it returns the empty string.
2023-03-15 13:14:21 -07:00
Damian Gryski
b044d27dff
reflect: move StructField.Anonymous field to match upstream location
2023-03-15 00:13:08 +01:00
Damian Gryski
6768af91e7
reflect: TypeOf(nil) should be nil
2023-03-14 23:58:27 +01:00
Damian Gryski
a366c014c7
reflect: call decomposeInterface() directly in TypeOf()
2023-03-14 09:53:45 -07:00
Damian Gryski
e0aee1f23c
reflect: Type.AssignableTo(): you can assign anything to interface{}
2023-03-14 17:07:23 +01:00
Damian Gryski
ad9f790dfc
reflect: set Index field in Field()
2023-03-14 17:04:24 +01:00
Damian Gryski
04412cba0e
reflect: add stub for StructOf()
2023-03-14 16:54:44 +01:00
Damian Gryski
3b2763896f
reflect: add stubs for Method(), CanConvert(), ArrayOf()
2023-03-14 16:54:44 +01:00
Damian Gryski
6a45b73fcb
compiler, reflect: replace package and name length with null-byte termination
2023-03-08 09:38:49 -08:00
Damian Gryski
2de64d3f4e
compiler, reflect: add Type.PkgPath
2023-03-08 09:38:49 -08:00
Damian Gryski
90af41d089
reflect: add Type.String()
2023-03-08 09:38:49 -08:00
Damian Gryski
7654d86d2c
compiler, reflect: add support for named types
2023-03-08 09:38:49 -08:00
Damian Gryski
e4ef6f85ac
reflect: allow nil rawType to call Kind()
2023-03-03 10:18:32 -08:00
Damian Gryski
3a3de8a778
reflect: add pointerTo()
2023-03-03 10:18:32 -08:00
Damian Gryski
d0f4702f8b
reflect: add MapIndex()
2023-02-28 13:10:40 -08:00
Damian Gryski
9541525402
reflect: add Type.Elem() and Type.Key() for Maps
2023-02-28 13:10:40 -08:00
Damian Gryski
60a93e8e2d
compiler, reflect: add map key and element type info
2023-02-28 13:10:40 -08:00
Ayke van Laethem
4e8453167f
all: refactor reflect package
...
This is a big commit that changes the way runtime type information is stored in
the binary. Instead of compressing it and storing it in a number of sidetables,
it is stored similar to how the Go compiler toolchain stores it (but still more
compactly).
This has a number of advantages:
* It is much easier to add new features to reflect support. They can simply
be added to these structs without requiring massive changes (especially in
the reflect lowering pass).
* It removes the reflect lowering pass, which was a large amount of hard to
understand and debug code.
* The reflect lowering pass also required merging all LLVM IR into one
module, which is terrible for performance especially when compiling large
amounts of code. See issue 2870 for details.
* It is (probably!) easier to reason about for the compiler.
The downside is that it increases code size a bit, especially when reflect is
involved. I hope to fix some of that in later patches.
2023-02-17 22:54:34 +01:00
Anuraag Agrawal
62594004c6
Stub out reflect.Type FieldByIndex
2022-10-26 12:06:08 +02:00
Elliott Sales de Andrade
836ab95192
Rename reflect.Ptr to reflect.Pointer
...
This was done in plain Go for 1.18:
17910ed4ff
2022-03-18 15:27:28 +01:00
Kyle Conroy
cfed3f0213
fix: Add stubs for more missing reflect methods
...
With these methods stubbed out, the text/template package can be
imported. These changes also allow code generated by protoc to compile.
2022-02-24 12:32:40 -05:00
Damian Gryski
484bb8f13d
src/reflect: fix stripPrefix comment
2021-12-18 10:02:36 +01:00
Damian Gryski
d9ad500cf7
src/reflect: fix type.Size() to account for struct padding
...
Fixes #2141
2021-09-27 17:04:16 +02:00
Ayke van Laethem
d45497691f
reflect: add StructField.IsExported method
...
This field was introduced in Go 1.17 and is used by the encoding/json
package (starting with Go 1.17).
2021-08-30 09:18:58 +02:00
Ayke van Laethem
e587b1d1b4
reflect: implement New function
...
This is very important for some use cases, for example for Vecty.
2021-04-12 14:49:26 +02:00
Ayke van Laethem
4f6d598ea8
reflect: implement Sizeof and Alignof for func values
...
This is a small change that appears to be necessary for encoding/json
support. It's simple enough to implement.
2021-03-29 01:04:11 +02:00
Ayke van Laethem
e9f9a4b750
reflect: fix AssignableTo and Implements methods
...
They both reversed the direction of the check, in a way that mostly
cancelled each other out. Of course they're still mostly unimplemented,
but it's better if they're not wrong.
2021-03-28 14:00:37 +02:00
Ayke van Laethem
c849bccb83
reflect: let reflect.Type be of interface type
...
This matches the main Go implementation and (among others) fixes a
compatibility issue with the encoding/json package. The encoding/json
package compares reflect.Type variables against nil, which does not work
as long as reflect.Type is of integer type.
This also adds a reflect.RawType() function (like reflect.Type()) that
makes it easier to avoid working with interfaces in the runtime package.
It is internal only, but exported to let the runtime package use it.
This change introduces a small code size increase when working with the
reflect package, but I've tried to keep it to a minimum. Most programs
that don't make extensive use of the reflect package (and don't use
package like fmt) should not be impacted by this.
2021-03-23 14:32:33 +01:00
Ayke van Laethem
3010466c55
reflect: implement PtrTo
2021-01-23 10:55:46 +01:00
Cornel
720a54a0fe
extend stdlib to allow import of more packages ( #1099 )
...
* stdlib: extend stdlib to allow import of more packages
2020-06-23 11:56:28 +02:00
Jaden Weiss
4339cbd56f
add implementaion of array alignment in reflect
2019-10-25 15:18:03 +02:00
Jaden Weiss
17ef7a5c32
all: add support for go 1.13
2019-09-24 16:13:26 +02:00
Jaden Weiss
d17f500c8b
replace reflect.interfaceHeader with strongly typed runtime functions
2019-09-22 16:36:11 +02:00
Ayke van Laethem
e356bad4d1
reflect: implement t.Comparable()
...
This is necessary to support the context package, which is a dependency
of a lot of packages.
2019-08-20 10:20:09 +02:00
Ayke van Laethem
c19c738f52
reflect: implement support for array types
2019-08-19 11:08:26 +02:00