public override void OutAIfThenElseStm(AIfThenElseStm node)
 {
     bool value;
     if (IsConst(node.GetCondition(), out value))
     {
         if (value)
         {
             node.ReplaceBy(node.GetThenBody());
         }
         else
         {
             node.ReplaceBy(node.GetElseBody());
         }
         changedSomething = true;
     }
 }
        public override void OutAIfThenElseStm(AIfThenElseStm node)
        {
            //Check that the type of the exp is not an array
            PType type = data.ExpTypes[node.GetCondition()];
            bool isValid = true;
            if (type is AArrayTempType)
                isValid = false;
            else if (type is ANamedType)
            {
                ANamedType aType = (ANamedType) type;
                if (data.StructTypeLinks.ContainsKey(aType))
                {
                    isValid = false;
                }
            }
            if (!isValid)
            {
                errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText134")));
            }

            base.OutAIfThenElseStm(node);
        }
Пример #3
0
 public override void CaseAIfThenElseStm(AIfThenElseStm node)
 {
     InAIfThenElseStm(node);
     if (node.GetElseBody() != null)
     {
         node.GetElseBody().Apply(this);
     }
     if (node.GetThenBody() != null)
     {
         node.GetThenBody().Apply(this);
     }
     if (node.GetCondition() != null)
     {
         node.GetCondition().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutAIfThenElseStm(node);
 }
 public override void CaseAIfThenElseStm(AIfThenElseStm node)
 {
     Write("if(");
     node.GetCondition().Apply(this);
     Write(")\n");
     node.GetThenBody().Apply(this);
     Write("else\n");
     node.GetElseBody().Apply(this);
 }