/*************************************************************************** forblock.cpp - description ------------------- begin : Thu Mar 20 20:44:15 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 #include extern int interrupt; ForBlock::~ForBlock(){ delete ass; delete exp1; delete exp2; if(block) delete block; } ZObj * ForBlock::eval(){ //exec_line done exec_line = line; //eval assignment ZObj * res = ass->eval(); ZObj::remove(res); //eval exp1 res = exp1->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 for 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; } //continue // if(is_zcont(t)){ // ZObj::remove(res); // exp2->eval(); // } if(is_zbreak(t)){ ZObj::remove(b); ZObj::remove(t); return new ZStatus(true); } ZObj::remove(t); ZObj::remove(b); ZObj::remove(exp2->eval()); b = (ZBool*)exp1->eval(); } ZObj::remove(b); return new ZStatus(true); }