Example #1
0
        public List <CSNode> RetrieveFragmentLeaves(CSNode rootNode)
        {
            var rootChildren = new List <CSNode>(rootNode.Children.Cast <CSNode>());

            rootChildren.Reverse();
            Stack <CSNode> nodeStack = new Stack <CSNode>(rootChildren);


            var leaves = new List <CSNode>();

            while (nodeStack.Count > 0)
            {
                var node = nodeStack.Pop();
                if (node.IsFragmentRoot || node.Children.Count == 0)
                {
                    leaves.Add(node);
                }
                else if (!node.IsFragmentRoot)
                {
                    var children = new List <CSNode>(node.Children.Cast <CSNode>());
                    children.Reverse();
                    using (var en = children.Cast <CSNode>().GetEnumerator())
                    {
                        while (en.MoveNext())
                        {
                            nodeStack.Push(en.Current);
                        }
                    }
                }
            }

            return(leaves);
        }
        public void NoLeafsBinarizationTest()
        {
            CSNode root = new CSNode();

            root.STInfo         = "root";
            root.IsFragmentRoot = true;

            CSNode child1 = new CSNode();

            child1.STInfo         = "child1";
            child1.IsFragmentRoot = true;
            root.AddChild(child1);

            CSNode child2 = new CSNode();

            child2.STInfo         = "child2";
            child2.IsFragmentRoot = true;
            root.AddChild(child2);

            CSNode child3 = new CSNode();

            child3.STInfo         = "child3";
            child3.IsFragmentRoot = true;
            root.AddChild(child3);

            CSNode child4 = new CSNode();

            child4.STInfo         = "child4";
            child4.IsFragmentRoot = true;
            root.AddChild(child4);

            LabeledTreeTransformations.Binarize(root, new CSNodeCreator());
            Assert.AreEqual(root.GetFragmentString(), "(root (child1) (B_root (child2) (B_root (child3) (child4)  )  )  ) ");
        }
Example #3
0
        public void TestNewGenericWithArrayType()
        {
            CSNode   root = ParseScript("CSScript.Test.GenericOne<int[]> a = new CSScript.Test.GenericOne<int[]>(new int[] {1,2,3});");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(CSScript.Test.GenericOne <int[]>), obj.Type);
        }
Example #4
0
 protected virtual void CreateCSObject()
 {
     if (this.innerNode == null)
     {
         this.innerNode = new CSNode();
     }
 }
Example #5
0
        public void GetFragmentStringTestLong()
        {
            CSNode root = new CSNode();

            root.STInfo         = "root";
            root.IsFragmentRoot = true;

            CSNode child1 = new CSNode();

            child1.STInfo         = "child1";
            child1.IsFragmentRoot = false;
            root.AddChild(child1);

            CSNode grandChild1 = new CSNode();

            grandChild1.STInfo         = "grandChild1";
            grandChild1.IsFragmentRoot = true;
            child1.AddChild(grandChild1);

            CSNode grandChild2 = new CSNode();

            grandChild2.STInfo         = "grandChild2";
            grandChild2.IsFragmentRoot = true;
            child1.AddChild(grandChild2);

            CSNode child2 = new CSNode();

            child2.STInfo         = "child2";
            child2.IsFragmentRoot = true;
            root.AddChild(child2);

            Assert.AreEqual(root.GetFragmentString(), "(root (child1 (grandChild1) (grandChild2)  ) (child2)  ) ");
        }
Example #6
0
        public void TestLocalVariable2()
        {
            CSNode   root = ParseScript("CSScript.Test.Simple s = new CSScript.Test.Simple(33); int b = s._a;");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("b", obj.Name);
            Assert.AreEqual(33, obj.GetAs <int> ());
        }
Example #7
0
        public void TestLocalVariable()
        {
            CSNode   root = ParseScript("int a = 33; int b = a;");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("b", obj.Name);
            Assert.AreEqual(33, obj.GetAs <int> ());
        }
Example #8
0
        public void TestStaticProperty()
        {
            CSNode   root = ParseScript("CSScript.Test.Simple.Hoge = \"HelloWorld\"; CSScript.Test.Simple.Hoge;");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("Hoge", obj.Name);
            Assert.AreEqual("HelloWorld", obj.GetAs <string> ());
        }
