| 129 | |
| 130 | == Argument Processing Algorithms == |
| 131 | |
| 132 | Here is some documentation for ways that the argument processing algorithm ({{{Parrot_pcc_fill_params_from_op and Parrot_pcc_fill_params_from_varargs}}}) work. There are two possible ways, depending on whether we iterate over the list of parameters and pull arguments, or iterate over the list of arguments and push them into parameters. First, iterating over parameters (similar to what is done now): |
| 133 | |
| 134 | {{{ |
| 135 | Infinite loop |
| 136 | get next positional arg |
| 137 | get next positional parameter slot |
| 138 | |
| 139 | if parameter slot is NULL |
| 140 | if positional arg is NULL # No more of either, done. Break |
| 141 | break |
| 142 | if error checking |
| 143 | throw exception |
| 144 | if positional arg is NULL |
| 145 | if error checking |
| 146 | throw exception |
| 147 | |
| 148 | if parameter slot is slurpy |
| 149 | create new RPA PMC |
| 150 | insert new RPA PMC into destination context parameter slot |
| 151 | |
| 152 | if we have a slurpy array pmc |
| 153 | add positional arg to slurpy array pmc |
| 154 | else |
| 155 | Insert positional into destination context parameter slot |
| 156 | if current parameter slot is optional |
| 157 | set corresponding opt_flag TRUE |
| 158 | |
| 159 | Infinite loop |
| 160 | get next named arg name |
| 161 | get next named arg value |
| 162 | get next named parameter slot |
| 163 | |
| 164 | if arg name/value pair is NULL |
| 165 | if parameter slot is NULL |
| 166 | break # Even, we're done |
| 167 | else if error checking |
| 168 | throw exception |
| 169 | if parameter slot is NULL |
| 170 | throw exception |
| 171 | |
| 172 | if parmeter slot is slurpy |
| 173 | create new Hash PMC |
| 174 | insert new Hash PMC into destination context parameter slot |
| 175 | |
| 176 | if we have a slurpy hash PMC |
| 177 | add name/value pair to slurpy hash PMC |
| 178 | else |
| 179 | Insert value into destination context parameter slot |
| 180 | if current parameter slot is optional |
| 181 | set corresponding opt_flag to TRUE |
| 182 | |
| 183 | Loop over all remaining opt_flag parameters |
| 184 | set to FALSE |
| 185 | }}} |
| 186 | |
| 187 | Next, iterating over arguments. This requires iterator functionality installed into CallSignature, which does not currently exist: |
| 188 | |
| 189 | {{{ |
| 190 | Infinite loop |
| 191 | get next positional arg |
| 192 | get next parameter flag |
| 193 | |
| 194 | if no parameter flag |
| 195 | if no positional arg # No more of either, done. |
| 196 | end loop |
| 197 | if error checking |
| 198 | throw exception |
| 199 | if no positional arg |
| 200 | set all remaining positional opt_flags to FALSE |
| 201 | if error checking |
| 202 | throw exception |
| 203 | |
| 204 | if parameter flag is slurpy |
| 205 | create new RPA PMC |
| 206 | insert new RPA PMC into destination context parameter slot |
| 207 | add positional arg to slurpy array pmc |
| 208 | add all remaining positional args to slurpy array pmc |
| 209 | end loop |
| 210 | |
| 211 | Insert positional into destination context parameter slot |
| 212 | |
| 213 | if current parameter slot is optional |
| 214 | set corresponding opt_flag TRUE |
| 215 | |
| 216 | Infinite loop |
| 217 | get next named arg name |
| 218 | get next named arg value |
| 219 | get next parameter flag |
| 220 | |
| 221 | if no parameter flag |
| 222 | if no arg name/value pair |
| 223 | end loop # Even, we're done |
| 224 | if error checking |
| 225 | throw exception |
| 226 | if no arg name/value pair |
| 227 | set all remaining named opt_flags to FALSE |
| 228 | if error checking |
| 229 | throw exception |
| 230 | |
| 231 | if parameter flag is slurpy |
| 232 | create new Hash PMC |
| 233 | insert new Hash PMC into destination context parameter slot |
| 234 | add name/value pair to slurpy hash PMC |
| 235 | add all remaining name/value pairs to slurpy hash PMC |
| 236 | |
| 237 | Insert value into destination context parameter slot |
| 238 | if current parameter slot is optional |
| 239 | set corresponding opt_flag to TRUE |
| 240 | }}} |
| 241 | |