Branch: Tag:

2017-11-25

2017-11-25 17:26:45 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Replaced resolv_program() with resolv_type().

The function resolv_program() (not to be confused with
resolve_program()) is no longer used, so remove it.

Move some inlined code from language.yacc to a function
called resolv_type().

1591:    }   }    - /* This one always leaves a program if possible */ - void resolv_program(node *n) + void resolv_type(node *n)   { -  if (!n) { -  push_int(0); -  return; -  } +  resolv_constant(n);    -  check_tree(n,0); +  if (TYPEOF(Pike_sp[-1]) == T_TYPE) { +  /* "typedef" */ +  push_finished_type(Pike_sp[-1].u.type); +  } else { +  /* object type */ +  struct program *p = NULL;    -  fix_type_field(n); -  -  if (!pike_types_le(n->type, inheritable_type_string) && -  (THIS_COMPILATION->lex.pragmas & ID_STRICT_TYPES)) { -  yytype_report(REPORT_WARNING, -  n->current_file, n->line_number, inheritable_type_string, -  n->current_file, n->line_number, n->type, -  0, "Not a valid object type.\n"); +  if (TYPEOF(Pike_sp[-1]) == T_OBJECT) { +  if(!(p = Pike_sp[-1].u.object->prog)) +  { +  pop_stack(); +  push_int(0); +  yyerror("Destructed object used as program identifier."); +  }else{ +  int f = FIND_LFUN(p->inherits[SUBTYPEOF(Pike_sp[-1])].prog, +  LFUN_CALL); +  if(f!=-1) +  { +  SET_SVAL_SUBTYPE(Pike_sp[-1], +  f + p->inherits[SUBTYPEOF(Pike_sp[-1])]. +  identifier_level); +  SET_SVAL_TYPE(Pike_sp[-1], T_FUNCTION); +  }else{ +  extern void f_object_program(INT32); +  if (Pike_compiler->compiler_pass == 2) +  yywarning("Using object as program identifier."); +  f_object_program(1);    } -  +  } +  }    -  resolv_class(n); -  switch(TYPEOF(Pike_sp[-1])) -  { +  switch(TYPEOF(Pike_sp[-1])) {    case T_FUNCTION: -  if(program_from_function(Pike_sp-1)) +  if((p = program_from_function(Pike_sp-1))) { +  push_object_type(0, p?(p->id):0);    break; -  +  } else { +  /* Attempt to get the return type for the function. */ +  struct pike_type *a, *b; +  a = get_type_of_svalue(Pike_sp-1); +  /* Note: check_splice_call() below eats a reference from a. +  * Note: CALL_INHIBIT_WARNINGS is needed since we don't +  * provide a function name (and we don't want +  * warnings here anyway). +  */ +  a = check_splice_call(NULL, a, 0, mixed_type_string, NULL, +  CALL_INHIBIT_WARNINGS); +  if (a) { +  b = new_get_return_type(a, 0); +  free_type(a); +  if (b) { +  push_finished_type(b); +  free_type(b); +  break; +  } +  } +  } +  /* FALL_THROUGH */       default:    if (Pike_compiler->compiler_pass!=1) -  yyerror("Illegal program identifier"); +  my_yyerror("Illegal program identifier: %O.", Pike_sp-1);    pop_stack();    push_int(0); -  +  push_object_type(0, 0); +  break;       case T_PROGRAM: -  +  p = Pike_sp[-1].u.program; +  push_object_type(0, p?(p->id):0);    break;    }    } -  + }      node *index_node(node * const n, char *node_name, struct pike_string *id)   {