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: docode.c,v 1.42 1998/11/22 11:02:41 hubbe Exp $"); + RCSID("$Id: docode.c,v 1.43 1999/01/31 09:01:44 hubbe Exp $");   #include "las.h"   #include "program.h"   #include "language.h"
191:    }   }    + static inline struct compiler_frame *find_local_frame(INT32 depth) + { +  struct compiler_frame *f=compiler_frame; +  while(--depth>=0) f=f->previous; +  return f; + } +    static int do_docode2(node *n,int flags)   {    INT32 tmp1,tmp2,tmp3;
393:    switch(CDR(n)->token)    {    case F_LOCAL: -  if(CDR(n)->u.number >= compiler_frame->max_number_of_locals) +  if(CDR(n)->u.integer.a >= +  find_local_frame(CDR(n)->u.integer.b)->max_number_of_locals)    yyerror("Illegal to use local variable here.");    -  +  if(CDR(n)->u.integer.b) goto normal_assign; +     code_expression(CAR(n), 0, "RHS");    emit(flags & DO_POP ? F_ASSIGN_LOCAL_AND_POP:F_ASSIGN_LOCAL, -  CDR(n)->u.number ); +  CDR(n)->u.integer.a );    break;       case F_IDENTIFIER:
413:    break;       default: +  normal_assign:    tmp1=do_docode(CDR(n),DO_LVALUE);    if(do_docode(CAR(n),0)!=1) yyerror("RHS is void!");    emit2(flags & DO_POP ? F_ASSIGN_AND_POP:F_ASSIGN);
1094:    }       case F_LOCAL: -  if(n->u.number >= compiler_frame->max_number_of_locals) +  if(n->u.integer.a >= +  find_local_frame(n->u.integer.b)->max_number_of_locals)    yyerror("Illegal to use local variable here."); -  +  +  if(n->u.integer.b) +  { +  emit(F_LDA,n->u.integer.b);    if(flags & WANT_LVALUE)    { -  +  emit(F_LEXICAL_LOCAL_LVALUE,n->u.number); +  return 2; +  }else{ +  emit(F_LEXICAL_LOCAL,n->u.number); +  return 1; +  } +  }else{ +  if(flags & WANT_LVALUE) +  {    emit(F_LOCAL_LVALUE,n->u.number);    return 2;    }else{    emit(F_LOCAL,n->u.number);    return 1;    } -  +  }    -  +  case F_TRAMPOLINE: +  emit(F_TRAMPOLINE,n->u.number); +  return 1; +     case F_IDENTIFIER:    if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, n->u.number)->identifier_flags))    {