pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:1657:
PIKE_CONCAT(low_add_to_,NAME) ( Pike_compiler, ARG ); \ } /* Funny guys use the uppermost value for nonexistant variables and the like. Hence -2 and not -1. Y2K. */ #define PASS1ONLY(NUMTYPE,TYPE,ARGTYPE,NAME) \ void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \ TYPE ARG) { \ NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \ CHECK_FOO(NUMTYPE,TYPE,NAME); \
-
DO_IF_DEBUG(if (state->compiler_pass !=
1
) {
\
+
DO_IF_DEBUG(if (state->compiler_pass !=
COMPILER_PASS_FIRST
) { \
Pike_fatal("Adding " TOSTR(NAME) " in pass %d.\n", \ state->compiler_pass); \ }); \ if(m == state->new_program->PIKE_CONCAT(num_,NAME)) { \ TYPE *tmp; \ if(m==MAXVARS(NUMTYPE)) { \ yyerror("Too many " #NAME "."); \ return; \ } \ m = MINIMUM(m*2+1,MAXVARS(NUMTYPE)); \
pike.git/src/program.c:1889:
{ push_svalue(m+e); ref_push_string(ident); f_index(2); if(!IS_UNDEFINED(Pike_sp-1)) { struct node_s *ret; UNSETJMP(tmp);
-
if (Pike_compiler->compiler_pass ==
2
&&
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
&&
((TYPEOF(Pike_sp[-1]) == T_OBJECT && Pike_sp[-1].u.object == placeholder_object) || (TYPEOF(Pike_sp[-1]) == T_PROGRAM && Pike_sp[-1].u.program == placeholder_program))) { my_yyerror("Got placeholder %s (resolver problem) " "when indexing a module with %S.", get_name_of_type (TYPEOF(Pike_sp[-1])), ident); ret = 0; } else {
pike.git/src/program.c:1942:
{ int i; if(see_inherit) { i=really_low_find_shared_string_identifier(ident, p->new_program, SEE_PROTECTED|SEE_PRIVATE); if(i!=-1) { if ((p->flags & COMPILATION_FORCE_RESOLVE) &&
-
(p->compiler_pass ==
2
) &&
+
(p->compiler_pass ==
COMPILER_PASS_LAST
) &&
((p->num_inherits + 1) < p->new_program->num_inherits) && (PTR_FROM_INT(p->new_program, i)->inherit_offset > p->num_inherits)) { /* Don't look up symbols inherited later, since we need to get * the same symbol in both passes in the force_resolve mode. */ continue; } return p == Pike_compiler ? mkidentifiernode(i) :
pike.git/src/program.c:2026:
ref_push_string(ident); ref_push_string(c->lex.current_file); if (c->handler) { ref_push_object(c->handler); } else { push_int(0); } if (!safe_apply_current2(PC_RESOLV_FUN_NUM, 3, NULL)) handle_compile_exception ("Error resolving '%S'.", ident);
-
if (Pike_compiler->compiler_pass !=
2
) {
+
if (Pike_compiler->compiler_pass !=
COMPILER_PASS_LAST
) {
/* If we get a program that hasn't gone through pass 1 yet then we * have to register a dependency now in our pass 1 so that our * pass 2 gets delayed. Otherwise the other program might still be * just as unfinished when we come back here in pass 2. */ struct program *p = NULL; if (TYPEOF(Pike_sp[-1]) == T_PROGRAM) p = Pike_sp[-1].u.program; else if (TYPEOF(Pike_sp[-1]) == T_OBJECT || (TYPEOF(Pike_sp[-1]) == T_FUNCTION && SUBTYPEOF(Pike_sp[-1]) != FUNCTION_BUILTIN)) p = Pike_sp[-1].u.object->prog; if (p && !(p->flags & PROGRAM_PASS_1_DONE)) report_compiler_dependency (p); }
-
if (Pike_compiler->compiler_pass ==
2
&&
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
&&
((TYPEOF(Pike_sp[-1]) == T_OBJECT && Pike_sp[-1].u.object == placeholder_object) || (TYPEOF(Pike_sp[-1]) == T_PROGRAM && Pike_sp[-1].u.program == placeholder_program))) { my_yyerror("Got placeholder %s (resolver problem) " "when resolving '%S'.", get_name_of_type (TYPEOF(Pike_sp[-1])), ident); } else { if(!c->resolve_cache) c->resolve_cache=dmalloc_touch(struct mapping *, allocate_mapping(10));
pike.git/src/program.c:2427:
struct program *prog = state->new_program->inherits[i].prog; if (((id = FIND_LFUN(prog, LFUN_ARROW)) == -1) && (prog == state->new_program)) { /* We are allowed to see private symbols in ourselves... */ id = really_low_find_shared_string_identifier(lfun_strings[LFUN_ARROW], prog, SEE_PROTECTED|SEE_PRIVATE); } else if ((id != -1) && (prog != state->new_program)) { id = really_low_reference_inherited_identifier(state, i, id); }
-
if ((id != -1) && (state->compiler_pass ==
2
)) {
+
if ((id != -1) && (state->compiler_pass ==
COMPILER_PASS_LAST
)) {
if (inherit_num < 0) { /* Find the closest inherit containing the lfun::`->() * that is about to be called. * * In the single inherit case, this will always * result in inherit_num == 1. */ struct inherit *inherits = state->new_program->inherits; inherit_num = PTR_FROM_INT(state->new_program, id)->inherit_offset; while (inherits[inherit_num].inherit_level > 1) {
pike.git/src/program.c:2777:
#endif #endif sub_ref = PTR_FROM_INT(inh->prog, cur_id - inh->identifier_level); /* Check if the symbol was used before it was inherited. */ if ((c->lex.pragmas & ID_STRICT_TYPES) && (sub_ref->id_flags & ID_USED)) { struct identifier *sub_id = ID_FROM_PTR(inh->prog, sub_ref); if (IDENTIFIER_IS_FUNCTION(sub_id->identifier_flags)) {
-
if ((Pike_compiler->compiler_pass ==
2
) &&
+
if ((Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) &&
!pike_types_le(ID_FROM_PTR(Pike_compiler->new_program, new_ref)->type, sub_id->type)) { yytype_report(REPORT_WARNING, NULL, 0, sub_id->type, NULL, 0, ID_FROM_PTR(Pike_compiler->new_program, new_ref)->type, 0, "Type mismatch when overloading function %S.", name); } } else {
pike.git/src/program.c:4259:
id = ID_FROM_INT(prog, j); id_flags |= ref->id_flags; opt_flags |= id->opt_flags; /* NB: The dispatcher needs the variant references to * not get overloaded for the ::-operator to work. */ ref->id_flags |= ID_LOCAL; if (type) { struct pike_type * temp = type;
-
if ((Pike_compiler->compiler_pass ==
2
) && !ref->inherit_offset &&
+
if ((Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) &&
+
!ref->inherit_offset &&
!check_variant_overload(id->type, type)) { /* This symbol is shadowed by later variants. */ yytype_report(REPORT_WARNING, NULL, 0, NULL, Pike_compiler->new_program->strings[id->filename_strno], id->linenumber, id->type, 0, "Function %S() masked by later variant.", name); ref_push_type_value(type); low_yyreport(REPORT_WARNING,
pike.git/src/program.c:4325:
{ Pike_compiler->init_node=mknode(F_COMMA_EXPR, mkcastnode(void_type_string, mkapplynode(mkidentifiernode(id),0)), Pike_compiler->init_node); } } } if (finish == 1) {
-
if (Pike_compiler->compiler_pass ==
1
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) {
/* Called from end_program(). */ if (Pike_compiler->init_node) { /* Make sure that the __INIT symbol exists, so that * we won't get a fatal when we add the actual code * further down when we have entered pass 2. * * Also make sure that it is marked as having side effects, * or it will be optimized away when inherited... */ define_function(init_name, function_type_string, ID_PROTECTED, IDENTIFIER_PIKE_FUNCTION, NULL, OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); } }
-
Pike_compiler->compiler_pass =
2
;
+
Pike_compiler->compiler_pass =
COMPILER_PASS_LAST
;
} /* * Define the __INIT function, but only if there was any code * to initialize. */ if(Pike_compiler->init_node) { /* Inhibit this_function. */
pike.git/src/program.c:4451:
toss_compilation_resources(); #if 0 CDFPRINTF("th(%ld) end_first_pass(): " "%p compilation_depth:%d, Pike_compiler->compiler_pass:%d\n", (long)th_self(), prog, c->compilation_depth, Pike_compiler->compiler_pass); #endif
-
if(!Pike_compiler->compiler_frame && (Pike_compiler->compiler_pass==
2
|| !prog) && c->resolve_cache)
+
if(!Pike_compiler->compiler_frame &&
+
(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
|| !prog) &&
+
c->resolve_cache)
{ free_mapping(dmalloc_touch(struct mapping *, c->resolve_cache)); c->resolve_cache=0; } #define POP #include "compilation.h" exit_type_stack();
pike.git/src/program.c:4793:
{ struct program *np=(q?q:Pike_compiler)->new_program; struct reference funp; struct program *p; int d, num_id_refs; if(f==-1) return -1; p = np->inherits[i].prog;
-
if ((q?q:Pike_compiler)->compiler_pass ==
2
) {
+
if ((q?q:Pike_compiler)->compiler_pass ==
COMPILER_PASS_LAST
) {
struct identifier *id = ID_FROM_INT(p, f); if (((id->identifier_flags & IDENTIFIER_TYPE_MASK) == IDENTIFIER_PIKE_FUNCTION) && (id->func.offset == -1)) { /* Prototype. */ return -1; } } funp = p->identifier_references[f]; funp.inherit_offset += i;
pike.git/src/program.c:5043:
#endif CDFPRINTF("th(%ld) %p inherit %p\n", (long) th_self(), Pike_compiler->new_program, p); if(!p) { yyerror("Illegal program pointer."); return; }
-
if (Pike_compiler->compiler_pass =
=
2
) {
+
if (Pike_compiler->compiler_pass
!
=
COMPILER_PASS_FIRST
) {
struct program *old_p = Pike_compiler->new_program->inherits[Pike_compiler->num_inherits+1].prog; Pike_compiler->num_inherits += old_p->num_inherits; if (old_p != p) { yyerror("Got different program for inherit in second pass " "(resolver problem)."); } if (!(p->flags & PROGRAM_FINISHED)) {
pike.git/src/program.c:5609:
struct compilation *c = THIS_COMPILATION; struct program_state *state = Pike_compiler; struct identifier *id; 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
)
+
if(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
)
Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n" "Added identifier: \"%s\"\n", name->str); #endif for(e = 0; DO_IF_DEBUG_ELSE(state, 1) && (e < depth); e++) { state = state->previous; } #ifdef PIKE_DEBUG if (!state) {
pike.git/src/program.c:5733:
size_t offset, INT32 run_time_type) { struct compilation *c = THIS_COMPILATION; 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
)
+
if(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
)
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; return
pike.git/src/program.c:5875:
return n; } } if (!(IDENTIFIERP(n)->id_flags & ID_EXTERN)) { if (IDENTIFIERP(n)->id_flags & ID_FINAL) my_yyerror("Illegal to redefine 'final' " "variable/functions %S", name); if(!(IDENTIFIERP(n)->id_flags & ID_INLINE) ||
-
Pike_compiler->compiler_pass!=
1
)
+
Pike_compiler->compiler_pass
!=
COMPILER_PASS_LAST
)
{ int n2; if(ID_FROM_INT(Pike_compiler->new_program, n)->type != type && !pike_types_le(type, ID_FROM_INT(Pike_compiler->new_program, n)->type)) { int level = REPORT_WARNING; if (!match_types(ID_FROM_INT(Pike_compiler->new_program, n)->type, type)) { level = REPORT_ERROR;
pike.git/src/program.c:6126:
n, id->func.const_info.offset); #endif } return n; } #ifdef PIKE_DEBUG if(Pike_compiler->new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED)) Pike_fatal("Attempting to add constant to fixed program\n");
-
if(Pike_compiler->compiler_pass==
2
) {
+
if(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
) {
dump_program_tables(Pike_compiler->new_program, 2); Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n" " Attempted to add the identifier \"%s\"\n", name->str); } #endif #if 1 if (c) { #endif
pike.git/src/program.c:6400:
#endif /* If this is an lfun, match against the predefined type. */ if ((lfun_type = low_mapping_string_lookup(lfun_types, name))) { int orig_pragmas = c->lex.pragmas; #ifdef PIKE_DEBUG if (TYPEOF(*lfun_type) != T_TYPE) { Pike_fatal("Bad entry in lfun_types for key \"%s\"\n", name->str); } #endif /* PIKE_DEBUG */
-
if (Pike_compiler->compiler_pass ==
2
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) {
/* Inhibit deprecation warnings during the comparison. */ c->lex.pragmas |= ID_NO_DEPRECATION_WARNINGS; if (!pike_types_le(type, lfun_type->u.type)) { int level = REPORT_NOTICE; if (!match_types(type, lfun_type->u.type)) { level = REPORT_ERROR; } else if (c->lex.pragmas & ID_STRICT_TYPES) { level = REPORT_WARNING; } if (level != REPORT_NOTICE) {
pike.git/src/program.c:6480:
if ((i >= 0) && !((ref = PTR_FROM_INT(prog, i))->id_flags & ID_INHERITED)) { /* Not an inherited symbol. */ struct identifier *id = ID_FROM_INT(prog, i); if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags)) { my_yyerror("Illegal to redefine function %S with variable.", symbol); } else if (id->run_time_type != PIKE_T_GET_SET) { my_yyerror("Illegal to redefine a current variable with a getter/setter: %S.", symbol); } else { if ((ref->id_flags | ID_USED) != (flags | ID_USED)) {
-
if (Pike_compiler->compiler_pass ==
1
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) {
yywarning("Modifier mismatch for variable %S.", symbol); } ref->id_flags &= flags | ID_USED; } getter_setter = i; } /* FIXME: Update id->type here. */ } else { struct identifier *id; i = low_define_variable(symbol, symbol_type, flags,
pike.git/src/program.c:6515:
*/ flags |= ID_PROTECTED /* | ID_PRIVATE | ID_INLINE | ID_USED */; free_type(symbol_type); free_string(symbol); } } if(IDENTIFIER_IS_C_FUNCTION(function_flags)) prog->flags |= PROGRAM_HAS_C_METHODS;
-
if (Pike_compiler->compiler_pass ==
1
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) {
/* Mark the type as tentative by setting the runtime-type * to T_MIXED. * * NOTE: This should be reset to T_FUNCTION in pass 2. */ run_time_type = T_MIXED; } i = isidentifier(name);
-
if (Pike_compiler->compiler_pass ==
1
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) {
if (flags & ID_VARIANT) { if (i >= 0) { if (!is_variant_dispatcher(prog, i)) { /* This function will be the termination function for * our variant dispatcher. */ struct reference ref = prog->identifier_references[i]; /* Make sure to not get complaints about multiple * definitions when adding the variant dispatcher. */
pike.git/src/program.c:6630:
struct identifier *id = ID_FROM_INT(prog, getter_setter); (&id->func.gs_info.getter)[is_setter] = i; } return i; } /* Note: The type from pass 1 may be incompatible with the one from * pass 2. Only do this in pass 2, and only if the previous * type isn't from pass 1. */
-
if ((Pike_compiler->compiler_pass ==
2
) &&
+
if ((Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) &&
(funp->run_time_type == T_FUNCTION)) { /* match types against earlier prototype or vice versa */ if(!match_types(type, funp->type)) { yytype_report(REPORT_ERROR, NULL, 0, funp->type, NULL, 0, type, 0, "Prototype doesn't match for function %S.", name); } }
pike.git/src/program.c:6671:
if((ref.id_flags & ID_FINAL) #if 0 && !(funp->func.offset == -1) #endif ) { my_yyerror("Illegal to redefine 'final' function %S.", name); }
-
if (!(flags & ID_VARIANT) && (Pike_compiler->compiler_pass ==
1
) &&
+
if (!(flags & ID_VARIANT) &&
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) &&
(funp->func.c_fun == f_dispatch_variant) && (!func || (func->c_fun != f_dispatch_variant) || !IDENTIFIER_IS_C_FUNCTION(function_flags)) && IDENTIFIER_IS_C_FUNCTION(funp->identifier_flags)) { /* Overriding a variant function dispatcher with * a non-variant function in pass 1. * * Hide the corresponding variant functions. */ int j = prog->num_identifier_references;
pike.git/src/program.c:6770:
} return overridden; } /* NOTE: At this point we already have the identifier in the * new program, and just need to add the reference. */ } else { make_a_new_def: #ifdef PIKE_DEBUG
-
if(Pike_compiler->compiler_pass==
2
)
+
if(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
)
Pike_fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n" "Added identifier: \"%s\"\n", name->str); #endif /* Define a new function */ if(func) idptr = *func; else idptr.offset = -1;
pike.git/src/program.c:7052:
funp = prog->identifier_references + i; if(funp->id_flags & ID_HIDDEN) continue; if(!(funp->id_flags & ID_VARIANT)) continue; if(funp->id_flags & ID_PROTECTED) if(!(flags & SEE_PROTECTED)) continue; fun = ID_FROM_PTR(prog, funp); /* if(fun->func.offset == -1) continue; * Prototype */ if(!is_same_string(fun->name,name)) continue; if(type && (fun->type != type)) {
-
if ((Pike_compiler->compiler_pass ==
2
) &&
+
if ((Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) &&
!(funp->id_flags & ID_INHERITED) && match_types(fun->type, type)) { tentative = i; } continue; } if(funp->id_flags & ID_INHERITED) { struct inherit *inh = INHERIT_FROM_PTR(prog, funp); if ((funp->id_flags & ID_PRIVATE) && !(flags & SEE_PRIVATE)) continue;