| 4148 | */ |
| 4149 | |
| 4150 | LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) |
| 4151 | { |
| 4152 | JAM_FUNCTION * function; |
| 4153 | instruction * code; |
| 4154 | LIST * l; |
| 4155 | LIST * r; |
| 4156 | LIST * result = L0; |
| 4157 | #ifndef NDEBUG |
| 4158 | void * saved_stack = s->data; |
| 4159 | #endif |
| 4160 | |
| 4161 | PROFILE_ENTER_LOCAL(function_run); |
| 4162 | |
| 4163 | #ifdef JAM_DEBUGGER |
| 4164 | frame->function = function_; |
| 4165 | #endif |
| 4166 | |
| 4167 | if ( function_->type == FUNCTION_BUILTIN ) |
| 4168 | { |
| 4169 | PROFILE_ENTER_LOCAL(function_run_FUNCTION_BUILTIN); |
| 4170 | BUILTIN_FUNCTION const * const f = (BUILTIN_FUNCTION *)function_; |
| 4171 | if ( function_->formal_arguments ) |
| 4172 | argument_list_check( function_->formal_arguments, |
| 4173 | function_->num_formal_arguments, function_, frame ); |
| 4174 | |
| 4175 | debug_on_enter_function( frame, f->base.rulename, NULL, -1 ); |
| 4176 | result = f->func( frame, f->flags ); |
| 4177 | debug_on_exit_function( f->base.rulename ); |
| 4178 | PROFILE_EXIT_LOCAL(function_run_FUNCTION_BUILTIN); |
| 4179 | PROFILE_EXIT_LOCAL(function_run); |
| 4180 | return result; |
| 4181 | } |
| 4182 | |
| 4183 | #ifdef HAVE_PYTHON |
| 4184 | else if ( function_->type == FUNCTION_PYTHON ) |
| 4185 | { |
| 4186 | PROFILE_ENTER_LOCAL(function_run_FUNCTION_PYTHON); |
| 4187 | PYTHON_FUNCTION * f = (PYTHON_FUNCTION *)function_; |
| 4188 | debug_on_enter_function( frame, f->base.rulename, NULL, -1 ); |
| 4189 | result = call_python_function( f, frame ); |
| 4190 | debug_on_exit_function( f->base.rulename ); |
| 4191 | PROFILE_EXIT_LOCAL(function_run_FUNCTION_PYTHON); |
| 4192 | PROFILE_EXIT_LOCAL(function_run); |
| 4193 | return result; |
| 4194 | } |
| 4195 | #endif |
| 4196 | |
| 4197 | assert( function_->type == FUNCTION_JAM ); |
| 4198 | |
| 4199 | if ( function_->formal_arguments ) |
| 4200 | argument_list_push( function_->formal_arguments, |
| 4201 | function_->num_formal_arguments, function_, frame, s ); |
| 4202 | |
| 4203 | function = (JAM_FUNCTION *)function_; |
| 4204 | debug_on_enter_function( frame, function->base.rulename, function->file, function->line ); |
| 4205 | code = function->code; |
| 4206 | for ( ; ; ) |
| 4207 | { |
no test coverage detected