--- parser3/src/main/execute.C 2001/05/28 06:10:06 1.166 +++ parser3/src/main/execute.C 2001/06/29 14:16:29 1.172 @@ -4,16 +4,15 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: execute.C,v 1.166 2001/05/28 06:10:06 parser Exp $ */ +static const char *RCSId="$Id: execute.C,v 1.172 2001/06/29 14:16:29 parser Exp $"; #include "pa_opcode.h" #include "pa_array.h" #include "pa_request.h" #include "pa_vstring.h" #include "pa_vhash.h" -#include "pa_vnothing.h" +#include "pa_vvoid.h" #include "pa_vcode_frame.h" #include "pa_vmethod_frame.h" #include "pa_vobject.h" @@ -300,7 +299,7 @@ void Request::execute(const Array& ops) if(string) value=NEW VString(*string); else - value=NEW VNothing(pool()); + value=NEW VVoid(pool()); wcontext=static_cast(POP()); rcontext=POP(); PUSH(value); @@ -321,7 +320,7 @@ void Request::execute(const Array& ops) if(string) value=NEW VString(*string); else - NEW VNothing(pool()); + NEW VVoid(pool()); wcontext=static_cast(POP()); PUSH(value); break; @@ -530,16 +529,44 @@ void Request::execute(const Array& ops) case OP_DIV: { Value *b=POP(); Value *a=POP(); - Value *value=NEW VDouble(pool(), a->as_double() / b->as_double()); + + double a_double=a->as_double(); + double b_double=b->as_double(); + + if(b_double == 0) { + const String *problem_source=&b->as_string(); +#ifndef NO_STRING_ORIGIN + if(!problem_source->origin().file) + problem_source=&b->name(); +#endif + THROW(0, 0, + problem_source, + "Division by zero"); + } + + Value *value=NEW VDouble(pool(), a_double / b_double); PUSH(value); break; } case OP_MOD: { Value *b=POP(); Value *a=POP(); - Value *value=NEW VDouble(pool(), - a->as_int() % - b->as_int()); + + int a_int=a->as_int(); + int b_int=b->as_int(); + + if(b_int == 0) { + const String *problem_source=&b->as_string(); +#ifndef NO_STRING_ORIGIN + if(!problem_source->origin().file) + problem_source=&b->name(); +#endif + THROW(0, 0, + problem_source, + "Modulus by zero"); + } + + Value *value=NEW VDouble(pool(), a_int % b_int); PUSH(value); break; } @@ -705,7 +732,7 @@ Value *Request::get_element() { if(value) value=&process(*value, &name); // process possible code-junction else { - value=NEW VNothing(pool()); + value=NEW VVoid(pool()); value->set_name(name); }