Charles.Forsyth20060303-partialeea662d19 years agoHistory
231 lines · 5.2 KB · Text
RawDownload
.TH C2L 10.1 .SH NAMEc2l \- C to Limbo translator.SH SYNOPSIS.B c2l[.I option ...].I file.SH DESCRIPTION.I C2ltranslates the named C.I fileinto Limbo. The translated code should be almost always syntactically correctbut will certainly never be semantically correct as certain constructs in C(strings for example) are almost impossible to convert automatically into Limbo.Otherwise it tries to do a good job of translating the C constructs that have somesort of equivalence in Limbo. The C ternary.B ?:operator is replaced where possible.C library calls are mapped to calls to the Limbo system module, maths module orthe provided Limbo libc modules. Some library calls, such as malloc, are insteadmapped directly into Limbo wherever possible..PPOnce a translation has been made, running the .IR limbo (1)compiler on the resulting output should pick out the areas where handediting is required..PP.I C2lnormally puts all mapped C code (plus that from included files) into asingle .b file..PPThe options to.I c2lare:.TP.B -pUse an ANSI preprocessor in place of the internal one..TP.BI -D name=def.br.ns.TP.BI -D nameDefine the.I nameto the preprocessor,as if by.LR #define .If no definition is given, the name is defined as.LR 1 ..TP.BI -I dirAn.L #includefile whose name does not begin with slashor is enclosed in double quotesis alwayssought first in the directory of the.I fileargument.  If this fails, or the name is enclosed in.BR <> ,it is then soughtin directories named in .B -Ioptions,then in.BR /sys/include ,and finally in.BR /$objtype/include ..TP.B -mPut the mapped code of any included.B .hfiles into its corresponding.B .mfile instead ofthe.B .bfile..TP.B -iSend the mapped code of any included.B .hfiles to.BR /dev/null ..TP.B -lSend the mapped code of any non-local included.B .hfiles to.BR /dev/null . .TP.B -cJust generate code corresponding to the C code ie don't include any prologueor epilogue code such as an implement header, include declarations, moduledeclarations or an init function..TP .B -vOutputs any warnings to standard error as well as putting them in the output source..TP.B -sMap C strings to NUL-terminated arrays of bytes in Limbo. This just about preservesthe semantics of strings and makes the process of hand editing much easier. It isuseful as a first attempt at translation. In this case the module.B /module/libc0.mis used in place of the standard one.B /module/libc.m..TP.B -SMap.B "char*"in C to string in Limbo. Incompatible with the.B -soption..TP.B -MIndicates this file is the one containing the C main program. Used with the.B -qoption below when .I c2ldoes not always know this until it's too late..TP.B -qThis reduces the number of passes that.I c2lmakes over the C code. It makes it faster but more liable to miss sometransformations. Cyclic data structures might not be detected..TP.B -aFor functions which are passed the address of a scalar typed (ie not a structureor union) expression as a parameter, pass the expression itself andrewrite the function and all calls of it to return the expression. For example :-.PP.EX		int		f(int x, int *y)		{			*y = x*x*x;			return x*(*y);		} 		void		g()		{			int p3, p4; 			p4 = f(1729, &p3);		}.EE.PP		becomes.PP.EX		f(x: int, y: int): (int, int)		{			y = x*x*x;			return (x*y, y);		} 		g()		{			p3, p4: int; 			(p4, p3) = f(1729, p3);		}.EE.PP.I C2lruns the preprocessor on the C code before starting translation. Asa special case it will convert definitions of constants into Limbo constant declarations.It makes no attempt to convert any definitions into function declarations..PPIdentifier names that clash with Limbo keywords have letter.B xappended so, for example,a structure member called.B typewould become.BR typex ..PPWarning messages preceded by the acronym TBA (to be addressed) are issued forNUL bytes in strings, ... as an argument, array indices in declarations, use of void type, use of unions, bit fields, use of address operator, negative arrayindices, element specifiers, initial values in Limbo modules, labels, gotos and casestatement fall through..PPThe C types.B charand.B "unsigned char"are mapped to the Limbo.B bytetype.The C types short, unsigned short, int, unsigned int, long and unsigned longare mapped to the Limbo int type. The C types long long and unsigned long longare mapped to the Limbo big type. Finally the C types float and double are mappedto the Limbo real type..PPAnonymous C structures and unions map to a name of the form <module>_adt_<num> where module is the name of the module which is, in turn, derived from the file name. Anonymous member names in strucures and unions have aname of the form anon_<num>. Finally,temporary variables generated by.I c2lhave a name of the form tmp_<num>. In all cases <num> is a unique identifier..SH SOURCE.TF /utils/c2l.TP.B /module/libc.m.TP.B /module/libc0.m.TP.B /appl/lib/libc.b.TP.B /appl/lib/libc0.b.TP.SH "SEE ALSO".IR 2c (10.1),.IR limbo (1).SH BUGS.I C2lis not a pretty printer. It has its own idea of how Limbo should be laid out..PP.I C2lmay well crash if given invalid C code..PP.I c2l -adoes not always do all possible conversions.