--- parser3/src/main/execute.C 2001/06/28 07:41:59 1.168 +++ parser3/src/main/execute.C 2001/07/13 10:58:03 1.175 @@ -4,10 +4,8 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: execute.C,v 1.168 2001/06/28 07:41:59 parser Exp $ */ -static char *RCSId="$Id: execute.C,v 1.168 2001/06/28 07:41:59 parser Exp $"; +static const char *RCSId="$Id: execute.C,v 1.175 2001/07/13 10:58:03 parser Exp $"; #include "pa_opcode.h" #include "pa_array.h" @@ -255,6 +253,7 @@ void Request::execute(const Array& ops) // maybe they do ^object.method[] call, remember the fact wcontext->inc_somebody_entered_some_object(); + //_asm int 3; Value *value=get_element(); PUSH(value); break; @@ -531,16 +530,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()); + + 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, + "Modulus by zero"); + } + + Value *value=NEW VDouble(pool(), fmod(a_double, b_double)); PUSH(value); break; } @@ -807,6 +834,7 @@ const String *Request::execute_method(Va return result; } +/// @test remove virtual @auto calls when initializing children const String *Request::execute_method(Value& aself, const String& method_name, bool return_cstr) { if(Value *value=aself.get_element(method_name))