diff --git a/.gitattributes b/.gitattributes index 108581d2e9b1c1c75c8e055aa581d2c06ef524d2..02f161ab2783307a55ace08e2e610dc5cc6638bc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -286,7 +286,6 @@ testfont binary /refdoc/structure/traditional.xml foreign_ident /src/aclocal.m4 foreign_ident /src/alloca.c foreign_ident -/src/apply_low.h foreign_ident /src/backend.h foreign_ident /src/bignum.h foreign_ident /src/block_alloc_h.h foreign_ident @@ -318,7 +317,6 @@ testfont binary /src/dynamic_load.c foreign_ident /src/dynamic_load.h foreign_ident /src/encode.h foreign_ident -/src/error.c foreign_ident /src/errors.h foreign_ident /src/export_list foreign_ident /src/facetgroup.cmod foreign_ident @@ -668,7 +666,6 @@ testfont binary /src/modules/system/system.h foreign_ident /src/modules/system/testsuite.in foreign_ident /src/multiset.h foreign_ident -/src/object.c foreign_ident /src/object.h foreign_ident /src/opcodes.c foreign_ident /src/opcodes.h foreign_ident diff --git a/src/apply_low.h b/src/apply_low.h index 0e3b2e31c236a275f90319d1badad21d331cb4fd..a78618a2912c4f337a597f28c77a0d0e28a55501 100644 --- a/src/apply_low.h +++ b/src/apply_low.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: apply_low.h,v 1.36 2009/06/06 13:13:46 grubba Exp $ +|| $Id$ */ { @@ -229,7 +229,7 @@ case IDENTIFIER_CONSTANT: { struct svalue *s=&(Pike_fp->context->prog-> - constants[function->func.offset].sval); + constants[function->func.const_info.offset].sval); debug_malloc_touch(Pike_fp); if(s->type == T_PROGRAM) { diff --git a/src/builtin.cmod b/src/builtin.cmod index bf0f62ede57f74fc844e14d1890ed2ca33aa817e..11a60ede82df3d71b96413e702555a66d0080e01 100644 --- a/src/builtin.cmod +++ b/src/builtin.cmod @@ -1191,8 +1191,8 @@ PIKEFUN string function_name(program|function func) id = ID_FROM_INT(p, e); if (IDENTIFIER_IS_CONSTANT(id->identifier_flags) && - (id->func.offset >= 0) && - is_eq( & PROG_FROM_INT(p, e)->constants[id->func.offset].sval, + (id->func.const_info.offset >= 0) && + is_eq( & PROG_FROM_INT(p, e)->constants[id->func.const_info.offset].sval, func)) REF_RETURN id->name; } diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 638789a64aa60930e2533d21649f9f8286780b1b..c5c74938d5658039bf735adfa4c5f11657da22c5 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -8995,8 +8995,8 @@ PMOD_EXPORT void f_function_defined(INT32 args) id->func.offset != -1) file = low_get_line(id_prog->program + id->func.offset, id_prog, &line); else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags) && - id->func.offset >= 0 && - (p2 = program_from_svalue (&id_prog->constants[id->func.offset].sval))) + id->func.const_info.offset >= 0 && + (p2 = program_from_svalue (&id_prog->constants[id->func.const_info.offset].sval))) file = low_get_program_line (p2, &line); else /* The program line is better than nothing for C functions. */ diff --git a/src/docode.c b/src/docode.c index bbc92a16868ed37b91d435b4c4ad22a3966230c3..2a18aaf5e2d85fc0a45ff6d5cc5ff976a651902a 100644 --- a/src/docode.c +++ b/src/docode.c @@ -929,14 +929,14 @@ static int do_docode2(node *n, int flags) } else if (level) { if (IDENTIFIER_IS_CONSTANT(id->identifier_flags) && (ref->id_flags & ID_INLINE) && !ref->inherit_offset && - (id->func.offset >= 0)) { + (id->func.const_info.offset >= 0)) { /* An inline, local or final constant identifier in * a lexically surrounding (aka parent) class. * Avoid vtable traversal during runtime by moving * the constant to this class. */ struct svalue *s = &state->new_program-> - constants[id->func.offset].sval; + constants[id->func.const_info.offset].sval; if (s->type == T_PROGRAM && s->u.program->flags & PROGRAM_USES_PARENT) { /* An external reference is required. */ @@ -959,18 +959,18 @@ static int do_docode2(node *n, int flags) emit1(F_LFUN, n->u.integer.b); } else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags) && (ref->id_flags & ID_INLINE) && !ref->inherit_offset && - (id->func.offset >= 0)) { + (id->func.const_info.offset >= 0)) { /* An inline, local or final constant identifier. * No need for vtable traversal during runtime. */ struct svalue *s = &state->new_program-> - constants[id->func.offset].sval; + constants[id->func.const_info.offset].sval; if (s->type == T_PROGRAM && s->u.program->flags & PROGRAM_USES_PARENT) { /* Program using parent. Convert to an LFUN. */ emit1(F_LFUN, n->u.integer.b); } else { - emit1(F_CONSTANT, id->func.offset); + emit1(F_CONSTANT, id->func.const_info.offset); } }else{ emit1(F_GLOBAL, n->u.integer.b); diff --git a/src/encode.c b/src/encode.c index ae66432b92e9f48d262944d8a131472193ba0bc4..5f86f7c5ff02efd4c4c5596e7a6804a2c3454f0c 100644 --- a/src/encode.c +++ b/src/encode.c @@ -1555,7 +1555,7 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc code_number(id->linenumber, data); /* offset */ - code_number(id->func.offset, data); + code_number(id->func.const_info.offset, data); /* run-time type */ code_number(id->run_time_type, data); @@ -4376,10 +4376,10 @@ static void decode_value2(struct decode_data *data) id.identifier_flags = IDENTIFIER_CONSTANT; /* offset */ - decode_number(id.func.offset, data); + decode_number(id.func.const_info.offset, data); /* FIXME: - * Verify validity of func.offset + * Verify validity of func.const_info.offset */ /* run_time_type */ diff --git a/src/error.c b/src/error.c index 3a9153286269c1961a2388164affeae47672010a..46b26667f301e31e93e279c8fa25cb9de7719ca4 100644 --- a/src/error.c +++ b/src/error.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: error.c,v 1.170 2010/09/27 17:06:17 grubba Exp $ +|| $Id$ */ #define NO_PIKE_SHORTHAND @@ -859,7 +859,7 @@ static void f_error__sprintf(INT32 args) SEE_PRIVATE); if (i != -1) push_svalue (&PROG_FROM_INT (p, i)-> - constants[ID_FROM_INT (p, i)->func.offset].sval); + constants[ID_FROM_INT (p, i)->func.const_info.offset].sval); else { ref_push_program (p); SAFE_APPLY_MASTER ("describe_program", 1); diff --git a/src/gc.c b/src/gc.c index e1dd8b4e5b0657caee806211ca59753bc8c6672f..ae17db38f38165c0558a95574b143dad5fe26287 100644 --- a/src/gc.c +++ b/src/gc.c @@ -1445,9 +1445,13 @@ again: else if (IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags)) fprintf (stderr, " pc: %"PRINTPTRDIFFT"d", id->func.offset); else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags)) { - fputs (" value: ", stderr); - safe_print_svalue_compact ( - stderr, &id_inh->prog->constants[id->func.offset].sval); + if (id->func.const_info.offset != -1) { + fputs (" value: ", stderr); + safe_print_svalue_compact ( + stderr, &id_inh->prog->constants[id->func.const_info.offset].sval); + } else { + fputs (" placeholder constant", stderr); + } } fputc ('\n', stderr); diff --git a/src/language.yacc b/src/language.yacc index 0e9767d72d8913764084be5bf6f185e486891d83..e2213ea3e14d8f8edf022b0dba9e6e93308547ea 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -2792,9 +2792,9 @@ class: TOK_CLASS line_number_info optional_identifier if(IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { struct svalue *s; - if ((id->func.offset >= 0) && + if ((id->func.const_info.offset >= 0) && ((s = &PROG_FROM_INT(Pike_compiler->new_program,i)-> - constants[id->func.offset].sval)->type == T_PROGRAM)) + constants[id->func.const_info.offset].sval)->type == T_PROGRAM)) { low_start_new_program(s->u.program, 2, $3->u.sval.u.string, diff --git a/src/las.c b/src/las.c index 2692b0f5aed85f98af5e54c17906f8e70b4df995..916ff79b2cf67a78faebf1dca151f0788cc0ec95 100644 --- a/src/las.c +++ b/src/las.c @@ -1188,8 +1188,8 @@ node *debug_mkexternalnode(struct program *parent_prog, int i) if (!(PTR_FROM_INT(parent_prog, i)->id_flags & ID_LOCAL)) { /* It's possible to overload the identifier. */ res->node_info = OPT_EXTERNAL_DEPEND; - } else { - struct svalue *s = &parent_prog->constants[id->func.offset].sval; + } else if (id->func.const_info.offset != -1) { + struct svalue *s = &parent_prog->constants[id->func.const_info.offset].sval; if ((s->type == T_PROGRAM) && (s->u.program->flags & PROGRAM_USES_PARENT)) { /* The constant program refers to its parent, so we need as well. */ @@ -1522,9 +1522,10 @@ void resolv_constant(node *n) } if(IDENTIFIER_IS_CONSTANT(i->identifier_flags)) { - if(i->func.offset != -1) + if(i->func.const_info.offset != -1) { - push_svalue(&PROG_FROM_INT(p, numid)->constants[i->func.offset].sval); + push_svalue(&PROG_FROM_INT(p, numid)-> + constants[i->func.const_info.offset].sval); }else{ if(Pike_compiler->compiler_pass!=1) yyerror("Constant is not defined yet."); diff --git a/src/object.c b/src/object.c index 58d492121bc9f4f8ba9a9017c27ec56825947416..f0ad18086c3e44a86447b768586f4600853dd4fc 100644 --- a/src/object.c +++ b/src/object.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: object.c,v 1.311 2010/07/28 22:50:59 mast Exp $ +|| $Id$ */ #include "global.h" @@ -1184,9 +1184,9 @@ PMOD_EXPORT void low_object_index_no_free(struct svalue *to, case IDENTIFIER_CONSTANT: { - if (i->func.offset >= 0) { + if (i->func.const_info.offset >= 0) { struct svalue *s; - s=& PROG_FROM_INT(p,f)->constants[i->func.offset].sval; + s=& PROG_FROM_INT(p,f)->constants[i->func.const_info.offset].sval; if(s->type==T_PROGRAM && (s->u.program->flags & PROGRAM_USES_PARENT)) { diff --git a/src/program.c b/src/program.c index 94a75cb26ffeb28ac3e412594b53902dd169d43e..1d95e4a5ca2671774c8872e1b53f0175a494f3d3 100644 --- a/src/program.c +++ b/src/program.c @@ -3124,7 +3124,7 @@ void dump_program_tables (const struct program *p, int indent) indent, "", id->func.ext_ref.depth, id->func.ext_ref.id); } else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { fprintf (stderr, "%*s Constant #%ld\n", - indent, "", (long)id->func.offset); + indent, "", (long)id->func.const_info.offset); } else if (IDENTIFIER_IS_VARIABLE(id->identifier_flags)) { fprintf (stderr, "%*s Offset: 0x%08lx\n", indent, "", (long)id->func.offset); @@ -4665,10 +4665,10 @@ void compiler_do_inherit(node *n, if(numid != IDREF_MAGIC_THIS && (IDENTIFIER_IS_CONSTANT((i=ID_FROM_INT(p, numid))-> identifier_flags)) && - (i->func.offset != -1)) + (i->func.const_info.offset != -1)) { struct svalue *s=&PROG_FROM_INT(p, numid)-> - constants[i->func.offset].sval; + constants[i->func.const_info.offset].sval; if(s->type != T_PROGRAM) { do_inherit(s,flags,name); @@ -5293,9 +5293,9 @@ PMOD_EXPORT int add_constant(struct pike_string *name, /* Alias for a symbol in the current or surrounding programs. */ if(IDENTIFIER_IS_CONSTANT(id->identifier_flags) && - (id->func.offset != -1) && + (id->func.const_info.offset != -1) && (state == Pike_compiler)) { - c=& p->constants[id->func.offset].sval; + c=& p->constants[id->func.const_info.offset].sval; } else if (IDENTIFIER_IS_VARIABLE(id->identifier_flags) && (state == Pike_compiler)) { my_yyerror("Attempt to make a constant %S of a variable.", @@ -5335,13 +5335,13 @@ PMOD_EXPORT int add_constant(struct pike_string *name, }else{ struct identifier *id; id=ID_FROM_INT(Pike_compiler->new_program,n); - if(id->func.offset>=0) { + if(id->func.const_info.offset>=0) { /* Update the stored constant. */ assign_svalue (&PROG_FROM_INT(Pike_compiler->new_program,n)-> - constants[id->func.offset].sval, c); + constants[id->func.const_info.offset].sval, c); } else { id->run_time_type = (unsigned char) c->type; - id->func.offset = store_constant(c, 0, 0); + id->func.const_info.offset = store_constant(c, 0, 0); } free_type(id->type); if ((c->type == T_INT) && !(flags & ID_INLINE)) { @@ -5356,7 +5356,7 @@ PMOD_EXPORT int add_constant(struct pike_string *name, #ifdef PROGRAM_BUILD_DEBUG fprintf (stderr, "%.*sstored constant #%d at %d\n", cc->compilation_depth, "", - n, id->func.offset); + n, id->func.const_info.offset); #endif } return n; @@ -5392,7 +5392,7 @@ PMOD_EXPORT int add_constant(struct pike_string *name, dummy.type = get_type_of_svalue(c); } dummy.run_time_type = (unsigned char) c->type; - dummy.func.offset=store_constant(c, 0, 0); + dummy.func.const_info.offset = store_constant(c, 0, 0); dummy.opt_flags=OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND; if(c->type == PIKE_T_PROGRAM && (c->u.program->flags & PROGRAM_CONSTANT)) dummy.opt_flags=0; @@ -5401,7 +5401,7 @@ PMOD_EXPORT int add_constant(struct pike_string *name, else { copy_pike_type(dummy.type, mixed_type_string); dummy.run_time_type=T_MIXED; - dummy.func.offset=-1; + dummy.func.const_info.offset = -1; dummy.opt_flags=0; } #endif @@ -6401,9 +6401,9 @@ struct array *program_indices(struct program *p) */ continue; } else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { - if (id->func.offset >= 0) { + if (id->func.const_info.offset >= 0) { struct program *p2 = PROG_FROM_INT(p, e); - struct svalue *val = &p2->constants[id->func.offset].sval; + struct svalue *val = &p2->constants[id->func.const_info.offset].sval; if ((val->type != T_PROGRAM) || !(val->u.program->flags & PROGRAM_USES_PARENT)) { ref_push_string(ID_FROM_INT(p, e)->name); @@ -6440,9 +6440,9 @@ struct array *program_values(struct program *p) */ continue; } else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { - if (id->func.offset >= 0) { + if (id->func.const_info.offset >= 0) { struct program *p2 = PROG_FROM_INT(p, e); - struct svalue *val = &p2->constants[id->func.offset].sval; + struct svalue *val = &p2->constants[id->func.const_info.offset].sval; if ((val->type != T_PROGRAM) || !(val->u.program->flags & PROGRAM_USES_PARENT)) { push_svalue(val); @@ -6512,9 +6512,9 @@ int low_program_index_no_free(struct svalue *to, struct program *p, int e, } if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { - if (id->func.offset >= 0) { + if (id->func.const_info.offset >= 0) { struct program *p2 = PROG_FROM_INT(p, e); - struct svalue *val = &p2->constants[id->func.offset].sval; + struct svalue *val = &p2->constants[id->func.const_info.offset].sval; assign_svalue_no_free(to, val); } else { /* Prototype constant. */ @@ -6549,8 +6549,9 @@ int program_index_no_free(struct svalue *to, struct svalue *what, ((parent = what->u.object)->prog) && IDENTIFIER_IS_CONSTANT((id = ID_FROM_INT(parent->prog, what->subtype))->identifier_flags) && - (id->func.offset != -1) && - ((sub = &PROG_FROM_INT(parent->prog, what->subtype)->constants[id->func.offset].sval)->type == T_PROGRAM)) { + (id->func.const_info.offset != -1) && + ((sub = &PROG_FROM_INT(parent->prog, what->subtype)-> + constants[id->func.const_info.offset].sval)->type == T_PROGRAM)) { p = sub->u.program; parent_identifier = what->subtype; } else { @@ -10653,8 +10654,8 @@ struct program *low_program_from_function(struct object *o, INT32 i) o = loc.o; } if(!IDENTIFIER_IS_CONSTANT(id->identifier_flags)) return 0; - if(id->func.offset==-1) return 0; - f = &PROG_FROM_INT(p,i)->constants[id->func.offset].sval; + if(id->func.const_info.offset==-1) return 0; + f = &PROG_FROM_INT(p,i)->constants[id->func.const_info.offset].sval; if(f->type!=T_PROGRAM) return 0; return f->u.program; } diff --git a/src/program.h b/src/program.h index 77f0d0f4a369685eb0a52149ee3c299dc1ebc62f..b5fc9d8ca4c3b84b77005b6c12045d732c1ece05 100644 --- a/src/program.h +++ b/src/program.h @@ -208,6 +208,16 @@ union idptr unsigned short id; /* Reference number. */ } ext_ref; + /* Constant. (IDENTIFIER_CONSTANT) + * + * Offset of the struct program_constant in program.constants + * in the program pointed to by prog in the struct inherit + * that corresponds to the identifier. + */ + struct { + ptrdiff_t offset; /* Offset in the constants table. */ + } const_info; + /* Getter/setter reference pair. (IDENTIFIER_VARIABLE && PIKE_T_GET_SET) */ struct { @@ -224,10 +234,6 @@ union idptr * variable may be either a normal or a short svalue, depending on * identifier.run_time_type. (IDENTIFIER_VARIABLE) * - * For constants: Offset of the struct program_constant in - * program.constants in the program pointed to by prog in the struct - * inherit that corresponds to the identifier. (IDENTIFIER_CONSTANT) - * * For pike functions: Offset to the start of the function in * program.program in the program pointed to by prog in the struct * inherit that corresponds to the identifier. Or -1 if a prototype. @@ -381,7 +387,7 @@ struct inherit * until one is found with an inherit_level less than this one. */ INT16 inherit_level; - /* All the identifier references in the inherited program has been + /* All the identifier references in the inherited program have been * copied to this program with the first one at this offset. */ INT16 identifier_level;