pike.git / lib / modules / Val.pmod

version» Context lines:

pike.git/lib/modules/Val.pmod:180:   //! if (objectp(something) && something->is_val_null) ...   //! @endcode   //!   //! That way it's possible for other code to replace it with an   //! extended class, or create their own variants which needs to behave   //! like @[Val.null].   //!   //! @fixme   //! The Oracle glue currently uses static null objects which won't be   //! affected if this object is replaced. -  - //! The type for @[nan]. - class NaN { -  constant is_val_nan = 1; -  -  inline private int(0..1) `>(mixed that) { -  return 0; -  } -  -  inline private int(0..1) `<(mixed that) { -  return 0; -  } -  -  inline private mixed `+(mixed that) { -  return this; -  } -  -  inline private mixed `-(mixed that) { -  return this; -  } -  -  inline private mixed `*(mixed that) { -  return this; -  } -  -  inline private mixed `/(mixed that) { -  return this; -  } -  -  inline private int(0..1) `==(mixed that) { -  return 0; -  } -  -  private mixed cast(string to) { -  switch (to) { -  case "string": -  return ""; -  } -  return UNDEFINED; -  } -  -  private string _sprintf(int fmt) { -  return "NaN"; -  } - } -  - //! The type for @[posinfty]. - class PositiveInfinity { -  constant is_val_positiveinfinity = 1; -  -  inline private int(0..1) `<(mixed that) { -  return 0; -  } -  -  inline private mixed `+(mixed that) { -  return objectp(that) -  && (([object]that)->is_val_negativeinfinity || ([object]that)->is_val_nan) -  ? nan : this; -  } -  -  inline private mixed `*(mixed that) { -  return !that ? nan : that > 0 ? this : neginfty; -  } -  -  inline private mixed `/(mixed that) { -  return !that || objectp(that) && (([object]that)->is_val_positiveinfinity -  || ([object]that)->is_val_negativeinfinity) -  ? nan : that > 0 ? this : neginfty; -  } -  -  private int(0..1) `==(mixed that) { -  return objectp(that) && [int(0..1)]([object]that)->is_val_positiveinfinity; -  } -  -  private mixed cast(string to) { -  switch (to) { -  case "string": -  return ""; -  } -  return UNDEFINED; -  } -  -  private string _sprintf(int fmt) { -  return "+Infinity"; -  } - } -  - //! The type for @[neginfty]. - class NegativeInfinity { -  constant is_val_negativeinfinity = 1; -  -  variant inline private int(0..1) `>(mixed that) { -  return 0; -  } -  -  inline private mixed `+(mixed that) { -  return objectp(that) -  && (([object]that)->is_val_positiveinfinity || ([object]that)->is_val_nan) -  ? nan : this; -  } -  -  inline private mixed `*(mixed that) { -  return !that ? nan : that > 0 ? this : posinfty; -  } -  -  inline private mixed `/(mixed that) { -  return !that || objectp(that) && (([object]that)->is_val_positiveinfinity -  || ([object]that)->is_val_negativeinfinity) -  ? nan : that > 0 ? this : posinfty; -  } -  -  private int(0..1) `==(mixed that) { -  return objectp(that) && [int(0..1)]([object]that)->is_val_negativeinfinity; -  } -  -  private mixed cast(string to) { -  switch (to) { -  case "string": -  return ""; -  } -  return UNDEFINED; -  } -  -  private string _sprintf(int fmt) { -  return "-Infinity"; -  } - } -  - //! - NaN nan = NaN(); -  - //! - PositiveInfinity posinfty = PositiveInfinity(); -  - //! - NegativeInfinity neginfty = NegativeInfinity(); +