pike.git / src / pike_compiler.c

version» Context lines:

pike.git/src/pike_compiler.c:2579: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if (a_flag > 2) {    dump_program_tables(ret, 0);    }   #endif /* PIKE_DEBUG */    verify_supporters();    return ret;    }   }    +  + void push_compiler_frame(int lexical_scope) + { +  struct compiler_frame *f; +  f=ALLOC_STRUCT(compiler_frame); +  f->previous=Pike_compiler->compiler_frame; +  f->lexical_scope=lexical_scope; +  f->current_type=0; +  f->current_return_type=0; +  +  f->current_number_of_locals=0; +  f->max_number_of_locals=0; +  f->min_number_of_locals=0; +  f->last_block_level=-1; +  +  f->current_function_number=-2; /* no function */ +  f->recur_label=-1; +  f->is_inline=0; +  f->num_args=-1; +  f->opt_flags = OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND; /* FIXME: Should be 0. */ +  Pike_compiler->compiler_frame=f; + } +  + node *low_pop_local_variables(int level, node *block) + { +  struct compilation *c = THIS_COMPILATION; +  while(Pike_compiler->compiler_frame->current_number_of_locals > level) +  { +  int e; +  e=--(Pike_compiler->compiler_frame->current_number_of_locals); +  if (block) { +  block = mknode(F_COMMA_EXPR, block, +  mknode(F_POP_VALUE, +  mknode(F_ASSIGN, +  mkintnode(0), +  mklocalnode(e, 0)), +  NULL)); +  } +  if ((Pike_compiler->compiler_pass == 2) && +  !(Pike_compiler->compiler_frame->variable[e].flags & +  LOCAL_VAR_IS_USED)) { +  ref_push_string(Pike_compiler->compiler_frame->variable[e].name); +  low_yyreport(REPORT_WARNING, +  Pike_compiler->compiler_frame->variable[e].file, +  Pike_compiler->compiler_frame->variable[e].line, +  parser_system_string, +  1, "Unused local variable %s."); +  } +  free_string(Pike_compiler->compiler_frame->variable[e].name); +  free_type(Pike_compiler->compiler_frame->variable[e].type); +  if(Pike_compiler->compiler_frame->variable[e].def) +  free_node(Pike_compiler->compiler_frame->variable[e].def); +  +  free_string(Pike_compiler->compiler_frame->variable[e].file); +  } +  return block; + } +  + node *pop_local_variables(int level, node *block) + { + #if 1 +  struct compilation *c = THIS_COMPILATION; +  /* We need to save the variables Kuppo (but not their names) */ +  if(level < Pike_compiler->compiler_frame->min_number_of_locals) +  { +  /* FIXME: Consider using flags to indicate whether a local variable +  * actually is used from a nested scope. */ +  for(;level<Pike_compiler->compiler_frame->min_number_of_locals;level++) +  { +  if ((Pike_compiler->compiler_pass == 2) && +  !(Pike_compiler->compiler_frame->variable[level].flags & +  LOCAL_VAR_IS_USED)) { +  ref_push_string(Pike_compiler->compiler_frame->variable[level].name); +  low_yyreport(REPORT_WARNING, +  Pike_compiler->compiler_frame->variable[level].file, +  Pike_compiler->compiler_frame->variable[level].line, +  parser_system_string, +  1, "Unused local variable %s."); +  /* Make sure we only warn once... */ +  Pike_compiler->compiler_frame->variable[level].flags |= +  LOCAL_VAR_IS_USED; +  } +  free_string(Pike_compiler->compiler_frame->variable[level].name); +  copy_shared_string(Pike_compiler->compiler_frame->variable[level].name, +  empty_pike_string); +  /* FIXME: Do we need to keep the filenames? */ +  } +  } + #endif +  return low_pop_local_variables(level, block); + } +  +  + void pop_compiler_frame(void) + { +  struct compiler_frame *f; +  +  f=Pike_compiler->compiler_frame; + #ifdef PIKE_DEBUG +  if(!f) +  Pike_fatal("Popping out of compiler frames\n"); + #endif +  +  low_pop_local_variables(0, NULL); +  if(f->current_type) +  free_type(f->current_type); +  +  if(f->current_return_type) +  free_type(f->current_return_type); +  +  Pike_compiler->compiler_frame=f->previous; +  dmfree((char *)f); + } +  +  + PMOD_EXPORT void change_compiler_compatibility(int major, int minor) + { +  CHECK_COMPILER(); +  +  push_int(major); +  push_int(minor); +  +  safe_apply_current2(PC_CHANGE_COMPILER_COMPATIBILITY_FUN_NUM, 2, +  "change_compiler_compatibility"); +  pop_stack(); + } +    void init_pike_compiler(void)   {   #ifdef PIKE_THREADS    co_init(&Pike_compiler_cond);   #endif       compile_compiler();   }      void cleanup_pike_compiler(void)