pike.git / src / docode.c

version» Context lines:

pike.git/src/docode.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: docode.c,v 1.42 1998/11/22 11:02:41 hubbe Exp $"); + RCSID("$Id: docode.c,v 1.43 1999/01/31 09:01:44 hubbe Exp $");   #include "las.h"   #include "program.h"   #include "language.h"   #include "pike_types.h"   #include "stralloc.h"   #include "interpret.h"   #include "constants.h"   #include "array.h"   #include "pike_macros.h"   #include "error.h"
pike.git/src/docode.c:184:    return !!CAR(n)+!!CDR(n);       default:    ret=0;    if(car_is_node(n)) ret += count_cases(CAR(n));    if(cdr_is_node(n)) ret += count_cases(CDR(n));    return ret;    }   }    + static inline struct compiler_frame *find_local_frame(INT32 depth) + { +  struct compiler_frame *f=compiler_frame; +  while(--depth>=0) f=f->previous; +  return f; + } +    static int do_docode2(node *n,int flags)   {    INT32 tmp1,tmp2,tmp3;       if(!n) return 0;       if(flags & DO_LVALUE)    {    switch(n->token)    {
pike.git/src/docode.c:386:    emit2(CAR(n)->token);       emit2(n->token);    return n->token==F_ASSIGN;    }       default:    switch(CDR(n)->token)    {    case F_LOCAL: -  if(CDR(n)->u.number >= compiler_frame->max_number_of_locals) +  if(CDR(n)->u.integer.a >= +  find_local_frame(CDR(n)->u.integer.b)->max_number_of_locals)    yyerror("Illegal to use local variable here.");    -  +  if(CDR(n)->u.integer.b) goto normal_assign; +     code_expression(CAR(n), 0, "RHS");    emit(flags & DO_POP ? F_ASSIGN_LOCAL_AND_POP:F_ASSIGN_LOCAL, -  CDR(n)->u.number ); +  CDR(n)->u.integer.a );    break;       case F_IDENTIFIER:    if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(new_program, CDR(n)->u.number)->identifier_flags))    {    yyerror("Cannot assign functions or constants.\n");    }else{    code_expression(CAR(n), 0, "RHS");    emit(flags & DO_POP ? F_ASSIGN_GLOBAL_AND_POP:F_ASSIGN_GLOBAL,    CDR(n)->u.number);    }    break;       default: -  +  normal_assign:    tmp1=do_docode(CDR(n),DO_LVALUE);    if(do_docode(CAR(n),0)!=1) yyerror("RHS is void!");    emit2(flags & DO_POP ? F_ASSIGN_AND_POP:F_ASSIGN);    break;    }    return flags & DO_POP ? 0 : 1;    }       case F_LAND:    case F_LOR:
pike.git/src/docode.c:1087:    emit(F_CONSTANT,tmp1);       /* copy now or later ? */    if(!(flags & DO_NOT_COPY) && !(n->tree_info & OPT_EXTERNAL_DEPEND))    emit2(F_COPY_VALUE);    return 1;       }       case F_LOCAL: -  if(n->u.number >= compiler_frame->max_number_of_locals) +  if(n->u.integer.a >= +  find_local_frame(n->u.integer.b)->max_number_of_locals)    yyerror("Illegal to use local variable here."); -  +  +  if(n->u.integer.b) +  { +  emit(F_LDA,n->u.integer.b);    if(flags & WANT_LVALUE)    { -  +  emit(F_LEXICAL_LOCAL_LVALUE,n->u.number); +  return 2; +  }else{ +  emit(F_LEXICAL_LOCAL,n->u.number); +  return 1; +  } +  }else{ +  if(flags & WANT_LVALUE) +  {    emit(F_LOCAL_LVALUE,n->u.number);    return 2;    }else{    emit(F_LOCAL,n->u.number);    return 1;    } -  +  }    -  +  case F_TRAMPOLINE: +  emit(F_TRAMPOLINE,n->u.number); +  return 1; +     case F_IDENTIFIER:    if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, n->u.number)->identifier_flags))    {    if(flags & WANT_LVALUE)    {    yyerror("Cannot assign functions.\n");    }else{    emit(F_LFUN,n->u.number);    }    }else{