Ejemplo n.º 1
0
        public override void Evaluate()
        {
            Term       targetTerm = new Term(RegexMatch.Groups[1].Value);
            Expression e          = new Expression(RegexMatch.Groups[2].Value, ParentContext);

            if (targetTerm.Type == Term.TermTypes.STRUCTURE)
            {
                object baseObj = new Expression(targetTerm.SubTerms[0], ParentContext).GetValue();

                if (baseObj is SpecialValue)
                {
                    if (((SpecialValue)baseObj).SetSuffix(targetTerm.SubTerms[1].Text.ToUpper(), e.GetValue()))
                    {
                        State = ExecutionState.DONE;
                        return;
                    }
                    else
                    {
                        throw new kOSException("Suffix '" + targetTerm.SubTerms[1].Text + "' doesn't exist or is read only", this);
                    }
                }
                else
                {
                    throw new kOSException("Can't set subvalues on a " + Expression.GetFriendlyNameOfItem(baseObj), this);
                }
            }
            else
            {
                Variable v = FindOrCreateVariable(targetTerm.Text);

                if (v != null)
                {
                    v.Value = e.GetValue();
                    State   = ExecutionState.DONE;
                    return;
                }
            }
        }