pike.git / src / docode.c

version» Context lines:

pike.git/src/docode.c:1:   /*\   ||| This file is part of Pike. For copyright information see COPYRIGHT.   ||| Pike is distributed under GPL, LGPL and MPL. See the file COPYING   ||| for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: docode.c,v 1.143 2002/07/02 18:12:16 grubba Exp $"); + RCSID("$Id: docode.c,v 1.144 2002/08/15 14:49:20 marcus 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 "pike_error.h"   #include "pike_memory.h"
pike.git/src/docode.c:71:   static int current_stack_depth = 0;   #endif      #define PUSH_CLEANUP_FRAME(func, arg) do { \    struct cleanup_frame cleanup_frame__; \    cleanup_frame__.cleanup = (cleanup_func) (func); \    cleanup_frame__.cleanup_arg = (void *)(ptrdiff_t) (arg); \    cleanup_frame__.stack_depth = current_stack_depth; \    DO_IF_DEBUG( \    if (current_label->cleanups == (void *)(ptrdiff_t) -1) \ -  fatal("current_label points to an unused statement_label.\n"); \ +  Pike_fatal("current_label points to an unused statement_label.\n"); \    ) \    if (current_label->break_label == -2) { \    DO_IF_DEBUG( \    if (current_label->prev->break_label == -2) \ -  fatal("Found two open statement_label entries in a row.\n"); \ +  Pike_fatal("Found two open statement_label entries in a row.\n"); \    ) \    cleanup_frame__.prev = current_label->prev->cleanups; \    current_label->prev->cleanups = &cleanup_frame__; \    } \    else { \    cleanup_frame__.prev = current_label->cleanups; \    current_label->cleanups = &cleanup_frame__; \    }      #define POP_AND_DONT_CLEANUP \    if (current_label->cleanups == &cleanup_frame__) \    current_label->cleanups = cleanup_frame__.prev; \    else { \    DO_IF_DEBUG( \    if (current_label->prev->cleanups != &cleanup_frame__) \ -  fatal("Cleanup frame lost from statement_label cleanup list.\n");\ +  Pike_fatal("Cleanup frame lost from statement_label cleanup list.\n");\    ) \    current_label->prev->cleanups = cleanup_frame__.prev; \    } \   } while (0)      #define POP_AND_DO_CLEANUP \    do_pop(current_stack_depth - cleanup_frame__.stack_depth); \    cleanup_frame__.cleanup(cleanup_frame__.cleanup_arg); \    POP_AND_DONT_CLEANUP   
pike.git/src/docode.c:116:    * through jumps, but not through exceptions). This includes the    * svalue and mark stacks, and the catch block nesting.    */   #ifdef PIKE_DEBUG   #define BLOCK_BEGIN \    PUSH_CLEANUP_FRAME(do_cleanup_synch_mark, 0); \    if (d_flag > 2) emit0(F_SYNCH_MARK);   #define BLOCK_END \    if (current_stack_depth != cleanup_frame__.stack_depth) { \    print_tree(n); \ -  fatal("Stack not in synch after block: is %d, should be %d.\n", \ +  Pike_fatal("Stack not in synch after block: is %d, should be %d.\n", \    current_stack_depth, cleanup_frame__.stack_depth); \    } \    if (d_flag > 2) emit0(F_POP_SYNCH_MARK); \    POP_AND_DONT_CLEANUP   #else   #define BLOCK_BEGIN   #define BLOCK_END   #endif      #define PUSH_STATEMENT_LABEL do { \
pike.git/src/docode.c:151:    new_label__.stack_depth = current_stack_depth; \    ) \    current_label->stack_depth = current_stack_depth; \    }      #define POP_STATEMENT_LABEL \    current_label = new_label__.prev; \    DO_IF_DEBUG( \    if (new_label__.cleanups && \    new_label__.cleanups != (void *)(ptrdiff_t) -1) \ -  fatal("Cleanup frames still left in statement_label.\n")); \ +  Pike_fatal("Cleanup frames still left in statement_label.\n")); \   } while (0)      struct switch_data   {    INT32 index;    INT32 less_label, greater_label, default_label;    INT32 values_on_stack;    INT32 *jumptable;    struct pike_type *type;   };
pike.git/src/docode.c:242:   int ins_label(int lbl)   {    if(lbl==-1) lbl=alloc_label();    low_insert_label(lbl);    return lbl;   }      void do_pop(int x)   {   #ifdef PIKE_DEBUG -  if (x < 0) fatal("Cannot do pop of %d args.\n", x); +  if (x < 0) Pike_fatal("Cannot do pop of %d args.\n", x);   #endif    switch(x)    {    case 0: return;    case 1: emit0(F_POP_VALUE); break;    default: emit1(F_POP_N_ELEMS,x); break;    }    current_stack_depth -= x;   }   
pike.git/src/docode.c:284:   #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 stack_depth_save = current_stack_depth;    int save_current_line=lex.current_line;    if(!n) return 0;    lex.current_line=n->line_number;   #ifdef PIKE_DEBUG -  if (current_stack_depth == -4711) fatal("do_docode() used outside docode().\n"); +  if (current_stack_depth == -4711) Pike_fatal("do_docode() used outside docode().\n");   #endif    i=do_docode2(check_node_hash(n), flags);    current_stack_depth = stack_depth_save + i;       lex.current_line=save_current_line;    return i;   }      static int is_efun(node *n, c_fun fun)   {
pike.git/src/docode.c:307:    n->u.sval.u.efun->function == fun;   }      static void code_expression(node *n, INT16 flags, char *err)   {    switch(do_docode(check_node_hash(n), (INT16)(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", +  Pike_fatal("Internal compiler error (%s), line %ld, file %s\n",    err,    (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))
pike.git/src/docode.c:667:    return 1;       case F_PUSH_ARRAY: {    if (current_label != &top_statement_label_dummy || current_label->cleanups) {    /* Might not have a surrounding apply node if evaluated as a    * constant by the optimizer. */   #ifdef PIKE_DEBUG    if (!current_label->cleanups ||    (current_label->cleanups->cleanup != do_pop_mark &&    current_label->cleanups->cleanup != do_pop_to_mark)) -  fatal("F_PUSH_ARRAY unexpected in this context.\n"); +  Pike_fatal("F_PUSH_ARRAY unexpected in this context.\n");   #endif    current_label->cleanups->cleanup = do_pop_to_mark;    }    code_expression(CAR(n), 0, "`@");    emit0(F_PUSH_ARRAY);    return 0;    }       case '?':    {
pike.git/src/docode.c:780:    case F_AND_EQ: opname="`&"; break;    case F_OR_EQ: opname="`|"; break;    case F_XOR_EQ: opname="`^"; break;    case F_LSH_EQ: opname="`<<"; break;    case F_RSH_EQ: opname="`>>"; break;    case F_SUB_EQ: opname="`-"; break;    case F_MULT_EQ:opname="`*"; break;    case F_MOD_EQ: opname="`%"; break;    case F_DIV_EQ: opname="`/"; break;    default: -  fatal("Really???\n"); +  Pike_fatal("Really???\n");    opname="`make gcc happy";    }       emit_builtin_svalue(opname);    emit2(F_REARRANGE,1,1);       if(CDR(n)->token == F_AUTO_MAP)    {    do_encode_automap_arg_list(CDR(n), 0);    }else{    code_expression(CDR(n), 0, "assignment");    }    emit_apply_builtin("__automap__");    }else{    tmp1=do_docode(CAR(n),DO_LVALUE);   #ifdef PIKE_DEBUG    if(tmp1 != 2) -  fatal("HELP! FATAL INTERNAL COMPILER ERROR (7)\n"); +  Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (7)\n");   #endif       if(n->token == F_ADD_EQ && (flags & DO_POP))    {    code_expression(CDR(n), 0, "assignment");    emit0(F_ADD_TO_AND_POP);    return 0;    }       if(CAR(n)->token != F_AUTO_MAP &&
pike.git/src/docode.c:888:    match_types(CDR(n)->type, object_type_string) ||    match_types(CDR(n)->type, multiset_type_string) ||    match_types(CDR(n)->type, mapping_type_string))    {    switch(do_docode(check_node_hash(CDAR(n)), 0))    {    case 1: emit0(F_LTOSVAL2); break;    case 2: emit0(F_LTOSVAL3); break;   #ifdef PIKE_DEBUG    default: -  fatal("Arglebargle glop-glyf?\n"); +  Pike_fatal("Arglebargle glop-glyf?\n");   #endif    }    }else{    emit0(F_LTOSVAL);    do_docode(check_node_hash(CDAR(n)), 0);    }       emit0(CAR(n)->token);       emit0(n->token);
pike.git/src/docode.c:989:    case F_DIVIDE:    case F_MOD:    case F_LSH:    case F_RSH:    case F_XOR:    case F_OR:    case F_AND:    case F_NOT:    case F_COMPL:    case F_NEGATE: -  fatal("Optimizer error.\n"); +  Pike_fatal("Optimizer error.\n");       case F_RANGE:    tmp1=do_docode(CAR(n),DO_NOT_COPY_TOPLEVEL);    if(do_docode(CDR(n),DO_NOT_COPY)!=2) -  fatal("Compiler internal error (at %ld).\n",(long)lex.current_line); +  Pike_fatal("Compiler internal error (at %ld).\n",(long)lex.current_line);    emit0(n->token);    return DO_NOT_WARN((INT32)tmp1);       case F_INC:    case F_POST_INC:    if(CAR(n)->token == F_AUTO_MAP_MARKER)    {    int depth=0;    int ret=0;    node *tmp=CAR(n);
pike.git/src/docode.c:1022:    if(n->token == F_POST_INC)    {    emit0(F_LTOSVAL);    emit2(F_REARRANGE,1,2);    ret++;    flags|=DO_POP;    }      #ifdef PIKE_DEBUG    if(tmp1 != 2) -  fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n"); +  Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");   #endif       emit0(F_MARK);    emit0(F_MARK);    emit0(F_LTOSVAL);    emit1(F_NUMBER, depth);    emit_apply_builtin("__builtin.automap_marker");    emit_builtin_svalue("`+");    emit2(F_REARRANGE,1,1);    emit1(F_NUMBER, 1);
pike.git/src/docode.c:1047:    emit0(F_ASSIGN_AND_POP);    }else{    emit0(F_ASSIGN);    ret++;    }    return ret;    }else{    tmp1=do_docode(CAR(n),DO_LVALUE);   #ifdef PIKE_DEBUG    if(tmp1 != 2) -  fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n"); +  Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");   #endif       if(flags & DO_POP)    {    emit0(F_INC_AND_POP);    return 0;    }else{    emit0(n->token);    return 1;    }
pike.git/src/docode.c:1084:    if(n->token == F_POST_DEC)    {    emit0(F_LTOSVAL);    emit2(F_REARRANGE,1,2);    ret++;    flags|=DO_POP;    }      #ifdef PIKE_DEBUG    if(tmp1 != 2) -  fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n"); +  Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");   #endif       emit0(F_MARK);    emit0(F_MARK);    emit0(F_LTOSVAL);    emit1(F_NUMBER, depth);    emit_apply_builtin("__builtin.automap_marker");    emit_builtin_svalue("`-");    emit2(F_REARRANGE,1,1);    emit1(F_NUMBER, 1);
pike.git/src/docode.c:1109:    emit0(F_ASSIGN_AND_POP);    }else{    emit0(F_ASSIGN);    ret++;    }    return ret;    }else{    tmp1=do_docode(CAR(n),DO_LVALUE);   #ifdef PIKE_DEBUG    if(tmp1 != 2) -  fatal("HELP! FATAL INTERNAL COMPILER ERROR (2)\n"); +  Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (2)\n");   #endif    if(flags & DO_POP)    {    emit0(F_DEC_AND_POP);    return 0;    }else{    emit0(n->token);    return 1;    }    }
pike.git/src/docode.c:1570:    INT32 e,cases,*order;    INT32 *jumptable;    struct switch_data prev_switch = current_switch;   #ifdef PIKE_DEBUG    struct svalue *save_sp=Pike_sp;   #endif    BLOCK_BEGIN;    PUSH_STATEMENT_LABEL;       if(do_docode(CAR(n),0)!=1) -  fatal("Internal compiler error, time to panic\n"); +  Pike_fatal("Internal compiler error, time to panic\n");       if (!(CAR(n) && (current_switch.type = CAR(n)->type))) {    current_switch.type = mixed_type_string;    }       current_label->break_label=alloc_label();       cases=count_cases(CDR(n));       tmp1=emit1(F_SWITCH,0);
pike.git/src/docode.c:1603:    {    jumptable[e] = DO_NOT_WARN((INT32)emit1(F_POINTER, 0));    current_switch.jumptable[e]=-1;    }    emit0(F_NOTREACHED);       DO_CODE_BLOCK(CDR(n));      #ifdef PIKE_DEBUG    if(Pike_sp-save_sp != cases) -  fatal("Count cases is wrong!\n"); +  Pike_fatal("Count cases is wrong!\n");   #endif       f_aggregate(cases);       /* FIXME: get_switch_order might possibly be able to    * throw errors, add a catch around this! -Hubbe    */    order=get_switch_order(Pike_sp[-1].u.array);       if (!Pike_compiler->num_parse_error) {
pike.git/src/docode.c:1672:    free((char *)current_switch.jumptable);       current_switch = prev_switch;       low_insert_label( current_label->break_label);       POP_STATEMENT_LABEL;    BLOCK_END;   #ifdef PIKE_DEBUG    if(Pike_interpreter.recoveries && Pike_sp-Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer) -  fatal("Stack error after F_SWITCH (underflow)\n"); +  Pike_fatal("Stack error after F_SWITCH (underflow)\n");   #endif    return 0;    }       case F_CASE:    case F_CASE_RANGE:    {    if(!current_switch.jumptable)    {    yyerror("Case outside switch.");
pike.git/src/docode.c:1908:    return 1;    }       case F_LVALUE_LIST:    return do_docode(CAR(n),DO_LVALUE)+do_docode(CDR(n),DO_LVALUE);       case F_ARRAY_LVALUE:    tmp1=do_docode(CAR(n),DO_LVALUE);   #ifdef PIKE_DEBUG    if(tmp1 & 1) -  fatal("Very internal compiler error.\n"); +  Pike_fatal("Very internal compiler error.\n");   #endif    emit1(F_ARRAY_LVALUE, DO_NOT_WARN((INT32)(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."); +  Pike_fatal("Bugg in F_ARROW, index not string.");    if(flags & WANT_LVALUE)    {    /* FIXME!!!! ??? I wonder what needs fixing... /Hubbe */    tmp1=do_docode(CAR(n), 0);    emit1(F_ARROW_STRING, store_prog_string(CDR(n)->u.sval.u.string));    return 2;    }else{    tmp1 = do_docode(CAR(n), DO_NOT_COPY);    if ((tmp2 = lfun_lookup_id(CDR(n)->u.sval.u.string)) != -1) {    emit1(F_LOOKUP_LFUN, tmp2);
pike.git/src/docode.c:1948:    case F_INDEX:    if(flags & WANT_LVALUE)    {    int mklval=CAR(n) && match_types(CAR(n)->type, string_type_string);    tmp1 = do_docode(CAR(n),    (INT16)(mklval ? DO_LVALUE_IF_POSSIBLE : 0));    if(tmp1==2)    {   #ifdef PIKE_DEBUG    if(!mklval) -  fatal("Unwanted lvalue!\n"); +  Pike_fatal("Unwanted lvalue!\n");   #endif    emit0(F_INDIRECT);    }       if(do_docode(CDR(n),0) != 1) -  fatal("Internal compiler error, please report this (1)."); +  Pike_fatal("Internal compiler error, please report this (1).");    if(CDR(n)->token != F_CONSTANT &&    match_types(CDR(n)->type, string_type_string))    emit0(F_CLEAR_STRING_SUBTYPE);    return 2;    }else{    tmp1=do_docode(CAR(n), DO_NOT_COPY);       code_expression(CDR(n), DO_NOT_COPY, "index");    if(CDR(n)->token != F_CONSTANT &&    match_types(CDR(n)->type, string_type_string))
pike.git/src/docode.c:2027:    emit2(F_EXTERNAL, n->u.sval.subtype, x);    Pike_compiler->new_program->flags |=    PROGRAM_USES_PARENT | PROGRAM_NEEDS_PARENT;    return 1;    }    }    /* FALL_THROUGH */   #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"); +  Pike_fatal("Internal error: Pointer to parent cannot be a compile time constant!\n");   #endif    /* FALL_THROUGH */    default:    tmp1=store_constant(&(n->u.sval),    !(n->tree_info & OPT_EXTERNAL_DEPEND),    n->name);    emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));    return 1;       case T_TYPE:
pike.git/src/docode.c:2159:    do_encode_automap_arg_list(CDR(n),0);    emit_apply_builtin("__automap__");    return 1;       case F_AUTO_MAP_MARKER:    yyerror("[*] not supported here.\n");    emit0(F_CONST0);    return 1;       default: -  fatal("Infernal compiler error (unknown parse-tree-token %d).\n", n->token); +  Pike_fatal("Infernal compiler error (unknown parse-tree-token %d).\n", n->token);    return 0; /* make gcc happy */    }   }      INT32 do_code_block(node *n)   {    INT32 ret;   #ifdef PIKE_DEBUG -  if (current_stack_depth != -4711) fatal("Reentrance in do_code_block().\n"); +  if (current_stack_depth != -4711) Pike_fatal("Reentrance in do_code_block().\n");    current_stack_depth = 0;   #endif       init_bytecode();    label_no=1;      #ifdef ALIGN_PIKE_FUNCTION_BEGINNINGS    while( ( (((INT32) PIKE_PC)+2) & (ALIGN_PIKE_JUMPS-1)))    ins_byte(0);   #endif