MCPcopy
hub / github.com/google/mangle / Modes

Method Modes

ast/decl.go:185–214  ·  view source on GitHub ↗

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. "?" ... "?".

()

Source from the content-addressed store, hash-verified

183// Returns nil if the declaration does not declare modes. This is
184// always interpreted as supporting all modes i.e. "?" ... "?".
185func (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).
217func (d Decl) PackageID() string {

Callers 7

oneStepEvalPremiseMethod · 0.80
EvalPremiseMethod · 0.80
newInferContextFunction · 0.80
checkMethod · 0.80
scrutineeIsInputArgFunction · 0.80
RewriteClauseFunction · 0.80
CheckRuleMethod · 0.80

Calls 1

findDescrMethod · 0.95

Tested by

no test coverage detected