Branch: Tag:

2003-08-03

2003-08-03 00:58:06 by Martin Stjernholm <mast@lysator.liu.se>

Fixed handling of IDREF_MAGIC_THIS.

Rev: src/docode.c:1.165
Rev: src/las.c:1.338

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.337 2003/07/30 18:44:38 mast Exp $ + || $Id: las.c,v 1.338 2003/08/03 00:58:06 mast Exp $   */      #include "global.h" - RCSID("$Id: las.c,v 1.337 2003/07/30 18:44:38 mast Exp $"); + RCSID("$Id: las.c,v 1.338 2003/08/03 00:58:06 mast Exp $");      #include "language.h"   #include "interpret.h"
130: 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)) {
1397:   {    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)    {
1418:    }else{    res->node_info = OPT_NOT_CONST;    } +  }    res->tree_info = res->node_info;      #ifdef __CHECKER__
1571:    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;    }
2516:    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;
3816:       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";
3850:    }    }    } +  }    break;       default: