Пример #1
0
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
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)
	}
}