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

  1. /*****************************************************************************/
  2. #ifndef _COMP_H_
  3. #define _COMP_H_
  4. /*****************************************************************************/
  5.  
  6. const   unsigned    MAX_IDENT_LEN   = 1023;     // max # of chars in identifier
  7.  
  8. /*****************************************************************************/
  9.  
  10. #ifdef  __IL__
  11. #undef  ASYNCH_INPUT_READ
  12. #else
  13. #define ASYNCH_INPUT_READ       1
  14. #endif
  15.  
  16. /*****************************************************************************/
  17.  
  18. #ifndef _CONFIG_H_
  19. #include "config.h"
  20. #endif
  21.  
  22. #ifndef _ALLOC_H_
  23. #include "alloc.h"
  24. #endif
  25.  
  26. #ifndef _INFILE_H_
  27. #include "infile.h"
  28. #endif
  29.  
  30. #ifndef _PEWRITE_H_
  31. #include "PEwrite.h"
  32. #endif
  33.  
  34. #ifndef _CORWRAP_H
  35. #include "CORwrap.h"
  36. #endif
  37.  
  38. #ifndef _MDSTRNS_H_
  39. #include "MDstrns.h"
  40. #endif
  41.  
  42. #ifndef _ATTRS_H_
  43. #include "attrs.h"
  44. #endif
  45.  
  46. /*****************************************************************************/
  47.  
  48. #ifndef CALG_SHA1
  49. const   unsigned    CALG_SHA1 = 0x00008004;
  50. #endif
  51.  
  52. /*****************************************************************************/
  53.  
  54. bool                parseGUID(const char *str, GUID *guidPtr, bool curlied);
  55. tokens              treeOp2token(treeOps oper);
  56. bool                processOption(const char *optStr, Compiler comp);
  57.  
  58. /*****************************************************************************
  59.  *
  60.  *  This is here because we can't include "symbol.h" just yet due to other
  61.  *  dependencies.
  62.  */
  63.  
  64. enum symbolKinds
  65. {
  66.     SYM_ERR,
  67.     SYM_VAR,
  68.     SYM_FNC,
  69.     SYM_PROP,
  70.     SYM_LABEL,
  71.     SYM_USING,
  72.     SYM_GENARG,
  73.     SYM_ENUMVAL,
  74.     SYM_TYPEDEF,
  75.     SYM_COMPUNIT,
  76.  
  77.     /*
  78.         The symbol kinds that follow are the only ones that define
  79.         scopes (i.e. they may own other symbols). This is relied
  80.         upon in the function symDef::sdHasScope().
  81.      */
  82.  
  83.     SYM_ENUM,
  84.     SYM_SCOPE,
  85.     SYM_CLASS,
  86.     SYM_NAMESPACE,
  87.  
  88.     SYM_FIRST_SCOPED = SYM_ENUM,
  89. };
  90.  
  91. enum str_flavors
  92. {
  93.     STF_NONE,                   // 0: undetermined
  94.  
  95.     STF_CLASS,                  // 1: it's a  class
  96.     STF_UNION,                  // 2: it's a  union
  97.     STF_STRUCT,                 // 3: it's a  struct
  98.     STF_INTF,                   // 4: it's an interface
  99.     STF_DELEGATE,               // 5: it's a  delegate
  100.     STF_GENARG,                 // 6: it's a  generic class formal argument
  101.  
  102.     STF_COUNT
  103. };
  104.  
  105. /*****************************************************************************
  106.  *
  107.  *  The following refers to the "namespace" in which names are looked up,
  108.  *  this has nothing to do with the "namespace" scoping concept.
  109.  */
  110.  
  111. enum name_space
  112. {
  113.     NS_NONE     = 0x0000,
  114.  
  115.     NS_NORM     = 0x0001,       // variables, members, classes, etc.
  116.     NS_TYPE     = 0x0002,       // types
  117.     NS_LABEL    = 0x0004,       // labels
  118.     NS_CONT     = 0x0008,       // contains other names (used with NS_NORM/NS_TYPE)
  119.     NS_HIDE     = 0x0010,       // not visible at all
  120. };
  121.  
  122. /*****************************************************************************/
  123.  
  124. enum callingConvs
  125. {
  126.     CCNV_NONE,
  127.     CCNV_CDECL,
  128.     CCNV_STDCALL,
  129.     CCNV_WINAPI,
  130. };
  131.  
  132. /*****************************************************************************/
  133.  
  134. enum compileStates
  135. {
  136.     CS_NONE,
  137.     CS_KNOWN,
  138.     CS_PARSED,
  139.     CS_DECLSOON,                // symbol is on its way to 'declared'
  140.     CS_DECLARED,
  141.     CS_CNSEVALD,                // constant evaluated if present
  142.     CS_COMPILED,
  143. };
  144.  
  145. enum accessLevels
  146. {
  147.     ACL_ERROR,
  148.  
  149.     ACL_PUBLIC,
  150.     ACL_PROTECTED,
  151.     ACL_DEFAULT,
  152.     ACL_PRIVATE,
  153. };
  154.  
  155. /*****************************************************************************
  156.  *
  157.  *  The following holds information about a security attribute.
  158.  */
  159.  
  160. DEFMGMT
  161. class   PairListRec
  162. {
  163. public:
  164.     PairList            plNext;
  165.     Ident               plName;
  166. //  ConstStr            plValue;
  167.     bool                plValue;        // for only true/false is allowed
  168. };
  169.  
  170. DEFMGMT
  171. class   SecurityDesc
  172. {
  173. public:
  174.     CorDeclSecurity     sdSpec;
  175.     bool                sdIsPerm;       // capability (false) or permission (true) ?
  176.  
  177.     UNION(sdIsPerm)
  178.     {
  179.     CASE(false)
  180.         ConstStr            sdCapbStr;
  181.  
  182.     CASE(true)
  183.         struct
  184.         {
  185.             SymDef              sdPermCls;
  186.             PairList            sdPermVal;
  187.         }
  188.                             sdPerm;
  189.     };
  190. };
  191.  
  192. /*****************************************************************************
  193.  *
  194.  *  The following better match the values in System::AtributeTargets !
  195.  */
  196.  
  197. enum    attrTgts
  198. {
  199.     ATGT_Assemblies    = 0x0001,
  200.     ATGT_Modules       = 0x0002,
  201.     ATGT_Classes       = 0x0004,
  202.     ATGT_Structs       = 0x0008,
  203.     ATGT_Enums         = 0x0010,
  204.     ATGT_Constructors  = 0x0020,
  205.     ATGT_Methods       = 0x0040,
  206.     ATGT_Properties    = 0x0080,
  207.     ATGT_Fields        = 0x0100,
  208.     ATGT_Events        = 0x0200,
  209.     ATGT_Interfaces    = 0x0400,
  210.     ATGT_Parameters    = 0x0800,
  211. };
  212.  
  213. /*****************************************************************************
  214.  *
  215.  *  A simple array-like table that pointers can be thrown into and a simple
  216.  *  index is returned that can later be used to retrieve the pointer value.
  217.  */
  218.  
  219. DEFMGMT
  220. class   VecEntryDsc
  221. {
  222. public:
  223.     const   void    *   vecValue;
  224. #ifdef  DEBUG
  225.     vecEntryKinds       vecKind;
  226. #endif
  227. };
  228.  
  229. /*****************************************************************************
  230.  *
  231.  *  This holds a qualified name of the form "foo.bar. .... baz". It's a simple
  232.  *  array of identifiers and a flag as to whether the final entry was ".*".
  233.  */
  234.  
  235. DEFMGMT
  236. class QualNameRec
  237. {
  238. public:
  239.  
  240.     unsigned        qnCount     :31;    // number of identifiers
  241.     unsigned        qnEndAll    :1;     // ends in ".*" ?
  242.  
  243. #if MGDDATA
  244.     Ident        [] qnTable;            // the array allocated separately
  245. #else
  246.     Ident           qnTable[];          // the array follows in memory
  247. #endif
  248.  
  249. };
  250.  
  251. /*****************************************************************************
  252.  *
  253.  *  The following describes a "/** @" style directive.
  254.  */
  255.  
  256. enum    atCommFlavors
  257. {
  258.     AC_NONE,
  259.  
  260.     AC_COM_INTF,
  261.     AC_COM_CLASS,
  262.     AC_COM_METHOD,
  263.     AC_COM_PARAMS,
  264.     AC_COM_REGISTER,
  265.  
  266.     AC_DLL_IMPORT,
  267.     AC_DLL_STRUCT,
  268.     AC_DLL_STRUCTMAP,
  269.  
  270.     AC_CONDITIONAL,
  271.  
  272.     AC_DEPRECATED,
  273.  
  274.     AC_COUNT
  275. };
  276.  
  277. struct  marshalDsc;
  278. typedef marshalDsc *    MarshalInfo;
  279. struct  marshalDsc
  280. {
  281.     unsigned char       marshType;          // the real type is 'CorNativeType'
  282.     unsigned char       marshSubTp;         // element type for arrays
  283.     unsigned char       marshModeIn;        // used only for args
  284.     unsigned char       marshModeOut;       // used only for args
  285.     unsigned            marshSize;          // used for fixed array types
  286. };
  287.  
  288. struct  marshalExt : marshalDsc
  289. {
  290.     const   char *      marshCustG;
  291.     const   char *      marshCustC;
  292.     SymDef              marshCustT;
  293. };
  294.  
  295. struct  methArgDsc;
  296. typedef methArgDsc *    MethArgInfo;
  297. struct  methArgDsc
  298. {
  299.     MethArgInfo         methArgNext;
  300.     marshalDsc          methArgDesc;
  301.     Ident               methArgName;
  302. };
  303.  
  304. struct  atCommDsc;
  305. typedef atCommDsc *     AtComment;
  306. struct  atCommDsc
  307. {
  308.     AtComment           atcNext;
  309.     atCommFlavors       atcFlavor;
  310.  
  311.     UNION(atcFlavor)
  312.     {
  313.     CASE(AC_DLL_IMPORT)
  314.         Linkage             atcImpLink;
  315.  
  316. //  CASE(AC_COM_METHOD)
  317.  
  318.     CASE(AC_CONDITIONAL)
  319.         bool                atcCondYes;
  320.  
  321.     CASE(AC_COM_INTF)
  322.     CASE(AC_COM_REGISTER)
  323.         struct
  324.         {
  325.             ConstStr            atcGUID;
  326.             bool                atcDual;
  327.         }
  328.                             atcReg;
  329.  
  330.     CASE(AC_COM_METHOD)
  331.         struct
  332.         {
  333.             signed int          atcVToffs;  // -1 means "none specified"
  334.             signed int          atcDispid;  // -1 means "none specified"
  335.         }
  336.                             atcMethod;
  337.  
  338.     CASE(AC_COM_PARAMS)
  339.         MethArgInfo         atcParams;
  340.  
  341.     CASE(AC_DLL_STRUCT)
  342.         struct
  343.         {
  344.             unsigned    char    atcPack;
  345.             unsigned    char    atcStrings; // matches Interop::CharacterSet
  346.         }
  347.                             atcStruct;
  348.  
  349.     CASE(AC_DLL_STRUCTMAP)
  350.         MarshalInfo         atcMarshal;
  351.     }
  352.                         atcInfo;
  353. };
  354.  
  355. /*****************************************************************************
  356.  *
  357.  *  The following holds information about a linkage specifier.
  358.  */
  359.  
  360. DEFMGMT
  361. class LinkDesc
  362. {
  363. public:
  364.  
  365.     const   char *  ldDLLname;          // DLL name
  366.     const   char *  ldSYMname;          // entry point name
  367.  
  368.     unsigned        ldStrings   :4;     // 0=none,1=auto,2=ANSI,3=Unicode,4=Ole
  369.     unsigned        ldLastErr   :1;     // lasterror set by fn?
  370.     unsigned        ldCallCnv   :3;     // CC_xxx (see above)
  371. };
  372.  
  373. #if MGDDATA
  374.  
  375. inline
  376. void                copyLinkDesc(Linkage dst, Linkage src)
  377. {
  378.     dst->ldDLLname = src->ldDLLname;
  379.     dst->ldSYMname = src->ldSYMname;
  380.     dst->ldStrings = src->ldStrings;
  381.     dst->ldLastErr = src->ldLastErr;
  382. }
  383.  
  384. #else
  385.  
  386. inline
  387. void                copyLinkDesc(LinkDesc & dst, Linkage src)
  388. {
  389.     memcpy(&dst, src, sizeof(dst));
  390. }
  391.  
  392. #endif
  393.  
  394. /*****************************************************************************
  395.  *
  396.  *  The following holds any "extra" (rare) information about a symbol.
  397.  */
  398.  
  399. enum    xinfoKinds
  400. {
  401.     XI_NONE,
  402.     XI_LINKAGE,
  403.     XI_MARSHAL,
  404.     XI_SECURITY,
  405.     XI_ATCOMMENT,
  406.     XI_ATTRIBUTE,
  407.  
  408.     XI_UNION_TAG,
  409.     XI_UNION_MEM,
  410.  
  411.     XI_COUNT
  412. };
  413.  
  414. DEFMGMT
  415. class   XinfoDsc
  416. {
  417. public:
  418.     SymXinfo        xiNext;
  419.     xinfoKinds      xiKind;
  420. };
  421.  
  422. DEFMGMT
  423. class   XinfoLnk  : public XinfoDsc         // linkage descriptor
  424. {
  425. public:
  426.     LinkDesc        xiLink;
  427. };
  428.  
  429. DEFMGMT
  430. class   XinfoSec  : public XinfoDsc         // security specification
  431. {
  432. public:
  433.     SecurityInfo    xiSecInfo;
  434. };
  435.  
  436. DEFMGMT
  437. class   XinfoAtc  : public XinfoDsc         // @comment
  438. {
  439. public:
  440.     AtComment       xiAtcInfo;
  441. };
  442.  
  443. DEFMGMT
  444. class   XinfoCOM  : public XinfoDsc         // COM marshalling info
  445. {
  446. public:
  447.     MarshalInfo     xiCOMinfo;
  448. };
  449.  
  450. DEFMGMT
  451. class   XinfoAttr : public XinfoDsc         // custom attribute
  452. {
  453. public:
  454.     SymDef          xiAttrCtor;
  455.     unsigned        xiAttrMask;
  456.     size_t          xiAttrSize;
  457.     genericBuff     xiAttrAddr;
  458. };
  459.  
  460. DEFMGMT
  461. class   XinfoSym  : public XinfoDsc         // tagged/anonymous union info
  462. {
  463. public:
  464.     SymDef          xiSymInfo;
  465. };
  466.  
  467. /*****************************************************************************/
  468.  
  469. struct  strCnsDsc;
  470. typedef strCnsDsc *     strCnsPtr;
  471. struct  strCnsDsc
  472. {
  473.     strCnsPtr       sclNext;
  474.     mdToken         sclTok;
  475.     size_t          sclAddr;
  476. };
  477.  
  478. /*****************************************************************************/
  479.  
  480. enum    dclModBits
  481. {
  482.     DB_NONE,
  483.  
  484.     DB_STATIC,
  485.     DB_EXTERN,
  486.     DB_VIRTUAL,
  487.     DB_ABSTRACT,
  488.     DB_OVERRIDE,
  489.     DB_INLINE,
  490.     DB_EXCLUDE,
  491.     DB_SEALED,
  492.     DB_OVERLOAD,
  493.     DB_NATIVE,
  494.  
  495.     DB_CONST,
  496.     DB_VOLATILE,
  497.  
  498.     DB_MANAGED,
  499.     DB_UNMANAGED,
  500.     DB_UNSAFE,
  501.  
  502.     DB_PROPERTY,
  503.  
  504.     DB_TRANSIENT,
  505.     DB_SERLZABLE,
  506.  
  507.     DB_DEFAULT,
  508.     DB_MULTICAST,
  509.  
  510.     DB_ALL,
  511.     DB_RESET = DB_ALL-1,
  512.  
  513.     DB_TYPEDEF,
  514.     DB_XMODS,
  515.  
  516.     DB_CLEARED
  517. };
  518.  
  519. enum    dclMods
  520. {
  521.     DM_STATIC    = (1 <<  DB_STATIC   ),
  522.     DM_EXTERN    = (1 <<  DB_EXTERN   ),
  523.     DM_VIRTUAL   = (1 <<  DB_VIRTUAL  ),
  524.     DM_ABSTRACT  = (1 <<  DB_ABSTRACT ),
  525.     DM_OVERRIDE  = (1 <<  DB_OVERRIDE ),
  526.     DM_INLINE    = (1 <<  DB_INLINE   ),
  527.     DM_EXCLUDE   = (1 <<  DB_EXCLUDE  ),
  528.     DM_SEALED    = (1 <<  DB_SEALED   ),
  529.     DM_OVERLOAD  = (1 <<  DB_OVERLOAD ),
  530.     DM_NATIVE    = (1 <<  DB_NATIVE   ),
  531.  
  532.     DM_CONST     = (1 <<  DB_CONST    ),
  533.     DM_VOLATILE  = (1 <<  DB_VOLATILE ),
  534.  
  535.     DM_MANAGED   = (1 <<  DB_MANAGED  ),
  536.     DM_UNMANAGED = (1 <<  DB_UNMANAGED),
  537.     DM_UNSAFE    = (1 <<  DB_UNSAFE   ),
  538.  
  539.     DM_PROPERTY  = (1 <<  DB_PROPERTY ),
  540.  
  541.     DM_TRANSIENT = (1 <<  DB_TRANSIENT),
  542.     DM_SERLZABLE = (1 <<  DB_SERLZABLE),
  543.  
  544.     DM_DEFAULT   = (1 <<  DB_DEFAULT  ),
  545.     DM_MULTICAST = (1 <<  DB_MULTICAST),
  546.  
  547.     DM_TYPEDEF   = (1 <<  DB_TYPEDEF  ),        // used only for file-scope typedefs
  548.     DM_XMODS     = (1 <<  DB_XMODS    ),        // security modifier / other stuff present
  549.  
  550.     DM_CLEARED   = (1 <<  DB_CLEARED  ),        // modifiers have not been parsed
  551.  
  552.     DM_ALL       =((1 <<  DB_ALL) - 1 )         // used for masking
  553. };
  554.  
  555. struct  declMods
  556. {
  557.     unsigned        dmMod   :24;        // mask of DM_xxx above
  558.     unsigned char   dmAcc   : 8;        // type is accessLevels
  559. };
  560.  
  561. inline
  562. DeclMod             clearDeclMods(DeclMod mods)
  563. {
  564.     mods->dmMod = 0;
  565.     mods->dmAcc = ACL_DEFAULT;
  566.  
  567.     return  mods;
  568. }
  569.  
  570. inline
  571. DeclMod              initDeclMods(DeclMod mods, accessLevels acc)
  572. {
  573.     mods->dmMod = 0;
  574.     mods->dmAcc = acc;
  575.  
  576.     return  mods;
  577. }
  578.  
  579. enum dclrtrName
  580. {
  581.     DN_NONE     = 0,
  582.     DN_OPTIONAL = 1,
  583.     DN_REQUIRED = 2,
  584.     DN_MASK     = 3,
  585.  
  586.     DN_QUALOK = 0x80                    // combine with others to allow "foo.bar"
  587. };
  588.  
  589. /*****************************************************************************/
  590.  
  591. DEFMGMT
  592. class StrListRec
  593. {
  594. public:
  595.  
  596.     StrList             slNext;
  597.     stringBuff          slString;
  598. };
  599.  
  600. /*****************************************************************************/
  601.  
  602. DEFMGMT
  603. class BlkListRec
  604. {
  605. public:
  606.  
  607.     BlkList             blNext;
  608.     genericRef          blAddr;
  609. };
  610.  
  611. /*****************************************************************************/
  612.  
  613. DEFMGMT
  614. class   NumPairDsc
  615. {
  616. public:
  617.     unsigned            npNum1;
  618.     unsigned            npNum2;
  619. };
  620.  
  621. /*****************************************************************************/
  622.  
  623. DEFMGMT
  624. class   constStr
  625. {
  626. public:
  627.     size_t              csLen;
  628.     stringBuff          csStr;
  629. };
  630.  
  631. DEFMGMT
  632. class constVal
  633. {
  634. public:
  635.  
  636.     TypDef              cvType;
  637.  
  638. #ifdef  DEBUG
  639.     var_types           cvVtyp;
  640. #else
  641.     unsigned char       cvVtyp;
  642. #endif
  643.  
  644.     unsigned char       cvIsStr;    // is this a string constant?
  645.     unsigned char       cvHasLC;    // is this a string constant with large chars?
  646.  
  647.     union
  648.     {
  649.         __int32             cvIval;
  650.         __int64             cvLval;
  651.         float               cvFval;
  652.         double              cvDval;
  653.         ConstStr            cvSval;
  654.     }
  655.                         cvValue;
  656. };
  657.  
  658. /*****************************************************************************
  659.  *
  660.  *  Bitsets are used to detect uninitialized variable use. Basically, if there
  661.  *  is a small numbers of locals we need to track, we use a simple integer bit
  662.  *  variable, otherwise we have to use a dynamically sized array of bits. The
  663.  *  bitsetDsc structure holds the data for each instance of a bitset, all of
  664.  *  global state (and code that implements the behavior) is in the compiler
  665.  *  for efficiency class.
  666.  */
  667.  
  668. #ifdef  __64BIT__
  669. const   size_t          bitsetSmallSize = 64;
  670. typedef __uint64        bitsetSmallType;
  671. #else
  672. const   size_t          bitsetSmallSize = 32;
  673. typedef __uint32        bitsetSmallType;
  674. #endif
  675.  
  676. const   size_t          bitsetLargeSize =  8;
  677. typedef genericBuff     bitsetLargeType;
  678.  
  679. DEFMGMT
  680. struct  bitset
  681. {
  682. #ifdef  DEBUG
  683.     unsigned            bsCheck;
  684. #endif
  685.     union
  686.     {
  687.         bitsetSmallType     bsSmallVal;
  688.         bitsetLargeType     bsLargeVal;
  689.     };
  690. };
  691.  
  692. /*****************************************************************************
  693.  *
  694.  *  The following keeps track of statement nesting when compiling statements.
  695.  */
  696.  
  697. DEFMGMT
  698. struct  stmtNestRec
  699. {
  700.     StmtNest            snOuter;
  701.     Tree                snStmtExpr;
  702.     treeOps             snStmtKind;
  703.     SymDef              snLabel;
  704.     ILblock             snLabCont;
  705.     ILblock             snLabBreak;
  706.     bool                snHadCont;
  707.     bool                snHadBreak;
  708.     bitset              snDefCont;
  709.     bitset              snDefBreak;
  710. };
  711.  
  712. /*****************************************************************************
  713.  *
  714.  *  The max. inline buffer size for conversions to Unicode.
  715.  */
  716.  
  717. const   unsigned        MAX_INLINE_NAME_LEN = 32;
  718.  
  719. /*****************************************************************************
  720.  *
  721.  *  Metadata import state - one is allocated per each file imported.
  722.  */
  723.  
  724. DEFMGMT
  725. class   metadataImp
  726. {
  727. private:
  728.  
  729.     Compiler            MDcomp;
  730.     SymTab              MDstab;
  731.  
  732.     WCHAR               MDprevNam[MAX_PACKAGE_NAME];
  733.     SymDef              MDprevSym;
  734.  
  735.     mdToken             MDdelegTok;
  736.  
  737.     mdToken             MDclsRefObsolete;           // typeref for System::ObsoleteAttribute
  738.     mdToken             MDclsDefObsolete;           // typedef for System::ObsoleteAttribute
  739.  
  740.  
  741.     mdToken             MDclsRefAttribute;          // typeref for System::Attribute
  742.     mdToken             MDclsDefAttribute;          // typedef for System::Attribute
  743.     mdToken             MDctrDefAttribute1;         // methdef for System::Attribute::ctor(arg1)
  744.     mdToken             MDctrDefAttribute2;         // methdef for System::Attribute::ctor(arg2)
  745.     mdToken             MDctrDefAttribute3;         // methdef for System::Attribute::ctor(arg3)
  746.     mdToken             MDctrRefAttribute1;         // methref for System::Attribute::ctor(arg1)
  747.     mdToken             MDctrRefAttribute2;         // methref for System::Attribute::ctor(arg2)
  748.     mdToken             MDctrRefAttribute3;         // methref for System::Attribute::ctor(arg3)
  749.  
  750. public:
  751.  
  752.     MetaDataImp         MDnext;
  753.  
  754.     unsigned            MDnum;                      // importer index (used for lookups)
  755.  
  756.     WMetaDataImport    *MDwmdi;
  757.  
  758.     void                MDinit(Compiler             comp,
  759.                                SymTab               stab)
  760.     {
  761.         MDcomp = comp;
  762.         MDstab = stab;
  763.         MDwmdi = NULL;
  764.  
  765.         MDfileTok    = 0;
  766.  
  767.         MDprevNam[0] = 0;
  768.  
  769.         MDundefCount = 0;
  770.     }
  771.  
  772.     void                MDinit(WMetaDataImport  *   wmdi,
  773.                                Compiler             comp,
  774.                                SymTab               stab)
  775.     {
  776.         MDcomp = comp;
  777.         MDstab = stab;
  778.         MDwmdi = wmdi;
  779.  
  780.         MDprevNam[0] = 0;
  781.     }
  782.  
  783.     unsigned            MDundefCount;           // bumped for unrecognized stuff
  784.  
  785.     void                MDimportCTyp(mdTypeDef      td,
  786.                                      mdToken        ft);
  787.  
  788.     SymDef              MDimportClss(mdTypeDef      td,
  789.                                      SymDef         clsSym,
  790.                                      unsigned       assx,
  791.                                      bool           deep);
  792.     void                MDimportStab(const char *   fname,
  793.                                      unsigned       assx    = 0,
  794.                                      bool           asmOnly = false,
  795.                                      bool           isBCL   = false);
  796.  
  797.     TypDef              MDimportClsr(mdTypeRef      clsRef,
  798.                                      bool           isVal);
  799.     TypDef              MDimportType(MDsigImport  * sig);
  800.  
  801.     ArgDef              MDimportArgs(MDsigImport  * sig,
  802.                                      unsigned       cnt,
  803.                                      MDargImport  * state);
  804.  
  805.     bool                MDfindAttr  (mdToken        token,
  806.                                      wideStr        name,
  807.                                      const void * * blobAddr,
  808.                                      ULONG        * blobSize);
  809.  
  810.     SymDef              MDfindPropMF(SymDef         propSym,
  811.                                      mdToken        methTok,
  812.                                      bool           getter);
  813.  
  814.     SymDef              MDimportMem(SymDef          scope,
  815.                                     Ident           name,
  816.                                     mdToken         memTok,
  817.                                     unsigned        attrs,
  818.                                     bool            isProp,
  819.                                     bool            fileScope,
  820.                                     PCCOR_SIGNATURE sigAddr,
  821.                                     size_t          sigSize);
  822.  
  823.     accessLevels        MDgetAccessLvl(unsigned attrs);
  824.  
  825.     SymDef              MDparseDotted(WCHAR *name, symbolKinds kind, bool *added);
  826.     Ident               MDhashWideName(WCHAR *name);
  827.  
  828.     void                MDchk4CustomAttrs(SymDef sym, mdToken tok);
  829.  
  830. private:
  831.  
  832.     unsigned            MDassIndex;                 // assembly index or 0
  833.     mdToken             MDfileTok;
  834.  
  835.     void                MDcreateFileTok();
  836.  
  837. public:
  838.  
  839.     void                MDrecordFile()
  840.     {
  841.         if  (!MDfileTok && MDassIndex)
  842.             MDcreateFileTok();
  843.     }
  844. };
  845.  
  846. /*****************************************************************************
  847.  *
  848.  *  The following is used to save/restore the current symbol table context.
  849.  */
  850.  
  851. DEFMGMT
  852. struct STctxSave
  853. {
  854.     SymDef              ctxsScp;
  855.     SymDef              ctxsCls;
  856.     SymDef              ctxsNS;
  857.     UseList             ctxsUses;
  858.     SymDef              ctxsComp;
  859.     SymDef              ctxsFncSym;
  860.     TypDef              ctxsFncTyp;
  861. };
  862.  
  863. /*****************************************************************************/
  864. #ifdef  SETS
  865. /*****************************************************************************/
  866.  
  867. const   unsigned        COLL_STATE_VALS   = 8;  // please don't ask, it's too horrible ...
  868.  
  869. const   AnsiStr         CFC_CLSNAME_PREFIX= "$DB-state$";
  870.  
  871. const   AnsiStr         CFC_ARGNAME_ITEM  = "$item";
  872. const   AnsiStr         CFC_ARGNAME_ITEM1 = "$item1";
  873. const   AnsiStr         CFC_ARGNAME_ITEM2 = "$item2";
  874. const   AnsiStr         CFC_ARGNAME_STATE = "$state";
  875.  
  876. DEFMGMT
  877. class funcletDesc
  878. {
  879. public:
  880.  
  881.     funcletList         fclNext;
  882.     SymDef              fclFunc;
  883.     SaveTree            fclExpr;
  884. };
  885.  
  886. DEFMGMT
  887. struct collOpNest
  888. {
  889.     collOpList          conOuter;
  890.     int                 conIndex;
  891.     SymDef              conIterVar;
  892. };
  893.  
  894. /*****************************************************************************/
  895. #endif//SETS
  896. /*****************************************************************************
  897.  *
  898.  *  The following describes an overlapped I/O file.
  899.  */
  900.  
  901. #ifdef  ASYNCH_INPUT_READ
  902.  
  903. DEFMGMT
  904. class   queuedFile
  905. {
  906. public:
  907.     QueuedFile      qfNext;
  908.  
  909.     Compiler        qfComp;
  910.  
  911.     const   char *  qfName;         // name of the file
  912.     size_t          qfSize;         // size in bytes
  913.     void    *       qfBuff;         // address of contents (or NULL)
  914.     HANDLE          qfHandle;       // handle when file is open
  915.     HANDLE          qfEvent;        // signalled when entire contents read
  916.  
  917. #ifdef  DEBUG
  918.     QueuedFile      qfSelf;
  919. #endif
  920.  
  921.     OVERLAPPED      qfOdsc;
  922.  
  923.     bool            qfReady;        // file is ready to be open
  924.     bool            qfOpen;         // file is being read
  925.     bool            qfDone;         // file has been read
  926.     bool            qfParsing;      // file is bein compiled
  927. };
  928.  
  929. #else
  930.  
  931. DEFMGMT
  932. class   queuedFile
  933. {
  934. };
  935.  
  936. #endif
  937.  
  938. /*****************************************************************************
  939.  *
  940.  *  The following defines state and members/methods that are global to the
  941.  *  compilation process.
  942.  */
  943.  
  944. DEFMGMT
  945. class compiler
  946. {
  947. public:
  948.  
  949.     compConfig          cmpConfig;
  950.  
  951.     /************************************************************************/
  952.     /* Main entry points for the compilation process                        */
  953.     /************************************************************************/
  954.  
  955.     bool                cmpInit();
  956.  
  957.     static
  958.     bool                cmpPrepSrc(genericRef cookie, stringBuff file,
  959.                                                       QueuedFile buff    = NULL,
  960.                                                       stringBuff srcText = NULL);
  961.  
  962.     bool                cmpStart(const char *defOutFileName);
  963.     bool                cmpClass(const char *className = NULL);
  964.  
  965.     bool                cmpDone(bool errors);
  966.  
  967.     void                cmpPrepOutput();
  968.  
  969.     void                cmpOutputFileDone(OutFile outf){}
  970.  
  971.     WritePE             cmpPEwriter;
  972.  
  973.     /************************************************************************/
  974.     /* Current public state of the compilation process                      */
  975.     /************************************************************************/
  976.  
  977. public:
  978.  
  979.     SymTab              cmpCurST;           // current symbol table
  980.     SymDef              cmpCurNS;           // the namespace   we're in
  981.     SymDef              cmpCurCls;          // the class scope we're in
  982.     SymDef              cmpCurScp;          // the local scope we're in
  983.     SymDef              cmpLabScp;          // the label scope we're using
  984.     UseList             cmpCurUses;         // the "using" clauses in effect
  985.     SymDef              cmpCurComp;         // the current compilation unit
  986.  
  987. #ifdef  SETS
  988. //  SymDef              cmpOuterScp;        // lookup scopes outside of global
  989. #endif
  990.  
  991.     SymDef              cmpCurFncSym;       // function symbol we're compiling
  992.     TypDef              cmpCurFncTyp;       // function  type  we're compiling
  993.     TypDef              cmpCurFncRtp;       // function return type
  994.     var_types           cmpCurFncRvt;       // function return type
  995.  
  996.     SymList             cmpLclStatListT;    // temp list of local static variables
  997.     SymList             cmpLclStatListP;    // perm list of local static variables
  998.  
  999.     bool                cmpManagedMode;     // is default "managed" ?
  1000.  
  1001.     ILblock             cmpLeaveLab;        // return from try/catch label / NULL
  1002.     SymDef              cmpLeaveTmp;        // return value temp
  1003.  
  1004.     unsigned            cmpInTryBlk;
  1005.     unsigned            cmpInHndBlk;
  1006.     unsigned            cmpInFinBlk;
  1007.  
  1008. private:
  1009.  
  1010.     /************************************************************************/
  1011.     /* Various members used in the compilation process                      */
  1012.     /************************************************************************/
  1013.  
  1014.     SymDef              cmpAsserAbtSym;
  1015.  
  1016. public:
  1017.  
  1018.     unsigned            cmpFncCntSeen;
  1019.     unsigned            cmpFncCntComp;
  1020.  
  1021.     Ident               cmpIdentMain;
  1022.     SymDef              cmpFnSymMain;
  1023.     mdToken             cmpTokenMain;
  1024.  
  1025.     Ident               cmpIdentVAbeg;
  1026.     SymDef              cmpFNsymVAbeg;
  1027.     Ident               cmpIdentVAget;
  1028.     SymDef              cmpFNsymVAget;
  1029.  
  1030.     Ident               cmpIdentCompare;
  1031.     Ident               cmpIdentEquals;
  1032.     Ident               cmpIdentNarrow;
  1033.     Ident               cmpIdentWiden;
  1034.  
  1035.     Ident               cmpIdentGet;
  1036.     Ident               cmpIdentSet;
  1037.     Ident               cmpIdentExit;
  1038.     Ident               cmpIdentEnter;
  1039.     Ident               cmpIdentConcat;
  1040.     Ident               cmpIdentInvoke;
  1041.     Ident               cmpIdentInvokeBeg;
  1042.     Ident               cmpIdentInvokeEnd;
  1043.     Ident               cmpIdentVariant;
  1044.     Ident               cmpIdentToString;
  1045.     Ident               cmpIdentGetType;
  1046.     Ident               cmpIdentGetTpHnd;
  1047.     Ident               cmpIdentAssertAbt;
  1048.  
  1049.     Ident               cmpIdentDbgBreak;
  1050.  
  1051.     Ident               cmpIdentXcptCode;
  1052.     Ident               cmpIdentXcptInfo;
  1053.     Ident               cmpIdentAbnmTerm;
  1054.  
  1055.     Ident               cmpIdentGetNArg;
  1056.     SymDef              cmpGetNextArgFN;    // ArgIterator::GetNextArg(int)
  1057.  
  1058.     SymDef              cmpCtorArgIter;     // ArgIterator(int,int)
  1059.  
  1060.     SymDef              cmpConcStr2Fnc;     // Concat(String,String)
  1061.     SymDef              cmpConcStr3Fnc;     // Concat(String,String,String)
  1062.     SymDef              cmpConcStrAFnc;     // Concat(String[])
  1063.  
  1064.     SymDef              cmpStrCompare;      // string value comparison method
  1065.     SymDef              cmpStrEquals;       // string value equality   method
  1066.  
  1067.     SymDef              cmpFindStrCompMF(const char *name, bool retBool);
  1068.     Tree                cmpCallStrCompMF(Tree expr,
  1069.                                          Tree  op1,
  1070.                                          Tree  op2, SymDef fsym);
  1071.  
  1072.     SymDef              cmpFNsymCSenter;    // CriticalSection::Enter
  1073.     SymDef              cmpFNsymCSexit;     // CriticalSection::Exit
  1074.  
  1075.     mdToken             cmpAttrDeprec;      // attribute ref for "Deprecated"
  1076.     mdToken             cmpAttrIsDual;      // attribute ref for "IsDual"
  1077.     mdToken             cmpAttrDefProp;     // attribute ref for "DefaultMemberAttribute"
  1078.     mdToken             cmpAttrSerlzb;      // attribute ref for "SerializableAttribute"
  1079.     mdToken             cmpAttrNonSrlz;     // attribute ref for "NonSerializedAttribute"
  1080.  
  1081.     SymDef              cmpAttrClsSym;      // System::Attribute        symbol
  1082.     SymDef              cmpAuseClsSym;      // System::AttributeUsage   symbol
  1083. //  SymDef              cmpAttrTgtSym;      // System::AttributeTargets symbol
  1084.  
  1085.     SymDef              cmpMarshalCls;      // System::Runtime::InteropServices::Marshal
  1086.  
  1087.     SymDef              cmpStringConstCls;  // fake class for unmanaged strings
  1088.  
  1089. #ifdef  SETS
  1090.  
  1091.     SymDef              cmpXPathCls;        // class    XPath
  1092.  
  1093.     SymDef              cmpXMLattrClass;    // class    XPath::XML_Class
  1094.     SymDef              cmpXMLattrElement;  // class    XPath::XML_Element
  1095.  
  1096.     SymDef              cmpInitXMLfunc;     // function XPath::createXMLinst
  1097.  
  1098.     Ident               cmpIdentGenBag;
  1099.     SymDef              cmpClassGenBag;     // generic class "bag"
  1100.     Ident               cmpIdentGenLump;
  1101.     SymDef              cmpClassGenLump;    // generic class "lump"
  1102.  
  1103.     void                cmpFindXMLcls();
  1104.  
  1105.     Ident               cmpIdentCSitem;
  1106.     Ident               cmpIdentCSitem1;
  1107.     Ident               cmpIdentCSitem2;
  1108.     Ident               cmpIdentCSstate;
  1109.  
  1110.     Ident               cmpIdentDBhelper;
  1111.     SymDef              cmpClassDBhelper;
  1112.  
  1113.     Ident               cmpIdentDBall;
  1114.     Ident               cmpIdentDBsort;
  1115.     Ident               cmpIdentDBslice;
  1116.     Ident               cmpIdentDBfilter;
  1117.     Ident               cmpIdentDBexists;
  1118.     Ident               cmpIdentDBunique;
  1119.     Ident               cmpIdentDBproject;
  1120.     Ident               cmpIdentDBgroupby;
  1121.  
  1122.     Ident               cmpIdentForEach;
  1123.     SymDef              cmpClassForEach;
  1124.     SymDef              cmpFNsymForEachCtor;
  1125.     SymDef              cmpFNsymForEachMore;
  1126.  
  1127.     SymDef              cmpCompare2strings; // String::Compare(String,String)
  1128.  
  1129.     SaveTree            cmpCurFuncletBody;
  1130.     void                cmpGenCollFunclet(SymDef fncSym, SaveTree body);
  1131.     SymDef              cmpCollFuncletCls;
  1132.     funcletList         cmpFuncletList;
  1133.  
  1134.     collOpList          cmpCollOperList;
  1135.     unsigned            cmpCollOperCount;
  1136.  
  1137.     void                cmpGenCollExpr (Tree        expr);
  1138.  
  1139.     Tree                cmpCloneExpr   (Tree        expr,
  1140.                                         SymDef      oldSym,
  1141.                                         SymDef      newSym);
  1142.  
  1143.     SaveTree            cmpSaveTree_I1 (SaveTree    dest,
  1144.                                   INOUT size_t REF  size, __int32  val);
  1145.     SaveTree            cmpSaveTree_U1 (SaveTree    dest,
  1146.                                   INOUT size_t REF  size, __uint32 val);
  1147.     SaveTree            cmpSaveTree_U4 (SaveTree    dest,
  1148.                                   INOUT size_t REF  size, __uint32 val);
  1149.     SaveTree            cmpSaveTree_ptr(SaveTree    dest,
  1150.                                   INOUT size_t REF  size, void *   val);
  1151.     SaveTree            cmpSaveTree_buf(SaveTree    dest,
  1152.                                   INOUT size_t REF  size, void * dataAddr,
  1153.                                                           size_t dataSize);
  1154.  
  1155.     size_t              cmpSaveTreeRec (Tree        expr,
  1156.                                         SaveTree    dest,
  1157.                                         unsigned  * stszPtr,
  1158.                                         Tree      * stTable);
  1159.  
  1160. private:
  1161.  
  1162.     unsigned            cmpSaveIterSymCnt;
  1163.     SymDef  *           cmpSaveIterSymTab;
  1164.  
  1165.     #define             MAX_ITER_VAR_CNT    8
  1166.  
  1167. public:
  1168.  
  1169.     SaveTree            cmpSaveExprTree(Tree        expr,
  1170.                                         unsigned    iterSymCnt,
  1171.                                         SymDef    * iterSymTab,
  1172.                                         unsigned  * stSizPtr = NULL,
  1173.                                         Tree    * * stTabPtr = NULL);
  1174.  
  1175.     int                 cmpReadTree_I1 (INOUT SaveTree REF save);
  1176.     unsigned            cmpReadTree_U1 (INOUT SaveTree REF save);
  1177.     unsigned            cmpReadTree_U4 (INOUT SaveTree REF save);
  1178.     void *              cmpReadTree_ptr(INOUT SaveTree REF save);
  1179.     void                cmpReadTree_buf(INOUT SaveTree REF save, size_t dataSize,
  1180.                                                                  void * dataAddr);
  1181.  
  1182.     Tree                cmpReadTreeRec (INOUT SaveTree REF save);
  1183.     Tree                cmpReadExprTree(      SaveTree     save,
  1184.                                               unsigned   * lclCntPtr);
  1185.  
  1186. #endif
  1187.  
  1188.     SymDef              cmpFNsymGetTpHnd;   // Type::GetTypeFromHandle
  1189.     void                cmpFNsymGetTPHdcl();
  1190.     SymDef              cmpFNsymGetTPHget()
  1191.     {
  1192.         if  (!cmpFNsymGetTpHnd)
  1193.             cmpFNsymGetTPHdcl();
  1194.  
  1195.         return  cmpFNsymGetTpHnd;
  1196.     }
  1197.  
  1198.     SymDef              cmpRThandleCls;     // struct System::RuntimeTypeHandle
  1199.     void                cmpRThandleClsDcl();
  1200.     SymDef              cmpRThandleClsGet()
  1201.     {
  1202.         if  (!cmpRThandleCls)
  1203.             cmpRThandleClsDcl();
  1204.  
  1205.         return  cmpRThandleCls;
  1206.     }
  1207.  
  1208.     SymDef              cmpDeclUmgOper(tokens tokName, const char *extName);
  1209.  
  1210.     SymDef              cmpFNumgOperNew;    // unmanaged operator new
  1211.     SymDef              cmpFNumgOperNewGet()
  1212.     {
  1213.         if  (!cmpFNumgOperNew)
  1214.             cmpFNumgOperNew = cmpDeclUmgOper(tkNEW   , "??2@YAPAXI@Z");
  1215.  
  1216.         return  cmpFNumgOperNew;
  1217.     }
  1218.  
  1219.     SymDef              cmpFNumgOperDel;    // unmanaged operator delete
  1220.     SymDef              cmpFNumgOperDelGet()
  1221.     {
  1222.         if  (!cmpFNumgOperDel)
  1223.             cmpFNumgOperDel = cmpDeclUmgOper(tkDELETE, "??3@YAXPAX@Z");
  1224.  
  1225.         return  cmpFNumgOperDel;
  1226.     }
  1227.  
  1228.     Ident               cmpIdentSystem;
  1229.     SymDef              cmpNmSpcSystem;
  1230.  
  1231.     Ident               cmpIdentRuntime;
  1232.     SymDef              cmpNmSpcRuntime;
  1233.  
  1234.     Ident               cmpIdentObject;
  1235.     SymDef              cmpClassObject;
  1236.     TypDef              cmpRefTpObject;
  1237.  
  1238.     Ident               cmpIdentArray;
  1239.     SymDef              cmpClassArray;
  1240.     TypDef              cmpRefTpArray;
  1241.  
  1242.     Ident               cmpIdentString;
  1243.     SymDef              cmpClassString;
  1244.     TypDef              cmpRefTpString;
  1245.  
  1246.     Ident               cmpIdentType;
  1247.     SymDef              cmpClassType;
  1248.     TypDef              cmpRefTpType;
  1249.  
  1250.     Ident               cmpIdentDeleg;
  1251.     SymDef              cmpClassDeleg;
  1252.     TypDef              cmpRefTpDeleg;
  1253.  
  1254.     Ident               cmpIdentMulti;
  1255.     SymDef              cmpClassMulti;
  1256.     TypDef              cmpRefTpMulti;
  1257.  
  1258.     Ident               cmpIdentExcept;
  1259.     SymDef              cmpClassExcept;
  1260.     TypDef              cmpRefTpExcept;
  1261.  
  1262.     Ident               cmpIdentRTexcp;
  1263.     SymDef              cmpClassRTexcp;
  1264.     TypDef              cmpRefTpRTexcp;
  1265.  
  1266.     SymDef              cmpClassMonitor;
  1267.     TypDef              cmpRefTpMonitor;
  1268.  
  1269.     Ident               cmpIdentArgIter;
  1270.     SymDef              cmpClassArgIter;
  1271.     TypDef              cmpRefTpArgIter;
  1272.  
  1273.     Ident               cmpIdentEnum;
  1274.     SymDef              cmpClassEnum;
  1275.  
  1276.     Ident               cmpIdentValType;
  1277.     SymDef              cmpClassValType;
  1278.  
  1279.     TypDef              cmpAsyncDlgRefTp;
  1280.     TypDef              cmpIAsyncRsRefTp;
  1281.  
  1282.     TypDef              cmpFindArgIterType();
  1283.     TypDef              cmpFindMonitorType();
  1284.     TypDef              cmpFindStringType();
  1285.     TypDef              cmpFindObjectType();
  1286.     TypDef              cmpFindExceptType();
  1287.     TypDef              cmpFindRTexcpType();
  1288.     TypDef              cmpFindArrayType();
  1289.     TypDef              cmpFindDelegType();
  1290.     TypDef              cmpFindMultiType();
  1291.     TypDef              cmpFindTypeType();
  1292.  
  1293.     TypDef              cmpExceptRef()
  1294.     {
  1295.         if  (cmpRefTpExcept)
  1296.             return cmpRefTpExcept;
  1297.         else
  1298.             return cmpFindExceptType();
  1299.     }
  1300.  
  1301.     TypDef              cmpRTexcpRef()
  1302.     {
  1303.         if  (cmpRefTpRTexcp)
  1304.             return cmpRefTpRTexcp;
  1305.         else
  1306.             return cmpFindRTexcpType();
  1307.     }
  1308.  
  1309.     TypDef              cmpStringRef()
  1310.     {
  1311.         if  (cmpRefTpString)
  1312.             return cmpRefTpString;
  1313.         else
  1314.             return cmpFindStringType();
  1315.     }
  1316.  
  1317.     TypDef              cmpObjectRef()
  1318.     {
  1319.         if  (cmpRefTpObject)
  1320.             return cmpRefTpObject;
  1321.         else
  1322.             return cmpFindObjectType();
  1323.     }
  1324.  
  1325.     TypDef              cmpTypeRef()
  1326.     {
  1327.         if  (cmpRefTpType)
  1328.             return cmpRefTpType;
  1329.         else
  1330.             return cmpFindTypeType();
  1331.     }
  1332.  
  1333.     TypDef              cmpArrayRef()
  1334.     {
  1335.         if  (cmpRefTpArray)
  1336.             return cmpRefTpArray;
  1337.         else
  1338.             return cmpFindArrayType();
  1339.     }
  1340.  
  1341.     TypDef              cmpDelegRef()
  1342.     {
  1343.         if  (cmpRefTpDeleg)
  1344.             return cmpRefTpDeleg;
  1345.         else
  1346.             return cmpFindDelegType();
  1347.     }
  1348.  
  1349.     TypDef              cmpMultiRef()
  1350.     {
  1351.         if  (cmpRefTpMulti)
  1352.             return cmpRefTpMulti;
  1353.         else
  1354.             return cmpFindMultiType();
  1355.     }
  1356.  
  1357.     TypDef              cmpArgIterRef()
  1358.     {
  1359.         if  (cmpRefTpArgIter)
  1360.             return cmpRefTpArgIter;
  1361.         else
  1362.             return cmpFindArgIterType();
  1363.     }
  1364.  
  1365.     TypDef              cmpMonitorRef()
  1366.     {
  1367.         if  (cmpRefTpMonitor)
  1368.             return cmpRefTpMonitor;
  1369.         else
  1370.             return cmpFindMonitorType();
  1371.     }
  1372.  
  1373.     void                cmpInteropFind();
  1374.     SymDef              cmpInteropSym;      // System::Runtime::InteropServices
  1375.     SymDef              cmpInteropGet()
  1376.     {
  1377.         if  (!cmpInteropSym)
  1378.             cmpInteropFind();
  1379.  
  1380.         return  cmpInteropSym;
  1381.     }
  1382.  
  1383.     void                cmpNatTypeFind();
  1384.     SymDef              cmpNatTypeSym;      // System::Runtime::InteropServices::NativeType
  1385.     SymDef              cmpNatTypeGet()
  1386.     {
  1387.         if  (!cmpNatTypeSym)
  1388.             cmpNatTypeFind();
  1389.  
  1390.         return  cmpNatTypeSym;
  1391.     }
  1392.  
  1393.     void                cmpCharSetFind();
  1394.     SymDef              cmpCharSetSym;      // System::Runtime::InteropServices::CharacterSet
  1395.     SymDef              cmpCharSetGet()
  1396.     {
  1397.         if  (!cmpCharSetSym)
  1398.             cmpCharSetFind();
  1399.  
  1400.         return  cmpCharSetSym;
  1401.     }
  1402.  
  1403. #ifdef  SETS
  1404.  
  1405.     TypDef              cmpObjArrTypeFind();
  1406.     TypDef              cmpObjArrType;      // Object[]
  1407.  
  1408.     TypDef              cmpObjArrTypeGet()
  1409.     {
  1410.         if  (!cmpObjArrType)
  1411.             cmpObjArrTypeFind();
  1412.  
  1413.         return  cmpObjArrType;
  1414.     }
  1415.  
  1416. #endif
  1417.  
  1418.     bool                cmpIsByRefType(TypDef type);
  1419.  
  1420.     bool                cmpIsStringVal(Tree   expr);
  1421.     bool                cmpIsObjectVal(Tree   expr);
  1422.  
  1423.     unsigned            cmpIsBaseClass(TypDef baseCls, TypDef dervCls);
  1424.  
  1425. private:
  1426.     unsigned            cmpCntAnonymousNames;
  1427. public:
  1428.     Ident               cmpNewAnonymousName();
  1429.  
  1430.     void                cmpMarkStdType(SymDef clsSym);
  1431.  
  1432. private:
  1433.  
  1434.     void                cmpFindHiddenBaseFNs(SymDef fncSym, SymDef clsSym);
  1435.  
  1436.     SymList             cmpNoDimArrVars;
  1437.  
  1438.     Tree                cmpTypeIDinst(TypDef type);
  1439.  
  1440. #ifdef  DEBUG
  1441.     SymDef              cmpInitVarCur;
  1442.     unsigned            cmpInitVarOfs;
  1443. #endif
  1444.  
  1445.     memBuffPtr          cmpWriteVarData(memBuffPtr      dest,
  1446.                                         genericBuff     str,
  1447.                                         size_t          len);
  1448.  
  1449.     memBuffPtr          cmpInitVarPad  (memBuffPtr      dest,
  1450.                                         size_t          amount);
  1451.  
  1452.     bool                cmpInitVarAny  (INOUT memBuffPtr REF dest,
  1453.                                         TypDef          type,
  1454.                                         SymDef          varSym = NULL);
  1455.     bool                cmpInitVarScl  (INOUT memBuffPtr REF dest,
  1456.                                         TypDef          type,
  1457.                                         SymDef          varSym = NULL);
  1458.     bool                cmpInitVarArr  (INOUT memBuffPtr REF dest,
  1459.                                         TypDef          type,
  1460.                                         SymDef          varSym = NULL);
  1461.     bool                cmpInitVarCls  (INOUT memBuffPtr REF dest,
  1462.                                         TypDef          type,
  1463.                                         SymDef          varSym = NULL);
  1464.  
  1465.     memBuffPtr          cmpWriteOneInit(memBuffPtr      dest,
  1466.                                         Tree            expr);
  1467.     memBuffPtr          cmpInitVarBeg  (SymDef          varSym,
  1468.                                         bool            undim = false);
  1469.     void                cmpInitVarEnd  (SymDef          varSym);
  1470.     Tree                cmpParseOneInit(TypDef          type);
  1471.  
  1472.     void                cmpBindUseList (UseList         useList);
  1473.  
  1474.     SymDef              cmpEntryPointCls;
  1475.     void                cmpChk4entryPt (SymDef          sym);
  1476.  
  1477.     SymDef              cmpDeclDataMem (SymDef          clsSym,
  1478.                                         declMods        memMod,
  1479.                                         TypDef          type,
  1480.                                         Ident           name);
  1481.  
  1482.     SymDef              cmpDeclPropMem (SymDef          clsSym,
  1483.                                         TypDef          type,
  1484.                                         Ident           name);
  1485.  
  1486.     SymDef              cmpDeclFuncMem (SymDef          clsSym,
  1487.                                         declMods        memMod,
  1488.                                         TypDef          type,
  1489.                                         Ident           name);
  1490.  
  1491.     SymXinfo            cmpFindXtraInfo(SymXinfo        infoList,
  1492.                                         xinfoKinds      infoKind);
  1493.  
  1494.     SymXinfoCOM         cmpFindMarshal (SymXinfo        infoList);
  1495.     SymXinfoLnk         cmpFindLinkInfo(SymXinfo        infoList);
  1496.     SymXinfoSec         cmpFindSecSpec (SymXinfo        infoList);
  1497.     SymXinfoSym         cmpFindSymInfo (SymXinfo        infoList,
  1498.                                         xinfoKinds      kind);
  1499.     SymXinfoAtc         cmpFindATCentry(SymXinfo        infoList,
  1500.                                         atCommFlavors   flavor);
  1501.  
  1502.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1503.                                         SymXinfo        infoAdd)
  1504.     {
  1505.         if  (infoAdd)
  1506.         {
  1507.             infoAdd->xiNext = infoList;
  1508.             return infoAdd;
  1509.         }
  1510.         else
  1511.             return infoList;
  1512.     }
  1513.  
  1514.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1515.                                         MarshalInfo     marshal);
  1516.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1517.                                         SymDef          sym,
  1518.                                         xinfoKinds      kind);
  1519.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1520.                                         SecurityInfo    secInfo);
  1521.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1522.                                         AtComment        atcDesc);
  1523.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1524.                                         Linkage         linkSpec);
  1525.  
  1526. public: // used in the parser
  1527.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1528.                                         SymDef          attrCtor,
  1529.                                         unsigned        attrMask,
  1530.                                         size_t          attrSize,
  1531.                                         genericBuff     attrAddr);
  1532.  
  1533. public:
  1534.     static
  1535.     size_t              cmpDecodeAlign (unsigned        alignVal);
  1536.     static
  1537.     unsigned            cmpEncodeAlign (size_t          alignSiz);
  1538.  
  1539. private:
  1540.  
  1541.     void                cmpLayoutClass (SymDef          clsSym);
  1542.  
  1543.     TypDef              cmpGetClassSpec(bool            needIntf);
  1544.  
  1545.     void                cmpObsoleteUse (SymDef          sym,
  1546.                                         unsigned        wrn);
  1547.  
  1548.     SymDef              cmpFindIntfImpl(SymDef          clsSym,
  1549.                                         SymDef          ifcSym,
  1550.                                         SymDef        * impOvlPtr = NULL);
  1551.  
  1552.     void                cmpClsImplAbs  (SymDef          clsSym,
  1553.                                         SymDef          fncSym);
  1554.  
  1555.     void                cmpCheckClsIntf(SymDef          clsSym);
  1556.  
  1557.     void                cmpCheckIntfLst(SymDef          clsSym,
  1558.                                         SymDef          baseSym,
  1559.                                         TypList         intfList);
  1560.  
  1561.     void                cmpDeclProperty(SymDef          memSym,
  1562.                                         declMods        memMod,
  1563.                                         DefList         memDef);
  1564.     void                cmpDeclDelegate(DefList         decl,
  1565.                                         SymDef          dlgSym,
  1566.                                         accessLevels    acc);
  1567.  
  1568.     void                cmpDeclTdef    (SymDef          tdefSym);
  1569.     void                cmpDeclEnum    (SymDef          enumSym,
  1570.                                         bool            namesOnly = false);
  1571.  
  1572.     unsigned            cmpDeclClassRec;
  1573.     void                cmpDeclClass   (SymDef          clsSym,
  1574.                                         bool            noCnsEval = false);
  1575.     void                cmpCompClass   (SymDef          clsSym);
  1576.     void                cmpCompVar     (SymDef          varSym,
  1577.                                         DefList         srcDesc);
  1578.     void                cmpCompFnc     (SymDef          fncSym,
  1579.                                         DefList         srcDesc);
  1580.  
  1581.     ExtList             cmpFlipMemList (ExtList         nspMem);
  1582.  
  1583.     IniList             cmpDeferCnsFree;
  1584.     IniList             cmpDeferCnsList;
  1585.  
  1586.     void                cmpEvalMemInit (ExtList         cnsDef);
  1587.     void                cmpEvalMemInits(SymDef          clsSym,
  1588.                                         ExtList         constList,
  1589.                                         bool            noEval,
  1590.                                         IniList         deferLst);
  1591.  
  1592.     void                cmpEvalCnsSym  (SymDef          sym,
  1593.                                         bool            saveCtx);
  1594.  
  1595.     void                cmpDeclConsts  (SymDef          scope,
  1596.                                         bool            fullEval);
  1597.  
  1598.     bool                cmpDeclSym     (SymDef          sym,
  1599.                                         SymDef          onlySym,
  1600.                                         bool            recurse);
  1601.  
  1602.     bool                cmpCompSym     (SymDef          sym,
  1603.                                         SymDef          onlySym,
  1604.                                         bool            recurse);
  1605.  
  1606.     void                cmpDeclFileSym (ExtList         decl,
  1607.                                         bool            fullDecl);
  1608.  
  1609.     bool                cmpDeclSymDoit (SymDef          sym,
  1610.                                         bool            noCnsEval = false);
  1611.  
  1612.     bool                cmpDeclClsNoCns(SymDef          sym);
  1613.  
  1614.     void                cmpSaveSTctx   (STctxSave      & save);
  1615.     void                cmpRestSTctx   (STctxSave      & save);
  1616.  
  1617. public:
  1618.  
  1619.     bool                cmpDeclSym     (SymDef          sym);
  1620.  
  1621.     memBuffPtr          cmpAllocGlobVar(SymDef          varSym);
  1622.  
  1623.     size_t              cmpGetTypeSize (TypDef          type,
  1624.                                         size_t    *     alignPtr = NULL);
  1625.  
  1626.     static
  1627.     void                cmpRecordMemDef(SymDef          clsSym,
  1628.                                         ExtList         decl);
  1629.  
  1630.     /************************************************************************/
  1631.     /*  Logic that checks for uninitialized variable use                    */
  1632.     /************************************************************************/
  1633.  
  1634.     bool                cmpChkVarInit;          // enables the whole thing
  1635.  
  1636.     bool                cmpChkMemInit;          // need to check static mem init?
  1637.  
  1638.     unsigned            cmpLclVarCnt;           // # of local variables to track
  1639.  
  1640.     bool                cmpGotoPresent;         // irreducible flow-graph?
  1641.  
  1642.     bitset              cmpVarsDefined;         // vars known to be defined
  1643.     bitset              cmpVarsFlagged;         // vars already flagged
  1644.  
  1645.     bitset              cmpVarsIgnore;          // used for unneeded args
  1646.  
  1647.     void                cmpChkMemInits();
  1648.  
  1649.     void                cmpChkVarInitBeg(unsigned lclVarCnt, bool hadGoto);
  1650.     void                cmpChkVarInitEnd();
  1651.  
  1652.     void                cmpChkVarInitExprRec(Tree expr);
  1653.     void                cmpChkVarInitExpr   (Tree expr)
  1654.     {
  1655.         if  (cmpChkVarInit)
  1656.             cmpChkVarInitExprRec(expr);
  1657.     }
  1658.  
  1659.     void                cmpCheckUseCond(Tree expr, OUT bitset REF yesBS,
  1660.                                                    bool           yesSkip,
  1661.                                                    OUT bitset REF  noBS,
  1662.                                                    bool            noSkip);
  1663.  
  1664.     /************************************************************************/
  1665.     /*  Helper logic that maintains bitsets                                 */
  1666.     /************************************************************************/
  1667.  
  1668.     size_t              cmpLargeBSsize;         // size of large bitset or 0
  1669.  
  1670.     void                cmpBitSetInit(unsigned lclVarCnt)
  1671.     {
  1672.         if  (lclVarCnt > bitsetSmallSize)
  1673.             cmpLargeBSsize = (lclVarCnt + bitsetLargeSize - 1) / bitsetLargeSize;
  1674.         else
  1675.             cmpLargeBSsize = 0;
  1676.     }
  1677.  
  1678.     void                cmpBS_bigStart (  OUT bitset REF bs)
  1679.     {
  1680. #ifdef  DEBUG
  1681.         bs.bsCheck = 0xBEEFDEAD;
  1682. #endif
  1683.     }
  1684.  
  1685.     void                cmpBS_bigCreate(  OUT bitset REF bs);
  1686.     void                cmpBitSetCreate(  OUT bitset REF bs)
  1687.     {
  1688.         if  (cmpLargeBSsize)
  1689.             cmpBS_bigCreate(bs);
  1690.         else
  1691.             bs.bsSmallVal = 0;
  1692.     }
  1693.  
  1694.     void                cmpBS_bigDone  (IN    bitset REF bs);
  1695.     void                cmpBitSetDone  (IN    bitset REF bs)
  1696.     {
  1697.         if  (cmpLargeBSsize)
  1698.             cmpBS_bigDone(bs);
  1699.     }
  1700.  
  1701.     void                cmpBS_bigWrite (INOUT bitset REF bs, unsigned pos,
  1702.                                                              unsigned val);
  1703.     void                cmpBitSetWrite (INOUT bitset REF bs, unsigned pos,
  1704.                                                              unsigned val)
  1705.     {
  1706.         assert(val == 0 || val == 1);
  1707.  
  1708.         if  (cmpLargeBSsize)
  1709.         {
  1710.             cmpBS_bigWrite(bs, pos, val);
  1711.         }
  1712.         else
  1713.         {
  1714.             bitsetSmallType mask = (bitsetSmallType)1 << pos;
  1715.  
  1716.             assert(pos < bitsetSmallSize);
  1717.  
  1718.             if  (val)
  1719.                 bs.bsSmallVal |=  mask;
  1720.             else
  1721.                 bs.bsSmallVal &= ~mask;
  1722.         }
  1723.     }
  1724.  
  1725.     void                cmpBS_bigCreate(  OUT bitset REF dst,
  1726.                                         IN    bitset REF src);
  1727.     void                cmpBitSetCreate(  OUT bitset REF dst,
  1728.                                         IN    bitset REF src)
  1729.     {
  1730.         if  (cmpLargeBSsize)
  1731.         {
  1732.             cmpBS_bigCreate(dst, src);
  1733.         }
  1734.         else
  1735.         {
  1736.             dst.bsSmallVal = src.bsSmallVal;
  1737.         }
  1738.     }
  1739.  
  1740.     void                cmpBS_bigAssign(  OUT bitset REF dst,
  1741.                                         IN    bitset REF src);
  1742.     void                cmpBitSetAssign(  OUT bitset REF dst,
  1743.                                         IN    bitset REF src)
  1744.     {
  1745.         if  (cmpLargeBSsize)
  1746.         {
  1747.             cmpBS_bigAssign(dst, src);
  1748.         }
  1749.         else
  1750.         {
  1751.             dst.bsSmallVal = src.bsSmallVal;
  1752.         }
  1753.     }
  1754.  
  1755.     unsigned            cmpBS_bigRead  (IN    bitset REF bs, unsigned pos);
  1756.     unsigned            cmpBitSetRead  (IN    bitset REF bs, unsigned pos)
  1757.     {
  1758.         if  (cmpLargeBSsize)
  1759.         {
  1760.             return  cmpBS_bigRead(bs, pos);
  1761.         }
  1762.         else
  1763.         {
  1764.             assert(pos < bitsetSmallSize);
  1765.  
  1766.             return  ((bs.bsSmallVal & ((bitsetSmallType)1 << pos)) != 0);
  1767.         }
  1768.     }
  1769.  
  1770.     void                cmpBS_bigUnion (INOUT bitset REF bs1,
  1771.                                         IN    bitset REF bs2);
  1772.     void                cmpBitSetUnion (INOUT bitset REF bs1,
  1773.                                         IN    bitset REF bs2)
  1774.     {
  1775.         if  (cmpLargeBSsize)
  1776.         {
  1777.             cmpBS_bigUnion(bs1, bs2);
  1778.         }
  1779.         else
  1780.         {
  1781.             bs1.bsSmallVal |= bs2.bsSmallVal;
  1782.         }
  1783.     }
  1784.  
  1785.     void                cmpBS_bigIntsct(INOUT bitset REF bs1,
  1786.                                         IN    bitset REF bs2);
  1787.     void                cmpBitSetIntsct(INOUT bitset REF bs1,
  1788.                                         IN    bitset REF bs2)
  1789.     {
  1790.         if  (cmpLargeBSsize)
  1791.         {
  1792.             cmpBS_bigIntsct(bs1, bs2);
  1793.         }
  1794.         else
  1795.         {
  1796.             bs1.bsSmallVal &= bs2.bsSmallVal;
  1797.         }
  1798.     }
  1799.  
  1800.     /************************************************************************/
  1801.     /*  In case anyone wants to know how much work we've been doing         */
  1802.     /************************************************************************/
  1803.  
  1804. public:
  1805.     unsigned            cmpLineCnt;
  1806.  
  1807.     /************************************************************************/
  1808.     /* Members used for statement reachability analysis                     */
  1809.     /************************************************************************/
  1810.  
  1811. private:
  1812.  
  1813.     bool                cmpStmtReachable;
  1814.  
  1815.     void                cmpErrorReach(Tree stmt);
  1816.  
  1817.     void                cmpCheckReach(Tree stmt)
  1818.     {
  1819.         if  (!cmpStmtReachable)
  1820.             cmpErrorReach(stmt);
  1821.     }
  1822.  
  1823.     /************************************************************************/
  1824.     /* Pointers to the hash table, scanner, symbol manager, ...             */
  1825.     /************************************************************************/
  1826.  
  1827. public:
  1828.  
  1829.     Scanner             cmpScanner;
  1830.     Parser              cmpParser;
  1831.  
  1832.     block_allocator     cmpAllocTemp;       // limited lifetime allocs
  1833.     norls_allocator     cmpAllocPerm;       // this never goes away
  1834.     norls_allocator     cmpAllocCGen;       // used for MSIL generation
  1835.  
  1836. #ifdef  DLL
  1837.     void    *           cmpOutputFile;      // when compiling to memory
  1838. #endif
  1839.  
  1840. private:
  1841.  
  1842.     BlkList             cmpAllocList;
  1843.  
  1844. public:
  1845.  
  1846.     genericRef          cmpAllocBlock(size_t sz);
  1847.  
  1848.     /************************************************************************/
  1849.     /* The following is the root of all evil - er - symbols and such        */
  1850.     /************************************************************************/
  1851.  
  1852.     HashTab             cmpGlobalHT;        // global hash   table
  1853.     SymTab              cmpGlobalST;        // global symbol table
  1854.     SymDef              cmpGlobalNS;        // global namespace symbol
  1855.  
  1856.     /************************************************************************/
  1857.     /* Pre-defined standard types                                           */
  1858.     /************************************************************************/
  1859.  
  1860.     TypDef              cmpTypeInt;
  1861.     TypDef              cmpTypeBool;
  1862.     TypDef              cmpTypeChar;
  1863.     TypDef              cmpTypeVoid;
  1864.     TypDef              cmpTypeUint;
  1865.     TypDef              cmpTypeNatInt;
  1866.     TypDef              cmpTypeNatUint;
  1867.  
  1868.     TypDef              cmpTypeCharPtr;
  1869.     TypDef              cmpTypeWchrPtr;
  1870.     TypDef              cmpTypeVoidPtr;
  1871.  
  1872.     TypDef              cmpTypeVoidFnc;     // void fnc()
  1873.     TypDef              cmpTypeStrArr;      // String[]
  1874.  
  1875.     /************************************************************************/
  1876.     /* Generic type support                                                 */
  1877.     /************************************************************************/
  1878.  
  1879.     SymList             cmpGenInstList;     // current set of instantiations
  1880.     SymList             cmpGenInstFree;     // list of free instantiation desc's
  1881.  
  1882.     GenArgDscA          cmpGenArgAfree;     // list of free actual arg descriptors
  1883.  
  1884.     void                cmpDeclInstType(SymDef clsSym);
  1885.  
  1886.     TypDef              cmpInstanceType(TypDef genType, bool chkOnly = false);
  1887.  
  1888.     SymDef              cmpInstanceMeth(INOUT SymDef REF newOvl,
  1889.                                               SymDef     clsSym,
  1890.                                               SymDef     ovlSym);
  1891.  
  1892.     /************************************************************************/
  1893.     /* Members related to error reporting                                   */
  1894.     /************************************************************************/
  1895.  
  1896.     SymDef              cmpErrorSym;
  1897.     SymDef              cmpErrorComp;
  1898.     const   char *      cmpErrorSrcf;
  1899.     Tree                cmpErrorTree;
  1900.  
  1901.     unsigned            cmpErrorCount;
  1902.     unsigned            cmpFatalCount;
  1903.     unsigned            cmpMssgsCount;
  1904.  
  1905.     unsigned            cmpErrorMssgDisabled;
  1906.  
  1907. #if TRAP_VIA_SETJMP
  1908.     ErrTrap             cmpErrorTraps;
  1909. #endif
  1910.  
  1911. private:
  1912.  
  1913.     void                cmpSetSrcPos(SymDef memSym);
  1914.  
  1915.     void                cmpShowMsg (unsigned errNum, const char *kind, va_list args);
  1916.  
  1917.     const   char *      cmpErrorGenTypName(TypDef typ);
  1918.     const   char *      cmpErrorGenSymName(SymDef sym, bool qual = false);
  1919.     const   char *      cmpErrorGenSymName(Ident name, TypDef type);
  1920.  
  1921.     void                cmpReportSymDef(SymDef sym);
  1922.     void                cmpRedefSymErr (SymDef sym, unsigned err);
  1923.  
  1924. public:
  1925.  
  1926.     void                cmpErrorInit();
  1927.     void                cmpErrorSave();
  1928.  
  1929.     // The following is accessed by the scanner (we have no friends)
  1930.  
  1931.     BYTE                cmpInitialWarn[WRNcountWarn];
  1932.  
  1933.     // NOTE: Use the varargs version with extreme care -- no type checking!
  1934.  
  1935.     void                cmpSetErrPos(DefSrc def, SymDef compUnit);
  1936.  
  1937.     void                cmpCntError();
  1938.  
  1939.     void    _cdecl      cmpGenWarn (unsigned errNum, ...);
  1940.     void    _cdecl      cmpGenError(unsigned errNum, ...);
  1941.     void    _cdecl      cmpGenFatal(unsigned errNum, ...);
  1942.  
  1943.     void                cmpError   (unsigned errNum)
  1944.     {
  1945.         cmpGenError(errNum);
  1946.     }
  1947.  
  1948.     void                cmpWarn    (unsigned wrnNum)
  1949.     {
  1950.         cmpGenWarn (wrnNum);
  1951.     }
  1952.  
  1953.     void                cmpFatal   (unsigned errNum)
  1954.     {
  1955.         cmpGenFatal(errNum);
  1956.     }
  1957.  
  1958.     void                cmpFatal   (unsigned errNum, SymDef    sym);
  1959.  
  1960.     void                cmpError   (unsigned errNum, Ident    name);
  1961.     void                cmpError   (unsigned errNum, SymDef    sym);
  1962.     void                cmpError   (unsigned errNum, QualName qual);
  1963.     void                cmpError   (unsigned errNum, TypDef   type);
  1964.     void                cmpError   (unsigned errNum, Ident    name, TypDef type,
  1965.                                                                     bool   glue);
  1966.     void                cmpError   (unsigned errNum, TypDef   typ1, TypDef typ2);
  1967.     void                cmpError   (unsigned errNum, TypDef    typ, Ident  name);
  1968.     void                cmpError   (unsigned errNum, SymDef    sym, Ident  name,
  1969.                                                                     TypDef type);
  1970.     void                cmpError   (unsigned errNum, Ident    name, TypDef typ1,
  1971.                                                                     TypDef typ2);
  1972.     void                cmpError   (unsigned errNum, Ident    name, SymDef sym1,
  1973.                                                                     SymDef sym2);
  1974.     void                cmpError   (unsigned errNum, Ident    nam1, Ident  nam2,
  1975.                                                                     Ident  nam3);
  1976.     void                cmpError   (unsigned errNum, SymDef    sym, Ident  name);
  1977.     void                cmpError   (unsigned errNum, SymDef    sym, QualName qual,
  1978.                                                                     TypDef type);
  1979.     void                cmpErrorXtp(unsigned errNum, SymDef    sym, Tree   args);
  1980.     void                cmpErrorQnm(unsigned errNum, SymDef    sym);
  1981.     void                cmpErrorQSS(unsigned errNum, SymDef    sm1, SymDef sym2);
  1982.     void                cmpErrorQSS(unsigned errNum, SymDef    sym, TypDef type);
  1983.     void                cmpErrorAtp(unsigned errNum, SymDef    sym, Ident  name,
  1984.                                                                     TypDef type);
  1985.     void                cmpErrorSST(unsigned errNum, stringBuff str,
  1986.                                                      SymDef    sym,
  1987.                                                      TypDef    typ);
  1988.  
  1989.     void                cmpWarn    (unsigned wrnNum, TypDef   typ1, TypDef typ2);
  1990.     void                cmpWarn    (unsigned wrnNum, QualName name);
  1991.     void                cmpWarn    (unsigned wrnNum, TypDef   type);
  1992.     void                cmpWarnQnm (unsigned wrnNum, SymDef    sym);
  1993.     void                cmpWarnQns (unsigned wrnNum, SymDef    sym, AnsiStr str);
  1994.     void                cmpWarnNqn (unsigned wrnNum, unsigned  val, SymDef  sym);
  1995.     void                cmpWarnSQS (unsigned wrnNum, SymDef   sym1, SymDef sym2);
  1996.  
  1997.     unsigned            cmpStopErrorMessages();
  1998.     bool                cmpRestErrorMessages(unsigned errcnt = 0);
  1999.  
  2000.     void                cmpModifierError(unsigned err, unsigned mods);
  2001.     void                cmpMemFmod2Error(tokens tok1, tokens tok2);
  2002.  
  2003.     /************************************************************************/
  2004.     /* Members used for handling unmanaged classes                          */
  2005.     /************************************************************************/
  2006.  
  2007. public:
  2008.  
  2009.     SymList             cmpVtableList;      // list of vtables to generate
  2010.     unsigned            cmpVtableCount;
  2011.  
  2012. private:
  2013.  
  2014. #ifdef  DEBUG
  2015.     unsigned            cmpVtableIndex;
  2016. #endif
  2017.  
  2018.     void                cmpGenVtableContents(SymDef      vtabSym);
  2019.  
  2020.     memBuffPtr          cmpGenVtableSection (SymDef     innerSym,
  2021.                                              SymDef     outerSym,
  2022.                                              memBuffPtr dest);
  2023.  
  2024.     /************************************************************************/
  2025.     /* Members used for handling value types                                */
  2026.     /************************************************************************/
  2027.  
  2028.     void                cmpInitStdValTypes();
  2029.  
  2030.     Ident               cmpStdValueIdens[TYP_lastIntrins];
  2031.     TypDef              cmpStdValueTypes[TYP_lastIntrins];
  2032.  
  2033. public:
  2034.  
  2035.     var_types           cmpFindStdValType(TypDef    typ);
  2036.     TypDef              cmpFindStdValType(var_types vtp);
  2037.  
  2038.     TypDef              cmpCheck4valType(TypDef type);
  2039.  
  2040.     /************************************************************************/
  2041.     /* Members used to bind expressions                                     */
  2042.     /************************************************************************/
  2043.  
  2044.     SymDef              cmpThisSym;
  2045.     Tree                cmpThisRef();
  2046.     Tree                cmpThisRefOK();
  2047.  
  2048. private:
  2049.  
  2050.     Tree                cmpAllocExprRaw  (Tree          expr,
  2051.                                           treeOps       oper);
  2052.  
  2053.     Tree                cmpCreateExprNode(Tree          expr,
  2054.                                           treeOps       oper,
  2055.                                           TypDef        type);
  2056.     Tree                cmpCreateExprNode(Tree          expr,
  2057.                                           treeOps       oper,
  2058.                                           TypDef        type,
  2059.                                           Tree          op1,
  2060.                                           Tree          op2 = NULL);
  2061.  
  2062.     Tree                cmpCreateIconNode(Tree          expr,
  2063.                                           __int32       val,
  2064.                                           var_types     typ);
  2065.     Tree                cmpCreateLconNode(Tree          expr,
  2066.                                           __int64       val,
  2067.                                           var_types     typ);
  2068.     Tree                cmpCreateFconNode(Tree          expr,
  2069.                                           float         val);
  2070.     Tree                cmpCreateDconNode(Tree          expr,
  2071.                                           double        val);
  2072.     Tree                cmpCreateSconNode(stringBuff    str,
  2073.                                           size_t        len,
  2074.                                           unsigned      wide,
  2075.                                           TypDef        type);
  2076.     Tree                cmpCreateErrNode (unsigned      errn = 0);
  2077.     Tree                cmpCreateVarNode (Tree          expr,
  2078.                                           SymDef        sym);
  2079.  
  2080.     Tree                cmpAppend2argList(Tree          args,
  2081.                                           Tree          addx);
  2082.  
  2083.     /*----------------------------------------------------------------------*/
  2084.  
  2085.     void                cmpRecErrorPos   (Tree          expr);
  2086.  
  2087.     bool                cmpExprIsErr     (Tree          expr);
  2088.  
  2089.     /*----------------------------------------------------------------------*/
  2090.  
  2091.     Tree                cmpFoldIntUnop   (Tree          args);
  2092.     Tree                cmpFoldLngUnop   (Tree          args);
  2093.     Tree                cmpFoldFltUnop   (Tree          args);
  2094.     Tree                cmpFoldDblUnop   (Tree          args);
  2095.  
  2096.     Tree                cmpFoldIntBinop  (Tree          args);
  2097.     Tree                cmpFoldLngBinop  (Tree          args);
  2098.     Tree                cmpFoldFltBinop  (Tree          args);
  2099.     Tree                cmpFoldDblBinop  (Tree          args);
  2100.     Tree                cmpFoldStrBinop  (Tree          args);
  2101.  
  2102.     /*----------------------------------------------------------------------*/
  2103.  
  2104.     Tree                cmpShrinkExpr    (Tree          expr);
  2105.     Tree                cmpCastOfExpr    (Tree          expr,
  2106.                                           TypDef        type,
  2107.                                           bool          explicitCast);
  2108.     var_types           cmpConstSize     (Tree          expr,
  2109.                                           var_types     vtp);
  2110.  
  2111.     bool                cmpCheckException(TypDef        type);
  2112.  
  2113. public:
  2114.     bool                cmpCheckAccess   (SymDef        sym);
  2115.  
  2116. private:
  2117.     bool                cmpCheckAccessNP (SymDef        sym);
  2118.  
  2119.     bool                cmpCheckLvalue   (Tree          expr,
  2120.                                           bool          addr,
  2121.                                           bool          noErr = false);
  2122.  
  2123.     Tree                cmpCheckFuncCall (Tree          call);
  2124.  
  2125.     bool                cmpConvergeValues(INOUT Tree REF op1,
  2126.                                           INOUT Tree REF op2);
  2127.  
  2128.     Tree                cmpRefMemberVar  (Tree          expr,
  2129.                                           SymDef        sym,
  2130.                                           Tree          objPtr = NULL);
  2131.  
  2132.     TypDef              cmpMergeFncType  (SymDef        fncSym,
  2133.                                           TypDef        type);
  2134.  
  2135.     SymDef              cmpFindOvlMatch  (SymDef        fncSym,
  2136.                                           Tree          args,
  2137.                                           Tree          thisArg);
  2138.  
  2139.     bool                cmpMakeRawStrLit (Tree          expr,
  2140.                                           TypDef        type,
  2141.                                           bool          chkOnly    = false);
  2142.     bool                cmpMakeRawString (Tree          expr,
  2143.                                           TypDef        type,
  2144.                                           bool          chkOnly    = false);
  2145.  
  2146.     int                 cmpConversionCost(Tree          srcExpr,
  2147.                                           TypDef        dstType,
  2148.                                           bool          noUserConv = false);
  2149.  
  2150.     /*----------------------------------------------------------------------*/
  2151.  
  2152.     SymDef              cmpSymbolNS      (SymDef        sym);
  2153.     SymDef              cmpSymbolOwner   (SymDef        sym);
  2154.  
  2155.     TypDef              cmpGetActualTP   (TypDef        type);
  2156.  
  2157. public:
  2158.  
  2159.     TypDef              cmpActualType    (TypDef        type);
  2160.     TypDef              cmpDirectType    (TypDef        type);
  2161.  
  2162.     var_types           cmpActualVtyp    (TypDef        type);
  2163.     var_types           cmpDirectVtyp    (TypDef        type);
  2164.  
  2165.     static
  2166.     var_types           cmpEnumBaseVtp   (TypDef        type);
  2167.  
  2168.     /*----------------------------------------------------------------------*/
  2169.  
  2170. public:
  2171.  
  2172.     bool                cmpIsManagedAddr (Tree          expr);
  2173.  
  2174.     /*----------------------------------------------------------------------*/
  2175.  
  2176. private:
  2177.  
  2178.     ExtList             cmpTempMLfree;
  2179.  
  2180.     ExtList             cmpTempMLappend  (ExtList       list,
  2181.                                           ExtList     * lastPtr,
  2182.                                           SymDef        sym,
  2183.                                           SymDef        comp,
  2184.                                           UseList       uses,
  2185.                                           scanPosTP     dclFpos,
  2186.                                           unsigned      dclLine);
  2187.  
  2188.     void                cmpTempMLrelease (ExtList       entry);
  2189.  
  2190.     /*----------------------------------------------------------------------*/
  2191.  
  2192. #ifndef NDEBUG
  2193.  
  2194.     void                cmpChk4ctxChange (TypDef        type1,
  2195.                                           TypDef        type2,
  2196.                                           unsigned      flags);
  2197.  
  2198. #endif
  2199.  
  2200.     bool                cmpDiffContext   (TypDef        cls1,
  2201.                                           TypDef        cls2);
  2202.  
  2203. private:
  2204.     Tree                cmpDecayArray    (Tree          expr);
  2205. public:
  2206.     Tree                cmpDecayCheck    (Tree          expr);
  2207.  
  2208.     TypDef              cmpGetRefBase    (TypDef        reftyp);
  2209.  
  2210.     var_types           cmpSymbolVtyp    (SymDef        sym);
  2211.  
  2212.     /*----------------------------------------------------------------------*/
  2213.  
  2214. private:
  2215.  
  2216.     size_t              cmpStoreMDlen    (size_t            len,
  2217.                                           BYTE  *           dest = NULL);
  2218.  
  2219. public:
  2220.  
  2221.     SymDef              cmpBindAttribute (SymDef            clsSym,
  2222.                                           Tree              argList,
  2223.                                           unsigned          tgtMask,
  2224.                                       OUT unsigned    REF   useMask,
  2225.                                       OUT genericBuff REF   blobAddr,
  2226.                                       OUT size_t      REF   blobSize);
  2227.  
  2228.     /*----------------------------------------------------------------------*/
  2229.  
  2230.     void                cmpDeclDefCtor   (SymDef        clsSym);
  2231.  
  2232. private:
  2233.  
  2234.     SymDef              cmpFindCtor      (TypDef        clsTyp,
  2235.                                           bool          chkArgs,
  2236.                                           Tree          args = NULL);
  2237.  
  2238.     Tree                cmpCallCtor      (TypDef        type,
  2239.                                           Tree          args);
  2240.  
  2241. #ifdef  SETS
  2242.  
  2243.     Tree                cmpBindProject   (Tree          expr);
  2244.     Tree                cmpBindSetOper   (Tree          expr);
  2245.  
  2246.     // pre-allocate collection operator state classes
  2247.  
  2248.     SymDef  *           cmpSetOpClsTable;
  2249.     SymDef              cmpDclFilterCls  (unsigned      args);
  2250. public:
  2251.     unsigned            cmpSetOpCnt;
  2252.  
  2253.     TypDef              cmpIsCollection  (TypDef        type);
  2254.  
  2255.     unsigned            cmpClassDefCnt;
  2256.  
  2257. #endif
  2258.  
  2259. public:
  2260.  
  2261.     Tree                cmpBindCondition (Tree          cond);
  2262.     int                 cmpEvalCondition (Tree          cond);
  2263.  
  2264.     ConstStr            cmpSaveStringCns (const  char * str,
  2265.                                           size_t        len);
  2266.     ConstStr            cmpSaveStringCns (const wchar * str,
  2267.                                           size_t        len);
  2268.  
  2269. private:
  2270.  
  2271.     Tree                cmpBindVarArgUse (Tree          call);
  2272.  
  2273.     SymDef              cmpBindQualName  (QualName      name,
  2274.                                           bool          notLast);
  2275.  
  2276.     bool                cmpParseConstDecl(SymDef        varSym,
  2277.                                           Tree          init  = NULL,
  2278.                                           Tree        * ncPtr = NULL);
  2279.  
  2280.     Tree                cmpBooleanize    (Tree          expr,
  2281.                                           bool          sense);
  2282.  
  2283.     Tree                cmpFetchConstVal (ConstVal      cval,
  2284.                                           Tree          expr = NULL);
  2285.  
  2286.     SymDef              cmpFindPropertyDM(SymDef        accSym,
  2287.                                           bool        * isSetPtr);
  2288.  
  2289.     SymDef              cmpFindPropertyFN(SymDef        clsSym,
  2290.                                           Ident         propName,
  2291.                                           Tree          args,
  2292.                                           bool          getter,
  2293.                                           bool        * found);
  2294.  
  2295. public:
  2296.     Ident               cmpPropertyName  (Ident         name,
  2297.                                           bool          getter);
  2298.  
  2299. private:
  2300.     Tree                cmpBindProperty  (Tree          expr,
  2301.                                           Tree          args,
  2302.                                           Tree          asgx);
  2303.  
  2304.     Tree                cmpScaleIndex    (Tree          expr,
  2305.                                           TypDef        type,
  2306.                                           treeOps       oper);
  2307.  
  2308.     Tree                cmpBindArrayExpr (TypDef        type,
  2309.                                           int           dimPos = 0,
  2310.                                           unsigned      elems  = 0);
  2311.  
  2312.     Tree                cmpBindArrayBnd  (Tree          expr);
  2313.     void                cmpBindArrayType (TypDef        type,
  2314.                                           bool          needDef,
  2315.                                           bool          needDim,
  2316.                                           bool          mustDim);
  2317.  
  2318. public:
  2319.  
  2320.     TypDef              cmpBindExprType  (Tree          expr);
  2321.  
  2322.     void                cmpBindType      (TypDef        type,
  2323.                                           bool          needDef,
  2324.                                           bool          needDim);
  2325.  
  2326.     bool                cmpIsStringExpr  (Tree          expr);
  2327.  
  2328. private:
  2329.  
  2330.     Tree                cmpBindQmarkExpr (Tree          expr);
  2331.  
  2332.     Tree                bindSLVinit      (TypDef        type,
  2333.                                           Tree          init);
  2334.  
  2335.     Tree                cmpBindNewExpr   (Tree          expr);
  2336.  
  2337.     Tree                cmpAdd2Concat    (Tree          expr,
  2338.                                           Tree          list,
  2339.                                           Tree        * lastPtr);
  2340.     Tree                cmpListConcat    (Tree          expr);
  2341.     Tree                cmpBindConcat    (Tree          expr);
  2342.  
  2343.     Tree                cmpBindCall      (Tree          tree);
  2344.  
  2345.     Tree                cmpBindNameUse   (Tree          tree,
  2346.                                           bool          isCall,
  2347.                                           bool          classOK);
  2348.  
  2349.     Tree                cmpBindName      (Tree          tree,
  2350.                                           bool          isCall,
  2351.                                           bool          classOK);
  2352.  
  2353.     Tree                cmpRefAnUnionMem (Tree          expr);
  2354.  
  2355.     Tree                cmpBindDotArr    (Tree          tree,
  2356.                                           bool          isCall,
  2357.                                           bool          classOK);
  2358.  
  2359. #ifdef  SETS
  2360.  
  2361. public:
  2362.  
  2363.     static
  2364.     SymDef              cmpNextInstDM    (SymDef        memList,
  2365.                                           SymDef    *   memSymPtr);
  2366.  
  2367. private:
  2368.  
  2369.     Tree                cmpBindSlicer    (Tree          expr);
  2370.  
  2371.     Tree                cmpBindXMLinit   (SymDef        clsSym,
  2372.                                           Tree          init);
  2373.  
  2374.     SymXinfo            cmpAddXMLattr    (SymXinfo      xlist,
  2375.                                           bool          elem,
  2376.                                           unsigned      num);
  2377.  
  2378. #endif
  2379.  
  2380.     Tree                cmpBindThisRef   (SymDef        sym);
  2381.  
  2382.     Tree                cmpBindAssignment(Tree          dstx,
  2383.                                           Tree          srcx,
  2384.                                           Tree          tree,
  2385.                                           treeOps       oper = TN_ASG);
  2386.  
  2387.     Tree                cmpCompOperArg1;
  2388.     Tree                cmpCompOperArg2;
  2389.     Tree                cmpCompOperFnc1;
  2390.     Tree                cmpCompOperFnc2;
  2391.     Tree                cmpCompOperFunc;
  2392.     Tree                cmpCompOperCall;
  2393.  
  2394.     Tree                cmpCompareValues (Tree          expr,
  2395.                                           Tree          op1,
  2396.                                           Tree          op2);
  2397.  
  2398.     Tree                cmpConvOperExpr;
  2399.  
  2400.     unsigned            cmpMeasureConv   (Tree          srcExpr,
  2401.                                           TypDef        dstType,
  2402.                                           unsigned      lowCost,
  2403.                                           SymDef        convSym,
  2404.                                           SymDef      * bestCnv1,
  2405.                                           SymDef      * bestCnv2);
  2406.  
  2407.     Tree                cmpCheckOvlOper  (Tree          expr);
  2408.  
  2409.     Tree                cmpCheckConvOper (Tree          expr,
  2410.                                           TypDef        srcTyp,
  2411.                                           TypDef        dstTyp,
  2412.                                           bool          expConv,
  2413.                                           unsigned    * costPtr = NULL);
  2414.  
  2415.     Tree                cmpUnboxExpr     (Tree          expr,
  2416.                                           TypDef        type);
  2417.  
  2418.     Tree                cmpBindExprRec   (Tree          expr);
  2419.  
  2420. public:
  2421.  
  2422.     Tree                cmpCoerceExpr    (Tree          expr,
  2423.                                           TypDef        type, bool explicitCast);
  2424.  
  2425.     Tree                cmpBindExpr      (Tree          expr);
  2426.  
  2427.     Tree                cmpFoldExpression(Tree          expr);
  2428.  
  2429.     /************************************************************************/
  2430.     /* Members used for generating IL                                       */
  2431.     /************************************************************************/
  2432.  
  2433.     GenILref            cmpILgen;
  2434.  
  2435.     stmtNestRec         cmpStmtLast;
  2436.     StmtNest            cmpStmtNest;
  2437.  
  2438.     SymDef              cmpFilterObj;
  2439.  
  2440.     bool                cmpBaseCTisOK;
  2441.     bool                cmpBaseCTcall;
  2442.     bool                cmpThisCTcall;
  2443.  
  2444.     SymDef              cmpTempVarMake   (TypDef        type);
  2445.     void                cmpTempVarDone   (SymDef        tsym);
  2446.  
  2447. #ifdef  SETS
  2448.  
  2449.     void                cmpStmtConnect   (Tree          stmt);
  2450.  
  2451.     void                cmpStmtSortFnc   (Tree          sortList);
  2452.     void                cmpStmtProjFnc   (Tree          sortList);
  2453.  
  2454.     void                cmpStmtForEach   (Tree          stmt,
  2455.                                           SymDef        lsym = NULL);
  2456.  
  2457. #endif
  2458.  
  2459.     void                cmpStmtDo        (Tree          stmt,
  2460.                                           SymDef        lsym = NULL);
  2461.     void                cmpStmtFor       (Tree          stmt,
  2462.                                           SymDef        lsym = NULL);
  2463.     void                cmpStmtTry       (Tree          stmt,
  2464.                                           Tree          pref = NULL);
  2465.     void                cmpStmtExcl      (Tree          stmt);
  2466.     void                cmpStmtWhile     (Tree          stmt,
  2467.                                           SymDef        lsym = NULL);
  2468.     void                cmpStmtSwitch    (Tree          stmt,
  2469.                                           SymDef        lsym = NULL);
  2470.  
  2471.     void                cmpStmt          (Tree          stmt);
  2472.  
  2473. #ifndef NDEBUG
  2474.     bool                cmpDidCTinits;
  2475. #endif
  2476.     void                cmpAddCTinits    ();
  2477.  
  2478.     SymDef              cmpBlockDecl     (Tree          blockDcl,
  2479.                                           bool          outer,
  2480.                                           bool          genDecl,
  2481.                                           bool          isCatch);
  2482.     SymDef              cmpBlock         (Tree          block,
  2483.                                           bool          outer);
  2484.  
  2485.     SymDef              cmpGenFNbodyBeg  (SymDef        fncSym,
  2486.                                           Tree          body,
  2487.                                           bool          hadGoto,
  2488.                                           unsigned      lclVarCnt);
  2489.     void                cmpGenFNbodyEnd();
  2490.  
  2491. #ifdef  OLD_IL
  2492.     GenOILref           cmpOIgen;
  2493. #endif
  2494.  
  2495.     /************************************************************************/
  2496.     /* Members used for metadata output                                     */
  2497.     /************************************************************************/
  2498.  
  2499. public:
  2500.  
  2501.     WMetaDataDispenser *cmpWmdd;
  2502.     WMetaDataEmit      *cmpWmde;
  2503.     WAssemblyEmit      *cmpWase;
  2504.  
  2505. private:
  2506.  
  2507.     mdAssembly          cmpCurAssemblyTok;
  2508.  
  2509.     mdTypeRef           cmpLinkageClass;        // fake class for entry points
  2510.  
  2511. #ifdef  DEBUG
  2512.     unsigned            cmpGenLocalSigLvx;
  2513. #endif
  2514.  
  2515.     void                cmpSecurityMD    (mdToken       token,
  2516.                                           SymXinfo      infoList);
  2517.  
  2518.     void                cmpGenLocalSigRec(SymDef        scope);
  2519.  
  2520.     wchar   *           cmpGenMDname     (SymDef        sym,
  2521.                                           bool          full,
  2522.                                           wchar  *      buffAddr,
  2523.                                           size_t        buffSize,
  2524.                                           wchar  *    * buffHeapPtr);
  2525.  
  2526.     SymDef              cmpTypeDefList;
  2527.     SymDef              cmpTypeDefLast;
  2528.  
  2529.     void                cmpGenTypMetadata(SymDef        sym);
  2530.     void                cmpGenGlbMetadata(SymDef        sym);
  2531.     void                cmpGenMemMetadata(SymDef        sym);
  2532.  
  2533.     wchar   *           cmpArrayClsPref  (SymDef        sym,
  2534.                                           wchar *       dest,
  2535.                                           int           delim,
  2536.                                           bool          fullPath = false);
  2537.     wchar   *           cmpArrayClsName  (TypDef        type,
  2538.                                           bool          nonAbstract,
  2539.                                           wchar *       dest,
  2540.                                           wchar *       nptr);
  2541.  
  2542.     Tree                cmpFakeXargsVal;
  2543.  
  2544.     void                cmpAddCustomAttrs(SymXinfo      infoList,
  2545.                                           mdToken       owner);
  2546.  
  2547.     void                cmpSetGlobMDoffsR(SymDef        scope,
  2548.                                           unsigned      dataOffs);
  2549.  
  2550. public:
  2551.  
  2552.     void                cmpSetGlobMDoffs (unsigned      dataOffs);
  2553.     void                cmpSetStrCnsOffs (unsigned       strOffs);
  2554.  
  2555.     mdToken             cmpMDstringLit   (wchar *       str,
  2556.                                           size_t        len);
  2557.  
  2558.     TypDef              cmpGetBaseArray  (TypDef        type);
  2559.  
  2560.     mdToken             cmpArrayEAtoken  (TypDef        arrType,
  2561.                                           unsigned      dimCnt,
  2562.                                           bool          store,
  2563.                                           bool          addr = false);
  2564.  
  2565.     mdToken             cmpArrayCTtoken  (TypDef         arrType,
  2566.                                           TypDef        elemType,
  2567.                                           unsigned      dimCnt);
  2568.  
  2569.     mdToken             cmpArrayTpToken  (TypDef        type,
  2570.                                           bool          nonAbstract = false);
  2571.  
  2572.     mdToken             cmpPtrTypeToken  (TypDef        type);
  2573.  
  2574.     mdToken             cmpClsEnumToken  (TypDef        type);
  2575.  
  2576.     PCOR_SIGNATURE      cmpTypeSig       (TypDef        type,
  2577.                                           size_t      * lenPtr);
  2578.     mdSignature         cmpGenLocalSig   (SymDef        scope,
  2579.                                           unsigned      count);
  2580.     void                cmpGenMarshalInfo(mdToken       token,
  2581.                                           TypDef        type,
  2582.                                           MarshalInfo   info);
  2583.     PCOR_SIGNATURE      cmpGenMarshalSig (TypDef        type,
  2584.                                           MarshalInfo   info,
  2585.                                           size_t      * lenPtr);
  2586.     PCOR_SIGNATURE      cmpGenMemberSig  (SymDef        memSym,
  2587.                                           Tree          xargs,
  2588.                                           TypDef        memTyp,
  2589.                                           TypDef        prefTp,
  2590.                                           size_t      * lenPtr);
  2591.     void                cmpGenFldMetadata(SymDef        fldSym);
  2592.     mdSignature         cmpGenSigMetadata(TypDef        fncTyp,
  2593.                                           TypDef        pref  = NULL);
  2594.     mdToken             cmpGenFncMetadata(SymDef        fncSym,
  2595.                                           Tree          xargs = NULL);
  2596.     mdToken             cmpGenClsMetadata(SymDef        clsSym,
  2597.                                           bool          extref = false);
  2598.     mdToken             cmpStringConstTok(size_t        addr,
  2599.                                           size_t        size);
  2600.     unsigned            cmpStringConstCnt;
  2601.     strCnsPtr           cmpStringConstList;
  2602.  
  2603.     void                cmpFixupScopes   (SymDef        scope);
  2604.  
  2605.     void                cmpAttachMDattr  (mdToken       target,
  2606.                                           wideStr       oldName,
  2607.                                           AnsiStr       newName,
  2608.                                           mdToken     * newTokPtr,
  2609.                                           unsigned      valTyp = 0,
  2610.                                           const void  * valPtr = NULL,
  2611.                                           size_t        valSiz = 0);
  2612. private:
  2613.  
  2614.     // fixed table of assembly tokens
  2615.  
  2616.     unsigned            cmpAssemblyRefCnt;
  2617.  
  2618.     mdAssembly          cmpAssemblyRefTab[32];
  2619.     mdAssemblyRef       cmpAssemblyRefTok[32];
  2620.     WAssemblyImport *   cmpAssemblyRefImp[32];
  2621.     BYTE *              cmpAssemblyRefXXX[32];
  2622.  
  2623.     unsigned            cmpAssemblyBCLx;
  2624.  
  2625. public:
  2626.  
  2627.     void                cmpAssemblyTkBCL(unsigned assx)
  2628.     {
  2629.         cmpAssemblyBCLx = assx;
  2630.     }
  2631.  
  2632.     bool                cmpAssemblyIsBCL(unsigned assx)
  2633.     {
  2634.         assert(assx && assx <= cmpAssemblyRefCnt);
  2635.  
  2636.         return  (assx == cmpAssemblyBCLx);
  2637.     }
  2638.  
  2639.     mdExportedType           cmpAssemblySymDef(SymDef sym, mdTypeDef defTok = 0);
  2640.     mdAssemblyRef       cmpAssemblyAddRef(mdAssembly ass, WAssemblyImport *imp);
  2641.  
  2642.     unsigned            cmpAssemblyRefAdd(mdAssembly ass, WAssemblyImport *imp, BYTE *cookie = NULL)
  2643.     {
  2644.         assert(cmpAssemblyRefCnt < arraylen(cmpAssemblyRefTab));
  2645.  
  2646.         cmpAssemblyRefTab[cmpAssemblyRefCnt] = ass;
  2647.         cmpAssemblyRefImp[cmpAssemblyRefCnt] = imp;
  2648.         cmpAssemblyRefXXX[cmpAssemblyRefCnt] = cookie;
  2649.  
  2650.         return  ++cmpAssemblyRefCnt;
  2651.     }
  2652.  
  2653.     mdAssemblyRef       cmpAssemblyRefRec(unsigned assx)
  2654.     {
  2655.         assert(assx && assx <= cmpAssemblyRefCnt);
  2656.  
  2657.         assx--;
  2658.  
  2659.         assert(cmpAssemblyRefTab[assx]);
  2660.  
  2661.         if  (cmpAssemblyRefTok[assx] == 0)
  2662.              cmpAssemblyRefTok[assx] = cmpAssemblyAddRef(cmpAssemblyRefTab[assx],
  2663.                                                          cmpAssemblyRefImp[assx]);
  2664.  
  2665.         return  cmpAssemblyRefTok[assx];
  2666.     }
  2667.  
  2668.     WAssemblyImport *   cmpAssemblyGetImp(unsigned assx)
  2669.     {
  2670.         assert(assx && assx <= cmpAssemblyRefCnt);
  2671.  
  2672.         assert(cmpAssemblyRefTab[assx-1]);
  2673.  
  2674.         return cmpAssemblyRefImp[assx-1];
  2675.     }
  2676.  
  2677.     mdToken             cmpAssemblyAddFile(wideStr  fileName,
  2678.                                            bool     doHash,
  2679.                                            unsigned flags = 0);
  2680.  
  2681.     void                cmpAssemblyAddType(wideStr  typeName,
  2682.                                            mdToken  defTok,
  2683.                                            mdToken  scpTok,
  2684.                                            unsigned flags);
  2685.  
  2686.     void                cmpAssemblyAddRsrc(AnsiStr  fileName,
  2687.                                            bool     internal);
  2688.  
  2689.     void                cmpAssemblyNonCLS();
  2690.  
  2691.     void                cmpMarkModuleUnsafe();
  2692.  
  2693.     /************************************************************************/
  2694.     /* Members used for conversion to Unicode                               */
  2695.     /************************************************************************/
  2696.  
  2697. public:
  2698.  
  2699.     wchar               cmpUniConvBuff[MAX_INLINE_NAME_LEN+1];
  2700.  
  2701.     size_t              cmpUniConvSize;
  2702.     wchar   *           cmpUniConvAddr;
  2703.  
  2704.     void                cmpUniConvInit()
  2705.     {
  2706.         cmpUniConvAddr = cmpUniConvBuff;
  2707.         cmpUniConvSize = MAX_INLINE_NAME_LEN;
  2708.     }
  2709.  
  2710. #if MGDDATA
  2711.     String              cmpUniConv(char managed [] str, size_t len);
  2712. #endif
  2713.     wideString          cmpUniConv(const char *    str, size_t len);
  2714.     wideString          cmpUniCnvW(const char *    str, size_t*lenPtr);
  2715.  
  2716.     wideString          cmpUniConv(Ident name)
  2717.     {
  2718.         return          cmpUniConv(name->idSpelling(), name->idSpellLen());
  2719.     }
  2720.  
  2721.     /************************************************************************/
  2722.     /* Members used to create metadata signatures                           */
  2723.     /************************************************************************/
  2724.  
  2725. private:
  2726.  
  2727.     char                cmpMDsigBuff[256];                  // default buffer
  2728.  
  2729.     size_t              cmpMDsigSize;                       // size of current buff
  2730.     char    *           cmpMDsigHeap;                       // non-NULL if on heap
  2731.  
  2732. #ifndef NDEBUG
  2733.     bool                cmpMDsigUsed;                       // to detect recursion
  2734. #endif
  2735.  
  2736.     char    *           cmpMDsigBase;                       // buffer start addr
  2737.     char    *           cmpMDsigNext;                       // next byte to store
  2738.     char    *           cmpMDsigEndp;                       // buffer end addr
  2739.  
  2740.     void                cmpMDsigExpand(size_t size);
  2741.  
  2742. public:
  2743.  
  2744.     void                cmpMDsigInit()
  2745.     {
  2746.         cmpMDsigBase = cmpMDsigBuff;
  2747.         cmpMDsigEndp = cmpMDsigBase + sizeof(cmpMDsigBuff);
  2748.         cmpMDsigSize = sizeof(cmpMDsigBuff) - 4;
  2749. #ifndef NDEBUG
  2750.         cmpMDsigUsed = false;
  2751. #endif
  2752.         cmpMDsigHeap = NULL;
  2753.     }
  2754.  
  2755.     void                cmpMDsigStart ();
  2756.     PCOR_SIGNATURE      cmpMDsigEnd   (size_t     *sizePtr);
  2757.  
  2758.     void                cmpMDsigAddStr(const char *str, size_t len);
  2759.     void                cmpMDsigAddStr(const char *str)
  2760.     {
  2761.                         cmpMDsigAddStr(str, strlen(str)+1);
  2762.     }
  2763.  
  2764.     void                cmpMDsigAdd_I1(int         val);    // fixed-size  8-bit int
  2765.     void                cmpMDsigAddCU4(unsigned    val);    // compressed unsigned
  2766.     void                cmpMDsigAddTok(mdToken     tok);    // compressed token
  2767.  
  2768.     void                cmpMDsigAddTyp(TypDef      type);
  2769.  
  2770.     /************************************************************************/
  2771.     /* Metadata import stuff                                                */
  2772.     /************************************************************************/
  2773.  
  2774.     MetaDataImp         cmpMDlist;
  2775.     MetaDataImp         cmpMDlast;
  2776.     unsigned            cmpMDcount;
  2777.  
  2778.     void                cmpInitMD();
  2779.  
  2780.     void                cmpInitMDimp ();
  2781.     void                cmpDoneMDimp ();
  2782.  
  2783.     void                cmpInitMDemit();
  2784.     void                cmpDoneMDemit();
  2785.  
  2786.     MetaDataImp         cmpAddMDentry();
  2787.  
  2788.     IMetaDataImport   * cmpFindImporter(SymDef globSym);
  2789.  
  2790.     void                cmpImportMDfile(const char *fname   = NULL,
  2791.                                         bool        asmOnly = false,
  2792.                                         bool        isBCL   = false);
  2793.  
  2794. private:
  2795.     void                cmpFindMDimpAPIs(SymDef                   typSym,
  2796.                                          IMetaDataImport        **imdiPtr,
  2797.                                          IMetaDataAssemblyEmit  **iasePtr,
  2798.                                          IMetaDataAssemblyImport**iasiPtr);
  2799. public:
  2800.  
  2801.     void                cmpMakeMDimpTref(SymDef clsSym);
  2802.     void                cmpMakeMDimpFref(SymDef fncSym);
  2803.     void                cmpMakeMDimpDref(SymDef fldSym);
  2804.     void                cmpMakeMDimpEref(SymDef etpSym);
  2805.  
  2806.     /************************************************************************/
  2807.     /* Metadata debug output                                                */
  2808.     /************************************************************************/
  2809.  
  2810.     unsigned            cmpCurFncSrcBeg;
  2811.     unsigned            cmpCurFncSrcEnd;
  2812.  
  2813.     WSymWriter         *cmpSymWriter;
  2814.  
  2815.     void               *cmpSrcFileDocument(SymDef srcSym);
  2816.  
  2817.     /************************************************************************/
  2818.     /* Generic utility vector deal to convert pointer to small indices      */
  2819.     /************************************************************************/
  2820.  
  2821. private:
  2822.  
  2823. #if MGDDATA
  2824.     VecEntryDsc []      cmpVecTable;
  2825. #else
  2826.     VecEntryDsc *       cmpVecTable;
  2827. #endif
  2828.  
  2829.     unsigned            cmpVecCount;        // number of items stored
  2830.     unsigned            cmpVecAlloc;        // size currently allocated
  2831.  
  2832.     void                cmpVecExpand();
  2833.  
  2834. public:
  2835.  
  2836.     unsigned            cmpAddVecEntry(const void * val, vecEntryKinds kind)
  2837.     {
  2838.         assert(val != NULL);
  2839.  
  2840.         if  (cmpVecCount >= cmpVecAlloc)
  2841.             cmpVecExpand();
  2842.  
  2843.         assert(cmpVecCount < cmpVecAlloc);
  2844.  
  2845. #ifdef  DEBUG
  2846.         cmpVecTable[cmpVecCount].vecKind  = kind;
  2847. #endif
  2848.         cmpVecTable[cmpVecCount].vecValue = val;
  2849.  
  2850.         return  ++cmpVecCount;
  2851.     }
  2852.  
  2853.     const   void *      cmpGetVecEntry(unsigned x, vecEntryKinds kind)
  2854.     {
  2855.         assert(x && x <= cmpVecCount);
  2856.  
  2857.         assert(cmpVecTable[x - 1].vecKind == kind);
  2858.         return cmpVecTable[x - 1].vecValue;
  2859.     }
  2860.  
  2861. //  bool                cmpDelVecEntry(unsigned x, vecEntryKinds kind);
  2862.  
  2863.     /************************************************************************/
  2864.     /* Miscellaneous members                                                */
  2865.     /************************************************************************/
  2866.  
  2867.     bool                cmpEvalPreprocCond();
  2868.  
  2869. #ifdef DEBUG
  2870.     void                cmpDumpSymbolTable();
  2871. #endif
  2872.  
  2873.     bool                cmpParserInit;       // has the parser been initialized?
  2874. };
  2875.  
  2876. /*****************************************************************************
  2877.  *
  2878.  *  For easier debugging of the compiler itself. NOTE: This is not thread-safe!
  2879.  */
  2880.  
  2881. #ifdef  DEBUG
  2882. #ifndef __SMC__
  2883. extern  Compiler        TheCompiler;
  2884. extern  Scanner         TheScanner;
  2885. #endif
  2886. #endif
  2887.  
  2888. /*****************************************************************************
  2889.  *
  2890.  *  The following is used to temporarily disable error messages.
  2891.  */
  2892.  
  2893. inline
  2894. unsigned                compiler::cmpStopErrorMessages()
  2895. {
  2896.     cmpErrorMssgDisabled++;
  2897.     return  cmpMssgsCount;
  2898. }
  2899.  
  2900. inline
  2901. bool                    compiler::cmpRestErrorMessages(unsigned errcnt)
  2902. {
  2903.     cmpErrorMssgDisabled--;
  2904.     return  cmpMssgsCount > errcnt;
  2905. }
  2906.  
  2907. /*****************************************************************************
  2908.  *
  2909.  *  In non-debug mode the following function doesn't need to do any work.
  2910.  */
  2911.  
  2912. #ifndef DEBUG
  2913. inline  void            compiler::cmpInitVarEnd(SymDef varSym){}
  2914. #endif
  2915.  
  2916. /*****************************************************************************/
  2917.  
  2918. #include "symbol.h"
  2919. #include "type.h"
  2920.  
  2921. /*****************************************************************************/
  2922.  
  2923. inline
  2924. void    *           SMCgetMem(Compiler comp, size_t size)
  2925. {
  2926.     return  comp->cmpAllocTemp.baAlloc      (size);
  2927. }
  2928.  
  2929. inline
  2930. void    *           SMCgetM_0(Compiler comp, size_t size)
  2931. {
  2932.     return  comp->cmpAllocTemp.baAllocOrNull(size);
  2933. }
  2934.  
  2935. inline
  2936. void                SMCrlsMem(Compiler comp, void *block)
  2937. {
  2938.             comp->cmpAllocTemp.baFree(block);
  2939. }
  2940.  
  2941. /*****************************************************************************
  2942.  *
  2943.  *  Each symbol table manages its own names and symbol/type entries.
  2944.  */
  2945.  
  2946. DEFMGMT
  2947. class symTab
  2948. {
  2949.     Compiler            stComp;
  2950.     unsigned            stOwner;
  2951.  
  2952. public:
  2953.     HashTab             stHash;
  2954.  
  2955.     norls_allocator *   stAllocPerm;        // used for all  non-local allocs
  2956.  
  2957. private:
  2958.     norls_allocator *   stAllocTemp;        // used for function-local allocs
  2959.  
  2960. public:
  2961.  
  2962.     void                stInit(Compiler             comp,
  2963.                                norls_allocator    * alloc,
  2964.                                HashTab              hash   = NULL,
  2965.                                unsigned             ownerx = 0);
  2966.  
  2967.     /************************************************************************/
  2968.     /* Members used to manage symbol entries                                */
  2969.     /************************************************************************/
  2970.  
  2971.     DefList             stRecordSymSrcDef(SymDef    sym,
  2972.                                           SymDef    st,
  2973.                                           UseList   uses, scanPosTP dclFpos,
  2974. //                                                        scanPosTP dclEpos,
  2975.                                                           unsigned  dclLine,
  2976. //                                                        unsigned  dclCol,
  2977.                                           bool      ext = false);
  2978.  
  2979.     ExtList             stRecordMemSrcDef(Ident     name,
  2980.                                           QualName  qual,
  2981.                                           SymDef    comp,
  2982.                                           UseList   uses, scanPosTP dclFpos,
  2983. //                                                        scanPosTP dclEpos,
  2984.                                                           unsigned  dclLine);
  2985.  
  2986.     /*-------------------------------------------------------------------*/
  2987.  
  2988.     TypDef              stDlgSignature(TypDef       dlgTyp);
  2989.  
  2990.     /*-------------------------------------------------------------------*/
  2991.  
  2992.     ovlOpFlavors        stOvlOperIndex(tokens       token,
  2993.                                        unsigned     argCnt = 0);
  2994.     Ident               stOvlOperIdent(ovlOpFlavors oper);
  2995.  
  2996.     /*-------------------------------------------------------------------*/
  2997.  
  2998.     SymDef              stFindOvlFnc  (SymDef       fsym,
  2999.                                        TypDef       type);
  3000.     SymDef              stFindOvlProp (SymDef       psym,
  3001.                                        TypDef       type);
  3002.  
  3003.     SymDef              stFindSameProp(SymDef       psym,
  3004.                                        TypDef       type);
  3005.  
  3006.     SymDef              stDeclareSym  (Ident        name,
  3007.                                        symbolKinds  kind,
  3008.                                        name_space   nspc,
  3009.                                        SymDef       scope);
  3010.  
  3011.     SymDef              stDeclareOper (ovlOpFlavors oper,
  3012.                                        SymDef       scope);
  3013.  
  3014.     SymDef              stDeclareLab  (Ident        name,
  3015.                                        SymDef       scope, norls_allocator*alloc);
  3016.  
  3017.     SymDef              stDeclareOvl  (SymDef       fsym);
  3018.  
  3019.     SymDef              stDeclareNcs  (Ident        name,
  3020.                                        SymDef       scope,
  3021.                                        str_flavors  flavor);
  3022.  
  3023.     SymDef              stDeclareLcl  (Ident        name,
  3024.                                        symbolKinds  kind,
  3025.                                        name_space   nspc,
  3026.                                        SymDef       scope,
  3027.                                        norls_allocator *alloc);
  3028.  
  3029. #ifdef DEBUG
  3030.  
  3031.     void                stDumpSymDef  (DefSrc       def,
  3032.                                        SymDef       comp);
  3033.  
  3034.     void                stDumpSymbol  (SymDef       sym,
  3035.                                        int          indent,
  3036.                                        bool         recurse,
  3037.                                        bool         members);
  3038.  
  3039.     void                stDumpQualName(QualName     name);
  3040.  
  3041.     void                stDumpUsings  (UseList      uses,
  3042.                                        unsigned     indent);
  3043.  
  3044. #endif
  3045.  
  3046.     SymDef              stSearchUsing (INOUT UseList REF uses,
  3047.                                        Ident             name,
  3048.                                        name_space        nsp);
  3049.  
  3050. private:
  3051.  
  3052.     SymDef              stFindInClass (Ident        name,
  3053.                                        SymDef       scope,
  3054.                                        name_space   symNS);
  3055.  
  3056. public:
  3057.  
  3058.     SymDef              stFindInBase  (SymDef       memSym,
  3059.                                        SymDef       scope);
  3060.  
  3061.     SymDef              stFindBCImem  (SymDef       clsSym,
  3062.                                        Ident        name,
  3063.                                        TypDef       type,
  3064.                                        symbolKinds  kind,
  3065.                                  INOUT SymDef   REF matchFN,
  3066.                                        bool         baseOnly);
  3067.  
  3068.     SymDef              stLookupAllCls(Ident        name,
  3069.                                        SymDef       scope,
  3070.                                        name_space   symNS,
  3071.                                        compileStates state);
  3072.  
  3073.     SymDef              stLookupProp  (Ident        name,
  3074.                                        SymDef       scope);
  3075.  
  3076.     SymDef              stLookupOperND(ovlOpFlavors oper,
  3077.                                        SymDef       scope);
  3078.     SymDef              stLookupOper  (ovlOpFlavors oper,
  3079.                                        SymDef       scope);
  3080.  
  3081.     SymDef              stLookupNspSym(Ident        name,
  3082.                                        name_space   symNS,
  3083.                                        SymDef       scope);
  3084.  
  3085.     SymDef              stLookupClsSym(Ident        name,
  3086.                                        SymDef       scope);
  3087.  
  3088.     SymDef              stLookupScpSym(Ident        name,
  3089.                                        SymDef       scope);
  3090.  
  3091.     SymDef              stLookupLclSym(Ident        name,
  3092.                                        SymDef       scope);
  3093.  
  3094. #ifdef  SETS
  3095.     SymDef              stImplicitScp;
  3096. #endif
  3097.  
  3098.     SymDef              stLookupSym   (Ident        name,
  3099.                                        name_space   symNS);
  3100.  
  3101.     SymDef              stLookupLabSym(Ident        name,
  3102.                                        SymDef       scope)
  3103.     {
  3104.         return  stLookupNspSym(name, NS_HIDE, scope);
  3105.     }
  3106.  
  3107.     void                stRemoveSym   (SymDef       sym);
  3108.  
  3109.     static
  3110.     SymDef              stNamespOfSym (SymDef       sym)
  3111.     {
  3112.         assert(sym->sdSymKind == SYM_VAR  ||
  3113.                sym->sdSymKind == SYM_FNC  ||
  3114.                sym->sdSymKind == SYM_ENUM ||
  3115.                sym->sdSymKind == SYM_CLASS);
  3116.  
  3117.         do
  3118.         {
  3119.             sym = sym->sdParent; assert(sym);
  3120.         }
  3121.         while (sym->sdSymKind == SYM_CLASS);
  3122.         assert(sym->sdSymKind == SYM_NAMESPACE);
  3123.  
  3124.         return sym;
  3125.     }
  3126.  
  3127.     static
  3128.     SymDef              stErrSymbol;        // to indicate error conditions
  3129.  
  3130.     /************************************************************************/
  3131.     /* Members used to manage type descriptors                              */
  3132.     /************************************************************************/
  3133.  
  3134. public:
  3135.  
  3136.     void                stInitTypes  (unsigned      refHashSz = 512,
  3137.                                       unsigned      arrHashSz = 128);
  3138.  
  3139.     void                stExtArgsBeg (  OUT ArgDscRec REF newArgs,
  3140.                                         OUT ArgDef    REF lastRef,
  3141.                                             ArgDscRec     oldArgs,
  3142.                                             bool          prefix  = false,
  3143.                                             bool          outOnly = false);
  3144.     void                stExtArgsAdd (INOUT ArgDscRec REF newArgs,
  3145.                                       INOUT ArgDef    REF lastArg,
  3146.                                             TypDef        argType,
  3147.                                             const char *  argName = NULL);
  3148.     void                stExtArgsEnd (INOUT ArgDscRec REF newArgs);
  3149.  
  3150.     void                stAddArgList (INOUT ArgDscRec REF args,
  3151.                                       TypDef        type,
  3152.                                       Ident         name);
  3153.  
  3154.     TypList             stAddIntfList(TypDef        type,
  3155.                                       TypList       list,
  3156.                                       TypList *     lastPtr);
  3157.  
  3158.     TypDef              stNewClsType (SymDef        tsym);
  3159.     TypDef              stNewEnumType(SymDef        tsym);
  3160.  
  3161.     TypDef              stNewRefType (var_types     kind,
  3162.                                       TypDef        elem = NULL,
  3163.                                       bool          impl = false);
  3164.  
  3165.     DimDef              stNewDimDesc (unsigned      size);
  3166.     TypDef              stNewGenArrTp(unsigned      dcnt,
  3167.                                       TypDef        elem,
  3168.                                       bool          generic);
  3169.     TypDef              stNewArrType (DimDef        dims,
  3170.                                       bool          mgd,
  3171.                                       TypDef        elem = NULL);
  3172.     TypDef              stNewFncType (ArgDscRec     args,
  3173.                                       TypDef        rett = NULL);
  3174.  
  3175.     TypDef              stNewTdefType(SymDef        tsym);
  3176.  
  3177.     TypDef              stNewErrType (Ident         name);
  3178.  
  3179. private:
  3180.  
  3181.     TypDef              stAllocTypDef(var_types     kind);
  3182.  
  3183.     static
  3184.     unsigned            stTypeHash   (TypDef        type,
  3185.                                       int           ival,
  3186.                                       bool          bval1,
  3187.                                       bool          bval2 = false);
  3188.  
  3189.     TypDef              stRefTypeList;
  3190.     unsigned            stRefTpHashSize;
  3191.     TypDef         *    stRefTpHash;
  3192.  
  3193.     TypDef              stArrTypeList;
  3194.     unsigned            stArrTpHashSize;
  3195.     TypDef         *    stArrTpHash;
  3196.  
  3197. #ifdef  SETS
  3198.     static
  3199.     unsigned            stAnonClassHash(TypDef clsTyp);
  3200. #endif
  3201.  
  3202.     static
  3203.     unsigned            stComputeTypeCRC(TypDef typ);
  3204.  
  3205.     static
  3206.     unsigned            stComputeArgsCRC(TypDef typ);
  3207.  
  3208. private:
  3209.     TypDef              stIntrinsicTypes[TYP_lastIntrins + 1];
  3210. public:
  3211.     TypDef              stIntrinsicType(var_types vt)
  3212.     {
  3213.         assert((unsigned)vt <= TYP_lastIntrins);
  3214.  
  3215.         return  stIntrinsicTypes[vt];
  3216.     };
  3217.  
  3218.     static
  3219.     bool                stArgsMatch  (TypDef typ1, TypDef typ2);
  3220.     static
  3221.     bool                stMatchArrays(TypDef typ1, TypDef typ2, bool subtype);
  3222.     static
  3223.     bool                stMatchTypes (TypDef typ1, TypDef typ2);
  3224.     static
  3225.     bool                stMatchType2 (TypDef typ1, TypDef typ2);
  3226.  
  3227. private:
  3228.     static
  3229.     BYTE                stIntrTypeSizes [TYP_COUNT];
  3230.     static
  3231.     BYTE                stIntrTypeAligns[TYP_COUNT];
  3232.  
  3233. public:
  3234.     static
  3235.     size_t              stIntrTypeSize (var_types type);
  3236.     static
  3237.     size_t              stIntrTypeAlign(var_types type);
  3238.  
  3239.     static
  3240.     normString          stClsFlavorStr(unsigned flavor);
  3241.     static
  3242.     normString          stIntrinsicTypeName(var_types);
  3243.  
  3244.     unsigned            stIsBaseClass(TypDef baseCls, TypDef dervCls);
  3245.  
  3246.     static
  3247.     bool                stIsAnonUnion(SymDef clsSym);
  3248.     static
  3249.     bool                stIsAnonUnion(TypDef clsTyp);
  3250.  
  3251.     static
  3252.     bool                stIsObjectRef(TypDef type);
  3253.  
  3254.     /************************************************************************/
  3255.     /* Members used for error reporting (and debugging of the compiler)     */
  3256.     /************************************************************************/
  3257.  
  3258. private:
  3259.  
  3260.     char    *           typeNameNext;
  3261.     char    *           typeNameAddr;
  3262.     TypDef  *           typeNameDeft;
  3263.     bool    *           typeNameDeff;
  3264.  
  3265.     void                pushTypeChar(int ch);
  3266. #if MGDDATA
  3267.     void                pushTypeStr (String     str);
  3268. #else
  3269.     void                pushTypeStr (const char*str);
  3270. #endif
  3271.     void                pushTypeSep (bool       refOK = false,
  3272.                                      bool       arrOK = false);
  3273.  
  3274.     void                pushTypeNstr(SymDef     sym,
  3275.                                      bool       fullName);
  3276.     void                pushQualNstr(QualName   name);
  3277.  
  3278.     void                pushTypeInst(SymDef     clsSym);
  3279.  
  3280.     void                pushTypeArgs(TypDef     type);
  3281.     void                pushTypeDims(TypDef     type);
  3282.  
  3283.     void                pushTypeName(TypDef     type,
  3284.                                      bool       isptr,
  3285.                                      bool       qual);
  3286.  
  3287.     void                pushFullName(TypDef     typ,
  3288.                                      SymDef     sym,
  3289.                                      Ident      name,
  3290.                                      QualName   qual,
  3291.                                      bool       fullName);
  3292.  
  3293.     bool                stDollarClsMode;
  3294.  
  3295. public:
  3296.  
  3297.     //  get "outer$inner" string for nested class names
  3298.  
  3299.     void                stTypeNameSetDollarClassMode(bool dollars)
  3300.     {
  3301.         stDollarClsMode = dollars;
  3302.     }
  3303.  
  3304.     stringBuff          stTypeName(TypDef       typ,
  3305.                                    SymDef       sym         = NULL,
  3306.                                    Ident        name        = NULL,
  3307.                                    QualName     qual        = NULL,
  3308.                                    bool         fullName    = false,
  3309.                                    stringBuff   destBuffPos = NULL);
  3310.  
  3311.  
  3312.     const   char *      stErrorTypeName(TypDef   type);
  3313.     const   char *      stErrorTypeName(Ident    name, TypDef type);
  3314.     const   char *      stErrorSymbName(SymDef    sym, bool   qual = false,
  3315.                                                        bool notype = false);
  3316.     const   char *      stErrorIdenName(Ident    name, TypDef type = NULL);
  3317.     const   char *      stErrorQualName(QualName name, TypDef type = NULL);
  3318. };
  3319.  
  3320. /*****************************************************************************/
  3321.  
  3322. inline
  3323. bool                symTab::stMatchTypes(TypDef typ1, TypDef typ2)
  3324. {
  3325.     if  (typ1 == typ2)
  3326.         return  true;
  3327.  
  3328.     if  (typ1 && typ2)
  3329.         return  stMatchType2(typ1, typ2);
  3330.  
  3331.     return  false;
  3332. }
  3333.  
  3334. /*****************************************************************************
  3335.  *
  3336.  *  Returns the size (in bytes) of the given intrinsic type.
  3337.  */
  3338.  
  3339. inline
  3340. size_t              symTab::stIntrTypeSize(var_types type)
  3341. {
  3342.     assert(type < sizeof(stIntrTypeSizes)/sizeof(stIntrTypeSizes[0]));
  3343.     assert(stIntrTypeSizes[type] || type == TYP_NATINT || type == TYP_NATUINT);
  3344.  
  3345.     return stIntrTypeSizes[type];
  3346. }
  3347.  
  3348. /*****************************************************************************
  3349.  *
  3350.  *  Returns the alignment of the given intrinsic type.
  3351.  */
  3352.  
  3353. inline
  3354. size_t              symTab::stIntrTypeAlign(var_types type)
  3355. {
  3356.     assert(type < sizeof(stIntrTypeAligns)/sizeof(stIntrTypeAligns[0]));
  3357.     assert(stIntrTypeAligns[type]);
  3358.  
  3359.     return stIntrTypeAligns[type];
  3360. }
  3361.  
  3362. /*****************************************************************************
  3363.  *
  3364.  *  A wrapper around stIsBaseClass() that makes sure the derived class has
  3365.  *  been declared before calling it.
  3366.  */
  3367.  
  3368. inline
  3369. unsigned            compiler::cmpIsBaseClass(TypDef baseCls, TypDef dervCls)
  3370. {
  3371.     if  (dervCls->tdClass.tdcSymbol->sdCompileState < CS_DECLARED)
  3372.         cmpDeclSym(dervCls->tdClass.tdcSymbol);
  3373.  
  3374.     return  cmpGlobalST->stIsBaseClass(baseCls, dervCls);
  3375. }
  3376.  
  3377. /*****************************************************************************/
  3378. #endif
  3379. /*****************************************************************************/
  3380.