Branch: Tag:

1997-02-19

1997-02-19 05:04:19 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

division and multiplication on array implemented

Rev: src/array.c:1.6
Rev: src/array.h:1.3
Rev: src/operators.c:1.9

5:   \*/   #include <math.h>   #include "global.h" - RCSID("$Id: operators.c,v 1.8 1997/02/13 02:38:58 nisse Exp $"); + RCSID("$Id: operators.c,v 1.9 1997/02/19 05:04:19 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"
834:    return;    }    +  case TWO_TYPES(T_ARRAY,T_ARRAY): +  { +  struct array *ret; +  ret=implode_array(sp[-2].u.array, sp[-1].u.array); +  pop_n_elems(2); +  push_array(ret); +  break; +  } +     case TWO_TYPES(T_FLOAT,T_FLOAT):    sp--;    sp[-1].u.float_number *= sp[0].u.float_number;
927:    return;    }    +  case T_ARRAY: +  { +  struct array *ret=explode_array(sp[-2].u.array, sp[-1].u.array); +  pop_n_elems(2); +  push_array(ret); +  return; +  } +     case T_FLOAT:    if(sp[-1].u.float_number == 0.0)    error("Division by zero.\n");
1252:    add_efun2("`<<",f_lsh,SHIFT_TYPE,OPT_TRY_OPTIMIZE,0,generate_lsh);    add_efun2("`>>",f_rsh,SHIFT_TYPE,OPT_TRY_OPTIMIZE,0,generate_rsh);    -  add_efun2("`*",f_multiply,"function(object,mixed...:mixed)|function(int...:int)|!function(int...:mixed)&function(float|int...:float)|function(string*,string:string)",OPT_TRY_OPTIMIZE,optimize_binary,generate_multiply); +  add_efun2("`*",f_multiply,"function(array(array),array:array)|function(object,mixed...:mixed)|function(int...:int)|!function(int...:mixed)&function(float|int...:float)|function(string*,string:string)",OPT_TRY_OPTIMIZE,optimize_binary,generate_multiply);    -  add_efun2("`/",f_divide,"function(object,mixed:mixed)|function(int,int:int)|function(float|int,float:float)|function(float,int:float)|function(string,string:string*)",OPT_TRY_OPTIMIZE,0,generate_divide); +  add_efun2("`/",f_divide,"function(array,array:array(array))|function(object,mixed:mixed)|function(int,int:int)|function(float|int,float:float)|function(float,int:float)|function(string,string:string*)",OPT_TRY_OPTIMIZE,0,generate_divide);       add_efun2("`%",f_mod,"function(object,mixed:mixed)|function(int,int:int)|!function(int,int:mixed)&function(int|float,int|float:float)",OPT_TRY_OPTIMIZE,0,generate_mod);       add_efun2("`~",f_compl,"function(object:mixed)|function(int:int)|function(float:float)|function(string:string)",OPT_TRY_OPTIMIZE,0,generate_compl);    add_efun2("sizeof", f_sizeof, "function(string|multiset|array|mapping|object:int)",0,0,generate_sizeof);   }