and result is already done.
*/
register t_node *left = nd->nd_left;
- register t_node *right = nd->nd_right;
register t_type *result_tp;
+ int needs_fn;
if (left->nd_type == std_type) {
CodeStd(nd);
assert(IsProcCall(left));
- if (right) {
- CodeParameters(ParamList(left->nd_type), right);
+ if (nd->nd_right) {
+ CodeParameters(ParamList(left->nd_type), nd->nd_right);
}
switch(left->nd_class) {
if (level > 0) {
C_lxl((arith) (proclevel - level));
}
+ needs_fn = left->nd_def->df_scope->sc_defmodule;
C_cal(NameOfProc(left->nd_def));
break;
}}
/* Fall through */
default:
+ needs_fn = 1;
CodePExpr(left);
C_cai();
}
}
else C_lfr(sz);
}
- DoFilename();
+ DoFilename(needs_fn);
DoLineno(nd);
}
t_scopelist *vis;
char *fn = FileName;
int ln = LineNumber;
- t_scope *newsc = CurrentScope;
+ t_scope *newsc;
level += incr;
df = lookup(id, GlobalScope, D_IMPORTED, 0);
ForeignFlag = 0;
DefId = id;
open_scope(CLOSEDSCOPE);
+ newsc = CurrentScope;
vis = CurrVis;
+ newsc->sc_defmodule = incr;
if (!strcmp(id->id_text, "SYSTEM")) {
do_SYSTEM();
df = lookup(id, GlobalScope, D_IMPORTED, 0);
}
else {
- newsc = CurrentScope;
if (!is_anon_idf(id) && GetFile(id->id_text)) {
DefModule();
struct def *sc_def; /* list of definitions in this scope */
arith sc_off; /* offsets of variables in this scope */
char sc_scopeclosed; /* flag indicating closed or open scope */
+ char sc_defmodule; /* flag set is this scope is from a separate
+ definition module
+ */
int sc_level; /* level of this scope */
struct def *sc_definedby; /* The def structure defining this scope */
struct node *sc_end; /* node to remember line number of end of scope */
}
}
-DoFilename()
+DoFilename(needed)
{
static label filename_label = 0;
- oldlineno = 0;
- if (! options['L']) {
+ oldlineno = 0; /* always invalidate remembered line number */
+ if (needed && ! options['L']) {
if (! filename_label) {
filename_label = 1;
for (; nd; nd = nd->nd_left) {
C_cal(nd->nd_def->mod_vis->sc_scope->sc_name);
}
- DoFilename();
+ DoFilename(1);
}
WalkDefList(sc->sc_def, MkCalls);
proclevel++;
C_ms_par(procedure->df_type->prc_nbpar);
TmpOpen(procscope);
DoPriority();
- DoFilename(); /* ??? only when this procedure is exported? */
+ /* generate code for filename only when the procedure can be
+ exported, either directly or by taking the address.
+ This cannot be done if the level is not zero (because in
+ this case it is a nested procedure).
+ */
+ DoFilename(! procscope->sc_level);
func_type = tp = RemoveEqual(ResultType(procedure->df_type));