pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:667:    }    ;      close_bracket_or_missing: ']'    | /* empty */    {    yyerror("Missing ']'.");    }    ;    - /* This variant is used to push the compiler context for functions -  * with a declared return type, which has been stored in + /* This variant is used to start a new compiler frame for functions +  * with a declared return type.    * -  +  * On entry the return type to be is taken from +  *    * compiler_frame->current_type    * -  * (eg via simple_type). +  * in the current frame (stored there eg via simple_type). This is +  * then copied to +  * +  * compiler_frame->current_return_type +  * +  * for the new frame.    */   start_function: /* empty */    {    push_compiler_frame(SCOPE_LOCAL);       if(!Pike_compiler->compiler_frame->previous ||    !Pike_compiler->compiler_frame->previous->current_type)    {    yyerror("Internal compiler error (start_function)."); -  copy_pike_type(Pike_compiler->compiler_frame->current_type, +  copy_pike_type(Pike_compiler->compiler_frame->current_return_type,    mixed_type_string);    }else{ -  copy_pike_type(Pike_compiler->compiler_frame->current_type, +  copy_pike_type(Pike_compiler->compiler_frame->current_return_type,    Pike_compiler->compiler_frame->previous->current_type);    }       $$ = Pike_compiler->compiler_frame;    }    ;      optional_constant: /* empty */    {    $$ = OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT;
pike.git/src/language.yacc:749:    }    }    arguments close_paren_or_missing    {    int e;       /* Adjust opt_flags in case we've got an optional_constant. */    Pike_compiler->compiler_frame->opt_flags = $4;       /* construct the function type */ -  push_finished_type(Pike_compiler->compiler_frame->current_type); -  -  if(Pike_compiler->compiler_frame->current_return_type) -  free_type(Pike_compiler->compiler_frame->current_return_type); -  Pike_compiler->compiler_frame->current_return_type = compiler_pop_type(); -  +     push_finished_type(Pike_compiler->compiler_frame->current_return_type);       e = $<number>8 + $9 - 1;    if(Pike_compiler->varargs &&    (!$<number>8 || (Pike_compiler->num_create_args >= 0)))    {    push_finished_type(Pike_compiler->compiler_frame->variable[e].type);    e--;    pop_type_stack(T_ARRAY);    }else{
pike.git/src/language.yacc:2064:      continue: TOK_CONTINUE optional_label { $$=mknode(F_CONTINUE,$2,0); } ;      /* This variant is used to push the compiler context for    * functions without a declared return type (ie lambdas).    */   start_lambda: /* empty */    {    push_compiler_frame(SCOPE_LOCAL);    +  debug_malloc_touch(Pike_compiler->compiler_frame->current_return_type); +  if(Pike_compiler->compiler_frame->current_return_type) +  free_type(Pike_compiler->compiler_frame->current_return_type); +  copy_pike_type(Pike_compiler->compiler_frame->current_return_type, +  any_type_string); +     $$ = Pike_compiler->compiler_frame;    }    ;      implicit_identifier: /* empty */    {    struct pike_string *name;    $$=mkstrnode(name = get_new_name(NULL));    free_string(name);    }    ;      lambda: TOK_LAMBDA line_number_info implicit_identifier start_lambda -  { -  debug_malloc_touch(Pike_compiler->compiler_frame->current_return_type); -  if(Pike_compiler->compiler_frame->current_return_type) -  free_type(Pike_compiler->compiler_frame->current_return_type); -  copy_pike_type(Pike_compiler->compiler_frame->current_return_type, -  any_type_string); -  } +     func_args    {    struct pike_string *name = $3->u.sval.u.string;    struct pike_type *type;    int e;       $<number>$ = Pike_compiler->varargs;    Pike_compiler->varargs = 0;       if (Pike_compiler->compiler_pass == 1) {    /* Define a tentative prototype for the lambda. */    push_finished_type(mixed_type_string); -  e=$6-1; +  e=$5-1;    if($<number>$)    {    push_finished_type(Pike_compiler->compiler_frame->variable[e].type);    e--;    pop_type_stack(T_ARRAY);    }else{    push_type(T_VOID);    }    Pike_compiler->varargs=0;    push_type(T_MANY);
pike.git/src/language.yacc:2136:    {    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;    c->lex.current_file = $2->current_file;    c->lex.current_line = $2->line_number;    -  debug_malloc_touch($8); -  $8=mknode(F_COMMA_EXPR,$8,mknode(F_RETURN,mkintnode(0),0)); +  debug_malloc_touch($7); +  $7=mknode(F_COMMA_EXPR,$7,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($8); +  type=find_return_type($7);    if (type) {    push_finished_type(type);    free_type(type);    } else {    yywarning("Failed to determine return type for lambda.");    push_type(T_ZERO);    }    } else {    /* Tentative return type. */    push_type(T_MIXED);    }    -  e=$6-1; -  if($<number>7) +  e=$5-1; +  if($<number>6)    {    push_finished_type(Pike_compiler->compiler_frame->variable[e].type);    e--;    pop_type_stack(T_ARRAY);    }else{    push_type(T_VOID);    }    Pike_compiler->varargs=0;    push_type(T_MANY);    for(; e>=0; e--) {
pike.git/src/language.yacc:2185:    fprintf(stderr, "%d: LAMBDA: %s 0x%08lx 0x%08lx\n%d: type: ",    Pike_compiler->compiler_pass, name->str,    (long)Pike_compiler->new_program->id,    Pike_compiler->local_class_counter-1,    Pike_compiler->compiler_pass);    simple_describe_type(type);    fprintf(stderr, "\n");   #endif /* LAMBDA_DEBUG */       f=dooptcode(name, -  $8, +  $7,    type,    ID_PROTECTED | ID_PRIVATE | ID_INLINE | ID_USED);      #ifdef PIKE_DEBUG    if (f != Pike_compiler->compiler_frame->current_function_number) {    Pike_fatal("Lost track of lambda %s.\n", name->str);    }   #endif /* PIKE_DEBUG */      #ifdef LAMBDA_DEBUG
pike.git/src/language.yacc:2247:    ;      local_function: TOK_IDENTIFIER start_function func_args    {    struct pike_string *name;    struct pike_type *type;    int id,e;    node *n;    struct identifier *i=0;    -  debug_malloc_touch(Pike_compiler->compiler_frame->current_return_type); -  if(Pike_compiler->compiler_frame->current_return_type) -  free_type(Pike_compiler->compiler_frame->current_return_type); -  copy_pike_type(Pike_compiler->compiler_frame->current_return_type, -  Pike_compiler->compiler_frame->current_type); -  -  +     /***/    push_finished_type(Pike_compiler->compiler_frame->current_return_type);       e=$3-1;    if(Pike_compiler->varargs)    {    push_finished_type(Pike_compiler->compiler_frame->variable[e].type);    e--;    pop_type_stack(T_ARRAY);    }else{
pike.git/src/language.yacc:3371:    * We might want to allow having more than block after    * a function ( ie. func(args) {} {} {} {} )    * -Hubbe    */      optional_block: /* EMPTY */ { $$=0; }    | '{' line_number_info    /* FIXME: Use implicit_identifier to make __func__ point to the lambda? */    start_lambda    { -  debug_malloc_touch(Pike_compiler->compiler_frame->current_return_type); -  if(Pike_compiler->compiler_frame->current_return_type) -  free_type(Pike_compiler->compiler_frame->current_return_type); -  copy_pike_type(Pike_compiler->compiler_frame->current_return_type, -  any_type_string); -  +     /* block code */    $<number>1=Pike_compiler->num_used_modules;    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals;    }    statements end_block    {    struct pike_type *type;    int f/*, e */;    struct pike_string *name;    struct compilation *c = THIS_COMPILATION;