コード例 #1
0
ファイル: CommandSet.cs プロジェクト: jwvanderbeck/KOS_old
        public override void Evaluate()
        {
            var targetTerm = new Term(RegexMatch.Groups[1].Value);
            var e = new Expression.Expression(RegexMatch.Groups[2].Value, ParentContext);

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

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

            if (v == null) return;
            v.Value = e.GetValue();
            State = ExecutionState.DONE;
        }
コード例 #2
0
ファイル: CommandSet.cs プロジェクト: vosechu/KOS
        public override void Evaluate()
        {
            var targetTerm = new Term(RegexMatch.Groups[1].Value);
            var e          = new Expression.Expression(RegexMatch.Groups[2].Value, ParentContext);

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

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

            if (v == null)
            {
                return;
            }
            v.Value = e.GetValue();
            State   = ExecutionState.DONE;
        }
コード例 #3
0
ファイル: CommandTestKegex.cs プロジェクト: vosechu/KOS
        public override void Evaluate()
        {
            var e = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);

            StdOut(e.GetValue().ToString());

            State = ExecutionState.DONE;
        }
コード例 #4
0
        public override void Evaluate()
        {
            var e = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);

            StdOut(e.GetValue().ToString());

            State = ExecutionState.DONE;
        }
コード例 #5
0
ファイル: CommandCallExternal.cs プロジェクト: QuakeIV/KOS
        public override void Evaluate()
        {
            // External functions are now handled within expressions,
            // so simply execute the expression and throw away the value
            var subEx = new Expression.Expression(RegexMatch.Groups[1].Value, this);
            subEx.GetValue();

            State = ExecutionState.DONE;
        }
コード例 #6
0
ファイル: CommandCallExternal.cs プロジェクト: vosechu/KOS
        public override void Evaluate()
        {
            // External functions are now handled within expressions,
            // so simply execute the expression and throw away the value
            var subEx = new Expression.Expression(RegexMatch.Groups[1].Value, this);

            subEx.GetValue();

            State = ExecutionState.DONE;
        }
コード例 #7
0
        public override void Evaluate()
        {
            var ex = new Expression.Expression(RegexMatch.Groups[1].Value, this);
            var obj = ex.GetValue();

            var node = obj as Node;
            if (node != null)
            {
                node.Remove();
            }
            else
            {
                throw new KOSException("Supplied object ineligible for removal", this);
            }

            State = ExecutionState.DONE;
        }
コード例 #8
0
        public override void Evaluate()
        {
            var ex  = new Expression.Expression(RegexMatch.Groups[1].Value, this);
            var obj = ex.GetValue();

            var node = obj as Node;

            if (node != null)
            {
                node.Remove();
            }
            else
            {
                throw new KOSException("Supplied object ineligible for removal", this);
            }

            State = ExecutionState.DONE;
        }