SubsetFunction produces a function declaration which matches the supported subset, or nil if the function is not supported by the LibrarySubset. For IncludeFunctions, if the function does not specify a set of overloads to include, the whole function definition is included. If overloads are set, the
(fn *decls.FunctionDecl)
| 579 | // whole function definition is excluded. If overloads are set, then a new function which |
| 580 | // includes only the permitted overloads is produced. |
| 581 | func (lib *LibrarySubset) SubsetFunction(fn *decls.FunctionDecl) (*decls.FunctionDecl, bool) { |
| 582 | // When lib is null, it should indicate that all values are included in the subset. |
| 583 | if lib == nil { |
| 584 | return fn, true |
| 585 | } |
| 586 | if lib.Disabled { |
| 587 | return nil, false |
| 588 | } |
| 589 | if len(lib.IncludeFunctions) != 0 { |
| 590 | for _, include := range lib.IncludeFunctions { |
| 591 | if include.Name != fn.Name() { |
| 592 | continue |
| 593 | } |
| 594 | if len(include.Overloads) == 0 { |
| 595 | return fn, true |
| 596 | } |
| 597 | overloadIDs := make([]string, len(include.Overloads)) |
| 598 | for i, o := range include.Overloads { |
| 599 | overloadIDs[i] = o.ID |
| 600 | } |
| 601 | return fn.Subset(decls.IncludeOverloads(overloadIDs...)), true |
| 602 | } |
| 603 | return nil, false |
| 604 | } |
| 605 | if len(lib.ExcludeFunctions) != 0 { |
| 606 | for _, exclude := range lib.ExcludeFunctions { |
| 607 | if exclude.Name != fn.Name() { |
| 608 | continue |
| 609 | } |
| 610 | if len(exclude.Overloads) == 0 { |
| 611 | return nil, false |
| 612 | } |
| 613 | overloadIDs := make([]string, len(exclude.Overloads)) |
| 614 | for i, o := range exclude.Overloads { |
| 615 | overloadIDs[i] = o.ID |
| 616 | } |
| 617 | return fn.Subset(decls.ExcludeOverloads(overloadIDs...)), true |
| 618 | } |
| 619 | return fn, true |
| 620 | } |
| 621 | return fn, true |
| 622 | } |
| 623 | |
| 624 | // SubsetMacro indicates whether the macro function should be included in the library subset. |
| 625 | func (lib *LibrarySubset) SubsetMacro(macroFunction string) bool { |