home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_macros_cpp________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-07-10  |  8.3 KB  |  355 lines

  1. /*****************************************************************************
  2.  *
  3.  *  The following file is pre-preprocessed and fed into the SafeC+ compiler,
  4.  *  since it doesn't support macros with arguments and all that other stuff.
  5.  *  It is included directly as an ordinary source file when the compiler is
  6.  *  built as a C++ program.
  7.  */
  8.  
  9. #include "smcPCH.h"
  10. #pragma hdrstop
  11.  
  12. #ifdef  __PREPROCESS__
  13. #include "macros.h"
  14. #else
  15. #include "genIL.h"
  16. #endif
  17.  
  18. /*****************************************************************************/
  19. /*****************************************************************************/
  20.  
  21. #include "tokens.h"
  22. #include "treeops.h"
  23.  
  24. /*****************************************************************************/
  25.  
  26. #ifdef  __UMG__
  27. #include "symsizes.h"
  28. #include "typsizes.h"
  29. #endif
  30.  
  31. /*****************************************************************************/
  32.  
  33. #include "config.h"
  34.  
  35. optionDesc      optionInfo[] =
  36. {
  37.     #define CMDOPT(name, type, phase, defval)                           \
  38.     {                                                                   \
  39.         offsetof(compConfig, cc##name),                                 \
  40.         sizeof(type),                                                   \
  41.         phase,                                                          \
  42.         (NatInt)defval                                                  \
  43.     },
  44.  
  45.     #include "options.h"
  46. };
  47.  
  48. /*****************************************************************************/
  49.  
  50. #ifdef  __SMC__
  51.  
  52. #undef  SMC_ERR
  53. #undef  SMC_WR1
  54. #undef  SMC_WRN
  55. #define SMC_ERR(name, lvl, str)  name,
  56. #define SMC_WR1(name, lvl, str)  name, WRNfirstWarn = name,
  57. #define SMC_WRN(name, lvl, str)  name,
  58. enum    errors
  59. {
  60.     #include "errors.h"
  61.  
  62.     WRNafterWarn
  63. };
  64. #undef  SMC_ERR
  65. #undef  SMC_WR1
  66. #undef  SMC_WRN
  67.  
  68. const
  69. unsigned    WRNcountWarn = WRNafterWarn - WRNfirstWarn + 1;
  70.  
  71. #endif
  72.  
  73. /*****************************************************************************/
  74.  
  75. #undef  SMC_ERR
  76. #define SMC_ERR(name, lvl, str)  str,
  77. #define SMC_WR1(name, lvl, str)  str,
  78. #define SMC_WRN(name, lvl, str)  str,
  79. const   char *          errorTable[] =
  80. {
  81.     #include "errors.h"
  82. };
  83. #undef  SMC_ERR
  84. #undef  SMC_WR1
  85. #undef  SMC_WRN
  86.  
  87. /*****************************************************************************/
  88.  
  89. #undef  SMC_ERR
  90. #define SMC_ERR(name, lvl, str)
  91. #define SMC_WR1(name, lvl, str)  lvl,
  92. #define SMC_WRN(name, lvl, str)  lvl,
  93. BYTE                    warnDefault[] =
  94. {
  95.     #include "errors.h"
  96. };
  97. #undef  SMC_ERR
  98. #undef  SMC_WR1
  99. #undef  SMC_WRN
  100.  
  101. /*****************************************************************************/
  102.  
  103. #include "attrs.h"
  104.  
  105. const char    *     attrNames[] =
  106. {
  107.     #define ATTRDEF(ename, sname) sname,
  108.     #include "attrlist.h"
  109. };
  110.  
  111. /*****************************************************************************/
  112.  
  113. static
  114. unsigned char       optokens[] =
  115. {
  116.     #define TREEOP(en,tk,sn,IL,pr,ok) tk,
  117.     #include "toplist.h"
  118. };
  119.  
  120. tokens              treeOp2token(treeOps oper)
  121. {
  122.     assert(oper < arraylen(optokens));
  123.     assert(optokens[oper] != tkNone);
  124.  
  125.     return (tokens)optokens[oper];
  126. }
  127.  
  128. /*****************************************************************************/
  129.  
  130. #ifdef  DEBUG
  131.  
  132. static
  133. const   char *      treeNodeNames[] =
  134. {
  135.     #define TREEOP(en,tk,sn,IL,pr,ok) sn,
  136.     #include "toplist.h"
  137. };
  138.  
  139. const   char    *   treeNodeName(treeOps op)
  140. {
  141.     assert(op < sizeof(treeNodeNames)/sizeof(treeNodeNames[0]));
  142.  
  143.     return  treeNodeNames[op];
  144. }
  145.  
  146. #endif
  147.  
  148. /*****************************************************************************/
  149.  
  150. const
  151. unsigned char       TreeNode::tnOperKindTable[] =
  152. {
  153.     #define TREEOP(en,tk,sn,IL,pr,ok) ok,
  154.     #include "toplist.h"
  155. };
  156.  
  157. /*****************************************************************************/
  158.  
  159. const
  160. kwdDsc              hashTab::hashKwdDescs[tkKwdCount] =
  161. {
  162.     #define KEYWORD(str, nam, info, prec2, op2, prec1, op1, mod) { op1,op2,prec1,prec2,nam,mod,info },
  163.     #define KWDNOID(str, nam, info, prec2, op2, prec1, op1, mod) { op1,op2,prec1,prec2,nam,mod,info },
  164.     #define KWDFAKE(str, nam, info, prec2, op2, prec1, op1, mod)
  165.     #include "keywords.h"
  166. };
  167.  
  168. const
  169. char *              hashTab::hashKwdNtab[tkKwdCount] =
  170. {
  171.     #define KEYWORD(str, nam, info, prec2, op2, prec1, op1, mod) str,
  172.     #define KWDNOID(str, nam, info, prec2, op2, prec1, op1, mod) str,
  173.     #define KWDFAKE(str, nam, info, prec2, op2, prec1, op1, mod)
  174.     #include "keywords.h"
  175. };
  176.  
  177. /*****************************************************************************/
  178.  
  179. #ifdef  DEBUG
  180.  
  181. const char *        tokenNames[] =
  182. {
  183.     #define KEYWORD(str, nam, info, prec2, op2, prec1, op1, mod) str,
  184.     #include "keywords.h"
  185. };
  186.  
  187. #endif
  188.  
  189. /*****************************************************************************/
  190.  
  191. #ifdef  __SMC__
  192.  
  193. enum    var_types
  194. {
  195.     #define DEF_TP(tn,sz,al,nm,tf) TYP_##tn,
  196.     #include "typelist.h"
  197.     #undef  DEF_TP
  198.  
  199.     TYP_COUNT,
  200.  
  201.     TYP_lastIntrins = TYP_LONGDBL
  202. };
  203.  
  204. #endif
  205.  
  206. /*****************************************************************************/
  207.  
  208. BYTE                symTab::stIntrTypeSizes[] =
  209. {
  210.     #define DEF_TP(tn,sz,al,nm,tf) sz,
  211.     #include "typelist.h"
  212.     #undef  DEF_TP
  213. };
  214.  
  215. BYTE                symTab::stIntrTypeAligns[] =
  216. {
  217.     #define DEF_TP(tn,sz,al,nm,tf) al,
  218.     #include "typelist.h"
  219.     #undef  DEF_TP
  220. };
  221.  
  222. BYTE                varTypeClassification[] =
  223. {
  224.     #define DEF_TP(tn,sz,al,nm,tf) tf,
  225.     #include "typelist.h"
  226.     #undef  DEF_TP
  227. };
  228.  
  229. normString          symTab::stIntrinsicTypeName(var_types vt)
  230. {
  231.     static
  232.     const   char *      typeNames[] =
  233.     {
  234.         #define DEF_TP(tn,sz,al,nm,tf) nm,
  235.         #include "typelist.h"
  236.         #undef  DEF_TP
  237.     };
  238.  
  239.     assert(vt < sizeof(typeNames)/sizeof(typeNames[0]));
  240.  
  241.     return  typeNames[vt];
  242. }
  243.  
  244. /*****************************************************************************/
  245.  
  246. #ifdef  __SMC__
  247.  
  248. enum    ILopcodes
  249. {
  250.     #define OPDEF(name, str, decs, incs, args, optp, stdlen, stdop1, stdop2, flow) name,
  251.     #include "opcode.def"
  252.     #undef  OPDEF
  253.  
  254.     CEE_count,
  255.  
  256.     CEE_UNREACHED,                  // fake value: end of block is unreached
  257. };
  258.  
  259. #endif
  260.  
  261. /*****************************************************************************/
  262.  
  263. ILencoding          ILopcodeCodes[] =
  264. {
  265.     #define OPDEF(name, str, decs, incs, args, optp, stdlen, stdop1, stdop2, flow) { stdop1, stdop2, stdlen },
  266.     #include "opcode.def"
  267.     #undef  OPDEF
  268. };
  269.  
  270. /*****************************************************************************/
  271.  
  272. #define Push0    0
  273. #define Push1    1
  274. #define PushI    1
  275. #define PushI8   1
  276. #define PushR4   1
  277. #define PushR8   1
  278. #define PushRef  1
  279. #define VarPush  0
  280.  
  281. #define Pop0     0
  282. #define Pop1    -1
  283. #define PopI    -1
  284. #define PopI8   -1
  285. #define PopR4   -1
  286. #define PopR8   -1
  287. #define PopRef  -1
  288. #define VarPop   0
  289.  
  290. signed  char        ILopcodeStack[] =
  291. {
  292.     #define OPDEF(name, str, decs, incs, args, optp, stdlen, stdop1, stdop2, flow) ((incs)+(decs)),
  293.     #include "opcode.def"
  294.     #undef  OPDEF
  295. };
  296.  
  297. /*****************************************************************************/
  298.  
  299. #ifdef  DEBUG
  300.  
  301. const char *        opcodeNames[] =
  302. {
  303.     #define OPDEF(nam,str,op,decs,incs,ops,otp, len, op1, op2) str,
  304.     #include "opcode.def"
  305.     #undef  OPDEF
  306. };
  307.  
  308. const char *        opcodeName(unsigned op)
  309. {
  310.     assert(op < sizeof(opcodeNames)/sizeof(*opcodeNames));
  311.  
  312.     return  opcodeNames[op];
  313. }
  314.  
  315. #endif
  316.  
  317. /*****************************************************************************/
  318.  
  319. const   char *      MDnamesStr[] =
  320. {
  321.     #define MD_NAME(ovop, name) name,
  322.     #include "MDnames.h"
  323.     #undef  MD_NAME
  324. };
  325.  
  326. #ifdef  DEBUG
  327.  
  328. const  ovlOpFlavors MDnamesChk[] =
  329. {
  330.     #define MD_NAME(ovop, name) OVOP_##ovop,
  331.     #include "MDnames.h"
  332.     #undef  MD_NAME
  333. };
  334.  
  335. #endif
  336.  
  337. #include "MDstrns.h"
  338.  
  339. ovlOpFlavors        MDfindOvop(const char *name)
  340. {
  341.     unsigned        i;
  342.  
  343.     // This is pretty lame -- is there a better way?
  344.  
  345.     for (i = 0; i < arraylen(MDnamesStr); i++)
  346.     {
  347.         if  (MDnamesStr[i] && !strcmp(name, MDnamesStr[i]))
  348.             return  (ovlOpFlavors)i;
  349.     }
  350.  
  351.     return  OVOP_NONE;
  352. }
  353.  
  354. /*****************************************************************************/
  355.