Branch: Tag:

2013-05-31

2013-05-31 17:33:01 by Per Hedbor <ph@opera.com>

Added get_lax_type_of_svalue. Used for constant:s.

int(0..0) -> zero
int(X..Y) -> int
string(X..Y) -> string

This was done to remove some code duplication, and as an added feature
constant x = "foo"; now allows you to assign "f\xfff" when inheriting.

7581:    return NULL;   }    + struct pike_type *get_lax_type_of_svalue( const struct svalue *c ) + { +  struct pike_type *res; +  if (TYPEOF(*c) == T_INT) +  { +  if (c->u.integer) +  copy_pike_type(res, int_type_string); +  else +  copy_pike_type(res, zero_type_string); +  } +  else if (TYPEOF(*c) == T_STRING ) +  copy_pike_type(res, string_type_string); +  else +  return get_type_of_svalue(c); +  +  return res; + } +    struct pike_type *get_type_of_svalue(const struct svalue *s)   {    struct pike_type *ret;