// +build !gccgo

package reflect2

import (
	
	
	
)

// typelinks2 for 1.7 ~
//go:linkname typelinks2 reflect.typelinks
func typelinks2() ( []unsafe.Pointer,  [][]int32)

// initOnce guards initialization of types and packages
var initOnce sync.Once

var types map[string]reflect.Type
var packages map[string]map[string]reflect.Type

// discoverTypes initializes types and packages
func discoverTypes() {
	types = make(map[string]reflect.Type)
	packages = make(map[string]map[string]reflect.Type)

	loadGoTypes()
}

func loadGoTypes() {
	var  interface{} = reflect.TypeOf(0)
	,  := typelinks2()
	for ,  := range  {
		 := []
		for ,  := range  {
			(*emptyInterface)(unsafe.Pointer(&)).word = resolveTypeOff(unsafe.Pointer(), )
			 := .(reflect.Type)
			if .Kind() == reflect.Ptr && .Elem().Kind() == reflect.Struct {
				 := .Elem()
				 := packages[.PkgPath()]
				if  == nil {
					 = map[string]reflect.Type{}
					packages[.PkgPath()] = 
				}
				types[.String()] = 
				[.Name()] = 
			}
		}
	}
}

type emptyInterface struct {
	typ  unsafe.Pointer
	word unsafe.Pointer
}

// TypeByName return the type by its name, just like Class.forName in java
func ( string) Type {
	initOnce.Do(discoverTypes)
	return Type2(types[])
}

// TypeByPackageName return the type by its package and name
func ( string,  string) Type {
	initOnce.Do(discoverTypes)
	 := packages[]
	if  == nil {
		return nil
	}
	return Type2([])
}