diff --git a/compiler/interface.go b/compiler/interface.go index a359f33a..097eadcf 100644 --- a/compiler/interface.go +++ b/compiler/interface.go @@ -131,6 +131,8 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value { case *types.Map: typeFieldTypes = append(typeFieldTypes, 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: typeFieldTypes = append(typeFieldTypes, @@ -193,6 +195,8 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value { case *types.Map: typeFields = []llvm.Value{ c.getTypeCode(types.NewPointer(typ)), // ptrTo + c.getTypeCode(typ.Elem()), // elem + c.getTypeCode(typ.Key()), // key } case *types.Struct: typeFields = []llvm.Value{ diff --git a/src/reflect/type.go b/src/reflect/type.go index cc106a70..3998adc0 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -33,6 +33,8 @@ // - map types (this is still missing the key and element types) // meta uint8 // ptrTo *typeStruct +// elem *typeStruct +// key *typeStruct // - struct types (see structType): // meta uint8 // numField uint16 @@ -408,6 +410,13 @@ type arrayType struct { arrayLen uintptr } +type mapType struct { + rawType + ptrTo *rawType + elem *rawType + key *rawType +} + // 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 // architectures, the ptrTo field still has the same offset as in all the other