Пример #1
0
 //IStatement
 public void Execute()
 {
     if (!IsObject)
     {
         VariablesDictionary.SetVariable(variable, expression.Evaluate());
     }
     else
     {
         ExecuteArray();
     }
 }
Пример #2
0
        private void ExecuteArray()
        {
            IObject obj    = VariablesDictionary.GetObject(variable);
            IObject result = obj;

            GetIndexes();
            for (int i = 0; i < indexes.Count; ++i)
            {
                if (i == indexes.Count - 1)
                {
                    if (obj is ArrayIndex && indexes[i] is int)
                    {
                        ((ArrayIndex)obj)[(int)indexes[i]] = getObject();
                    }
                    else if (obj is ArrayObject && indexes[i] is string)
                    {
                        ((ArrayObject)obj)[(string)indexes[i]] = getObject();
                    }
                    else
                    {
                        throw new Exception("wrong index or type");
                    }
                    break;
                }
                if (obj is ArrayIndex && indexes[i] is int)
                {
                    obj = ((ArrayIndex)obj)[(int)indexes[i]];
                }
                else if (obj is ArrayObject && indexes[i] is string)
                {
                    obj = ((ArrayObject)obj)[(string)indexes[i]];
                }
                else
                {
                    throw new Exception("wrong index or type");
                }
            }
            VariablesDictionary.SetVariable(variable, result);
        }