Example #9
0
        public void TestStaticVariable()
        {
            CSNode   root = ParseScript("CSScript.Test.Simple.HELLO = \"HelloWorld\"; CSScript.Test.Simple.HELLO;");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("HELLO", obj.Name);
            Assert.AreEqual("HelloWorld", obj.GetAs <string> ());
        }
Example #10
0
        public void TestNewInnerClass()
        {
            CSNode   root = ParseScript("CSScript.Test.Simple.Inner a = new CSScript.Test.Simple.Inner (33);");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(CSScript.Test.Simple.Inner), obj.Type);
            Assert.AreEqual(33, obj.GetAs <CSScript.Test.Simple.Inner> ()._a);
        }
Example #11
0
        public void AssignInt()
        {
            CSNode   root = ParseScript("var myVar = 3;");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("myVar", obj.Name);
            Assert.AreEqual(3, obj.Value);
        }
Example #12
0
        public void TestTypeIntArray()
        {
            CSNode   root = ParseScript("int[] a = new int[3];");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(int[]), obj.Type);
            Assert.AreEqual(3, obj.GetAs <int[]> ().Length);
        }
Example #13
0
 protected virtual void CreateCSObject()
 {
     if (this.innerNode != null)
     {
         return;
     }
     this.innerNode = new CSNode();
 }
Example #14
0
        public void AssignImmedidate()
        {
            CSNode root = ParseScript("var 4 = 3;");

            root.Evaluate();
            LogAssert.Expect(LogType.Error, "[CSScript line: 1 col: 4] missing NAME at '4'");
            LogAssert.Expect(LogType.Error, "[CSScript line: 1 col: 4] cannot assign to IMMEDIATE");
        }
Example #15
0
        public void TestTypeDictionaryAraray()
        {
            CSNode   root = ParseScript("System.Collections.Generic.Dictionary<string, int>[] a = new System.Collections.Generic.Dictionary<string, int>[3];");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(System.Collections.Generic.Dictionary <string, int>[]), obj.Type);
            Assert.AreEqual(3, obj.GetAs <System.Collections.Generic.Dictionary <string, int>[]> ().Length);
        }
Example #16
0
        public void NewArrayInt()
        {
            CSNode   root = ParseScript("var a = new int[32];");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(int[]), obj.Type);
            int[] arr = obj.GetAs <int[]> ();
            Assert.AreEqual(32, arr.Length);
        }
Example #17
0
		public void TestStaticMethod () {
			CSNode root = ParseScript (
				"string a = CSScript.Test.Simple.StaticMethod(\"moge\");"
			);
			
			CSObject obj = root.Evaluate ();
			Assert.AreEqual ("a", obj.Name);
			Assert.AreEqual ("moge", obj.GetAs<string> ());
		}
Example #18
0
		public void TestMethodIntWrongCall () {
			CSNode root = ParseScript (
				"int a = CSScript.Test.Simple.GetInt();"
			);

			Assert.Throws<System.MissingMethodException> (() => {
				CSObject obj = root.Evaluate ();
			}, "static method: GetInt cannot be found in CSScript.Test.Simple");
		}
Example #19
0
        public void TestNewInnerGenericClass()
        {
            CSNode   root = ParseScript("CSScript.Test.GenericOne<int>.Inner<float, string> a = new CSScript.Test.GenericOne<int>.Inner<float, string>(3.3f, \"hoge\");");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(CSScript.Test.GenericOne <int> .Inner <float, string>), obj.Type);
            Assert.AreEqual(3.3f, obj.GetAs <CSScript.Test.GenericOne <int> .Inner <float, string> > ()._a);
            Assert.AreEqual("hoge", obj.GetAs <CSScript.Test.GenericOne <int> .Inner <float, string> > ()._b);
        }
Example #20
0
        public void TypedVarSimple()
        {
            CSNode   root = ParseScript("CSScript.Test.Simple a = new CSScript.Test.Simple(3);");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("a", obj.Name);
            Assert.AreEqual(typeof(Simple), obj.Type);
            Assert.AreEqual(3, obj.GetAs <Simple> ()._a);
        }
Example #21
0
        public void TypedVarInt()
        {
            CSNode   root = ParseScript("int a = 3;");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual("a", obj.Name);
            Assert.AreEqual(typeof(int), obj.Type);
            Assert.AreEqual(3, obj.Value);
        }
