Branch: Tag:

2003-08-18

2003-08-18 15:11:38 by Martin Stjernholm <mast@lysator.liu.se>

Backported an important fix from 7.5, along with testsuite cases:
Reworked the Foo::this implementation to work correctly with parent
pointers through inherits etc. It's now done through a special
identifier reference integer IDREF_MAGIC_THIS.

Rev: bin/mktestsuite:1.22
Rev: src/builtin_functions.c:1.461
Rev: src/docode.c:1.162
Rev: src/interpret.c:1.293
Rev: src/interpret_functions.h:1.125
Rev: src/las.c:1.321
Rev: src/object.c:1.220
Rev: src/program.c:1.474
Rev: src/program.h:1.176
Rev: src/testsuite.in:1.589

2:   || 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: las.c,v 1.320 2003/07/30 18:44:38 mast Exp $ + || $Id: las.c,v 1.321 2003/08/18 15:11:38 mast Exp $   */      #include "global.h" - RCSID("$Id: las.c,v 1.320 2003/07/30 18:44:38 mast Exp $"); + RCSID("$Id: las.c,v 1.321 2003/08/18 15:11:38 mast Exp $");      #include "language.h"   #include "interpret.h"
125: Inside #if defined(PIKE_DEBUG)
   while (state && (state->new_program->id != parent_id)) {    state = state->previous;    } -  if (state) { +  if (state && id_no != IDREF_MAGIC_THIS) {    struct identifier *id = ID_FROM_INT(state->new_program, id_no);    if (id) {   #if 0
998:    }    break;    case F_EXTERNAL: -  { +  if (a->u.integer.b != IDREF_MAGIC_THIS) {    struct program_state *state = Pike_compiler;    int program_id = a->u.integer.a;    while (state && (state->new_program->id != program_id)) {
1396:   {    struct program_state *state;    node *res = mkemptynode(); -  struct identifier *id; +     res->token = F_EXTERNAL;    -  id = ID_FROM_INT(parent_prog, i); +  if (i == IDREF_MAGIC_THIS) { +  type_stack_mark(); +  push_object_type (0, parent_prog->id); +  res->type = pop_unfinished_type(); +  res->node_info = OPT_NOT_CONST; +  } +  +  else { +  struct identifier *id = ID_FROM_INT(parent_prog, i);   #ifdef PIKE_DEBUG    if(d_flag)    {
1417:    }else{    res->node_info = OPT_NOT_CONST;    } +  }    res->tree_info = res->node_info;      #ifdef __CHECKER__
1570:    return;       case F_EXTERNAL: -  { -  struct program_state *state = Pike_compiler; +  if (n->u.integer.b == IDREF_MAGIC_THIS) { +  yyerror ("Expected constant, got reference to this"); +  push_int (0); +  return; +  }    -  +  else { +  struct program_state *state = Pike_compiler;    while (state && (state->new_program->id != n->u.integer.a)) {    state = state->previous;    }
2489:    char *name = "?";    int program_id = foo->u.integer.a;    int level = 0; +  int id_no = foo->u.integer.b;    while(state && (state->new_program->id != program_id)) {    state = state->previous;    level++;    } -  if (state) { -  int id_no = foo->u.integer.b; +  if (id_no == IDREF_MAGIC_THIS) +  name = "this"; +  else if (state) {    struct identifier *id = ID_FROM_INT(state->new_program, id_no);    if (id && id->name) {    name = id->name->str;
3732:       case F_EXTERNAL:    { -  int program_id = CAR(n)->u.integer.a; +     int id_no = CAR(n)->u.integer.b; -  +  +  if (id_no == IDREF_MAGIC_THIS) +  name = "this"; /* Should perhaps qualify it. */ +  +  else { +  int program_id = CAR(n)->u.integer.a;    struct program_state *state = Pike_compiler;       name="external symbol";
3766:    }    }    } +  }    break;       default: