Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

run.c

00001  /*
00002   * plint/prog/run.c : functions which control the flow of the program
00003   * 
00004   * Time-stamp: <2002-10-06 03:02:27 gseba>
00005   * 
00006   * Copyright (C) Sebastian Glita, email: gseba@users.sourceforge.net
00007   * 
00008   * This file is part of plint.
00009   * 
00010   * plint is free software; you can  redistribute it and/or modify it under the
00011   * terms of the  GNU General Public License as published  by the Free Software
00012   * Foundation; either version 2, or (at your option) any later version.
00013   *
00014   * plint  is distributed  in the  hope  that it  will be  useful, but  WITHOUT
00015   * ANY  WARRANTY; without  even  the implied  warranty  of MERCHANTABILITY  or
00016   * FITNESS FOR A  PARTICULAR PURPOSE.  See the GNU  General Public License for
00017   * more details.
00018   * 
00019   * You should  have received a  copy of the  GNU General Public  License along
00020   * with  plint; see  the file  COPYING.  If  not, write  to the  Free Software
00021   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA USA.
00022   *
00023   */
00024 
00025 #pragma GCC dependency "Makefile" maybe some command line defines have changed
00026 
00027 #include "plint.h"
00028 #include "share.h"
00029 #include "error.h"
00030 
00031 #include "data.h"
00032 #include "var.h"
00033 #include "stack.h"
00034 #include "flow.h"
00035 #include "action.h"
00036 #include "iterate.h"
00037 
00038 #include "misc/file.h"
00039 #include "misc/sys.h"
00040 
00041 
00042 void plint_start_run()
00043 {
00044   plint_ins.prnt = 0;
00045 
00046   plint_code.root->flag = 4; /* top procedure was called implicitly, mark it */
00047   plint_stack_push(plint_code.root);
00048   plint_stack.bot = plint_stack.top;
00049 
00050   PLINT_VAR_ADD(plint_var_dup(plint->data.argo), plint_str_sn(plint_argo_str));
00051   PLINT_VAR_ADD(plint_var_dup(plint->data.argv), plint_str_sn(plint_argv_str));
00052 }
00053 
00054 void plint_end_run()
00055 {
00056 }
00057 
00058 
00059 
00060 #include "parse/mygrm.h"
00061 int plint_run_eof()
00062 {
00063   if (plint->flow.ctl.type == PLINT_CTL_NONE)
00064     {
00065       if (plint->act._type == PLINT_ACT_NONE)
00066         {
00067           if (plint->iter == PLINT_ITER_NONE)
00068             goto flow_eof;
00069 
00070           switch (plint->iter)
00071             {
00072               case PLINT_ITER_NEXT:
00073                 return ITER_NEXT;
00074 
00075               case PLINT_ITER_DONE:
00076                 return ITER_DONE;
00077 
00078             default:
00079             }
00080           assert(0);
00081           return 0;
00082         }
00083 
00084       switch (plint->act._type)
00085         {
00086         case PLINT_ACT_DONE:
00087           return ACT_DONE;
00088 
00089         case PLINT_ACT_CALL:
00090         case PLINT_ACT_SEEK:
00091           return ACT_REDO;
00092 
00093         default:
00094         }
00095       assert(0);
00096       return 0;
00097     }
00098 
00099  flow_eof:
00100 
00101   switch (plint->flow.ctl.type)
00102     {
00103     case PLINT_CTL_EXIT:
00104     case PLINT_CTL_RETN:
00105     case PLINT_CTL_ESCP:
00106     case PLINT_CTL_BREK:        
00107       return RUN_DONE;
00108 
00109     default:
00110       if (plint->flow.ctl.count)
00111         return RUN_DONE;
00112     }
00113 
00114   if (PLINT_CTRL_LOOP || !PLINT_MAP_BLOCK(EXIT, plint_stack.top->block.src->blk, &plint_stack.top->block))
00115     {
00116       plint->flow.ctl.type = PLINT_CTL_LOOP;
00117       return RUN_REDO;
00118     }
00119 
00120   return RUN_DONE;
00121 }

Generated on Thu Jan 9 19:02:38 2003 for plint by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002