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.73 2000/05/11 14:09:45 grubba Exp $"); + RCSID("$Id: docode.c,v 1.74 2000/06/24 00:48:13 hubbe Exp $");   #include "las.h"   #include "program.h"   #include "pike_types.h"   #include "stralloc.h"   #include "interpret.h"   #include "constants.h"   #include "array.h"   #include "pike_macros.h"   #include "error.h"   #include "pike_memory.h"
pike.git/src/docode.c:33:   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;   static struct pike_string *current_switch_type = NULL;      void upd_int(int offset, INT32 tmp)   { -  MEMCPY(new_program->program+offset, (char *)&tmp,sizeof(tmp)); +  MEMCPY(Pike_compiler->new_program->program+offset, (char *)&tmp,sizeof(tmp));   }      INT32 read_int(int offset)   { -  return EXTRACT_INT(new_program->program+offset); +  return EXTRACT_INT(Pike_compiler->new_program->program+offset);   }      int store_linenumbers=1;   static int label_no=0;      int alloc_label(void) { return ++label_no; }      int do_jump(int token,INT32 lbl)   {    if(lbl==-1) lbl=alloc_label();
pike.git/src/docode.c:189:    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; +  struct compiler_frame *f=Pike_compiler->compiler_frame;    while(--depth>=0) f=f->previous;    return f;   }      int do_lfun_call(int id,node *args)   {   #if 1 -  if(id == compiler_frame->current_function_number) +  if(id == Pike_compiler->compiler_frame->current_function_number)    {    int n=count_args(args); -  if(n == compiler_frame->num_args) +  if(n == Pike_compiler->compiler_frame->num_args)    { -  if(compiler_frame->is_inline) +  if(Pike_compiler->compiler_frame->is_inline)    {    emit0(F_MARK);    do_docode(args,0); -  compiler_frame->recur_label=do_jump(F_RECUR, -  compiler_frame->recur_label); +  Pike_compiler->compiler_frame->recur_label=do_jump(F_RECUR, +  Pike_compiler->compiler_frame->recur_label);    return 1;    }else{    emit0(F_MARK);    do_docode(args,0);    emit1(F_COND_RECUR,id); -  compiler_frame->recur_label=do_jump(F_POINTER, -  compiler_frame->recur_label); +  Pike_compiler->compiler_frame->recur_label=do_jump(F_POINTER, +  Pike_compiler->compiler_frame->recur_label);    return 1;    }    }    }   #endif    emit0(F_MARK);    do_docode(args,0);    emit1(F_CALL_LFUN, id);    return 1;   }
pike.git/src/docode.c:487:    yyerror("Illegal to use local variable here.");       if(CDR(n)->u.integer.b) goto normal_assign;       code_expression(CAR(n), 0, "RHS");    emit1(flags & DO_POP ? F_ASSIGN_LOCAL_AND_POP:F_ASSIGN_LOCAL,    CDR(n)->u.integer.a );    break;       case F_IDENTIFIER: -  if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(new_program, CDR(n)->u.id.number)->identifier_flags)) +  if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program, CDR(n)->u.id.number)->identifier_flags))    {    yyerror("Cannot assign functions or constants.\n");    }else{    code_expression(CAR(n), 0, "RHS");    emit1(flags & DO_POP ? F_ASSIGN_GLOBAL_AND_POP:F_ASSIGN_GLOBAL,    CDR(n)->u.id.number);    }    break;       default:
pike.git/src/docode.c:789:    tmp1=store_constant(& CAR(n)->u.sval,    !(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),    CAR(n)->name);    emit1(F_APPLY,tmp1);    }    if(n->type == void_type_string)    return 0;       return 1;    }else{ -  if(CAR(n)->u.sval.u.object == fake_object) +  if(CAR(n)->u.sval.u.object == Pike_compiler->fake_object)    return do_lfun_call(CAR(n)->u.sval.subtype,CDR(n));    }    }       emit0(F_MARK);    do_docode(CDR(n),0);    tmp1=store_constant(& CAR(n)->u.sval,    !(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),    CAR(n)->name);    emit1(F_APPLY,tmp1);       return 1;    }    else if(CAR(n)->token == F_IDENTIFIER && -  IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, +  IDENTIFIER_IS_FUNCTION(ID_FROM_INT(Pike_compiler->new_program,    CAR(n)->u.id.number)->identifier_flags))    {    return do_lfun_call(CAR(n)->u.id.number,CDR(n));    }    else    {    struct pike_string *tmp;    struct efun *fun;    node *foo;   
pike.git/src/docode.c:913:    DO_CODE_BLOCK(CDR(n));      #ifdef PIKE_DEBUG    if(sp-save_sp != cases)    fatal("Count cases is wrong!\n");   #endif       f_aggregate(cases);    order=get_switch_order(sp[-1].u.array);    -  if (!num_parse_error) { +  if (!Pike_compiler->num_parse_error) {    /* Check for cases inside a range */    for(e=0; e<cases-1; e++)    {    if(order[e] < cases-1)    {    int o1=order[e]*2+2;    if(current_switch_jumptable[o1]==current_switch_jumptable[o1+1] &&    current_switch_jumptable[o1]==current_switch_jumptable[o1+2])    {    if(order[e]+1 != order[e+1])
pike.git/src/docode.c:992:    if (!match_types(lower->type, current_switch_type)) {    yytype_error("Type mismatch in case.",    current_switch_type, lower->type, 0);    } else if (lex.pragmas & ID_STRICT_TYPES) {    yytype_error("Type mismatch in case.",    current_switch_type, lower->type, YYTE_IS_WARNING);    }    }    }    -  if (!num_parse_error) { +  if (!Pike_compiler->num_parse_error) {    tmp1=eval_low(lower);    if(tmp1<1)    {    yyerror("Error in case label.");    push_int(0);    tmp1=1;    }    pop_n_elems(tmp1-1);    current_switch_values_on_stack++;    for(tmp1=current_switch_values_on_stack; tmp1 > 1; tmp1--)
pike.git/src/docode.c:1026:       if(CAR(n))    {    if(!is_const(CDR(n)))    yyerror("Case label isn't constant.");       current_switch_jumptable[current_switch_case]=    current_switch_jumptable[current_switch_case-1];    current_switch_case++;    -  if (!num_parse_error) { +  if (!Pike_compiler->num_parse_error) {    tmp1=eval_low(CDR(n));    if(tmp1<1)    {    yyerror("Error in second half of case label.");    push_int(0);    tmp1=1;    }    pop_n_elems(tmp1-1);    current_switch_values_on_stack++;    for(tmp1=current_switch_values_on_stack; tmp1 > 1; tmp1--)
pike.git/src/docode.c:1208:    return 1;       case T_STRING:    tmp1=store_prog_string(n->u.sval.u.string);    emit1(F_STRING,tmp1);    return 1;       case T_FUNCTION:    if(n->u.sval.subtype!=FUNCTION_BUILTIN)    { -  if(n->u.sval.u.object == fake_object) +  if(n->u.sval.u.object == Pike_compiler->fake_object)    {    emit1(F_LFUN,n->u.sval.subtype);    return 1;    }       if(n->u.sval.u.object->next == n->u.sval.u.object)    {    int x=0;    struct object *o;    -  for(o=fake_object->parent;o!=n->u.sval.u.object;o=o->parent) +  for(o=Pike_compiler->fake_object->parent;o!=n->u.sval.u.object;o=o->parent)    x++;    emit2(F_EXTERNAL, n->u.sval.subtype,x); -  new_program->flags |= PROGRAM_USES_PARENT; +  Pike_compiler->new_program->flags |= PROGRAM_USES_PARENT;    return 1;    }    }      #ifdef PIKE_DEBUG    case T_OBJECT:    if(n->u.sval.u.object->next == n->u.sval.u.object)    fatal("Internal error: Pointer to parent cannot be a compile time constant!\n");   #endif   
pike.git/src/docode.c:1286:    emit1(F_LOCAL,n->u.id.number);    return 1;    }    }       case F_TRAMPOLINE:    emit1(F_TRAMPOLINE,n->u.id.number);    return 1;       case F_IDENTIFIER: -  if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, n->u.id.number)->identifier_flags)) +  if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(Pike_compiler->new_program, n->u.id.number)->identifier_flags))    {    if(flags & WANT_LVALUE)    {    yyerror("Cannot assign functions.\n");    }else{    emit1(F_LFUN,n->u.id.number);    }    }else{    if(flags & WANT_LVALUE)    {
pike.git/src/docode.c:1319:    fatal("Infernal compiler error (unknown parse-tree-token).\n");    return 0; /* make gcc happy */    }   }      void do_code_block(node *n)   {    init_bytecode();    label_no=1;    -  emit1(F_BYTE,compiler_frame->max_number_of_locals); -  emit1(F_BYTE,compiler_frame->num_args); +  emit1(F_BYTE,Pike_compiler->compiler_frame->max_number_of_locals); +  emit1(F_BYTE,Pike_compiler->compiler_frame->num_args);    emit0(F_START_FUNCTION);    emit1(F_LABEL,0); -  if(new_program->identifier_references[compiler_frame-> +  if(Pike_compiler->new_program->identifier_references[Pike_compiler->compiler_frame->    current_function_number].id_flags &    ID_INLINE)    { -  compiler_frame->recur_label=0; -  compiler_frame->is_inline=1; +  Pike_compiler->compiler_frame->recur_label=0; +  Pike_compiler->compiler_frame->is_inline=1;    }       DO_CODE_BLOCK(n);    -  if(compiler_frame->recur_label > 0) +  if(Pike_compiler->compiler_frame->recur_label > 0)    {   #ifdef PIKE_DEBUG    if(l_flag)    {    fprintf(stderr,"Generating inline recursive function.\n");    }   #endif    /* generate code again, but this time it is inline */ -  compiler_frame->is_inline=1; +  Pike_compiler->compiler_frame->is_inline=1;       /* This is a no-op, but prevents optimizer to delete the bytes below */    emit1(F_LABEL,-1); -  emit1(F_BYTE,compiler_frame->max_number_of_locals); -  emit1(F_BYTE,compiler_frame->num_args); +  emit1(F_BYTE,Pike_compiler->compiler_frame->max_number_of_locals); +  emit1(F_BYTE,Pike_compiler->compiler_frame->num_args);    emit0(F_START_FUNCTION); -  emit1(F_LABEL,compiler_frame->recur_label); +  emit1(F_LABEL,Pike_compiler->compiler_frame->recur_label);    DO_CODE_BLOCK(n);    }    assemble();   }      int docode(node *n)   {    int tmp;    int label_no_save = label_no;    dynamic_buffer instrbuf_save = instrbuf;