1*572c4311Sfengbojiang<!-- $Id: luac.man,v 1.28 2006/01/06 16:03:34 lhf Exp $ --> 2*572c4311Sfengbojiang<HTML> 3*572c4311Sfengbojiang<HEAD> 4*572c4311Sfengbojiang<TITLE>LUAC man page</TITLE> 5*572c4311Sfengbojiang<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css"> 6*572c4311Sfengbojiang</HEAD> 7*572c4311Sfengbojiang 8*572c4311Sfengbojiang<BODY BGCOLOR="#FFFFFF"> 9*572c4311Sfengbojiang 10*572c4311Sfengbojiang<H2>NAME</H2> 11*572c4311Sfengbojiangluac - Lua compiler 12*572c4311Sfengbojiang<H2>SYNOPSIS</H2> 13*572c4311Sfengbojiang<B>luac</B> 14*572c4311Sfengbojiang[ 15*572c4311Sfengbojiang<I>options</I> 16*572c4311Sfengbojiang] [ 17*572c4311Sfengbojiang<I>filenames</I> 18*572c4311Sfengbojiang] 19*572c4311Sfengbojiang<H2>DESCRIPTION</H2> 20*572c4311Sfengbojiang<B>luac</B> 21*572c4311Sfengbojiangis the Lua compiler. 22*572c4311SfengbojiangIt translates programs written in the Lua programming language 23*572c4311Sfengbojianginto binary files that can be later loaded and executed. 24*572c4311Sfengbojiang<P> 25*572c4311SfengbojiangThe main advantages of precompiling chunks are: 26*572c4311Sfengbojiangfaster loading, 27*572c4311Sfengbojiangprotecting source code from accidental user changes, 28*572c4311Sfengbojiangand 29*572c4311Sfengbojiangoff-line syntax checking. 30*572c4311Sfengbojiang<P> 31*572c4311SfengbojiangPrecompiling does not imply faster execution 32*572c4311Sfengbojiangbecause in Lua chunks are always compiled into bytecodes before being executed. 33*572c4311Sfengbojiang<B>luac</B> 34*572c4311Sfengbojiangsimply allows those bytecodes to be saved in a file for later execution. 35*572c4311Sfengbojiang<P> 36*572c4311SfengbojiangPrecompiled chunks are not necessarily smaller than the corresponding source. 37*572c4311SfengbojiangThe main goal in precompiling is faster loading. 38*572c4311Sfengbojiang<P> 39*572c4311SfengbojiangThe binary files created by 40*572c4311Sfengbojiang<B>luac</B> 41*572c4311Sfengbojiangare portable only among architectures with the same word size and byte order. 42*572c4311Sfengbojiang<P> 43*572c4311Sfengbojiang<B>luac</B> 44*572c4311Sfengbojiangproduces a single output file containing the bytecodes 45*572c4311Sfengbojiangfor all source files given. 46*572c4311SfengbojiangBy default, 47*572c4311Sfengbojiangthe output file is named 48*572c4311Sfengbojiang<B>luac.out</B>, 49*572c4311Sfengbojiangbut you can change this with the 50*572c4311Sfengbojiang<B>-o</B> 51*572c4311Sfengbojiangoption. 52*572c4311Sfengbojiang<P> 53*572c4311SfengbojiangIn the command line, 54*572c4311Sfengbojiangyou can mix 55*572c4311Sfengbojiangtext files containing Lua source and 56*572c4311Sfengbojiangbinary files containing precompiled chunks. 57*572c4311SfengbojiangThis is useful because several precompiled chunks, 58*572c4311Sfengbojiangeven from different (but compatible) platforms, 59*572c4311Sfengbojiangcan be combined into a single precompiled chunk. 60*572c4311Sfengbojiang<P> 61*572c4311SfengbojiangYou can use 62*572c4311Sfengbojiang<B>'-'</B> 63*572c4311Sfengbojiangto indicate the standard input as a source file 64*572c4311Sfengbojiangand 65*572c4311Sfengbojiang<B>'--'</B> 66*572c4311Sfengbojiangto signal the end of options 67*572c4311Sfengbojiang(that is, 68*572c4311Sfengbojiangall remaining arguments will be treated as files even if they start with 69*572c4311Sfengbojiang<B>'-'</B>). 70*572c4311Sfengbojiang<P> 71*572c4311SfengbojiangThe internal format of the binary files produced by 72*572c4311Sfengbojiang<B>luac</B> 73*572c4311Sfengbojiangis likely to change when a new version of Lua is released. 74*572c4311SfengbojiangSo, 75*572c4311Sfengbojiangsave the source files of all Lua programs that you precompile. 76*572c4311Sfengbojiang<P> 77*572c4311Sfengbojiang<H2>OPTIONS</H2> 78*572c4311SfengbojiangOptions must be separate. 79*572c4311Sfengbojiang<P> 80*572c4311Sfengbojiang<B>-l</B> 81*572c4311Sfengbojiangproduce a listing of the compiled bytecode for Lua's virtual machine. 82*572c4311SfengbojiangListing bytecodes is useful to learn about Lua's virtual machine. 83*572c4311SfengbojiangIf no files are given, then 84*572c4311Sfengbojiang<B>luac</B> 85*572c4311Sfengbojiangloads 86*572c4311Sfengbojiang<B>luac.out</B> 87*572c4311Sfengbojiangand lists its contents. 88*572c4311Sfengbojiang<P> 89*572c4311Sfengbojiang<B>-o </B><I>file</I> 90*572c4311Sfengbojiangoutput to 91*572c4311Sfengbojiang<I>file</I>, 92*572c4311Sfengbojianginstead of the default 93*572c4311Sfengbojiang<B>luac.out</B>. 94*572c4311Sfengbojiang(You can use 95*572c4311Sfengbojiang<B>'-'</B> 96*572c4311Sfengbojiangfor standard output, 97*572c4311Sfengbojiangbut not on platforms that open standard output in text mode.) 98*572c4311SfengbojiangThe output file may be a source file because 99*572c4311Sfengbojiangall files are loaded before the output file is written. 100*572c4311SfengbojiangBe careful not to overwrite precious files. 101*572c4311Sfengbojiang<P> 102*572c4311Sfengbojiang<B>-p</B> 103*572c4311Sfengbojiangload files but do not generate any output file. 104*572c4311SfengbojiangUsed mainly for syntax checking and for testing precompiled chunks: 105*572c4311Sfengbojiangcorrupted files will probably generate errors when loaded. 106*572c4311SfengbojiangLua always performs a thorough integrity test on precompiled chunks. 107*572c4311SfengbojiangBytecode that passes this test is completely safe, 108*572c4311Sfengbojiangin the sense that it will not break the interpreter. 109*572c4311SfengbojiangHowever, 110*572c4311Sfengbojiangthere is no guarantee that such code does anything sensible. 111*572c4311Sfengbojiang(None can be given, because the halting problem is unsolvable.) 112*572c4311SfengbojiangIf no files are given, then 113*572c4311Sfengbojiang<B>luac</B> 114*572c4311Sfengbojiangloads 115*572c4311Sfengbojiang<B>luac.out</B> 116*572c4311Sfengbojiangand tests its contents. 117*572c4311SfengbojiangNo messages are displayed if the file passes the integrity test. 118*572c4311Sfengbojiang<P> 119*572c4311Sfengbojiang<B>-s</B> 120*572c4311Sfengbojiangstrip debug information before writing the output file. 121*572c4311SfengbojiangThis saves some space in very large chunks, 122*572c4311Sfengbojiangbut if errors occur when running a stripped chunk, 123*572c4311Sfengbojiangthen the error messages may not contain the full information they usually do. 124*572c4311SfengbojiangFor instance, 125*572c4311Sfengbojiangline numbers and names of local variables are lost. 126*572c4311Sfengbojiang<P> 127*572c4311Sfengbojiang<B>-v</B> 128*572c4311Sfengbojiangshow version information. 129*572c4311Sfengbojiang<H2>FILES</H2> 130*572c4311Sfengbojiang<P> 131*572c4311Sfengbojiang<B>luac.out</B> 132*572c4311Sfengbojiangdefault output file 133*572c4311Sfengbojiang<H2>SEE ALSO</H2> 134*572c4311Sfengbojiang<B>lua</B>(1) 135*572c4311Sfengbojiang<BR> 136*572c4311Sfengbojiang<A HREF="http://www.lua.org/">http://www.lua.org/</A> 137*572c4311Sfengbojiang<H2>DIAGNOSTICS</H2> 138*572c4311SfengbojiangError messages should be self explanatory. 139*572c4311Sfengbojiang<H2>AUTHORS</H2> 140*572c4311SfengbojiangL. H. de Figueiredo, 141*572c4311SfengbojiangR. Ierusalimschy and 142*572c4311SfengbojiangW. Celes 143*572c4311Sfengbojiang<!-- EOF --> 144*572c4311Sfengbojiang</BODY> 145*572c4311Sfengbojiang</HTML> 146