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: program.c,v 1.106 1999/01/21 09:15:14 hubbe Exp $"); + RCSID("$Id: program.c,v 1.107 1999/01/31 09:02:00 hubbe Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
606:    init_node=0;    num_parse_error=0;    -  push_compiler_frame(); +  push_compiler_frame(0);      #ifdef PIKE_DEBUG    if(lex.current_file)
2406:   }   #endif    + struct program *pike_trampoline_program=0; +  + static void apply_trampoline(INT32 args) + { +  error("Internal error: Trampoline magic failed!\n"); + } +  + void init_program(void) + { +  start_new_program(); +  add_storage(sizeof(struct pike_trampoline)); +  add_function("`()",apply_trampoline,"function(mixed...:mixed)",0); +  pike_trampoline_program=end_program(); + } +    void cleanup_program(void)   {    int e;
2424:    free_mapping(resolve_cache);    resolve_cache=0;    } +  +  if(pike_trampoline_program) +  { +  free_program(pike_trampoline_program); +  pike_trampoline_program=0;    } -  + }      #ifdef GC2   
2544:    *size_=size;   }    - void push_compiler_frame(void) + void push_compiler_frame(int lexical_scope)   {    struct compiler_frame *f;    f=ALLOC_STRUCT(compiler_frame); -  +  f->lexical_scope=lexical_scope;    f->current_type=0;    f->current_return_type=0;    f->current_number_of_locals=0;
2792:    return implements_cache[hval].ret;   }    - #if 0 - void f_encode_program(INT32 args) - { -  check_stack(20); -  f_version(); -  push_int(p->flags); -  push_int(p->storage_needed); -  if(p->init || p->exit || p->gc_marked || p->gc_check) -  error("Cannot encode C programs.\n"); -  push_int(total_size); -  push_string(make_shared_binary_string(p->program, p->num_program)); -  push_string(make_shared_binary_string(p->linenumbers, p->num_linenumbers)); -  push_string(make_shared_binary_string((char *)p->identifier_index, p->num_identifier_index * sizeof(unsigned short*))); -  push_string(make_shared_binary_string((char *)p->variable_index, p->num_variable_index * sizeof(unsigned short*))); -  push_string(make_shared_binary_string((char *)p->identifier_references, p->num_identifier_references * sizeof(struct reference))); -  check_stack(p->num_strings); -  for(e=0;e<p->num_strings;e++) ref_push_string(p->strings[e]); -  f_aggregate(p->num_strings); +     -  check_stack(p->num_inherits * 2); -  for(e=1;e<p->num_strings;e++) -  { -  ref_push_string(p->inherits[e].name); -  } +     -  f_aggregate(p->num_inherits); +     -  check_stack(NUM_LFUNS); -  for(e=0;e<NUM_LFUNS;e++) push_int(p->lfuns[e]); -  -  UNSET_ONERROR(tmp); -  -  free_mapping(data->encoded); -  pop_n_elems(args); -  push_string(low_free_buf(&data->buf)); - } -  - #endif +