pike.git / src / program.c

version» Context lines:

pike.git/src/program.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. - || $Id: program.c,v 1.518 2003/08/20 19:40:09 mast Exp $ + || $Id: program.c,v 1.519 2003/08/20 21:42:35 grubba Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.518 2003/08/20 19:40:09 mast Exp $"); + RCSID("$Id: program.c,v 1.519 2003/08/20 21:42:35 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "language.h"   #include "lex.h"   #include "pike_macros.h"   #include "fsort.h"
pike.git/src/program.c:3615:    yyerror("Failed to resolv external constant.\n");    return;    }    p = state->new_program;    numid = n->u.integer.b;    }       continue_inherit:       if(numid != IDREF_MAGIC_THIS && -  (i=ID_FROM_INT(p, numid), IDENTIFIER_IS_CONSTANT(i->identifier_flags))) +  (IDENTIFIER_IS_CONSTANT((i=ID_FROM_INT(p, numid))-> +  identifier_flags)) && +  (i->func.offset != -1))    {    struct svalue *s=&PROG_FROM_INT(p, numid)->    constants[i->func.offset].sval;    if(s->type != T_PROGRAM)    {    do_inherit(s,flags,name);    return;    }else{    low_inherit(s->u.program,    0,
pike.git/src/program.c:4022: Inside #if defined(PROGRAM_BUILD_DEBUG)
   fprintf (stderr, "%.*sdeclaring constant (pass=%d): ",    compilation_depth, " ",    Pike_compiler->compiler_pass);    push_string (name);    print_svalue (stderr, --Pike_sp);    }    putc ('\n', stderr);    }   #endif    + #if 0    if (!c) {    zero.type = T_INT;    zero.subtype = 0;    zero.u.integer = 0;    c = &zero;    } -  + #endif      #ifdef PIKE_DEBUG    if(name!=debug_findstring(name))    Pike_fatal("define_constant on nonshared string.\n");   #endif       do { -  if(/* c && */ +  if( + #if 1 +  c && + #endif    c->type == T_FUNCTION &&    c->subtype != FUNCTION_BUILTIN &&    c->u.object->prog)    {    struct reference *idref = PTR_FROM_INT(c->u.object->prog, c->subtype);    struct program *p = PROG_FROM_PTR(c->u.object->prog, idref);    struct identifier *id = p->identifiers + idref->identifier_offset;    if(c->u.object->prog == Pike_compiler->new_program) {    if(IDENTIFIER_IS_CONSTANT(id->identifier_flags) &&    id->func.offset != -1)
pike.git/src/program.c:4063:    id->type,    flags,    id->identifier_flags | IDENTIFIER_ALIAS,    & id->func,    id->opt_flags);       }    }    }    -  if(/* c && */ !svalues_are_constant(c,1,BIT_MIXED,0)) +  if( + #if 1 +  c && + #endif +  !svalues_are_constant(c,1,BIT_MIXED,0))    yyerror("Constant values may not have references to this.");       }while(0);       n = isidentifier(name);       if(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE)    { -  if(n==-1) +  if(n==-1 + #if 1 +  || !c + #endif +  )    {    yyerror("Pass2: Constant disappeared!");    }else{    struct identifier *id;    id=ID_FROM_INT(Pike_compiler->new_program,n);    if(id->func.offset>=0)    {    struct pike_type *s;    /* I don't know why this function preferred to retain the    * previously stored constant rather than using the one we get
pike.git/src/program.c:4097:    constants[id->func.offset].sval;   #else    assign_svalue (&PROG_FROM_INT(Pike_compiler->new_program,n)->    constants[id->func.offset].sval, c);   #endif    s=get_type_of_svalue(c);    free_type(id->type);    id->type=s;    }    else { - #if 0 + #if 1   #ifdef PIKE_DEBUG    if (!c) Pike_fatal("Can't declare constant during second compiler pass\n");   #endif   #endif    free_type(id->type);    id->type = get_type_of_svalue(c);    id->run_time_type = c->type;    id->func.offset = store_constant(c, 0, 0);    }   #ifdef PROGRAM_BUILD_DEBUG
pike.git/src/program.c:4127: Inside #if defined(PIKE_DEBUG)
   if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED))    Pike_fatal("Attempting to add constant to fixed program\n");       if(Pike_compiler->compiler_pass==2)    Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n");   #endif       copy_shared_string(dummy.name, name);    dummy.identifier_flags = IDENTIFIER_CONSTANT;    - #if 0 + #if 1    if (c) {   #endif    dummy.type = get_type_of_svalue(c);    dummy.run_time_type=c->type;    dummy.func.offset=store_constant(c, 0, 0);    dummy.opt_flags=OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND;    if(c->type == PIKE_T_PROGRAM && (c->u.program->flags & PROGRAM_CONSTANT))    dummy.opt_flags=0; - #if 0 + #if 1    }    else {    copy_pike_type(dummy.type, mixed_type_string);    dummy.run_time_type=T_MIXED;    dummy.func.offset=-1;    dummy.opt_flags=0;    }   #endif       ref.id_flags=flags;