Example #22
0
        public void NewArrayList()
        {
            CSNode   root = ParseScript("var a = new System.Collections.Generic.List<int>[2];");
            CSObject obj  = root.Evaluate();

            Assert.AreEqual(typeof(List <int>[]), obj.Type);
            List <int>[] arr = obj.GetAs <List <int>[]> ();
            Assert.AreEqual(2, arr.Length);
        }
Example #23
0
        private CSNode RetrieveOneWithCoressponding(CSNode node)
        {
            while (!node.IsExistingRoslynNode)
            {
                node = node.Parent as CSNode;
            }

            return(node);
        }
Example #24
0
        public void Declaration()
        {
            CSNode root = ParseScript("var myVar;");

            CSObject obj = root.Evaluate();

            Assert.AreEqual("myVar", obj.Name);
            Assert.AreEqual(null, obj.Value);
        }
Example #25
0
        public void NewSimpleClass()
        {
            CSNode root = ParseScript("var a = new CSScript.Test.Simple();");

            CSObject obj = root.Evaluate();

            Assert.AreEqual("a", obj.Name);
            Assert.AreEqual(typeof(CSScript.Test.Simple), obj.Value.GetType());
        }
Example #26
0
		public void TestMethodInt () {
			CSNode root = ParseScript (
				"CSScript.Test.Simple s = new CSScript.Test.Simple(55);\n" +
				"int a = s.GetInt();"
			);

			CSObject obj = root.Evaluate ();
			Assert.AreEqual ("a", obj.Name);
			Assert.AreEqual (55, obj.GetAs<int> ());
		}
Example #27
0
        public void TestStaticVariable2()
        {
            CSNode root = ParseScript(
                "CSScript.Test.GenericOne<int>._s = new CSScript.Test.Simple (34);" +
                "int a = CSScript.Test.GenericOne<int>._s._a;");
            CSObject obj = root.Evaluate();

            Assert.AreEqual("a", obj.Name);
            Assert.AreEqual(34, obj.GetAs <int> ());
        }
Example #28
0
        public void TestLocalVariable3()
        {
            CSNode root = ParseScript(
                "CSScript.Test.Simple s = new CSScript.Test.Simple(33);\n" +
                "CSScript.Test.GenericOne<CSScript.Test.Simple> g = new CSScript.Test.GenericOne<CSScript.Test.Simple>(s);\n" +
                "int b = g._pa._a;");
            CSObject obj = root.Evaluate();

            Assert.AreEqual("b", obj.Name);
            Assert.AreEqual(33, obj.GetAs <int> ());
        }
Example #29
0
        public void NewSimpleClassArgsRef()
        {
            CSNode root = ParseScript("var a = new CSScript.Test.Simple(new CSScript.Test.Simple());");

            CSObject obj = root.Evaluate();

            Assert.AreEqual("a", obj.Name);

            Assert.AreEqual(typeof(CSScript.Test.Simple), obj.Value.GetType());
            CSScript.Test.Simple s = obj.Value as CSScript.Test.Simple;
            Assert.AreNotEqual(null, s._i);
        }
Example #30
0
        public void NewSimpleClassArgsString()
        {
            CSNode root = ParseScript("var a = new CSScript.Test.Simple(\"hello\");");

            CSObject obj = root.Evaluate();

            Assert.AreEqual("a", obj.Name);

            Assert.AreEqual(typeof(CSScript.Test.Simple), obj.Value.GetType());
            CSScript.Test.Simple s = obj.Value as CSScript.Test.Simple;
            Assert.AreEqual("hello", s._s);
        }
Example #31
0
   internal CRNode m_pRNode;                    // node information for UDT list used in rcv queue
#endregion

