gotools/go/ast/inspector/typeof.go

const nArrayType

const nAssignStmt

const nBadDecl

const nBadExpr

const nBadStmt

const nBasicLit

const nBinaryExpr

const nBlockStmt

const nBranchStmt

const nCallExpr

const nCaseClause

const nChanType

const nCommClause

const nComment

const nCommentGroup

const nCompositeLit

const nDeclStmt

const nDeferStmt

const nEllipsis

const nEmptyStmt

const nExprStmt

const nField

const nFieldList

const nFile

const nForStmt

const nFuncDecl

const nFuncLit

const nFuncType

const nGenDecl

const nGoStmt

const nIdent

const nIfStmt

const nImportSpec

const nIncDecStmt

const nIndexExpr

const nIndexListExpr

const nInterfaceType

const nKeyValueExpr

const nLabeledStmt

const nMapType

const nPackage

const nParenExpr

const nRangeStmt

const nReturnStmt

const nSelectStmt

const nSelectorExpr

const nSendStmt

const nSliceExpr

const nStarExpr

const nStructType

const nSwitchStmt

const nTypeAssertExpr

const nTypeSpec

const nTypeSwitchStmt

const nUnaryExpr

const nValueSpec

// typeOf returns a distinct single-bit value that represents the type of n.
//
// Various implementations were benchmarked with BenchmarkNewInspector:
//
//	                                                                GOGC=off
//	- type switch					4.9-5.5ms	2.1ms
//	- binary search over a sorted list of types	5.5-5.9ms	2.5ms
//	- linear scan, frequency-ordered list		5.9-6.1ms	2.7ms
//	- linear scan, unordered list			6.4ms		2.7ms
//	- hash table					6.5ms		3.1ms
//
// A perfect hash seemed like overkill.
//
// The compiler's switch statement is the clear winner
// as it produces a binary tree in code,
// with constant conditions and good branch prediction.
// (Sadly it is the most verbose in source code.)
// Binary search suffered from poor branch prediction.
func typeOf(n ast.Node) uint64 {}

func maskOf(nodes []ast.Node) uint64 {}