Branch: Tag:

2009-11-17

2009-11-17 14:08:46 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Add a prototype for implicitly added create() during the first pass.
Update the type of classes on exit, since there might be an lfun::create().
Fixes [bug 4351 (#4351)].

Rev: src/language.yacc:1.453

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: language.yacc,v 1.452 2009/09/12 13:31:38 grubba Exp $ + || $Id: language.yacc,v 1.453 2009/11/17 14:08:46 grubba Exp $   */      %pure_parser
2833:    MAKE_CONST_STRING(create_string, "create");    if (((ref_id = isidentifier(create_string)) < 0) ||    (ref = PTR_FROM_INT(Pike_compiler->new_program, ref_id))->inherit_offset || -  (((id = ID_FROM_PTR(Pike_compiler->new_program, ref))->func.offset == -1) && -  (Pike_compiler->compiler_pass == 2))) { +  ((id = ID_FROM_PTR(Pike_compiler->new_program, ref))->func.offset == -1)) {    int e; -  node *create_code = NULL; +     struct pike_type *type = NULL;    int nargs = Pike_compiler->num_create_args; -  int f; +        push_compiler_frame(SCOPE_LOCAL);   
2894:    0,    OPT_SIDE_EFFECT);    +  if (Pike_compiler->compiler_pass == 2) { +  node *create_code = NULL; +  int f; +     /* Third: Generate the initialization code.    *    * global_arg = [type]local_arg;
2952:    Pike_fatal("define_function screwed up! %d != %d\n",    f, Pike_compiler->compiler_frame->current_function_number);   #endif +  }       /* Done. */   
2968:    /* fprintf(stderr, "LANGUAGE.YACC: CLASS end\n"); */       if(p) { +  /* Update the type for the program constant, +  * since we might have a lfun::create(). */ +  struct identifier *i; +  struct svalue sv; +  sv.type = T_PROGRAM; +  sv.subtype = 0; +  sv.u.program = p; +  i = ID_FROM_INT(Pike_compiler->new_program, $<number>4); +  free_type(i->type); +  i->type = get_type_of_svalue(&sv);    free_program(p);    } else if (!Pike_compiler->num_parse_error) {    /* Make sure code in this class is aware that something went wrong. */