| 3044 | } |
| 3045 | |
| 3046 | void argument_list_push( struct arg_list * formal, int formal_count, |
| 3047 | FUNCTION * function, FRAME * frame, STACK * s ) |
| 3048 | { |
| 3049 | LOL * all_actual = frame->args; |
| 3050 | int i; |
| 3051 | |
| 3052 | for ( i = 0; i < formal_count; ++i ) |
| 3053 | { |
| 3054 | LIST * actual = lol_get( all_actual, i ); |
| 3055 | LISTITER actual_iter = list_begin( actual ); |
| 3056 | LISTITER const actual_end = list_end( actual ); |
| 3057 | int j; |
| 3058 | for ( j = 0; j < formal[ i ].size; ++j ) |
| 3059 | { |
| 3060 | struct argument * formal_arg = &formal[ i ].args[ j ]; |
| 3061 | LIST * value; |
| 3062 | |
| 3063 | switch ( formal_arg->flags ) |
| 3064 | { |
| 3065 | case ARG_ONE: |
| 3066 | if ( actual_iter == actual_end ) |
| 3067 | argument_error( "missing argument", function, frame, |
| 3068 | formal_arg->arg_name ); |
| 3069 | value = list_new( object_copy( list_item( actual_iter ) ) ); |
| 3070 | actual_iter = list_next( actual_iter ); |
| 3071 | break; |
| 3072 | case ARG_OPTIONAL: |
| 3073 | if ( actual_iter == actual_end ) |
| 3074 | value = L0; |
| 3075 | else |
| 3076 | { |
| 3077 | value = list_new( object_copy( list_item( actual_iter ) ) ); |
| 3078 | actual_iter = list_next( actual_iter ); |
| 3079 | } |
| 3080 | break; |
| 3081 | case ARG_PLUS: |
| 3082 | if ( actual_iter == actual_end ) |
| 3083 | argument_error( "missing argument", function, frame, |
| 3084 | formal_arg->arg_name ); |
| 3085 | /* fallthrough */ |
| 3086 | case ARG_STAR: |
| 3087 | value = list_copy_range( actual, actual_iter, actual_end ); |
| 3088 | actual_iter = actual_end; |
| 3089 | break; |
| 3090 | case ARG_VARIADIC: |
| 3091 | return; |
| 3092 | } |
| 3093 | |
| 3094 | type_check( formal_arg->type_name, value, frame, function, |
| 3095 | formal_arg->arg_name ); |
| 3096 | |
| 3097 | if ( formal_arg->index != -1 ) |
| 3098 | { |
| 3099 | LIST * * const old = &frame->module->fixed_variables[ |
| 3100 | formal_arg->index ]; |
| 3101 | stack_push( s, *old ); |
| 3102 | *old = value; |
| 3103 | } |
no test coverage detected