pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:3611:      optional_block: /* EMPTY */ { $$=0; }    | '{' line_number_info    /* FIXME: Use implicit_identifier to make __func__ point to the lambda? */    start_lambda    {    /* block code */    $<number>1=Pike_compiler->num_used_modules;    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals;    +  /* Declare the argument variable. +  * +  * NB: The code in the next block knows that this variable +  * will be variable #0. +  */    push_type(T_MIXED);    push_type(T_ARRAY);    add_local_name(args_string, compiler_pop_type(), 0);    }    statements end_block    {    struct pike_type *type;    int f/*, e */;    struct pike_string *name;    struct compilation *c = THIS_COMPILATION;    struct pike_string *save_file = c->lex.current_file;    int save_line = c->lex.current_line; -  +  int args_used = +  Pike_compiler->compiler_frame->variable[0].flags & LOCAL_VAR_IS_USED; +  +  /* Don't warn about the argument if unused. */ +  Pike_compiler->compiler_frame->variable[0].flags |= LOCAL_VAR_IS_USED; +     c->lex.current_file = $2->current_file;    c->lex.current_line = $2->line_number;    -  +  /* block code */ +  unuse_modules(Pike_compiler->num_used_modules - $<number>1); +  $5 = pop_local_variables($<number>4, $5); +  +  debug_malloc_touch($5); +  $5=mknode(F_COMMA_EXPR,$5,mknode(F_RETURN,mkintnode(0),0)); +     if (Pike_compiler->compiler_pass == 2) {    /* Doing this in pass 1 might induce too strict checks on types    * in cases where we got placeholders. */    type=find_return_type($5);    if (type) {    push_finished_type(type);    free_type(type);    } else {    yywarning("Failed to determine return type for implicit lambda.");    push_type(T_ZERO);    }    } else {    /* Tentative return type. */    push_type(T_MIXED);    }    -  if (Pike_compiler->compiler_frame->variable[0].flags & LOCAL_VAR_IS_USED) { +  if (args_used) {    /* __ARGS__ is used. */    push_type(T_MIXED);    } else { -  /* Don't warn about the unused argument. */ -  Pike_compiler->compiler_frame->variable[0].flags |= LOCAL_VAR_IS_USED; +     push_type(T_VOID);    }       push_type(T_MANY);       type=compiler_pop_type();    -  /* block code */ -  unuse_modules(Pike_compiler->num_used_modules - $<number>1); -  $5 = pop_local_variables($<number>4, $5); -  -  debug_malloc_touch($5); -  $5=mknode(F_COMMA_EXPR,$5,mknode(F_RETURN,mkintnode(0),0)); -  +     name = get_new_name(NULL);      #ifdef LAMBDA_DEBUG    fprintf(stderr, "%d: IMPLICIT LAMBDA: %s 0x%08lx 0x%08lx\n",    Pike_compiler->compiler_pass, name->str,    (long)Pike_compiler->new_program->id,    Pike_compiler->local_class_counter-1);   #endif /* LAMBDA_DEBUG */       f=dooptcode(name,