コード例 #1
0
ファイル: type.go プロジェクト: MovingtoMars/nnvm
func TypeSizeInBits(typ types.Type) int {
	switch typ := typ.(type) {
	case *types.Int:
		w := typ.Width()
		for w%8 != 0 {
			w++
		}
		return w

	case *types.Float:
		return typ.Type().Width()

	case *types.Pointer:
		return 64

	case *types.Array:
		return TypeSizeInBits(typ.Element()) * typ.Length()

	case *types.Struct:
		return newStructLayout(typ).size

	default:
		panic("unim")
	}
}