Modes returns the supported modes declared for this predicate. Returns nil if the declaration does not declare modes. This is always interpreted as supporting all modes i.e. "?" ... "?".
()
| 183 | // Returns nil if the declaration does not declare modes. This is |
| 184 | // always interpreted as supporting all modes i.e. "?" ... "?". |
| 185 | func (d Decl) Modes() []Mode { |
| 186 | convertMode := func(args []BaseTerm) Mode { |
| 187 | var mode Mode |
| 188 | for _, arg := range args { |
| 189 | m, ok := arg.(Constant) |
| 190 | if !ok || m.Type != StringType { |
| 191 | return nil |
| 192 | } |
| 193 | switch m.Symbol { |
| 194 | case InputString: |
| 195 | mode = append(mode, ArgModeInput) |
| 196 | case OutputString: |
| 197 | mode = append(mode, ArgModeOutput) |
| 198 | case InputOutputString: |
| 199 | mode = append(mode, ArgModeInputOutput) |
| 200 | default: |
| 201 | return nil |
| 202 | } |
| 203 | } |
| 204 | return mode |
| 205 | } |
| 206 | var modes []Mode |
| 207 | d.findDescr(DescrMode, func(a Atom) { |
| 208 | mode := convertMode(a.Args) |
| 209 | if len(mode) > 0 { |
| 210 | modes = append(modes, mode) |
| 211 | } |
| 212 | }) |
| 213 | return modes |
| 214 | } |
| 215 | |
| 216 | // PackageID returns the package part (dirname). |
| 217 | func (d Decl) PackageID() string { |
no test coverage detected