34 FB_LANG_OPT_SCOPE
or _
35 FB_LANG_OPT_NAMESPC
or _
36 FB_LANG_OPT_EXTERN
or _
37 FB_LANG_OPT_FUNCOVL
or _
38 FB_LANG_OPT_OPEROVL
or _
39 FB_LANG_OPT_CLASS
or _
40 FB_LANG_OPT_INITIALIZER
or _
41 FB_LANG_OPT_AUTOVAR
or _
42 FB_LANG_OPT_SINGERRLINE
or _
43 FB_LANG_OPT_QUIRKFUNC _
49 FB_LANG_OPT_SCOPE
or _
50 FB_LANG_OPT_NAMESPC
or _
51 FB_LANG_OPT_EXTERN
or _
52 FB_LANG_OPT_FUNCOVL
or _
53 FB_LANG_OPT_INITIALIZER
or _
56 FB_LANG_OPT_PERIODS
or _
57 FB_LANG_OPT_NUMLABEL
or _
58 FB_LANG_OPT_IMPLICIT
or _
59 FB_LANG_OPT_DEFTYPE
or _
60 FB_LANG_OPT_SUFFIX
or _
61 FB_LANG_OPT_METACMD
or _
62 FB_LANG_OPT_OPTION
or _
63 FB_LANG_OPT_ONERROR
or _
64 FB_LANG_OPT_QUIRKFUNC _
70 FB_LANG_OPT_NAMESPC
or _
71 FB_LANG_OPT_EXTERN
or _
72 FB_LANG_OPT_FUNCOVL
or _
73 FB_LANG_OPT_INITIALIZER
or _
74 FB_LANG_OPT_GOSUB
or _
77 FB_LANG_OPT_PERIODS
or _
78 FB_LANG_OPT_NUMLABEL
or _
79 FB_LANG_OPT_IMPLICIT
or _
80 FB_LANG_OPT_DEFTYPE
or _
81 FB_LANG_OPT_SUFFIX
or _
82 FB_LANG_OPT_METACMD
or _
83 FB_LANG_OPT_OPTION
or _
84 FB_LANG_OPT_ONERROR
or _
85 FB_LANG_OPT_QUIRKFUNC _
90 FB_LANG_OPT_GOSUB
or _
93 FB_LANG_OPT_PERIODS
or _
94 FB_LANG_OPT_NUMLABEL
or _
95 FB_LANG_OPT_IMPLICIT
or _
96 FB_LANG_OPT_DEFTYPE
or _
97 FB_LANG_OPT_SUFFIX
or _
98 FB_LANG_OPT_METACMD
or _
99 FB_LANG_OPT_OPTION
or _
100 FB_LANG_OPT_ONERROR
or _
101 FB_LANG_OPT_QUIRKFUNC _
110 FB_DATATYPE_ULONGINT, _
111 FB_DATATYPE_USHORT, _
112 FB_FUNCMODE_STDCALL, _
113 FB_FUNCMODE_STDCALL, _
114 0
or FB_TARGETOPT_UNDERSCORE _
115 or FB_TARGETOPT_EXPORT _
116 or FB_TARGETOPT_RETURNINREGS _
121 FB_DATATYPE_ULONGINT, _
122 FB_DATATYPE_USHORT, _
123 FB_FUNCMODE_STDCALL, _
124 FB_FUNCMODE_STDCALL, _
125 0
or FB_TARGETOPT_UNIX _
126 or FB_TARGETOPT_UNDERSCORE _
127 or FB_TARGETOPT_EXPORT _
128 or FB_TARGETOPT_RETURNINREGS _
136 FB_FUNCMODE_STDCALL_MS, _
137 0
or FB_TARGETOPT_UNIX _
138 or FB_TARGETOPT_CALLEEPOPSHIDDENPTR _
146 FB_FUNCMODE_STDCALL_MS, _
147 0
or FB_TARGETOPT_UNDERSCORE _
148 or FB_TARGETOPT_CALLEEPOPSHIDDENPTR _
155 FB_FUNCMODE_STDCALL, _
156 FB_FUNCMODE_STDCALL, _
157 0
or FB_TARGETOPT_UNDERSCORE _
158 or FB_TARGETOPT_RETURNINREGS _
166 FB_FUNCMODE_STDCALL_MS, _
167 0
or FB_TARGETOPT_UNIX _
168 or FB_TARGETOPT_CALLEEPOPSHIDDENPTR _
169 or FB_TARGETOPT_RETURNINREGS _
177 FB_FUNCMODE_STDCALL_MS, _
178 0
or FB_TARGETOPT_UNIX _
179 or FB_TARGETOPT_CALLEEPOPSHIDDENPTR _
180 or FB_TARGETOPT_RETURNINREGS _
188 FB_FUNCMODE_STDCALL_MS, _
189 0
or FB_TARGETOPT_UNIX _
190 or FB_TARGETOPT_CALLEEPOPSHIDDENPTR _
191 or FB_TARGETOPT_RETURNINREGS _
199 FB_FUNCMODE_STDCALL_MS, _
200 0
or FB_TARGETOPT_UNIX _
201 or FB_TARGETOPT_CALLEEPOPSHIDDENPTR _
202 or FB_TARGETOPT_RETURNINREGS _
215 ( @
"i386" , @
"386" , TRUE , 32 ), _
216 ( @
"i486" , @
"486" , TRUE , 32 ), _
217 ( @
"i586" , @
"586" , TRUE , 32 ), _
218 ( @
"i686" , @
"686" , TRUE , 32 ), _
219 ( @
"athlon" , @
"athlon" , TRUE , 32 ), _
220 ( @
"athlon-xp" , @
"athlon-xp" , TRUE , 32 ), _
221 ( @
"athlon-fx" , @
"athlon-fx" , TRUE , 32 ), _
222 ( @
"k8-sse3" , @
"k8-sse3" , TRUE , 32 ), _
223 ( @
"pentium-mmx", @
"pentium-mmx" , TRUE , 32 ), _
224 ( @
"pentium2" , @
"pentium2" , TRUE , 32 ), _
225 ( @
"pentium3" , @
"pentium3" , TRUE , 32 ), _
226 ( @
"pentium4" , @
"pentium4" , TRUE , 32 ), _
227 ( @
"prescott" , @
"pentium4-sse3", TRUE , 32 ), _
228 ( @
"x86-64" , @
"x86-64" , FALSE, 64 ), _
229 ( NULL , @
"32" , FALSE, 32 ), _
230 ( NULL , @
"64" , FALSE, 64 ), _
231 ( NULL , NULL , FALSE, 0 ) _
241 byval incfilehash
as THASH
ptr, _
243 )
as zstring ptr static
247 #if defined(
__FB_WIN32__ )
or defined(
__FB_DOS__ )
260 byval incfilehash
as THASH
ptr, _
262 )
as zstring ptr static
264 dim as zstring ptr fname, res
265 dim as uinteger index
268 #if defined(
__FB_WIN32__ )
or defined(
__FB_DOS__ )
277 if( res = NULL )
then
278 hashAdd( incfilehash, fname, fname, index )
291 byval lang
as FB_LANG _
301 byval lang
as FB_LANG _
308 sub fbInit(
byval ismain
as integer,
byval restarts
as integer )
310 strsetInit( @env.libpaths, FB_INITLIBNODES \ 4 )
312 env.restarts = restarts
313 env.dorestart = FALSE
315 redim infileTb( 0
to FB_MAXINCRECLEVEL-1 )
320 env.opt.
explicit = (env.clopt.lang = FB_LANG_FB)
323 if( env.clopt.lang <> FB_LANG_QB )
then
325 env.lang.integerkeyworddtype = FB_DATATYPE_INTEGER
329 env.lang.int15literaldtype = FB_DATATYPE_INTEGER
330 env.lang.int16literaldtype = FB_DATATYPE_UINT
331 env.lang.int31literaldtype = FB_DATATYPE_INTEGER
332 env.lang.int32literaldtype = FB_DATATYPE_UINT
333 env.lang.floatliteraldtype = FB_DATATYPE_DOUBLE
338 env.lang.integerkeyworddtype = FB_DATATYPE_SHORT
343 env.lang.int15literaldtype = FB_DATATYPE_SHORT
344 env.lang.int16literaldtype = FB_DATATYPE_USHORT
345 env.lang.int31literaldtype = FB_DATATYPE_LONG
346 env.lang.int32literaldtype = FB_DATATYPE_ULONG
347 env.lang.floatliteraldtype = FB_DATATYPE_SINGLE
350 env.opt.parammode = FB_PARAMMODE_BYREF
351 env.opt.procpublic = TRUE
352 env.opt.escapestr = FALSE
353 env.opt.
dynamic = FALSE
355 env.opt.
gosub = (env.clopt.lang = FB_LANG_QB)
357 env.fbctinf_started = FALSE
366 env.wchar_doconv = (
sizeof(
wstring ) = typeGetSize( env.target.wchar ))
367 env.pointersize = typeGetSize( typeAddrOf( FB_DATATYPE_VOID ) )
369 hashInit( @env.incfilehash, FB_INITINCFILES )
370 hashInit( @env.inconcehash, FB_INITINCFILES )
372 stackNew( @parser.stmt.stk, FB_INITSTMTSTACKNODES,
len( FB_CMPSTMTSTK ), FALSE )
408 if( env.clopt.backend = FB_BACKEND_GAS )
then
409 env.clopt.asmsyntax = FB_ASMSYNTAX_INTEL
411 env.clopt.asmsyntax = FB_ASMSYNTAX_ATT
421 env.clopt.outtype = FB_DEFAULT_OUTTYPE
422 env.clopt.pponly = FALSE
424 env.clopt.backend = FB_DEFAULT_BACKEND
425 env.clopt.target = FB_DEFAULT_TARGET
426 env.clopt.cputype = FB_DEFAULT_CPUTYPE
427 env.clopt.fputype = FB_DEFAULT_FPUTYPE
428 env.clopt.fpmode = FB_DEFAULT_FPMODE
429 env.clopt.vectorize = FB_DEFAULT_VECTORIZELEVEL
430 env.clopt.optlevel = 0
432 env.clopt.lang = FB_DEFAULT_LANG
433 env.clopt.forcelang = FALSE
435 env.clopt.debug = FALSE
436 env.clopt.errorcheck = FALSE
437 env.clopt.extraerrchk = FALSE
438 env.clopt.resumeerr = FALSE
439 env.clopt.profile = FALSE
441 env.clopt.warninglevel = 0
442 env.clopt.showerror = TRUE
443 env.clopt.maxerrors = FB_DEFAULT_MAXERRORS
444 env.clopt.pdcheckopt = FB_PDCHECK_NONE
446 env.clopt.gosubsetjmp = FALSE
447 env.clopt.
export = FALSE
448 env.clopt.multithreaded = FALSE
449 env.clopt.msbitfields = FALSE
450 env.clopt.stacksize = FB_DEFSTACKSIZE
470 select case as const( opt )
471 case FB_COMPOPT_OUTTYPE
472 env.clopt.outtype = value
473 case FB_COMPOPT_PPONLY
474 env.clopt.pponly = value
476 case FB_COMPOPT_BACKEND
477 env.clopt.backend = value
479 case FB_COMPOPT_TARGET
480 env.clopt.target = value
482 case FB_COMPOPT_CPUTYPE
483 env.clopt.cputype = value
484 case FB_COMPOPT_FPUTYPE
485 env.clopt.fputype = value
486 case FB_COMPOPT_FPMODE
487 env.clopt.fpmode = value
488 case FB_COMPOPT_VECTORIZE
489 env.clopt.vectorize = value
490 case FB_COMPOPT_OPTIMIZELEVEL
491 env.clopt.optlevel = value
492 case FB_COMPOPT_ASMSYNTAX
493 env.clopt.asmsyntax = value
496 env.clopt.lang = value
498 case FB_COMPOPT_FORCELANG
499 env.clopt.forcelang = value
501 case FB_COMPOPT_DEBUG
502 env.clopt.debug = value
503 case FB_COMPOPT_ERRORCHECK
504 env.clopt.errorcheck = value
505 case FB_COMPOPT_RESUMEERROR
506 env.clopt.resumeerr = value
507 case FB_COMPOPT_EXTRAERRCHECK
508 env.clopt.extraerrchk = value
509 case FB_COMPOPT_PROFILE
510 env.clopt.profile = value
512 case FB_COMPOPT_WARNINGLEVEL
513 env.clopt.warninglevel = value
514 case FB_COMPOPT_SHOWERROR
515 env.clopt.showerror = value
516 case FB_COMPOPT_MAXERRORS
517 env.clopt.maxerrors = value
518 case FB_COMPOPT_PEDANTICCHK
519 env.clopt.pdcheckopt = value
521 case FB_COMPOPT_GOSUBSETJMP
522 env.clopt.gosubsetjmp = value
523 case FB_COMPOPT_EXPORT
524 env.clopt.
export = value
525 case FB_COMPOPT_MSBITFIELDS
526 env.clopt.msbitfields = value
527 case FB_COMPOPT_MULTITHREADED
528 env.clopt.multithreaded = value
529 case FB_COMPOPT_STACKSIZE
530 env.clopt.stacksize = value
531 if (env.clopt.stacksize < FB_MINSTACKSIZE)
then
532 env.clopt.stacksize = FB_MINSTACKSIZE
538 select case as const( opt )
539 case FB_COMPOPT_OUTTYPE
540 function = env.clopt.outtype
541 case FB_COMPOPT_PPONLY
542 function = env.clopt.pponly
544 case FB_COMPOPT_BACKEND
545 function = env.clopt.backend
546 case FB_COMPOPT_TARGET
547 function = env.clopt.target
548 case FB_COMPOPT_CPUTYPE
549 function = env.clopt.cputype
550 case FB_COMPOPT_FPUTYPE
551 function = env.clopt.fputype
552 case FB_COMPOPT_FPMODE
553 function = env.clopt.fpmode
554 case FB_COMPOPT_VECTORIZE
555 function = env.clopt.vectorize
556 case FB_COMPOPT_OPTIMIZELEVEL
557 function = env.clopt.optlevel
558 case FB_COMPOPT_ASMSYNTAX
559 function = env.clopt.asmsyntax
562 function = env.clopt.lang
563 case FB_COMPOPT_FORCELANG
564 function = env.clopt.forcelang
566 case FB_COMPOPT_DEBUG
567 function = env.clopt.debug
568 case FB_COMPOPT_ERRORCHECK
569 function = env.clopt.errorcheck
570 case FB_COMPOPT_RESUMEERROR
571 function = env.clopt.resumeerr
572 case FB_COMPOPT_EXTRAERRCHECK
573 function = env.clopt.extraerrchk
574 case FB_COMPOPT_PROFILE
575 function = env.clopt.profile
577 case FB_COMPOPT_WARNINGLEVEL
578 function = env.clopt.warninglevel
579 case FB_COMPOPT_SHOWERROR
580 function = env.clopt.showerror
581 case FB_COMPOPT_MAXERRORS
582 function = env.clopt.maxerrors
583 case FB_COMPOPT_PEDANTICCHK
584 function = env.clopt.pdcheckopt
586 case FB_COMPOPT_GOSUBSETJMP
587 function = env.clopt.gosubsetjmp
588 case FB_COMPOPT_EXPORT
589 function = env.clopt.
export
590 case FB_COMPOPT_MSBITFIELDS
591 function = env.clopt.msbitfields
592 case FB_COMPOPT_MULTITHREADED
593 function = env.clopt.multithreaded
594 case FB_COMPOPT_STACKSIZE
595 function = env.clopt.stacksize
604 select case as const opt
605 case FB_COMPOPT_MSBITFIELDS
612 if( parser.
scope <> FB_MAINSCOPE )
then
614 if( fbIsModLevel( ) = FALSE )
then
617 errReport( FB_ERRMSG_ILLEGALINSIDEASCOPE )
623 if( env.clopt.forcelang )
then
628 if( env.restarts = 0 )
then
659 function = (env.clopt.target <> FB_DEFAULT_TARGET)
664 function = env.target.id
688 function = FB_DEFAULT_CPUTYPE
691 select case( fb_CpuDetect( )
shr 28 )
692 case 3 :
function = FB_CPUTYPE_386
693 case 4 :
function = FB_CPUTYPE_486
694 case 5 :
function = FB_CPUTYPE_586
695 case 6 :
function = FB_CPUTYPE_686
702 return FB_DEFAULT_CPUTYPE32
704 return FB_DEFAULT_CPUTYPE64
707 for i
as integer = 0
to FB_CPUTYPE__COUNT-1
715 case "x86_64",
"amd64"
716 function = FB_CPUTYPE_X86_64
726 if (env.clopt.target = FB_COMPTARGET_XBOX)
then
727 function =
"XBoxStartup"
742 function =
"fb_ctor__" + sname
752 s =
hCurDir( ) + FB_HOST_PATHDIV
768 dim as string defid, deftext
769 dim as string ptr def =
listGetHead(@env.predefines)
771 dim as integer idlength =
instr(*def,
"=") - 1
772 if (idlength < 0)
then
776 defid =
left(*def, idlength)
777 deftext =
right(*def,
len(*def) - idlength - 1)
782 if (
len(deftext) = 0)
then
794 dim as string ptr file =
listGetHead(@env.preincludes)
802 if( env.fbctinf_started = FALSE )
then
803 env.fbctinf_started = TRUE
804 irEmitFBCTINFBEGIN( )
806 irEmitFBCTINFSTRING( value )
810 dim as TSTRSETITEM
ptr i =
any
815 assert( env.fbctinf_started = FALSE )
821 if( i->userdata = FALSE )
then
832 if( i->userdata = FALSE )
then
840 if( env.clopt.multithreaded )
then
846 if( env.clopt.lang <> FB_LANG_FB )
then
851 if( env.fbctinf_started )
then
858 byval infname
as zstring ptr, _
859 byval outfname
as zstring ptr, _
860 byref pponlyfile
as string, _
861 byval ismain
as integer _
866 env.inf.
name = *infname
868 env.inf.incfile = NULL
869 env.inf.ismain = ismain
871 env.outf.
name = *outfname
872 env.outf.ismain = ismain
880 env.inf.num =
freefile
881 if(
open( *infname,
for binary,
access read,
as #env.inf.num ) <> 0 )
then
882 errReportEx( FB_ERRMSG_FILEACCESSERROR, infname, -1 )
889 if( irEmitBegin( ) = FALSE )
then
895 env.ppfile_num =
freefile( )
896 if(
open( pponlyfile,
for output,
as #env.ppfile_num ) <> 0 )
then
897 errReportEx( FB_ERRMSG_FILEACCESSERROR, pponlyfile, -1 )
921 if( env.clopt.outtype = FB_OUTTYPE_OBJECT )
then
930 if( env.ppfile_num > 0 )
then
931 close #env.ppfile_num
947 return ((env.dorestart = FALSE)
and (
errGetCount() < env.clopt.maxerrors))
950 sub fbSetLibs(
byval libs
as TSTRSET
ptr,
byval libpaths
as TSTRSET
ptr)
955 sub fbGetLibs(
byval libs
as TSTRSET
ptr,
byval libpaths
as TSTRSET
ptr)
961 if( env.inf.
name >
"" )
then
973 if( path = NULL )
then
977 #if defined(
__FB_WIN32__ )
or defined(
__FB_DOS__ )
978 if( path[1] =
asc(
":") )
then
981 if( (path[0] =
asc(
"/"))
or (path[0] =
asc(RSLASH)) )
then
983 if( (path[1] =
asc(
"/"))
or (path[1] =
asc(RSLASH)) )
then
992 function = (path[0] =
asc(
"/"))
1005 if( path[0] = NULL )
then
1012 #if defined(
__FB_WIN32__ )
or defined(
__FB_DOS__ )
1015 if( path[1] =
asc(
":") )
then
1018 if( (path[0] =
asc(
"/"))
or (path[0] =
asc(RSLASH)) )
then
1021 if( (path[1] =
asc(
"/"))
or (path[1] =
asc(RSLASH)) )
then
1038 static cidx(0
to FB_MAXPATHLEN \ 2)
as integer =
any
1039 dim as integer stk =
any
1040 dim as integer s =
any
1041 dim as integer n =
any
1042 dim as integer d =
any
1043 dim as integer r =
any
1044 dim as integer w =
any
1045 dim as integer c =
any
1058 for r = s
to len( *path ) - 1
1063 if( (c =
asc(
"/"))
or (c =
asc(RSLASH)) )
then
1072 elseif( (d = 1)
and (n = 1) )
then
1077 elseif( (d = 2)
and (n = 2) )
then
1101 if( c =
asc(
".") )
then
1121 static as zstring * FB_MAXPATHLEN incfile
1122 dim as zstring ptr fileidx
1124 if( env.includerec >= FB_MAXINCRECLEVEL )
then
1140 dim as string ptr path =
listGetHead(@env.includepaths)
1142 incfile = *path + FB_HOST_PATHDIV + *
filename
1150 if (path = NULL)
then
1163 incfile =
hCurDir( ) + FB_HOST_PATHDIV + incfile
1168 errReportEx( FB_ERRMSG_FILENOTFOUND, QUOTE + incfile + QUOTE )
1175 errReportEx( FB_ERRMSG_FILENOTFOUND, QUOTE + incfile + QUOTE )
1185 if(
hFindIncFile( @env.incfilehash, incfile ) <> NULL )
then
1191 if(
hFindIncFile( @env.inconcehash, incfile ) <> NULL )
then
1196 fileidx =
hAddIncFile( @env.incfilehash, incfile )
1202 env.inf.
name = incfile
1203 env.inf.incfile = fileidx
1206 env.inf.num =
freefile
1207 if(
open( incfile,
for binary,
access read,
as #env.inf.num ) <> 0 )
then
1228 env.inf =
infileTb( env.includerec )
1234 byval txt
as zstring ptr _
1237 select case lcase(*txt)
1239 function = FB_LANG_FB
1241 function = FB_LANG_FB_DEPRECATED
1243 function = FB_LANG_FB_FBLITE
1245 function = FB_LANG_QB
1247 function = FB_LANG_INVALID