pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:5709:    unsigned function_flags,    union idptr *func,    unsigned opt_flags)   {    struct compilation *c = THIS_COMPILATION;    struct identifier *funp,fun;    struct reference ref;    struct svalue *lfun_type;    int run_time_type = T_FUNCTION;    INT32 i; -  INT16 *getter_setter = NULL; +  int getter_setter = -1; +  int is_setter = 0;       CHECK_COMPILER();      #ifdef PROGRAM_BUILD_DEBUG    {    struct pike_string *d = describe_type (type);    fprintf (stderr, "%.*sdefining function (pass=%d): %s ",    c->compilation_depth, "", Pike_compiler->compiler_pass, d->str);    free_string (d);    push_string (name);
pike.git/src/program.c:5763:    (index_shared_string(name, 1) == '-') &&    (index_shared_string(name, 2) == '>')) ||    ((name->len > 1) &&    (index_shared_string(name, 0) == '`') &&    ((index_shared_string(name, 1) >= 256) ||    isidchar(index_shared_string(name, 1))))) {    /* Getter setter. */    struct pike_string *symbol = NULL;    struct pike_type *symbol_type = NULL;    struct pike_type *gs_type = NULL; -  int is_setter = 0; +     int delta = 1; /* new-style */    if (index_shared_string(name, 1) == '-') {    /* Getter setter (old-style). */    delta = 3;    }    if (index_shared_string(name, name->len-1) != '=') {    /* fprintf(stderr, "Got getter: %s\n", name->str); */    gs_type = lfun_getter_type_string;    symbol = string_slice(name, delta, name->len-delta);    symbol_type = get_argument_type(type, -1);
pike.git/src/program.c:5813:    my_yyerror("Illegal to redefine function %S with variable.", symbol);    } else if (id->run_time_type != PIKE_T_GET_SET) {    my_yyerror("Illegal to redefine a current variable with a getter/setter: %S.", symbol);    } else {    if ((ref->id_flags | ID_USED) != (flags | ID_USED)) {    if (Pike_compiler->compiler_pass == 1) {    yywarning("Modifier mismatch for variable %S.", symbol);    }    ref->id_flags &= flags | ID_USED;    } -  getter_setter = &id->func.gs_info.getter + is_setter; +  getter_setter = i;    }    /* FIXME: Update id->type here. */    } else {    struct identifier *id;    i = low_define_variable(symbol, symbol_type, flags,    ~0, PIKE_T_GET_SET);    id = ID_FROM_INT(Pike_compiler->new_program, i);       /* Paranoia. */    id->func.gs_info.getter = -1;    id->func.gs_info.setter = -1;    -  getter_setter = &id->func.gs_info.getter + is_setter; +  getter_setter = i;    }    /* NOTE: The function needs to have the same PRIVATE/INLINE    * behaviour as the variable for overloading to behave    * as expected.    *    * FIXME: Force PRIVATE?    */    flags |= ID_PROTECTED /* | ID_PRIVATE | ID_INLINE | ID_USED */;    free_type(symbol_type);    free_string(symbol);
pike.git/src/program.c:5880:    function_flags |= IDENTIFIER_HAS_BODY;       if(!(ref.id_flags & ID_INHERITED)) /* not inherited */    {       if( !( IDENTIFIER_IS_FUNCTION(funp->identifier_flags) &&    ( (!func || func->offset == -1) || (funp->func.offset == -1))))    {    my_yyerror("Identifier %S defined twice.", name);    -  if (getter_setter) { -  *getter_setter = i; +  if (getter_setter != -1) { +  struct identifier *id = ID_FROM_INT(Pike_compiler->new_program, +  getter_setter); +  (&id->func.gs_info.getter)[is_setter] = i;    }    return i;    }       /* Note: The type from pass 1 may be incompatible with the one from    * pass 2. Only do this in pass 2, and only if the previous    * type isn't from pass 1.    */    if ((Pike_compiler->compiler_pass == 2) &&    (funp->run_time_type == T_FUNCTION)) {
pike.git/src/program.c:5996: Inside #if defined(PIKE_DEBUG)
   ref.inherit_offset, ref.identifier_offset,    ref.id_flags,    oref->inherit_offset,    oref->identifier_offset,    oref->id_flags,    overridden);    Pike_fatal("New function overloading algorithm failed!\n");    }   #endif    -  if (getter_setter) { -  INT32 old_i = *getter_setter; +  if (getter_setter != -1) { +  struct identifier *id = ID_FROM_INT(Pike_compiler->new_program, +  getter_setter); +  INT32 old_i = (&id->func.gs_info.getter)[is_setter];    if ((old_i >= 0) && (old_i != overridden)) {    my_yyerror("Multiple definitions for %S.", name);    } -  *getter_setter = overridden; +  (&id->func.gs_info.getter)[is_setter] = overridden;    }    return overridden;    }    /* NOTE: At this point we already have the identifier in the    * new program, and just need to add the reference.    */    } else {    make_a_new_def:      #ifdef PIKE_DEBUG
pike.git/src/program.c:6067:    /* Add the reference. */       i=Pike_compiler->new_program->num_identifier_references;    add_to_identifier_references(ref);      #ifdef PROGRAM_BUILD_DEBUG    fprintf(stderr, "%.*sadded new definition #%d\n",    c->compilation_depth, "", i);   #endif    -  if (getter_setter) { -  INT32 old_i = *getter_setter; +  if (getter_setter != -1) { +  struct identifier *id = ID_FROM_INT(Pike_compiler->new_program, +  getter_setter); +  INT32 old_i = (&id->func.gs_info.getter)[is_setter];    if (old_i >= 0) {    my_yyerror("Multiple definitions for %S.", name);    } -  *getter_setter = i; +  (&id->func.gs_info.getter)[is_setter] = i;    }       return i;   }      #if 0      int add_ext_ref(struct program_state *state, struct program *target, int i)   {    struct reference ref, *r;