コード例 #1
0
ファイル: CommandLog.cs プロジェクト: jwvanderbeck/KOS_old
        public override void Evaluate()
        {
            // Todo: let the user specify a volume "LOG something TO file ON volume"
            var targetVolume = SelectedVolume;

            // If the archive is out of reach, the signal is lost in space.
            if (!targetVolume.CheckRange())
            {
                State = ExecutionState.DONE;
                return;
            }

            var targetFile = RegexMatch.Groups[2].Value.Trim();
            var e = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);

            if (e.IsNull())
            {
                State = ExecutionState.DONE;
            }
            else
            {
                targetVolume.AppendToFile(targetFile, e.ToString());
                State = ExecutionState.DONE;
            }
        }
コード例 #2
0
ファイル: CommandLog.cs プロジェクト: vosechu/KOS
        public override void Evaluate()
        {
            // Todo: let the user specify a volume "LOG something TO file ON volume"
            var targetVolume = SelectedVolume;

            // If the archive is out of reach, the signal is lost in space.
            if (!targetVolume.CheckRange())
            {
                State = ExecutionState.DONE;
                return;
            }

            var targetFile = RegexMatch.Groups[2].Value.Trim();
            var e          = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);

            if (e.IsNull())
            {
                State = ExecutionState.DONE;
            }
            else
            {
                targetVolume.AppendToFile(targetFile, e.ToString());
                State = ExecutionState.DONE;
            }
        }
コード例 #3
0
        public override void Evaluate()
        {
            var       target = new Expression.Expression(RegexMatch.Groups[2].Value, ParentContext).GetValue();
            var       name   = new Term(RegexMatch.Groups[3].Value);
            var       type   = new Term(RegexMatch.Groups[1].Value);
            ListValue list;

            if (target is VesselTarget)
            {
                list = Vessel.PartList(type.Text);
            }
            else
            {
                var targetVessel = VesselUtils.GetVesselByName(target.ToString());
                if (targetVessel != null)
                {
                    if (targetVessel.loaded)
                    {
                        list = targetVessel.PartList(type.Text);
                    }
                    else
                    {
                        throw new KOSException("Vessel: " + target + " Is Unloaded, Cannot continue.");
                    }
                }
                else
                {
                    throw new KOSException("Could not get list: " + type.Text + " for Vessel: " + target);
                }
            }

            FindOrCreateVariable(name.Text).Value = list;
            State = ExecutionState.DONE;
        }
コード例 #4
0
        public override void Evaluate()
        {
            var target = new Expression.Expression(RegexMatch.Groups[2].Value, ParentContext).GetValue();
            var name = new Term(RegexMatch.Groups[3].Value);
            var type = new Term(RegexMatch.Groups[1].Value);
            ListValue list;

            if (target is VesselTarget)
            {
                list = Vessel.PartList(type.Text);
            }
            else
            {
                var targetVessel = VesselUtils.GetVesselByName(target.ToString());
                if (targetVessel != null)
                {
                    if (targetVessel.loaded)
                    {
                        list = targetVessel.PartList(type.Text);
                    }
                    else
                    {
                        throw new KOSException("Vessel: " + target + " Is Unloaded, Cannot continue.");
                    }
                }
                else
                {
                    throw new KOSException("Could not get list: " + type.Text + " for Vessel: " + target);
                }
            }

            FindOrCreateVariable(name.Text).Value = list;
            State = ExecutionState.DONE;
        }
コード例 #5
0
ファイル: CommandPrint.cs プロジェクト: vosechu/KOS
        public override void Evaluate()
        {
            var e = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);

            if (e.IsNull())
            {
                StdOut("NULL");
                State = ExecutionState.DONE;
            }
            else
            {
                StdOut(e.ToString());
                State = ExecutionState.DONE;
            }
        }
コード例 #6
0
ファイル: CommandPrint.cs プロジェクト: jwvanderbeck/KOS_old
        public override void Evaluate()
        {
            var e = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);

            if (e.IsNull())
            {
                StdOut("NULL");
                State = ExecutionState.DONE;
            }
            else
            {
                StdOut(e.ToString());
                State = ExecutionState.DONE;
            }
        }
コード例 #7
0
        public override void Evaluate()
        {
            var e = new Expression.Expression(RegexMatch.Groups[1].Value, ParentContext);
            var ex = new Expression.Expression(RegexMatch.Groups[2].Value, ParentContext);
            var ey = new Expression.Expression(RegexMatch.Groups[3].Value, ParentContext);

            if (e.IsNull()) throw new KOSException("Null value in print statement");

            int x, y;

            if (Int32.TryParse(ex.ToString(), out x) && Int32.TryParse(ey.ToString(), out y))
            {
                Put(e.ToString(), x, y);
            }
            else
            {
                throw new KOSException("Non-numeric value assigned to numeric function", this);
            }

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

            if (e.IsNull())
            {
                throw new KOSException("Null value in print statement");
            }

            int x, y;

            if (Int32.TryParse(ex.ToString(), out x) && Int32.TryParse(ey.ToString(), out y))
            {
                Put(e.ToString(), x, y);
            }
            else
            {
                throw new KOSException("Non-numeric value assigned to numeric function", this);
            }

            State = ExecutionState.DONE;
        }
コード例 #9
0
 public override string ToString()
 {
     return("if(" + expr.ToString() + ")then (" + thenStat.ToString() + ") else(" + elseStat.ToString() + ")");
 }
コード例 #10
0
 public override string ToString()
 {
     return("closeFile(" + expression.ToString() + ")");
 }
コード例 #11
0
 public override string ToString()
 {
     return("new(" + var + "," + expr.ToString() + ")");
 }
コード例 #12
0
 public override string ToString()
 {
     return("openReadFile(" + expression.ToString() + ")");
 }
コード例 #13
0
 public override string ToString()
 {
     return(id + "=" + expr.ToString());
 }
コード例 #14
0
 public override string ToString()
 {
     return("readFile(" + expression.ToString() + "," + var + ")");
 }