FreeBASIC  0.91.0
fbc.bas File Reference
#include "fb.bi"
#include "hlp.bi"
#include "hash.bi"
#include "list.bi"
#include "objinfo.bi"
#include "file.bi"
Include dependency graph for fbc.bas:

Go to the source code of this file.

Data Structures

class  FBC_EXTOPT
 
class  FBCIOFILE
 
class  FBC_OBJINF
 
class  FBCCTX
 

Macros

#define ENABLE_GORC
 
#define safeKill(f)
 

Typedefs

using fo = any if(len(fbc.xpm.srcfile)=0) then return TRUE end if ''Remember *.xpm file name xpmfile=fbc.xpm.srcfile ''Set *.bas name based on input file name or-o< file >:if(len(*fbc.xpm.objfile) > 0) then fbc.xpm.srcfile=hStripExt(*fbc.xpm.objfile) end if ''foo.xpm-> foo.xpm.bas to avoid collision with foo.bas fbc.xpm.srcfile &=".bas"if(fbc.verbose) then print"parsing xpm: ", xpmfile &" -o "&fbc.xpm.srcfile end if if(hParseXpm(xpmfile, code)=FALSE) then ''TODO:show error message exit function end if fo=freefile() if(open(fbc.xpm.srcfile, for output, as#fo)) then ''TODO:show error message exit function end if print#fo, code
 

Enumerations

enum  {
  FBCTOOL_AS = 0, FBCTOOL_AR, FBCTOOL_LD, FBCTOOL_GCC,
  FBCTOOL_LLC, FBCTOOL_DLLTOOL, FBCTOOL_GORC, FBCTOOL_WINDRES,
  FBCTOOL_CXBE, FBCTOOL__COUNT
}
 
enum  {
  OPT_A = 0, OPT_ARCH, OPT_ASM, OPT_B,
  OPT_C, OPT_CKEEPOBJ, OPT_D, OPT_DLL,
  OPT_DYLIB, OPT_E, OPT_EX, OPT_EXX,
  OPT_EXPORT, OPT_FORCELANG, OPT_FPMODE, OPT_FPU,
  OPT_G, OPT_GEN, OPT_HELP, OPT_I,
  OPT_INCLUDE, OPT_L, OPT_LANG, OPT_LIB,
  OPT_M, OPT_MAP, OPT_MAXERR, OPT_MT,
  OPT_NODEFLIBS, OPT_NOERRLINE, OPT_O, OPT_OPTIMIZE,
  OPT_P, OPT_PP, OPT_PREFIX, OPT_PRINT,
  OPT_PROFILE, OPT_R, OPT_RKEEPASM, OPT_RR,
  OPT_RRKEEPASM, OPT_S, OPT_STATIC, OPT_T,
  OPT_TARGET, OPT_TITLE, OPT_V, OPT_VEC,
  OPT_VERSION, OPT_W, OPT_WA, OPT_WC,
  OPT_WL, OPT_X, OPT_Z, OPT__COUNT
}
 

Functions

then Invalid XPM header close
exit function end if Check for
lines containing 
strings (color and pixel lines) ''Other lines(declaration line
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely but should
automatically be as long as
they don t contain strings dim
as integer ln Strip everything
in front of the first in a new
separated by a if it s not the
first one 
if (saw_rows) then code+
 
close Clean up the temp bas if
R wasn t given 
if (fbc.keepasm=FALSE) then fbcAddTemp(fbc.xpm.srcfile) end if hCompileBas(@fbc.xpm
 
FB isn t strict about it don t
let gcc make assumptions
because they cause
incompatibilities with the ASM
backend For however with the C
backend gcc ffast math
optimizes out the 
subtraction (even under-O0) and inserts 0 instead. ''Avoid gcc exception handling bloat ln+
 
sub fbcFindBin (byval_as_integer tool, byref_as_string path, byref_as_integer relying_on_system=FALSE)
 
function_as_integer fbcRunBin (byval_as_zstring_ptr action, byval_as_integer tool, byref_as_string ln)
 
private sub fbcInit ()
 
private sub hSetOutName ()
 
private sub fbcEnd (byval_as_integer errnum)
 
private sub fbcAddTemp (byref_as_string file)
 
private function_as_string_ptr fbcAddObj (byref_as_string file)
 
private function_as_string fbcFindLibFile (byval_as_zstring_ptr file)
 
private sub fbcAddDefLibPath (byref_as_string path)
 
private sub fbcAddLibPathFor (byval_as_zstring_ptr libname)
 
private function_as_integer hPutLdArgsIntoFile (byref_as_string ldcline)
 
private function_as_integer clearDefList (byref_as_string deffile)
 
private function_as_integer hGenerateEmptyDefFile (byref_as_string deffile)
 
private function_as_integer makeImpLib (byref_as_string dllname, byref_as_string deffile)
 
private function_as_string hFindLib (byval_as_zstring_ptr file)
 
private function_as_integer hLinkFiles ()
 
private sub hReadObjinfo ()
 
private sub hCollectObjinfo ()
 
private sub hFatalInvalidOption (byref_as_string arg)
 
private sub hCheckWaitingObjfile ()
 
private sub hSetIofile (byval_as_FBCIOFILE_ptr module, byref_as_string srcfile, byval_as_integer is_rc)
 
private sub hAddBas (byref_as_string basfile)
 
private sub hParseTargetId (byref_as_string os, byref_as_string arch)
 
private function_as_integer hParseTargetOS (byref_as_string os)
 
private sub handleOpt (byval_as_integer optid, byref_as_string arg)
 
private function_as_integer parseOption (byval_as_zstring_ptr opt)
 
sub parseArgsFromFile (byref_as_string filename)
 
private sub handleArg (byref_as_string arg)
 
private sub hParseArgs (byval_as_integer argc, byval_as_zstring_ptr_ptr argv)
 
private sub fbcInit2 ()
 
private function_as_string hGetAsmName (byval_as_FBCIOFILE_ptr module, byval_as_integer stage)
 
private sub hCompileBas (byval_as_FBCIOFILE_ptr module, byval_as_integer is_main, byval_as_integer is_fbctinf)
 
private sub hCompileModules ()
 
private function_as_integer hParseXpm (byref_as_string xpmfile, byref_as_string code)
 
private function_as_integer hCompileXpm ()
 
private function_as_integer hCompileStage2Module (byval_as_FBCIOFILE_ptr module)
 
private sub hCompileStage2Modules ()
 
private function_as_integer hAssembleModule (byval_as_FBCIOFILE_ptr module)
 
private sub hAssembleModules ()
 
private function_as_integer hAssembleRc (byval_as_FBCIOFILE_ptr rc)
 
private sub hAssembleRcs ()
 
private sub hAssembleXpm ()
 
private function_as_integer hCompileFbctinf ()
 
private function_as_integer hArchiveFiles ()
 
private sub hSetDefaultLibPaths ()
 
private sub fbcAddDefLib (byval_as_zstring_ptr libname)
 
private sub hAddDefaultLibs ()
 
private sub hPrintOptions ()
 
private sub hAppendConfigInfo (byref_as_string config, byval_as_zstring_ptr info)
 
private sub hPrintVersion ()
 

Variables

then Invalid XPM header close
exit function end if Check for
lines containing empty 
lines
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C 
comments
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely 
handled
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely but should
automatically be 
ignored
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely but should
automatically be as long as
they don t contain strings dim
as integer 
saw_rows
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely but should
automatically be as long as
they don t contain strings dim
as integer ln Strip everything
in front of the first 
ln
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely but should
automatically be as long as
they don t contain strings dim
as integer ln Strip everything
in front of the first in a new 
line
 
then Invalid XPM header close
exit function end if Check for
lines containing empty C aren
t explicitely but should
automatically be as long as
they don t contain strings dim
as integer ln Strip everything
in front of the first in a new
separated by a 
comma
 
close Clean up the temp bas if
R wasn t given 
FALSE
 
close Clean up the temp bas if
R wasn t given FALSE 
function
 
close Clean up the temp bas if
R wasn t given FALSE asmfile 
asmfile
 
FB isn t strict about it don t
let gcc make assumptions
because they cause
incompatibilities with the ASM
backend For 
example
 
FB isn t strict about it don t
let gcc make assumptions
because they cause
incompatibilities with the ASM
backend For however with the C
backend 
with
 
FB isn t strict about it don t
let gcc make assumptions
because they cause
incompatibilities with the ASM
backend For however with the C
backend gcc ffast math
optimizes out the not even * 
o
 
FB isn t strict about it don t
let gcc make assumptions
because they cause
incompatibilities with the ASM
backend For however with the C
backend gcc ffast math
optimizes out the not even so
we need to make it *obj and
then rename it afterwards dim
as integer 
need_rename
 
static zstring toolnames [toFBCTOOL__COUNT+1] =
 
FBCCTX fbc
 
integer option_takes_argument [to[OPT__COUNT+1]+1] =
 

Macro Definition Documentation

#define ENABLE_GORC

Definition at line 16 of file fbc.bas.

#define safeKill (   f)
Value:
/* (multi line FreeBasic #MACRO)
if( kill( f ) <> 0 ) then
end if
#endmacro */

Definition at line 3363 of file fbc.bas.

Typedef Documentation

using fo = any if( len( fbc.xpm.srcfile ) = 0 ) then return TRUE end if '' Remember *.xpm file name xpmfile = fbc.xpm.srcfile '' Set *.bas name based on input file name or -o <file>: if( len( *fbc.xpm.objfile ) > 0 ) then fbc.xpm.srcfile = hStripExt( *fbc.xpm.objfile ) end if '' foo.xpm -> foo.xpm.bas to avoid collision with foo.bas fbc.xpm.srcfile &= ".bas" if( fbc.verbose ) then print "parsing xpm: ", xpmfile & " -o " & fbc.xpm.srcfile end if if( hParseXpm( xpmfile, code ) = FALSE ) then '' TODO: show error message exit function end if fo = freefile( ) if( open( fbc.xpm.srcfile, for output, as #fo ) ) then '' TODO: show error message exit function end if print #fo, code

Definition at line 2555 of file fbc.bas.

Enumeration Type Documentation

anonymous enum
Enumerator
FBCTOOL_AS 
FBCTOOL_AR 
FBCTOOL_LD 
FBCTOOL_GCC 
FBCTOOL_LLC 
FBCTOOL_DLLTOOL 
FBCTOOL_GORC 
FBCTOOL_WINDRES 
FBCTOOL_CXBE 
FBCTOOL__COUNT 

Definition at line 3331 of file fbc.bas.

anonymous enum
Enumerator
OPT_A 
OPT_ARCH 
OPT_ASM 
OPT_B 
OPT_C 
OPT_CKEEPOBJ 
OPT_D 
OPT_DLL 
OPT_DYLIB 
OPT_E 
OPT_EX 
OPT_EXX 
OPT_EXPORT 
OPT_FORCELANG 
OPT_FPMODE 
OPT_FPU 
OPT_G 
OPT_GEN 
OPT_HELP 
OPT_I 
OPT_INCLUDE 
OPT_L 
OPT_LANG 
OPT_LIB 
OPT_M 
OPT_MAP 
OPT_MAXERR 
OPT_MT 
OPT_NODEFLIBS 
OPT_NOERRLINE 
OPT_O 
OPT_OPTIMIZE 
OPT_P 
OPT_PP 
OPT_PREFIX 
OPT_PRINT 
OPT_PROFILE 
OPT_R 
OPT_RKEEPASM 
OPT_RR 
OPT_RRKEEPASM 
OPT_S 
OPT_STATIC 
OPT_T 
OPT_TARGET 
OPT_TITLE 
OPT_V 
OPT_VEC 
OPT_VERSION 
OPT_W 
OPT_WA 
OPT_WC 
OPT_WL 
OPT_X 
OPT_Z 
OPT__COUNT 

Definition at line 4397 of file fbc.bas.

Function Documentation

private function_as_integer clearDefList ( byref_as_string  deffile)

Definition at line 3666 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub fbcAddDefLib ( byval_as_zstring_ptr  libname)

Definition at line 6110 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub fbcAddDefLibPath ( byref_as_string  path)

Definition at line 3525 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub fbcAddLibPathFor ( byval_as_zstring_ptr  libname)

Definition at line 3529 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_string_ptr fbcAddObj ( byref_as_string  file)

Definition at line 3463 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub fbcAddTemp ( byref_as_string  file)

Definition at line 3459 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub fbcEnd ( byval_as_integer  errnum)

Definition at line 3436 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

sub fbcFindBin ( byval_as_integer  tool,
byref_as_string  path,
byref_as_integer  relying_on_system = FALSE 
)

Definition at line 3539 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_string fbcFindLibFile ( byval_as_zstring_ptr  file)

Definition at line 3473 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub fbcInit ( )

Definition at line 3370 of file fbc.bas.

Here is the call graph for this function:

private sub fbcInit2 ( )

Definition at line 5330 of file fbc.bas.

Here is the call graph for this function:

function_as_integer fbcRunBin ( byval_as_zstring_ptr  action,
byval_as_integer  tool,
byref_as_string  ln 
)

Definition at line 3578 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hAddBas ( byref_as_string  basfile)

Definition at line 4297 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hAddDefaultLibs ( )

Definition at line 6114 of file fbc.bas.

Here is the call graph for this function:

private sub handleArg ( byref_as_string  arg)

Definition at line 5033 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub handleOpt ( byval_as_integer  optid,
byref_as_string  arg 
)

Definition at line 4515 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hAppendConfigInfo ( byref_as_string  config,
byval_as_zstring_ptr  info 
)

Definition at line 6318 of file fbc.bas.

Here is the caller graph for this function:

private function_as_integer hArchiveFiles ( )

Definition at line 6046 of file fbc.bas.

Here is the call graph for this function:

private function_as_integer hAssembleModule ( byval_as_FBCIOFILE_ptr  module)

Definition at line 5892 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hAssembleModules ( )

Definition at line 5920 of file fbc.bas.

Here is the call graph for this function:

private function_as_integer hAssembleRc ( byval_as_FBCIOFILE_ptr  rc)

Definition at line 5930 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hAssembleRcs ( )

Definition at line 5990 of file fbc.bas.

Here is the call graph for this function:

private sub hAssembleXpm ( )

Definition at line 6001 of file fbc.bas.

Here is the call graph for this function:

private sub hCheckWaitingObjfile ( )

Definition at line 4249 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hCollectObjinfo ( )

Definition at line 4212 of file fbc.bas.

Here is the call graph for this function:

private sub hCompileBas ( byval_as_FBCIOFILE_ptr  module,
byval_as_integer  is_main,
byval_as_integer  is_fbctinf 
)

Definition at line 5504 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_integer hCompileFbctinf ( )

Definition at line 6012 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hCompileModules ( )

Definition at line 5612 of file fbc.bas.

Here is the call graph for this function:

private function_as_integer hCompileStage2Module ( byval_as_FBCIOFILE_ptr  module)

Definition at line 5786 of file fbc.bas.

Here is the call graph for this function:

private sub hCompileStage2Modules ( )

Definition at line 5882 of file fbc.bas.

Here is the call graph for this function:

private function_as_integer hCompileXpm ( )

Definition at line 5741 of file fbc.bas.

Here is the call graph for this function:

private sub hFatalInvalidOption ( byref_as_string  arg)

Definition at line 4244 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_string hFindLib ( byval_as_zstring_ptr  file)

Definition at line 3748 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_integer hGenerateEmptyDefFile ( byref_as_string  deffile)

Definition at line 3697 of file fbc.bas.

Here is the caller graph for this function:

private function_as_string hGetAsmName ( byval_as_FBCIOFILE_ptr  module,
byval_as_integer  stage 
)

Definition at line 5476 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_integer hLinkFiles ( )

Definition at line 3757 of file fbc.bas.

Here is the call graph for this function:

private sub hParseArgs ( byval_as_integer  argc,
byval_as_zstring_ptr_ptr  argv 
)

Definition at line 5211 of file fbc.bas.

Here is the call graph for this function:

private sub hParseTargetId ( byref_as_string  os,
byref_as_string  arch 
)

Definition at line 4306 of file fbc.bas.

Here is the caller graph for this function:

private function_as_integer hParseTargetOS ( byref_as_string  os)

Definition at line 4328 of file fbc.bas.

Here is the caller graph for this function:

private function_as_integer hParseXpm ( byref_as_string  xpmfile,
byref_as_string  code 
)

Definition at line 5669 of file fbc.bas.

Here is the caller graph for this function:

private sub hPrintOptions ( )

Definition at line 6248 of file fbc.bas.

private sub hPrintVersion ( )

Definition at line 6325 of file fbc.bas.

Here is the call graph for this function:

private function_as_integer hPutLdArgsIntoFile ( byref_as_string  ldcline)

Definition at line 3622 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hReadObjinfo ( )

Definition at line 4166 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hSetDefaultLibPaths ( )

Definition at line 6074 of file fbc.bas.

Here is the call graph for this function:

private sub hSetIofile ( byval_as_FBCIOFILE_ptr  module,
byref_as_string  srcfile,
byval_as_integer  is_rc 
)

Definition at line 4257 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub hSetOutName ( )

Definition at line 3398 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

then Invalid XPM header close exit function end if Check for lines containing empty C aren t explicitely but should automatically be as long as they don t contain strings dim as integer ln Strip everything in front of the first in a new separated by a if it s not the first one if ( saw_rows  )

Here is the caller graph for this function:

close Clean up the temp bas if R wasn t given if ( fbc.  keepasm = FALSE)
private function_as_integer makeImpLib ( byref_as_string  dllname,
byref_as_string  deffile 
)

Definition at line 3710 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private sub parseArgsFromFile ( byref_as_string  filename)

Definition at line 5145 of file fbc.bas.

Here is the call graph for this function:

Here is the caller graph for this function:

private function_as_integer parseOption ( byval_as_zstring_ptr  opt)

Definition at line 4903 of file fbc.bas.

Here is the caller graph for this function:

then Invalid XPM header close exit function end if Check for lines containing strings ( color and pixel  lines)
FB isn t strict about it don t let gcc make assumptions because they cause incompatibilities with the ASM backend For however with the C backend gcc ffast math optimizes out the subtraction ( even under-  O0)

Variable Documentation

close Clean up the temp bas if R wasn t given FALSE asmfile asmfile

Definition at line 2570 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty C aren t explicitely but should automatically be as long as they don t contain strings dim as integer ln Strip everything in front of the first in a new separated by a comma

Definition at line 2483 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty C comments

Definition at line 2475 of file fbc.bas.

FB isn t strict about it don t let gcc make assumptions because they cause incompatibilities with the ASM backend For example

Definition at line 2608 of file fbc.bas.

close Clean up the temp bas if R wasn t given FALSE

Definition at line 2563 of file fbc.bas.

FBCCTX fbc

Definition at line 3368 of file fbc.bas.

close Clean up the temp bas if R wasn t given FALSE function
Initial value:
end function
private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as integer
dim as string ln

Definition at line 2564 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty C aren t explicitely handled

Definition at line 2475 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty C aren t explicitely but should automatically be ignored

Definition at line 2475 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty C aren t explicitely but should automatically be as long as they don t contain strings dim as integer ln Strip everything in front of the first in a new line

Definition at line 2483 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty lines

Definition at line 2475 of file fbc.bas.

FB isn t strict about it don t let gcc make assumptions ln
Initial value:
= right( ln, len( ln ) - (instr( ln, """" ) - 1) )
'' Strip everything behind the second '"'
ln = left( ln, instr( 2, ln, """" ) )
'' Got something left?
if( len( ln ) > 0 ) then
'' Add an entry to the array

Definition at line 2483 of file fbc.bas.

FB isn t strict about it don t let gcc make assumptions because they cause incompatibilities with the ASM backend For however with the C backend gcc ffast math optimizes out the not even so we need to make it* obj and then rename it afterwards dim as integer need_rename
Initial value:
'' Ensure to use *.obj so GoRC accepts it
if( hGetFileExt( *rc->objfile ) <> "obj" ) then
*rc->objfile += ".obj"
end if
'' Change the include env var to point to the (hopefully present)
'' win/rc
enum {
PRINT_HOST,
PRINT_TARGET,
PRINT_X
}

Definition at line 2717 of file fbc.bas.

FB isn t strict about it don t let gcc make assumptions because they cause incompatibilities with the ASM backend For however with the C backend gcc ffast math optimizes out the not even* o

Definition at line 2714 of file fbc.bas.

integer option_takes_argument[to[OPT__COUNT+1]+1] =

Definition at line 4456 of file fbc.bas.

then Invalid XPM header close exit function end if Check for lines containing empty C aren t explicitely but should automatically be as long as they don t contain strings dim as integer saw_rows
Initial value:
while( eof( f ) = FALSE )
line input #f

Definition at line 2478 of file fbc.bas.

zstring toolnames[toFBCTOOL__COUNT+1] =
static

Definition at line 3344 of file fbc.bas.

FB isn t strict about it don t let gcc make assumptions because they cause incompatibilities with the ASM backend For however with the C backend with

Definition at line 2608 of file fbc.bas.