| 725 | |
| 726 | |
| 727 | Dynamic doRun(CppiaCtx *ctx, int inHaveArgs) |
| 728 | { |
| 729 | function->addExtraDefaults(ctx,inHaveArgs); |
| 730 | function->addStackVarsSpace(ctx); |
| 731 | |
| 732 | unsigned char *base = ((unsigned char *)this) + sizeof(CppiaClosure); |
| 733 | // this pointer... |
| 734 | *(hx::Object **)ctx->frame = *(hx::Object **)base; |
| 735 | |
| 736 | for(int i=0;i<function->captureVars.size();i++) |
| 737 | { |
| 738 | CppiaStackVar *var = function->captureVars[i]; |
| 739 | int size = sTypeSize[var->expressionType]; |
| 740 | memcpy( ctx->frame+var->stackPos, base + var->capturePos, size); |
| 741 | } |
| 742 | |
| 743 | #ifdef CPPIA_JIT |
| 744 | if (function->compiled) |
| 745 | { |
| 746 | { |
| 747 | AutoFrame frame(ctx); |
| 748 | function->compiled(ctx); |
| 749 | } |
| 750 | if (!ctx->exception) |
| 751 | { |
| 752 | switch(function->returnType) |
| 753 | { |
| 754 | case etFloat: |
| 755 | return ctx->getFloat(); |
| 756 | case etInt: |
| 757 | return ctx->getInt(); |
| 758 | case etString: |
| 759 | return ctx->getString(); |
| 760 | case etObject: |
| 761 | return ctx->getObject(); |
| 762 | default: ; |
| 763 | } |
| 764 | } |
| 765 | return null(); |
| 766 | } |
| 767 | //printf("Not compiled %d!\n", function->captureVars.size()); |
| 768 | //todo - compiled? |
| 769 | #endif |
| 770 | |
| 771 | // TODO - stack var space added twice? |
| 772 | function->runFunctionClosure(ctx); |
| 773 | ctx->breakContReturn = 0; |
| 774 | |
| 775 | switch(function->returnType) |
| 776 | { |
| 777 | case etFloat: |
| 778 | return ctx->getFloat( ); |
| 779 | case etInt: |
| 780 | return ctx->getInt( ); |
| 781 | case etString: |
| 782 | return ctx->getString( ); |
| 783 | case etObject: |
| 784 | return ctx->getObject( ); |
nothing calls this directly
no test coverage detected