Esempio n. 1
0
        /// <summary>
        /// 移除对局部变量的引用
        /// </summary>
        /// <param name="varName">变量名</param>
        /// <return>操作成功与否</return>
        public bool UnsignalVar(string varName)
        {
            VariablePackage varItem = null;

            if ((varItem = this.localVarList.Find((x) => x.varName == varName)) != null)
            {
                varItem.referenceCount--;
                if (varItem.referenceCount == 0)
                {
                    this.localVarList.Remove(varItem);
                }
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// 查找一个局部变量,如果不存在就增加它;并且增添它的被引用次数
        /// </summary>
        /// <param name="varName">变量名</param>
        /// <param name="isLeftValue">是否作为左值</param>
        /// <param name="line">出现的行</param>
        /// <returns>在调用方法前该变量是否不存在</returns>
        public bool SignalVar(string varName, bool isLeftValue, int line)
        {
            VariablePackage varItem = null;

            if ((varItem = this.localVarList.Find((x) => x.varName == varName)) != null)
            {
                if (isLeftValue)
                {
                    varItem.firstLeftValueLine = Math.Min(line, varItem.firstLeftValueLine);
                }
                varItem.referenceCount++;
                return(false);
            }
            varItem = new VariablePackage()
            {
                varName            = varName,
                firstLeftValueLine = isLeftValue ? line : Int32.MaxValue,
                isGlobal           = false,
                referenceCount     = 1
            };
            this.localVarList.Add(varItem);
            return(true);
        }
Esempio n. 3
0
 /// <summary>
 /// 查找一个局部变量,如果不存在就增加它;并且增添它的被引用次数
 /// </summary>
 /// <param name="varName">变量名</param>
 /// <param name="isLeftValue">是否作为左值</param>
 /// <param name="line">出现的行</param>
 /// <returns>在调用方法前该变量是否不存在</returns>
 public bool SignalVar(string varName, bool isLeftValue, int line)
 {
     VariablePackage varItem = null;
     if ((varItem = this.localVarList.Find((x) => x.varName == varName)) != null)
     {
         if (isLeftValue)
         {
             varItem.firstLeftValueLine = Math.Min(line, varItem.firstLeftValueLine);
         }
         varItem.referenceCount++;
         return false;
     }
     varItem = new VariablePackage()
     {
         varName = varName,
         firstLeftValueLine = isLeftValue ? line : Int32.MaxValue,
         isGlobal = false,
         referenceCount = 1
     };
     this.localVarList.Add(varItem);
     return true;
 }