コード例 #1
0
ファイル: deadcode.go プロジェクト: xingskycn/php-1
func EliminateCalls(nodes []ast.Node, knownFunctions map[string]ast.Node) {
	for _, node := range nodes {
		switch node := node.(type) {
		case ast.FunctionCallExpression:
			if static := ast.Static(node.FunctionName); static != nil {
				delete(knownFunctions, static.Value)
			}
		case *ast.FunctionCallExpression:
			if static := ast.Static(node.FunctionName); static != nil {
				delete(knownFunctions, static.Value)
			}
		}
		EliminateCalls(node.Children(), knownFunctions)
	}

}
コード例 #2
0
ファイル: classes.go プロジェクト: henrylee2cn/php
func EliminateClasses(nodes []ast.Node, knownClasses map[string]ast.Node) {
	for _, node := range nodes {
		switch node := node.(type) {
		case ast.NewCallExpr:
			if static := ast.Static(node.Class); static != nil {
				delete(knownClasses, static.Value)
			}
		case *ast.NewCallExpr:
			if static := ast.Static(node.Class); static != nil {
				delete(knownClasses, static.Value)
			}
		case ast.ClassExpr:
			if static := ast.Static(node.Receiver); static != nil {
				delete(knownClasses, static.Value)
			}
		case *ast.ClassExpr:
			if static := ast.Static(node.Receiver); static != nil {
				delete(knownClasses, static.Value)
			}
		}
		EliminateClasses(node.Children(), knownClasses)
	}
}