Ejemplo n.º 1
0
 public override void VisitForCycleNode(ForCycleNode fc)
 {
     fc.Counter.Visit(this);
     fc.LeftBound.Visit(this);
     fc.RightBound.Visit(this);
     fc.Step.Visit(this);
     fc.Stat.Visit(this);
 }
Ejemplo n.º 2
0
 public override void VisitForCycleNode(ForCycleNode fc)
 {
     Text += IndentStr() + "for ";
     fc.Counter.Visit(this);
     Text += " in (";
     fc.LeftBound.Visit(this);
     Text += ", ";
     fc.RightBound.Visit(this);
     Text += ", ";
     fc.Step.Visit(this);
     Text += ")";
     Text += Environment.NewLine;
     fc.Stat.Visit(this);
 }
Ejemplo n.º 3
0
 public virtual void VisitForCycleNode(ForCycleNode fc)
 {
 }
Ejemplo n.º 4
0
        public override void VisitForCycleNode(ForCycleNode fc)
        {
            Console.WriteLine(Tag + " VisitForCycleNoe");

            fc.Step.Visit(this);

            if (GetLastLine().Accum.StartsWith(TempVariableName))
            {
                GetLastLine().Accum = "lc" + GetLastLine().Label;
            }

            var step = GetLastLine().Accum;

            fc.LeftBound.Visit(this);
            var L = GetLastLine().Accum;

            fc.RightBound.Visit(this);

            if (GetLastLine().Accum.StartsWith(TempVariableName))
            {
                GetLastLine().Accum = "lr" + GetLastLine().Label;
            }
            var R = GetLastLine().Accum;

            var initCounterLine = new ThreeAddrLine();

            initCounterLine.Accum   = fc.Counter.Name;
            initCounterLine.OpType  = ThreeAddrOpType.Assign;
            initCounterLine.RightOp = L;
            initCounterLine.Label   = GenNewLabel();

            Data.Add(initCounterLine);

            var startLoopLabel = GenNewLabel();

            var checkLine = new ThreeAddrLine();

            checkLine.Label   = startLoopLabel;
            checkLine.Accum   = GenNewTemporaryVariable();
            checkLine.LeftOp  = fc.Counter.Name;
            checkLine.OpType  = ToStringHelper.ToString(BinaryOpType.Less);
            checkLine.RightOp = R;

            Data.Add(checkLine);

            var whileLine = new ThreeAddrLine();

            whileLine.Label  = GenNewLabel();
            whileLine.LeftOp = GetLastLine().Accum;
            whileLine.OpType = ThreeAddrOpType.IfGoto;
            Data.Add(whileLine);

            var outsideWhileLine = new ThreeAddrLine();

            outsideWhileLine.Label  = GenNewLabel();
            outsideWhileLine.OpType = ThreeAddrOpType.Goto;
            Data.Add(outsideWhileLine);
            whileLine.RightOp = GenNewLabel();
            fc.Stat.Visit(this);

            var counterIncLine = new ThreeAddrLine();

            counterIncLine.Label   = GenNewLabel();
            counterIncLine.Accum   = fc.Counter.Name;
            counterIncLine.LeftOp  = fc.Counter.Name;
            counterIncLine.OpType  = ToStringHelper.ToString(BinaryOpType.Plus);
            counterIncLine.RightOp = step;
            Data.Add(counterIncLine);


            var gotoStartLine = new ThreeAddrLine();

            gotoStartLine.Label   = GenNewLabel();
            gotoStartLine.OpType  = ThreeAddrOpType.Goto;
            gotoStartLine.RightOp = startLoopLabel;
            Data.Add(gotoStartLine);

            InsertNop();
            outsideWhileLine.RightOp = GetLastLine().Label;
        }
Ejemplo n.º 5
0
 public override void VisitForCycleNode(ForCycleNode fc)
 {
     fc.Stat.Visit(this);
 }