/*************************************************************************** whileblock.cpp - description ------------------- begin : Thu Mar 20 20:43:35 2003 copyright : (C) 2002 by Cavalli Andrea email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include extern int interrupt; ZObj * WhileBlock::eval(){ //exec_line done exec_line = line; ZObj * res = expr->eval(); if(!is_zbool(res)){ ZObj::remove(res); throw ZError(line,"Invalid expression"); } ZBool * b = (ZBool*)res; while(b->data){ if(interrupt){ char buff[256]; sprintf(buff,"excution of while block stopped at line %i",line); throw string(buff); } ZObj * t; if(block!=NULL) t = block->eval(); else t = new ZStatus(true); if(is_zret(t)){ return t; } if(is_zcont(t)){ throw ZError(line,"continue not allowed in while block"); } if(is_zbreak(t)){ ZObj::remove(b); ZObj::remove(t); return new ZStatus(true); } ZObj::remove(t); ZObj::remove(b); b = (ZBool*) expr->eval(); } ZObj::remove(b); return new ZStatus(true); }