⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 varmgrc.c

📁 [随书类]Dos6.0源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
               if (mkVar.flags & FVLVAL)
                  goto RE_DD_Exit;          
            if (retval = StdSearch())
               goto RetValExit;              /* return error code             */
            if (!vm_fVarFound) {
               if ((vm_fPVCur) && !(mkVar.flags & FVLVAL)) {
                  vm_fPVCur = FALSE;         /* search the tMV                */
                  if (retval = StdSearch())
                     goto RetValExit;        /* return error code             */
                  vm_fPVCur = TRUE;          /* reset                         */
                  }
               if (!vm_fVarFound)
                  if (retval = CreateVar(oHashCreate, createMask | FVFUN))
                     goto RetValExit;        /* return error code             */
               }
            }  /* if FVFNNAME */
         }  /* if FVFUNCTION, of FVFNNAME */

      else {                                 /* must be FORMAL, STATIC, 
                                                COMMON, SHARED, or CONST      */
         if (retval = StdSearch())
            goto RetValExit;                 /* return error code             */

         if (flags & (FVFORMAL | FVSTATIC | FVCONST)) {
            if (vm_fVarFound)
               goto RE_DD_Exit;              /* existing var matches formal,
                                                static, or const              */
            if (retval = CreateVar(oHashCreate, createMask))
               goto RetValExit;              /* return error code             */
            
            if ((flags & FVCONST) && !vm_fPVCur) {
               DbAssert(txdCur.scanState == SS_RUDE)  /* ensure no owners     */
               FlagsOf(vm_pVarCur) |= FVSHARED;

               /* remember that an entry of this oNam is module shared: */
               nm_mask |= NM_fShared;
               }
            }  /* if FVFORMAL, FVSTATIC, or FVCONST */

         else if (flags & FVCOMMON) {
            fCreate = TRUE;                  /* assume we want to create the
                                                variable if not found         */
            if (vm_fVarFound) {
               pVar = vm_pVarCur;
               if (FlagsOf(pVar) & FVARRAY) {
                  DbAssert(txdCur.scanState == SS_RUDE)  /* ensure no owners  */
                  FlagsOf(pVar) |= FVCOMMON; /* convert entry to be a COMMON  */
                  FlagsOf(pVar) &= ~FVVALUESTORED;
                  fCreate = FALSE;           /* don't want to create too ...  */
                  }
	       else			     /* not an array		      */
		  goto RE_DD_Exit;	     /* [14]			      */
               }  /* if found */
            
            if (fCreate)   
               if (retval = CreateVar(UNDEFINED, createMask))
                  goto RetValExit;     /* return error code */

            if (flags & FVSHARED) {
               DbAssert(txdCur.scanState == SS_RUDE)  /* ensure no owners     */
               FlagsOf(vm_pVarCur) |= FVSHARED;

               /* remember that an entry of this oNam is module shared: */
               nm_mask |= NM_fShared;
               }
            }  /* if FVCOMMON */

         else {                              /* must be FVSHARED              */
            DbAssert(flags & FVSHARED)
            /* NOTE: this case MUST be tested AFTER we check for FVCOMMON     */
            if (vm_fPVCur) {                 /* active procedure              */
               if (vm_fVarFound)
		  goto RE_DD_Exit;	     /* [14] in case found entry
						[14] contains an owner	      */
               else {                        /* var not found in the tPV      */
                  vm_fPVCur = FALSE;
                  if (retval = StdSearch())  /* search tMV                    */
                     goto RetValExit;
                  vm_fPVCur = TRUE;          /* reset                         */
                  if (!vm_fVarFound) {
                     if (retval = CreateVar(UNDEFINED, createMask & ~FVSHARED))
                        goto RetValExit;     /* create var a module level     */
                     }
                  FlagsOf(vm_pVarCur) |= FVSHARED; /* scanner needs this bit
                                                      set in module entry.
                                                      Namespace bit keeps
                                                      this case straight.     */
                  vm_oVarTmp = vm_oVarCur;   /* save offset to tMV entry      */
                  if (retval = CreateVar(prsCur.oVarHash, createMask))
                     goto RetValExit;        /* return error code             */
                  pVar = vm_pVarCur;
                  ValueOf(pVar, oMV) = 
                  vm_oVarCur = vm_oVarTmp;
                  }
               }
            else {                           /* no proc active - DIM SHARED   */
               if (!vm_fVarFound)
                  if (retval = CreateVar(UNDEFINED, createMask))
                     goto RetValExit;        /* return error code             */
               /* NOTE: the parser CAN call us here when we're not in SS_RUDE,
                  NOTE: but the txtmgr guarantees us that if a user enters
                  NOTE: or modifies a DIM SHARED statement, it will be a rude
                  NOTE: edit. I.e., we don't need to worry about any proc-level
                  NOTE: variables here, since the rude scanner scans the
                  NOTE: module before any of the procedures in the module     */
               FlagsOf(vm_pVarCur) |= FVSHARED;

               /* remember that an entry of this oNam is module shared: */
               nm_mask |= NM_fShared;
               }
            }  /* if FVSHARED */

         }  /* COMMON, SHARED */

      }  /* some special-case flag(s) is/are set */


   /* var was either explicitly or implicitly typed; set flag accordingly:    */
   if (!(flags & FVIMPLICIT))
      FlagsOf((var *)(mrsCur.bdVar.pb + vm_oVarCur)) |= FVEVEREXPLICIT;

   if (nm_mask != 0)
      SetONamMask(mkVar.oNam, nm_mask);      /* don't set name table flag bits
                                                until no chance of error      */

   DbChkoVar(vm_oVarCur)
   DbChkoTyp(mkVar.oTyp)
   DbMkVarExit(vm_oVarCur,vm_fVarFound,vm_fPVCur)

   /* Reset most of the input flags to their default values (FALSE) - - leave
      the rest as they were on entry                                          */
   mkVar.exitFlags = mkVar.flags;            /* NOTE: can remove exitFlags
                                                      when MakeVariable is
                                                      rewritten in native code*/
   mkVar.flags = inputFlags & ~(FVFNNAME | FVASCLAUSE | FVIMPLICIT | FVLVAL | 
		     FVFORCEARRAY | FVINDEXED | FVFUNCTION | FVCONST);
   mkVar.flags2 &= ~(MV_fONamInOTyp | MV_fDontCreate);

   return(vm_oVarCur);

