001    package escjava.vcGeneration;
002    
003    // TBoolOp = return a boolean and sons are boolean : list(boolean) -> boolean
004    public class TAnyEQ extends TFunction {
005    
006        public void typeTree(){
007            
008            /*
009             * Semantic control
010             */
011    
012            if(sons.size() < 2)
013                TDisplay.err(this, "typeTree()", "Node has a different number of sons = "+sons.size()+" which is < from 2, bizarre...");
014            else
015                // retrieve the son and compare their type
016                {
017                    TNode n1 = getChildAt(0);
018                    TNode n2 = getChildAt(1);
019                    TypeInfo vi1 = n1.getTypeInfo();
020                    TypeInfo vi2 = n2.getTypeInfo();
021                    
022    
023                    if(vi1 == null & vi2 == null)
024                        TDisplay.warn(this, "typeTree()", "Not able to infer type in an AnyEQ node");
025                    else {
026                        if(vi1 == null & vi2 != null) {
027                            TDisplay.info(this, "typeTree()", "Inferring that node "+n1.toString()+ " has type "+vi2.old+" because it's a son of an AnyEQ node which other son has type "+vi2.old);
028                            
029                            n1.setType(vi2, true);
030                        }
031                        else if(vi1 != null & vi2 == null) {
032                            TDisplay.info(this, "typeTree()", "Inferring that node "+n2.toString()+ " has type "+vi1.old+" because it's a son of an AnyEQ node which other son has type "+vi1.old);
033                            n2.setType(vi1, true);
034                        }
035                    }
036    
037                    n1.typeTree();
038                    n2.typeTree();
039                }
040    
041        }
042    
043        public void accept(/*@ non_null @*/ TVisitor v) throws java.io.IOException{
044            v.visitTAnyEQ(this);
045        }
046    
047    }
048