FreeBASIC  0.91.0
fb.bi
Go to the documentation of this file.
1 #ifndef __FB_BI__
2 #define __FB_BI__
3 
4 const FB_VER_MAJOR = 0
5 const FB_VER_MINOR = 91
6 const FB_VER_PATCH = 0
7 
8 
9 #define QUOTE !"\""
10 #if defined( __FB_WIN32__ ) or defined( __FB_CYGWIN__ ) or defined( __FB_DOS__ )
11  #define NEWLINE !"\r\n"
12 #else
13  #define NEWLINE !"\n"
14 #endif
15 #define RSLASH !"\\"
16 #define TABCHAR !"\t"
17 #define ESCCHAR !"\27"
18 #define LFCHAR !"\n"
19 
20 #include once "list.bi"
21 #include once "hash.bi"
22 
23 ''
24 const FB_MAXPATHLEN = 260
25 
26 const FB_MAXINCRECLEVEL = 16
27 const FB_MAXARGRECLEVEL = 8
28 const FB_MAXPRAGMARECLEVEL = 8
29 const FB_MAXNAMESPCRECLEVEL = 64
30 
31 const FB_MAXARRAYDIMS = 8
32 const FB_MAXDEFINEARGS = 32
33 
34 const FB_MAXNAMELEN = 64
35 const FB_MAXLITLEN = 1024 '' literal strings max length
36 const FB_MAXNUMLEN = 64
37 const FB_MAXOPERANDLEN = FB_MAXNAMELEN + 2 + 16 + 2 + 1
39 
40 const FB_MAXSCOPEDEPTH = 128
41 
42 const FB_DEFAULT_MAXERRORS = 10
43 
44 const FB_ERR_INFINITE = &h7fffffff
45 
46 const INVALID = -1
47 
48 ''
49 const FB_VERSION = FB_VER_MAJOR & "." & FB_VER_MINOR & "." & FB_VER_PATCH
50 const FB_BUILD_DATE = __DATE__
51 const FB_SIGN = "FreeBASIC " & FB_VERSION
52 const FB_VER_STR_MAJOR = str( FB_VER_MAJOR )
53 const FB_VER_STR_MINOR = str( FB_VER_MINOR )
54 const FB_VER_STR_PATCH = str( FB_VER_PATCH )
55 
56 '' compiler options corresponding to the FBCMMLINEOPT struct
57 '' (for use with the public fbSet/GetOption() interface)
58 enum FB_COMPOPT
59  '' compiler output file type
60  FB_COMPOPT_OUTTYPE '' FB_OUTTYPE_*
61  FB_COMPOPT_PPONLY '' boolean: TRUE for preprocessor-only mode
62 
63  '' backend, target, code generation
64  FB_COMPOPT_BACKEND '' FB_BACKEND_*
65  FB_COMPOPT_TARGET '' FB_COMPTARGET_*
66  FB_COMPOPT_CPUTYPE '' FB_CPUTYPE_*
67  FB_COMPOPT_FPUTYPE '' FB_FPUTYPE_*
68  FB_COMPOPT_FPMODE '' FB_FPMODE_*
69  FB_COMPOPT_VECTORIZE '' FB_VECTORIZELEVEL_*
70  FB_COMPOPT_OPTIMIZELEVEL '' integer, for -gen gcc's gcc -O<N>
71  FB_COMPOPT_ASMSYNTAX '' FB_ASMSYNTAX_*, for -gen gcc
72 
73  '' parser -lang mode
74  FB_COMPOPT_LANG '' FB_LANG_*: lang compatibility
75  FB_COMPOPT_FORCELANG '' boolean: TRUE if -forcelang was specified
76 
77  '' debugging/error checking
78  FB_COMPOPT_DEBUG '' boolean: -g
79  FB_COMPOPT_ERRORCHECK '' boolean: runtime error checks
80  FB_COMPOPT_RESUMEERROR '' boolean: RESUME support
81  FB_COMPOPT_EXTRAERRCHECK '' boolean: NULL pointer/array bounds checks
82  FB_COMPOPT_PROFILE '' boolean: -profile
83 
84  '' error/warning reporting behaviour
85  FB_COMPOPT_WARNINGLEVEL '' integer
86  FB_COMPOPT_SHOWERROR '' boolean: show source code line containing error?
87  FB_COMPOPT_MAXERRORS '' -maxerr integer
88  FB_COMPOPT_PEDANTICCHK '' FB_PDCHECK_* flags
89 
90  '' the rest
91  FB_COMPOPT_GOSUBSETJMP '' boolean: implement GOSUB using setjmp/longjump?
92  FB_COMPOPT_EXPORT '' boolean: export all symbols declared as EXPORT?
93  FB_COMPOPT_MSBITFIELDS '' boolean: use M$'s bitfields packing?
94  FB_COMPOPT_MULTITHREADED '' boolean: -mt
95  FB_COMPOPT_STACKSIZE '' integer
96 
98 end enum
99 
100 '' pedantic checks
101 enum FB_PDCHECK
102  FB_PDCHECK_NONE = &h00000000
103 
104  FB_PDCHECK_ESCSEQ = &h00000001
105  FB_PDCHECK_PARAMMODE = &h00000002
106  FB_PDCHECK_PARAMSIZE = &h00000004
107  FB_PDCHECK_NEXTVAR = &h00000008
108  FB_PDCHECK_CASTTONONPTR = &h00000010
109  FB_PDCHECK_SIGNEDNESS = &h00000020
110 
111  FB_PDCHECK_ALL = &hffffffff
112 
114 end enum
115 
116 '' cpu types
117 '' When changing, update fb.bas:cputypeinfo()
118 enum FB_CPUTYPE
119  FB_CPUTYPE_386 = 0
133  FB_CPUTYPE_32 '' just to identify -arch 32/64, as a shortcut for the default arch for 32/64bit
137 end enum
138 
139 '' fpu types
140 enum FB_FPUTYPE
143 end enum
144 
145 '' floating-point modes
146 enum FB_FPMODE
149 end enum
150 
153 
155  FB_VECTORIZE_NONE '' no vectorization
156  FB_VECTORIZE_NORMAL '' complete expression merging
157  FB_VECTORIZE_INTRATREE '' intra-expression merging
158  FB_VECTORIZE_SUBEXPRESSION '' sub-expression merging (not implemented yet)
159 end enum
160 
162 
163 '' output file type
164 enum FB_OUTTYPE
169 end enum
170 
172 
173 '' target platform
174 enum FB_COMPTARGET
185 end enum
186 
187 '' languages (update the fb.bas::langTb() array when changing this list)
188 enum FB_LANG
189  FB_LANG_INVALID = -1
190 
191  FB_LANG_FB = 0
194  FB_LANG_QB
195 
196  FB_LANGS
197 end enum
198 
200 
201 ''
202 enum FB_BACKEND
206 
208 end enum
209 
210 enum FB_ASMSYNTAX
213 end enum
214 
215 '' Compiler internal settings, same order as FB_COMPOPT_*
216 type FBCMMLINEOPT
217  '' compiler output file type
219  pponly as integer '' TRUE for preprocessor-only mode
220 
221  '' backend, target, code generation
222  backend as FB_BACKEND '' backend (-gen gas/gcc)
223  target as FB_COMPTARGET '' target platform
224  cputype as FB_CPUTYPE '' target CPU architecture
225  fputype as FB_FPUTYPE '' target FPU
226  fpmode as FB_FPMODE '' precise or fast fp mode (SSE+ only)
227  vectorize as FB_VECTORIZELEVEL '' enable automatic vectorization
228  optlevel as integer '' -gen gcc optimization level (gcc -O<N>)
229  asmsyntax as FB_ASMSYNTAX '' asm syntax mode for -gen gcc
230 
231  '' parser -lang mode
232  lang as FB_LANG '' lang compatibility
233  forcelang as integer '' TRUE if -forcelang was specified
234 
235  '' debugging/error checking
236  debug as integer '' true = add debug info (default = false)
237  errorcheck as integer '' enable runtime error checks?
238  resumeerr as integer '' enable RESUME support?
239  extraerrchk as integer '' enable NULL pointer/array bounds checks?
240  profile as integer '' build profiling code (default = false)
241 
242  '' error/warning reporting behaviour
243  warninglevel as integer '' (default = 0)
244  showerror as integer '' show line giving error (default = true)
245  maxerrors as integer '' max number errors the parser will show
246  pdcheckopt as FB_PDCHECK '' pedantic checks
247 
248  '' the rest
249  gosubsetjmp as integer '' implement GOSUB using setjmp/longjump? (default = false)
250  export as integer '' export all symbols declared as EXPORT (default = true)
251  msbitfields as integer '' use M$'s bitfields packing
252  multithreaded as integer '' link against thread-safe runtime library (default = false)
253  stacksize as integer
254 end type
255 
256 '' features allowed in the selected language
257 enum FB_LANG_OPT
258  FB_LANG_OPT_MT = &h00000001
259  FB_LANG_OPT_SCOPE = &h00000002
260  FB_LANG_OPT_NAMESPC = &h00000004
261  FB_LANG_OPT_EXTERN = &h00000008
262  FB_LANG_OPT_FUNCOVL = &h00000010
263  FB_LANG_OPT_OPEROVL = &h00000020
264  FB_LANG_OPT_CLASS = &h00000040
265  FB_LANG_OPT_INITIALIZER = &h00000080
266  FB_LANG_OPT_SINGERRLINE = &h00000100
267 
268  FB_LANG_OPT_ALWAYSOVL = &h00000400
269  FB_LANG_OPT_AUTOVAR = &h00000800
270 
271  FB_LANG_OPT_GOSUB = &h00010000
272  FB_LANG_OPT_CALL = &h00020000
273  FB_LANG_OPT_LET = &h00040000
274  FB_LANG_OPT_PERIODS = &h00080000
275  FB_LANG_OPT_NUMLABEL = &h00100000
276  FB_LANG_OPT_IMPLICIT = &h00200000
277  FB_LANG_OPT_DEFTYPE = &h00400000
278  FB_LANG_OPT_SUFFIX = &h00800000
279  FB_LANG_OPT_METACMD = &h01000000
280  FB_LANG_OPT_OPTION = &h02000000
281 
282  FB_LANG_OPT_ONERROR = &h08000000
283 
284  FB_LANG_OPT_QUIRKFUNC = &h20000000
285 end enum
286 
287 #if defined(__FB_WIN32__)
288 const FB_HOST = "win32"
289 const FB_HOST_EXEEXT = ".exe"
290 const FB_HOST_PATHDIV = RSLASH
292 #elseif defined(__FB_CYGWIN__)
293 const FB_HOST = "cygwin"
294 const FB_HOST_EXEEXT = ".exe"
295 const FB_HOST_PATHDIV = "/"
297 #elseif defined(__FB_LINUX__)
298 const FB_HOST = "linux"
299 const FB_HOST_EXEEXT = ""
300 const FB_HOST_PATHDIV = "/"
302 #elseif defined(__FB_DOS__)
303 const FB_HOST = "dos"
304 const FB_HOST_EXEEXT = ".exe"
305 const FB_HOST_PATHDIV = RSLASH
307 #elseif defined(__FB_FREEBSD__)
308 const FB_HOST = "freebsd"
309 const FB_HOST_EXEEXT = ""
310 const FB_HOST_PATHDIV = "/"
312 #elseif defined(__FB_OPENBSD__)
313 const FB_HOST = "openbsd"
314 const FB_HOST_EXEEXT = ""
315 const FB_HOST_PATHDIV = "/"
317 #elseif defined(__FB_DARWIN__)
318 const FB_HOST = "darwin"
319 const FB_HOST_EXEEXT = ""
320 const FB_HOST_PATHDIV = "/"
322 #elseif defined(__FB_NETBSD__)
323 const FB_HOST = "netbsd"
324 const FB_HOST_EXEEXT = ""
325 const FB_HOST_PATHDIV = "/"
327 #else
328 #error Unsupported host
329 #endif
330 
331 #ifdef __FB_64BIT__
334 #else
337 #endif
338 
341 
342 '' info section
343 const FB_INFOSEC_NAME = "fbctinf"
344 const FB_INFOSEC_OBJNAME = "__fb_ct.inf"
345 #ifdef __FB_DOS__
346  const FB_INFOSEC_BASNAME = "__fb_ct.bas"
347 #else
348  const FB_INFOSEC_BASNAME = "__fb_ct.inf.bas"
349 #endif
350 
351 #include once "error.bi"
352 
353 declare sub fbInit(byval ismain as integer, byval restarts as integer)
354 declare sub fbEnd()
355 
356 declare sub fbCompile _
357  ( _
358  byval infname as zstring ptr, _
359  byval outfname as zstring ptr, _
360  byref pponlyfile as string, _
361  byval ismain as integer _
362  )
363 
364 declare function fbShouldRestart() as integer
365 declare function fbShouldContinue() as integer
366 
367 declare sub fbGlobalInit()
368 declare sub fbAddIncludePath(byref path as string)
369 declare sub fbAddPreDefine(byref def as string)
370 declare sub fbAddPreInclude(byref file as string)
371 
372 declare sub fbSetOption( byval opt as integer, byval value as integer )
373 declare function fbGetOption( byval opt as integer ) as integer
374 
375 declare sub fbChangeOption(byval opt as integer, byval value as integer)
376 declare sub fbSetLibs(byval libs as TSTRSET ptr, byval libpaths as TSTRSET ptr)
377 declare sub fbGetLibs(byval libs as TSTRSET ptr, byval libpaths as TSTRSET ptr)
378 declare sub fbPragmaOnce()
379 declare sub fbIncludeFile(byval filename as zstring ptr, byval isonce as integer)
380 
381 declare function fbGetTargetId( ) as zstring ptr
382 declare function fbGetGccArch( ) as zstring ptr
383 declare function fbGetFbcArch( ) as zstring ptr
384 declare function fbCpuTypeIs64bit( ) as integer
385 declare function fbCpuTypeIsX86( ) as integer
386 declare function fbIdentifyFbcArch( byref fbcarch as string ) as integer
387 
388 declare function fbGetEntryPoint _
389  ( _
390  ) as string
391 
392 declare function fbGetModuleEntry _
393  ( _
394  ) as string
395 
396 declare function fbIsCrossComp _
397  ( _
398  ) as integer
399 
400 declare sub fbGetDefaultLibs _
401  ( _
402  byval dstlist as TLIST ptr, _
403  byval dsthash as THASH ptr _
404  )
405 
406 declare sub fbMainBegin _
407  ( _
408  )
409 
410 declare sub fbMainEnd _
411  ( _
412  )
413 
414 declare function fbGetLangOptions _
415  ( _
416  byval lang as FB_LANG _
417  ) as FB_LANG_OPT
418 
419 declare function fbGetLangName _
420  ( _
421  byval lang as FB_LANG _
422  ) as string
423 
424 declare function fbGetLangId _
425  ( _
426  byval txt as zstring ptr _
427  ) as FB_LANG
428 
429 
430 ''
431 '' macros
432 ''
433 
434 #define fbLangOptIsSet( op ) ((env.lang.opt and (op)) <> 0)
435 
436 #define fbLangIsSet( op ) (env.clopt.lang = op)
437 
438 #define fbPdCheckIsSet( op ) ((env.clopt.pdcheckopt and (op)) <> 0)
439 
440 
441 #endif '' __FB_BI__
442