Exemple #1
0
        private static void AddToDictionary(string astrParentKey, List <ICodeLine> codelines, string astrDictionaryKey, string astrDataKey)
        {
            string    lstrSingleObjectKey = astrParentKey;//lobjChildNode.Attribute("name").Value;
            ICodeLine lobjCodeLine        = Operation.Invoke(Operation.Variable(astrDictionaryKey),
                                                             "SetVal", new OperationConst(lstrSingleObjectKey), Operation.Variable(astrDataKey));

            codelines.Add(lobjCodeLine);
        }
Exemple #2
0
		public ICodeLine Else(ICodeLine firstCodeLine, params ICodeLine[] codeLines)
		{
			ElseCodeLines.Add(firstCodeLine);
			foreach (var codeLine in codeLines)
			{
				ElseCodeLines.Add(codeLine);
			}
			return this;
		}
Exemple #3
0
		public IIfThen Then(ICodeLine firstCodeLine, params ICodeLine[] codeLines)
		{
			ThenCodeLines.Add(firstCodeLine);
			foreach (var codeLine in codeLines)
			{
				ThenCodeLines.Add(codeLine);
			}
			return this;
		}
 public ICodeLine Do(ICodeLine firstCodeLine, params ICodeLine[] codeLines)
 {
     CodeLines.Add(firstCodeLine);
     foreach (var codeLine in codeLines)
     {
         CodeLines.Add(codeLine);
     }
     return(this);
 }
Exemple #5
0
 public IIfThen Then(ICodeLine firstCodeLine, params ICodeLine[] codeLines)
 {
     ThenCodeLines.Add(firstCodeLine);
     foreach (var codeLine in codeLines)
     {
         ThenCodeLines.Add(codeLine);
     }
     return(this);
 }
        private static List <ICodeLine> ProcessSingleElement(XElement aobjSingleChildNode, string aobjParentContainerKey, bool ablnPackInList = false)
        {
            List <ICodeLine> llstCodeLines       = new List <ICodeLine>();
            string           lstrSingleObjectKey = aobjSingleChildNode.Attribute("name").Value;

            //dfo.FunctionBody.Add(CodeLine.Assign(lstrSingleObjectKey, Operation.CreateInstance(typeof(mDictionary))));
            llstCodeLines.Add(CodeLine.Assign("localvar", Operation.CreateInstance(typeof(mDictionary)))); //temporary variable to hold the keyvalue paid within the loop.

            if (ablnPackInList)
            {
                llstCodeLines.Add(CodeLine.CreateVariable(typeof(List <object>), "lst"));
                llstCodeLines.Add(CodeLine.Assign("lst", Operation.CreateInstance(typeof(List <object>))));
            }


            foreach (var lobjChildNode in aobjSingleChildNode.Elements())
            {
                switch (lobjChildNode.Name.LocalName)
                {
                case "assign":
                {
                    string lstrPath = lobjChildNode.Attribute("path").Value;
                    string lstrKey  = lobjChildNode.Attribute("name").Value;
                    llstCodeLines.Add(Operation.Invoke(Operation.Variable("localvar"),
                                                       "SetVal", new OperationConst(lstrKey), Operation.Get(lstrPath)));
                }
                break;

                case "single":
                {
                    llstCodeLines.AddRange(ProcessSingleElement(lobjChildNode, aobjParentContainerKey));
                }
                break;
                }
            }
            // if (firstIteration)
            //if (ablnPackInList)
            //{
            //    llstCodeLines.Add(Operation.Invoke(Operation.Variable("lst"), "Add",
            //        Operation.Variable("localvar")));
            //    llstCodeLines.Add(Operation.Invoke(Operation.Variable(aobjParentContainerKey),
            //        "SetVal", new OperationConst(lstrSingleObjectKey), Operation.Variable("lst")));
            //}
            //else
            {
                ICodeLine lobjCodeLine = Operation.Invoke(Operation.Variable(aobjParentContainerKey),
                                                          "SetVal", new OperationConst(lstrSingleObjectKey), Operation.Variable("localvar"));
                llstCodeLines.Add(lobjCodeLine);
            }
            return(llstCodeLines);
        }
Exemple #7
0
        public void PreParseExpression(ParseContext context)
        {
            //var pl = context.Current;
            CollectionSourceVar.PreParseExpression(context);

            LoopVar =
                // CodeLine.CreateVariable(CollectionSourceVar.ParsedType, "loopvar");
                CodeLine.CreateVariable(CollectionSourceVar.ParsedType.GetGenericArguments().Single(), LoopVarName);
            context.AddLevel();
            LoopVar.PreParseExpression(context);
            foreach (var line in CodeLines)
            {
                line.PreParseExpression(context);
            }

            context.RemoveLevel();
        }
