1 - callname recognition is moved to rmach.c.

2 - The overall scheme is altered.
	first, all input files are processed until a combining phase is met.
	then, all the combining phases are executed, the resulting files
	are again processed until a combiner (or final) phase is met.
3 - The EM_DIR shell variable can be used to set ack's idea of the EM
    home directory.
This commit is contained in:
keie 1984-09-10 16:37:11 +00:00
parent 31f96c6850
commit c504e2e22a

View file

@ -36,6 +36,7 @@ main(argc,argv) char **argv ; {
register list_elem *elem ; register list_elem *elem ;
register char *frontend ; register char *frontend ;
register int *n_sig ; register int *n_sig ;
register trf *phase ;
progname=argv[0]; progname=argv[0];
varinit(); varinit();
@ -45,10 +46,24 @@ main(argc,argv) char **argv ; {
} else { } else {
setlist(FRONTENDS); setlist(FRONTENDS);
} }
if ( callname ) {
if ( machine ) {
fuerror("can not produce code for both %s and %s",
callname,machine) ;
}
machine= callname ;
}
if ( !machine && ! (machine=getenv("ACKM")) ) {
#ifdef ACKM
machine= ACKM; /* The default machine */
#else
fuerror("No machine specified") ;
#endif
}
setlist(machine); setlist(machine);
transini(); transini();
scanneeds(); scanneeds();
template= mktemp(ACKNAME) ; sprintf(template,TMPNAME,getpid()) ;
if ( n_error && !k_flag ) return n_error ; if ( n_error && !k_flag ) return n_error ;
for ( n_sig=sigs ; *n_sig ; n_sig++ ) { for ( n_sig=sigs ; *n_sig ; n_sig++ ) {
@ -56,23 +71,47 @@ main(argc,argv) char **argv ; {
signal(*n_sig,SIG_IGN) ; signal(*n_sig,SIG_IGN) ;
} }
} }
scanlist ( l_first(arguments), elem ) {
if ( !process(l_content(*elem)) && !k_flag ) return 1 ;
}
orig.p_path= (char *)0 ;
if ( !combiner && !stopsuffix ) { if ( !stopsuffix ) {
/* Call combiner directly without any transformation */ /* Find the linker, needed for argument building */
scanlist(l_first(tr_list),elem) { scanlist(l_first(tr_list),elem) {
if ( t_cont(*elem)->t_combine ) { if ( t_cont(*elem)->t_linker ) {
combiner= t_cont(*elem) ; linker= t_cont(*elem) ;
linker->t_do= YES ;
} }
} }
} }
if ( !combiner || n_error ) return n_error ; scanlist ( l_first(arguments), elem ) {
if ( !process(l_content(*elem)) && !k_flag ) return 1 ;
}
orig.p_path= (char *)0 ;
if ( !rts ) rts="" ;
setsvar(keeps(RTS),rts) ;
if ( !do_combine() ) return 1 ; scanlist(l_first(tr_list),elem) {
phase=t_cont(*elem) ;
if ( phase->t_combine && phase->t_do ) {
if ( phase->t_blocked ) {
#ifdef DEBUG
if ( debug ) {
vprint("phase %s is blocked\n",
phase->t_name) ;
}
#endif
disc_inputs(phase) ;
continue ;
}
orig.p_keep=YES ;
orig.p_keeps=NO ;
orig.p_path=phase->t_origname ;
if ( p_basename ) throws(p_basename) ;
p_basename= keeps(basename(orig.p_path)) ;
if ( !startrf(phase) && !k_flag ) return 1 ;
}
}
if ( n_error ) return n_error ;
if ( g_flag ) { if ( g_flag ) {
return do_run(); return do_run();
@ -87,7 +126,13 @@ char *srcvar() {
varinit() { varinit() {
/* initialize the string variables */ /* initialize the string variables */
setsvar(keeps(HOME),keeps(EM_DIR)) ; register char *envstr ;
if ( envstr=getenv("EM_DIR") ) {
setsvar(keeps(HOME),keeps(envstr)) ;
} else {
setsvar(keeps(HOME),keeps(EM_DIR)) ;
}
setpvar(keeps(SRC),srcvar) ; setpvar(keeps(SRC),srcvar) ;
} }
@ -147,9 +192,14 @@ vieuwargs(argc,argv) char **argv ; {
} }
keeptail(&argp[2]); eaten=1 ; keeptail(&argp[2]); eaten=1 ;
break ; break ;
case '.': if ( rts ) fuerror("Two run-time systems?") ; case '.': if ( rts ) {
rts= &argp[1] ; eaten=1; if ( strcmp(rts,&argp[1])!=0 )
keephead(rts) ; keeptail(rts) ; fuerror("Two run-time systems?") ;
} else {
rts= &argp[1] ;
keephead(rts) ; keeptail(rts) ;
}
eaten=1 ;
break ; break ;
#ifdef DEBUG #ifdef DEBUG
case 'd': debug++ ; case 'd': debug++ ;
@ -179,13 +229,6 @@ vieuwargs(argc,argv) char **argv ; {
werror("Unexpected characters at end of %s",argp) ; werror("Unexpected characters at end of %s",argp) ;
} }
} }
if ( !machine && ! (machine=getenv("ACKM")) ) {
#ifdef ACKM
machine= ACKM; /* The default machine */
#else
fuerror("No machine specified") ;
#endif
}
return ; return ;
} }
@ -198,97 +241,124 @@ firstarg(argp) register char *argp ; {
} else { } else {
name= argp ; name= argp ;
} }
if ( strcmp(name,"ack")==0 ) return ; callname= name;
if ( strcmp(name,"acc")==0 || strcmp(name,"cc")==0 ) {
rts= ".c" ; keephead(rts) ; keeptail(rts) ;
return ;
}
if ( strcmp(name,"apc")==0 || strcmp(name,"pc")==0 ) {
rts= ".p" ; keephead(rts) ; keeptail(rts) ;
return ;
}
machine= name;
} }
/************************* argument processing ***********************/ /************************* argument processing ***********************/
process(arg) char *arg ; { process(arg) char *arg ; {
/* Process files & library arguments */ /* Process files & library arguments */
register list_elem *elem ; trf *phase ;
register trf *phase ;
int first=YES ;
#ifdef DEBUG #ifdef DEBUG
if ( debug ) vprint("Processing %s\n",arg) ; if ( debug ) vprint("Processing %s\n",arg) ;
#endif #endif
if ( arg[0]=='-' ) { l_add(&c_arguments,keeps(arg)) ; return 1 ; }
p_suffix= rindex(arg,SUFCHAR) ; p_suffix= rindex(arg,SUFCHAR) ;
if ( p_basename ) throws(p_basename) ;
orig.p_keep= YES ; /* Don't throw away the original ! */ orig.p_keep= YES ; /* Don't throw away the original ! */
orig.p_keeps= NO;
orig.p_path= arg ; orig.p_path= arg ;
if ( arg[0]=='-' || !p_suffix ) {
if ( linker ) add_input(&orig,linker) ;
return 1 ;
}
if ( p_basename ) throws(p_basename) ;
p_basename= keeps(basename(arg)) ; p_basename= keeps(basename(arg)) ;
if ( !p_suffix ) { l_add(&c_arguments,keeps(arg)) ; return 1 ; }
/* Try to find a path through the transformations */ /* Try to find a path through the transformations */
switch( setpath() ) { switch( getpath(&phase) ) {
case F_NOPATH : case F_NOPATH :
error("Cannot produce the desired file from %s",arg) ; error("Cannot produce the desired file from %s",arg) ;
l_add(&c_arguments,keeps(arg)) ; if ( linker ) add_input(&orig,linker) ;
return 1 ; return 1 ;
case F_NOMATCH : case F_NOMATCH :
if ( stopsuffix ) werror("Unknown suffix in %s",arg) ; if ( stopsuffix ) werror("Unknown suffix in %s",arg) ;
l_add(&c_arguments,keeps(arg)) ; if ( linker ) add_input(&orig,linker) ;
return 1 ; return 1 ;
case F_OK : case F_OK :
break ; break ;
} }
orig.p_keeps= NO; if ( !phase ) return 1 ;
if ( phase->t_combine ) {
add_input(&orig,phase) ;
return 1 ;
}
in= orig ; in= orig ;
scanlist(l_first(tr_list), elem) { if ( !nill_flag ) {
phase= t_cont(*elem) ; printf("%s\n",arg) ;
if ( phase->t_do ) { /* perform this transformation */ }
if ( first ) { return startrf(phase) ;
if ( !nill_flag ) { }
printf("%s\n",arg) ;
} int startrf(first) trf *first ; {
} /* Start the transformations at the indicated phase */
switch ( phase->t_prep ) { register trf *phase ;
default : if ( !mayprep() ) break ;
case YES: if ( !transform(cpp_trafo) ) { phase=first ;
n_error++ ; for(;;) {
switch ( phase->t_prep ) {
/* BEWARE, sign extension */
default : if ( !mayprep() ) break ;
case YES: if ( !transform(cpp_trafo) ) {
n_error++ ;
#ifdef DEBUG #ifdef DEBUG
vprint("Pre-processor failed\n") ; vprint("Pre-processor failed\n") ;
#endif #endif
return 0 ; return 0 ;
} }
case NO : case NO :
break ; break ;
} }
if ( cpp_trafo && stopsuffix && if ( cpp_trafo && stopsuffix &&
strcmp(cpp_trafo->t_out,stopsuffix)==0 ) { strcmp(cpp_trafo->t_out,stopsuffix)==0 ) {
break ; break ;
} }
if ( !transform(phase) ) { if ( !transform(phase) ) {
n_error++ ; n_error++ ;
block(phase->t_next) ;
#ifdef DEBUG #ifdef DEBUG
if ( debug ) { if ( debug ) {
if ( !orig.p_path ) {
vprint("phase %s failed\n",
phase->t_name ) ;
} else {
vprint("phase %s for %s failed\n", vprint("phase %s for %s failed\n",
phase->t_name,orig.p_path) ; phase->t_name,orig.p_path) ;
} }
#endif
return 0 ;
} }
first=NO ; #endif
return 0 ;
}
first=NO ;
phase=phase->t_next ;
if ( !phase ) {
#ifdef DEBUG
if ( debug ) vprint("Transformation sequence complete for %s\n",
orig.p_path) ;
#endif
/* No more work on this file */
if ( !in.p_keep ) {
fatal("attempt to discard the result file") ;
}
if ( in.p_keeps ) throws(in.p_path) ;
in.p_keep=NO ; in.p_keeps=NO ; in.p_path= (char *) 0 ;
return 1 ;
}
if ( phase->t_combine ) {
add_input(&in,phase) ;
break ;
} }
} }
#ifdef DEBUG
if ( debug ) vprint("Transformation complete for %s\n",orig.p_path) ;
#endif
if ( !in.p_keep ) fatal("attempt to discard the result file") ;
l_add(&c_arguments,keeps(in.p_path));
disc_files() ;
return 1 ; return 1 ;
} }
block(first) trf *first ; {
/* One of the input files of this phase could not be produced,
block all combiners taking their input from this one.
*/
register trf *phase ;
for ( phase=first ; phase ; phase=phase->t_next ) {
if ( phase->t_combine ) phase->t_blocked=YES ;
}
}
mayprep() { mayprep() {
int file ; int file ;
char fc ; char fc ;
@ -316,21 +386,17 @@ scanneeds() {
} }
setneeds(suffix,tail) char *suffix ; { setneeds(suffix,tail) char *suffix ; {
register list_elem *elem ; trf *phase ;
register trf *phase ;
p_suffix= suffix ; p_suffix= suffix ;
switch ( setpath() ) { switch ( getpath(&phase) ) {
case F_OK : case F_OK :
scanlist( l_first(tr_list), elem ) { for ( ; phase ; phase= phase->t_next ) {
phase = t_cont(*elem) ; if ( phase->t_needed ) {
if ( phase->t_do ) { if ( tail )
if ( phase->t_needed ) { add_tail(phase->t_needed) ;
if ( tail ) else
add_tail(phase->t_needed) ; add_head(phase->t_needed) ;
else
add_head(phase->t_needed) ;
}
} }
} }
break ; break ;
@ -338,7 +404,7 @@ setneeds(suffix,tail) char *suffix ; {
werror("\"%s\": unrecognized suffix",suffix) ; werror("\"%s\": unrecognized suffix",suffix) ;
break ; break ;
case F_NOPATH : case F_NOPATH :
werror("incomplete internal specification for %s files", werror("sorry, cannot produce the desired file(s) from %s files",
suffix) ; suffix) ;
break ; break ;
} }