pike.git/src/program.c:1724: Inside #if 0
Pike_compiler->new_program->identifiers[i].linenumber,
i);
}
}
add_to_identifiers (id);
}
#else
#define debug_add_to_identifiers(ARG) add_to_identifiers(ARG)
#endif
- static void add_identifier(struct compilation *c,
+ static int low_add_identifier(struct compilation *c,
struct pike_type *type,
struct pike_string *name,
unsigned int identifier_flags,
unsigned int opt_flags,
union idptr func,
int run_time_type)
{
struct identifier dummy;
-
+ int n = Pike_compiler->new_program->num_identifiers;
+
copy_shared_string(dummy.name, name);
copy_pike_type(dummy.type, type);
dummy.filename_strno = store_prog_string(c->lex.current_file);
dummy.linenumber = c->lex.current_line;
dummy.identifier_flags = identifier_flags;
dummy.run_time_type = run_time_type;
dummy.func = func;
dummy.opt_flags = opt_flags;
#ifdef PROFILING
dummy.self_time=0;
dummy.num_calls=0;
dummy.recur_depth=0;
dummy.total_time=0;
#endif
debug_add_to_identifiers(dummy);
-
+
+ return n;
}
-
+ static int add_identifier(struct compilation *c,
+ struct pike_type *type,
+ struct pike_string *name,
+ unsigned int modifier_flags,
+ unsigned int identifier_flags,
+ unsigned int opt_flags,
+ union idptr func,
+ int run_time_type)
+ {
+ struct reference ref;
+ struct identifier dummy;
+ int n;
+
+ if (modifier_flags & ID_PRIVATE) modifier_flags |= ID_LOCAL|ID_PROTECTED;
+
+ if (((identifier_flags & (IDENTIFIER_VARIABLE|IDENTIFIER_ALIAS)) ==
+ IDENTIFIER_VARIABLE) &&
+ (modifier_flags & ID_WEAK)) {
+ identifier_flags |= IDENTIFIER_WEAK;
+ }
+
+ ref.id_flags = modifier_flags;
+ ref.identifier_offset =
+ low_add_identifier(c, type, name,
+ identifier_flags, opt_flags,
+ func, run_time_type);
+ ref.inherit_offset = 0;
+ ref.run_time_type = PIKE_T_UNKNOWN;
+
+ if ((identifier_flags & (IDENTIFIER_VARIABLE|IDENTIFIER_ALIAS)) ==
+ IDENTIFIER_VARIABLE) {
+ add_to_variable_index(ref.identifier_offset);
+ }
+
+ n = Pike_compiler->new_program->num_identifier_references;
+ add_to_identifier_references(ref);
+
+ return n;
+ }
+
void add_relocated_int_to_program(INT32 i)
{
add_to_relocations(Pike_compiler->new_program->num_program);
ins_int(i, (void (*)(char))add_to_program);
}
void use_module(struct svalue *s)
{
struct compilation *c = THIS_COMPILATION;
if( (1<<TYPEOF(*s)) & (BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM))
pike.git/src/program.c:5496:
*/
int low_define_alias(struct pike_string *name, struct pike_type *type,
int flags, int depth, int refno)
{
int n;
int e;
struct compilation *c = THIS_COMPILATION;
struct program_state *state = Pike_compiler;
struct identifier *id;
- struct reference ref;
+
union idptr func;
#ifdef PIKE_DEBUG
if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED))
Pike_fatal("Attempting to add variable to fixed program\n");
if(Pike_compiler->compiler_pass==2)
Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"
"Added identifier: \"%s\"\n", name->str);
#endif
pike.git/src/program.c:5529:
}
#endif
id = ID_FROM_INT(state->new_program, refno);
func.ext_ref.depth = depth;
func.ext_ref.id = refno;
if (flags & ID_PRIVATE) flags |= ID_INLINE;
- ref.id_flags=flags;
- ref.identifier_offset=Pike_compiler->new_program->num_identifiers;
- ref.inherit_offset=0;
- ref.run_time_type = PIKE_T_UNKNOWN;
-
- add_identifier(c, type ? type : id->type, name ? name : id->name,
- id->identifier_flags | IDENTIFIER_ALIAS, 0,
+ return add_identifier(c, type ? type : id->type, name ? name : id->name,
+ flags, id->identifier_flags | IDENTIFIER_ALIAS, 0,
func, id->run_time_type);
-
- n = Pike_compiler->new_program->num_identifier_references;
- add_to_identifier_references(ref);
-
- return n;
+
}
PMOD_EXPORT int define_alias(struct pike_string *name, struct pike_type *type,
int flags, int depth, int refno)
{
/* FIXME: Support NULL name and type. */
int n = isidentifier(name);
if(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE)
{
pike.git/src/program.c:5630:
return low_define_alias(name, type, flags, depth, refno);
}
/* argument must be a shared string */
int low_define_variable(struct pike_string *name,
struct pike_type *type,
INT32 flags,
size_t offset,
INT32 run_time_type)
{
- int n;
-
+
struct compilation *c = THIS_COMPILATION;
- struct identifier dummy;
- struct reference ref;
+
union idptr func;
#ifdef PIKE_DEBUG
if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED))
Pike_fatal("Attempting to add variable to fixed program\n");
if(Pike_compiler->compiler_pass==2)
Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"
"Added identifier: \"%s\"\n", name->str);
#endif
func.offset = offset - Pike_compiler->new_program->inherits[0].storage_offset;
if (run_time_type == PIKE_T_FREE) func.offset = -1;
if (flags & ID_PRIVATE) flags |= ID_LOCAL|ID_PROTECTED;
- ref.id_flags=flags;
- ref.identifier_offset=Pike_compiler->new_program->num_identifiers;
- ref.inherit_offset=0;
- ref.run_time_type = PIKE_T_UNKNOWN;
-
- add_to_variable_index(ref.identifier_offset);
-
- if (flags & ID_WEAK) {
+ return
add_identifier(c, type, name,
- IDENTIFIER_VARIABLE|IDENTIFIER_WEAK, 0,
+ flags, IDENTIFIER_VARIABLE, 0,
func,
run_time_type);
- } else {
- add_identifier(c, type, name,
- IDENTIFIER_VARIABLE, 0,
- func,
- run_time_type);
+
}
- n=Pike_compiler->new_program->num_identifier_references;
- add_to_identifier_references(ref);
-
- return n;
- }
-
+
/* type is a serialized tokenized type. */
PMOD_EXPORT int quick_map_variable(const char *name,
int name_length,
size_t offset,
const char *type,
int UNUSED(type_length),
INT32 run_time_type,
INT32 flags)
{
int ret;
pike.git/src/program.c:6083: Inside #if 1
else {
copy_pike_type(type, mixed_type_string);
func.const_info.offset = -1;
opt_flags = 0;
}
#endif
if (flags & ID_PRIVATE) flags |= ID_LOCAL|ID_PROTECTED;
ref.id_flags=flags;
- ref.identifier_offset=Pike_compiler->new_program->num_identifiers;
+ ref.identifier_offset =
+ low_add_identifier(cc, type, name,
+ IDENTIFIER_CONSTANT, opt_flags,
+ func, c ? TYPEOF(*c) : T_MIXED);
ref.inherit_offset=0;
ref.run_time_type = PIKE_T_UNKNOWN;
- add_identifier(cc, type, name,
- IDENTIFIER_CONSTANT, opt_flags,
- func, c ? TYPEOF(*c) : T_MIXED);
+
free_pike_type(type);
if(n != -1)
{
int overridden;
if(IDENTIFIERP(n)->id_flags & ID_FINAL)
my_yyerror("Illegal to redefine 'final' identifier %S", name);
if(IDENTIFIER_IS_VARIABLE(ID_FROM_INT(Pike_compiler->new_program,
pike.git/src/program.c:6641: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%*saltering the existing definition\n",
c->compilation_depth, "");
#endif
if(func)
idptr = *func;
else
idptr.offset = -1;
- ref.identifier_offset = prog->num_identifiers;
-
- add_identifier(c, type, name,
+ ref.identifier_offset =
+ low_add_identifier(c, type, name,
function_flags, opt_flags,
idptr, run_time_type);
}
if (flags & ID_PRIVATE) flags |= ID_LOCAL|ID_PROTECTED;
ref.inherit_offset = 0;
ref.id_flags = flags;
if (flags & ID_VARIANT) {
ref.id_flags |= ID_USED;
pike.git/src/program.c:6718: Inside #if defined(PIKE_DEBUG)
if (a_flag > 5) {
fprintf(stderr,
"Adding new function #%d: '%s'\n"
" identifier_flags:0x%02x opt_flags:0x%04x\n",
prog->num_identifiers,
name->str,
function_flags, opt_flags);
}
#endif /* PIKE_DEBUG */
- i = prog->num_identifiers;
-
- add_identifier(c, type, name,
+ i = low_add_identifier(c, type, name,
function_flags, opt_flags,
idptr, run_time_type);
if (flags & ID_PRIVATE) flags |= ID_LOCAL|ID_PROTECTED;
ref.id_flags = flags;
ref.identifier_offset = i;
ref.inherit_offset = 0;
}