Пример #1
0
 public bool Run(GcMachine m, string[] param)
 {
     if (m.GetLocalIDByName(param[1]) == -1)
     {
         System.Console.WriteLine("Local varible " + param[1] + "do not exist.");
     }
     else
     {
         Varible v  = m.GetLocalByID(m.GetLocalIDByName(param[1]));
         string  st = "Local varible " + param[1] + ":";
         if (v.type == VarType.TYPE_NUMBER)
         {
             st += v.num.ToString();
         }
         else if (v.type == VarType.TYPE_STRING)
         {
             st = st + "\"" + m.GetString(v.pointer).Replace("\n", "").Replace("\r", "") + "\"";
         }
         else
         {
             st += "(function)";
         }
         System.Console.WriteLine(st);
     }
     return(false);
 }
Пример #2
0
 public bool Run(GcMachine m, string[] param)
 {
     if (!m.IsGlobalExists(param[1]))
     {
         System.Console.WriteLine("Varible " + param[1] + "has not been initialized yet.");
     }
     else
     {
         Varible v  = m.GetGlobal(param[1]);
         string  st = "Varible " + param[1] + ":";
         if (v.type == VarType.TYPE_NUMBER)
         {
             st += v.num.ToString();
         }
         else if (v.type == VarType.TYPE_STRING)
         {
             st = st + "\"" + m.GetString(v.pointer).Replace("\n", "").Replace("\r", "") + "\"";
         }
         else
         {
             st += "(function)";
         }
         System.Console.WriteLine(st);
     }
     return(false);
 }
Пример #3
0
        private Varible GetVarible()
        {
            if (!char.IsLetter(_stringContainer.CurrentSymbol))
            {
                return(null);
            }

            var varible = new Varible {
                Name = _stringContainer.PopCurrentSymbol()
            };

            if (_stringContainer.CurrentSymbol == '^')
            {
                _stringContainer.PopCurrentSymbol();
                double degree;
                if (TryGetNumber(out degree))
                {
                    varible.Degree = (int)degree;
                }
                else
                {
                    SetError(IncrorrectFormatEquotionStringMessage);
                    return(null);
                }
            }
            else
            {
                varible.Degree = 1;
            }

            return(varible);
        }
Пример #4
0
 protected bool Equals(Varible other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Degree == other.Degree && Name == other.Name);
 }