(ctx context.Context, id *call.ID)
| 104 | } |
| 105 | |
| 106 | func resultCallFromRecipeIDInput(ctx context.Context, id *call.ID) (*ResultCall, error) { |
| 107 | if id == nil { |
| 108 | return nil, nil |
| 109 | } |
| 110 | if id.IsHandle() { |
| 111 | return nil, fmt.Errorf("handle-form IDs cannot be converted to inline recipe calls: %s", idInputDebugString(id)) |
| 112 | } |
| 113 | |
| 114 | var callType *ResultCallType |
| 115 | if id.Type() != nil { |
| 116 | callType = NewResultCallType(id.Type().ToAST()) |
| 117 | } |
| 118 | frame := &ResultCall{ |
| 119 | Kind: ResultCallKindField, |
| 120 | Type: callType, |
| 121 | Field: id.Field(), |
| 122 | View: id.View(), |
| 123 | Nth: id.Nth(), |
| 124 | EffectIDs: id.EffectIDs(), |
| 125 | ExtraDigests: id.ExtraDigests(), |
| 126 | } |
| 127 | |
| 128 | if receiver := id.Receiver(); receiver != nil { |
| 129 | receiverRef, err := resultCallRefFromIDInput(ctx, receiver) |
| 130 | if err != nil { |
| 131 | return nil, fmt.Errorf("receiver: %w", err) |
| 132 | } |
| 133 | frame.Receiver = receiverRef |
| 134 | } |
| 135 | if mod := id.Module(); mod != nil { |
| 136 | modRef, err := resultCallRefFromIDInput(ctx, mod.ID()) |
| 137 | if err != nil { |
| 138 | return nil, fmt.Errorf("module: %w", err) |
| 139 | } |
| 140 | frame.Module = &ResultCallModule{ |
| 141 | ResultRef: modRef, |
| 142 | Name: mod.Name(), |
| 143 | Ref: mod.Ref(), |
| 144 | Pin: mod.Pin(), |
| 145 | } |
| 146 | } |
| 147 | for _, arg := range id.Args() { |
| 148 | converted, err := resultCallArgFromRecipeArgument(ctx, arg) |
| 149 | if err != nil { |
| 150 | return nil, fmt.Errorf("arg %q: %w", arg.Name(), err) |
| 151 | } |
| 152 | frame.Args = append(frame.Args, converted) |
| 153 | } |
| 154 | for _, input := range id.ImplicitInputs() { |
| 155 | converted, err := resultCallArgFromRecipeArgument(ctx, input) |
| 156 | if err != nil { |
| 157 | return nil, fmt.Errorf("implicit input %q: %w", input.Name(), err) |
| 158 | } |
| 159 | frame.ImplicitInputs = append(frame.ImplicitInputs, converted) |
| 160 | } |
| 161 | return frame, nil |
| 162 | } |
| 163 |
no test coverage detected