Changes between Version 13 and Version 14 of CallingConventionsOverview

Show
Ignore:
Timestamp:
10/04/09 00:58:32 (12 years ago)
Author:
whiteknight
Comment:

post outlines for argument processing algorithms, for reference.

Legend:

Unmodified
Added
Removed
Modified
  • CallingConventionsOverview

    v13 v14  
    127127 
    128128- Likely bug in Parrot_call_sub reimplementation (t/src/embed.t) 
     129 
     130== Argument Processing Algorithms == 
     131 
     132Here 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{{{ 
     135Infinite 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 
     159Infinite 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 
     183Loop over all remaining opt_flag parameters 
     184    set to FALSE 
     185}}} 
     186 
     187Next, iterating over arguments. This requires iterator functionality installed into CallSignature, which does not currently exist: 
     188 
     189{{{ 
     190Infinite 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 
     216Infinite 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