コード例 #1
0
ファイル: Block.cs プロジェクト: theta1220/sumi
 public void Using(Block block)
 {
     foreach (var runnable in block.Runnables)
     {
         Runnables.Add(runnable);
     }
     foreach (var value in block.Values)
     {
         if (Values.Find(o => o.Name == value.Name) != null)
         {
             continue;
         }
         Values.Add(value);
     }
     foreach (var func in block.Functions)
     {
         if (Values.Find(o => o.Name == func.Name) != null)
         {
             continue;
         }
         var clone = func.Clone() as Function;
         clone.Parent = this;
         Functions.Add(clone);
     }
 }
コード例 #2
0
ファイル: Caller.cs プロジェクト: theta1220/sumi
        public override void OnEntered()
        {
            Function = GetParentBlock().FindFunction(Name);

            if (Function == null)
            {
                Log.Error("メソッドの呼び出しに失敗しました: {0}->{1}", GetParentClass().FullName, Name);
                return;
            }
            Runnables.Add(Function);
            SetCaller();
            SetArgs();
        }
コード例 #3
0
ファイル: Runnable.cs プロジェクト: theta1220/sumi
 public Runnable(Runnable other)
 {
     Source       = other.Source;
     ExecuteCount = other.ExecuteCount;
     foreach (var obj in other.Runnables)
     {
         var clone = (obj as Runnable).Clone();
         clone.Parent = this;
         Runnables.Add(clone);
     }
     Parent     = other.Parent;
     _isEntered = other._isEntered;
 }
コード例 #4
0
        public override void OnEntered()
        {
            var methodName = ExtractMethodName(Source);

            if (methodName == "system_call")
            {
                Runnables.Add(new SystemCaller(this, Source));
            }
            else if (IsSetter(Source))
            {
                Runnables.Add(new ValueSetter(this, Source));
            }
            else
            {
                Runnables.Add(new Caller(this, Source));
            }
        }
コード例 #5
0
ファイル: Block.cs プロジェクト: theta1220/sumi
        public Block(Runnable parent, string text, string name = "") : base(parent, text)
        {
            if (name.Length > 0)
            {
                Name = name;
            }
            var sources = text.PoSplitSource();

            foreach (var source in sources)
            {
                if (source.PoMatchHead("func"))
                {
                    Functions.Add(new Function(this, source));
                }
                else if (source.PoMatchHead("test"))
                {
                    Tests.Add(new Function(this, source));
                }
                else if (source.PoMatchHead("class"))
                {
                    var def      = new Class(this, source);
                    var fullName = string.Format("{0}.{1}", FullName, def.Name);
                    if (!Class.ExistsStaticClass(fullName))
                    {
                        Class.AddStaticClass(fullName, def);
                    }
                    else
                    {
                        Class.GetStaticClass(fullName).Using(def);
                    }
                }
                else if (source.PoMatchHead("extension"))
                {
                    var def = new Class(this, source);
                    if (!Class.ExistsStaticExtension(def.Name))
                    {
                        Class.AddStaticExtension(def);
                    }
                    else
                    {
                        Class.GetStaticExtension(def.Name).Using(def);
                    }
                }
                else if (source.PoMatchHead("if") ||
                         source.PoMatchHead("else if") ||
                         source.PoMatchHead("else"))
                {
                    Runnables.Add(new If(this, source));
                }
                else if (source.PoMatchHead("count"))
                {
                    Runnables.Add(new Count(this, source));
                }
                else if (source.PoMatchHead("while"))
                {
                    Runnables.Add(new While(this, source));
                }
                else if (source.PoMatchHead("foreach"))
                {
                    Runnables.Add(new Foreach(this, source));
                }
                else if (source.PoMatchHead("for"))
                {
                    Runnables.Add(new For(this, source));
                }
                else if (source.PoMatchHead("return"))
                {
                    Runnables.Add(new Return(this, source));
                }
                else if (source.PoMatchHead("continue"))
                {
                    Runnables.Add(new Continue(this, source));
                }
                else if (source.PoMatchHead("break"))
                {
                    Runnables.Add(new Break(this, source));
                }
                else if (source.PoMatchHead("{"))
                {
                    Runnables.Add(new Block(this, source.PoExtract('{', '}')));
                }
                else
                {
                    Runnables.Add(new Term(this, source));
                }
            }
        }