public override void OutAIfThenStm(AIfThenStm node)
 {
     bool value;
     if (IsConst(node.GetCondition(), out value))
     {
         if (value)
         {
             node.ReplaceBy(node.GetBody());
         }
         else
         {
             node.Parent().RemoveChild(node);
         }
         changedSomething = true;
     }
 }
        public override void OutAIfThenStm(AIfThenStm 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.OutAIfThenStm(node);
        }
Ejemplo n.º 3
0
 public override void CaseAIfThenStm(AIfThenStm node)
 {
     InAIfThenStm(node);
     if (node.GetBody() != null)
     {
         node.GetBody().Apply(this);
     }
     if (node.GetCondition() != null)
     {
         node.GetCondition().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutAIfThenStm(node);
 }
 public override void CaseAIfThenStm(AIfThenStm node)
 {
     Write("if(");
     node.GetCondition().Apply(this);
     Write(")\n");
     node.GetBody().Apply(this);
 }