FreeBASIC  0.91.0
fbint.bi
Go to the documentation of this file.
1 #ifndef __FBINT_BI__
2 #define __FBINT_BI__
3 
4 ''
5 '' internal compiler definitions
6 ''
7 
8 #include once "fb.bi"
9 
10 const FB_MINSTACKSIZE = 32 * 1024
11 const FB_DEFSTACKSIZE = 1024 * 1024
12 
13 const FB_MAXINTNAMELEN = 1 + FB_MAXNAMELEN + 1 + 1 + 2
14 const FB_MAXINTLITLEN = FB_MAXLITLEN + 32
15 
16 const FB_MAXGOTBITEMS = 64
17 
18 ''
19 const FB_INITSYMBOLNODES = 8000
20 const FB_INITFIELDNODES = 16
21 const FB_INITDEFARGNODES = 500
22 const FB_INITDEFTOKNODES = 1000
23 const FB_INITDIMNODES = 400
24 const FB_INITLIBNODES = 20
25 const FB_INITFWDREFNODES = 500
26 const FB_INITVARININODES = 1000
27 const FB_INITINCFILES = 256
28 const FB_INITSTMTSTACKNODES = 128
29 
30 '' DATA stmt internal format
31 enum FB_DATASTMT_ID
32  FB_DATASTMT_ID_NULL = &h0000
33  FB_DATASTMT_ID_WSTR = &h8000 '' start point
34  FB_DATASTMT_ID_LINK = &hffff
35  FB_DATASTMT_ID_OFFSET = &hfffe
36 
37  FB_DATASTMT_ID_ZSTR = &h0001 '' used by AST only
38  FB_DATASTMT_ID_CONST = &h0002 '' /
39 end enum
40 
41 const FB_DATASTMT_PREFIX = "_{fbdata}_"
42 
43 
44 '' print modes (same as in rtlib/fb_console.h)
45 enum FBPRINTMASK
46  FB_PRINTMASK_NEWLINE = &h00000001
47  FB_PRINTMASK_PAD = &h00000002
48  FB_PRINTMASK_APPEND_SPACE = &h00000010
49  FB_PRINTMASK_ISLAST = &h80000000
50 end enum
51 
52 '' file constants (same as in rtlib/fb_file.h)
53 enum FBFILEMODE
59 end enum
60 
61 enum FBFILEACCESS
66 end enum
67 
68 enum FBFILELOCK
73 end enum
74 
75 enum FBOPENKIND
84 end enum
85 
86 '' FB runtime errors (same as rtlib/fb_error.h)
87 enum FB_RTERROR
88  FB_RTERROR_OK = 0
106 end enum
107 
108 ''
109 const FB_MAINSCOPE = 0
110 const FB_MAINPROCNAME = "__FB_MAINPROC__"
111 const FB_MODLEVELNAME = "__FB_MODLEVELPROC__"
112 const FB_GLOBCTORNAME = "_GLOBAL__I"
113 const FB_GLOBDTORNAME = "_GLOBAL__D"
114 
115 const FB_INSTANCEPTR = "THIS"
116 
117 ''
118 ''
119 ''
120 
121 '' some chars
122 const CHAR_NULL = 00, _
123  CHAR_BELL = 07, _
124  CHAR_BKSPC = 08, _
125  CHAR_TAB = 09, _
126  CHAR_LF = 10, _
127  CHAR_VTAB = 11, _
128  CHAR_FORMFEED = 12, _
129  CHAR_CR = 13, _
130  CHAR_SPACE = 32, _
131  CHAR_0 = 48, _
132  CHAR_1 = 49, _
133  CHAR_2 = 50, _
134  CHAR_3 = 51, _
135  CHAR_4 = 52, _
136  CHAR_5 = 53, _
137  CHAR_6 = 54, _
138  CHAR_7 = 55, _
139  CHAR_8 = 56, _
140  CHAR_9 = 57, _
141  CHAR_AUPP = 65, CHAR_ALOW = 97, _
142  CHAR_BUPP = 66, CHAR_BLOW = 98, _
143  CHAR_CUPP = 67, CHAR_CLOW = 99, _
144  CHAR_DUPP = 68, CHAR_DLOW = 100, _
145  CHAR_EUPP = 69, CHAR_ELOW = 101, _
146  CHAR_FUPP = 70, CHAR_FLOW = 102, _
147  CHAR_GUPP = 71, CHAR_GLOW = 103, _
148  CHAR_HUPP = 72, CHAR_HLOW = 104, _
149  CHAR_IUPP = 73, CHAR_ILOW = 105, _
150  CHAR_JUPP = 74, CHAR_JLOW = 106, _
151  CHAR_KUPP = 75, CHAR_KLOW = 107, _
152  CHAR_LUPP = 76, CHAR_LLOW = 108, _
153  CHAR_MUPP = 77, CHAR_MLOW = 109, _
154  CHAR_NUPP = 78, CHAR_NLOW = 110, _
155  CHAR_OUPP = 79, CHAR_OLOW = 111, _
156  CHAR_PUPP = 80, CHAR_PLOW = 112, _
157  CHAR_QUPP = 81, CHAR_QLOW = 113, _
158  CHAR_RUPP = 82, CHAR_RLOW = 114, _
159  CHAR_SUPP = 83, CHAR_SLOW = 115, _
160  CHAR_TUPP = 84, CHAR_TLOW = 116, _
161  CHAR_UUPP = 85, CHAR_ULOW = 117, _
162  CHAR_VUPP = 86, CHAR_VLOW = 118, _
163  CHAR_WUPP = 87, CHAR_WLOW = 119, _
164  CHAR_XUPP = 88, CHAR_XLOW = 120, _
165  CHAR_YUPP = 89, CHAR_YLOW = 121, _
166  CHAR_ZUPP = 90, CHAR_ZLOW = 122, _
167  CHAR_LPRNT = 40, _
168  CHAR_RPRNT = 41, _
169  CHAR_COMMA = 44, _
170  CHAR_DOT = 46, _
171  CHAR_PLUS = 43, _
172  CHAR_MINUS = 45, _
173  CHAR_RSLASH = 92, _
174  CHAR_SLASH = 47, _
175  CHAR_CART = 94, _
176  CHAR_EQ = 61, _
177  CHAR_LT = 60, _
178  CHAR_GT = 62, _
179  CHAR_AMP = 38, _
180  CHAR_UNDER = 95, _
181  CHAR_EXCL = 33, _
182  CHAR_SHARP = 35, _
183  CHAR_DOLAR = 36, _
184  CHAR_PERC = 37, _
185  CHAR_QUOTE = 34, _
186  CHAR_APOST = 39, _
187  CHAR_TIMES = 42, _
188  CHAR_STAR = CHAR_TIMES, _
189  CHAR_COLON = 58, _
190  CHAR_SEMICOLON= 59, _
191  CHAR_AT = 64, _
192  CHAR_QUESTION = 63, _
193  CHAR_TILD = 126, _
194  CHAR_ESC = 27, _
195  CHAR_LBRACE = 123, _
196  CHAR_RBRACE = 125, _
197  CHAR_LBRACKET = 91, _
198  CHAR_RBRACKET = 93
199 
200 
201 '' assuming it won't ever be used inside lit strings
203 
204 
205 '' tokens
206 enum FB_TOKEN
207  FB_TK_EOF = 256
208  FB_TK_EOL
211  FB_TK_REM
212 
217  FB_TK_ID
218 
219  FB_TK_IF
220  FB_TK_THEN
221  FB_TK_ELSE
224  FB_TK_CASE
225  FB_TK_IS
228  FB_TK_WEND
230  FB_TK_EXIT
231  FB_TK_DO
232  FB_TK_LOOP
233  FB_TK_WITH
234  FB_TK_FOR
235  FB_TK_STEP
236  FB_TK_NEXT
237  FB_TK_TO
241 
242  FB_TK_AND
243  FB_TK_OR
246  FB_TK_XOR
247  FB_TK_EQV
248  FB_TK_IMP
249  FB_TK_NOT
250  FB_TK_MOD
251  FB_TK_SHL
252  FB_TK_SHR
253  FB_TK_EQ
254  FB_TK_GT
255  FB_TK_LT
256  FB_TK_NE
257  FB_TK_LE
258  FB_TK_GE
260 
263  FB_TK_DIM
264  FB_TK_VAR
269 
272 
275 
279 
293 
296  FB_TK_TYPE
298  FB_TK_ENUM
300  FB_TK_END
304  FB_TK_ASM
305  FB_TK_SUB
313  FB_TK_BASE
316 
317  FB_TK_BYTE
322  FB_TK_UINT
323  FB_TK_LONG
332  FB_TK_ANY
333  FB_TK_PTR
336  FB_TK_AS
337 
339 
347  FB_TK_LIB
349  FB_TK_NEW
351 
352  FB_TK_LET
354  FB_TK_GOTO
356 
357  FB_TK_CALL
358 
362  FB_TK_SADD
363 
369  FB_TK_CINT
371  FB_TK_CLNG
375  FB_TK_CSNG
376  FB_TK_CDBL
379  FB_TK_CPTR
380  FB_TK_CAST
381 
382  FB_TK_LSET
383  FB_TK_RSET
384  FB_TK_ASC
385  FB_TK_CHR
386  FB_TK_WCHR
387  FB_TK_STR
388  FB_TK_CVD
389  FB_TK_CVS
390  FB_TK_CVI
391  FB_TK_CVL
394  FB_TK_MKD
395  FB_TK_MKS
396  FB_TK_MKI
397  FB_TK_MKL
400  FB_TK_WSTR
401  FB_TK_MID
404  FB_TK_TRIM
410  FB_TK_READ
411  FB_TK_DATA
412  FB_TK_ABS
413  FB_TK_SGN
414  FB_TK_FIX
415  FB_TK_FRAC
416  FB_TK_SIN
417  FB_TK_ASIN
418  FB_TK_COS
419  FB_TK_ACOS
420  FB_TK_TAN
421  FB_TK_ATN
422  FB_TK_SQR
423  FB_TK_LOG
424  FB_TK_EXP
425  FB_TK_INT
429  FB_TK_LEN
431  FB_TK_PEEK
432  FB_TK_POKE
433  FB_TK_SWAP
434  FB_TK_OPEN
436  FB_TK_SEEK
437  FB_TK_PUT
438  FB_TK_GET
441  FB_TK_LOCK
449  FB_TK_NAME
450  FB_TK_SPC
451  FB_TK_TAB
452  FB_TK_LINE
453  FB_TK_VIEW
462 
463  FB_TK_ON
466  FB_TK_ERR
468  FB_TK_IIF
469 
470  FB_TK_PSET
479  FB_TK_DRAW
481 
483 
485 end enum
486 
487 '' single char tokens
488 const FB_TK_DIRECTIVECHAR = CHAR_DOLAR '' $
489 const FB_TK_DECLSEPCHAR = CHAR_COMMA '' ,
490 const FB_TK_ASSIGN = FB_TK_EQ '' special case, because lex
491 const FB_TK_DEREFCHAR = CHAR_STAR '' *
492 const FB_TK_ADDROFCHAR = CHAR_AT '' @
493 
499 
500 
501 '' token classes
502 enum FB_TKCLASS
511 end enum
512 
513 #include once "hash.bi"
514 #include once "stack.bi"
515 #include once "symb.bi"
516 
517 ''
518 enum FBFILE_FORMAT
525 end enum
526 
527 type FBFILE
528  num as integer
529  name as zstring * FB_MAXPATHLEN+1
530  incfile as zstring ptr
531  ismain as integer
533 end type
534 
535 enum FB_TARGETOPT
536  FB_TARGETOPT_UNIX = &h00000001 '' Unix-like system? (for __FB_UNIX__ #define)
537  FB_TARGETOPT_UNDERSCORE = &h00000002 '' Underscore prefix for symbols?
538  FB_TARGETOPT_EXPORT = &h00000004 '' Support for exporting symbols from DLLs?
539 
540  '' Whether callee always pops the hidden struct result ptr
541  '' i386 SysV ABI (MinGW GCC 4.6, Linux, DJGPP, etc.):
542  '' callee always pops hidden param, even for cdecl ("hybrid")
543  '' MinGW GCC 4.7, MSVC ABI:
544  '' hidden param is popped according to calling convention
546 
547  '' Returning structures in registers only exists on Win32, and
548  '' - neither Linux GCC (following the i386 SysV ABI),
549  '' - nor DJGPP
550  '' do it. TODO: what about the BSDs and Darwin/MacOSX?
551  FB_TARGETOPT_RETURNINREGS = &h00000010
552 end enum
553 
554 type FBTARGET
555  id as zstring ptr
556  size_t32 as FB_DATATYPE '' 32bit size_t type
557  size_t64 as FB_DATATYPE '' 64bit size_t type
558  wchar as FB_DATATYPE '' Real wstring data type
559  fbcall as FB_FUNCMODE '' Default calling convention, must match the rtlib's FBCALL
560  stdcall as FB_FUNCMODE '' Calling convention to use for stdcall (stdcall or stdcallms)
562 end type
563 
564 type FBOPTION
565  base as integer '' default= 0
566  parammode as integer '' def = byref
567  explicit as integer '' def = false
568  procpublic as integer '' def = true
569  escapestr as integer '' def = false
570  dynamic as integer '' def = false
571  gosub as integer '' def = true in FB_LANG_QB, false in all other dialects
572 end type
573 
574 type FBMAIN
575  proc as FBSYMBOL ptr
576  initnode as ASTNODE ptr
577 end type
578 
579 type FB_LANG_CTX
580  opt as FB_LANG_OPT '' language supported features
581  integerkeyworddtype as FB_DATATYPE '' dtype produced by INTEGER (and related) keywords
582  int15literaldtype as FB_DATATYPE '' default dtype for integer number literals that fit into 15 bits
583  int16literaldtype as FB_DATATYPE '' etc.
586  floatliteraldtype as FB_DATATYPE '' default dtype for float number literals
587 end type
588 
589 type FBENV
590  '' Global fb interface data
591  predefines as TLIST
592  preincludes as TLIST
594 
595  clopt as FBCMMLINEOPT '' cmm-line options
596  target as FBTARGET '' target specific
597  wchar_doconv as integer '' ok to convert literals at compile-time?
598 
599  pointersize as integer
600 
601  '' Parse-specific things
602 
603  inf as FBFILE '' source file
604  outf as FBFILE '' destine file
605 
606  ppfile_num as integer '' -pp output file
607 
608  '' include files
609  incfilehash as THASH
610  inconcehash as THASH
611  includerec as integer '' >0 if parsing an include file
612 
613  main as FBMAIN
614 
615  lang as FB_LANG_CTX '' language supported features
616 
617  opt as FBOPTION '' context-sensitive options
618 
619  restarts as integer '' number of parser restarts
620  dorestart as integer '' request parser restart
621 
622  '' Lists to collect #inclibs and #libpaths
623  libs as TSTRSET
624  libpaths as TSTRSET
625 
626  fbctinf_started as integer
627 end type
628 
629 #include once "hlp.bi"
630 
631 declare function fbGetInputFileParentDir( ) as string
632 declare sub fbAddLib(byval libname as zstring ptr)
633 declare sub fbAddLibPath(byval path as zstring ptr)
634 
635 ''
636 '' super globals
637 ''
638 common shared as FBENV env
639 
640 #endif ''__FBINT_BI__
641