Beispiel #1
0
 public void AcceptLoopBlock(LoopBlock stmt)
 {
     stmt.Body.Accept(this);
 }
Beispiel #2
0
 public virtual void Break(LoopBlock loop)
 {
     BreakLoopStatement stmt = new BreakLoopStatement()
     {
         Loop = loop
     };
     _cstack.Peek().Statements.Add(stmt);
 }
Beispiel #3
0
 public virtual void Continue(LoopBlock loop)
 {
     ContinueLoopStatement stmt = new ContinueLoopStatement()
     {
         Loop = loop
     };
     _cstack.Peek().Statements.Add(stmt);
 }
Beispiel #4
0
 public void Continue(LoopBlock loop)
 {
     Contract.Requires(loop != null);
 }
Beispiel #5
0
 public virtual LoopBlock Loop()
 {
     LoopBlock block = new LoopBlock();
     CompoundStatement body = new CompoundStatement();
     block.Body = body;
     _sstack.Push(block);
     _cstack.Peek().Statements.Add(block);
     _cstack.Push(body);
     return block;
 }
Beispiel #6
0
 private void GenerateGenericLoop(LoopBlock loop)
 {
     _tw.WriteLine("while(true)");
     GenerateLoop(loop);
     if (loop.Trailer != null)
         loop.Trailer.Accept(this);
 }
Beispiel #7
0
 public void Break(LoopBlock loop)
 {
     Contract.Requires(loop != null);
 }
 public void AcceptLoopBlock(LoopBlock stmt)
 {
     stmt.Body.Accept(this);
     if (stmt.CounterVariable != null)
         RequireType(stmt.CounterVariable.Type, _design);
     if (stmt.HeadCondition != null)
         Resolve(stmt.HeadCondition);
     if (stmt.Initializer != null)
         stmt.Initializer.Accept(this);
     if (stmt.Trailer != null)
         stmt.Trailer.Accept(this);
 }
Beispiel #9
0
 public void AcceptLoopBlock(LoopBlock stmt)
 {
     stmt.Body.Successor = stmt.Body;
     stmt.Body.Accept(this);
 }
Beispiel #10
0
            public void AcceptLoopBlock(LoopBlock stmt)
            {
                if (stmt.Label != null)
                    _tw.Write(stmt.Label + ": ");
                GenerateComments(stmt);

                LoopBlock whileLoop = stmt.AsWhileLoop();
                if (whileLoop != null)
                {
                    GenerateWhileLoop(whileLoop);
                }
                else
                {
                    GenerateLoop(stmt);
                }
            }
 public override void AcceptLoopBlock(LoopBlock stmt)
 {
     Success = false;
 }
Beispiel #12
0
 private void GenerateLoop(LoopBlock stmt)
 {
     _tw.WriteLine("loop");
     _tw.Indent++;
     stmt.Body.AcceptIfEnabled(this);
     _tw.Indent--;
     _tw.Write("end loop");
     if (stmt.Label != null)
         _tw.Write(" " + stmt.Label);
     _tw.WriteLine(";");
 }
Beispiel #13
0
 private void GenerateWhileLoop(LoopBlock loop)
 {
     _tw.Write("while ");
     _tw.Write(loop.HeadCondition.ToString(_vhdg));
     _tw.Write(" ");
     GenerateLoop(loop);
     loop.Trailer.Accept(this);
 }
Beispiel #14
0
            private void GenerateForLoop(LoopBlock loop)
            {
                _tw.Write("for ");
                _tw.Write(_vhdg.GetLiteralNotation()(loop.CounterVariable, LiteralReference.EMode.Direct));
                _tw.Write(" in ");
                _tw.Write(loop.CounterStart.ToString(_vhdg));
                Expression counterStop = loop.CounterStop;
                switch (loop.CounterDirection)
                {
                    case LoopBlock.ECounterDirection.IncrementOne:
                        _tw.Write(" to ");
                        break;

                    case LoopBlock.ECounterDirection.DecrementOne:
                        _tw.Write(" downto ");
                        break;

                    default:
                        throw new NotImplementedException();
                }
                _tw.Write(counterStop.ToString(_vhdg));
                if (loop.CounterLimitKind == LoopBlock.ELimitKind.ExcludingStopValue)
                {
                    switch (loop.CounterDirection)
                    {
                        case LoopBlock.ECounterDirection.IncrementOne:
                            _tw.Write(" - 1");
                            break;

                        case LoopBlock.ECounterDirection.DecrementOne:
                            _tw.Write(" + 1");
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                }
                _tw.Write(" ");
                GenerateLoop(loop);
                loop.Trailer.Accept(this);
            }
Beispiel #15
0
 public void AcceptLoopBlock(LoopBlock stmt)
 {
     throw new NotConvertibleToInlineExpressionException();
 }
Beispiel #16
0
        public void AcceptLoopBlock(LoopBlock stmt)
        {
            stmt.Body.Accept(this);
            for (int i = 0; i < stmt.Locals.Count; i++)
            {
                stmt.Locals[i] = (IStorableLiteral)Lookup((Literal)stmt.Locals[i]);
            }

        }
Beispiel #17
0
 internal override Statement CloneInternal(CloneContext ctx)
 {
     LoopBlock loop = new LoopBlock();
     ctx.Map(this, loop);
     loop.Body = Body.GetClone(ctx);
     return loop;
 }
Beispiel #18
0
            //      ALTERADA !!!
            private void GenerateForLoop(LoopBlock loop)
            {
                _tw.Write("for(");
                _tw.Write(loop.Initializer.Value.ToString(_SysCg));
                _tw.Write("; ");
                _tw.Write(loop.HeadCondition.ToString(_SysCg));
                _tw.Write("; ");
                _tw.Write(loop.Step.Value.ToString(_SysCg));
                _tw.Write(")");

                Expression counterStop = loop.CounterStop;
                GenerateLoop(loop);
                loop.Trailer.Accept(this);
            }