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.16 1997/04/17 22:47:06 hubbe Exp $"); + RCSID("$Id: docode.c,v 1.16.2.1 1997/06/25 22:46:36 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:25:   #include "operators.h"      INT32 current_break=-1;   INT32 current_continue=-1;      static INT32 current_switch_case;   static INT32 current_switch_default;   static INT32 current_switch_values_on_stack;   static INT32 *current_switch_jumptable =0;    - void ins_byte(unsigned char b,int area) - { -  add_to_mem_block(area, (char *)&b, 1); - } -  - void ins_signed_byte(char b,int area) - { -  add_to_mem_block(area, (char *)&b, 1); - } -  - void ins_short(INT16 l,int area) - { -  add_to_mem_block(area, (char *)&l, sizeof(INT16)); - } -  - /* -  * Store an INT32. -  */ - void ins_int(INT32 l,int area) - { -  add_to_mem_block(area, (char *)&l+0, sizeof(INT32)); - } -  +    void upd_int(int offset, INT32 tmp)   { - #ifdef HANDLES_UNALIGNED_MEMORY_ACCESS -  *((int *)(areas[A_PROGRAM].s.str+offset))=tmp; - #else -  MEMCPY(areas[A_PROGRAM].s.str+offset, (char *)&tmp,sizeof(tmp)); - #endif +  MEMCPY(new_program->program+offset, (char *)&tmp,sizeof(tmp));   }      INT32 read_int(int offset)   { -  INT32 tmp; - #ifdef HANDLES_UNALIGNED_MEMORY_ACCESS -  tmp=*((int *)(areas[A_PROGRAM].s.str+offset)); - #else -  MEMCPY((char *)&tmp, areas[A_PROGRAM].s.str+offset,sizeof(tmp)); - #endif -  return tmp; +  return EXTRACT_INT(new_program->program+offset);   }      int store_linenumbers=1;      /*    * A mechanism to remember addresses on a stack.    */   int comp_stackp;   INT32 comp_stack[COMPILER_STACK_SIZE];   
pike.git/src/docode.c:141:    case 1: emit2(F_POP_VALUE); break;    default: emit(F_POP_N_ELEMS,x); break;    }   }      #define DO_CODE_BLOCK(X) do_pop(do_docode((X),DO_NOT_COPY | DO_POP));      int do_docode(node *n,INT16 flags)   {    int i; -  int save_current_line=current_line; +  int save_current_line=lex.current_line;    if(!n) return 0; -  current_line=n->line_number; +  lex.current_line=n->line_number;    i=do_docode2(n, flags);    -  current_line=save_current_line; +  lex.current_line=save_current_line;    return i;   }         static int is_efun(node *n, c_fun fun)   {    return n && n->token == F_CONSTANT &&    n->u.sval.subtype == FUNCTION_BUILTIN &&    n->u.sval.u.efun->function == fun;   }      static void code_expression(node *n, int flags, char *err)   {    switch(do_docode(n, flags & ~ DO_POP))    {    case 0: my_yyerror("Void expression for %s",err);    case 1: return;    case 2:    fatal("Internal compiler error (%s), line %ld, file %s\n",    err, -  (long)current_line, -  current_file?current_file->str:"Unknown"); +  (long)lex.current_line, +  lex.current_file?lex.current_file->str:"Unknown");    }   }      void do_cond_jump(node *n, int label, int iftrue, int flags)   {    iftrue=!!iftrue;    if((flags & DO_POP) && node_is_tossable(n))    {    int t,f;    t=!!node_is_true(n);
pike.git/src/docode.c:287:    case F_IDENTIFIER:    case F_INDEX:    case F_ARROW:    case F_ARG_LIST:    break;    }    }       switch(n->token)    { +  case F_UNDEFINED: +  yyerror("Undefined identifier"); +  emit(F_NUMBER,0); +  return 1; +     case F_PUSH_ARRAY:    code_expression(CAR(n), 0, "`@");    emit2(F_PUSH_ARRAY);    return -0x7ffffff;       case '?':    {    INT32 *prev_switch_jumptable = current_switch_jumptable;    int adroppings , bdroppings;    current_switch_jumptable=0;
pike.git/src/docode.c:433:    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 >= local_variables->max_number_of_locals) +  if(CDR(n)->u.number >= compiler_frame->max_number_of_locals)    yyerror("Illegal to use local variable here.");       code_expression(CAR(n), 0, "RHS");    emit(flags & DO_POP ? F_ASSIGN_LOCAL_AND_POP:F_ASSIGN_LOCAL,    CDR(n)->u.number );    break;       case F_IDENTIFIER: -  if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(& fake_program, CDR(n)->u.number)->flags)) +  if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(new_program, CDR(n)->u.number)->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:
pike.git/src/docode.c:493:    case F_OR:    case F_AND:    case F_NOT:    case F_COMPL:    case F_NEGATE:    fatal("Optimizer errror.\n");       case F_RANGE:    tmp1=do_docode(CAR(n),DO_NOT_COPY);    if(do_docode(CDR(n),DO_NOT_COPY)!=2) -  fatal("Compiler internal error (at %ld).\n",(long)current_line); +  fatal("Compiler internal error (at %ld).\n",(long)lex.current_line);    emit2(n->token);    return tmp1;       case F_INC:    case F_POST_INC:    tmp1=do_docode(CAR(n),DO_LVALUE);   #ifdef DEBUG    if(tmp1 != 2)    fatal("HELP! FATAL INTERNAL COMPILER ERROR\n");   #endif
pike.git/src/docode.c:695:       emit2(F_MARK);    do_docode(CDR(n),0);    tmp1=store_constant(& CAR(n)->u.sval,    !(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND));    emit(F_APPLY,tmp1);       return 1;    }    else if(CAR(n)->token == F_IDENTIFIER && -  IDENTIFIER_IS_FUNCTION(ID_FROM_INT(& fake_program, CAR(n)->u.number)->flags)) +  IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, CAR(n)->u.number)->flags))    {    emit2(F_MARK);    do_docode(CDR(n),0);    emit(F_CALL_LFUN, CAR(n)->u.number);    return 1;    }    else    {    struct pike_string *tmp;    struct efun *fun;
pike.git/src/docode.c:1027:    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 >= local_variables->max_number_of_locals) +  if(n->u.number >= compiler_frame->max_number_of_locals)    yyerror("Illegal to use local variable here.");    if(flags & DO_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(& fake_program, n->u.number)->flags)) +  if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, n->u.number)->flags))    {    if(flags & DO_LVALUE)    {    yyerror("Cannot assign functions.\n");    }else{    emit(F_LFUN,n->u.number);    }    }else{    if(flags & DO_LVALUE)    {