+ }
+
+cleanup:
+ if (developer_insane.integer && vm_tempstringsbuf.cursize > restorevm_tempstringsbuf_cursize)
+ Con_DPrintf("CLVM_ExecuteProgram: %s used %i bytes of tempstrings\n", PRVM_GetString(prog->functions[fnum].s_name), vm_tempstringsbuf.cursize - restorevm_tempstringsbuf_cursize);
+ // delete tempstrings created by this function
+ vm_tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
+
+ f->totaltime += (Sys_DoubleTime() - calltime);
+
+ SV_FlushBroadcastMessages();
+}
+#endif
+
+/*
+====================
+SVVM_ExecuteProgram
+====================
+*/
+void SVVM_ExecuteProgram (func_t fnum, const char *errormessage)
+{
+ mstatement_t *st, *startst;
+ mfunction_t *f, *newf;
+ prvm_edict_t *ed;
+ prvm_eval_t *ptr;
+ int jumpcount, cachedpr_trace, exitdepth;
+ int restorevm_tempstringsbuf_cursize;
+ double calltime;
+ double tm, starttm;
+
+ calltime = Sys_DoubleTime();
+
+ if (!fnum || fnum >= (unsigned int)prog->numfunctions)
+ {
+ if (PRVM_allglobaledict(self))
+ PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)), NULL);
+ PRVM_ERROR ("SVVM_ExecuteProgram: %s", errormessage);
+ }
+
+ f = &prog->functions[fnum];
+
+ // after executing this function, delete all tempstrings it created
+ restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
+
+ prog->trace = prvm_traceqc.integer;
+
+ // we know we're done when pr_depth drops to this
+ exitdepth = prog->depth;
+
+// make a stack frame
+ st = &prog->statements[PRVM_EnterFunction (f)];
+ // save the starting statement pointer for profiling
+ // (when the function exits or jumps, the (st - startst) integer value is
+ // added to the function's profile counter)
+ startst = st;
+ starttm = calltime;
+ // instead of counting instructions, we count jumps
+ jumpcount = 0;
+ // add one to the callcount of this function because otherwise engine-called functions aren't counted
+ prog->xfunction->callcount++;
+
+chooseexecprogram:
+ cachedpr_trace = prog->trace;
+ if (prvm_statementprofiling.integer || prog->trace)
+ {
+#define PRVMSLOWINTERPRETER 1
+ if (prvm_timeprofiling.integer)
+ {
+#define PRVMTIMEPROFILING 1
+#include "prvm_execprogram.h"
+#undef PRVMTIMEPROFILING
+ }