Branch: Tag:

2007-03-30

2007-03-30 14:43:32 by Henrik Grubbström (Grubba) <grubba@grubba.org>

__check_call() has been renamed __low_check_call().

Rev: lib/modules/Pike.pmod/module.pmod:1.15

3:      // Pike core things that don't belong anywhere else.   // - // $Id: module.pmod,v 1.14 2007/03/26 11:36:20 grubba Exp $ + // $Id: module.pmod,v 1.15 2007/03/30 14:43:32 grubba Exp $      constant WEAK_INDICES = __builtin.PIKE_WEAK_INDICES;   constant WEAK_VALUES = __builtin.PIKE_WEAK_VALUES;
43:   constant get_runtime_info = __builtin.get_runtime_info;      // Type-checking: - constant check_call = predef::__check_call; + constant low_check_call = predef::__low_check_call;   constant get_return_type = predef::__get_return_type;   constant get_first_arg_type = predef::__get_first_arg_type;      program Encoder = [program] master()->Encoder;   program Decoder = [program] master()->Decoder;   program Codec = [program] master()->Codec; -  +  + #if 0 + static constant TYPE = typeof(typeof([mixed]0)); +  + TYPE check_call(TYPE fun_type, TYPE ... arg_types) + { +  array(TYPE) conts = allocate(sizeof(arg_types) + 1); +  conts[0] = fun_type; +  foreach(arg_types; int i; TYPE arg_type) { +  if (!(conts[i+1] = low_check_call(conts[i], arg_type, +  (i == (sizeof(arg_types)-1))?2:0))) { +  werror("Error: Bad argument %d to function, got %O, expected %O.\n", +  i+1, arg_type, get_first_arg_type(conts[i])); +  break; +  } +  } +  if (!conts[sizeof(arg_types)]) { +  int i; +  for(i = 0; (i < sizeof(arg_types)) && conts[i+1]; i++) { +  TYPE param_type = get_first_arg_type(conts[i]); +  if (arg_types[i] <= param_type) continue; +  werror("Warning: Potentially bad argument %d to function, got %O, expected %O.\n", +  i+1, arg_types[i], param_type); +  } +  return 0; +  } +  TYPE ret = get_return_type(conts[-1]); +  if (!ret) { +  werror("Error: Too few arguments.\n"); +  } +  return ret; + } + #endif /* 0 */