Esempio n. 1
0
        public int AddLocVar(string name)
        {
            var newVar = new LocVarInfo
            {
                Name    = name,
                Prev    = _locNames.ContainsKey(name) ? _locNames[name] : null,
                ScopeLv = _scopeLv,
                Slot    = AllocReg()
            };

            _locVars.Add(newVar);
            _locNames[name] = newVar;
            return(newVar.Slot);
        }
Esempio n. 2
0
        public void RemoveLocVar(LocVarInfo locVarInfo)
        {
            FreeReg();

            if (locVarInfo.Prev is null)
            {
                _locNames.Remove(locVarInfo.Name);
            }
            else if (locVarInfo.Prev.ScopeLv == locVarInfo.ScopeLv)
            {
                RemoveLocVar(locVarInfo.Prev);
            }
            else
            {
                _locNames[locVarInfo.Name] = locVarInfo.Prev;
            }
        }