⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acd.1

📁 Unix操作系统minix 2.0源码
💻 1
📖 第 1 页 / 共 2 页
字号:
transform .o .o	iftemp $\(**		$> = $\(**	else		cp $\(** $>	optimize $>.ft P.fi.RE.TP.BI ifhash " arg"Executes the ifhash-body if.I argis an existing file with a '\fB#\fP' as the very first character.  Thisusually indicates that the file must be pre-processed:.SP.RS.nf.ft Btransform .s .o	ifhash $\(**		mktemp ASM .s		$CPP $\(** > $ASM	else		ASM = $\(**	$AS \-o $> $ASM	unset ASM.ft P.fi.RE.TP.B elseExecutes the else-body if the last executed.BR if ,.BR ifdef ,.BR ifndef ,.BR iftemp ,or.B ifhashwas unsuccessful.  Note that.B elseneed not immediately follow an if, but you are advised not to make use ofthis.  It is a "feature" that may not last..TP.BI apply " suffix1 suffix2"Executed inside a transform rule body to transform the input file accordingto another transform rule that has the given input and output suffixes.  Thefile under.B $\(**will be replaced by the new file.  So if there is a.B .c .ipreprocessor rule then the example of.B ifhashcan be replaced by:.SP.RS.nf.ft Btransform .s .o	ifhash $\(**		apply .c .i	$AS \-o $> $*.ft P.fi.RE.TP.BI include " descr"Reads another description file and replaces the.B includewith it.  Execution continues with the first list in the new program.  Thesearch for.I descris the same as used for the.B \-descroption.  Use.B includeto switch in different front ends or back ends, or to call a shareddescription file with a different initialization.  Note that.I descris only evaluated the first time the.B includeis called.  After that the.B includehas been replaced with the included program, so changing its argument won'tget you a different file..TP.BI arg " string ...".B Argmay be executed in the initialization and scanning phase to post an argumentscanning rule, that's all the command itself does.  Like an.B ifthat fails it allows more guards to share the same body..TP.BI transform " suffix1 suffix2".BR Transform ,like.BR arg ,only posts a rule to transform a file with the suffix.I suffix1into a file with the suffix.IR suffix2 ..TP.BI prefer " suffix1 suffix2"Tells that the transformation rule from.I suffix1to.I suffix2is to be preferred when looking for a transformation path to the stop suffix.Normally the shortest route to the stop suffix is used..B Preferis ignored on a.BR combine ,because the special nature of combines does not allow ambiguity..SPThe two suffixes on a.B transformor.B prefermay be the same, giving a rule that is only executed when preferred..TP.BI combine " suffix-list suffix".B Combineis like.B transformexcept that it allows a list of input suffixes to match several types ofinput files that must be combined into one..TP.B scanThe scanning phase may be run early from the initialization phase with the.B scancommand.  Use it if you need to make choices based on the arguments beforeposting the transformation rules.  After running this,.B scanand.B argbecome no-ops..TP.B compileMove on to the compilation phase early, so that you have a chance to runa few extra commands before exiting.  This command implies a.BR scan ..PPAny other command is seen as a \s-2UNIX\s+2 command.  This is where the.B <and.B >operators come into play.  They redirect standard input and standard outputto the file mentioned after them, just like the shell..B Acdwill stop with an error if the command is not successful..SS The Initialization PhaseThe driver starts by executing the program once from top to bottom toinitialize variables and post argument scanning and transformation rules..SS The Scanning PhaseIn this phase the driver makes a pass over the command line arguments toprocess options.  Each.B argrule is tried one by one in the order they were posted against the front ofthe argument list.  If a match is made then the matched arguments are removedfrom the argument list and the arg-body is executed.  If no match can be madethen the first argument is moved to the list of files waiting to betransformed and the scan is restarted..PPThe match is done as follows: Each of the strings after.B argmust match one argument at the front of the argument list.  A characterin a string must match a character in an argument word, a subst in a stringmay match 1 to all remaining characters in the argument, preferring theshortest possible match.  The hyphen in a argument starting with a hyphencannot be matched by a subst.  Therefore:.PP.RS.B arg \-i.RE.PPmatches only the argument.BR \-i ..PP.RS.B arg \-O$n.RE.PPmatches any argument that starts with.B \-Oand is at least three characters long.  Lastly,.PP.RS.B arg \-o $out.RE.PPmatches.B \-oand the argument following it, unless that argument starts with a hyphen..PPThe variable.B $\(**is set to all the matched arguments before the arg-body is executed.  Allthe substs in the arg strings are set to the characters they match.  Thevariable.B $>is set to null.  All the values of the variables are saved and the variablesmarked local.  All variables except.B $>are marked read-only.  After the arg-body is executed is the value of.B $>concatenated to the file list.  This allows one to stuff new files into thetransformation phase.  These added names are not evaluated until the startof the next phase..SS The Compilation PhaseThe files gathered in the file list in the scanning phase are now transformedone by one using the transformation rules.  The shortest, or preferred routeis computed for each file all the way to the stop suffix.  Each file istransformed until it lands at the stop suffix, or at a combine rule.  Aftera while all files are either fully transformed or at a combine rule..PPThe driver chooses a combine rule that is not on a path from another combinerule and executes it.  The file that results is then transformed until itagain lands at a combine rule or the stop suffix.  This continues until allfiles are at the stop suffix and the program exits..PPThe paths through transform rules may be ambiguous and have cycles, they willbe resolved.  But paths through combines must be unambiguous, because ofthe many paths from the different files that meet there.  A description filewill usually have only one combine rule for the loader.  However if you dohave a combine conflict then put a no-op transform rule in front of one toresolve the problem..PPIf a file matches a long and a short suffix then the long suffix is preferred.By putting a null input suffix (\fB""\fP) in a rule one can match any filethat no other rule matches.  You can send unknown files to the loader thisway..PPThe variable.B $\(**is set to the file to be transformed or the files to be combined before thetransform or combine-body is executed..B $>is set to the output file name, it may again be modified..B $<is set to the original name of the first file of.B $\(**with the leading directories and the suffix removed..B $\(**will be made up of temporary files after the first rule..B $>will be another temporary file or the name of the target file.RB ( $<plus the stop suffix), if the stop suffix is reached..PP.B $>is passed to the next rule; it is imploded and checked to be a single word.This driver does not store intermediate object files in the current directorylike most other compilers, but keeps them in.B /tmptoo.  (Who knows if the current directory can have files created in?)  As anexample, here is how you can express the "normal" method:.PP.RS.nf.ft Btransform .s .o	if $> = $<.o		# Stop suffix is .o	else		$> = $<.o		temporary $>	$AS \-o $> $\(**.ft P.fi.RE.PPNote that.B temporaryis not called if the target is already the object file, or you would losethe intended result!.B $>is known to be a word, because.B $<is local.  (Any string whose substs are all expanded changes to a word.).SS "Predefined Variables"The driver has three variables predefined:.BR PROGRAM ,set to the call name of the driver,.BR VERSION ,the driver's version number, and.BR ARCH ,set to the name of the default output architecture.  The latter is optional,and only defined if.B acdwas compiled with \fB\-DARCH=\e"\fP\fIarch-name\fP\fB\e"\fP..SH EXAMPLEAs an example a description file for a C compiler is given.  It has afront end (ccom), an intermediate code optimizer (opt), a code generator (cg),an assembler (as), and a loader (ld).  The compiler can pre-process, butthere is also a separate cpp.  If the.B \-Dand options like it are changed to look like.B \-othen this example is even as required by \s-2POSIX\s+2..RS.nf# The compiler support search path.C =	/lib /usr/lib /usr/local/lib# Compiler passes.CPP =	$C/cpp $CPP_FCCOM =	$C/ccom $CPP_FOPT =	$C/optCG =	$C/cgAS =	$C/asLD =	$C/ld# Predefined symbols.CPP_F =	\-D__EXAMPLE_CC__# Library path.LIBPATH = $USERLIBPATH $C# Default transformation target.stop .out# Preprocessor directives.arg \-D$namearg \-U$namearg \-I$dir	CPP_F = $CPP_F $\(**# Stop suffix.arg \-c	stop .oarg \-E	stop .E# Optimization.arg \-O	prefer .m .m	OPT = $OPT -O1arg \-O$n	numeric $n	prefer .m .m	OPT = $OPT $\(**# Add debug info to the executable.arg \-g	CCOM = $CCOM -g# Add directories to the library path.arg \-L$dir	USERLIBPATH = $USERLIBPATH $dir# \-llib must be searched in $LIBPATH later.arg \-l$lib	$> = $LIBPATH/lib$lib.a# Change output file.arg \-o$outarg \-o $out	OUT = $out# Complain about a missing argument.arg \-o	error "argument expected after '$\(**'"# Any other option (like \-s) are for the loader.arg \-$any	LD = $LD $\(**# Preprocess C-source.transform .c .i	$CPP $\(** > $># Preprocess C-source and send it to standard output or $OUT.transform .c .E	ifndef OUT		$CPP $\(**	else		$CPP $\(** > $OUT# Compile C-source to intermediate code.transform .c .mtransform .i .m	$CCOM $\(** $># Intermediate code optimizer.transform .m .m	$OPT $\(** > $># Intermediate to assembly.transform .m .s	$CG $\(** > $># Assembler to object code.transform .s .o	if $> = $<.o		ifdef OUT			$> = $OUT	$AS \-o $> $\(**# Combine object files and libraries to an executable.combine (.o .a) .out	ifndef OUT		OUT = a.out	$LD \-o $OUT $C/crtso.o $\(** $C/libc.a.fi.RE.SH FILES.TP 25n.RI /usr/lib/ descr /descr\- compiler driver description file..SH "SEE ALSO".BR cc (1)..SH ACKNOWLEDGEMENTSEven though the end result doesn't look much like it, many ideas werenevertheless derived from the ACK compiler driver by Ed Keizer..SH BUGS\s-2POSIX\s+2 requires that if compiling one source file to an object filefails then the compiler should continue with the next source file.  There isno way.B acdcan do this, it always stops after error.  It doesn't even know what anobject file is!  (The requirement is stupid anyhow.).PPIf you don't think that tabs are 8 spaces wide, then don't mix them withspaces for indentation..SH AUTHORKees J. Bot (kjb@cs.vu.nl)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -