@@ -31,7 +31,6 @@ int exec_close_task();
3131void sys_before_comp ();
3232
3333static char fileName [OS_FILENAME_SIZE + 1 ];
34- static int exec_tid ;
3534static stknode_t err_node ;
3635
3736#define EVT_CHECK_EVERY 50
@@ -1528,47 +1527,7 @@ int sbasic_recursive_exec(int tid) {
15281527}
15291528
15301529/**
1531- * dump-taskinfo
1532- */
1533- void sbasic_dump_taskinfo (FILE * output ) {
1534- int i ;
1535- int prev_tid = 0 ;
1536-
1537- fprintf (output , "\n* task list:\n" );
1538- for (i = 0 ; i < count_tasks (); i ++ ) {
1539- prev_tid = activate_task (i );
1540- fprintf (output , " id %d, child of %d, file %s, status %d\n" , ctask -> tid , ctask -> parent , ctask -> file ,
1541- ctask -> status );
1542- }
1543- activate_task (prev_tid );
1544- }
1545-
1546- /**
1547- * dump-bytecode
1548- */
1549- void sbasic_dump_bytecode (int tid , FILE * output ) {
1550- int i ;
1551- int prev_tid ;
1552-
1553- prev_tid = activate_task (tid );
1554-
1555- for (i = 0 ; i < count_tasks (); i ++ ) {
1556- activate_task (i );
1557- if (ctask -> parent == tid ) {
1558- // do the same for the childs
1559- sbasic_dump_bytecode (ctask -> tid , output );
1560- }
1561- }
1562-
1563- activate_task (tid );
1564- fprintf (output , "\n* task: %d/%d (%s)\n" , ctask -> tid , count_tasks (), prog_file );
1565- // run the code
1566- dump_bytecode (output );
1567- activate_task (prev_tid );
1568- }
1569-
1570- /**
1571- * TODO add comment
1530+ * compile the given file into bytecode
15721531 */
15731532int sbasic_compile (const char * file ) {
15741533 int comp_rq = 0 ; // compilation required = 0
@@ -1626,18 +1585,21 @@ int sbasic_compile(const char *file) {
16261585/**
16271586 * initialize executor and run a binary
16281587 */
1629- void sbasic_exec_prepare (const char * filename ) {
1588+ int sbasic_exec_prepare (const char * filename ) {
1589+ int taskId ;
1590+
16301591 v_init_pool ();
16311592
16321593 // load source
16331594 if (opt_nosave ) {
1634- exec_tid = brun_create_task (filename , ctask -> bytecode , 0 );
1595+ taskId = brun_create_task (filename , ctask -> bytecode , 0 );
16351596 } else {
1636- exec_tid = brun_create_task (filename , 0 , 0 );
1597+ taskId = brun_create_task (filename , 0 , 0 );
16371598 }
16381599 // reset system
16391600 cmd_play_reset ();
16401601 graph_reset ();
1602+ return taskId ;
16411603}
16421604
16431605/*
@@ -1694,9 +1656,6 @@ int sbasic_exec(const char *file) {
16941656 opt_pref_height = 0 ;
16951657 opt_show_page = 0 ;
16961658
1697- if (opt_decomp ) {
1698- opt_nosave = 1 ;
1699- }
17001659 // setup global values
17011660 gsb_last_line = gsb_last_error = 0 ;
17021661 strlcpy (gsb_last_file , file , sizeof (gsb_last_file ));
@@ -1708,20 +1667,14 @@ int sbasic_exec(const char *file) {
17081667 // cannot run a unit
17091668 exec_rq = 0 ;
17101669 gsb_last_error = 1 ;
1711- } else if (opt_decomp && success ) {
1712- sbasic_exec_prepare (file ); // load everything
1713- sbasic_dump_taskinfo (stdout );
1714- sbasic_dump_bytecode (exec_tid , stdout );
1715- exec_close (exec_tid ); // clean up executor's garbages
1716- exec_rq = 0 ;
17171670 } else if (!success ) { // there was some errors; do not continue
17181671 exec_rq = 0 ;
17191672 gsb_last_error = 1 ;
17201673 }
17211674
17221675 if (exec_rq ) { // we will run it
17231676 // load everything
1724- sbasic_exec_prepare (file );
1677+ int exec_tid = sbasic_exec_prepare (file );
17251678
17261679 dev_init (opt_graphics , 0 ); // initialize output device for graphics
17271680 srand (clock ()); // randomize
0 commit comments