pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:1:   /* -*- c -*-   || 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      %token TOK_ARROW      /*    * Basic value pushing    */   %token TOK_CONSTANT TOK_FLOAT TOK_STRING
pike.git/src/language.yacc:2826:       /* Check if we have create arguments but no locally defined create(). */    if ($6) {    struct pike_string *create_string = NULL;    struct reference *ref = NULL;    struct identifier *id = NULL;    int ref_id;    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);       /* Init: Prepend the create arguments. */    if (Pike_compiler->num_create_args < 0) {    for (e = 0; e < -Pike_compiler->num_create_args; e++) {    id = Pike_compiler->new_program->identifiers + e;    add_ref(id->type);    add_local_name(id->name, id->type, 0);    /* Note: add_local_name() above will return e. */
pike.git/src/language.yacc:2887:    /* Second: Declare the function. */       Pike_compiler->compiler_frame->current_function_number=    define_function(create_string, type,    ID_INLINE | ID_PROTECTED,    IDENTIFIER_PIKE_FUNCTION |    (Pike_compiler->num_create_args < 0?IDENTIFIER_VARARGS:0),    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;    * [,..]    */       for(e=0; e<nargs; e++)    {    if(!Pike_compiler->compiler_frame->variable[e].name ||    !Pike_compiler->compiler_frame->variable[e].name->len)
pike.git/src/language.yacc:2945:   #ifdef PIKE_DEBUG    if(Pike_interpreter.recoveries &&    Pike_sp-Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer)    Pike_fatal("Stack error (underflow)\n");       if(Pike_compiler->compiler_pass == 1 &&    f!=Pike_compiler->compiler_frame->current_function_number)    Pike_fatal("define_function screwed up! %d != %d\n",    f, Pike_compiler->compiler_frame->current_function_number);   #endif +  }       /* Done. */       free_type(type);    pop_compiler_frame();    }    }       if(Pike_compiler->compiler_pass == 1)    p=end_first_pass(0);    else    p=end_first_pass(1);       /* 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. */    Pike_compiler->num_parse_error = 1;    }       $$=mkidentifiernode($<number>4);       free_node($2);    free_node($3);