home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / smc / comp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  105.8 KB  |  3,142 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;     // temp hack
  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. enum    dclModBits
  470. {
  471.     DB_NONE,
  472.  
  473.     DB_STATIC,
  474.     DB_EXTERN,
  475.     DB_VIRTUAL,
  476.     DB_ABSTRACT,
  477.     DB_OVERRIDE,
  478.     DB_INLINE,
  479.     DB_EXCLUDE,
  480.     DB_SEALED,
  481.     DB_OVERLOAD,
  482.     DB_NATIVE,
  483.  
  484.     DB_CONST,
  485.     DB_VOLATILE,
  486.  
  487.     DB_MANAGED,
  488.     DB_UNMANAGED,
  489.     DB_UNSAFE,
  490.  
  491.     DB_PROPERTY,
  492.  
  493.     DB_TRANSIENT,
  494.     DB_SERLZABLE,
  495.  
  496.     DB_DEFAULT,
  497.     DB_MULTICAST,
  498.  
  499.     DB_ALL,
  500.     DB_RESET = DB_ALL-1,
  501.  
  502.     DB_TYPEDEF,
  503.     DB_XMODS,
  504.  
  505.     DB_CLEARED
  506. };
  507.  
  508. enum    dclMods
  509. {
  510.     DM_STATIC    = (1 <<  DB_STATIC   ),
  511.     DM_EXTERN    = (1 <<  DB_EXTERN   ),
  512.     DM_VIRTUAL   = (1 <<  DB_VIRTUAL  ),
  513.     DM_ABSTRACT  = (1 <<  DB_ABSTRACT ),
  514.     DM_OVERRIDE  = (1 <<  DB_OVERRIDE ),
  515.     DM_INLINE    = (1 <<  DB_INLINE   ),
  516.     DM_EXCLUDE   = (1 <<  DB_EXCLUDE  ),
  517.     DM_SEALED    = (1 <<  DB_SEALED   ),
  518.     DM_OVERLOAD  = (1 <<  DB_OVERLOAD ),
  519.     DM_NATIVE    = (1 <<  DB_NATIVE   ),
  520.  
  521.     DM_CONST     = (1 <<  DB_CONST    ),
  522.     DM_VOLATILE  = (1 <<  DB_VOLATILE ),
  523.  
  524.     DM_MANAGED   = (1 <<  DB_MANAGED  ),
  525.     DM_UNMANAGED = (1 <<  DB_UNMANAGED),
  526.     DM_UNSAFE    = (1 <<  DB_UNSAFE   ),
  527.  
  528.     DM_PROPERTY  = (1 <<  DB_PROPERTY ),
  529.  
  530.     DM_TRANSIENT = (1 <<  DB_TRANSIENT),
  531.     DM_SERLZABLE = (1 <<  DB_SERLZABLE),
  532.  
  533.     DM_DEFAULT   = (1 <<  DB_DEFAULT  ),        // legacy mode only
  534.     DM_MULTICAST = (1 <<  DB_MULTICAST),        // legacy mode only
  535.  
  536.     DM_TYPEDEF   = (1 <<  DB_TYPEDEF  ),        // used only for file-scope typedefs
  537.     DM_XMODS     = (1 <<  DB_XMODS    ),        // security modifier / other stuff present
  538.  
  539.     DM_CLEARED   = (1 <<  DB_CLEARED  ),        // modifiers have not been parsed
  540.  
  541.     DM_ALL       =((1 <<  DB_ALL) - 1 )         // used for masking
  542. };
  543.  
  544. struct  declMods
  545. {
  546.     unsigned        dmMod   :24;        // mask of DM_xxx above
  547.     unsigned char   dmAcc   : 8;        // type is accessLevels
  548. };
  549.  
  550. inline
  551. DeclMod             clearDeclMods(DeclMod mods)
  552. {
  553.     mods->dmMod = 0;
  554.     mods->dmAcc = ACL_DEFAULT;
  555.  
  556.     return  mods;
  557. }
  558.  
  559. inline
  560. DeclMod              initDeclMods(DeclMod mods, accessLevels acc)
  561. {
  562.     mods->dmMod = 0;
  563.     mods->dmAcc = acc;
  564.  
  565.     return  mods;
  566. }
  567.  
  568. enum dclrtrName
  569. {
  570.     DN_NONE     = 0,
  571.     DN_OPTIONAL = 1,
  572.     DN_REQUIRED = 2,
  573.     DN_MASK     = 3,
  574.  
  575.     DN_QUALOK = 0x80                    // combine with others to allow "foo.bar"
  576. };
  577.  
  578. /*****************************************************************************/
  579.  
  580. DEFMGMT
  581. class StrListRec
  582. {
  583. public:
  584.  
  585.     StrList             slNext;
  586.     stringBuff          slString;
  587. };
  588.  
  589. /*****************************************************************************/
  590.  
  591. DEFMGMT
  592. class BlkListRec
  593. {
  594. public:
  595.  
  596.     BlkList             blNext;
  597.     genericRef          blAddr;
  598. };
  599.  
  600. /*****************************************************************************/
  601.  
  602. DEFMGMT
  603. class   NumPairDsc
  604. {
  605. public:
  606.     unsigned            npNum1;
  607.     unsigned            npNum2;
  608. };
  609.  
  610. /*****************************************************************************/
  611.  
  612. DEFMGMT
  613. class   constStr
  614. {
  615. public:
  616.     size_t              csLen;
  617.     stringBuff          csStr;
  618. };
  619.  
  620. DEFMGMT
  621. class constVal
  622. {
  623. public:
  624.  
  625.     TypDef              cvType;
  626.  
  627. #ifdef  DEBUG
  628.     var_types           cvVtyp;
  629. #else
  630.     unsigned char       cvVtyp;
  631. #endif
  632.  
  633.     unsigned char       cvIsStr;    // is this a string constant?
  634.     unsigned char       cvHasLC;    // is this a string constant with large chars?
  635.  
  636.     union
  637.     {
  638.         __int32             cvIval;
  639.         __int64             cvLval;
  640.         float               cvFval;
  641.         double              cvDval;
  642.         ConstStr            cvSval;
  643.     }
  644.                         cvValue;
  645. };
  646.  
  647. /*****************************************************************************
  648.  *
  649.  *  Bitsets are used to detect uninitialized variable use. Basically, if there
  650.  *  is a small numbers of locals we need to track, we use a simple integer bit
  651.  *  variable, otherwise we have to use a dynamically sized array of bits. The
  652.  *  bitsetDsc structure holds the data for each instance of a bitset, all of
  653.  *  global state (and code that implements the behavior) is in the compiler
  654.  *  for efficiency class.
  655.  */
  656.  
  657. const   size_t          bitsetSmallSize = 32;
  658. typedef __uint32        bitsetSmallType;
  659.  
  660. const   size_t          bitsetLargeSize =  8;
  661. typedef genericBuff     bitsetLargeType;
  662.  
  663. DEFMGMT
  664. struct  bitset
  665. {
  666. #ifdef  DEBUG
  667.     unsigned            bsCheck;
  668. #endif
  669.     union
  670.     {
  671.         bitsetSmallType     bsSmallVal;
  672.         bitsetLargeType     bsLargeVal;
  673.     };
  674. };
  675.  
  676. /*****************************************************************************
  677.  *
  678.  *  The following keeps track of statement nesting when compiling statements.
  679.  */
  680.  
  681. DEFMGMT
  682. struct  stmtNestRec
  683. {
  684.     StmtNest            snOuter;
  685.     Tree                snStmtExpr;
  686.     treeOps             snStmtKind;
  687.     SymDef              snLabel;
  688.     ILblock             snLabCont;
  689.     ILblock             snLabBreak;
  690.     bool                snHadCont;
  691.     bool                snHadBreak;
  692.     bitset              snDefCont;
  693.     bitset              snDefBreak;
  694. };
  695.  
  696. /*****************************************************************************
  697.  *
  698.  *  The max. inline buffer size for conversions to Unicode.
  699.  */
  700.  
  701. const   unsigned        MAX_INLINE_NAME_LEN = 32;
  702.  
  703. /*****************************************************************************
  704.  *
  705.  *  Metadata import state - one is allocated per each file imported.
  706.  */
  707.  
  708. DEFMGMT
  709. class   metadataImp
  710. {
  711. private:
  712.  
  713.     Compiler            MDcomp;
  714.     SymTab              MDstab;
  715.  
  716.     WCHAR               MDprevNam[MAX_PACKAGE_NAME];
  717.     SymDef              MDprevSym;
  718.  
  719.     mdToken             MDdelegTok;
  720.  
  721.     mdToken             MDclsRefObsolete;           // typeref for System::ObsoleteAttribute
  722.     mdToken             MDclsDefObsolete;           // typedef for System::ObsoleteAttribute
  723.  
  724.     mdToken             MDclsRefAttribute;          // typeref for System::Attribute
  725.     mdToken             MDclsDefAttribute;          // typedef for System::Attribute
  726.     mdToken             MDctrDefAttribute1;         // methdef for System::Attribute::ctor(arg1)
  727.     mdToken             MDctrDefAttribute2;         // methdef for System::Attribute::ctor(arg2)
  728.     mdToken             MDctrDefAttribute3;         // methdef for System::Attribute::ctor(arg3)
  729.     mdToken             MDctrRefAttribute1;         // methref for System::Attribute::ctor(arg1)
  730.     mdToken             MDctrRefAttribute2;         // methref for System::Attribute::ctor(arg2)
  731.     mdToken             MDctrRefAttribute3;         // methref for System::Attribute::ctor(arg3)
  732.  
  733. public:
  734.  
  735.     MetaDataImp         MDnext;
  736.  
  737.     unsigned            MDnum;                      // importer index (used for lookups)
  738.  
  739.     WMetaDataImport    *MDwmdi;
  740.  
  741.     void                MDinit(Compiler             comp,
  742.                                SymTab               stab)
  743.     {
  744.         MDcomp = comp;
  745.         MDstab = stab;
  746.         MDwmdi = NULL;
  747.  
  748.         MDfileTok    = 0;
  749.  
  750.         MDprevNam[0] = 0;
  751.  
  752.         MDundefCount = 0;
  753.     }
  754.  
  755.     void                MDinit(WMetaDataImport  *   wmdi,
  756.                                Compiler             comp,
  757.                                SymTab               stab)
  758.     {
  759.         MDcomp = comp;
  760.         MDstab = stab;
  761.         MDwmdi = wmdi;
  762.  
  763.         MDprevNam[0] = 0;
  764.     }
  765.  
  766.     unsigned            MDundefCount;           // bumped for unrecognized stuff
  767.  
  768.     void                MDimportCTyp(mdTypeDef      td,
  769.                                      mdToken        ft);
  770.  
  771.     SymDef              MDimportClss(mdTypeDef      td,
  772.                                      SymDef         clsSym,
  773.                                      unsigned       assx,
  774.                                      bool           deep);
  775.     void                MDimportStab(const char *   fname,
  776.                                      unsigned       assx    = 0,
  777.                                      bool           asmOnly = false,
  778.                                      bool           isBCL   = false);
  779.  
  780.     TypDef              MDimportClsr(mdTypeRef      clsRef,
  781.                                      bool           isVal);
  782.     TypDef              MDimportType(MDsigImport  * sig);
  783.  
  784.     ArgDef              MDimportArgs(MDsigImport  * sig,
  785.                                      unsigned       cnt,
  786.                                      MDargImport  * state);
  787.  
  788.     bool                MDfindAttr  (mdToken        token,
  789.                                      wideStr        name,
  790.                                      const void * * blobAddr,
  791.                                      ULONG        * blobSize);
  792.  
  793.     SymDef              MDfindPropMF(SymDef         propSym,
  794.                                      mdToken        methTok,
  795.                                      bool           getter);
  796.  
  797.     SymDef              MDimportMem(SymDef          scope,
  798.                                     Ident           name,
  799.                                     mdToken         memTok,
  800.                                     unsigned        attrs,
  801.                                     bool            isProp,
  802.                                     bool            fileScope,
  803.                                     PCCOR_SIGNATURE sigAddr,
  804.                                     size_t          sigSize);
  805.  
  806.     accessLevels        MDgetAccessLvl(unsigned attrs);
  807.  
  808.     SymDef              MDparseDotted(WCHAR *name, symbolKinds kind, bool *added);
  809.     Ident               MDhashWideName(WCHAR *name);
  810.  
  811.     void                MDchk4CustomAttrs(SymDef sym, mdToken tok);
  812.  
  813. private:
  814.  
  815.     mdToken             MDfileTok;
  816.  
  817.     void                MDcreateFileTok();
  818.  
  819. public:
  820.  
  821.     void                MDrecordFile()
  822.     {
  823.         if  (!MDfileTok)
  824.             MDcreateFileTok();
  825.     }
  826. };
  827.  
  828. /*****************************************************************************
  829.  *
  830.  *  The following is used to save/restore the current symbol table context.
  831.  */
  832.  
  833. DEFMGMT
  834. struct STctxSave
  835. {
  836.     SymDef              ctxsScp;
  837.     SymDef              ctxsCls;
  838.     SymDef              ctxsNS;
  839.     UseList             ctxsUses;
  840.     SymDef              ctxsComp;
  841.     SymDef              ctxsFncSym;
  842.     TypDef              ctxsFncTyp;
  843. };
  844.  
  845. /*****************************************************************************/
  846. /*****************************************************************************
  847.  *
  848.  *  The following describes an overlapped I/O file.
  849.  */
  850.  
  851. #ifdef  ASYNCH_INPUT_READ
  852.  
  853. DEFMGMT
  854. class   queuedFile
  855. {
  856. public:
  857.     QueuedFile      qfNext;
  858.  
  859.     Compiler        qfComp;
  860.  
  861.     const   char *  qfName;         // name of the file
  862.     size_t          qfSize;         // size in bytes
  863.     void    *       qfBuff;         // address of contents (or NULL)
  864.     HANDLE          qfHandle;       // handle when file is open
  865.     HANDLE          qfEvent;        // signalled when entire contents read
  866.  
  867. #ifdef  DEBUG
  868.     QueuedFile      qfSelf;
  869. #endif
  870.  
  871.     OVERLAPPED      qfOdsc;
  872.  
  873.     bool            qfReady;        // file is ready to be open
  874.     bool            qfOpen;         // file is being read
  875.     bool            qfDone;         // file has been read
  876.     bool            qfParsing;      // file is bein compiled
  877. };
  878.  
  879. #else
  880.  
  881. DEFMGMT
  882. class   queuedFile
  883. {
  884. };
  885.  
  886. #endif
  887.  
  888. /*****************************************************************************
  889.  *
  890.  *  The following defines state and members/methods that are global to the
  891.  *  compilation process.
  892.  */
  893.  
  894. DEFMGMT
  895. class compiler
  896. {
  897. public:
  898.  
  899.     compConfig          cmpConfig;
  900.  
  901.     /************************************************************************/
  902.     /* Main entry points for the compilation process                        */
  903.     /************************************************************************/
  904.  
  905.     bool                cmpInit();
  906.  
  907.     static
  908.     bool                cmpPrepSrc(genericRef cookie, stringBuff file,
  909.                                                       QueuedFile buff    = NULL,
  910.                                                       stringBuff srcText = NULL);
  911.  
  912.     bool                cmpStart(const char *defOutFileName);
  913.     bool                cmpClass(const char *className = NULL);
  914.  
  915.     bool                cmpDone(bool errors);
  916.  
  917.     void                cmpPrepOutput();
  918.  
  919.     void                cmpOutputFileDone(OutFile outf){}
  920.  
  921.     WritePE             cmpPEwriter;
  922.  
  923.     /************************************************************************/
  924.     /* Current public state of the compilation process                      */
  925.     /************************************************************************/
  926.  
  927. public:
  928.  
  929.     SymTab              cmpCurST;           // current symbol table
  930.     SymDef              cmpCurNS;           // the namespace   we're in
  931.     SymDef              cmpCurCls;          // the class scope we're in
  932.     SymDef              cmpCurScp;          // the local scope we're in
  933.     SymDef              cmpLabScp;          // the label scope we're using
  934.     UseList             cmpCurUses;         // the "using" clauses in effect
  935.     SymDef              cmpCurComp;         // the current compilation unit
  936.  
  937.     SymDef              cmpCurFncSym;       // function symbol we're compiling
  938.     TypDef              cmpCurFncTyp;       // function  type  we're compiling
  939.     TypDef              cmpCurFncRtp;       // function return type
  940.     var_types           cmpCurFncRvt;       // function return type
  941.  
  942.     SymList             cmpLclStatListT;    // temp list of local static variables
  943.     SymList             cmpLclStatListP;    // perm list of local static variables
  944.  
  945.     bool                cmpManagedMode;     // is default "managed" ?
  946.  
  947.     ILblock             cmpLeaveLab;        // return from try/catch label / NULL
  948.     SymDef              cmpLeaveTmp;        // return value temp
  949.  
  950.     unsigned            cmpInTryBlk;
  951.     unsigned            cmpInHndBlk;
  952.     unsigned            cmpInFinBlk;
  953.  
  954. private:
  955.  
  956.     /************************************************************************/
  957.     /* Various members used in the compilation process                      */
  958.     /************************************************************************/
  959.  
  960.     SymDef              cmpAsserAbtSym;
  961.  
  962. public:
  963.  
  964.     unsigned            cmpFncCntSeen;
  965.     unsigned            cmpFncCntComp;
  966.  
  967.     Ident               cmpIdentMain;
  968.     SymDef              cmpFnSymMain;
  969.     mdToken             cmpTokenMain;
  970.  
  971.     Ident               cmpIdentVAbeg;
  972.     SymDef              cmpFNsymVAbeg;
  973.     Ident               cmpIdentVAget;
  974.     SymDef              cmpFNsymVAget;
  975.  
  976.     Ident               cmpIdentCompare;
  977.     Ident               cmpIdentEquals;
  978.     Ident               cmpIdentNarrow;
  979.     Ident               cmpIdentWiden;
  980.  
  981.     Ident               cmpIdentGet;
  982.     Ident               cmpIdentSet;
  983.     Ident               cmpIdentExit;
  984.     Ident               cmpIdentEnter;
  985.     Ident               cmpIdentConcat;
  986.     Ident               cmpIdentInvoke;
  987.     Ident               cmpIdentInvokeBeg;
  988.     Ident               cmpIdentInvokeEnd;
  989.     Ident               cmpIdentVariant;
  990.     Ident               cmpIdentToString;
  991.     Ident               cmpIdentGetType;
  992.     Ident               cmpIdentGetTpHnd;
  993.     Ident               cmpIdentAssertAbt;
  994.  
  995.     Ident               cmpIdentDbgBreak;
  996.  
  997.     Ident               cmpIdentXcptCode;
  998.     Ident               cmpIdentXcptInfo;
  999.     Ident               cmpIdentAbnmTerm;
  1000.  
  1001.     Ident               cmpIdentGetNArg;
  1002.     SymDef              cmpGetNextArgFN;    // ArgIterator::GetNextArg(int)
  1003.  
  1004.     SymDef              cmpCtorArgIter;     // ArgIterator(int,int)
  1005.  
  1006.     SymDef              cmpConcStr2Fnc;     // Concat(String,String)
  1007.     SymDef              cmpConcStr3Fnc;     // Concat(String,String,String)
  1008.     SymDef              cmpConcStrAFnc;     // Concat(String[])
  1009.  
  1010.     SymDef              cmpStrCompare;      // string value comparison method
  1011.     SymDef              cmpStrEquals;       // string value equality   method
  1012.  
  1013.     SymDef              cmpFindStrCompMF(const char *name, bool retBool);
  1014.     Tree                cmpCallStrCompMF(Tree expr,
  1015.                                          Tree  op1,
  1016.                                          Tree  op2, SymDef fsym);
  1017.  
  1018.     SymDef              cmpFNsymCSenter;    // CriticalSection::Enter
  1019.     SymDef              cmpFNsymCSexit;     // CriticalSection::Exit
  1020.  
  1021.     mdToken             cmpAttrDeprec;      // attribute ref for "Deprecated"
  1022.     mdToken             cmpAttrIsDual;      // attribute ref for "IsDual"
  1023.     mdToken             cmpAttrDefProp;     // attribute ref for "DefaultMemberAttribute"
  1024.     mdToken             cmpAttrSerlzb;      // attribute ref for "SerializableAttribute"
  1025.     mdToken             cmpAttrNonSrlz;     // attribute ref for "NonSerializedAttribute"
  1026.  
  1027.     SymDef              cmpAttrClsSym;      // System::Attribute        symbol
  1028.     SymDef              cmpAuseClsSym;      // System::AttributeUsage   symbol
  1029. //  SymDef              cmpAttrTgtSym;      // System::AttributeTargets symbol
  1030.  
  1031.     SymDef              cmpMarshalCls;      // System::Interop::Marshal
  1032.  
  1033.     SymDef              cmpFNsymGetTpHnd;   // Type::GetTypeFromHandle
  1034.     void                cmpFNsymGetTPHdcl();
  1035.     SymDef              cmpFNsymGetTPHget()
  1036.     {
  1037.         if  (!cmpFNsymGetTpHnd)
  1038.             cmpFNsymGetTPHdcl();
  1039.  
  1040.         return  cmpFNsymGetTpHnd;
  1041.     }
  1042.  
  1043.     SymDef              cmpRThandleCls;     // struct System::RuntimeTypeHandle
  1044.     void                cmpRThandleClsDcl();
  1045.     SymDef              cmpRThandleClsGet()
  1046.     {
  1047.         if  (!cmpRThandleCls)
  1048.             cmpRThandleClsDcl();
  1049.  
  1050.         return  cmpRThandleCls;
  1051.     }
  1052.  
  1053.     SymDef              cmpDeclUmgOper(tokens tokName, const char *extName);
  1054.  
  1055.     SymDef              cmpFNumgOperNew;    // unmanaged operator new
  1056.     SymDef              cmpFNumgOperNewGet()
  1057.     {
  1058.         if  (!cmpFNumgOperNew)
  1059.             cmpFNumgOperNew = cmpDeclUmgOper(tkNEW   , "??2@YAPAXI@Z");
  1060.  
  1061.         return  cmpFNumgOperNew;
  1062.     }
  1063.  
  1064.     SymDef              cmpFNumgOperDel;    // unmanaged operator delete
  1065.     SymDef              cmpFNumgOperDelGet()
  1066.     {
  1067.         if  (!cmpFNumgOperDel)
  1068.             cmpFNumgOperDel = cmpDeclUmgOper(tkDELETE, "??3@YAXPAX@Z");
  1069.  
  1070.         return  cmpFNumgOperDel;
  1071.     }
  1072.  
  1073.     Ident               cmpIdentSystem;
  1074.     SymDef              cmpNmSpcSystem;
  1075.  
  1076.     Ident               cmpIdentRuntime;
  1077.     SymDef              cmpNmSpcRuntime;
  1078.  
  1079.     Ident               cmpIdentObject;
  1080.     SymDef              cmpClassObject;
  1081.     TypDef              cmpRefTpObject;
  1082.  
  1083.     Ident               cmpIdentArray;
  1084.     SymDef              cmpClassArray;
  1085.     TypDef              cmpRefTpArray;
  1086.  
  1087.     Ident               cmpIdentString;
  1088.     SymDef              cmpClassString;
  1089.     TypDef              cmpRefTpString;
  1090.  
  1091.     Ident               cmpIdentType;
  1092.     SymDef              cmpClassType;
  1093.     TypDef              cmpRefTpType;
  1094.  
  1095.     Ident               cmpIdentDeleg;
  1096.     SymDef              cmpClassDeleg;
  1097.     TypDef              cmpRefTpDeleg;
  1098.  
  1099.     Ident               cmpIdentMulti;
  1100.     SymDef              cmpClassMulti;
  1101.     TypDef              cmpRefTpMulti;
  1102.  
  1103.     Ident               cmpIdentExcept;
  1104.     SymDef              cmpClassExcept;
  1105.     TypDef              cmpRefTpExcept;
  1106.  
  1107.     Ident               cmpIdentRTexcp;
  1108.     SymDef              cmpClassRTexcp;
  1109.     TypDef              cmpRefTpRTexcp;
  1110.  
  1111.     SymDef              cmpClassMonitor;
  1112.     TypDef              cmpRefTpMonitor;
  1113.  
  1114.     Ident               cmpIdentArgIter;
  1115.     SymDef              cmpClassArgIter;
  1116.     TypDef              cmpRefTpArgIter;
  1117.  
  1118.     Ident               cmpIdentEnum;
  1119.     SymDef              cmpClassEnum;
  1120.  
  1121.     Ident               cmpIdentValType;
  1122.     SymDef              cmpClassValType;
  1123.  
  1124.     TypDef              cmpAsyncDlgRefTp;
  1125.     TypDef              cmpIAsyncRsRefTp;
  1126.  
  1127.     TypDef              cmpFindArgIterType();
  1128.     TypDef              cmpFindMonitorType();
  1129.     TypDef              cmpFindStringType();
  1130.     TypDef              cmpFindObjectType();
  1131.     TypDef              cmpFindExceptType();
  1132.     TypDef              cmpFindRTexcpType();
  1133.     TypDef              cmpFindArrayType();
  1134.     TypDef              cmpFindDelegType();
  1135.     TypDef              cmpFindMultiType();
  1136.     TypDef              cmpFindTypeType();
  1137.  
  1138.     TypDef              cmpExceptRef()
  1139.     {
  1140.         if  (cmpRefTpExcept)
  1141.             return cmpRefTpExcept;
  1142.         else
  1143.             return cmpFindExceptType();
  1144.     }
  1145.  
  1146.     TypDef              cmpRTexcpRef()
  1147.     {
  1148.         if  (cmpRefTpRTexcp)
  1149.             return cmpRefTpRTexcp;
  1150.         else
  1151.             return cmpFindRTexcpType();
  1152.     }
  1153.  
  1154.     TypDef              cmpStringRef()
  1155.     {
  1156.         if  (cmpRefTpString)
  1157.             return cmpRefTpString;
  1158.         else
  1159.             return cmpFindStringType();
  1160.     }
  1161.  
  1162.     TypDef              cmpObjectRef()
  1163.     {
  1164.         if  (cmpRefTpObject)
  1165.             return cmpRefTpObject;
  1166.         else
  1167.             return cmpFindObjectType();
  1168.     }
  1169.  
  1170.     TypDef              cmpTypeRef()
  1171.     {
  1172.         if  (cmpRefTpType)
  1173.             return cmpRefTpType;
  1174.         else
  1175.             return cmpFindTypeType();
  1176.     }
  1177.  
  1178.     TypDef              cmpArrayRef()
  1179.     {
  1180.         if  (cmpRefTpArray)
  1181.             return cmpRefTpArray;
  1182.         else
  1183.             return cmpFindArrayType();
  1184.     }
  1185.  
  1186.     TypDef              cmpDelegRef()
  1187.     {
  1188.         if  (cmpRefTpDeleg)
  1189.             return cmpRefTpDeleg;
  1190.         else
  1191.             return cmpFindDelegType();
  1192.     }
  1193.  
  1194.     TypDef              cmpMultiRef()
  1195.     {
  1196.         if  (cmpRefTpMulti)
  1197.             return cmpRefTpMulti;
  1198.         else
  1199.             return cmpFindMultiType();
  1200.     }
  1201.  
  1202.     TypDef              cmpArgIterRef()
  1203.     {
  1204.         if  (cmpRefTpArgIter)
  1205.             return cmpRefTpArgIter;
  1206.         else
  1207.             return cmpFindArgIterType();
  1208.     }
  1209.  
  1210.     TypDef              cmpMonitorRef()
  1211.     {
  1212.         if  (cmpRefTpMonitor)
  1213.             return cmpRefTpMonitor;
  1214.         else
  1215.             return cmpFindMonitorType();
  1216.     }
  1217.  
  1218.     void                cmpInteropFind();
  1219.     SymDef              cmpInteropSym;      // System::Interop
  1220.     SymDef              cmpInteropGet()
  1221.     {
  1222.         if  (!cmpInteropSym)
  1223.             cmpInteropFind();
  1224.  
  1225.         return  cmpInteropSym;
  1226.     }
  1227.  
  1228.     void                cmpNatTypeFind();
  1229.     SymDef              cmpNatTypeSym;      // System::Interop::NativeType
  1230.     SymDef              cmpNatTypeGet()
  1231.     {
  1232.         if  (!cmpNatTypeSym)
  1233.             cmpNatTypeFind();
  1234.  
  1235.         return  cmpNatTypeSym;
  1236.     }
  1237.  
  1238.     void                cmpCharSetFind();
  1239.     SymDef              cmpCharSetSym;      // System::Interop::CharacterSet
  1240.     SymDef              cmpCharSetGet()
  1241.     {
  1242.         if  (!cmpCharSetSym)
  1243.             cmpCharSetFind();
  1244.  
  1245.         return  cmpCharSetSym;
  1246.     }
  1247.  
  1248.     bool                cmpIsByRefType(TypDef type);
  1249.  
  1250.     bool                cmpIsStringVal(Tree   expr);
  1251.     bool                cmpIsObjectVal(Tree   expr);
  1252.  
  1253.     unsigned            cmpIsBaseClass(TypDef baseCls, TypDef dervCls);
  1254.  
  1255. private:
  1256.     unsigned            cmpCntAnonymousNames;
  1257. public:
  1258.     Ident               cmpNewAnonymousName();
  1259.  
  1260.     void                cmpMarkStdType(SymDef clsSym);
  1261.  
  1262. private:
  1263.  
  1264.     void                cmpFindHiddenBaseFNs(SymDef fncSym, SymDef clsSym);
  1265.  
  1266.     SymList             cmpNoDimArrVars;
  1267.  
  1268.     Tree                cmpTypeIDinst(TypDef type);
  1269.  
  1270. #ifdef  DEBUG
  1271.     SymDef              cmpInitVarCur;
  1272.     unsigned            cmpInitVarOfs;
  1273. #endif
  1274.  
  1275.     memBuffPtr          cmpWriteVarData(memBuffPtr      dest,
  1276.                                         genericBuff     str,
  1277.                                         size_t          len);
  1278.  
  1279.     memBuffPtr          cmpInitVarPad  (memBuffPtr      dest,
  1280.                                         size_t          amount);
  1281.  
  1282.     bool                cmpInitVarAny  (INOUT memBuffPtr REF dest,
  1283.                                         TypDef          type,
  1284.                                         SymDef          varSym = NULL);
  1285.     bool                cmpInitVarScl  (INOUT memBuffPtr REF dest,
  1286.                                         TypDef          type,
  1287.                                         SymDef          varSym = NULL);
  1288.     bool                cmpInitVarArr  (INOUT memBuffPtr REF dest,
  1289.                                         TypDef          type,
  1290.                                         SymDef          varSym = NULL);
  1291.     bool                cmpInitVarCls  (INOUT memBuffPtr REF dest,
  1292.                                         TypDef          type,
  1293.                                         SymDef          varSym = NULL);
  1294.  
  1295.     memBuffPtr          cmpWriteOneInit(memBuffPtr      dest,
  1296.                                         Tree            expr);
  1297.     memBuffPtr          cmpInitVarBeg  (SymDef          varSym,
  1298.                                         bool            undim = false);
  1299.     void                cmpInitVarEnd  (SymDef          varSym);
  1300.     Tree                cmpParseOneInit(TypDef          type);
  1301.  
  1302.     void                cmpBindUseList (UseList         useList);
  1303.  
  1304.     SymDef              cmpEntryPointCls;
  1305.     void                cmpChk4entryPt (SymDef          sym);
  1306.  
  1307.     SymDef              cmpDeclDataMem (SymDef          clsSym,
  1308.                                         declMods        memMod,
  1309.                                         TypDef          type,
  1310.                                         Ident           name);
  1311.  
  1312.     SymDef              cmpDeclPropMem (SymDef          clsSym,
  1313.                                         TypDef          type,
  1314.                                         Ident           name);
  1315.  
  1316.     SymDef              cmpDeclFuncMem (SymDef          clsSym,
  1317.                                         declMods        memMod,
  1318.                                         TypDef          type,
  1319.                                         Ident           name);
  1320.  
  1321.     SymXinfo            cmpFindXtraInfo(SymXinfo        infoList,
  1322.                                         xinfoKinds      infoKind);
  1323.  
  1324.     SymXinfoCOM         cmpFindMarshal (SymXinfo        infoList);
  1325.     SymXinfoLnk         cmpFindLinkInfo(SymXinfo        infoList);
  1326.     SymXinfoSec         cmpFindSecSpec (SymXinfo        infoList);
  1327.     SymXinfoSym         cmpFindSymInfo (SymXinfo        infoList,
  1328.                                         xinfoKinds      kind);
  1329.     SymXinfoAtc         cmpFindATCentry(SymXinfo        infoList,
  1330.                                         atCommFlavors   flavor);
  1331.  
  1332.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1333.                                         SymXinfo        infoAdd)
  1334.     {
  1335.         if  (infoAdd)
  1336.         {
  1337.             infoAdd->xiNext = infoList;
  1338.             return infoAdd;
  1339.         }
  1340.         else
  1341.             return infoList;
  1342.     }
  1343.  
  1344.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1345.                                         MarshalInfo     marshal);
  1346.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1347.                                         SymDef          sym,
  1348.                                         xinfoKinds      kind);
  1349.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1350.                                         SecurityInfo    secInfo);
  1351.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1352.                                         AtComment        atcDesc);
  1353.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1354.                                         Linkage         linkSpec);
  1355.  
  1356. public: // used in the parser
  1357.     SymXinfo            cmpAddXtraInfo (SymXinfo        infoList,
  1358.                                         SymDef          attrCtor,
  1359.                                         unsigned        attrMask,
  1360.                                         size_t          attrSize,
  1361.                                         genericBuff     attrAddr);
  1362.  
  1363. public:
  1364.     static
  1365.     size_t              cmpDecodeAlign (unsigned        alignVal);
  1366.     static
  1367.     unsigned            cmpEncodeAlign (size_t          alignSiz);
  1368.  
  1369. private:
  1370.  
  1371.     void                cmpLayoutClass (SymDef          clsSym);
  1372.  
  1373.     TypDef              cmpGetClassSpec(bool            needIntf);
  1374.  
  1375.     void                cmpObsoleteUse (SymDef          sym,
  1376.                                         unsigned        wrn);
  1377.  
  1378.     SymDef              cmpFindIntfImpl(SymDef          clsSym,
  1379.                                         SymDef          ifcSym,
  1380.                                         SymDef        * impOvlPtr = NULL);
  1381.  
  1382.     void                cmpClsImplAbs  (SymDef          clsSym,
  1383.                                         SymDef          fncSym);
  1384.  
  1385.     void                cmpCheckClsIntf(SymDef          clsSym);
  1386.  
  1387.     void                cmpCheckIntfLst(SymDef          clsSym,
  1388.                                         SymDef          baseSym,
  1389.                                         TypList         intfList);
  1390.  
  1391.     void                cmpDeclProperty(SymDef          memSym,
  1392.                                         declMods        memMod,
  1393.                                         DefList         memDef);
  1394.     void                cmpDeclDelegate(DefList         decl,
  1395.                                         SymDef          dlgSym,
  1396.                                         accessLevels    acc);
  1397.  
  1398.     void                cmpDeclTdef    (SymDef          tdefSym);
  1399.     void                cmpDeclEnum    (SymDef          enumSym,
  1400.                                         bool            namesOnly = false);
  1401.  
  1402.     unsigned            cmpDeclClassRec;
  1403.     void                cmpDeclClass   (SymDef          clsSym,
  1404.                                         bool            noCnsEval = false);
  1405.     void                cmpCompClass   (SymDef          clsSym);
  1406.     void                cmpCompVar     (SymDef          varSym,
  1407.                                         DefList         srcDesc);
  1408.     void                cmpCompFnc     (SymDef          fncSym,
  1409.                                         DefList         srcDesc);
  1410.  
  1411.     ExtList             cmpFlipMemList (ExtList         nspMem);
  1412.  
  1413.     IniList             cmpDeferCnsFree;
  1414.     IniList             cmpDeferCnsList;
  1415.  
  1416.     void                cmpEvalMemInit (ExtList         cnsDef);
  1417.     void                cmpEvalMemInits(SymDef          clsSym,
  1418.                                         ExtList         constList,
  1419.                                         bool            noEval,
  1420.                                         IniList         deferLst);
  1421.  
  1422.     void                cmpEvalCnsSym  (SymDef          sym,
  1423.                                         bool            saveCtx);
  1424.  
  1425.     void                cmpDeclConsts  (SymDef          scope,
  1426.                                         bool            fullEval);
  1427.  
  1428.     bool                cmpDeclSym     (SymDef          sym,
  1429.                                         SymDef          onlySym,
  1430.                                         bool            recurse);
  1431.  
  1432.     bool                cmpCompSym     (SymDef          sym,
  1433.                                         SymDef          onlySym,
  1434.                                         bool            recurse);
  1435.  
  1436.     void                cmpDeclFileSym (ExtList         decl,
  1437.                                         bool            fullDecl);
  1438.  
  1439.     bool                cmpDeclSymDoit (SymDef          sym,
  1440.                                         bool            noCnsEval = false);
  1441.  
  1442.     bool                cmpDeclClsNoCns(SymDef          sym);
  1443.  
  1444.     void                cmpSaveSTctx   (STctxSave      & save);
  1445.     void                cmpRestSTctx   (STctxSave      & save);
  1446.  
  1447. public:
  1448.  
  1449.     bool                cmpDeclSym     (SymDef          sym);
  1450.  
  1451.     memBuffPtr          cmpAllocGlobVar(SymDef          varSym);
  1452.  
  1453.     size_t              cmpGetTypeSize (TypDef          type,
  1454.                                         size_t    *     alignPtr = NULL);
  1455.  
  1456.     static
  1457.     void                cmpRecordMemDef(SymDef          clsSym,
  1458.                                         ExtList         decl);
  1459.  
  1460.     /************************************************************************/
  1461.     /*  Logic that checks for uninitialized variable use                    */
  1462.     /************************************************************************/
  1463.  
  1464.     bool                cmpChkVarInit;          // enables the whole thing
  1465.  
  1466.     bool                cmpChkMemInit;          // need to check static mem init?
  1467.  
  1468.     unsigned            cmpLclVarCnt;           // # of local variables to track
  1469.  
  1470.     bool                cmpGotoPresent;         // irreducible flow-graph?
  1471.  
  1472.     bitset              cmpVarsDefined;         // vars known to be defined
  1473.     bitset              cmpVarsFlagged;         // vars already flagged
  1474.  
  1475.     bitset              cmpVarsIgnore;          // used for unneeded args
  1476.  
  1477.     void                cmpChkMemInits();
  1478.  
  1479.     void                cmpChkVarInitBeg(unsigned lclVarCnt, bool hadGoto);
  1480.     void                cmpChkVarInitEnd();
  1481.  
  1482.     void                cmpChkVarInitExprRec(Tree expr);
  1483.     void                cmpChkVarInitExpr   (Tree expr)
  1484.     {
  1485.         if  (cmpChkVarInit)
  1486.             cmpChkVarInitExprRec(expr);
  1487.     }
  1488.  
  1489.     void                cmpCheckUseCond(Tree expr, OUT bitset REF yesBS,
  1490.                                                    bool           yesSkip,
  1491.                                                    OUT bitset REF  noBS,
  1492.                                                    bool            noSkip);
  1493.  
  1494.     /************************************************************************/
  1495.     /*  Helper logic that maintains bitsets                                 */
  1496.     /************************************************************************/
  1497.  
  1498.     size_t              cmpLargeBSsize;         // size of large bitset or 0
  1499.  
  1500.     void                cmpBitSetInit(unsigned lclVarCnt)
  1501.     {
  1502.         if  (lclVarCnt > bitsetSmallSize)
  1503.             cmpLargeBSsize = (lclVarCnt + bitsetLargeSize - 1) / bitsetLargeSize;
  1504.         else
  1505.             cmpLargeBSsize = 0;
  1506.     }
  1507.  
  1508.     void                cmpBS_bigStart (  OUT bitset REF bs)
  1509.     {
  1510. #ifdef  DEBUG
  1511.         bs.bsCheck = 0xBEEFDEAD;
  1512. #endif
  1513.     }
  1514.  
  1515.     void                cmpBS_bigCreate(  OUT bitset REF bs);
  1516.     void                cmpBitSetCreate(  OUT bitset REF bs)
  1517.     {
  1518.         if  (cmpLargeBSsize)
  1519.             cmpBS_bigCreate(bs);
  1520.         else
  1521.             bs.bsSmallVal = 0;
  1522.     }
  1523.  
  1524.     void                cmpBS_bigDone  (IN    bitset REF bs);
  1525.     void                cmpBitSetDone  (IN    bitset REF bs)
  1526.     {
  1527.         if  (cmpLargeBSsize)
  1528.             cmpBS_bigDone(bs);
  1529.     }
  1530.  
  1531.     void                cmpBS_bigWrite (INOUT bitset REF bs, unsigned pos,
  1532.                                                              unsigned val);
  1533.     void                cmpBitSetWrite (INOUT bitset REF bs, unsigned pos,
  1534.                                                              unsigned val)
  1535.     {
  1536.         assert(val == 0 || val == 1);
  1537.  
  1538.         if  (cmpLargeBSsize)
  1539.         {
  1540.             cmpBS_bigWrite(bs, pos, val);
  1541.         }
  1542.         else
  1543.         {
  1544.             bitsetSmallType mask = (bitsetSmallType)1 << pos;
  1545.  
  1546.             assert(pos < bitsetSmallSize);
  1547.  
  1548.             if  (val)
  1549.                 bs.bsSmallVal |=  mask;
  1550.             else
  1551.                 bs.bsSmallVal &= ~mask;
  1552.         }
  1553.     }
  1554.  
  1555.     void                cmpBS_bigCreate(  OUT bitset REF dst,
  1556.                                         IN    bitset REF src);
  1557.     void                cmpBitSetCreate(  OUT bitset REF dst,
  1558.                                         IN    bitset REF src)
  1559.     {
  1560.         if  (cmpLargeBSsize)
  1561.         {
  1562.             cmpBS_bigCreate(dst, src);
  1563.         }
  1564.         else
  1565.         {
  1566.             dst.bsSmallVal = src.bsSmallVal;
  1567.         }
  1568.     }
  1569.  
  1570.     void                cmpBS_bigAssign(  OUT bitset REF dst,
  1571.                                         IN    bitset REF src);
  1572.     void                cmpBitSetAssign(  OUT bitset REF dst,
  1573.                                         IN    bitset REF src)
  1574.     {
  1575.         if  (cmpLargeBSsize)
  1576.         {
  1577.             cmpBS_bigAssign(dst, src);
  1578.         }
  1579.         else
  1580.         {
  1581.             dst.bsSmallVal = src.bsSmallVal;
  1582.         }
  1583.     }
  1584.  
  1585.     unsigned            cmpBS_bigRead  (IN    bitset REF bs, unsigned pos);
  1586.     unsigned            cmpBitSetRead  (IN    bitset REF bs, unsigned pos)
  1587.     {
  1588.         if  (cmpLargeBSsize)
  1589.         {
  1590.             return  cmpBS_bigRead(bs, pos);
  1591.         }
  1592.         else
  1593.         {
  1594.             assert(pos < bitsetSmallSize);
  1595.  
  1596.             return  ((bs.bsSmallVal & ((bitsetSmallType)1 << pos)) != 0);
  1597.         }
  1598.     }
  1599.  
  1600.     void                cmpBS_bigUnion (INOUT bitset REF bs1,
  1601.                                         IN    bitset REF bs2);
  1602.     void                cmpBitSetUnion (INOUT bitset REF bs1,
  1603.                                         IN    bitset REF bs2)
  1604.     {
  1605.         if  (cmpLargeBSsize)
  1606.         {
  1607.             cmpBS_bigUnion(bs1, bs2);
  1608.         }
  1609.         else
  1610.         {
  1611.             bs1.bsSmallVal |= bs2.bsSmallVal;
  1612.         }
  1613.     }
  1614.  
  1615.     void                cmpBS_bigIntsct(INOUT bitset REF bs1,
  1616.                                         IN    bitset REF bs2);
  1617.     void                cmpBitSetIntsct(INOUT bitset REF bs1,
  1618.                                         IN    bitset REF bs2)
  1619.     {
  1620.         if  (cmpLargeBSsize)
  1621.         {
  1622.             cmpBS_bigIntsct(bs1, bs2);
  1623.         }
  1624.         else
  1625.         {
  1626.             bs1.bsSmallVal &= bs2.bsSmallVal;
  1627.         }
  1628.     }
  1629.  
  1630.     /************************************************************************/
  1631.     /*  In case anyone wants to know how much work we've been doing         */
  1632.     /************************************************************************/
  1633.  
  1634. public:
  1635.     unsigned            cmpLineCnt;
  1636.  
  1637.     /************************************************************************/
  1638.     /* Members used for statement reachability analysis                     */
  1639.     /************************************************************************/
  1640.  
  1641. private:
  1642.  
  1643.     bool                cmpStmtReachable;
  1644.  
  1645.     void                cmpErrorReach(Tree stmt);
  1646.  
  1647.     void                cmpCheckReach(Tree stmt)
  1648.     {
  1649.         if  (!cmpStmtReachable)
  1650.             cmpErrorReach(stmt);
  1651.     }
  1652.  
  1653.     /************************************************************************/
  1654.     /* Pointers to the hash table, scanner, symbol manager, ...             */
  1655.     /************************************************************************/
  1656.  
  1657. public:
  1658.  
  1659.     Scanner             cmpScanner;
  1660.     Parser              cmpParser;
  1661.  
  1662.     block_allocator     cmpAllocTemp;       // limited lifetime allocs
  1663.     norls_allocator     cmpAllocPerm;       // this never goes away
  1664.     norls_allocator     cmpAllocCGen;       // used for IL generation
  1665.  
  1666. #ifdef  DLL
  1667.     void    *           cmpOutputFile;      // when compiling to memory
  1668. #endif
  1669.  
  1670. private:
  1671.  
  1672.     BlkList             cmpAllocList;
  1673.  
  1674. public:
  1675.  
  1676.     genericRef          cmpAllocBlock(size_t sz);
  1677.  
  1678.     /************************************************************************/
  1679.     /* The following is the root of all evil - er - symbols and such        */
  1680.     /************************************************************************/
  1681.  
  1682.     HashTab             cmpGlobalHT;        // global hash   table
  1683.     SymTab              cmpGlobalST;        // global symbol table
  1684.     SymDef              cmpGlobalNS;        // global namespace symbol
  1685.  
  1686.     /************************************************************************/
  1687.     /* Pre-defined standard types                                           */
  1688.     /************************************************************************/
  1689.  
  1690.     TypDef              cmpTypeInt;
  1691.     TypDef              cmpTypeBool;
  1692.     TypDef              cmpTypeChar;
  1693.     TypDef              cmpTypeVoid;
  1694.     TypDef              cmpTypeUint;
  1695.     TypDef              cmpTypeNatInt;
  1696.     TypDef              cmpTypeNatUint;
  1697.  
  1698.     TypDef              cmpTypeCharPtr;
  1699.     TypDef              cmpTypeWchrPtr;
  1700.     TypDef              cmpTypeVoidPtr;
  1701.  
  1702.     TypDef              cmpTypeVoidFnc;     // void fnc()
  1703.     TypDef              cmpTypeStrArr;      // String[]
  1704.  
  1705.     /************************************************************************/
  1706.     /* Generic type support                                                 */
  1707.     /************************************************************************/
  1708.  
  1709.     SymList             cmpGenInstList;     // current set of instantiations
  1710.     SymList             cmpGenInstFree;     // list of free instantiation desc's
  1711.  
  1712.     GenArgDscA          cmpGenArgAfree;     // list of free actual arg descriptors
  1713.  
  1714.     void                cmpDeclInstType(SymDef clsSym);
  1715.  
  1716.     TypDef              cmpInstanceType(TypDef genType, bool chkOnly = false);
  1717.  
  1718.     SymDef              cmpInstanceMeth(INOUT SymDef REF newOvl,
  1719.                                               SymDef     clsSym,
  1720.                                               SymDef     ovlSym);
  1721.  
  1722.     /************************************************************************/
  1723.     /* Members related to error reporting                                   */
  1724.     /************************************************************************/
  1725.  
  1726.     SymDef              cmpErrorSym;
  1727.     SymDef              cmpErrorComp;
  1728.     const   char *      cmpErrorSrcf;
  1729.     Tree                cmpErrorTree;
  1730.  
  1731.     unsigned            cmpErrorCount;
  1732.     unsigned            cmpFatalCount;
  1733.     unsigned            cmpMssgsCount;
  1734.  
  1735.     unsigned            cmpErrorMssgDisabled;
  1736.  
  1737. #if TRAP_VIA_SETJMP
  1738.     ErrTrap             cmpErrorTraps;
  1739. #endif
  1740.  
  1741. private:
  1742.  
  1743.     void                cmpSetSrcPos(SymDef memSym);
  1744.  
  1745.     void                cmpShowMsg (unsigned errNum, const char *kind, va_list args);
  1746.  
  1747.     const   char *      cmpErrorGenTypName(TypDef typ);
  1748.     const   char *      cmpErrorGenSymName(SymDef sym, bool qual = false);
  1749.     const   char *      cmpErrorGenSymName(Ident name, TypDef type);
  1750.  
  1751.     void                cmpReportSymDef(SymDef sym);
  1752.     void                cmpRedefSymErr (SymDef sym, unsigned err);
  1753.  
  1754. public:
  1755.  
  1756.     void                cmpErrorInit();
  1757.     void                cmpErrorSave();
  1758.  
  1759.     // The following is accessed by the scanner (we have no friends)
  1760.  
  1761.     BYTE                cmpInitialWarn[WRNcountWarn];
  1762.  
  1763.     // NOTE: Use the varargs version with extreme care -- no type checking!
  1764.  
  1765.     void                cmpSetErrPos(DefSrc def, SymDef compUnit);
  1766.  
  1767.     void                cmpCntError();
  1768.  
  1769.     void    _cdecl      cmpGenWarn (unsigned errNum, ...);
  1770.     void    _cdecl      cmpGenError(unsigned errNum, ...);
  1771.     void    _cdecl      cmpGenFatal(unsigned errNum, ...);
  1772.  
  1773.     void                cmpError   (unsigned errNum)
  1774.     {
  1775.         cmpGenError(errNum);
  1776.     }
  1777.  
  1778.     void                cmpWarn    (unsigned wrnNum)
  1779.     {
  1780.         cmpGenWarn (wrnNum);
  1781.     }
  1782.  
  1783.     void                cmpFatal   (unsigned errNum)
  1784.     {
  1785.         cmpGenFatal(errNum);
  1786.     }
  1787.  
  1788.     void                cmpFatal   (unsigned errNum, SymDef    sym);
  1789.  
  1790.     void                cmpError   (unsigned errNum, Ident    name);
  1791.     void                cmpError   (unsigned errNum, SymDef    sym);
  1792.     void                cmpError   (unsigned errNum, QualName qual);
  1793.     void                cmpError   (unsigned errNum, TypDef   type);
  1794.     void                cmpError   (unsigned errNum, Ident    name, TypDef type,
  1795.                                                                     bool   glue);
  1796.     void                cmpError   (unsigned errNum, TypDef   typ1, TypDef typ2);
  1797.     void                cmpError   (unsigned errNum, TypDef    typ, Ident  name);
  1798.     void                cmpError   (unsigned errNum, SymDef    sym, Ident  name,
  1799.                                                                     TypDef type);
  1800.     void                cmpError   (unsigned errNum, Ident    name, TypDef typ1,
  1801.                                                                     TypDef typ2);
  1802.     void                cmpError   (unsigned errNum, Ident    name, SymDef sym1,
  1803.                                                                     SymDef sym2);
  1804.     void                cmpError   (unsigned errNum, Ident    nam1, Ident  nam2,
  1805.                                                                     Ident  nam3);
  1806.     void                cmpError   (unsigned errNum, SymDef    sym, Ident  name);
  1807.     void                cmpError   (unsigned errNum, SymDef    sym, QualName qual,
  1808.                                                                     TypDef type);
  1809.     void                cmpErrorXtp(unsigned errNum, SymDef    sym, Tree   args);
  1810.     void                cmpErrorQnm(unsigned errNum, SymDef    sym);
  1811.     void                cmpErrorQSS(unsigned errNum, SymDef    sm1, SymDef sym2);
  1812.     void                cmpErrorQSS(unsigned errNum, SymDef    sym, TypDef type);
  1813.     void                cmpErrorAtp(unsigned errNum, SymDef    sym, Ident  name,
  1814.                                                                     TypDef type);
  1815.     void                cmpErrorSST(unsigned errNum, stringBuff str,
  1816.                                                      SymDef    sym,
  1817.                                                      TypDef    typ);
  1818.  
  1819.     void                cmpWarn    (unsigned wrnNum, TypDef   typ1, TypDef typ2);
  1820.     void                cmpWarn    (unsigned wrnNum, QualName name);
  1821.     void                cmpWarn    (unsigned wrnNum, TypDef   type);
  1822.     void                cmpWarnQnm (unsigned wrnNum, SymDef    sym);
  1823.     void                cmpWarnQns (unsigned wrnNum, SymDef    sym, AnsiStr str);
  1824.     void                cmpWarnNqn (unsigned wrnNum, unsigned  val, SymDef  sym);
  1825.     void                cmpWarnSQS (unsigned wrnNum, SymDef   sym1, SymDef sym2);
  1826.  
  1827.     unsigned            cmpStopErrorMessages();
  1828.     bool                cmpRestErrorMessages(unsigned errcnt = 0);
  1829.  
  1830.     void                cmpModifierError(unsigned err, unsigned mods);
  1831.     void                cmpMemFmod2Error(tokens tok1, tokens tok2);
  1832.  
  1833.     /************************************************************************/
  1834.     /* Members used for handling unmanaged classes                          */
  1835.     /************************************************************************/
  1836.  
  1837. public:
  1838.  
  1839.     SymList             cmpVtableList;      // list of vtables to generate
  1840.     unsigned            cmpVtableCount;
  1841.  
  1842. private:
  1843.  
  1844. #ifdef  DEBUG
  1845.     unsigned            cmpVtableIndex;
  1846. #endif
  1847.  
  1848.     void                cmpGenVtableContents(SymDef      vtabSym);
  1849.  
  1850.     memBuffPtr          cmpGenVtableSection (SymDef     innerSym,
  1851.                                              SymDef     outerSym,
  1852.                                              memBuffPtr dest);
  1853.  
  1854.     /************************************************************************/
  1855.     /* Members used for handling value types                                */
  1856.     /************************************************************************/
  1857.  
  1858.     void                cmpInitStdValTypes();
  1859.  
  1860.     Ident               cmpStdValueIdens[TYP_lastIntrins];
  1861.     TypDef              cmpStdValueTypes[TYP_lastIntrins];
  1862.  
  1863. public:
  1864.  
  1865.     var_types           cmpFindStdValType(TypDef    typ);
  1866.     TypDef              cmpFindStdValType(var_types vtp);
  1867.  
  1868.     TypDef              cmpCheck4valType(TypDef type);
  1869.  
  1870.     /************************************************************************/
  1871.     /* Members used to bind expressions                                     */
  1872.     /************************************************************************/
  1873.  
  1874.     SymDef              cmpThisSym;
  1875.     Tree                cmpThisRef();
  1876.     Tree                cmpThisRefOK();
  1877.  
  1878. private:
  1879.  
  1880.     Tree                cmpAllocExprRaw  (Tree          expr,
  1881.                                           treeOps       oper);
  1882.  
  1883.     Tree                cmpCreateExprNode(Tree          expr,
  1884.                                           treeOps       oper,
  1885.                                           TypDef        type);
  1886.     Tree                cmpCreateExprNode(Tree          expr,
  1887.                                           treeOps       oper,
  1888.                                           TypDef        type,
  1889.                                           Tree          op1,
  1890.                                           Tree          op2 = NULL);
  1891.  
  1892.     Tree                cmpCreateIconNode(Tree          expr,
  1893.                                           __int32       val,
  1894.                                           var_types     typ);
  1895.     Tree                cmpCreateLconNode(Tree          expr,
  1896.                                           __int64       val,
  1897.                                           var_types     typ);
  1898.     Tree                cmpCreateFconNode(Tree          expr,
  1899.                                           float         val);
  1900.     Tree                cmpCreateDconNode(Tree          expr,
  1901.                                           double        val);
  1902.     Tree                cmpCreateSconNode(stringBuff    str,
  1903.                                           size_t        len,
  1904.                                           unsigned      wide,
  1905.                                           TypDef        type);
  1906.     Tree                cmpCreateErrNode (unsigned      errn = 0);
  1907.     Tree                cmpCreateVarNode (Tree          expr,
  1908.                                           SymDef        sym);
  1909.  
  1910.     Tree                cmpAppend2argList(Tree          args,
  1911.                                           Tree          addx);
  1912.  
  1913.     /*----------------------------------------------------------------------*/
  1914.  
  1915.     void                cmpRecErrorPos   (Tree          expr);
  1916.  
  1917.     bool                cmpExprIsErr     (Tree          expr);
  1918.  
  1919.     /*----------------------------------------------------------------------*/
  1920.  
  1921.     Tree                cmpFoldIntUnop   (Tree          args);
  1922.     Tree                cmpFoldLngUnop   (Tree          args);
  1923.     Tree                cmpFoldFltUnop   (Tree          args);
  1924.     Tree                cmpFoldDblUnop   (Tree          args);
  1925.  
  1926.     Tree                cmpFoldIntBinop  (Tree          args);
  1927.     Tree                cmpFoldLngBinop  (Tree          args);
  1928.     Tree                cmpFoldFltBinop  (Tree          args);
  1929.     Tree                cmpFoldDblBinop  (Tree          args);
  1930.     Tree                cmpFoldStrBinop  (Tree          args);
  1931.  
  1932.     /*----------------------------------------------------------------------*/
  1933.  
  1934.     Tree                cmpShrinkExpr    (Tree          expr);
  1935.     Tree                cmpCastOfExpr    (Tree          expr,
  1936.                                           TypDef        type,
  1937.                                           bool          explicitCast);
  1938.     var_types           cmpConstSize     (Tree          expr,
  1939.                                           var_types     vtp);
  1940.  
  1941.     bool                cmpCheckException(TypDef        type);
  1942.  
  1943. public:
  1944.     bool                cmpCheckAccess   (SymDef        sym);
  1945.  
  1946. private:
  1947.     bool                cmpCheckAccessNP (SymDef        sym);
  1948.  
  1949.     bool                cmpCheckLvalue   (Tree          expr,
  1950.                                           bool          addr,
  1951.                                           bool          noErr = false);
  1952.  
  1953.     Tree                cmpCheckFuncCall (Tree          call);
  1954.  
  1955.     bool                cmpConvergeValues(INOUT Tree REF op1,
  1956.                                           INOUT Tree REF op2);
  1957.  
  1958.     Tree                cmpRefMemberVar  (Tree          expr,
  1959.                                           SymDef        sym,
  1960.                                           Tree          objPtr = NULL);
  1961.  
  1962.     TypDef              cmpMergeFncType  (SymDef        fncSym,
  1963.                                           TypDef        type);
  1964.  
  1965.     SymDef              cmpFindOvlMatch  (SymDef        fncSym,
  1966.                                           Tree          args,
  1967.                                           Tree          thisArg);
  1968.  
  1969.     bool                cmpMakeRawStrLit (Tree          expr,
  1970.                                           TypDef        type,
  1971.                                           bool          chkOnly    = false);
  1972.     bool                cmpMakeRawString (Tree          expr,
  1973.                                           TypDef        type,
  1974.                                           bool          chkOnly    = false);
  1975.  
  1976.     int                 cmpConversionCost(Tree          srcExpr,
  1977.                                           TypDef        dstType,
  1978.                                           bool          noUserConv = false);
  1979.  
  1980.     /*----------------------------------------------------------------------*/
  1981.  
  1982.     SymDef              cmpSymbolNS      (SymDef        sym);
  1983.     SymDef              cmpSymbolOwner   (SymDef        sym);
  1984.  
  1985.     TypDef              cmpGetActualTP   (TypDef        type);
  1986.  
  1987. public:
  1988.  
  1989.     TypDef              cmpActualType    (TypDef        type);
  1990.     TypDef              cmpDirectType    (TypDef        type);
  1991.  
  1992.     var_types           cmpActualVtyp    (TypDef        type);
  1993.     var_types           cmpDirectVtyp    (TypDef        type);
  1994.  
  1995.     static
  1996.     var_types           cmpEnumBaseVtp   (TypDef        type);
  1997.  
  1998.     /*----------------------------------------------------------------------*/
  1999.  
  2000. public:
  2001.  
  2002.     bool                cmpIsManagedAddr (Tree          expr);
  2003.  
  2004.     /*----------------------------------------------------------------------*/
  2005.  
  2006. private:
  2007.  
  2008.     ExtList             cmpTempMLfree;
  2009.  
  2010.     ExtList             cmpTempMLappend  (ExtList       list,
  2011.                                           ExtList     * lastPtr,
  2012.                                           SymDef        sym,
  2013.                                           SymDef        comp,
  2014.                                           UseList       uses,
  2015.                                           scanPosTP     dclFpos,
  2016.                                           unsigned      dclLine);
  2017.  
  2018.     void                cmpTempMLrelease (ExtList       entry);
  2019.  
  2020.     /*----------------------------------------------------------------------*/
  2021.  
  2022. #ifndef NDEBUG
  2023.  
  2024.     void                cmpChk4ctxChange (TypDef        type1,
  2025.                                           TypDef        type2,
  2026.                                           unsigned      flags);
  2027.  
  2028. #endif
  2029.  
  2030.     bool                cmpDiffContext   (TypDef        cls1,
  2031.                                           TypDef        cls2);
  2032.  
  2033. private:
  2034.     Tree                cmpDecayArray    (Tree          expr);
  2035. public:
  2036.     Tree                cmpDecayCheck    (Tree          expr);
  2037.  
  2038.     TypDef              cmpGetRefBase    (TypDef        reftyp);
  2039.  
  2040.     var_types           cmpSymbolVtyp    (SymDef        sym);
  2041.  
  2042.     /*----------------------------------------------------------------------*/
  2043.  
  2044. private:
  2045.  
  2046.     size_t              cmpStoreMDlen    (size_t            len,
  2047.                                           BYTE  *           dest = NULL);
  2048.  
  2049. public:
  2050.  
  2051.     SymDef              cmpBindAttribute (SymDef            clsSym,
  2052.                                           Tree              argList,
  2053.                                           unsigned          tgtMask,
  2054.                                       OUT unsigned    REF   useMask,
  2055.                                       OUT genericBuff REF   blobAddr,
  2056.                                       OUT size_t      REF   blobSize);
  2057.  
  2058.     /*----------------------------------------------------------------------*/
  2059.  
  2060.     void                cmpDeclDefCtor   (SymDef        clsSym);
  2061.  
  2062. private:
  2063.  
  2064.     SymDef              cmpFindCtor      (TypDef        clsTyp,
  2065.                                           bool          chkArgs,
  2066.                                           Tree          args = NULL);
  2067.  
  2068.     Tree                cmpCallCtor      (TypDef        type,
  2069.                                           Tree          args);
  2070.  
  2071. public:
  2072.  
  2073.     Tree                cmpBindCondition (Tree          cond);
  2074.     int                 cmpEvalCondition (Tree          cond);
  2075.  
  2076.     ConstStr            cmpSaveStringCns (const  char * str,
  2077.                                           size_t        len);
  2078.     ConstStr            cmpSaveStringCns (const wchar * str,
  2079.                                           size_t        len);
  2080.  
  2081. private:
  2082.  
  2083.     Tree                cmpBindVarArgUse (Tree          call);
  2084.  
  2085.     SymDef              cmpBindQualName  (QualName      name,
  2086.                                           bool          notLast);
  2087.  
  2088.     bool                cmpParseConstDecl(SymDef        varSym,
  2089.                                           Tree          init  = NULL,
  2090.                                           Tree        * ncPtr = NULL);
  2091.  
  2092.     Tree                cmpBooleanize    (Tree          expr,
  2093.                                           bool          sense);
  2094.  
  2095.     Tree                cmpFetchConstVal (ConstVal      cval,
  2096.                                           Tree          expr = NULL);
  2097.  
  2098.     SymDef              cmpFindPropertyDM(SymDef        accSym,
  2099.                                           bool        * isSetPtr);
  2100.  
  2101.     SymDef              cmpFindPropertyFN(SymDef        clsSym,
  2102.                                           Ident         propName,
  2103.                                           Tree          args,
  2104.                                           bool          getter,
  2105.                                           bool        * found);
  2106.  
  2107. public:
  2108.     Ident               cmpPropertyName  (Ident         name,
  2109.                                           bool          getter);
  2110.  
  2111. private:
  2112.     Tree                cmpBindProperty  (Tree          expr,
  2113.                                           Tree          args,
  2114.                                           Tree          asgx);
  2115.  
  2116.     Tree                cmpScaleIndex    (Tree          expr,
  2117.                                           TypDef        type,
  2118.                                           treeOps       oper);
  2119.  
  2120.     Tree                cmpBindArrayExpr (TypDef        type,
  2121.                                           int           dimPos = 0,
  2122.                                           unsigned      elems  = 0);
  2123.  
  2124.     Tree                cmpBindArrayBnd  (Tree          expr);
  2125.     void                cmpBindArrayType (TypDef        type,
  2126.                                           bool          needDef,
  2127.                                           bool          needDim,
  2128.                                           bool          mustDim);
  2129.  
  2130. public:
  2131.  
  2132.     TypDef              cmpBindExprType  (Tree          expr);
  2133.  
  2134.     void                cmpBindType      (TypDef        type,
  2135.                                           bool          needDef,
  2136.                                           bool          needDim);
  2137.  
  2138.     bool                cmpIsStringExpr  (Tree          expr);
  2139.  
  2140. private:
  2141.  
  2142.     Tree                cmpBindQmarkExpr (Tree          expr);
  2143.  
  2144.     Tree                bindSLVinit      (TypDef        type,
  2145.                                           Tree          init);
  2146.  
  2147.     Tree                cmpBindNewExpr   (Tree          expr);
  2148.  
  2149.     Tree                cmpAdd2Concat    (Tree          expr,
  2150.                                           Tree          list,
  2151.                                           Tree        * lastPtr);
  2152.     Tree                cmpListConcat    (Tree          expr);
  2153.     Tree                cmpBindConcat    (Tree          expr);
  2154.  
  2155.     Tree                cmpBindCall      (Tree          tree);
  2156.  
  2157.     Tree                cmpBindNameUse   (Tree          tree,
  2158.                                           bool          isCall,
  2159.                                           bool          classOK);
  2160.  
  2161.     Tree                cmpBindName      (Tree          tree,
  2162.                                           bool          isCall,
  2163.                                           bool          classOK);
  2164.  
  2165.     Tree                cmpRefAnUnionMem (Tree          expr);
  2166.  
  2167.     Tree                cmpBindDotArr    (Tree          tree,
  2168.                                           bool          isCall,
  2169.                                           bool          classOK);
  2170.  
  2171.     Tree                cmpBindThisRef   (SymDef        sym);
  2172.  
  2173.     Tree                cmpBindAssignment(Tree          dstx,
  2174.                                           Tree          srcx,
  2175.                                           Tree          tree,
  2176.                                           treeOps       oper = TN_ASG);
  2177.  
  2178.     Tree                cmpCompOperArg1;
  2179.     Tree                cmpCompOperArg2;
  2180.     Tree                cmpCompOperFnc1;
  2181.     Tree                cmpCompOperFnc2;
  2182.     Tree                cmpCompOperFunc;
  2183.     Tree                cmpCompOperCall;
  2184.  
  2185.     Tree                cmpCompareValues (Tree          expr,
  2186.                                           Tree          op1,
  2187.                                           Tree          op2);
  2188.  
  2189.     Tree                cmpConvOperExpr;
  2190.  
  2191.     unsigned            cmpMeasureConv   (Tree          srcExpr,
  2192.                                           TypDef        dstType,
  2193.                                           unsigned      lowCost,
  2194.                                           SymDef        convSym,
  2195.                                           SymDef      * bestCnv1,
  2196.                                           SymDef      * bestCnv2);
  2197.  
  2198.     Tree                cmpCheckOvlOper  (Tree          expr);
  2199.  
  2200.     Tree                cmpCheckConvOper (Tree          expr,
  2201.                                           TypDef        srcTyp,
  2202.                                           TypDef        dstTyp,
  2203.                                           bool          expConv,
  2204.                                           unsigned    * costPtr = NULL);
  2205.  
  2206.     Tree                cmpUnboxExpr     (Tree          expr,
  2207.                                           TypDef        type);
  2208.  
  2209.     Tree                cmpBindExprRec   (Tree          expr);
  2210.  
  2211. public:
  2212.  
  2213.     Tree                cmpCoerceExpr    (Tree          expr,
  2214.                                           TypDef        type, bool explicitCast);
  2215.  
  2216.     Tree                cmpBindExpr      (Tree          expr);
  2217.  
  2218.     Tree                cmpFoldExpression(Tree          expr);
  2219.  
  2220.     /************************************************************************/
  2221.     /* Members used for generating IL                                       */
  2222.     /************************************************************************/
  2223.  
  2224.     GenILref            cmpILgen;
  2225.  
  2226.     stmtNestRec         cmpStmtLast;
  2227.     StmtNest            cmpStmtNest;
  2228.  
  2229.     SymDef              cmpFilterObj;
  2230.  
  2231.     bool                cmpBaseCTisOK;
  2232.     bool                cmpBaseCTcall;
  2233.     bool                cmpThisCTcall;
  2234.  
  2235.     SymDef              cmpTempVarMake   (TypDef        type);
  2236.     void                cmpTempVarDone   (SymDef        tsym);
  2237.  
  2238.     void                cmpStmtDo        (Tree          stmt,
  2239.                                           SymDef        lsym = NULL);
  2240.     void                cmpStmtFor       (Tree          stmt,
  2241.                                           SymDef        lsym = NULL);
  2242.     void                cmpStmtTry       (Tree          stmt,
  2243.                                           Tree          pref = NULL);
  2244.     void                cmpStmtExcl      (Tree          stmt);
  2245.     void                cmpStmtWhile     (Tree          stmt,
  2246.                                           SymDef        lsym = NULL);
  2247.     void                cmpStmtSwitch    (Tree          stmt,
  2248.                                           SymDef        lsym = NULL);
  2249.  
  2250.     void                cmpStmt          (Tree          stmt);
  2251.  
  2252. #ifndef NDEBUG
  2253.     bool                cmpDidCTinits;
  2254. #endif
  2255.     void                cmpAddCTinits    ();
  2256.  
  2257.     SymDef              cmpBlockDecl     (Tree          blockDcl,
  2258.                                           bool          outer,
  2259.                                           bool          genDecl,
  2260.                                           bool          isCatch);
  2261.     SymDef              cmpBlock         (Tree          block,
  2262.                                           bool          outer);
  2263.  
  2264.     SymDef              cmpGenFNbodyBeg  (SymDef        fncSym,
  2265.                                           Tree          body,
  2266.                                           bool          hadGoto,
  2267.                                           unsigned      lclVarCnt);
  2268.     void                cmpGenFNbodyEnd();
  2269.  
  2270. #ifdef  OLD_IL
  2271.     GenOILref           cmpOIgen;
  2272. #endif
  2273.  
  2274.     /************************************************************************/
  2275.     /* Members used for metadata output                                     */
  2276.     /************************************************************************/
  2277.  
  2278. public:
  2279.  
  2280.     WMetaDataDispenser *cmpWmdd;
  2281.     WMetaDataEmit      *cmpWmde;
  2282.     WAssemblyEmit      *cmpWase;
  2283.  
  2284. private:
  2285.  
  2286.     mdAssembly          cmpCurAssemblyTok;
  2287.  
  2288.     mdTypeRef           cmpLinkageClass;        // fake class for entry points
  2289.  
  2290. #ifdef  DEBUG
  2291.     unsigned            cmpGenLocalSigLvx;
  2292. #endif
  2293.  
  2294.     void                cmpSecurityMD    (mdToken       token,
  2295.                                           SymXinfo      infoList);
  2296.  
  2297.     void                cmpGenLocalSigRec(SymDef        scope);
  2298.  
  2299.     wchar   *           cmpGenMDname     (SymDef        sym,
  2300.                                           bool          full,
  2301.                                           wchar  *      buffAddr,
  2302.                                           size_t        buffSize,
  2303.                                           wchar  *    * buffHeapPtr);
  2304.  
  2305.     SymDef              cmpTypeDefList;
  2306.     SymDef              cmpTypeDefLast;
  2307.  
  2308.     void                cmpGenTypMetadata(SymDef        sym);
  2309.     void                cmpGenGlbMetadata(SymDef        sym);
  2310.     void                cmpGenMemMetadata(SymDef        sym);
  2311.  
  2312.     wchar   *           cmpArrayClsPref  (SymDef        sym,
  2313.                                           wchar *       dest,
  2314.                                           int           delim,
  2315.                                           bool          fullPath = false);
  2316.     wchar   *           cmpArrayClsName  (TypDef        type,
  2317.                                           bool          nonAbstract,
  2318.                                           wchar *       dest,
  2319.                                           wchar *       nptr);
  2320.  
  2321.     Tree                cmpFakeXargsVal;
  2322.  
  2323.     void                cmpAddCustomAttrs(SymXinfo      infoList,
  2324.                                           mdToken       owner);
  2325.  
  2326.     void                cmpSetGlobMDoffsR(SymDef        scope,
  2327.                                           unsigned      dataOffs);
  2328.  
  2329. public:
  2330.  
  2331.     void                cmpSetGlobMDoffs (unsigned      dataOffs);
  2332.  
  2333.     mdToken             cmpMDstringLit   (wchar *       str,
  2334.                                           size_t        len);
  2335.  
  2336.     TypDef              cmpGetBaseArray  (TypDef        type);
  2337.  
  2338.     mdToken             cmpArrayEAtoken  (TypDef        arrType,
  2339.                                           unsigned      dimCnt,
  2340.                                           bool          store,
  2341.                                           bool          addr = false);
  2342.  
  2343.     mdToken             cmpArrayCTtoken  (TypDef         arrType,
  2344.                                           TypDef        elemType,
  2345.                                           unsigned      dimCnt);
  2346.  
  2347.     mdToken             cmpArrayTpToken  (TypDef        type,
  2348.                                           bool          nonAbstract = false);
  2349.  
  2350.     mdToken             cmpPtrTypeToken  (TypDef        type);
  2351.  
  2352.     mdToken             cmpClsEnumToken  (TypDef        type);
  2353.  
  2354.     PCOR_SIGNATURE      cmpTypeSig       (TypDef        type,
  2355.                                           size_t      * lenPtr);
  2356.     mdSignature         cmpGenLocalSig   (SymDef        scope,
  2357.                                           unsigned      count);
  2358.     void                cmpGenMarshalInfo(mdToken       token,
  2359.                                           TypDef        type,
  2360.                                           MarshalInfo   info);
  2361.     PCOR_SIGNATURE      cmpGenMarshalSig (TypDef        type,
  2362.                                           MarshalInfo   info,
  2363.                                           size_t      * lenPtr);
  2364.     PCOR_SIGNATURE      cmpGenMemberSig  (SymDef        memSym,
  2365.                                           Tree          xargs,
  2366.                                           TypDef        memTyp,
  2367.                                           TypDef        prefTp,
  2368.                                           size_t      * lenPtr);
  2369.     void                cmpGenFldMetadata(SymDef        fldSym);
  2370.     mdSignature         cmpGenSigMetadata(TypDef        fncTyp,
  2371.                                           TypDef        pref  = NULL);
  2372.     mdToken             cmpGenFncMetadata(SymDef        fncSym,
  2373.                                           Tree          xargs = NULL);
  2374.     mdToken             cmpGenClsMetadata(SymDef        clsSym,
  2375.                                           bool          extref = false);
  2376.  
  2377.     void                cmpFixupScopes   (SymDef        scope);
  2378.  
  2379.     void                cmpAttachMDattr  (mdToken       target,
  2380.                                           wideStr       oldName,
  2381.                                           AnsiStr       newName,
  2382.                                           mdToken     * newTokPtr,
  2383.                                           unsigned      valTyp = 0,
  2384.                                           const void  * valPtr = NULL,
  2385.                                           size_t        valSiz = 0);
  2386. private:
  2387.  
  2388.     // temp hack: fixed table of assembly tokens
  2389.  
  2390.     unsigned            cmpAssemblyRefCnt;
  2391.  
  2392.     mdAssembly          cmpAssemblyRefTab[32];
  2393.     mdAssemblyRef       cmpAssemblyRefTok[32];
  2394.     WAssemblyImport *   cmpAssemblyRefImp[32];
  2395.     BYTE *              cmpAssemblyRefXXX[32];          // temp hack!!!!!
  2396.  
  2397.     unsigned            cmpAssemblyBCLx;
  2398.  
  2399. public:
  2400.  
  2401.     void                cmpAssemblyTkBCL(unsigned assx)
  2402.     {
  2403.         cmpAssemblyBCLx = assx;
  2404.     }
  2405.  
  2406.     bool                cmpAssemblyIsBCL(unsigned assx)
  2407.     {
  2408.         assert(assx && assx <= cmpAssemblyRefCnt);
  2409.  
  2410.         return  (assx == cmpAssemblyBCLx);
  2411.     }
  2412.  
  2413.     mdComType           cmpAssemblySymDef(SymDef sym, mdTypeDef defTok = 0);
  2414.     mdAssemblyRef       cmpAssemblyAddRef(mdAssembly ass, WAssemblyImport *imp);
  2415.  
  2416.     unsigned            cmpAssemblyRefAdd(mdAssembly ass, WAssemblyImport *imp, BYTE *cookie = NULL)
  2417.     {
  2418.         assert(cmpAssemblyRefCnt < arraylen(cmpAssemblyRefTab));
  2419.  
  2420.         cmpAssemblyRefTab[cmpAssemblyRefCnt] = ass;
  2421.         cmpAssemblyRefImp[cmpAssemblyRefCnt] = imp;
  2422.         cmpAssemblyRefXXX[cmpAssemblyRefCnt] = cookie;  // temp hack!!!!!
  2423.  
  2424.         return  ++cmpAssemblyRefCnt;
  2425.     }
  2426.  
  2427.     mdAssemblyRef       cmpAssemblyRefRec(unsigned assx)
  2428.     {
  2429.         assert(assx && assx <= cmpAssemblyRefCnt);
  2430.  
  2431.         assx--;
  2432.  
  2433.         assert(cmpAssemblyRefTab[assx]);
  2434.  
  2435.         if  (cmpAssemblyRefTok[assx] == 0)
  2436.              cmpAssemblyRefTok[assx] = cmpAssemblyAddRef(cmpAssemblyRefTab[assx],
  2437.                                                          cmpAssemblyRefImp[assx]);
  2438.  
  2439.         return  cmpAssemblyRefTok[assx];
  2440.     }
  2441.  
  2442.     WAssemblyImport *   cmpAssemblyGetImp(unsigned assx)
  2443.     {
  2444.         assert(assx && assx <= cmpAssemblyRefCnt);
  2445.  
  2446.         assert(cmpAssemblyRefTab[assx-1]);
  2447.  
  2448.         return cmpAssemblyRefImp[assx-1];
  2449.     }
  2450.  
  2451.     mdToken             cmpAssemblyAddFile(wideStr  fileName,
  2452.                                            bool     doHash,
  2453.                                            unsigned flags = 0);
  2454.  
  2455.     void                cmpAssemblyAddType(wideStr  typeName,
  2456.                                            mdToken  defTok,
  2457.                                            mdToken  scpTok,
  2458.                                            unsigned flags);
  2459.  
  2460.     void                cmpAssemblyAddRsrc(AnsiStr  fileName,
  2461.                                            bool     internal);
  2462.  
  2463.     void                cmpAssemblyNonCLS();
  2464.  
  2465.     /************************************************************************/
  2466.     /* Members used for conversion to Unicode                               */
  2467.     /************************************************************************/
  2468.  
  2469. public:
  2470.  
  2471.     wchar               cmpUniConvBuff[MAX_INLINE_NAME_LEN+1];
  2472.  
  2473.     size_t              cmpUniConvSize;
  2474.     wchar   *           cmpUniConvAddr;
  2475.  
  2476.     void                cmpUniConvInit()
  2477.     {
  2478.         cmpUniConvAddr = cmpUniConvBuff;
  2479.         cmpUniConvSize = MAX_INLINE_NAME_LEN;
  2480.     }
  2481.  
  2482. #if MGDDATA
  2483.     String              cmpUniConv(char managed [] str, size_t len);
  2484. #endif
  2485.     wideString          cmpUniConv(const char *    str, size_t len);
  2486.     wideString          cmpUniCnvW(const char *    str, size_t*lenPtr);
  2487.  
  2488.     wideString          cmpUniConv(Ident name)
  2489.     {
  2490.         return          cmpUniConv(name->idSpelling(), name->idSpellLen());
  2491.     }
  2492.  
  2493.     /************************************************************************/
  2494.     /* Members used to create metadata signatures                           */
  2495.     /************************************************************************/
  2496.  
  2497. private:
  2498.  
  2499.     char                cmpMDsigBuff[256];                  // default buffer
  2500.  
  2501.     size_t              cmpMDsigSize;                       // size of current buff
  2502.     char    *           cmpMDsigHeap;                       // non-NULL if on heap
  2503.  
  2504. #ifndef NDEBUG
  2505.     bool                cmpMDsigUsed;                       // to detect recursion
  2506. #endif
  2507.  
  2508.     char    *           cmpMDsigBase;                       // buffer start addr
  2509.     char    *           cmpMDsigNext;                       // next byte to store
  2510.     char    *           cmpMDsigEndp;                       // buffer end addr
  2511.  
  2512.     void                cmpMDsigExpand(size_t size);
  2513.  
  2514. public:
  2515.  
  2516.     void                cmpMDsigInit()
  2517.     {
  2518.         cmpMDsigBase = cmpMDsigBuff;
  2519.         cmpMDsigEndp = cmpMDsigBase + sizeof(cmpMDsigBuff);
  2520.         cmpMDsigSize = sizeof(cmpMDsigBuff) - 4;
  2521. #ifndef NDEBUG
  2522.         cmpMDsigUsed = false;
  2523. #endif
  2524.         cmpMDsigHeap = NULL;
  2525.     }
  2526.  
  2527.     void                cmpMDsigStart ();
  2528.     PCOR_SIGNATURE      cmpMDsigEnd   (size_t     *sizePtr);
  2529.  
  2530.     void                cmpMDsigAddStr(const char *str, size_t len);
  2531.     void                cmpMDsigAddStr(const char *str)
  2532.     {
  2533.                         cmpMDsigAddStr(str, strlen(str)+1);
  2534.     }
  2535.  
  2536.     void                cmpMDsigAdd_I1(int         val);    // fixed-size  8-bit int
  2537.     void                cmpMDsigAddCU4(unsigned    val);    // compressed unsigned
  2538.     void                cmpMDsigAddTok(mdToken     tok);    // compressed token
  2539.  
  2540.     void                cmpMDsigAddTyp(TypDef      type);
  2541.  
  2542.     /************************************************************************/
  2543.     /* Metadata import stuff                                                */
  2544.     /************************************************************************/
  2545.  
  2546.     MetaDataImp         cmpMDlist;
  2547.     MetaDataImp         cmpMDlast;
  2548.     unsigned            cmpMDcount;
  2549.  
  2550.     void                cmpInitMD();
  2551.  
  2552.     void                cmpInitMDimp ();
  2553.     void                cmpDoneMDimp ();
  2554.  
  2555.     void                cmpInitMDemit();
  2556.     void                cmpDoneMDemit();
  2557.  
  2558.     MetaDataImp         cmpAddMDentry();
  2559.  
  2560.     IMetaDataImport   * cmpFindImporter(SymDef globSym);
  2561.  
  2562.     void                cmpImportMDfile(const char *fname   = NULL,
  2563.                                         bool        asmOnly = false,
  2564.                                         bool        isBCL   = false);
  2565.  
  2566. private:
  2567.     void                cmpFindMDimpAPIs(SymDef                   typSym,
  2568.                                          IMetaDataImport        **imdiPtr,
  2569.                                          IMetaDataAssemblyEmit  **iasePtr,
  2570.                                          IMetaDataAssemblyImport**iasiPtr);
  2571. public:
  2572.  
  2573.     void                cmpMakeMDimpTref(SymDef clsSym);
  2574.     void                cmpMakeMDimpFref(SymDef fncSym);
  2575.     void                cmpMakeMDimpDref(SymDef fldSym);
  2576.     void                cmpMakeMDimpEref(SymDef etpSym);
  2577.  
  2578.     /************************************************************************/
  2579.     /* Metadata debug output                                                */
  2580.     /************************************************************************/
  2581.  
  2582.     unsigned            cmpCurFncSrcBeg;
  2583.     unsigned            cmpCurFncSrcEnd;
  2584.  
  2585.     WSymWriter         *cmpSymWriter;
  2586.  
  2587.     void               *cmpSrcFileDocument(SymDef srcSym);
  2588.  
  2589.     /************************************************************************/
  2590.     /* Generic utility vector deal to convert pointer to small indices      */
  2591.     /************************************************************************/
  2592.  
  2593. private:
  2594.  
  2595. #if MGDDATA
  2596.     VecEntryDsc []      cmpVecTable;
  2597. #else
  2598.     VecEntryDsc *       cmpVecTable;
  2599. #endif
  2600.  
  2601.     unsigned            cmpVecCount;        // number of items stored
  2602.     unsigned            cmpVecAlloc;        // size currently allocated
  2603.  
  2604.     void                cmpVecExpand();
  2605.  
  2606. public:
  2607.  
  2608.     unsigned            cmpAddVecEntry(const void * val, vecEntryKinds kind)
  2609.     {
  2610.         assert(val != NULL);
  2611.  
  2612.         if  (cmpVecCount >= cmpVecAlloc)
  2613.             cmpVecExpand();
  2614.  
  2615.         assert(cmpVecCount < cmpVecAlloc);
  2616.  
  2617. #ifdef  DEBUG
  2618.         cmpVecTable[cmpVecCount].vecKind  = kind;
  2619. #endif
  2620.         cmpVecTable[cmpVecCount].vecValue = val;
  2621.  
  2622.         return  ++cmpVecCount;
  2623.     }
  2624.  
  2625.     const   void *      cmpGetVecEntry(unsigned x, vecEntryKinds kind)
  2626.     {
  2627.         assert(x && x <= cmpVecCount);
  2628.  
  2629.         assert(cmpVecTable[x - 1].vecKind == kind);
  2630.         return cmpVecTable[x - 1].vecValue;
  2631.     }
  2632.  
  2633. //  bool                cmpDelVecEntry(unsigned x, vecEntryKinds kind);
  2634.  
  2635.     /************************************************************************/
  2636.     /* Miscellaneous members                                                */
  2637.     /************************************************************************/
  2638.  
  2639.     bool                cmpEvalPreprocCond();
  2640.  
  2641. #ifdef DEBUG
  2642.     void                cmpDumpSymbolTable();
  2643. #endif
  2644.  
  2645.     bool                cmpParserInit;       // has the parser been initialized?
  2646. };
  2647.  
  2648. /*****************************************************************************
  2649.  *
  2650.  *  For easier debugging of the compiler itself. NOTE: This is not thread-safe!
  2651.  */
  2652.  
  2653. #ifdef  DEBUG
  2654. #ifndef __SMC__
  2655. extern  Compiler        TheCompiler;
  2656. extern  Scanner         TheScanner;
  2657. #endif
  2658. #endif
  2659.  
  2660. /*****************************************************************************
  2661.  *
  2662.  *  The following is used to temporarily disable error messages.
  2663.  */
  2664.  
  2665. inline
  2666. unsigned                compiler::cmpStopErrorMessages()
  2667. {
  2668.     cmpErrorMssgDisabled++;
  2669.     return  cmpMssgsCount;
  2670. }
  2671.  
  2672. inline
  2673. bool                    compiler::cmpRestErrorMessages(unsigned errcnt)
  2674. {
  2675.     cmpErrorMssgDisabled--;
  2676.     return  cmpMssgsCount > errcnt;
  2677. }
  2678.  
  2679. /*****************************************************************************
  2680.  *
  2681.  *  In non-debug mode the following function doesn't need to do any work.
  2682.  */
  2683.  
  2684. #ifndef DEBUG
  2685. inline  void            compiler::cmpInitVarEnd(SymDef varSym){}
  2686. #endif
  2687.  
  2688. /*****************************************************************************/
  2689.  
  2690. #include "symbol.h"
  2691. #include "type.h"
  2692.  
  2693. /*****************************************************************************/
  2694.  
  2695. inline
  2696. void    *           SMCgetMem(Compiler comp, size_t size)
  2697. {
  2698.     return  comp->cmpAllocTemp.baAlloc      (size);
  2699. }
  2700.  
  2701. inline
  2702. void    *           SMCgetM_0(Compiler comp, size_t size)
  2703. {
  2704.     return  comp->cmpAllocTemp.baAllocOrNull(size);
  2705. }
  2706.  
  2707. inline
  2708. void                SMCrlsMem(Compiler comp, void *block)
  2709. {
  2710.             comp->cmpAllocTemp.baFree(block);
  2711. }
  2712.  
  2713. /*****************************************************************************
  2714.  *
  2715.  *  Each symbol table manages its own names and symbol/type entries.
  2716.  */
  2717.  
  2718. DEFMGMT
  2719. class symTab
  2720. {
  2721.     Compiler            stComp;
  2722.     unsigned            stOwner;
  2723.  
  2724. public:
  2725.     HashTab             stHash;
  2726.  
  2727.     norls_allocator *   stAllocPerm;        // used for all  non-local allocs
  2728.  
  2729. private:
  2730.     norls_allocator *   stAllocTemp;        // used for function-local allocs
  2731.  
  2732. public:
  2733.  
  2734.     void                stInit(Compiler             comp,
  2735.                                norls_allocator    * alloc,
  2736.                                HashTab              hash   = NULL,
  2737.                                unsigned             ownerx = 0);
  2738.  
  2739.     /************************************************************************/
  2740.     /* Members used to manage symbol entries                                */
  2741.     /************************************************************************/
  2742.  
  2743.     DefList             stRecordSymSrcDef(SymDef    sym,
  2744.                                           SymDef    st,
  2745.                                           UseList   uses, scanPosTP dclFpos,
  2746. //                                                        scanPosTP dclEpos,
  2747.                                                           unsigned  dclLine,
  2748. //                                                        unsigned  dclCol,
  2749.                                           bool      ext = false);
  2750.  
  2751.     ExtList             stRecordMemSrcDef(Ident     name,
  2752.                                           QualName  qual,
  2753.                                           SymDef    comp,
  2754.                                           UseList   uses, scanPosTP dclFpos,
  2755. //                                                        scanPosTP dclEpos,
  2756.                                                           unsigned  dclLine);
  2757.  
  2758.     /*-------------------------------------------------------------------*/
  2759.  
  2760.     TypDef              stDlgSignature(TypDef       dlgTyp);
  2761.  
  2762.     /*-------------------------------------------------------------------*/
  2763.  
  2764.     ovlOpFlavors        stOvlOperIndex(tokens       token,
  2765.                                        unsigned     argCnt = 0);
  2766.     Ident               stOvlOperIdent(ovlOpFlavors oper);
  2767.  
  2768.     /*-------------------------------------------------------------------*/
  2769.  
  2770.     SymDef              stFindOvlFnc  (SymDef       fsym,
  2771.                                        TypDef       type);
  2772.     SymDef              stFindOvlProp (SymDef       psym,
  2773.                                        TypDef       type);
  2774.  
  2775.     SymDef              stFindSameProp(SymDef       psym,
  2776.                                        TypDef       type);
  2777.  
  2778.     SymDef              stDeclareSym  (Ident        name,
  2779.                                        symbolKinds  kind,
  2780.                                        name_space   nspc,
  2781.                                        SymDef       scope);
  2782.  
  2783.     SymDef              stDeclareOper (ovlOpFlavors oper,
  2784.                                        SymDef       scope);
  2785.  
  2786.     SymDef              stDeclareLab  (Ident        name,
  2787.                                        SymDef       scope, norls_allocator*alloc);
  2788.  
  2789.     SymDef              stDeclareOvl  (SymDef       fsym);
  2790.  
  2791.     SymDef              stDeclareNcs  (Ident        name,
  2792.                                        SymDef       scope,
  2793.                                        str_flavors  flavor);
  2794.  
  2795.     SymDef              stDeclareLcl  (Ident        name,
  2796.                                        symbolKinds  kind,
  2797.                                        name_space   nspc,
  2798.                                        SymDef       scope,
  2799.                                        norls_allocator *alloc);
  2800.  
  2801. #ifdef DEBUG
  2802.  
  2803.     void                stDumpSymDef  (DefSrc       def,
  2804.                                        SymDef       comp);
  2805.  
  2806.     void                stDumpSymbol  (SymDef       sym,
  2807.                                        int          indent,
  2808.                                        bool         recurse,
  2809.                                        bool         members);
  2810.  
  2811.     void                stDumpQualName(QualName     name);
  2812.  
  2813.     void                stDumpUsings  (UseList      uses,
  2814.                                        unsigned     indent);
  2815.  
  2816. #endif
  2817.  
  2818.     SymDef              stSearchUsing (INOUT UseList REF uses,
  2819.                                        Ident             name,
  2820.                                        name_space        nsp);
  2821.  
  2822. private:
  2823.  
  2824.     SymDef              stFindInClass (Ident        name,
  2825.                                        SymDef       scope,
  2826.                                        name_space   symNS);
  2827.  
  2828. public:
  2829.  
  2830.     SymDef              stFindInBase  (SymDef       memSym,
  2831.                                        SymDef       scope);
  2832.  
  2833.     SymDef              stFindBCImem  (SymDef       clsSym,
  2834.                                        Ident        name,
  2835.                                        TypDef       type,
  2836.                                        symbolKinds  kind,
  2837.                                  INOUT SymDef   REF matchFN,
  2838.                                        bool         baseOnly);
  2839.  
  2840.     SymDef              stLookupAllCls(Ident        name,
  2841.                                        SymDef       scope,
  2842.                                        name_space   symNS,
  2843.                                        compileStates state);
  2844.  
  2845.     SymDef              stLookupProp  (Ident        name,
  2846.                                        SymDef       scope);
  2847.  
  2848.     SymDef              stLookupOperND(ovlOpFlavors oper,
  2849.                                        SymDef       scope);
  2850.     SymDef              stLookupOper  (ovlOpFlavors oper,
  2851.                                        SymDef       scope);
  2852.  
  2853.     SymDef              stLookupNspSym(Ident        name,
  2854.                                        name_space   symNS,
  2855.                                        SymDef       scope);
  2856.  
  2857.     SymDef              stLookupClsSym(Ident        name,
  2858.                                        SymDef       scope);
  2859.  
  2860.     SymDef              stLookupScpSym(Ident        name,
  2861.                                        SymDef       scope);
  2862.  
  2863.     SymDef              stLookupLclSym(Ident        name,
  2864.                                        SymDef       scope);
  2865.  
  2866.     SymDef              stLookupSym   (Ident        name,
  2867.                                        name_space   symNS);
  2868.  
  2869.     SymDef              stLookupLabSym(Ident        name,
  2870.                                        SymDef       scope)
  2871.     {
  2872.         return  stLookupNspSym(name, NS_HIDE, scope);
  2873.     }
  2874.  
  2875.     void                stRemoveSym   (SymDef       sym);
  2876.  
  2877.     static
  2878.     SymDef              stNamespOfSym (SymDef       sym)
  2879.     {
  2880.         assert(sym->sdSymKind == SYM_VAR  ||
  2881.                sym->sdSymKind == SYM_FNC  ||
  2882.                sym->sdSymKind == SYM_ENUM ||
  2883.                sym->sdSymKind == SYM_CLASS);
  2884.  
  2885.         do
  2886.         {
  2887.             sym = sym->sdParent; assert(sym);
  2888.         }
  2889.         while (sym->sdSymKind == SYM_CLASS);
  2890.         assert(sym->sdSymKind == SYM_NAMESPACE);
  2891.  
  2892.         return sym;
  2893.     }
  2894.  
  2895.     static
  2896.     SymDef              stErrSymbol;        // to indicate error conditions
  2897.  
  2898.     /************************************************************************/
  2899.     /* Members used to manage type descriptors                              */
  2900.     /************************************************************************/
  2901.  
  2902. public:
  2903.  
  2904.     void                stInitTypes  (unsigned      refHashSz = 512,
  2905.                                       unsigned      arrHashSz = 128);
  2906.  
  2907.     void                stExtArgsBeg (  OUT ArgDscRec REF newArgs,
  2908.                                         OUT ArgDef    REF lastRef,
  2909.                                             ArgDscRec     oldArgs,
  2910.                                             bool          prefix  = false,
  2911.                                             bool          outOnly = false);
  2912.     void                stExtArgsAdd (INOUT ArgDscRec REF newArgs,
  2913.                                       INOUT ArgDef    REF lastArg,
  2914.                                             TypDef        argType,
  2915.                                             const char *  argName = NULL);
  2916.     void                stExtArgsEnd (INOUT ArgDscRec REF newArgs);
  2917.  
  2918.     void                stAddArgList (INOUT ArgDscRec REF args,
  2919.                                       TypDef        type,
  2920.                                       Ident         name);
  2921.  
  2922.     TypList             stAddIntfList(TypDef        type,
  2923.                                       TypList       list,
  2924.                                       TypList *     lastPtr);
  2925.  
  2926.     TypDef              stNewClsType (SymDef        tsym);
  2927.     TypDef              stNewEnumType(SymDef        tsym);
  2928.  
  2929.     TypDef              stNewRefType (var_types     kind,
  2930.                                       TypDef        elem = NULL,
  2931.                                       bool          impl = false);
  2932.  
  2933.     DimDef              stNewDimDesc (unsigned      size);
  2934.     TypDef              stNewGenArrTp(unsigned      dcnt,
  2935.                                       TypDef        elem,
  2936.                                       bool          generic);
  2937.     TypDef              stNewArrType (DimDef        dims,
  2938.                                       bool          mgd,
  2939.                                       TypDef        elem = NULL);
  2940.     TypDef              stNewFncType (ArgDscRec     args,
  2941.                                       TypDef        rett = NULL);
  2942.  
  2943.     TypDef              stNewTdefType(SymDef        tsym);
  2944.  
  2945.     TypDef              stNewErrType (Ident         name);
  2946.  
  2947. private:
  2948.  
  2949.     TypDef              stAllocTypDef(var_types     kind);
  2950.  
  2951.     static
  2952.     unsigned            stTypeHash   (TypDef        type,
  2953.                                       int           ival,
  2954.                                       bool          bval1,
  2955.                                       bool          bval2 = false);
  2956.  
  2957.     TypDef              stRefTypeList;
  2958.     unsigned            stRefTpHashSize;
  2959.     TypDef         *    stRefTpHash;
  2960.  
  2961.     TypDef              stArrTypeList;
  2962.     unsigned            stArrTpHashSize;
  2963.     TypDef         *    stArrTpHash;
  2964.  
  2965.     static
  2966.     unsigned            stComputeTypeCRC(TypDef typ);
  2967.  
  2968.     static
  2969.     unsigned            stComputeArgsCRC(TypDef typ);
  2970.  
  2971. private:
  2972.     TypDef              stIntrinsicTypes[TYP_lastIntrins + 1];
  2973. public:
  2974.     TypDef              stIntrinsicType(var_types vt)
  2975.     {
  2976.         assert((unsigned)vt <= TYP_lastIntrins);
  2977.  
  2978.         return  stIntrinsicTypes[vt];
  2979.     };
  2980.  
  2981.     static
  2982.     bool                stArgsMatch  (TypDef typ1, TypDef typ2);
  2983.     static
  2984.     bool                stMatchArrays(TypDef typ1, TypDef typ2, bool subtype);
  2985.     static
  2986.     bool                stMatchTypes (TypDef typ1, TypDef typ2);
  2987.     static
  2988.     bool                stMatchType2 (TypDef typ1, TypDef typ2);
  2989.  
  2990. private:
  2991.     static
  2992.     BYTE                stIntrTypeSizes [TYP_COUNT];
  2993.     static
  2994.     BYTE                stIntrTypeAligns[TYP_COUNT];
  2995.  
  2996. public:
  2997.     static
  2998.     size_t              stIntrTypeSize (var_types type);
  2999.     static
  3000.     size_t              stIntrTypeAlign(var_types type);
  3001.  
  3002.     static
  3003.     normString          stClsFlavorStr(unsigned flavor);
  3004.     static
  3005.     normString          stIntrinsicTypeName(var_types);
  3006.  
  3007.     unsigned            stIsBaseClass(TypDef baseCls, TypDef dervCls);
  3008.  
  3009.     static
  3010.     bool                stIsAnonUnion(SymDef clsSym);
  3011.     static
  3012.     bool                stIsAnonUnion(TypDef clsTyp);
  3013.  
  3014.     static
  3015.     bool                stIsObjectRef(TypDef type);
  3016.  
  3017.     /************************************************************************/
  3018.     /* Members used for error reporting (and debugging of the compiler)     */
  3019.     /************************************************************************/
  3020.  
  3021. private:
  3022.  
  3023.     char    *           typeNameNext;
  3024.     char    *           typeNameAddr;
  3025.     TypDef  *           typeNameDeft;
  3026.     bool    *           typeNameDeff;
  3027.  
  3028.     void                pushTypeChar(int ch);
  3029. #if MGDDATA
  3030.     void                pushTypeStr (String     str);
  3031. #else
  3032.     void                pushTypeStr (const char*str);
  3033. #endif
  3034.     void                pushTypeSep (bool       refOK = false,
  3035.                                      bool       arrOK = false);
  3036.  
  3037.     void                pushTypeNstr(SymDef     sym,
  3038.                                      bool       fullName);
  3039.     void                pushQualNstr(QualName   name);
  3040.  
  3041.     void                pushTypeInst(SymDef     clsSym);
  3042.  
  3043.     void                pushTypeArgs(TypDef     type);
  3044.     void                pushTypeDims(TypDef     type);
  3045.  
  3046.     void                pushTypeName(TypDef     type,
  3047.                                      bool       isptr,
  3048.                                      bool       qual);
  3049.  
  3050.     void                pushFullName(TypDef     typ,
  3051.                                      SymDef     sym,
  3052.                                      Ident      name,
  3053.                                      QualName   qual,
  3054.                                      bool       fullName);
  3055.  
  3056.     bool                stDollarClsMode;
  3057.  
  3058. public:
  3059.  
  3060.     // OUTRAGEOUS HACK to get "outer$inner" crap for nested class names
  3061.  
  3062.     void                stTypeNameSetDollarClassMode(bool dollars)
  3063.     {
  3064.         stDollarClsMode = dollars;
  3065.     }
  3066.  
  3067.     stringBuff          stTypeName(TypDef       typ,
  3068.                                    SymDef       sym         = NULL,
  3069.                                    Ident        name        = NULL,
  3070.                                    QualName     qual        = NULL,
  3071.                                    bool         fullName    = false,
  3072.                                    stringBuff   destBuffPos = NULL);
  3073.  
  3074.     const   char *      stErrorTypeName(TypDef   type);
  3075.     const   char *      stErrorTypeName(Ident    name, TypDef type);
  3076.     const   char *      stErrorSymbName(SymDef    sym, bool   qual = false,
  3077.                                                        bool notype = false);
  3078.     const   char *      stErrorIdenName(Ident    name, TypDef type = NULL);
  3079.     const   char *      stErrorQualName(QualName name, TypDef type = NULL);
  3080. };
  3081.  
  3082. /*****************************************************************************/
  3083.  
  3084. inline
  3085. bool                symTab::stMatchTypes(TypDef typ1, TypDef typ2)
  3086. {
  3087.     if  (typ1 == typ2)
  3088.         return  true;
  3089.  
  3090.     if  (typ1 && typ2)
  3091.         return  stMatchType2(typ1, typ2);
  3092.  
  3093.     return  false;
  3094. }
  3095.  
  3096. /*****************************************************************************
  3097.  *
  3098.  *  Returns the size (in bytes) of the given intrinsic type.
  3099.  */
  3100.  
  3101. inline
  3102. size_t              symTab::stIntrTypeSize(var_types type)
  3103. {
  3104.     assert(type < sizeof(stIntrTypeSizes)/sizeof(stIntrTypeSizes[0]));
  3105.     assert(stIntrTypeSizes[type] || type == TYP_NATINT || type == TYP_NATUINT);
  3106.  
  3107.     return stIntrTypeSizes[type];
  3108. }
  3109.  
  3110. /*****************************************************************************
  3111.  *
  3112.  *  Returns the alignment of the given intrinsic type.
  3113.  */
  3114.  
  3115. inline
  3116. size_t              symTab::stIntrTypeAlign(var_types type)
  3117. {
  3118.     assert(type < sizeof(stIntrTypeAligns)/sizeof(stIntrTypeAligns[0]));
  3119.     assert(stIntrTypeAligns[type]);
  3120.  
  3121.     return stIntrTypeAligns[type];
  3122. }
  3123.  
  3124. /*****************************************************************************
  3125.  *
  3126.  *  A wrapper around stIsBaseClass() that makes sure the derived class has
  3127.  *  been declared before calling it.
  3128.  */
  3129.  
  3130. inline
  3131. unsigned            compiler::cmpIsBaseClass(TypDef baseCls, TypDef dervCls)
  3132. {
  3133.     if  (dervCls->tdClass.tdcSymbol->sdCompileState < CS_DECLARED)
  3134.         cmpDeclSym(dervCls->tdClass.tdcSymbol);
  3135.  
  3136.     return  cmpGlobalST->stIsBaseClass(baseCls, dervCls);
  3137. }
  3138.  
  3139. /*****************************************************************************/
  3140. #endif
  3141. /*****************************************************************************/
  3142.