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.37 1998/05/17 20:06:43 grubba Exp $"); + RCSID("$Id: docode.c,v 1.38 1998/05/25 10:38: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:213:    case F_GLOBAL:    case F_IDENTIFIER:    case F_INDEX:    case F_ARROW:    case F_ARG_LIST:    case F_EXTERNAL:    break;    }    }    +  if(flags & DO_LVALUE_IF_POSSIBLE) +  { +  flags|=DO_INDIRECT; +  flags &=~DO_LVALUE_IF_POSSIBLE; +  }else{ +  flags &=~DO_INDIRECT; +  } +     switch(n->token)    {    case F_EXTERNAL:    emit(F_LDA, n->u.integer.a); -  if(flags & DO_LVALUE) +  if(flags & WANT_LVALUE)    {    emit(F_EXTERNAL_LVALUE, n->u.integer.b);    return 2;    }else{    emit(F_EXTERNAL, n->u.integer.b);    return 1;    }    break;       case F_UNDEFINED:
pike.git/src/docode.c:679:    }else{    tmp1=store_constant(& foo->u.sval, 1);    emit(F_APPLY, tmp1);    }    }    free_node(foo);    return 1;    }       case F_ARG_LIST: -  tmp1=do_docode(CAR(n),flags & ~DO_LVALUE); +  tmp1=do_docode(CAR(n),flags & ~WANT_LVALUE);    tmp1+=do_docode(CDR(n),flags);    return tmp1;          /* Switch:    * So far all switches are implemented with a binsearch lookup.    * It stores the case values in the programs area for constants.    * It also has a jump-table in the program itself, for every index in    * the array of cases, there is 2 indexes in the jumptable, and one extra.    * The first entry in the jumptable is used if you call switch with
pike.git/src/docode.c:937: Inside #if defined(DEBUG)
  #ifdef DEBUG    if(tmp1 & 1)    fatal("Very internal compiler error.\n");   #endif    emit(F_ARRAY_LVALUE, tmp1>>1);    return 2;       case F_ARROW:    if(CDR(n)->token != F_CONSTANT || CDR(n)->u.sval.type!=T_STRING)    fatal("Bugg in F_ARROW, index not string."); -  if(flags & DO_LVALUE) +  if(flags & WANT_LVALUE)    {    /* FIXME!!!! ??? I wonder what needs fixing... /Hubbe */    tmp1=do_docode(CAR(n), 0);    emit(F_ARROW_STRING, store_prog_string(CDR(n)->u.sval.u.string));    return 2;    }else{    tmp1=do_docode(CAR(n), DO_NOT_COPY);    emit(F_ARROW, store_prog_string(CDR(n)->u.sval.u.string));    if(!(flags & DO_NOT_COPY))    {    while(n && (n->token==F_INDEX || n->token==F_ARROW)) n=CAR(n);    if(n->token==F_CONSTANT && !(n->node_info & OPT_EXTERNAL_DEPEND))    emit2(F_COPY_VALUE);    }    }    return tmp1;       case F_INDEX: -  if(flags & DO_LVALUE) +  if(flags & WANT_LVALUE)    { -  tmp1=do_docode(CAR(n), 0); +  int mklval=CAR(n) && match_types(CAR(n)->type, string_type_string); +  tmp1=do_docode(CAR(n), +  mklval ? DO_LVALUE_IF_POSSIBLE : 0); +  if(tmp1==2) +  { + #ifdef DEBUG +  if(!mklval) +  fatal("Unwanted lvalue!\n"); + #endif +  emit2(F_INDIRECT); +  } +     if(do_docode(CDR(n),0) != 1)    fatal("Internal compiler error, please report this (1).");    if(CDR(n)->token != F_CONSTANT &&    match_types(CDR(n)->type, string_type_string))    emit2(F_CLEAR_STRING_SUBTYPE);    return 2;    }else{    tmp1=do_docode(CAR(n), DO_NOT_COPY);    code_expression(CDR(n), DO_NOT_COPY, "index"); -  +     emit2(F_INDEX); -  +     if(!(flags & DO_NOT_COPY))    {    while(n && (n->token==F_INDEX || n->token==F_ARROW)) n=CAR(n);    if(n->token==F_CONSTANT && !(n->node_info & OPT_EXTERNAL_DEPEND))    emit2(F_COPY_VALUE);    }    }    return tmp1;       case F_CONSTANT:
pike.git/src/docode.c:1039:    /* 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)    yyerror("Illegal to use local variable here."); -  if(flags & DO_LVALUE) +  if(flags & WANT_LVALUE)    {    emit(F_LOCAL_LVALUE,n->u.number);    return 2;    }else{    emit(F_LOCAL,n->u.number);    return 1;    }       case F_IDENTIFIER:    if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, n->u.number)->identifier_flags))    { -  if(flags & DO_LVALUE) +  if(flags & WANT_LVALUE)    {    yyerror("Cannot assign functions.\n");    }else{    emit(F_LFUN,n->u.number);    }    }else{ -  if(flags & DO_LVALUE) +  if(flags & WANT_LVALUE)    {    emit(F_GLOBAL_LVALUE,n->u.number);    return 2;    }else{    emit(F_GLOBAL,n->u.number);    }    }    return 1;       case F_VAL_LVAL: