psystem.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Load the system unit, create required defs for systemunit
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit psystem;
  19. interface
  20. uses symtable;
  21. procedure insertinternsyms(p : psymtable);
  22. procedure insert_intern_types(p : psymtable);
  23. procedure readconstdefs;
  24. procedure createconstdefs;
  25. implementation
  26. uses globals,tree;
  27. procedure insertinternsyms(p : psymtable);
  28. {
  29. all intern procedures for system unit
  30. }
  31. begin
  32. p^.insert(new(psyssym,init('CONCAT',in_concat_x)));
  33. p^.insert(new(psyssym,init('WRITE',in_write_x)));
  34. p^.insert(new(psyssym,init('WRITELN',in_writeln_x)));
  35. p^.insert(new(psyssym,init('ASSIGNED',in_assigned_x)));
  36. p^.insert(new(psyssym,init('READ',in_read_x)));
  37. p^.insert(new(psyssym,init('READLN',in_readln_x)));
  38. p^.insert(new(psyssym,init('OFS',in_ofs_x)));
  39. p^.insert(new(psyssym,init('SIZEOF',in_sizeof_x)));
  40. p^.insert(new(psyssym,init('TYPEOF',in_typeof_x)));
  41. p^.insert(new(psyssym,init('LOW',in_low_x)));
  42. p^.insert(new(psyssym,init('HIGH',in_high_x)));
  43. p^.insert(new(psyssym,init('SEG',in_seg_x)));
  44. p^.insert(new(psyssym,init('ORD',in_ord_x)));
  45. p^.insert(new(psyssym,init('PRED',in_pred_x)));
  46. p^.insert(new(psyssym,init('SUCC',in_succ_x)));
  47. p^.insert(new(psyssym,init('EXCLUDE',in_exclude_x_y)));
  48. p^.insert(new(psyssym,init('INCLUDE',in_include_x_y)));
  49. p^.insert(new(psyssym,init('BREAK',in_break)));
  50. p^.insert(new(psyssym,init('CONTINUE',in_continue)));
  51. p^.insert(new(psyssym,init('DEC',in_dec_x)));
  52. p^.insert(new(psyssym,init('INC',in_inc_x)));
  53. p^.insert(new(psyssym,init('STR',in_str_x_string)));
  54. p^.insert(new(psyssym,init('ASSERT',in_assert_x_y)));
  55. end;
  56. procedure insert_intern_types(p : psymtable);
  57. {
  58. all the types inserted into the system unit
  59. }
  60. var
  61. booleandef : pdef;
  62. {$ifdef GDB}
  63. { several defs to simulate more or less C++ objects for GDB }
  64. vmtdef : precdef;
  65. pvmtdef : ppointerdef;
  66. vmtarraydef : parraydef;
  67. vmtsymtable : psymtable;
  68. {$endif GDB}
  69. begin
  70. p^.insert(new(ptypesym,init('longint',s32bitdef)));
  71. p^.insert(new(ptypesym,init('ulong',u32bitdef)));
  72. p^.insert(new(ptypesym,init('void',voiddef)));
  73. p^.insert(new(ptypesym,init('char',cchardef)));
  74. {$ifdef i386}
  75. p^.insert(new(ptypesym,init('s64real',c64floatdef)));
  76. {$endif i386}
  77. p^.insert(new(ptypesym,init('s80real',s80floatdef)));
  78. p^.insert(new(ptypesym,init('cs32fixed',s32fixeddef)));
  79. p^.insert(new(ptypesym,init('byte',u8bitdef)));
  80. p^.insert(new(ptypesym,init('string',cshortstringdef)));
  81. p^.insert(new(ptypesym,init('shortstring',cshortstringdef)));
  82. p^.insert(new(ptypesym,init('longstring',clongstringdef)));
  83. p^.insert(new(ptypesym,init('ansistring',cansistringdef)));
  84. p^.insert(new(ptypesym,init('widestring',cwidestringdef)));
  85. p^.insert(new(ptypesym,init('word',u16bitdef)));
  86. p^.insert(new(ptypesym,init('boolean',booldef)));
  87. p^.insert(new(ptypesym,init('void_pointer',voidpointerdef)));
  88. p^.insert(new(ptypesym,init('file',cfiledef)));
  89. {$ifdef i386}
  90. p^.insert(new(ptypesym,init('REAL',new(pfloatdef,init(s64real)))));
  91. p^.insert(new(ptypesym,init('COMP',new(pfloatdef,init(s64bit)))));
  92. p^.insert(new(ptypesym,init('EXTENDED',new(pfloatdef,init(s80real)))));
  93. {$endif}
  94. {$ifdef m68k}
  95. { internal definitions }
  96. p^.insert(new(ptypesym,init('s32real',c64floatdef)));
  97. { mappings... }
  98. p^.insert(new(ptypesym,init('REAL',new(pfloatdef,init(s32real)))));
  99. if (cs_fp_emulation) in aktmoduleswitches then
  100. p^.insert(new(ptypesym,init('DOUBLE',new(pfloatdef,init(s32real)))))
  101. else
  102. p^.insert(new(ptypesym,init('DOUBLE',new(pfloatdef,init(s64real)))));
  103. if (cs_fp_emulation) in aktmoduleswitches then
  104. p^.insert(new(ptypesym,init('EXTENDED',new(pfloatdef,init(s32real)))))
  105. else
  106. p^.insert(new(ptypesym,init('EXTENDED',new(pfloatdef,init(s80real)))));
  107. { p^.insert(new(ptypesym,init('COMP',new(pfloatdef,init(s32real)))));}
  108. {$endif}
  109. p^.insert(new(ptypesym,init('SINGLE',new(pfloatdef,init(s32real)))));
  110. p^.insert(new(ptypesym,init('POINTER',new(ppointerdef,init(voiddef)))));
  111. p^.insert(new(ptypesym,init('STRING',cshortstringdef)));
  112. p^.insert(new(ptypesym,init('SHORTSTRING',cshortstringdef)));
  113. p^.insert(new(ptypesym,init('LONGSTRING',clongstringdef)));
  114. p^.insert(new(ptypesym,init('ANSISTRING',cansistringdef)));
  115. p^.insert(new(ptypesym,init('WIDESTRING',cwidestringdef)));
  116. booleandef:=new(porddef,init(bool8bit,0,1));
  117. p^.insert(new(ptypesym,init('BOOLEAN',booleandef)));
  118. p^.insert(new(ptypesym,init('BYTEBOOL',booleandef)));
  119. p^.insert(new(ptypesym,init('WORDBOOL',new(porddef,init(bool16bit,0,1)))));
  120. p^.insert(new(ptypesym,init('LONGBOOL',new(porddef,init(bool32bit,0,1)))));
  121. p^.insert(new(ptypesym,init('CHAR',new(porddef,init(uchar,0,255)))));
  122. p^.insert(new(ptypesym,init('TEXT',new(pfiledef,init(ft_text,nil)))));
  123. p^.insert(new(ptypesym,init('CARDINAL',new(porddef,init(u32bit,0,$ffffffff)))));
  124. p^.insert(new(ptypesym,init('FIXED',new(pfloatdef,init(f32bit)))));
  125. p^.insert(new(ptypesym,init('FIXED16',new(pfloatdef,init(f16bit)))));
  126. p^.insert(new(ptypesym,init('TYPEDFILE',new(pfiledef,init(ft_typed,voiddef)))));
  127. { !!!!!
  128. p^.insert(new(ptypesym,init('COMP',new(porddef,init(s64bit,0,0)))));
  129. p^.insert(new(ptypesym,init('SINGLE',new(porddef,init(s32real,0,0)))));
  130. p^.insert(new(ptypesym,init('EXTENDED',new(porddef,init(s80real,0,0)))));
  131. p^.insert(new(ptypesym,init('FILE',new(pfiledef,init(ft_untyped,nil)))));
  132. }
  133. { Add a type for virtual method tables in lowercase }
  134. { so it isn't reachable! }
  135. {$ifdef GDB}
  136. vmtsymtable:=new(psymtable,init(recordsymtable));
  137. vmtdef:=new(precdef,init(vmtsymtable));
  138. pvmtdef:=new(ppointerdef,init(vmtdef));
  139. vmtsymtable^.insert(new(pvarsym,init('parent',pvmtdef)));
  140. vmtsymtable^.insert(new(pvarsym,init('length',globaldef('longint'))));
  141. vmtsymtable^.insert(new(pvarsym,init('mlength',globaldef('longint'))));
  142. vmtarraydef:=new(parraydef,init(0,1,s32bitdef));
  143. vmtarraydef^.definition := voidpointerdef;
  144. vmtsymtable^.insert(new(pvarsym,init('__pfn',vmtarraydef)));
  145. p^.insert(new(ptypesym,init('__vtbl_ptr_type',vmtdef)));
  146. p^.insert(new(ptypesym,init('pvmt',pvmtdef)));
  147. vmtarraydef:=new(parraydef,init(0,1,s32bitdef));
  148. vmtarraydef^.definition := pvmtdef;
  149. p^.insert(new(ptypesym,init('vtblarray',vmtarraydef)));
  150. {$endif GDB}
  151. insertinternsyms(p);
  152. end;
  153. procedure readconstdefs;
  154. {
  155. Load all default definitions for consts from the system unit
  156. }
  157. begin
  158. s32bitdef:=porddef(globaldef('longint'));
  159. u32bitdef:=porddef(globaldef('ulong'));
  160. cshortstringdef:=pstringdef(globaldef('shortstring'));
  161. clongstringdef:=pstringdef(globaldef('longstring'));
  162. cansistringdef:=pstringdef(globaldef('ansistring'));
  163. cwidestringdef:=pstringdef(globaldef('widestring'));
  164. cchardef:=porddef(globaldef('char'));
  165. {$ifdef i386}
  166. c64floatdef:=pfloatdef(globaldef('s64real'));
  167. {$endif}
  168. {$ifdef m68k}
  169. c64floatdef:=pfloatdef(globaldef('s32real'));
  170. {$endif m68k}
  171. s80floatdef:=pfloatdef(globaldef('s80real'));
  172. s32fixeddef:=pfloatdef(globaldef('cs32fixed'));
  173. voiddef:=porddef(globaldef('void'));
  174. u8bitdef:=porddef(globaldef('byte'));
  175. u16bitdef:=porddef(globaldef('word'));
  176. booldef:=porddef(globaldef('boolean'));
  177. voidpointerdef:=ppointerdef(globaldef('void_pointer'));
  178. cfiledef:=pfiledef(globaldef('file'));
  179. end;
  180. procedure createconstdefs;
  181. {
  182. Create all default definitions for consts for the system unit
  183. }
  184. var
  185. oldregisterdef : boolean;
  186. begin
  187. { create definitions for constants }
  188. oldregisterdef:=registerdef;
  189. registerdef:=false;
  190. voiddef:=new(porddef,init(uvoid,0,0));
  191. u8bitdef:=new(porddef,init(u8bit,0,255));
  192. u16bitdef:=new(porddef,init(u16bit,0,65535));
  193. u32bitdef:=new(porddef,init(u32bit,0,$ffffffff));
  194. s32bitdef:=new(porddef,init(s32bit,$80000000,$7fffffff));
  195. booldef:=new(porddef,init(bool8bit,0,1));
  196. cchardef:=new(porddef,init(uchar,0,255));
  197. cshortstringdef:=new(pstringdef,shortinit(255));
  198. { should we give a length to the default long and ansi string definition ?? }
  199. clongstringdef:=new(pstringdef,longinit(-1));
  200. cansistringdef:=new(pstringdef,ansiinit(-1));
  201. cwidestringdef:=new(pstringdef,wideinit(-1));
  202. {$ifdef i386}
  203. c64floatdef:=new(pfloatdef,init(s64real));
  204. s80floatdef:=new(pfloatdef,init(s80real));
  205. {$endif}
  206. {$ifdef m68k}
  207. c64floatdef:=new(pfloatdef,init(s32real));
  208. if (cs_fp_emulation in aktmoduleswitches) then
  209. s80floatdef:=new(pfloatdef,init(s32real))
  210. else
  211. s80floatdef:=new(pfloatdef,init(s80real));
  212. {$endif}
  213. s32fixeddef:=new(pfloatdef,init(f32bit));
  214. { some other definitions }
  215. voidpointerdef:=new(ppointerdef,init(voiddef));
  216. cfiledef:=new(pfiledef,init(ft_untyped,nil));
  217. registerdef:=oldregisterdef;
  218. end;
  219. end.
  220. {
  221. $Log$
  222. Revision 1.9 1998-11-05 12:02:54 peter
  223. * released useansistring
  224. * removed -Sv, its now available in fpc modes
  225. Revision 1.8 1998/11/04 10:11:44 peter
  226. * ansistring fixes
  227. Revision 1.7 1998/10/05 12:32:48 peter
  228. + assert() support
  229. Revision 1.6 1998/09/24 23:49:17 peter
  230. + aktmodeswitches
  231. Revision 1.5 1998/08/10 14:50:19 peter
  232. + localswitches, moduleswitches, globalswitches splitting
  233. Revision 1.4 1998/06/25 14:04:24 peter
  234. + internal inc/dec
  235. Revision 1.3 1998/06/04 23:51:55 peter
  236. * m68k compiles
  237. + .def file creation moved to gendef.pas so it could also be used
  238. for win32
  239. Revision 1.2 1998/06/04 08:23:57 pierre
  240. * boolean again intern declared (needed to be able to compile
  241. older RTL's)
  242. Revision 1.1 1998/06/03 22:49:01 peter
  243. + wordbool,longbool
  244. * rename bis,von -> high,low
  245. * moved some systemunit loading/creating to psystem.pas
  246. }