RE_DD_Exit:
   retval = PRS_ER_RE | ER_DD;
RetValExit:
   DbMkVarExit(retval,vm_fVarFound,vm_fPVCur)
   /* Reset most of the input flags to their default values (FALSE) - - leave
      the rest as they were on entry                                          */
   mkVar.exitFlags = mkVar.flags;            /* NOTE: can remove exitFlags
                                                      when MakeVariable is
                                                      rewritten in native code*/
   mkVar.flags = inputFlags & ~(FVFNNAME | FVASCLAUSE | FVIMPLICIT | FVLVAL | 
		     FVFORCEARRAY | FVINDEXED | FVFUNCTION | FVCONST);
   mkVar.flags2 &= ~(MV_fONamInOTyp | MV_fDontCreate);

   return(retval);
   }  /* MakeVariable */


/*##############################################################################
#                                                                              #
#                 Call-back code, for when a variable table moves              #
#                                                                              #
##############################################################################*/
/***
*AdjustStatChain(pVarTable, oVar, cbAdjust)
*Purpose:
*  Adjust the back pointers to AD's and SD's in all static variables in
*  the current hash chain by cbAdjust bytes.
*  Note that this code is shared by AdjustMrsVarTable and AdjustPrsVarTable.
*
*Entry:
*  pVarTable is the base pointer for the variable table.
*  oVar is an offset into a variable table to the first var in a chain.
*  cbAdjust is an adjustment factor to be added to appropriate backpointers.
*
*Exit:
*  none.
*
*Exceptions:
*  none.
*
*******************************************************************************/
STATICF(VOID) AdjustStatChain(pVarTable, oVar, cbAdjust)
var *pVarTable;
REG2 ushort oVar;
ushort cbAdjust;
   {
   REG1 var *pVar;
   REG3 ushort flags;

   while (oVar != 0) {
      pVar = (var *)((char *)pVarTable + oVar);
      flags = FlagsOf(pVar);
      oVar = (OHashLinkOf(pVar) & 0xFFFE);

      if ((flags & FVFUN) || !(flags & FVVALUESTORED))
         continue;
      if (flags & FVARRAY) {
         if ((ValueOf(pVar, aryStat.aryDsc.fFeatures & FADF_SD)) &&
             (ValueOf(pVar, aryStat.aryDsc.pNext) != NOT_OWNER))
                  B_IAdUpd(&(ValueOf(pVar, aryStat.aryDsc)), cbAdjust);
         }
      else if ((OTypOf(pVar) == ET_SD) && (ValueOf(pVar,sdStr.pb) != NULL)) {
         B_ISdUpd(&(ValueOf(pVar, sdStr)), cbAdjust);
         }
      }  /* while */
   }  /* AdjustStatChain */

/***
*AdjustMrsVarTable(pVarTable, cbAdjust)
*
*Purpose:
*  Adjust the back pointers to AD's and SD's in all static variables in
*  the tMV by cbAdjust bytes.
*
*Entry:
*  pVarTable is the base pointer for the variable table.
*  cbAdjust is an adjustment factor to be added to appropriate backpointers.
*
*Exit:
*  none.
*
*Exceptions:
*  none.
*
*******************************************************************************/
VOID NEAR AdjustMrsVarTable(pVarTable, cbAdjust)
var *pVarTable;
ushort cbAdjust;
   {
   REG1 ushort iHash;
   REG2 ushort *pHash = (ushort *)pVarTable; /* tMV hash tbl @ start    */

   for (iHash = 0; iHash < CBINITMVHASH/2; iHash++)
      AdjustStatChain(pVarTable, *pHash++, cbAdjust);
   }  /* AdjustMrsVarTable */

/***
*AdjustPrsVarTable(pVarTable, oVarHash, cbAdjust)
*
*Purpose:
*  Adjust the back pointers to AD's and SD's in all static variables in
*  the given tPV by cbAdjust bytes.
*
*Entry:
*  pVarTable is the base pointer for the variable table.
*  oVarHash is the offset in the variable table to the tPV hash table.
*  cbAdjust is an adjustment factor to be added to appropriate backpointers.
*
*Exit:
*  none.
*
*Exceptions:
*  none.
*
*******************************************************************************/
VOID NEAR AdjustPrsVarTable(pVarTable, oVarHash, cbAdjust)
var *pVarTable;
ushort oVarHash;
ushort cbAdjust;
   {
   REG1 ushort iHash;
   REG2 ushort *pHash = (ushort *)((char *)pVarTable + oVarHash);
   
   if (oVarHash != UNDEFINED)
      for (iHash = 0; iHash < CBINITPVHASH/2; iHash++)
         AdjustStatChain(pVarTable, *pHash++, cbAdjust);
   }  /* AdjustPrsVarTable */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -