pike.git / src / language.y

version» Context lines:

pike.git/src/language.y:61:      %token F_MAX_OPCODE   %token F_ADD_EQ   %token F_AND_EQ   %token F_APPLY   %token F_ARG_LIST   %token F_ARRAY_ID   %token F_ARROW   %token F_BREAK   %token F_CASE + %token F_CLASS   %token F_COLON_COLON   %token F_COMMA   %token F_CONTINUE   %token F_DEFAULT   %token F_DIV_EQ   %token F_DO   %token F_DOT_DOT   %token F_DOT_DOT_DOT   %token F_EFUN   %token F_EFUN_CALL
pike.git/src/language.y:213:   %type <number> F_PROTECTED F_PUBLIC F_RETURN F_SSCANF F_STATIC   %type <number> F_STRING_ID F_SWITCH F_VARARGS F_VOID_ID F_WHILE      /* The following symbos return type information */      %type <n> string expr01 expr00 comma_expr   %type <n> expr2 expr1 expr3 expr0 expr4 catch lvalue_list   %type <n> lambda for_expr block assoc_pair new_local_name   %type <n> expr_list2 m_expr_list m_expr_list2 statement gauge sscanf   %type <n> for do cond optional_else_part while statements - %type <n> local_name_list + %type <n> local_name_list class   %type <n> unused2 foreach unused switch case return expr_list default   %type <n> continue break block_or_semi   %%      all: program;      program: program def optional_semi_colon    | /* empty */ ;      optional_semi_colon: /* empty */
pike.git/src/language.y:328:       tmp.offset=PC;    args=count_arguments($<string>8);    if(args < 0)    {    args=~args;    vargs=IDENTIFIER_VARARGS;    }else{    vargs=0;    } -  ins_byte(local_variables->current_number_of_locals, A_PROGRAM); +  ins_byte(local_variables->max_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)
pike.git/src/language.y:563:    mknode(F_ASSIGN,$4,    mklocalnode(islocal($2))));       };         block:'{'    {    $<number>$=local_variables->current_number_of_locals;    } -  statements '}' +  statements +  '}'    { -  int e; -  for(e=($<number>2)+1;e<local_variables->current_number_of_locals;e++) +  while(local_variables->current_number_of_locals > $<number>2)    { -  if(local_variables->variable[e].name) -  { +  int e; +  e=--(local_variables->current_number_of_locals);    free_string(local_variables->variable[e].name);    free_string(local_variables->variable[e].type);    } -  local_variables->variable[e].name=0; -  local_variables->variable[e].type=0; -  } +     $$=$3;    } ;      local_name_list: new_local_name    | local_name_list ',' new_local_name    {    $$=mknode(F_ARG_LIST,$1,$3);    }    ;   
pike.git/src/language.y:669:    func.offset=PC;       args=count_arguments(type);    if(args < 0)    {    args=~args;    vargs=IDENTIFIER_VARARGS;    }else{    vargs=0;    } -  ins_byte(local_variables->current_number_of_locals, A_PROGRAM); +  ins_byte(local_variables->max_number_of_locals, A_PROGRAM);    ins_byte(args, A_PROGRAM);       sprintf(buf,"__lambda_%ld",    (long)fake_program.num_identifier_references);    name=make_shared_string(buf);    dooptcode(name,mknode(F_ARG_LIST,$6,mknode(F_RETURN,mkintnode(0),0)),$4);    f=define_function(name,    type,    0,    IDENTIFIER_LPC_FUNCTION | vargs,    &func);    free_string(name);    free_string(type);    pop_locals();    $$=mkidentifiernode(f);    } ;    -  + class: F_CLASS '{' +  { +  start_new_program(); +  } +  program +  '}' +  { +  struct svalue s; +  s.u.program=end_program(); +  if(!s.u.program) +  { +  yyerror("Class definition failed."); +  s.type=T_INT; +  s.subtype=0; +  } else { +  s.type=T_PROGRAM; +  s.subtype=0; +  } +  $$=mksvaluenode(&s); +  free(&s); +  } ;      cond: F_IF '(' comma_expr ')'    statement    optional_else_part    {    $$=mknode('?',$3,mknode(':',$5,$6));    $$->line_number=$1;    $$=mkcastnode(void_type_string,$$);    $$->line_number=$1;    }
pike.git/src/language.y:895:    | expr4 F_DEC { $$=mknode(F_POST_DEC,$1,0); }    ;      expr4: string    | F_NUMBER { $$=mkintnode($1); }    | F_FLOAT { $$=mkfloatnode($1); }    | catch    | gauge    | sscanf    | lambda +  | class    | F_IDENTIFIER    {    int i;    struct efun *f;    if((i=islocal($1))>=0)    {    $$=mklocalnode(i);    }else if((i=isidentifier($1))>=0){    $$=mkidentifiernode(i);    }else if((f=lookup_efun($1))){
pike.git/src/language.y:952:    }    | F_IDENTIFIER F_COLON_COLON F_IDENTIFIER    {    int f;    struct reference *idp;       setup_fake_program();    f=reference_inherited_identifier($1,$3);    idp=fake_program.identifier_references+f;    if (f<0 || ID_FROM_PTR(&fake_program,idp)->func.offset == -1) +  {    my_yyerror("Undefined identifier %s::%s", $1->str,$3->str); -  +  $$=mkintnode(0); +  } else { +  $$=mkidentifiernode(f); +  }       free_string($1);    free_string($3); -  $$=mkidentifiernode(f); +     }    | F_COLON_COLON F_IDENTIFIER    {    int e,i;       $$=0;    setup_fake_program(); -  for(e=1;e<fake_program.num_inherits;e++) +  for(e=1;e<(int)fake_program.num_inherits;e++)    {    if(fake_program.inherits[e].inherit_level!=1) continue;    i=low_reference_inherited_identifier(e,$2);    if(i==-1) continue;    if($$)    {    $$=mknode(F_ARG_LIST,$$,mkidentifiernode(i));    }else{    $$=mkidentifiernode(i);    }
pike.git/src/language.y:1072:   void add_local_name(struct lpc_string *str,    struct lpc_string *type)   {    if (local_variables->current_number_of_locals == MAX_LOCAL)    {    yyerror("Too many local variables");    }else {    local_variables->variable[local_variables->current_number_of_locals].type = type;    local_variables->variable[local_variables->current_number_of_locals].name = str;    local_variables->current_number_of_locals++; +  if(local_variables->current_number_of_locals > +  local_variables->max_number_of_locals) +  { +  local_variables->max_number_of_locals= +  local_variables->current_number_of_locals;    }    } -  + }      /* argument must be a shared string */   int islocal(struct lpc_string *str)   {    int e;    for(e=local_variables->current_number_of_locals-1;e>=0;e--)    if(local_variables->variable[e].name==str)    return e;    return -1;   }
pike.git/src/language.y:1100:    {    if(local_variables->variable[e].name)    {    free_string(local_variables->variable[e].name);    free_string(local_variables->variable[e].type);    }    local_variables->variable[e].name=0;    local_variables->variable[e].type=0;    }    local_variables->current_number_of_locals = 0; +  local_variables->max_number_of_locals = 0;   }    -  - #ifdef DEBUG - void dump_program_desc(struct program *p) - { -  int e,d,q; - /* fprintf(stderr,"Program '%s':\n",p->name->str); */ -  - /* -  fprintf(stderr,"All inherits:\n"); -  for(e=0;e<p->num_inherits;e++) -  { -  fprintf(stderr,"%3d:",e); -  for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," "); -  fprintf(stderr,"%s\n",p->inherits[e].prog->name->str); -  } - */ -  -  fprintf(stderr,"All identifiers:\n"); -  for(e=0;e<p->num_identifier_references;e++) -  { -  fprintf(stderr,"%3d:",e); -  for(d=0;d<INHERIT_FROM_INT(p,e)->inherit_level;d++) fprintf(stderr," "); -  fprintf(stderr,"%s;\n",ID_FROM_INT(p,e)->name->str); -  } -  fprintf(stderr,"All sorted identifiers:\n"); -  for(q=0;q<p->num_identifier_indexes;q++) -  { -  e=p->identifier_index[q]; -  fprintf(stderr,"%3d (%3d):",e,q); -  for(d=0;d<INHERIT_FROM_INT(p,e)->inherit_level;d++) fprintf(stderr," "); -  fprintf(stderr,"%s;\n", ID_FROM_INT(p,e)->name->str); -  } - } - #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; -  +  l->current_number_of_locals=0; +  l->max_number_of_locals=0;    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 */   }