Exemplo n.º 1
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 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);
        }