Exemple #8
0
        private static bool _Run()
        {
            bool          result   = true;
            ICodeDocument document = CodeDocument.Create();
            ICodeLine     codeline = CodeLine.Create(document);

            document.AddBefore(codeline);

            result = result && (document.Cursor == codeline);

            IToken tokenFirst = Token.Create(Location.Create("filename", 0, 0, 10), "first", TokenKind.LiteralString);

            codeline.AddBefore(tokenFirst);  // codeline = [(first)]
            result = result && (codeline.Cursor == tokenFirst);
            IToken tokenAfter = Token.Create(Location.Create("filename", 0, 0, 10), "after", TokenKind.LiteralInteger);

            codeline.AddAfter(tokenAfter);                      // codeline = (first)[(after)]
            result = result && (codeline.Cursor == tokenAfter); // we set cursor to added item

            IToken tokenBefore = Token.Create(Location.Create("filename", 0, 0, 10), "before", TokenKind.LiteralFloat);

            codeline.AddBefore(tokenBefore); // codeline = (first)[(before)](after)
            result = result && (codeline.Cursor == tokenBefore);

            codeline.MoveCursorPrev(); // codeline = [(first)](before)(aft
            result = result && (codeline.Cursor == tokenFirst);
            codeline.MoveCursorNext(); // codeline - (first)[(before)](after)
            result = result && (codeline.Cursor == tokenBefore);
            codeline.MoveCursorNext(); // codeline = (first)(before)[(after)]
            result = result && (codeline.Cursor == tokenAfter);

            // now test saturation
            foreach (int i in F.range(0, 6))
            {
                codeline.MoveCursorPrev();
            }
            result = result && (codeline.Cursor == tokenFirst);
            foreach (int i in F.range(0, 6))
            {
                codeline.MoveCursorNext();
            }
            result = result && (codeline.Cursor == tokenAfter);
            return(result);
        }
        private static bool _Run()
        {
            bool          result        = true;
            ICodeDocument document      = CodeDocument.Create();
            ICodeLine     codelineFirst = CodeLine.Create(document);

            document.AddBefore(codelineFirst); // codedocument = [(first)]
            result = result && (document.Cursor == codelineFirst);

            ICodeLine codelineAfter = CodeLine.Create(document);

            document.AddAfter(codelineAfter);  // codedocument = (first)[(after)]
            result = result && (document.Cursor == codelineAfter);

            ICodeLine codelineBefore = CodeLine.Create(document);

            document.AddBefore(codelineBefore); // codedocument = (first)[(before)](after)
            result = result && (document.Cursor == codelineBefore);

            document.MoveCursorPrev(); // codedocument = [(first)](before)(after)
            result = result && (document.Cursor == codelineFirst);
            document.MoveCursorNext(); // codedocument = (first)[(before)](after)
            result = result && (document.Cursor == codelineBefore);
            document.MoveCursorNext(); // codedocument = (first)(before)[(after)]
            result = result && (document.Cursor == codelineAfter);

            // Now test saturation
            foreach (int i in F.range(0, 6))
            {
                document.MoveCursorPrev();
            }
            result = result && (document.Cursor == codelineFirst);
            foreach (int i in F.range(0, 6))
            {
                document.MoveCursorNext();
            }
            result = result && (document.Cursor == codelineAfter);


            return(result);
        }
 public IFunctionReturn WithBody(ICodeLine firstCodeLine, params ICodeLine[] codeLines)
 {
     if (firstCodeLine is If)
     {
         _codeLines.Add(GetRootIf(firstCodeLine as If));
     }
     else
     {
         _codeLines.Add(firstCodeLine);
     }
     foreach (var codeLine in codeLines)
     {
         if (codeLine is If)
         {
             _codeLines.Add(GetRootIf(codeLine as If));
         }
         else
         {
             _codeLines.Add(codeLine);
         }
     }
     return(this);
 }
Exemple #11
0
 public void AddAfter(ICodeLine codeline)
 {
     this.codelines.AddAfter(codeline);
 }
Exemple #12
0
 public void AddBefore(ICodeLine codeline)
 {
     this.codelines.AddBefore(codeline);
 }
Exemple #13
0
 public int Line(ICodeLine codeline)
 {
     return(-1);
 }