Пример #1
0
        public override void Translate(VarTable varTable, LabelStack labelStack, List <FourExp> fourExpList)
        {
            string label = labelStack.NewLabel();

            fourExpList.Add(FourExpFac.GenLabel(label));
            statement.Translate(varTable, labelStack, fourExpList);
            string condition = expression.GetValue(varTable, labelStack, fourExpList);

            fourExpList.Add(FourExpFac.GenJne(condition, 0 + "", label));
        }
Пример #2
0
 public override void Translate(VarTable varTable, LabelStack labelStack, List <FourExp> fourExpList)
 {
     if (statement1 == null)
     {
         string label     = labelStack.NewLabel();
         string condition = expression.GetValue(varTable, labelStack, fourExpList);
         fourExpList.Add(FourExpFac.GenJe(condition, 0 + "", label));
         statement1.Translate(varTable, labelStack, fourExpList);
         fourExpList.Add(FourExpFac.GenLabel(label));
     }
     else
     {
         string label1    = labelStack.NewLabel();
         string label2    = labelStack.NewLabel();
         string condition = expression.GetValue(varTable, labelStack, fourExpList);
         fourExpList.Add(FourExpFac.GenJe(condition, 0 + "", label1));
         statement1.Translate(varTable, labelStack, fourExpList);
         fourExpList.Add(FourExpFac.GenJmp(label2));
         fourExpList.Add(FourExpFac.GenLabel(label1));
         statement2.Translate(varTable, labelStack, fourExpList);
         fourExpList.Add(FourExpFac.GenLabel(label2));
     }
 }