pike.git/src/program.c:4925:    int e;    int n = 0;    struct array *res;    for (e = p->num_identifier_references; e--; ) {    struct identifier *id;    if (p->identifier_references[e].id_flags & ID_HIDDEN) {    continue;    }    id = ID_FROM_INT(p, e);    if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { +  if (id->func.offset >= 0) {    struct program *p2 = PROG_FROM_INT(p, e);    struct svalue *val = &p2->constants[id->func.offset].sval;    if ((val->type != T_PROGRAM) ||    !(val->u.program->flags & PROGRAM_USES_PARENT)) {    ref_push_string(ID_FROM_INT(p, e)->name);    n++;    } -  +  } else { +  /* Prototype constant. */ +  ref_push_string(ID_FROM_INT(p, e)->name); +  n++;    }    } -  +  }    f_aggregate(n);    res = Pike_sp[-1].u.array;    add_ref(res);    pop_stack();    return(res);   }      struct array *program_values(struct program *p)   {    int e;    int n = 0;    struct array *res;    for(e = p->num_identifier_references; e--; ) {    struct identifier *id;    if (p->identifier_references[e].id_flags & ID_HIDDEN) {    continue;    }    id = ID_FROM_INT(p, e);    if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { -  +  if (id->func.offset >= 0) {    struct program *p2 = PROG_FROM_INT(p, e);    struct svalue *val = &p2->constants[id->func.offset].sval;    if ((val->type != T_PROGRAM) ||    !(val->u.program->flags & PROGRAM_USES_PARENT)) {    push_svalue(val);    n++;    } -  +  } else { +  /* Prototype constant. */ +  push_int(0); +  n++;    }    } -  +  }    f_aggregate(n);    res = Pike_sp[-1].u.array;    add_ref(res);    pop_stack();    return(res);   }      void program_index_no_free(struct svalue *to, struct program *p,    struct svalue *ind)   {
pike.git/src/program.c:4986:    Pike_error("Can't index a program with a %s (expected string)\n",    get_name_of_type(ind->type));    }    s = ind->u.string;    e=find_shared_string_identifier(s, p);    if(e!=-1)    {    struct identifier *id;    id=ID_FROM_INT(p, e);    if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { +  if (id->func.offset >= 0) {    struct program *p2 = PROG_FROM_INT(p, e);    struct svalue *val = &p2->constants[id->func.offset].sval;    assign_svalue_no_free(to, val); -  +  } else { +  /* Prototype constant. */ +  to->type = T_INT; +  to->subtype = 0; +  to->u.integer = 0; +  }    return;    }    }       to->type=T_INT;    to->subtype=NUMBER_UNDEFINED;    to->u.integer=0;   }      /*