diff --git a/lib/master.pike.in b/lib/master.pike.in index f05c9cc7e0d3c2cdf40bab222ee4ea8eda49b630..8ae2488bf7f9570d44b51bc466c212a7272ef3e8 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -5471,7 +5471,7 @@ class Encoder array parent_object = ({0}); string|array parent_name = nameof (parent, parent_object); - if (!parent_name) { + if (!parent_name || (parent_name == "o")) { ENC_MSG (" inside the thing to encode - encoding recursively\n"); return UNDEFINED; } diff --git a/src/encode.c b/src/encode.c index 488b0c494a9fd429e69459f9319f9275a6a9aac8..2a0e3465ad872ab68ed1cd9a277a12a3363fc513 100644 --- a/src/encode.c +++ b/src/encode.c @@ -1063,35 +1063,51 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc pop_stack(); if( (p->flags & PROGRAM_HAS_C_METHODS) || p->event_handler ) { - if(p->parent) - { - /* We have to remove ourselves from the cache for now */ - struct svalue tmp = entry_id; - map_delete(data->encoded, val); - - code_entry(TAG_PROGRAM, 2, data); - ref_push_program(p->parent); - encode_value2(Pike_sp-1, data, 0); + int has_local_c_methods = 0; + for (d = 0; d < p->num_identifiers; d++) { + if (IDENTIFIER_IS_C_FUNCTION(p->identifiers[d].identifier_flags)) { + has_local_c_methods = 1; + break; + } + } + if (has_local_c_methods) { + if(p->parent) + { + /* We have to remove ourselves from the cache for now */ + struct svalue tmp = entry_id; + EDB(1, fprintf(stderr, + "%*sencode: encoding C program via parent.\n", + data->depth, "")); + map_delete(data->encoded, val); + + code_entry(TAG_PROGRAM, 2, data); + ref_push_program(p->parent); + encode_value2(Pike_sp-1, data, 0); - ref_push_program(p); - f_function_name(1); + ref_push_program(p); + f_function_name(1); #if 0 - if(TYPEOF(Pike_sp[-1]) == PIKE_T_INT) - Pike_error("Cannot encode C programs.\n"); + if(TYPEOF(Pike_sp[-1]) == PIKE_T_INT) + Pike_error("Cannot encode C programs.\n"); #endif - encode_value2(Pike_sp-1, data, 0); + encode_value2(Pike_sp-1, data, 0); - pop_n_elems(2); + pop_n_elems(2); - /* Put value back in cache */ - mapping_insert(data->encoded, val, &tmp); - goto encode_done; - } - if( p->event_handler ) - Pike_error("Cannot encode programs with event handlers.\n"); + /* Put value back in cache */ + mapping_insert(data->encoded, val, &tmp); + goto encode_done; + } + if( p->event_handler ) + Pike_error("Cannot encode programs with event handlers.\n"); #if 0 - Pike_error("Cannot encode C programs.\n"); + Pike_error("Cannot encode C programs.\n"); #endif + } else { + EDB(1, fprintf(stderr, + "%*sencode: encoding program overloading a C program.\n", + data->depth, "")); + } } #ifdef OLD_PIKE_ENCODE_PROGRAM @@ -1888,9 +1904,17 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc struct svalue str_sval; SET_SVAL(str_sval, T_STRING, 0, string, NULL); + EDB(2, + fprintf(stderr, "%*sencode: encoding constants\n", + data->depth, "")); + /* constants */ for(d=0;d<p->num_constants;d++) { + EDB(5, + fprintf(stderr, "%*sencode: encoding constant #%d\n", + data->depth, "", d)); + #ifdef PIKE_PORTABLE_BYTECODE if (((TYPEOF(p->constants[d].sval) == T_FUNCTION) && (SUBTYPEOF(p->constants[d].sval) == FUNCTION_BUILTIN)) ||