pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*\   ||| This file is part of Pike. For copyright information see COPYRIGHT.   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h"   #include <math.h> - RCSID("$Id: operators.c,v 1.149 2002/05/11 00:29:58 nilsson Exp $"); + RCSID("$Id: operators.c,v 1.150 2002/05/30 13:31:51 grubba Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"   #include "opcodes.h"   #include "operators.h"   #include "language.h"   #include "pike_memory.h"
pike.git/src/operators.c:177:    *! Addition operator.    *!    *! @returns    *! If there's only a single argument, that argument will be returned.    *!    *! If @[arg1] is an object and it has an @[lfun::`+()],    *! that function will be called with the rest of the arguments,    *! and the result returned.    *!    *! Otherwise if any of the other arguments is an object that has -  *! an @[lfun::``+()] the first such function fill be called +  *! an @[lfun::``+()] the first such function will be called    *! with the arguments leading up to it, and @[`+()] be called recursively -  *! with the result and the rest of the srguments. +  *! with the result and the rest of the arguments.    *!    *! If there are two arguments the result will be:    *! @mixed arg1    *! @type string    *! @[arg2] will be converted to a string, and the result the    *! strings concatenated. -  *! @type int -  *! @type float +  *! @type int|float    *! @mixed arg2    *! @type string    *! @[arg1] will be converted to string, and the result the    *! strings concatenated. -  *! @type int -  *! @type float +  *! @type int|float    *! The result will be @code{@[arg1] + @[arg2]@}, and will    *! be a float if either @[arg1] or @[arg2] is a float.    *! @endmixed    *! @type array    *! The arrays will be concatenated.    *! @type mapping    *! The mappings will be joined.    *! @type multiset    *! The multisets will be added.    *! @endmixed
pike.git/src/operators.c:1071:    *! If @[arg2] is an object that overloads @tt{``-()@}, that function will    *! be called with @[arg1] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1    *! @type mapping    *! @mixed arg2    *! @type array    *! The result will be @[arg1] with all occurrances of    *! @[arg2] removed. -  *! @type multiset -  *! @type mapping +  *! @type multiset|mapping    *! The result will be @[arg1] with all occurrences of    *! @code{@[indices](@[arg2])@} removed.    *! @endmixed -  *! @type array -  *! @type multiset +  *! @type array|multiset    *! The result will be the elements of @[arg1] that are not in @[arg2]. -  *! @type float -  *! @type int +  *! @type float|int    *! The result will be @code{@[arg1] - @[arg2]@}, and will be a float    *! if either @[arg1] or @[arg2] is a float.    *! @type string    *! Result will be the string @[arg1] with all occurrances of the    *! substring @[arg2] removed.    *! @endmixed    *!    *! @note    *! In Pike 7.0 and earlier the subtraction order was unspecified.    *!
pike.git/src/operators.c:1443:    *! If @[arg1] is an object that has an @[lfun::`&()], that function    *! will be called with @[arg2] as the single argument.    *!    *! If @[arg2] is an object that has an @[lfun::``&()], that function    *! will be called with @[arg1] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1    *! @type int    *! The result will be the bitwise and of @[arg1] and @[arg2]. -  *! @type array -  *! @type multiset -  *! @type mapping +  *! @type array|multiset|mapping    *! The result will be the elements of @[arg1] and @[arg2] that    *! occurr in both. -  *! @type type -  *! @type program +  *! @type type|program    *! The result will be the type intersection of @[arg1] and @[arg2].    *! @type string    *! The result will be the string where the elements of @[arg1]    *! and @[arg2] have been pairwise bitwise anded.    *! @endmixed    *!    *! @seealso    *! @[`|()], @[lfun::`&()], @[lfun::``&()]    */   PMOD_EXPORT void f_and(INT32 args)
pike.git/src/operators.c:1652:    *! If @[arg1] is an object that has an @[lfun::`|()], that function    *! will be called with @[arg2] as the single argument.    *!    *! If @[arg2] is an object that has an @[lfun::``|()], that function    *! will be called with @[arg1] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1    *! @type int    *! The result will be the binary or of @[arg1] and @[arg2]. -  *! @type mapping -  *! @type multiset +  *! @type mapping|multiset    *! The result will be the join of @[arg1] and @[arg2].    *! @type array    *! The result will be the concatenation of @[arg1] and @[arg2].    *! @type string    *! The result will be the pairwise bitwose or of @[arg1] and @[arg2]. -  *! @type type -  *! @type program +  *! @type type|program    *! The result will be the type join of @[arg1] and @[arg2].    *! @endmixed    *!    *! @seealso    *! @[`&()], @[lfun::`|()], @[lfun::``|()]    */   PMOD_EXPORT void f_or(INT32 args)   {    switch(args)    {
pike.git/src/operators.c:1863:    *! If @[arg1] is an object that has an @[lfun::`^()], that function    *! will be called with @[arg2] as the single argument.    *!    *! If @[arg2] is an object that has an @[lfun::``^()], that function    *! will be called with @[arg1] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1    *! @type int    *! The result will be the bitwise xor of @[arg1] and @[arg2]. -  *! @type mapping -  *! @type multiset -  *! @type array +  *! @type mapping|multiset|array    *! The result will be the elements of @[arg1] and @[arg2] that    *! only occurr in one of them.    *! @type string    *! The result will be the pairwise bitwise xor of @[arg1] and @[arg2]. -  *! @type type -  *! @type program +  *! @type type|program    *! The result will be the result of    *! @code{(@[arg1]&~@[arg2])|(~@[arg1]&@[arg2])@}.    *! @endmixed    *!    *! @seealso    *! @[`&()], @[`|()], @[lfun::`^()], @[lfun::``^()]    */   PMOD_EXPORT void f_xor(INT32 args)   {    switch(args)
pike.git/src/operators.c:2329:    *! If there are more than two arguments, the result will be    *! @code{`*(`*(@[arg1], @[arg2]), @@@[extras])@}.    *!    *! If @[arg2] is an object that implements @[lfun::``*()], that    *! function will be called with @[arg1] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1    *! @type array    *! @mixed arg2 -  *! @type int -  *! @type float +  *! @type int|float    *! The result will be @[arg1] concatenated @[arg2] times. -  *! @type string -  *! @type array +  *! @type string|array    *! The result will be the elements of @[arg1] concatenated with    *! @[arg2] interspersed.    *! @endmixed    *! @type string    *! The result will be @[arg1] concatenated @[arg2] times. -  *! @type int -  *! @type float +  *! @type int|float    *! The result will be @code{@[arg1] * @[arg2]@}, and will be a    *! float if either @[arg1] or @[arg2] is a float.    *! @endmixed    *!    *! @note    *! In Pike 7.0 and earlier the multiplication order was unspecified.    *!    *! @seealso    *! @[`+()], @[`-()], [`/()], @[lfun::`*()], @[lfun::``*()]    */
pike.git/src/operators.c:2683:    *! If @[arg1] is an object that implements @[lfun::`/()], that    *! function will be called with @[arg2] as the single argument.    *!    *! If @[arg2] is an object that implements @[lfun::``/()], that    *! function will be called with @[arg1] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1    *! @type string    *! @mixed arg2 -  *! @type int -  *! @type float +  *! @type int|float    *! The result will be and array of @[arg1] split in segments    *! of length @[arg2]. If @[arg2] is negative the splitting    *! will start from the end of @[arg1].    *! @type string    *! The result will be an array of @[arg1] split at each    *! occurrence of @[arg2]. Note that the segments that    *! matched against @[arg2] will not be in the result.    *! @endmixed    *! @type array    *! @mixed arg2 -  *! @type int -  *! @type float +  *! @type int|float    *! The result will be and array of @[arg1] split in segments    *! of length @[arg2]. If @[arg2] is negative the splitting    *! will start from the end of @[arg1].    *! @type array    *! The result will be an array of @[arg1] split at each    *! occurrence of @[arg2]. Note that the elements that    *! matched against @[arg2] will not be in the result.    *! @endmixed -  *! @type float -  *! @type int +  *! @type float|int    *! The result will be @code{@[arg1] / @[arg2]@}. If both arguments    *! are int, the result will be truncated to an int. Otherwise the    *! result will be a float.    *! @endmixed    */   PMOD_EXPORT void f_divide(INT32 args)   {    switch(args)    {    case 0:
pike.git/src/operators.c:2871:    *!    *! @returns    *! If @[arg1] is an object that implements @[lfun::`%()] then    *! that function will be called with @[arg2] as the single argument.    *!    *! If @[arg2] is an object that implements @[lfun::``%()] then    *! that function will be called with @[arg2] as the single argument.    *!    *! Otherwise the result will be as follows:    *! @mixed arg1 -  *! @type string -  *! @type array +  *! @type string|array    *! If @[arg2] is positive, the result will be the last    *! @code{`%(@[sizeof](@[arg1]), @[arg2])@} elements of @[arg1].    *! If @[arg2] is negative, the result will be the first    *! @code{`%(@[sizeof](@[arg1]), -@[arg2])@} elements of @[arg1]. -  *! @type int -  *! @type float +  *! @type int|float    *! The result will be    *! @code{@[arg1] - @[arg2]*@[floor](@[arg1]/@[arg2])@}.    *! The result will be a float if either @[arg1] or @[arg2] is    *! a float, and an int otherwise.    *! @endmixed    */   PMOD_EXPORT void f_mod(INT32 args)   {    if(args != 2) {    /* FIXME: Not appropriate when too many args. */
pike.git/src/operators.c:3064:    *!    *! @returns    *! The result will be as follows:    *! @mixed arg    *! @type object    *! If @[arg] implements @[lfun::`~()], that function will be called.    *! @type int    *! The bitwise inverse of @[arg] will be returned.    *! @type float    *! The result will be @code{-1.0 - @[arg]@}. -  *! @type type -  *! @type program +  *! @type type|program    *! The type inverse of @[arg] will be returned.    *! @type string    *! If @[arg] only contains characters in the range 0 - 255 (8-bit),    *! a string containing the corresponding 8-bit inverses will be    *! returned.    *! @endmixed    *!    *! @seealso    *! @[`!()], @[lfun::`~()]    */
pike.git/src/operators.c:3340:    *!    *! Index assign operator.    *!    *! If @[arg] is an object that implements @[lfun::`[]=()], that function    *! will be called with @[index] and @[val] as the arguments.    *!    *! @mixed arg    *! @type object    *! The non-static (ie public) variable named @[index] will be looked up    *! in @[arg], and assigned @[val]. -  *! @type array -  *! @type mapping +  *! @type array|mapping    *! Index @[index] in @[arg] will be assigned @[val].    *! @type multiset    *! If @[val] is @tt{0@} (zero), one occurrance of @[index] in    *! @[arg] will be removed. Otherwise @[index] will be added    *! to @[arg] if it is not already there.    *! @endmixed    *!    *! @returns    *! @[val] will be returned.    *!
pike.git/src/operators.c:3390:    *! This function behaves much like @[`[]=()], just that the index is always    *! a string.    *!    *! If @[arg] is an object that implements @[lfun::`->=()], that function    *! will be called with @[index] and @[val] as the arguments.    *!    *! @mixed arg    *! @type object    *! The non-static (ie public) variable named @[index] will be looked up    *! in @[arg], and assigned @[val]. -  *! @type array -  *! @type mapping +  *! @type array|mapping    *! Index @[index] in @[arg] will be assigned @[val].    *! @type multiset    *! If @[val] is @tt{0@} (zero), one occurrance of @[index] in    *! @[arg] will be removed. Otherwise @[index] will be added    *! to @[arg] if it is not already there.    *! @endmixed    *!    *! @returns    *! @[val] will be returned.    *!
pike.git/src/operators.c:3437:    *! @decl int sizeof(multiset arg)    *! @decl int sizeof(object arg)    *!    *! Sizeof operator.    *!    *! @returns    *! The result will be as follows:    *! @mixed arg    *! @type string    *! The number of characters in @[arg] will be returned. -  *! @type array -  *! @type multiset +  *! @type array|multiset    *! The number of elements in @[arg] will be returned.    *! @type mapping    *! The number of key-value pairs in @[arg] will be returned.    *! @type object    *! If @[arg] implements @[lfun::_sizeof()], that function will    *! be called. Otherwise the number of non-static (ie public)    *! symbols in @[arg] will be returned.    *! @endmixed    *!    *! @seealso