Branch: Tag:

1997-06-27

1997-06-27 06:55:22 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

variables in parents now works correctly

Rev: lib/master.pike:1.43.2.3
Rev: lib/modules/Stack.pmod:1.2.2.1(DEAD)
Rev: src/ChangeLog:1.97.2.3
Rev: src/builtin_functions.c:1.36.2.2
Rev: src/builtin_functions.h:1.3.2.2
Rev: src/cpp.h:1.1.2.1
Rev: src/docode.c:1.16.2.2
Rev: src/error.c:1.6.2.1
Rev: src/gc.c:1.8.2.1
Rev: src/interpret.c:1.42.2.2
Rev: src/language.yacc:1.42.2.3
Rev: src/las.c:1.32.2.2
Rev: src/las.h:1.6.2.2
Rev: src/lex.c:1.21.2.3
Rev: src/main.c:1.21.2.2
Rev: src/object.c:1.17.2.3
Rev: src/object.h:1.9.2.3
Rev: src/program.c:1.33.2.3
Rev: src/program.h:1.14.2.3
Rev: src/svalue.c:1.12.2.2
Rev: src/testsuite.in:1.40.2.3

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: interpret.c,v 1.42.2.1 1997/06/25 22:46:37 hubbe Exp $"); + RCSID("$Id: interpret.c,v 1.42.2.2 1997/06/27 06:55:16 hubbe Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
479:      static void eval_instruction(unsigned char *pc)   { -  unsigned INT32 instr, prefix=0; +  unsigned INT32 accumulator=0, instr, prefix=0;    while(1)    {    fp->pc = pc;
560:    CASE(F_PREFIX_CHARX256);    prefix+=EXTRACT_UCHAR(pc++)<<8;    break; +  +  CASE(F_LDA); accumulator=GET_ARG(); break; +     /* Push number */    CASE(F_CONST0); push_int(0); break;    CASE(F_CONST1); push_int(1); break;
568:    CASE(F_NUMBER); push_int(GET_ARG()); break;    CASE(F_NEG_NUMBER); push_int(-GET_ARG()); break;    +     /* The rest of the basic 'push value' instructions */    CASE(F_STRING);    copy_shared_string(sp->u.string,fp->context.prog->strings[GET_ARG()]);
614:    print_return_value();    break;    +  CASE(F_EXTERNAL); +  { +  struct inherit *inherit; +  struct program *p; +  INT32 id=GET_ARG(); +  struct object *o=fp->context.parent; +  INT32 i=fp->context.parent_identifier;    -  +  while(1) +  { +  if(!o) +  error("Parent no longer exists\n"); +  +  if(!(p=o->prog)) +  error("Attempting to access variable in destructed object\n"); +  +  inherit=INHERIT_FROM_INT(p, i); +  +  if(!accumulator) break; +  --accumulator; +  +  if(p->identifier_references[id].inherit_offset==0) +  { +  i=o->parent_identifier; +  o=o->parent; +  }else{ +  i=inherit->parent_identifier; +  o=inherit->parent; +  } +  } +  +  low_object_index_no_free(sp, +  o, +  id + inherit->identifier_level); +  sp++; +  print_return_value(); +  break; +  } +  +  CASE(F_EXTERNAL_LVALUE); +  { +  struct inherit *inherit; +  struct program *p; +  INT32 id=GET_ARG(); +  struct object *o=fp->context.parent; +  INT32 i=fp->context.parent_identifier; +  +  while(1) +  { +  if(!o) +  error("Parent no longer exists\n"); +  +  if(!(p=o->prog)) +  error("Attempting to access variable in destructed object\n"); +  +  inherit=INHERIT_FROM_INT(p, i); +  +  if(!accumulator) break; +  accumulator--; +  +  if(p->identifier_references[id].inherit_offset==0) +  { +  i=o->parent_identifier; +  o=o->parent; +  }else{ +  i=inherit->parent_identifier; +  o=inherit->parent; +  } +  } +  +  ref_push_object(o); +  sp->type=T_LVALUE; +  sp->u.integer=id + inherit->identifier_level; +  sp++; +  break; +  } +     CASE(F_MARK_AND_LOCAL); *(mark_sp++)=sp;    CASE(F_LOCAL);    assign_svalue_no_free(sp++,fp->locals+GET_ARG());
1214:    new_frame.fun = -1;    new_frame.pc = 0;    new_frame.current_storage=o->storage; +  new_frame.context.parent=0;    fp = & new_frame;       new_frame.current_object->refs++;
1279:    new_frame.parent_frame = fp;    new_frame.current_object = o;    new_frame.context = p->inherits[ ref->inherit_offset ]; +  if(!ref->inherit_offset) new_frame.context.parent=o->parent; +     function = new_frame.context.prog->identifiers + ref->identifier_offset;       new_frame.locals = sp - args;
1289:       new_frame.current_object->refs++;    new_frame.context.prog->refs++; +  if(new_frame.context.parent) new_frame.context.parent->refs++;      #ifdef DEBUG    if(t_flag)
1354:    struct svalue *s=fp->context.prog->constants+function->func.offset;    if(s->type == T_PROGRAM)    { -  struct object *tmp=parent_clone_object(s->u.program,o,args); +  struct object *tmp=parent_clone_object(s->u.program, +  o, +  fun, +  args);    push_object(tmp);    }else{    error("Calling strange value!\n");
1424:    sp++;    }    +  if(new_frame.context.parent) free_object(new_frame.context.parent);    free_object(new_frame.current_object);    free_program(new_frame.context.prog);