| 2976 | } |
| 2977 | |
| 2978 | void argument_list_check( struct arg_list * formal, int formal_count, |
| 2979 | FUNCTION * function, FRAME * frame ) |
| 2980 | { |
| 2981 | LOL * all_actual = frame->args; |
| 2982 | int i; |
| 2983 | |
| 2984 | for ( i = 0; i < formal_count; ++i ) |
| 2985 | { |
| 2986 | LIST * actual = lol_get( all_actual, i ); |
| 2987 | LISTITER actual_iter = list_begin( actual ); |
| 2988 | LISTITER const actual_end = list_end( actual ); |
| 2989 | int j; |
| 2990 | for ( j = 0; j < formal[ i ].size; ++j ) |
| 2991 | { |
| 2992 | struct argument * formal_arg = &formal[ i ].args[ j ]; |
| 2993 | LIST * value; |
| 2994 | |
| 2995 | switch ( formal_arg->flags ) |
| 2996 | { |
| 2997 | case ARG_ONE: |
| 2998 | if ( actual_iter == actual_end ) |
| 2999 | argument_error( "missing argument", function, frame, |
| 3000 | formal_arg->arg_name ); |
| 3001 | type_check_range( formal_arg->type_name, actual_iter, |
| 3002 | list_next( actual_iter ), frame, function, |
| 3003 | formal_arg->arg_name ); |
| 3004 | actual_iter = list_next( actual_iter ); |
| 3005 | break; |
| 3006 | case ARG_OPTIONAL: |
| 3007 | if ( actual_iter == actual_end ) |
| 3008 | value = L0; |
| 3009 | else |
| 3010 | { |
| 3011 | type_check_range( formal_arg->type_name, actual_iter, |
| 3012 | list_next( actual_iter ), frame, function, |
| 3013 | formal_arg->arg_name ); |
| 3014 | actual_iter = list_next( actual_iter ); |
| 3015 | } |
| 3016 | break; |
| 3017 | case ARG_PLUS: |
| 3018 | if ( actual_iter == actual_end ) |
| 3019 | argument_error( "missing argument", function, frame, |
| 3020 | formal_arg->arg_name ); |
| 3021 | /* fallthrough */ |
| 3022 | case ARG_STAR: |
| 3023 | type_check_range( formal_arg->type_name, actual_iter, |
| 3024 | actual_end, frame, function, formal_arg->arg_name ); |
| 3025 | actual_iter = actual_end; |
| 3026 | break; |
| 3027 | case ARG_VARIADIC: |
| 3028 | return; |
| 3029 | } |
| 3030 | } |
| 3031 | |
| 3032 | if ( actual_iter != actual_end ) |
| 3033 | argument_error( "extra argument", function, frame, list_item( |
| 3034 | actual_iter ) ); |
| 3035 | } |
no test coverage detected