Exemplo n.º 1
0
        void generateRightExpression(Expression left)
        {
            LabelTarget label = Expression.Label(typeof(void));
            int         i     = ExpressionsList.GetList().Count;

            foreach (ITree node in _rightExpression)
            {
                if (node.getMethodName() == Constants.ASSIGNMENT_STATMENT)
                {
                    AssignmentProcessor assignmenterProcessor = new AssignmentProcessor();
                    assignmenterProcessor.process((AssignmentStatment)node);
                }
                else if (node.getMethodName() == Constants.READ_STATMENT)
                {
                    ReaderProcessor readerProcessor = new ReaderProcessor();
                    readerProcessor.process((ReadStatment)node);
                }
                else if (node.getMethodName() == Constants.WRITE_STATMENT)
                {
                    WriterProcessor writeProcessor = new WriterProcessor();
                    writeProcessor.process((WriteStatment)node);
                }
                else if (node.getMethodName() == Constants.IF_STATMENT)
                {
                    IfStatmentProcessor ifStatmentProcessor = new IfStatmentProcessor();
                    ifStatmentProcessor.process((IfStatment)node);
                }
                else if (node.getMethodName() == Constants.WHILE_STATMENT)
                {
                    WhileProcessor whileProcessor = new WhileProcessor();
                    whileProcessor.process((WhileStatment)node);
                }
            }
            List <Expression> list = new List <Expression>();
            int x = i;

            while (ExpressionsList.GetList().Count != i)
            {
                list.Add(ExpressionsList.GetElement(x));
                ExpressionsList.RemoveElement(x);
            }
            Expression rigth     = Expression.Block(list);
            var        exitLabel = Expression.Label();

            var block =
                Expression.Loop(
                    Expression.IfThenElse(
                        left,
                        rigth, Expression.Break(label)), label);

            ExpressionsList.AddExpression(block);
        }
Exemplo n.º 2
0
        Expression generateRightExpression(List <object> expression)
        {
            int i = ExpressionsList.GetList().Count;

            foreach (ITree node in expression)
            {
                if (node.getMethodName() == Constants.ASSIGNMENT_STATMENT)
                {
                    AssignmentProcessor assignmenterProcessor = new AssignmentProcessor();
                    assignmenterProcessor.process((AssignmentStatment)node);
                }
                else if (node.getMethodName() == Constants.READ_STATMENT)
                {
                    ReaderProcessor readerProcessor = new ReaderProcessor();
                    readerProcessor.process((ReadStatment)node);
                }
                else if (node.getMethodName() == Constants.WRITE_STATMENT)
                {
                    WriterProcessor writeProcessor = new WriterProcessor();
                    writeProcessor.process((WriteStatment)node);
                }
                else if (node.getMethodName() == Constants.IF_STATMENT)
                {
                    IfStatmentProcessor ifStatmentProcessor = new IfStatmentProcessor();
                    ifStatmentProcessor.process((IfStatment)node);
                }
                else if (node.getMethodName() == Constants.WHILE_STATMENT)
                {
                    WhileProcessor whileProcessor = new WhileProcessor();
                    whileProcessor.process((WhileStatment)node);
                }
            }
            List <Expression> list = new List <Expression>()
            {
                Expression.Empty()
            };
            int x = i;

            while (ExpressionsList.GetList().Count != i)
            {
                list.Add(ExpressionsList.GetElement(x));
                ExpressionsList.RemoveElement(x);
            }
            return(Expression.Block(list));
        }