#region constructor and desctructor
        CUDT(CUDT ancestor)
{
   m_pSndBuffer = null;
   m_pRcvBuffer = null;
   m_pSndLossList = null;
   m_pRcvLossList = null;
   m_pACKWindow = null;
   m_pSndTimeWindow = null;
   m_pRcvTimeWindow = null;

   m_pSndQueue = null;
   m_pRcvQueue = null;
   m_pPeerAddr = null;
   m_pSNode = null;
   m_pRNode = null;

   // Initilize mutex and condition variables
   initSynch();

   // Default UDT configurations
   m_iMSS = ancestor.m_iMSS;
   m_bSynSending = ancestor.m_bSynSending;
   m_bSynRecving = ancestor.m_bSynRecving;
   m_iFlightFlagSize = ancestor.m_iFlightFlagSize;
   m_iSndBufSize = ancestor.m_iSndBufSize;
   m_iRcvBufSize = ancestor.m_iRcvBufSize;
   m_Linger = ancestor.m_Linger;
   m_iUDPSndBufSize = ancestor.m_iUDPSndBufSize;
   m_iUDPRcvBufSize = ancestor.m_iUDPRcvBufSize;
   m_iSockType = ancestor.m_iSockType;
   m_iIPversion = ancestor.m_iIPversion;
   m_bRendezvous = ancestor.m_bRendezvous;
   m_iSndTimeOut = ancestor.m_iSndTimeOut;
   m_iRcvTimeOut = ancestor.m_iRcvTimeOut;
   m_bReuseAddr = true;	// this must be true, because all accepted sockets shared the same port with the listener
   m_llMaxBW = ancestor.m_llMaxBW;

   m_pCCFactory = ancestor.m_pCCFactory.clone();
   m_pCC = null;
   m_pCache = ancestor.m_pCache;

   // Initial status
   m_bOpened = false;
   m_bListening = false;
   m_bConnected = false;
   m_bClosing = false;
   m_bShutdown = false;
   m_bBroken = false;
}
Example #32
0
      // Functionality:
      //    initialize a UDT entity and bind to a local address.
      // Parameters:
      //    None.
      // Returned value:
      //    None.

public void open()
{
   CGuard cg = new CGuard(m_ConnectionLock);

   // Initial sequence number, loss, acknowledgement, etc.
   m_iPktSize = m_iMSS - 28;
   m_iPayloadSize = m_iPktSize - CPacket.m_iPktHdrSize;

   m_iEXPCount = 1;
   m_iBandwidth = 1;
   m_iDeliveryRate = 16;
   m_iAckSeqNo = 0;
   m_ullLastAckTime = 0;

   // trace information
   m_StartTime = CClock.getTime();
   m_llSentTotal = m_llRecvTotal = m_iSndLossTotal = m_iRcvLossTotal = m_iRetransTotal = m_iSentACKTotal = m_iRecvACKTotal = m_iSentNAKTotal = m_iRecvNAKTotal = 0;
   m_LastSampleTime = CClock.getTime();
   m_llTraceSent = m_llTraceRecv = m_iTraceSndLoss = m_iTraceRcvLoss = m_iTraceRetrans = m_iSentACK = m_iRecvACK = m_iSentNAK = m_iRecvNAK = 0;
   m_llSndDuration = m_llSndDurationTotal = 0;

   // structures for queue
   if (null == m_pSNode)
      m_pSNode = new CSNode();
   m_pSNode.m_pUDT = this;
   m_pSNode.m_llTimeStamp = 1;
   m_pSNode.m_iHeapLoc = -1;

   if (null == m_pRNode)
      m_pRNode = new CRNode();
   m_pRNode.m_pUDT = this;
   m_pRNode.m_llTimeStamp = 1;
   m_pRNode.m_pPrev = m_pRNode.m_pNext = null;
   m_pRNode.m_bOnList = false;

   m_iRTT = 10 * m_iSYNInterval;
   m_iRTTVar = m_iRTT >> 1;
   m_ullCPUFrequency = CClock.getCPUFrequency();

   // set up the timers
   m_ullSYNInt = m_iSYNInterval * m_ullCPUFrequency;
   
   m_ullACKInt = m_ullSYNInt;
   m_ullNAKInt = (m_iRTT + 4 * m_iRTTVar) * m_ullCPUFrequency;
   m_ullEXPInt = (m_iRTT + 4 * m_iRTTVar) * m_ullCPUFrequency + m_ullSYNInt;
   m_ullMinEXPInt = 100000 * m_ullCPUFrequency;

   CClock.rdtsc(m_ullNextACKTime);
   m_ullNextACKTime += m_ullSYNInt;
   CClock.rdtsc(m_ullNextNAKTime);
   m_ullNextNAKTime += m_ullNAKInt;
   CClock.rdtsc(m_ullNextEXPTime);
   m_ullNextEXPTime += m_ullEXPInt;

   m_iPktCount = 0;
   m_iLightACKCount = 1;

   m_ullTargetTime = 0;
   m_ullTimeDiff = 0;

   // Now UDT is opened.
   m_bOpened = true;
}