--- parser3/src/classes/math.C 2005/08/26 11:08:30 1.39.8.2 +++ parser3/src/classes/math.C 2005/08/09 08:14:48 1.40 @@ -8,7 +8,7 @@ Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o. */ -static const char * const IDENT_MATH_C="$Date: 2005/08/26 11:08:30 $"; +static const char * const IDENT_MATH_C="$Date: 2005/08/09 08:14:48 $"; #include "pa_vmethod_frame.h" #include "pa_common.h" @@ -164,7 +164,8 @@ static inline int _random(uint top) { } static void _random(Request& r, MethodParams& params) { - double top=params.as_double(0, "range must be expression", r); + Value& range=params.as_junction(0, "range must be expression"); + double top=r.process_to_value(range).as_double(); if(top<=0 || top>MAX_UINT) throw Exception("parser.runtime", 0, @@ -180,8 +181,9 @@ static double degrees(double param) { re static double radians(double param) { return param /180 *PI; } static void math1(Request& r, MethodParams& params, math1_func_ptr func) { - double param=params.as_double(0, "parameter must be expression", r); - double result=func(param); + Value& param=params.as_junction(0, "parameter must be expression"); + + double result=func(r.process_to_value(param).as_double()); r.write_no_lang(*new VDouble(result)); } @@ -206,9 +208,12 @@ MATH1(sqrt); typedef double (*math2_func_ptr)(double, double); static void math2(Request& r, MethodParams& params, math2_func_ptr func) { - double a=params.as_double(0, "parameter must be expression", r); - double b=params.as_double(1, "parameter must be expression", r); - double result=func(a, b); + Value& a=params.as_junction(0, "parameter must be expression"); + Value& b=params.as_junction(1, "parameter must be expression"); + + double result=func( + r.process_to_value(a).as_double(), + r.process_to_value(b).as_double()); r.write_no_lang(*new VDouble(result)); }