pike.git / src / language.y

version» Context lines:

pike.git/src/language.y:1: + /*\ + ||| This file a part of uLPC, and is copyright by Fredrik Hubinette + ||| uLPC is distributed as GPL (General Public License) + ||| See the files COPYING and DISCLAIMER for more information. + \*/   %pure_parser      /*    * These values are used by the stack machine, and can not be directly    * called from LPC.    */   %token F_ADD_256 F_ADD_512 F_ADD_768 F_ADD_1024 F_ADD_256X   %token F_PREFIX_256 F_PREFIX_512 F_PREFIX_768 F_PREFIX_1024   %token F_PREFIX_CHARX256 F_PREFIX_WORDX256 F_PREFIX_24BITX256   %token F_POP_VALUE F_POP_N_ELEMS F_MARK F_CALL_LFUN      %token F_BRANCH F_BRANCH_WHEN_ZERO F_BRANCH_WHEN_NON_ZERO   %token F_INC_LOOP F_DEC_LOOP   %token F_INC_NEQ_LOOP F_DEC_NEQ_LOOP      %token F_INDEX F_INDIRECT   %token F_LTOSVAL F_LTOSVAL2 - %token F_WRITE_OPCODE F_PUSH_ARRAY + %token F_PUSH_ARRAY   %token F_RANGE F_COPY_VALUE      /*    * Basic value pushing    */   %token F_LFUN F_GLOBAL F_LOCAL   %token F_GLOBAL_LVALUE F_LOCAL_LVALUE   %token F_CONSTANT F_FLOAT F_STRING   %token F_NUMBER F_NEG_NUMBER F_CONST_1 F_CONST0 F_CONST1   
pike.git/src/language.y:262:    copy_shared_string($$, mixed_type_string);    }         def: modifiers type_or_error optional_stars F_IDENTIFIER '(' arguments ')'    {    int e;    /* construct the function type */    push_finished_type(local_variables->current_type);    while($3--) push_type(T_ARRAY); +  +  if(local_variables->current_return_type) +  free_string(local_variables->current_return_type); +  local_variables->current_return_type=pop_type(); +  +  push_finished_type(local_variables->current_return_type); +     e=$6-1;    if(varargs)    {    push_finished_type(local_variables->variable[e].type);    e--;    varargs=0;    pop_type_stack();    }else{    push_type(T_VOID);    }
pike.git/src/language.y:326:    ins_byte(local_variables->current_number_of_locals, A_PROGRAM);    ins_byte(args, A_PROGRAM);    dooptcode($4, $9, $6);       define_function($4,    $<string>8,    $1,    IDENTIFIER_LPC_FUNCTION | vargs,    &tmp);    } +  if(local_variables->current_return_type) +  { +  free_string(local_variables->current_return_type); +  local_variables->current_return_type=0; +  }    free_all_local_names();    free_string($4);    free_string($<string>8);    }    | modifiers type_or_error name_list ';' {}    | inheritance {}    | error    {    reset_type_stack();    if(num_parse_error>5) YYACCEPT;
pike.git/src/language.y:700:    $$=mknode(F_CASE,$2,0);    }    | F_CASE comma_expr F_DOT_DOT comma_expr ':'    {    $$=mknode(F_CASE,$2,$4);    }    ;      return: F_RETURN    { +  if(!match_types(local_variables->current_return_type, +  void_type_string)) +  { +  yyerror("Must return a value for a non-void function."); +  }    $$=mknode(F_RETURN,mkintnode(0),0);    }    | F_RETURN comma_expr    {    $$=mknode(F_RETURN,$2,0);    };      unused: { $$=0; }    | unused2    ;
pike.git/src/language.y:1080:    }   }   #endif         static void push_locals()   {    struct locals *l;    l=ALLOC_STRUCT(locals);    l->current_type=0; +  l->current_return_type=0;    l->next=local_variables;    local_variables=l;    local_variables->current_number_of_locals=0;   }      static void pop_locals()   {    struct locals *l;    free_all_local_names();    l=local_variables->next;    if(local_variables->current_type)    free_string(local_variables->current_type); -  +  if(local_variables->current_return_type) +  free_string(local_variables->current_return_type);    free((char *)local_variables);       local_variables=l;    /* insert check if ( local->next == parent locals ) here */   }