compiler, reflect: add map key and element type info
Этот коммит содержится в:
родитель
cdf785629a
коммит
60a93e8e2d
2 изменённых файлов: 13 добавлений и 0 удалений
|
@ -131,6 +131,8 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
|
||||||
case *types.Map:
|
case *types.Map:
|
||||||
typeFieldTypes = append(typeFieldTypes,
|
typeFieldTypes = append(typeFieldTypes,
|
||||||
types.NewVar(token.NoPos, nil, "ptrTo", types.Typ[types.UnsafePointer]),
|
types.NewVar(token.NoPos, nil, "ptrTo", types.Typ[types.UnsafePointer]),
|
||||||
|
types.NewVar(token.NoPos, nil, "elementType", types.Typ[types.UnsafePointer]),
|
||||||
|
types.NewVar(token.NoPos, nil, "keyType", types.Typ[types.UnsafePointer]),
|
||||||
)
|
)
|
||||||
case *types.Struct:
|
case *types.Struct:
|
||||||
typeFieldTypes = append(typeFieldTypes,
|
typeFieldTypes = append(typeFieldTypes,
|
||||||
|
@ -193,6 +195,8 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
|
||||||
case *types.Map:
|
case *types.Map:
|
||||||
typeFields = []llvm.Value{
|
typeFields = []llvm.Value{
|
||||||
c.getTypeCode(types.NewPointer(typ)), // ptrTo
|
c.getTypeCode(types.NewPointer(typ)), // ptrTo
|
||||||
|
c.getTypeCode(typ.Elem()), // elem
|
||||||
|
c.getTypeCode(typ.Key()), // key
|
||||||
}
|
}
|
||||||
case *types.Struct:
|
case *types.Struct:
|
||||||
typeFields = []llvm.Value{
|
typeFields = []llvm.Value{
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
// - map types (this is still missing the key and element types)
|
// - map types (this is still missing the key and element types)
|
||||||
// meta uint8
|
// meta uint8
|
||||||
// ptrTo *typeStruct
|
// ptrTo *typeStruct
|
||||||
|
// elem *typeStruct
|
||||||
|
// key *typeStruct
|
||||||
// - struct types (see structType):
|
// - struct types (see structType):
|
||||||
// meta uint8
|
// meta uint8
|
||||||
// numField uint16
|
// numField uint16
|
||||||
|
@ -408,6 +410,13 @@ type arrayType struct {
|
||||||
arrayLen uintptr
|
arrayLen uintptr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type mapType struct {
|
||||||
|
rawType
|
||||||
|
ptrTo *rawType
|
||||||
|
elem *rawType
|
||||||
|
key *rawType
|
||||||
|
}
|
||||||
|
|
||||||
// Type for struct types. The numField value is intentionally put before ptrTo
|
// Type for struct types. The numField value is intentionally put before ptrTo
|
||||||
// for better struct packing on 32-bit and 64-bit architectures. On these
|
// for better struct packing on 32-bit and 64-bit architectures. On these
|
||||||
// architectures, the ptrTo field still has the same offset as in all the other
|
// architectures, the ptrTo field still has the same offset as in all the other
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче