Branch: Tag:

1999-01-31

1999-01-31 09:03:50 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

lexical closures implemented...

Rev: src/ChangeLog:1.160
Rev: src/alloca.c:1.3
Rev: src/block_alloc.h:1.5
Rev: src/block_alloc_h.h:1.1
Rev: src/builtin_functions.c:1.146
Rev: src/callback.c:1.16
Rev: src/dmalloc.h:1.9
Rev: src/docode.c:1.43
Rev: src/error.c:1.23
Rev: src/error.h:1.27
Rev: src/interpret.c:1.113
Rev: src/interpret.h:1.26
Rev: src/language.yacc:1.109
Rev: src/las.c:1.73
Rev: src/las.h:1.18
Rev: src/lex.c:1.61
Rev: src/main.c:1.62
Rev: src/modules/call_out/call_out.c:1.24
Rev: src/object.c:1.55
Rev: src/peep.in:1.24
Rev: src/pike_memory.c:1.29
Rev: src/pike_memory.h:1.8
Rev: src/program.c:1.107
Rev: src/program.h:1.48
Rev: src/testsuite.in:1.142
Rev: src/threads.h:1.61

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: las.c,v 1.72 1999/01/29 12:29:02 hubbe Exp $"); + RCSID("$Id: las.c,v 1.73 1999/01/31 09:01:51 hubbe Exp $");      #include "language.h"   #include "interpret.h"
49:    {    case F_EXTERNAL:    case F_IDENTIFIER: +  case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL:    return 0;
64:    {    case F_EXTERNAL:    case F_IDENTIFIER: +  case F_TRAMPOLINE:    case F_CONSTANT:    case F_LOCAL:    case F_CAST:
503:    return mkefuncallnode(oper_id, arg1);   }    - node *mklocalnode(int var) + node *mklocalnode(int var, int depth)   { -  +  struct compiler_frame *f; +  int e;    node *res = mkemptynode();    res->token = F_LOCAL; -  copy_shared_string(res->type, compiler_frame->variable[var].type); +  +  f=compiler_frame; +  for(e=0;e<depth;e++) f=f->previous; +  copy_shared_string(res->type, f->variable[var].type); +     res->node_info = OPT_NOT_CONST;    res->tree_info=res->node_info;   #ifdef __CHECKER__    CDR(res)=0;   #endif -  res->u.number = var; +  res->u.integer.a = var; +  res->u.integer.b = depth;    return res;   }   
791:    switch(a->token)    {    case F_LOCAL: +  return a->u.integer.a == b->u.integer.b; +     case F_IDENTIFIER: -  +  case F_TRAMPOLINE: /* FIXME, the context has to be the same! */    return a->u.number == b->u.number;       case F_CAST:
902:    {    case F_LOCAL:    case F_IDENTIFIER: +  case F_TRAMPOLINE:    b=mkintnode(0);    *b=*n;    copy_shared_string(b->type, n->type);
1072:    {    case F_LOCAL:    if(needlval) putchar('&'); -  printf("$%ld",(long)foo->u.number); +  if(foo->u.integer.b) +  { +  printf("$<%ld>%ld",(long)foo->u.integer.b,(long)foo->u.integer.a); +  }else{ +  printf("$%ld",(long)foo->u.integer.a); +  }    break;       case '?':
1090:    printf("%s",ID_FROM_INT(new_program, foo->u.number)->name->str);    break;    +  case F_TRAMPOLINE: +  printf("trampoline<%s>",ID_FROM_INT(new_program, foo->u.number)->name->str); +  break; +     case F_ASSIGN:    low_print_tree(CDR(foo),1);    printf("=");
1229:    switch(n->token)    {    case F_LOCAL: -  q=p->locals+n->u.number; +  /* FIXME: handle local variable depth */ +  q=p->locals+n->u.integer.a;    goto set_pointer;       case F_IDENTIFIER:
1307:    switch(n->token)    {    case F_LOCAL: -  if(lvalue) p->locals[n->u.number]=VAR_USED; +  if(lvalue) p->locals[n->u.integer.a]=VAR_USED;    break;       case F_IDENTIFIER:
1569:    char *name;    switch(CAR(n)->token)    { + #if 0 /* FIXME */ +  case F_TRAMPOLINE; + #endif    case F_IDENTIFIER:    name=ID_FROM_INT(new_program, CAR(n)->u.number)->name->str;    break;
2334:    if(expected==-1) return -1;    return stupid_args(CDR(n), expected,vargs);    case F_LOCAL: -  return n->u.number==expected ? expected + 1 : -1; +  return (!n->u.integer.b && n->u.integer.a==expected) ? expected + 1 : -1;    default:    return -1;    }