| 3756 | */ |
| 3757 | |
| 3758 | LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) |
| 3759 | { |
| 3760 | JAM_FUNCTION * function; |
| 3761 | instruction * code; |
| 3762 | LIST * l; |
| 3763 | LIST * r; |
| 3764 | LIST * result = L0; |
| 3765 | void * saved_stack = s->data; |
| 3766 | |
| 3767 | if ( function_->type == FUNCTION_BUILTIN ) |
| 3768 | { |
| 3769 | BUILTIN_FUNCTION const * const f = (BUILTIN_FUNCTION *)function_; |
| 3770 | if ( function_->formal_arguments ) |
| 3771 | argument_list_check( function_->formal_arguments, |
| 3772 | function_->num_formal_arguments, function_, frame ); |
| 3773 | return f->func( frame, f->flags ); |
| 3774 | } |
| 3775 | |
| 3776 | #ifdef HAVE_PYTHON |
| 3777 | else if ( function_->type == FUNCTION_PYTHON ) |
| 3778 | { |
| 3779 | PYTHON_FUNCTION * f = (PYTHON_FUNCTION *)function_; |
| 3780 | return call_python_function( f, frame ); |
| 3781 | } |
| 3782 | #endif |
| 3783 | |
| 3784 | assert( function_->type == FUNCTION_JAM ); |
| 3785 | |
| 3786 | if ( function_->formal_arguments ) |
| 3787 | argument_list_push( function_->formal_arguments, |
| 3788 | function_->num_formal_arguments, function_, frame, s ); |
| 3789 | |
| 3790 | function = (JAM_FUNCTION *)function_; |
| 3791 | code = function->code; |
| 3792 | for ( ; ; ) |
| 3793 | { |
| 3794 | switch ( code->op_code ) |
| 3795 | { |
| 3796 | |
| 3797 | /* |
| 3798 | * Basic stack manipulation |
| 3799 | */ |
| 3800 | |
| 3801 | case INSTR_PUSH_EMPTY: |
| 3802 | stack_push( s, L0 ); |
| 3803 | break; |
| 3804 | |
| 3805 | case INSTR_PUSH_CONSTANT: |
| 3806 | { |
| 3807 | OBJECT * value = function_get_constant( function, code->arg ); |
| 3808 | stack_push( s, list_new( object_copy( value ) ) ); |
| 3809 | break; |
| 3810 | } |
| 3811 | |
| 3812 | case INSTR_PUSH_ARG: |
| 3813 | stack_push( s, frame_get_local( frame, code->arg ) ); |
| 3814 | break; |
| 3815 |
no test coverage detected