コード例 #1
0
 public override void OutABinopExp(ABinopExp node)
 {
     if (node.GetBinop() is AEqBinop || node.GetBinop() is ANeBinop)
     {
         if (node.GetLeft() is ANullExp || node.GetRight() is ANullExp)
         {
             if (node.GetLeft() is ANullExp)
             {
                 //Swap left and right
                 PExp temp = node.GetLeft();
                 node.SetLeft(node.GetRight());
                 node.SetRight(temp);
             }
             PExp exp = node.GetLeft();
             PType type = data.ExpTypes[exp];
             if (type is APointerType)
             {
                 if (node.GetBinop() is ANeBinop)
                 {
                     //Convert a != null to !(a == null)
                     AUnopExp unop = new AUnopExp(new AComplementUnop(new TComplement("!")), null);
                     node.ReplaceBy(unop);
                     unop.SetExp(node);
                     node.SetBinop(new AEqBinop(new TEq("==")));
                     data.ExpTypes[unop] = new ANamedType(new TIdentifier("bool"), null);
                 }
                 if (Util.IsIntPointer(node, ((APointerType)type).GetType(), data))
                 {
                     bool add = true;
                     foreach (PType pType in TypesWithIdentifierArray)
                     {
                         if (Util.TypesEqual(((APointerType)type).GetType(), pType, data))
                         {
                             add = false;
                             break;
                         }
                     }
                     if (add)
                         TypesWithIdentifierArray.Add(((APointerType)type).GetType());
                 }
             }
         }
     }
 }