Changeset 193

Show
Ignore:
Timestamp:
10/19/09 18:13:56 (5 weeks ago)
Author:
lb
Message:
 
Location:
trunk/cpp_analysis/src/xtc/lang/c4
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/cpp_analysis/src/xtc/lang/c4/C4.java

    r183 r193  
    7272                                        .word("extract", "optionExtract", 
    7373                                            false, "Extract everything related to one configuration option") 
     74                                        .word("featureName", "optionFeatureName", 
     75                                            false, "The name of the feature that is going to be extracted") 
    7476                                        .bool("DBResults", "dbResults",  
    7577                                            false, "Store the Results of the analysis into a DB") 
     
    117119      if(runtime.hasValue("optionExtract")) { 
    118120        tmp.setExtract(runtime.getString("optionExtract")); 
     121      } 
     122 
     123      if(runtime.hasValue("optionFeatureName")) { 
     124        tmp.setFeatureName(runtime.getString("optionFeatureName")); 
    119125      } 
    120126       
  • trunk/cpp_analysis/src/xtc/lang/c4/C4Core.rats

    r186 r193  
    470470generic DirectDeclarator := 
    471471    <NewFunction>   DirectDeclarator void:"(":Symbol  
    472                                      PushScope ParameterTypeList 
    473                                      void:")":Symbol ParameterContext  
     472                                     {yyState.setInFunctionDecl();} PushScope ParameterTypeList 
     473                                     {yyState.unsetInFunctionDecl();} void:")":Symbol ParameterContext  
    474474                                     @FunctionDeclarator 
    475475  / <OldFunction>   DirectDeclarator void:"(":Symbol 
  • trunk/cpp_analysis/src/xtc/lang/c4/C4Extractor.java

    r131 r193  
    3030 
    3131 
     32  /** The Debug extraction Flag **/ 
     33  private boolean DBG_EXTRACT = false; 
     34  /** The feature to create **/ 
     35  private String featureName; 
     36   
     37  /** The Configuration option to extract **/ 
     38  private String configOption; 
     39  /** The list of nodes  marked as to be extracted by the CPP Analyzer **/ 
     40  private ArrayList<C4Extractable> toExtract; 
     41 
     42  /** The original Tree before any extraction **/ 
     43  private Node tree;  
     44  /** The new Tree with everything extracted **/ 
     45  private Node newTree; 
     46  /** The name of the top level file to be extracted **/ 
     47  /** We do not extract anything from the included header files **/ 
     48  private String topLevel; 
     49   
     50  /** The collection of functionDefinitions extracted from the analysis 
     51   */ 
     52  private Map<String, GNode> functionDefinitions; 
     53 
     54  /** The collection of functionDefinitions after all the modification 
     55   *  populated during the extraction process 
     56   */ 
     57  private Map<String, GNode> modifiedFunctionDefinitions; 
     58 
     59  private Node father; 
     60 
     61  public C4Extractor(String featureName, String optExtract, ArrayList<C4Extractable> toExtract, Node unit, String fileName, Map<String, GNode> functionDefinitions ) { 
     62    this.featureName = featureName;  
     63    configOption   = optExtract; 
     64    this.toExtract      = toExtract; 
     65    tree           = unit; 
     66    topLevel       = fileName; 
     67    this.functionDefinitions = functionDefinitions; 
     68    modifiedFunctionDefinitions = new HashMap<String, GNode> (); 
     69  } 
     70 
     71 
    3272  static Node build(Formatting n, HashMap<Integer, Object> newChildren) { 
    3373    Formatting result = null ; 
     
    65105  } 
    66106 
    67  
    68   /** The Debug extraction Flag **/ 
    69   private boolean DBG_EXTRACT = false; 
    70   /** The Configuration option to extract **/ 
    71   private String configOption; 
    72   /** The list of nodes  marked as to be extracted by the CPP Analyzer **/ 
    73   private ArrayList<GNode> nodesToExtract; 
    74   /** The original Tree before any extraction **/ 
    75   private Node tree;  
    76   /** The new Tree with everything extracted **/ 
    77   private Node newTree; 
    78   /** The name of the top level file to be extracted **/ 
    79   /** We do not extract anything from the included header files **/ 
    80   String topLevel; 
    81  
    82   private Node father; 
    83  
    84   public C4Extractor(String optExtract, ArrayList<GNode> toExtract, Node unit, String fileName ) { 
    85     configOption   = optExtract; 
    86     nodesToExtract = toExtract; 
    87     tree           = unit; 
    88     topLevel       = fileName; 
    89  
    90   } 
    91  
    92107  private Node extractVisitor(Node n) { 
    93108    //Node modified = GNode.create((GNode)n); 
     
    111126        Node child = (Node) n.get(i); 
    112127 
    113         if(nodesToExtract.contains(child)) { 
     128        if(isToBeExtracted(child)) { 
    114129          if(DBG_EXTRACT) 
    115130            System.out.println("We are going to remove child number : " + index); 
     
    164179 
    165180    if(n instanceof GNode) { 
    166  
    167181      modified =  GNode.create(name, newChildren.size()); 
    168182 
     
    172186        modified.add(k, newChildren.get(bigK)); 
    173187      } 
     188 
     189      if (name == "FunctionDefinition") { 
     190          //We look for the name of this function 
     191          if (functionDefinitions.containsValue(n)) { 
     192            for (String funcName: functionDefinitions.keySet()) { 
     193                if(functionDefinitions.get(funcName) == n) { 
     194                    modifiedFunctionDefinitions.put(funcName, (GNode)modified); 
     195                } 
     196            } 
     197         } 
     198      } 
     199 
    174200    } 
    175201    else if( (n instanceof Formatting)) { 
     
    231257        fne.printStackTrace(); 
    232258    } 
    233   } 
    234  
     259   
     260    //Weaving 
     261    weave(newTree); 
     262      
     263   
     264  } 
     265 
     266 
     267 
     268  private ArrayList<C4Extractable> lookupToWeave(String funcName) { 
     269    ArrayList<C4Extractable> toWeave = new ArrayList<C4Extractable>(); 
     270     
     271    for(C4Extractable item : toExtract) { 
     272        if(item.getFuncName().equals(funcName)) { 
     273            toWeave.add(item); 
     274        } 
     275    } 
     276    return toWeave; 
     277  } 
     278 
     279 
     280  private void weave(Node newTree) { 
     281      Printer console = new Printer(new BufferedWriter(new OutputStreamWriter(System.out)));  
     282      new ParseTreePrinter(console).dispatch(tree); 
     283      System.out.println("\n\nABeforeEXTRACTION"); 
     284      console.format(newTree, false).pln().flush(); 
     285 
     286  
     287      new Visitor() { 
     288        public void visitFunctionDefinition(GNode n ) { 
     289          if (modifiedFunctionDefinitions.containsValue(n)) { 
     290            for (String funcName: modifiedFunctionDefinitions.keySet()) { 
     291                if(modifiedFunctionDefinitions.get(funcName) == n) { 
     292                    ArrayList<C4Extractable> toWeave = lookupToWeave(funcName);  
     293                    n.getGeneric(5).add(0,blockWrapping(toWeave)); 
     294                } 
     295            } 
     296         } 
     297  
     298        } 
     299 
     300        public void visit(Node n) { 
     301            for(int i=0; i < n.size(); i++) { 
     302                if(n.get(i) instanceof Node) { 
     303                    dispatch(n.getNode(i)); 
     304                } 
     305            } 
     306        } 
     307 
     308      }.dispatch(newTree); 
     309       
     310       
     311 
     312      System.out.println("AFTER WEAVING PRINTER\n\n"); 
     313      new C4ParseTreePrinter(console).dispatch(newTree); 
     314      console.flush(); 
     315      System.out.println("\n#######\n"); 
     316  
     317 
     318    } 
     319 
     320  private boolean isToBeExtracted(Node n) { 
     321        for(C4Extractable toBeExtracted : toExtract) { 
     322           if(toBeExtracted.getGNodeToExtract() == n) { 
     323               return true; 
     324            } 
     325        } 
     326         
     327        return false; 
     328    } 
     329 
     330  private Node blockWrapping(ArrayList<C4Extractable> toWeave) { 
     331    GNode tmpGNodeBefore = GNode.create("RawFeatureBefore"); 
     332    GNode tmpGNodeAfter = GNode.create("RawFeatureAfter"); 
     333     
     334    for(C4Extractable item: toWeave) { 
     335 
     336        if(item.getKind().equals("before")) 
     337            tmpGNodeBefore.add(item.getGNodeToExtract()); 
     338        else if(item.getKind().equals("after")) 
     339            tmpGNodeAfter.add(item.getGNodeToExtract()); 
     340  
     341    }  
     342 
     343    GNode featureBlock = GNode.create("FeatureBlockStatement"); 
     344     
     345    if(tmpGNodeBefore.size() > 0) {  
     346        Formatting roundBefore = Formatting.round1(new Token("_before_" + featureName + " { \n\t"), tmpGNodeBefore,new Token("\n    }\n")); 
     347        featureBlock.add(roundBefore); 
     348    } 
     349    if(tmpGNodeAfter.size() > 0) { 
     350    Formatting roundAfter = Formatting.round1(new Token("_after_" + featureName + " { \n\t"), tmpGNodeAfter,new Token("\n    }\n")); 
     351        featureBlock.add(roundAfter); 
     352    } 
     353 
     354    return featureBlock; 
     355 
     356  } 
    235357} 
  • trunk/cpp_analysis/src/xtc/lang/c4/C4MacrosManager.java

    r183 r193  
    1616 
    1717        /** A map of the object Macros **/ 
    18         private Map<String, Object> objectMacros; 
     18        private Map<String, Node> objectMacros; 
    1919 
    2020        /** A map of the function Macros **/ 
    21         private Map<String, Object> functionMacros; 
     21        private Map<String, Node> functionMacros; 
    2222 
    2323        /** A map of the various definition of removed Macros **/ 
    24         private Map<String, ArrayList<Object>> removedMacros; 
     24        /** Contains the complete story associated with this particular Macro **/ 
     25        private Map<String, ArrayList<Node>> oldDefinitionsMacros; 
     26         
     27        /** A map of the current definition of each macro defined **/ 
     28        private Map<String, Node> currentDefinitionMacros; 
     29        private Map<String, Integer> currentDefinitionIndex; 
    2530 
    2631        /** To remove all the macros defined in the previous branch...*/ 
    2732        private ArrayList<ArrayList <String>> branchMacros; 
    28         private ArrayList<Map<String, Object>> branchMacrosFunction; 
    29         private ArrayList<Map<String, Object>> branchMacrosObject; 
    30         private Map<String, Object> lastBranchMacrosObject; 
    31         private Map<String, Object> lastBranchMacrosFunction; 
     33        private ArrayList<Map<String, Node>> branchMacrosFunction; 
     34        private ArrayList<Map<String, Node>> branchMacrosObject; 
     35        private Map<String, Node> lastBranchMacrosObject; 
     36        private Map<String, Node> lastBranchMacrosFunction; 
    3237        private ArrayList<String> lastBranchMacros; 
    3338        private ArrayList<String> macro_keyword_global; 
     
    4045 
    4146        public C4MacrosManager() { 
    42                 this.removedMacros   = new HashMap<String, ArrayList<Object>>(); 
    43  
    44                 this.objectMacros    = new HashMap<String, Object>(); 
    45                 this.functionMacros  = new HashMap<String, Object>(); 
    46                 this.branchMacrosFunction = new ArrayList<Map<String, Object>>(); 
    47                 this.branchMacrosObject = new ArrayList<Map<String, Object>>(); 
     47                this.oldDefinitionsMacros   = new HashMap<String, ArrayList<Node>>(); 
     48 
     49                this.objectMacros    = new HashMap<String, Node>(); 
     50                this.functionMacros  = new HashMap<String, Node>(); 
     51                this.branchMacrosFunction = new ArrayList<Map<String, Node>>(); 
     52                this.branchMacrosObject = new ArrayList<Map<String, Node>>(); 
    4853                this.branchMacros = new ArrayList<ArrayList<String>>(); 
    4954                this.lastBranchMacros = new ArrayList<String>(); 
     
    7580                String name = null;  
    7681 
     82                 
    7783                if (objMacro.size() > 1) { 
    7884                        value = objMacro.getGeneric(1); 
     
    8187                        name = objMacro.getGeneric(0).getString(0); 
    8288                } 
    83  
     89                 
     90                 
     91                if(!oldDefinitionsMacros.containsKey(name)) { 
     92                        oldDefinitionsMacros.put(name, new ArrayList<Node>()); 
     93                } 
     94                 
     95                oldDefinitionsMacros.get(name).add(value); 
     96                 
    8497                if ( this.lastBranchMacrosObject != null ) { 
    8598                        this.lastBranchMacrosObject.put(name,value); 
     
    100113         */ 
    101114        protected void addFunctionMacro(GNode funcMacro) { 
    102  
     115                String name = funcMacro.getString(0); 
     116                Node value  = funcMacro; 
     117                 
     118                if(!oldDefinitionsMacros.containsKey(name)) { 
     119                        oldDefinitionsMacros.put(name, new ArrayList<Node>()); 
     120                } 
     121                 
     122                oldDefinitionsMacros.get(name).add(value); 
     123                 
    103124                if( this.lastBranchMacrosFunction != null) { 
    104                         this.lastBranchMacrosFunction.put(funcMacro.getString(0),funcMacro); 
     125                        this.lastBranchMacrosFunction.put(name, value); 
     126                         
    105127                        if( DBG_MM ) 
    106128                                System.out.println("@FM Putting Last " + funcMacro.getString(0) ); 
    107129                } 
    108130                else {  
    109                         this.functionMacros.put(funcMacro.getString(0), funcMacro); 
     131                        this.functionMacros.put(name, value); 
     132                         
    110133                        if( DBG_MM ) 
    111134                                System.out.println("@FM Putting Functions " + funcMacro.getString(0) ); 
     
    135158 
    136159                if(null == lastBranchMacrosFunction) 
    137                         lastBranchMacrosFunction = new HashMap<String, Object>();  
     160                        lastBranchMacrosFunction = new HashMap<String, Node>();  
    138161                else { 
    139                         HashMap<String, Object> tmp = new HashMap<String, Object>(); 
     162                        HashMap<String, Node> tmp = new HashMap<String, Node>(); 
    140163                        tmp.putAll(lastBranchMacrosFunction); 
    141164                        lastBranchMacrosFunction = tmp; 
     
    154177                //TODO GETTING RID OF ALL THESE LAST BRANCHES AND BRANCHES AND NESTING 
    155178                if(null == lastBranchMacrosObject) 
    156                         lastBranchMacrosObject = new HashMap<String, Object>(); 
     179                        lastBranchMacrosObject = new HashMap<String, Node>(); 
    157180                else { 
    158                         HashMap<String, Object> tmp = new HashMap<String, Object>(); 
     181                        HashMap<String, Node> tmp = new HashMap<String, Node>(); 
    159182                        tmp.putAll(lastBranchMacrosObject); 
    160183                        lastBranchMacrosObject = tmp; 
     
    222245 
    223246                if(branchMacrosFunction.size()> 0 && branchMacrosObject.size()> 0) { 
    224                         Map<String, Object> lastBranchMacrosFlushed; 
     247                        Map<String, Node> lastBranchMacrosFlushed; 
    225248 
    226249                        lastBranchMacrosFlushed = branchMacrosObject.get(branchMacrosObject.size()-1); 
     
    317340                                return false; 
    318341                        if(om.getGeneric(0).getName().equals("ObjectMacroValueSupported")){ 
    319                                 if(om.getGeneric(0).get(0) instanceof GNode) { 
     342                                if(om.getGeneric(0).get(0) instanceof Node) 
     343                if(om.getGeneric(0).getNode(0).strip() instanceof GNode) { 
    320344                                        GNode potentialPrimaryId = om.getGeneric(0).getGeneric(0); 
    321345                                        if(potentialPrimaryId.getName().equals("PrimaryIdentifier")) { 
     
    346370        public void removeMacro(String macroName) { 
    347371                if(isMacro(macroName)) { 
    348                         if(!removedMacros.containsKey(macroName)) 
    349                                 removedMacros.put(macroName, new ArrayList<Object>()); 
    350  
    351                         if(functionMacros.containsKey(macroName)) { 
    352                                 removedMacros.get(macroName).add(functionMacros.get(macroName)); 
    353                                 functionMacros.remove(macroName); 
     372                 
     373                        if(!oldDefinitionsMacros.containsKey(macroName)) 
     374                                oldDefinitionsMacros.put(macroName, new ArrayList<Node>()); 
     375                         
     376                        if(isFunctionMacro(macroName)) { 
     377                                if(lastBranchMacrosFunction != null) { 
     378                                        if(lastBranchMacrosFunction.containsKey(macroName)) { 
     379                                                //oldDefinitionsMacros.get(macroName).add(lastBranchMacrosFunction .get(macroName)); 
     380                                                lastBranchMacrosFunction.remove(macroName); 
     381                                        } 
     382                                } 
     383                                else if(functionMacros.containsKey(macroName)) { 
     384                                        //oldDefinitionsMacros.get(macroName).add(functionMacros.get(macroName)); 
     385                                        functionMacros.remove(macroName); 
     386                                } 
     387                                 
     388                        } else if(isObjectMacro(macroName)) { 
     389                                if(lastBranchMacrosObject != null) { 
     390                                        if(lastBranchMacrosObject.containsKey(macroName)) { 
     391                                                //oldDefinitionsMacros.get(macroName).add(lastBranchMacrosObject .get(macroName)); 
     392                                                lastBranchMacrosObject.remove(macroName); 
     393                                        } 
     394                                 
     395                                } 
     396                                else if(objectMacros.containsKey(macroName)) { 
     397                                        //oldDefinitionsMacros.get(macroName).add(objectMacros.get(macroName)); 
     398                                        objectMacros.remove(macroName); 
     399                                } 
     400                                 
    354401                        } 
    355                         else if(objectMacros.containsKey(macroName)) { 
    356                                 removedMacros.get(macroName).add(objectMacros.get(macroName)); 
    357                                 objectMacros.remove(macroName); 
    358                         } 
    359402                } 
    360403        } 
     
    364407         * Gets the map of the removed macros, removed by undef 
    365408         */ 
    366         public Map<String, ArrayList<Object>> getRemovedMacros() { 
    367                 return removedMacros; 
     409        public Map<String, ArrayList<Node>> getRemovedMacros() { 
     410                return oldDefinitionsMacros; 
    368411        } 
    369412 
     
    407450                        isfuncMacro =  (functionMacros.containsKey(macroName) || lastBranchMacrosFunction.containsKey(macroName)); 
    408451                else isfuncMacro = (functionMacros.containsKey(macroName) ); 
    409                 if( DBG_MM ) 
     452                 
     453        if( DBG_MM ) 
    410454                        System.out.println("IS FUNCTION MACRO " + macroName + " ? " + isfuncMacro); 
    411455                return isfuncMacro; 
     
    428472                                macroNode = getMacro(lastBranchMacrosFunction, macroName); 
    429473                        } 
    430                 } 
    431                 if(functionMacros.containsKey(macroName)) { 
     474                } else if(functionMacros.containsKey(macroName)) { 
    432475                        macroNode = getMacro(functionMacros, macroName); 
    433476                } 
     
    437480                                macroNode = getMacro(lastBranchMacrosObject, macroName); 
    438481                        } 
    439                 } 
    440  
    441                 if(objectMacros.containsKey(macroName)) { 
     482                } else if(objectMacros.containsKey(macroName)) { 
    442483                        macroNode = getMacro(objectMacros, macroName); 
    443484                } 
     
    452493         * @return The node associated with the macroName 
    453494         */ 
    454         public Node getMacro(Map<String, Object> macrosMap, String macroName) { 
    455                 return (Node) macrosMap.get(macroName); 
     495        public Node getMacro(Map<String, Node> macrosMap, String macroName) { 
     496                return macrosMap.get(macroName); 
    456497        } 
    457498 
     
    479520                        System.out.println('\t' + functionMacro); 
    480521        } 
     522         
     523         
     524        public void updateDefine(String macroName) { 
     525                if(!currentDefinitionIndex.containsKey(macroName)){ 
     526                   currentDefinitionIndex.put(macroName, 0);     
     527                } else { 
     528                        currentDefinitionIndex.put(macroName, currentDefinitionIndex.get(macroName) + 1); 
     529                } 
     530                 
     531                currentDefinitionMacros.put(macroName, oldDefinitionsMacros.get(macroName).get(0)); 
     532        } 
     533         
     534        public void undef(String macroName) { 
     535                //The macro that we undef is not defined 
     536                currentDefinitionMacros.put(macroName, null); 
     537 
     538        } 
     539         
     540         
    481541} 
  • trunk/cpp_analysis/src/xtc/lang/c4/C4State.java

    r183 r193  
    10231023 
    10241024                if(inMacroFlag) { 
     1025 
    10251026                        //We're in a Macro... The parameters could be types... 
    10261027                        //TODO improve the parsing, to actually check whether all can be types... 
  • trunk/cpp_analysis/src/xtc/lang/c4/CPPAnalyzer.java

    r183 r193  
    6464 
    6565                /** The debug level. */ 
    66                 private static final int DEBUG = 1; 
     66                private static final int DEBUG = 0; 
    6767 
    6868                /** The overall initializer list. */ 
     
    201201                                // Clear the saved states.  We are starting with the overall 
    202202                                // type. 
    203                 if (0 != states.size()) { 
     203                                if (0 != states.size()) { 
    204204                                        final State state = states.get(0); 
    205205                                        base    = state.base; 
     
    390390 
    391391                        try { 
    392                  
    393                 for (VariableT member : base.toStructOrUnion().getMembers()) { 
     392 
     393                                for (VariableT member : base.toStructOrUnion().getMembers()) { 
    394394                                        if (member.hasName()) { 
    395395                                                index++; 
     
    411411 
    412412                        } catch (NullPointerException e) { 
    413                             e.printStackTrace(); 
    414                 return false; 
     413                                e.printStackTrace(); 
     414                                return false; 
    415415                        } 
    416416 
     
    739739                                        try { 
    740740                                                Node n = (Node) o; 
    741                         dispatch(n); 
     741                                                dispatch(n); 
    742742                                        } catch (ClassCastException cce) { 
    743                         cce.printStackTrace(); 
     743                                                cce.printStackTrace(); 
    744744                                                continue; 
    745745                                        } 
     
    11131113                                                                                .bigIntValue(); 
    11141114                                                                        } catch (IllegalStateException x) { 
    1115                                                                         x.printStackTrace(); 
    1116                                         widthValue = BigInteger.ZERO; 
     1115                                                                                x.printStackTrace(); 
     1116                                                                                widthValue = BigInteger.ZERO; 
    11171117                                                                        } 
    11181118 
     
    12931293                        } else { 
    12941294                                String tag = null;  
    1295                 try {     
    1296                 tag = n.getString(1); 
    1297                 } catch (Exception e) { 
    1298                     tag = null; 
    1299                 } 
    1300  
    1301                 String name; 
     1295                                try {     
     1296                                        tag = n.getString(1); 
     1297                                } catch (Exception e) { 
     1298                                        tag = null; 
     1299                                } 
     1300 
     1301                                String name; 
    13021302                                if (null == tag) { 
    13031303                                        tag = table.freshName("tag"); 
     
    13101310 
    13111311                                        if (!t.isEnum()) { 
    1312                                                 reportPreviousTag(t); 
    13131312                                                type = ErrorT.TYPE; 
    13141313                                                return; 
    13151314 
    13161315                                        } else if (null != t.toTagged().getMembers()) { 
    1317                                                 reportPreviousTag(t); 
    13181316                                                type = ErrorT.TYPE; 
    13191317                                                return; 
     
    13641362                                                                lastValue = value; 
    13651363                                                        } catch (IllegalStateException x) { 
    1366                                                             x.printStackTrace(); 
    1367                                 value = lastValue.add(BigInteger.ONE); 
     1364                                                                x.printStackTrace(); 
     1365                                                                value = lastValue.add(BigInteger.ONE); 
    13681366                                                                lastValue = value; 
    13691367                                                        } 
     
    14571455 
    14581456                                        if (!t.isEnum()) { 
    1459                                                 reportPreviousTag(t); 
    14601457                                                type = ErrorT.TYPE; 
    14611458                                                return; 
     
    16231620                                multipleTypes(); 
    16241621                        } else { 
    1625                                  
    1626                 String tag = null;  
    1627                 try { 
    1628                     tag = n.getString(1); 
    1629                 } catch (Exception e) { 
    1630                     tag = null; 
    1631                 } 
     1622 
     1623                                String tag = null;  
     1624                                try { 
     1625                                        tag = n.getString(1); 
     1626                                } catch (Exception e) { 
     1627                                        tag = null; 
     1628                                } 
    16321629                                String name; 
    16331630                                if (null == tag) { 
     
    16411638 
    16421639                                        if (!t.isStruct()) { 
    1643                                                 reportPreviousTag(t); 
    16441640                                                type = ErrorT.TYPE; 
    16451641                                                return; 
    16461642 
    16471643                                        } else if (null != t.toTagged().getMembers()) { 
    1648                                                 reportPreviousTag(t); 
    16491644                                                type = ErrorT.TYPE; 
    16501645                                                return; 
     
    17081703 
    17091704                                        if (!t.isStruct()) { 
    1710                                                 reportPreviousTag(t); 
    17111705                                                type = ErrorT.TYPE; 
    17121706                                                return; 
     
    17521746                                final String name = n.getString(0); 
    17531747                                final Type value = (Type) table.current().lookup(name); 
    1754                 if ((null != value) && value.isAlias()) { 
     1748                                if ((null != value) && value.isAlias()) { 
    17551749                                        type = value; 
    17561750                                } else { 
     
    17891783                                multipleTypes(); 
    17901784                        } else { 
    1791                                  
    1792                 String tag = null; 
    1793                 try{ 
    1794                    tag = n.getString(1); 
    1795                 } catch(NullPointerException e) { 
    1796                    tag = null; 
    1797                 }  
    1798                  
    1799                 String name; 
     1785 
     1786                                String tag = null; 
     1787                                try{ 
     1788                                        tag = n.getString(1); 
     1789                                } catch(NullPointerException e) { 
     1790                                        tag = null; 
     1791                                }  
     1792 
     1793                                String name; 
    18001794                                if (null == tag) { 
    18011795                                        tag = table.freshName("tag"); 
     
    18081802 
    18091803                                        if (!t.isUnion()) { 
    1810                                                 reportPreviousTag(t); 
    18111804                                                type = ErrorT.TYPE; 
    18121805                                                return; 
    18131806 
    18141807                                        } else if (null != t.toTagged().getMembers()) { 
    1815                                                 reportPreviousTag(t); 
    18161808                                                type = ErrorT.TYPE; 
    18171809                                                return; 
     
    18461838                                // defined attribute to protected against nested redefinition. 
    18471839                                type.addAttribute(Constants.ATT_DEFINED); 
    1848                 List<VariableT> members = processMembers(n.getGeneric(2), false); 
     1840                                List<VariableT> members = processMembers(n.getGeneric(2), false); 
    18491841                                type.toUnion().setMembers(members); 
    18501842                                type.removeAttribute(Constants.ATT_DEFINED); 
     
    18711863 
    18721864                                        if (!t.isUnion()) { 
    1873                                                 reportPreviousTag(t); 
    18741865                                                type = ErrorT.TYPE; 
    18751866                                                return; 
     
    21102101        /** The flag to know whether we are in a left-Hand Side context */ 
    21112102        private boolean leftHandSide; 
    2112          
     2103 
    21132104        /** The flag to know whether we are in a Right-Hand Side context */ 
    21142105        private boolean rightHandSide; 
    21152106 
     2107        /** The flag to know whether we are in a Right-Hand Side context */ 
     2108        private boolean insideTest; 
     2109 
    21162110        /** The flag to know whether we are in a leftHandSide context */ 
    21172111        private boolean unaryModifier; 
    21182112 
     2113        /** The name of the function Definition currently visited */ 
     2114        private String functionDefinitionName; 
    21192115        /** 
    21202116         * A stack containing the nesting for all the conditions. 
     
    21692165        private String extract; 
    21702166 
     2167        /** String representing the configuration Option to remove **/ 
     2168        private String featureName = "anonymous"; 
     2169 
     2170 
    21712171        /** Flag to tell whether the location referencing configuration options  
    21722172         * should be logged or not 
     
    21742174        private boolean logLocation; 
    21752175 
    2176         /** List of the nodes to be extracted, to avoid retraversing to extract **/ 
    2177         private ArrayList<GNode> toExtract; 
     2176        /** List of the nodes to be extracted, to avoid retraversing to extract  
     2177         *  Each element of the ArrayList is a Triple with the name of the function 
     2178         *  definition from which to extract, the Node to extract and the string before or after 
     2179         *  string **/ 
     2180 
     2181        private ArrayList<C4Extractable> toExtract; 
    21782182 
    21792183        /** List of the header file currently visited  
     
    22002204        public void setExtract(String extract) { 
    22012205                this.extract = extract; 
     2206        } 
     2207 
     2208        /** Sets the name of the feature to create **/ 
     2209        public void setFeatureName(String featureName) { 
     2210                if(featureName != null) 
     2211                        this.featureName = featureName; 
    22022212        } 
    22032213 
     
    23742384 
    23752385                public void visit(Node n) { 
    2376             table.enter(n); 
     2386                        table.enter(n); 
    23772387                        for (Object o : n) { 
    23782388                                if (o instanceof Node) dispatch((Node)o); 
     
    26032613                //Extraction 
    26042614                if(null != extract && atTopLevelFile()) { 
    2605                         C4Extractor tmpExtractor = new C4Extractor(extract, toExtract, unit, fileName); 
     2615                        C4Extractor tmpExtractor = new C4Extractor(featureName, extract, toExtract, unit, fileName, functionDefinitions); 
    26062616                        tmpExtractor.extract(); 
    26072617                } 
     
    26452655 
    26462656                        public void visit(Node n) { 
    2647                 table.enter(n); 
     2657                                table.enter(n); 
    26482658                                for (Object o : n) { 
    26492659                                        if (o instanceof Node) dispatch((Node)o); 
     
    27932803                                || type.resolve().isFunction() != previous.resolve() 
    27942804                                .isFunction()) { 
    2795                         //runtime.error("'" + name 
    2796                         //              + "' redeclared as different kind of symbol", decl); 
    2797                         reportPrevious(name, previous); 
    27982805                        return ErrorT.TYPE; 
    27992806                } 
     
    28122819 
    28132820                if (composite.isError()) { 
    2814                         if (previous.hasAttribute(Constants.ATT_BUILTIN) 
    2815                                         && previous.resolve().isFunction()) { 
    2816                                 // runtime.error("conflicting types for built-in function '" + 
    2817                                 // name + "'", 
    2818                                 // decl); 
    2819                         } else { 
    2820                                 // runtime.error("conflicting types for '" + name + "'", decl); 
    2821                                 reportPrevious(name, previous); 
    2822                         } 
    28232821                        return ErrorT.TYPE; 
    2824  
    28252822                } else if (!c().hasSameQualifiers(type, previous)) { 
    2826                         // runtime.error("conflicting type qualifiers for '" + name + "'", 
    2827                         // decl); 
    2828                         reportPrevious(name, previous); 
    28292823                        return ErrorT.TYPE; 
    28302824                } 
     
    28452839                        final Scope current = table.current(); 
    28462840                        table.setScope(table.root()); 
    2847             table.enter(EXTERN_SCOPE); 
     2841                        table.enter(EXTERN_SCOPE); 
    28482842                        scope = table.current(); 
    28492843                        table.setScope(current); 
     
    30473041                                                        value = size.getConstant().bigIntValue(); 
    30483042                                                } catch (IllegalStateException x) { 
    3049                                                     x.printStackTrace(); 
    3050                             final GNode id = getDeclaredId(decl); 
     3043                                                        x.printStackTrace(); 
     3044                                                        final GNode id = getDeclaredId(decl); 
    30513045                                                        if (null == id) { 
    30523046                                                                //                      runtime.warning("can't compute size of array", 
     
    32453239                        // Enter a temporary scope so that variable length arrays can 
    32463240                        // reference previously declared parameters. 
    3247             table.enter(TMP_SCOPE); 
     3241                        table.enter(TMP_SCOPE); 
    32483242 
    32493243                        // A new-style parameter type list. 
     
    33293323 
    33303324                        // Exit the temporary scope and delete it again. 
    3331             table.exit(); 
     3325                        table.exit(); 
    33323326 
    33333327                        table.delete(TMP_SCOPE); 
     
    33653359        } 
    33663360 
    3367     private ArrayList<String> mergeMarked(Stack<ArrayList<String>> markedStack) { 
    3368         //We merge the various in the markedConfigOptionStack 
     3361        private ArrayList<String> mergeMarked(Stack<ArrayList<String>> markedStack) { 
     3362                //We merge the various in the markedConfigOptionStack 
    33693363                ArrayList<String> result = new ArrayList<String>(); 
    3370             for(ArrayList<String> marked: markedConfigOptionsStack) { 
    3371             result.addAll(marked); 
    3372         } 
    3373         return result; 
    3374     } 
    3375  
    3376  
    3377     public ArrayList<String> pushMarkedConfigOptions(GNode ifSection) { 
    3378         ArrayList<String> merged; 
    3379         ArrayList<String> newlyMarked = markConfigOptions(ifSection); 
    3380         markedConfigOptionsStack.push(newlyMarked); 
    3381         merged = mergeMarked(markedConfigOptionsStack); 
    3382         return merged; 
    3383     } 
    3384  
    3385     public ArrayList<String> popMarkedConfigOptions() { 
    3386         ArrayList<String> merged; 
    3387         markedConfigOptionsStack.pop(); 
    3388         merged = mergeMarked(markedConfigOptionsStack);  
    3389          
    3390         return merged; 
    3391     } 
     3364                for(ArrayList<String> marked: markedConfigOptionsStack) { 
     3365                        result.addAll(marked); 
     3366                } 
     3367                return result; 
     3368        } 
     3369 
     3370 
     3371        public ArrayList<String> pushMarkedConfigOptions(GNode ifSection) { 
     3372                ArrayList<String> merged; 
     3373                ArrayList<String> newlyMarked = markConfigOptions(ifSection); 
     3374                markedConfigOptionsStack.push(newlyMarked); 
     3375                merged = mergeMarked(markedConfigOptionsStack); 
     3376                return merged; 
     3377        } 
     3378 
     3379        public ArrayList<String> popMarkedConfigOptions() { 
     3380                ArrayList<String> merged; 
     3381                markedConfigOptionsStack.pop(); 
     3382                merged = mergeMarked(markedConfigOptionsStack);  
     3383 
     3384                return merged; 
     3385        } 
    33923386        /** 
    33933387         * Mark the config Options that define the parsed branch of an IfSection. 
     
    34093403                                                        + elIfn.get(0)); 
    34103404                                } 
    3411                                  
     3405 
    34123406                                if (elIfn.getGeneric(1).getName() != "Unparsed") { 
    34133407                                        //This condition holds 
    3414                                     GNode tmp = elIfn.getGeneric(0); 
    3415                       new Visitor() { 
    3416  
    3417                         Stack <Boolean> negationContext = new Stack<Boolean>(); 
    3418                         boolean tmpNegCont = false; 
    3419                         Boolean tmp = negationContext.push(new Boolean(false)); 
    3420                         public void visitDefinedExpression(GNode n) { 
    3421                             if(configOptions.contains(n.getString(0)) && !tmpNegCont) { 
    3422                                 //If this is a config option 
    3423                                 tmpConfigOptions.add(n.getString(0)); 
    3424                             } 
    3425                         } 
    3426                       
    3427                         public void visitIfGroupNegationExpression(GNode n) { 
    3428                             //XOR 
    3429                             tmpNegCont = tmpNegCont ^ true; 
    3430                             negationContext.push(new Boolean(tmpNegCont)); 
    3431                             //We dispatch the expression negated 
    3432                             dispatch(n.getGeneric(1)); 
    3433                             tmpNegCont = negationContext.pop(); 
    3434                         }  
    3435  
    3436                         public void visit(GNode n) {  
    3437                             for (int i = 0; i < n.size(); i++) { 
    3438                                                     if(n.get(i) instanceof Node){ 
    3439                                     if( n.getNode(i).strip() instanceof GNode) 
    3440                                         dispatch(n.getGeneric(i)); 
    3441                                 } 
    3442                             } 
    3443                         } 
    3444                      
    3445                         public void visitIfGroupExpression(GNode n) { 
    3446                             dispatch(n.getGeneric(0)); 
    3447                         } 
    3448  
    3449                       }.dispatch(tmp); 
     3408                                        GNode tmp = elIfn.getGeneric(0); 
     3409                                        new Visitor() { 
     3410 
     3411                                                Stack <Boolean> negationContext = new Stack<Boolean>(); 
     3412                                                boolean tmpNegCont = false; 
     3413                                                Boolean tmp = negationContext.push(new Boolean(false)); 
     3414                                                public void visitDefinedExpression(GNode n) { 
     3415                                                        if(configOptions.contains(n.getString(0)) && !tmpNegCont) { 
     3416                                                                //If this is a config option 
     3417                                                                tmpConfigOptions.add(n.getString(0)); 
     3418                                                        } 
     3419                                                } 
     3420 
     3421                                                public void visitIfGroupNegationExpression(GNode n) { 
     3422                                                        //XOR 
     3423                                                        tmpNegCont = tmpNegCont ^ true; 
     3424                                                        negationContext.push(new Boolean(tmpNegCont)); 
     3425                                                        //We dispatch the expression negated 
     3426                                                        dispatch(n.getGeneric(1)); 
     3427                                                        tmpNegCont = negationContext.pop(); 
     3428                                                }  
     3429 
     3430                                                public void visit(GNode n) {  
     3431                                                        for (int i = 0; i < n.size(); i++) { 
     3432                                                                if(n.get(i) instanceof Node){ 
     3433                                                                        if( n.getNode(i).strip() instanceof GNode) 
     3434                                                                                dispatch(n.getGeneric(i)); 
     3435                                                                } 
     3436                                                        } 
     3437                                                } 
     3438 
     3439                                                public void visitIfGroupExpression(GNode n) { 
     3440                                                        dispatch(n.getGeneric(0)); 
     3441                                                } 
     3442 
     3443                                        }.dispatch(tmp); 
    34503444                                } 
    34513445                        } 
     
    34563450                                                        + elsen.get(0)); 
    34573451                                } 
    3458                 if (elsen.getGeneric(0).getName() != "Unparsed") { 
     3452                                if (elsen.getGeneric(0).getName() != "Unparsed") { 
    34593453                                        //This condition holds. 
    34603454                                        //All the previously NDef configOptions are now defined 
    3461                     tmpConfigOptions.clear(); 
     3455                                        tmpConfigOptions.clear(); 
    34623456                                        tmpConfigOptions.addAll(tmpNDefConfigOptions); 
    34633457                                } 
     
    34743468                                if (ifn.getGeneric(1).getName() != "Unparsed") { 
    34753469                                        //This condition holds 
    3476                                     GNode tmp = ifn.getGeneric(0); 
    3477                       new Visitor() { 
    3478  
    3479                         Stack <Boolean> negationContext = new Stack<Boolean>(); 
    3480                         boolean tmpNegCont = false; 
    3481                         Boolean tmp = negationContext.push(new Boolean(false)); 
    3482                          
    3483                         public void visitDefinedExpression(GNode n) { 
    3484                             if(configOptions.contains(n.getString(0)) && !tmpNegCont) { 
    3485                                 //If this is a config option 
    3486                                 tmpConfigOptions.add(n.getString(0)); 
    3487                             } 
    3488                         } 
    3489                       
    3490                         public void visitIfGroupNegationExpression(GNode n) { 
    3491                             //XOR 
    3492                             tmpNegCont = tmpNegCont ^ true; 
    3493                             negationContext.push(new Boolean(tmpNegCont)); 
    3494                             //We dispatch the expression negated 
    3495                             dispatch(n.getGeneric(1)); 
    3496                             tmpNegCont = negationContext.pop(); 
    3497                         }  
    3498                          
    3499                         public void visit(GNode n) {  
    3500                             for (int i = 0; i < n.size(); i++) { 
    3501                                                     if(n.get(i) instanceof Node) 
    3502                                     if( n.getNode(i).strip() instanceof GNode) 
    3503                                         dispatch(n.getGeneric(i)); 
    3504                                             } 
    3505                         } 
    3506                      
    3507                         public void visitIfGroupExpression(GNode n) { 
    3508                             dispatch(n.getGeneric(0)); 
    3509                         } 
    3510  
    3511                       }.dispatch(tmp); 
     3470                                        GNode tmp = ifn.getGeneric(0); 
     3471                                        new Visitor() { 
     3472 
     3473                                                Stack <Boolean> negationContext = new Stack<Boolean>(); 
     3474                                                boolean tmpNegCont = false; 
     3475                                                Boolean tmp = negationContext.push(new Boolean(false)); 
     3476 
     3477                                                public void visitDefinedExpression(GNode n) { 
     3478                                                        if(configOptions.contains(n.getString(0)) && !tmpNegCont) { 
     3479                                                                //If this is a config option 
     3480                                                                tmpConfigOptions.add(n.getString(0)); 
     3481                                                        } 
     3482                                                } 
     3483 
     3484                                                public void visitIfGroupNegationExpression(GNode n) { 
     3485                                                        //XOR 
     3486                                                        tmpNegCont = tmpNegCont ^ true; 
     3487                                                        negationContext.push(new Boolean(tmpNegCont)); 
     3488                                                        //We dispatch the expression negated 
     3489                                                        dispatch(n.getGeneric(1)); 
     3490                                                        tmpNegCont = negationContext.pop(); 
     3491                                                }  
     3492 
     3493                                                public void visit(GNode n) {  
     3494                                                        for (int i = 0; i < n.size(); i++) { 
     3495                                                                if(n.get(i) instanceof Node) 
     3496                                                                        if( n.getNode(i).strip() instanceof GNode) 
     3497                                                                                dispatch(n.getGeneric(i)); 
     3498                                                        } 
     3499                                                } 
     3500 
     3501                                                public void visitIfGroupExpression(GNode n) { 
     3502                                                        dispatch(n.getGeneric(0)); 
     3503                                                } 
     3504 
     3505                                        }.dispatch(tmp); 
    35123506                                } 
    35133507 
     
    35473541 
    35483542                }.dispatch(ifSection); 
    3549              
    3550         return markedConfigOptionsTMP; 
     3543 
     3544                return markedConfigOptionsTMP; 
    35513545 
    35523546        } 
     
    36253619                                condition 
    36263620                                .add("Defined(" + ifDefn.getString(0) + ")"); 
    3627                          
     3621 
    36283622                                if (ifDefn.getGeneric(1).getName() != "Unparsed") 
    36293623                                        parsed = ifDefn.getGeneric(1); 
     
    36373631                                condition.add("NotDefined(" + ifNDefn.getString(0) 
    36383632                                                + ")"); 
    3639                                  
     3633 
    36403634 
    36413635                                if (ifNDefn.getGeneric(1).getName() != "Unparsed") 
     
    36473641                                        dispatch(ifSection.getGeneric(i)); 
    36483642                                } 
    3649                                  
    3650                 return new Pair<GNode, String>(parsed, condition.get(condition.size() -1 )); 
     3643 
     3644                                return new Pair<GNode, String>(parsed, condition.get(condition.size() -1 )); 
    36513645                        } 
    36523646                }.dispatch(ifSection); 
    3653                  
     3647 
    36543648                return parsedNodeAndCondition; 
    36553649 
     
    36673661                ifsNode                    = new ArrayList<GNode>(); 
    36683662                loopsNode                  = new ArrayList<GNode>(); 
    3669                 toExtract                  = new ArrayList<GNode>(); 
     3663                toExtract                  = new ArrayList<C4Extractable>(); 
    36703664                functionDefinitions        = new HashMap<String, GNode>(); 
    36713665                markedConfigOptionsStack   = new Stack<ArrayList<String>>(); 
     
    37083702                if(functionBody != null) { 
    37093703                        index = functionBody.indexOf(node); 
     3704 
    37103705                        if(index == (functionBody.size() - 2)){// at the end of a function 
    37113706                                result = true; 
    37123707                        } else if (index == -1) { // We have not found the object as is 
    3713                                 if(functionBody.get(functionBody.size() - 2 ) instanceof GNode) { 
     3708                                if(functionBody.getNode(functionBody.size() - 2 ).strip() instanceof GNode) { 
    37143709                                        GNode tmpGNode = functionBody.getGeneric(functionBody.size()- 2 ); 
    37153710                                        while(tmpGNode.size() == 1 || tmpGNode == node) { 
    3716                                                  
     3711 
    37173712                                                if(tmpGNode == node) { 
    37183713                                                        result = true; 
    37193714                                                } 
    3720                                                  
     3715 
    37213716                                                if( tmpGNode.get(0) instanceof GNode){ 
    3722                                                 tmpGNode = tmpGNode.getGeneric(0); 
    3723                                                 } else { 
     3717                                                        tmpGNode = tmpGNode.getGeneric(0); 
     3718                                                } else if (tmpGNode.get(0) instanceof Node) { 
     3719                                                        if (tmpGNode.getNode(0).strip() instanceof GNode) 
     3720                                                                tmpGNode = tmpGNode.getGeneric(0); 
     3721                                                        else 
     3722                                                                break; 
     3723                                                }  
     3724                                                else { 
    37243725                                                        break; 
    37253726                                                } 
    37263727                                        } 
    37273728                                } 
    3728                                          
     3729 
    37293730 
    37303731                        } else if (functionBody.getGeneric(index+1).getName() == "ReturnStatement") { //just before a return 
     
    37323733                        } 
    37333734                } 
    3734                  
     3735 
    37353736                return result; 
    37363737        } 
     
    39113912        private HashMap<String, Boolean> isMovableAfterConditionally( 
    39123913                        final GNode functionCall, String condFuncName, 
    3913                         final GNode functionDefinition, final Node args) { 
     3914                        final GNode functionDefinition, final Node args, final boolean inFuncBody) { 
    39143915                setCondMovable(true); 
    39153916                final GNode declarator = functionDefinition.getGeneric(2); 
     
    39363937                        public void visit(GNode n) { 
    39373938                                if (n.size() > 0) { 
    3938                                         if (n.get(0) instanceof GNode) 
    3939                                                 dispatch((GNode) n.get(0)); 
     3939                                        for( int i = 0; i< n.size(); i++) { 
     3940                                                if (n.get(i) instanceof GNode){  
     3941                                                        dispatch(n.getGeneric(i)); 
     3942                                                } 
     3943                                                else if(n.get(i) instanceof Node) { 
     3944                                                        if(n.getNode(i).strip() instanceof GNode) 
     3945                                                                dispatch(n.getGeneric(i)); 
     3946                                                } 
     3947                                        } 
    39403948                                } 
    39413949                        } 
     
    39573965                                if (n == functionCall) { 
    39583966                                        flag = true; 
    3959                     new Visitor() { 
     3967                                        new Visitor() { 
    39603968                                                public void visit(GNode n) { 
    39613969                                                        final int size = n.size(); 
    39623970                                                        for (int i = 0; i < size; i++) { 
    3963                                 if (n.get(i) instanceof GNode){ 
    3964                                                                     try {  
    3965                                         dispatch((Node) n.get(i)); 
    3966                                     } catch(Exception e) { 
    3967                                         System.out.println("Problem with this node "+ n.get(i)); 
    3968                                         e.printStackTrace(); 
    3969                                     }                                     
    3970                                 } 
    3971                             } 
     3971                                                                if (n.get(i) instanceof GNode){ 
     3972                                                                        try {  
     3973                                                                                dispatch((Node) n.get(i)); 
     3974                                                                        } catch(Exception e) { 
     3975                                                                                System.out.println("Problem with this node "+ n.get(i)); 
     3976                                                                                e.printStackTrace(); 
     3977                                                                        }                                     
     3978                                                                } 
     3979                                                        } 
    39723980                                                } 
    39733981 
     
    39833991                                                                for (int i = 0; i < size; i++) { 
    39843992                                                                        if (n.get(i) instanceof Node) 
    3985                                                                                 dispatch((Node) n.get(i)); 
     3993                                                                                if(n.getNode(i).strip() instanceof GNode) 
     3994                                                                                        dispatch((Node) n.getGeneric(i)); 
    39863995                                                                } 
    39873996                                                        } 
     
    40014010                                isMovableTmpMap.put( 
    40024011                                                "FunctionDefinition:" + n.getLocation(), 
    4003                                                 new Boolean(isMovable)); 
     4012                                                new Boolean(isMovable && inFuncBody)); 
    40044013                                return isMovableTmpMap; 
    40054014 
     
    40274036                                // after this return 
    40284037                                isMovableTmpMap.put("Return:" + n.getLocation(), 
    4029                                                 new Boolean(isMovable)); 
     4038                                                new Boolean(isMovable && inFuncBody)); 
    40304039                        } 
    40314040 
     
    40484057        @SuppressWarnings( { "unused", "unchecked" }) 
    40494058        private HashMap<String, Boolean> isMovableAfterFunctionMacroRef( 
    4050                         final Node macroref, final ArrayList<String> idsInMacro) { 
     4059                        final Node macroref, final ArrayList<String> idsInMacro, final boolean inFuncBody) { 
    40514060                HashMap<String, Boolean> result = null; 
    4052                  
     4061 
    40534062                if (funcDef != null) { 
    4054  
    40554063                        result = (HashMap<String, Boolean>) new Visitor() { 
    40564064                                boolean isMovable = true; 
     
    40644072                                        for (int i = 0; i < n.size(); i++) { 
    40654073                                                if (n.get(i) instanceof GNode){ 
    4066                             dispatch(n.getGeneric(i)); 
    4067                         } 
     4074                                                        dispatch(n.getGeneric(i)); 
     4075                                                } 
    40684076                                                else if (n.get(i) != null) { 
    4069                                                     if(n.get(i) instanceof Node) 
    4070                                 dispatch((Node)n.get(i)); 
    4071                             if(1 <= DEBUG) 
     4077                                                        if(n.get(i) instanceof Node) 
     4078                                                                dispatch((Node)n.get(i)); 
     4079                                                        if(1 <= DEBUG) 
    40724080                                                                System.out.println("IsMovableAfterFunctionMacroRef " + n.get(i).getClass()); 
    40734081                                                } 
     
    40894097 
    40904098                                public HashMap<String, Boolean> visitFunctionDefinition(GNode n) { 
    4091                     dispatch(n.getGeneric(5)); 
    4092                      
    4093                     if(!flag) 
    4094                                             System.out.println("NO FLAG SET Macro " + macroref + " LOC " + macroref.getLocation());  
    4095                     isMovableTmpMap.put("FunctionDefinition:" + n.getLocation(), 
    4096                                                         new Boolean(isMovable)); 
     4099                                        dispatch(n.getGeneric(5)); 
     4100 
     4101                                        if(!flag) 
     4102                                                System.out.println("NO FLAG SET Macro " + macroref + " LOC " + macroref.getLocation());  
     4103                                        isMovableTmpMap.put("FunctionDefinition:" + n.getLocation(), 
     4104                                                        new Boolean(isMovable && inFuncBody)); 
    40974105 
    40984106                                        return isMovableTmpMap; 
     
    41094117                                        } 
    41104118                                } 
    4111                  
    4112                 public void visitFunctionMacroCallStatement(GNode n) { 
    4113                     if(n == macroref) { 
    4114                         flag = true; 
    4115                     }  
    4116                 } 
     4119 
     4120                                public void visitFunctionMacroCallStatement(GNode n) { 
     4121                                        if(n == macroref) { 
     4122                                                flag = true; 
     4123                                        }  
     4124                                } 
    41174125 
    41184126                                public void visitMacroFunctionExpression(GNode n) { 
     
    41234131 
    41244132                                public void visitMacroReference(GNode n) { 
    4125                     if (n == macroref) { 
     4133                                        if (n == macroref) { 
    41264134                                                flag = true; 
    41274135                                        } 
     
    41374145                                                        isMovable = false; 
    41384146                                                } 
     4147 
    41394148                                                if (1 <= DEBUG) 
    41404149                                                        System.out.println(" FLAG Section " + n.getString(0) 
     
    41504159                                        // this return 
    41514160                                        isMovableTmpMap.put("Return:" + n.getLocation(), new Boolean( 
    4152                                                         isMovable)); 
     4161                                                        isMovable && inFuncBody)); 
    41534162                                } 
    41544163 
     
    42754284 
    42764285                new Visitor() { 
    4277          /*   public void visit(Node n) { 
    4278                  
     4286                        /*   public void visit(Node n) { 
     4287 
    42794288            }*/ 
    42804289                        public void visit(Node n) { 
    4281                 final int size = n.size(); 
     4290                                final int size = n.size(); 
    42824291                                for (int i = 0; i < size; i++) { 
    4283                     if(n.get(i) instanceof Node) 
    4284                         dispatch((Node) n.get(i)); 
    4285                 } 
     4292                                        if(n.get(i) instanceof Node) 
     4293                                                dispatch((Node) n.get(i)); 
     4294                                } 
    42864295                        } 
    42874296 
    42884297                        public void visitPrimaryIdentifier(GNode n) { 
    4289                 // Test for global variables in this function definition 
     4298                                // Test for global variables in this function definition 
    42904299                                if (table.current().lookupScope(n.getString(0)) != null) { 
    42914300                                        if (table.current().lookupScope(n.getString(0)) 
     
    42984307                                // Test for the parameters of the function 
    42994308                                Scope callerScope = table.current(); 
    4300                 table.enter(C4SymbolTable.toFunctionScopeName(functionName)); 
     4309                                table.enter(C4SymbolTable.toFunctionScopeName(functionName)); 
    43014310                                Scope funcScope = table.current(); 
    43024311 
     
    52205229                                } 
    52215230 
    5222                                 /* 
    5223                                  * if (parameters.size() == function.getParameters().size()) { 
    5224                                  * final int size = parameters.size(); for (int i = 0; i < size; 
    5225                                  * i++) { final Type t1 = (Type) table.current().lookupLocally( 
    5226                                  * (String) parameters.get(i)); final Type t2 = 
    5227                                  * function.getParameters().get(i); 
    5228                                  *  
    5229                                  * if (t1.hasError() || t2.hasError()) { // Ignore. } else if 
    5230                                  * (c().compose(t2, c().promoteArgument(t1), 
    5231                                  * pedantic).isError()) { // runtime.error("argument '" // + 
    5232                                  * t1.toVariable().getName() // + "' doesn't match prototype", 
    5233                                  * node); } else if (pedantic && !c().hasSameQualifiers(t2, t1)) 
    5234                                  * { // C99 6.7.5.3 15 // 
    5235                                  * runtime.error("type qualifiers of argument '" // + 
    5236                                  * t1.toVariable().getName() // + "' don't match prototype", 
    5237                                  * node); } } } 
    5238                                  */ 
     5231 
    52395232                        } 
    52405233 
     
    54375430                                                add(index.getConstant().bigIntValue()); 
    54385431                                        } catch (IllegalStateException x) { 
    5439                                             x.printStackTrace(); 
    5440                         ref = new StaticReference(ptr1); 
     5432                                                x.printStackTrace(); 
     5433                                                ref = new StaticReference(ptr1); 
    54415434                                        } 
    54425435                                } else { 
     
    54535446                        return ErrorT.TYPE; 
    54545447                } 
    5455         } 
    5456  
    5457         /** 
    5458          * Report a previous declaration or definition.  If the specified 
    5459          * type has a location, this method prints that location as a 
    5460          * previous declaration or definition. 
    5461          * 
    5462          * @param name The name. 
    5463          * @param type The type. 
    5464          */ 
    5465         public void reportPrevious(String name, Type type) { 
    5466                 // If the type has a location, print the error message. 
    5467                 /* 
    5468        if (type.hasLocation()) { 
    5469        runtime.errConsole().loc(type). 
    5470        p(": error: previous "); 
    5471        if (type.hasAttribute(Constants.ATT_MACRO) || 
    5472        type.hasAttribute(Constants.ATT_DEFINED)) { 
    5473        runtime.errConsole().p("definition"); 
    5474        } else { 
    5475        runtime.errConsole().p("declaration"); 
    5476        } 
    5477        runtime.errConsole().p(" of '").p(name).pln("' was here").flush(); 
    5478        } 
    5479                  */ 
    5480         } 
    5481  
    5482         /** 
    5483          * Report a previous declaration or definition of the specified 
    5484          * tagged type.  If the specified type has a location, this method 
    5485          * prints that location as a previous declaration or definition. 
    5486          * 
    5487          * @param type The type. 
    5488          */ 
    5489         public void reportPreviousTag(Type type) { 
    5490                 /* 
    5491        final Tagged tag = type.toTagged(); 
    5492  
    5493        if (type.hasLocation()) { 
    5494        runtime.errConsole().loc(type). 
    5495        p(": error: previous "); 
    5496        if (null != tag.getMembers()) { 
    5497        runtime.errConsole().p("definition"); 
    5498        } else { 
    5499        runtime.errConsole().p("declaration"); 
    5500        } 
    5501        runtime.errConsole().p(" of '").p(tag.getName()).p("' was here").flush(); 
    5502        } 
    5503                  */ 
    55045448        } 
    55055449 
     
    55225466                        if (macroDefinition.getGeneric(1) != null) { // FunctionMacroParameters 
    55235467                                if (macroDefinition.getGeneric(1).get(0) != null) { // CPPIdentifierList 
    5524                                         if ((macroDefinition.getGeneric(1).get(0) instanceof Node) && (macroDefinition.getGeneric(1).getGeneric(0) != null)) { 
    5525                         for (int i = 0; i < macroDefinition.getGeneric(1).getGeneric( 
    5526                                                                 0).size(); i++) {// Functions Parameters 
    5527                                                         if (macroDefinition.getGeneric(1).getGeneric(0).getName() 
    5528                                                                         .equals("CPPIdentifierList")) { 
    5529                                                                 try { 
    5530                                                                         formalParameters 
    5531                                                                         .add(macroDefinition 
    5532                                                                                         .getGeneric(1).getGeneric(0).getString( 
    5533                                                                                                         i)); 
    5534                                                                 } catch (ClassCastException cce) { 
    5535                                                                     cce.printStackTrace(); 
    5536                                     formalParameters 
    5537                                                                         .add("Unsupported Parameter"); 
    5538                                                                 } 
    5539                                                         } else if (macroDefinition.getGeneric(1).getGeneric(0) 
    5540                                                                         .getName() 
    5541                                                                         .equals("VariadicMacroParameters")) { 
    5542                                                                 for (int j = 0; j < macroDefinition.getGeneric(1) 
    5543                                                                 .getGeneric(0).size(); j++) 
    5544                                                                         if (macroDefinition.getGeneric(1).getGeneric(0) 
    5545                                                                                         .get(j) instanceof String) { 
    5546                                                                                 formalParameters 
    5547                                                                                 .add((String) macroDefinition 
    5548                                                                                                 .getGeneric(1).getGeneric(0) 
    5549                                                                                                 .get(j)); 
    5550                                                                         } else if (macroDefinition.getGeneric(1) 
    5551                                                                                         .getGeneric(0).get(j) instanceof GNode) { 
    5552                                         formalParameters 
    5553                                                                                 .add((String) macroDefinition 
     5468                                        if (macroDefinition.getGeneric(1).get(0) instanceof Node) { 
     5469                                                if (macroDefinition.getGeneric(1).getNode(0).strip() != null) { 
     5470                                                        //System.out.println("NULL AFTER STRIP " + macroDefinition.getGeneric(1).getNode(0)); 
     5471                                                        //System.out.println("MACRODEF GET GEN 1" + macroDefinition.getGeneric(1)); 
     5472                                                        //System.out.println("MACRODEF GET GEN 1STRIPPED " + macroDefinition.getGeneric(1).strip()); 
     5473                                                        //System.out.println("MACRO GETGENERIC " + macroDefinition.getGeneric(1).size()); 
     5474                                                        //     System.exit(-1); 
     5475 
     5476                                                        // else  
     5477                                                        if (macroDefinition.getGeneric(1).getNode(0).strip().isGeneric()) { 
     5478                                                                if (macroDefinition.getGeneric(1).getGeneric(0) != null) { 
     5479                                                                        for (int i = 0; i < macroDefinition.getGeneric(1).getGeneric( 
     5480                                                                                        0).size(); i++) {// Functions Parameters 
     5481 
     5482                                                                                if (macroDefinition.getGeneric(1).getGeneric(0).getName() 
     5483                                                                                                .equals("CPPIdentifierList")) { 
     5484                                                                                        try { 
     5485                                                                                                formalParameters 
     5486                                                                                                .add(macroDefinition 
     5487                                                                                                                .getGeneric(1).getGeneric(0).getString( 
     5488                                                                                                                                i)); 
     5489                                                                                        } catch (ClassCastException cce) { 
     5490                                                                                                cce.printStackTrace(); 
     5491                                                                                                formalParameters 
     5492                                                                                                .add("Unsupported Parameter"); 
     5493                                                                                        } 
     5494                                                                                } else if (macroDefinition.getGeneric(1).getGeneric(0) 
     5495                                                                                                .getName() 
     5496                                                                                                .equals("VariadicMacroParameters")) { 
     5497                                                                                        for (int j = 0; j < macroDefinition.getGeneric(1) 
     5498                                                                                        .getGeneric(0).size(); j++) { 
     5499                                                                                                if (macroDefinition.getGeneric(1).getGeneric(0) 
     5500                                                                                                                .get(j) instanceof String) { 
     5501                                                                                                        formalParameters 
     5502                                                                                                        .add(macroDefinition 
     5503                                                                                                                        .getGeneric(1).getGeneric(0) 
     5504                                                                                                                        .getString(j)); 
     5505                                                                                                } else {  
     5506                                                                                                        /* 
     5507                                        if (macroDefinition.getGeneric(1) 
     5508                                            .getGeneric(0) instanceof Node) { 
     5509                                            if (macroDefinition.getGeneric(1).getGeneric(0) 
     5510                                                    .get 
     5511 
     5512                                        }*/ 
     5513 
     5514                                                                                                        if (macroDefinition.getGeneric(1) 
     5515                                                                                                                        .getGeneric(0).getNode(j).strip().isToken()) { 
     5516                                                                                                                formalParameters 
     5517                                                                                                                .add(macroDefinition 
     5518                                                                                                                                .getGeneric(1).getGeneric(0) 
     5519                                                                                                                                .getString(j)); 
     5520 
     5521                                                                                                        } else if (macroDefinition.getGeneric(1) 
     5522                                                                                                                        .getGeneric(0).getNode(j).strip() instanceof GNode) { 
     5523                                                                                                                /*    formalParameters 
     5524                                            .add((String) macroDefinition 
    55545525                                                                                                .getGeneric(1).getGeneric(0) 
    55555526                                                                                                .getGeneric(j).getString(0)); 
     5527                                                                                                                 */ 
     5528                                                                                                                /*                                            System.out.println(" HERE "+ macroDefinition.getGeneric(1) 
     5529                                                                                        .getGeneric(0).getNode(j).get(0) + " " + (macroDefinition.getGeneric(1) 
     5530                                                                                        .getGeneric(0).getNode(j).get(0) instanceof String));*/ 
     5531                                                                                                                if( macroDefinition.getGeneric(1).getGeneric(0).getGeneric(j).get(0) instanceof String) { 
     5532                                                                                                                        formalParameters 
     5533                                                                                                                        .add((String) macroDefinition 
     5534                                                                                                                                        .getGeneric(1).getGeneric(0) 
     5535                                                                                                                                        .getGeneric(j).getString(0)); 
     5536 
     5537                                                                                                                } else if( macroDefinition.getGeneric(1).getGeneric(0).getGeneric(j).get(0) instanceof Node) { 
     5538                                                                                                                        //{ 
     5539                                                                                                                        /*System.out.println(" THERE "+ macroDefinition.getGeneric(1) 
     5540                                                                                        .getGeneric(0).getNode(j).get(0) + " " + (macroDefinition.getGeneric(1) 
     5541                                                                                        .getGeneric(0).getNode(j).getNode(0).strip()));*/ 
     5542 
     5543 
     5544                                                                                                                        if( macroDefinition.getGeneric(1).getGeneric(0).getGeneric(j).getNode(0).strip() != null)  
     5545                                                                                                                                formalParameters 
     5546                                                                                                                                .add((String) macroDefinition 
     5547                                                                                                                                                .getGeneric(1).getGeneric(0) 
     5548                                                                                                                                                .getGeneric(j).getString(0)); 
     5549                                                                                                                } 
     5550 
     5551                                                                                                        } 
     5552                                                                                                } 
     5553                                                                                        } 
     5554                                                                                } 
    55565555                                                                        } 
     5556                                                                }  
     5557                                                        } else { 
     5558                                                                if(macroDefinition.getGeneric(1).getNode(0).strip().isToken()) { 
     5559                                                                        for (int i = 0; i < macroDefinition.getGeneric(1).size(); i++) { 
     5560                                                                                try { 
     5561                                                                                        formalParameters.add(macroDefinition 
     5562                                                                                                        .getGeneric(1).getString(i)); 
     5563                                                                                } catch (ClassCastException cce) { 
     5564                                                                                        cce.printStackTrace(); 
     5565                                                                                        formalParameters.add("Unsupported Parmaeter"); 
     5566                                                                                } 
     5567                                                                        } 
     5568 
     5569                                                                } 
     5570                                                                //System.out.println("WEIRD  " + macroDefinition.getGeneric(1).getNode(0)); 
     5571                                                                //System.out.println("INSTANCE "+ macroDefinition.getGeneric(1).getNode(0).getLocation() +  " " + macroDefinition.getGeneric(1).getNode(0).strip().isToken()); 
     5572 
    55575573                                                        } 
    55585574                                                } 
     
    55635579                                                                                .getGeneric(1).getString(i)); 
    55645580                                                        } catch (ClassCastException cce) { 
    5565                                 cce.printStackTrace(); 
    5566                                 formalParameters.add("Unsupported Parmaeter"); 
     5581                                                                cce.printStackTrace(); 
     5582                                                                formalParameters.add("Unsupported Parmaeter"); 
    55675583                                                        } 
    55685584                                                } 
     
    55715587                                } 
    55725588                        } 
     5589 
    55735590                } 
    55745591                /** Retrieving the Actual Parameters */ 
     
    55795596                 **/ 
    55805597                // TODO Follow parameters 
     5598 
    55815599                if ((parameters != null) && (formalParameters.size() > 0)) { 
    55825600                        if (1 <= DEBUG) 
     
    55865604 
    55875605                        for (int i = 0; i < parameters.size(); i++) { 
    5588                 final int formal_index = i >= formalParameters.size() ? formalParameters 
     5606                                final int formal_index = i >= formalParameters.size() ? formalParameters 
    55895607                                                .size() - 1 
    55905608                                                : i; 
     
    55985616                                                        public void visit(GNode n) { 
    55995617                                                                for (int j = 0; j < n.size(); j++) { 
    5600                                                                         if (n.get(j) instanceof GNode) { 
    5601                                                                                 dispatch(n.getGeneric(j)); 
     5618                                                                        if(n.get(j) instanceof Node) { 
     5619                                                                                if (n.getNode(j).strip() instanceof GNode) { 
     5620                                                                                        dispatch(n.getGeneric(j)); 
     5621                                                                                } 
    56025622                                                                        } 
    56035623                                                                } 
     
    56255645                 * Parameters should not be modified too 
    56265646                 */ 
     5647                //System.out.println("PARAMETER DICT " + parameterDict); 
    56275648 
    56285649                // Visitor to visit the macro Definition and store all the 
     
    56365657                        public void visit(GNode n) { 
    56375658                                for (int i = 0; i < n.size(); i++) { 
    5638                                         if (n.get(i) instanceof GNode) 
    5639                                                 dispatch(n.getGeneric(i)); 
     5659                                        if (n.get(i) instanceof Node) 
     5660                                                if (n.getNode(i).strip() instanceof GNode) 
     5661                                                        dispatch(n.getGeneric(i)); 
    56405662                                } 
    56415663                        } 
     
    56535675                        public void visitMacroIdentifierConstant(GNode n) { 
    56545676                                // This is a parameter.. 
    5655  
     5677                                //System.out.println("LEFT " + leftHandinMacro + " unary " + unaryModinMacro 
     5678                                //      + "\n@@@ "  + parameterDict.get(n.getString(0))); 
    56565679                                if (leftHandinMacro || unaryModinMacro) { 
    56575680                                        // We retrieve the ids associated with the parameter 
    56585681                                        //TODO why this parameterDict index can be null ? 
    5659                                         if(parameterDict.get(n.get(0)) != null) 
    5660                                                 idsInMacro.addAll(parameterDict.get(n.get(0))); 
     5682                                        if(parameterDict.get(n.getString(0)) != null) { 
     5683                                                //System.out.println("PARAMETER ADD ALL " + parameterDict.get(n.getString(0)) + "n.get(0) " + n.get(0) ); 
     5684                                                idsInMacro.addAll(parameterDict.get(n.getString(0))); 
     5685                                        } 
    56615686                                } 
    56625687 
     
    56665691                        public void visitPostdecrementExpression(GNode n) { 
    56675692                                unaryModinMacro = true; 
    5668                                 dispatch((Node) n.get(0)); 
     5693                                dispatch((Node) n.getGeneric(0)); 
    56695694                                unaryModinMacro = false; 
    56705695                        } 
     
    56735698                        public void visitPostincrementExpression(GNode n) { 
    56745699                                unaryModinMacro = true; 
    5675                                 dispatch((Node) n.get(0)); 
     5700                                dispatch((Node) n.getGeneric(0)); 
    56765701                                unaryModinMacro = false; 
    56775702 
     
    56815706                        public void visitPredecrementExpression(GNode n) { 
    56825707                                unaryModinMacro = true; 
    5683                                 dispatch((Node) n.get(0)); 
     5708                                dispatch((Node) n.getGeneric(0)); 
    56845709                                unaryModinMacro = false; 
    56855710                        } 
     
    56885713                        public void visitPreincrementExpression(GNode n) { 
    56895714                                unaryModinMacro = true; 
    5690                                 dispatch((Node) n.get(0)); 
     5715                                dispatch((Node) n.getGeneric(0)); 
    56915716                                unaryModinMacro = false; 
    56925717                        } 
     
    56955720                        public void visitPrimaryIdentifier(GNode n) { 
    56965721                                if (leftHandinMacro || unaryModinMacro) 
    5697                                         idsInMacro.add((String) n.get(0)); 
     5722                                        idsInMacro.add(n.getString(0)); 
    56985723                        } 
    56995724 
    57005725                        @SuppressWarnings("unused") 
    57015726                        public void visitCPPIdentifierList(GNode n) { 
    5702                                 for(int i=0; i < n.size(); i++) 
     5727                                for(int i=0; i < n.size(); i++) { 
     5728                                        //System.out.println("ADDING " + n.getString(i)); 
    57035729                                        idsInMacro.add(n.getString(i)); 
     5730                                } 
    57045731                        } 
    57055732 
    57065733                        @SuppressWarnings("unused") 
    57075734                        public void visitAddressExpression(GNode n) { 
    5708                                 unaryModinMacro = true;  
     5735                                unaryModinMacro = true; 
     5736                                //System.out.println("seqlock ADDRESS EXPRESSION " + n ); 
    57095737                                for (int i = 0; i < n.size(); i++) { 
    5710                                         if (n.get(i) instanceof GNode) 
    5711                                                 dispatch(n.getGeneric(i)); 
     5738                                        if (n.get(i) instanceof Node) 
     5739                                                if (n.getNode(i).strip() instanceof GNode) 
     5740                                                        dispatch(n.getGeneric(i)); 
    57125741                                } 
    57135742                                unaryModinMacro = false; 
     
    57165745 
    57175746                }.dispatch(macroDefinition); 
     5747 
     5748                //System.out.println("IDS IN MACRO " + idsInMacro ) ; 
    57185749                return idsInMacro; 
    57195750        } 
     
    58075838                        } 
    58085839                } catch (NullPointerException e) { 
    5809                     //e.printStackTrace(); 
    5810             return result; 
     5840                        //e.printStackTrace(); 
     5841                        return result; 
    58115842                } 
    58125843        } 
     
    59185949        /** Visit the specified additive expression. */ 
    59195950        public Type visitAdditiveExpression(GNode n) { 
    5920         // C99 6.5.6 
     5951                // C99 6.5.6 
    59215952                final Node n1 = n.getGeneric(0); 
    59225953                final String op = n.getString(1); 
    59235954                final Node n2 = n.getGeneric(2); 
     5955                //We use the rightHandSide because we don't want to move a part of this kind  
     5956                //of expression 
     5957                //TODO add a stack 
     5958                rightHandSide = true; 
    59245959                final Type t1 = (Type) dispatch(n1); 
    59255960                final Type t2 = (Type) dispatch(n2); 
    5926         if (t1 != null && t2 != null) { 
     5961                rightHandSide = false; 
     5962                if (t1 != null && t2 != null) { 
    59275963                        final Type r1 = c().pointerize(t1); 
    59285964                        final Type r2 = c().pointerize(t2); 
     
    59916027                                                        } catch (IllegalStateException x) { 
    59926028                                                                // ref + ref 
    5993                                 x.printStackTrace(); 
     6029                                                                x.printStackTrace(); 
    59946030                                                                result = result.constant(new StaticReference( 
    59956031                                                                                result)); 
     
    60056041                                                                        : d1 - d2); 
    60066042                                                } catch (IllegalStateException x) { 
    6007                                                     x.printStackTrace(); 
    6008                             result = result 
     6043                                                        x.printStackTrace(); 
     6044                                                        result = result 
    60096045                                                        .constant(new StaticReference(result)); 
    60106046                                                } 
     
    60236059                                                                                .add(t2.getConstant().bigIntValue())); 
    60246060                                                        } catch (IllegalStateException x) { 
    6025                                                             x.printStackTrace(); 
    6026                                 result = result.constant(new StaticReference( 
     6061                                                                x.printStackTrace(); 
     6062                                                                result = result.constant(new StaticReference( 
    60276063                                                                                result)); 
    60286064                                                        } 
     
    60426078                                                                                .add(t1.getConstant().bigIntValue())); 
    60436079                                                        } catch (IllegalStateException x) { 
    6044                                                             x.printStackTrace(); 
    6045                                 result = result.constant(new StaticReference( 
     6080                                                                x.printStackTrace(); 
     6081                                                                result = result.constant(new StaticReference( 
    60466082                                                                                result)); 
    60476083                                                        } 
     
    60916127                                                                        .subtract(t2.getConstant().bigIntValue())); 
    60926128                                                } catch (IllegalStateException x) { 
    6093                                                     //x.printStackTrace(); 
    6094                             result = result 
     6129                                                        //x.printStackTrace(); 
     6130                                                        result = result 
    60956131                                                        .constant(new StaticReference(result)); 
    60966132                                                } 
     
    61896225                                                                .bigIntValue())); 
    61906226                                        } catch (IllegalStateException x) { 
    6191                                             x.printStackTrace(); 
    6192                         result = result.constant(new StaticReference(result)); 
     6227                                                x.printStackTrace(); 
     6228                                                result = result.constant(new StaticReference(result)); 
    61936229                                        } 
    61946230                                } 
     
    62696305                final Type t2 = (Type) dispatch(n2); 
    62706306                rightHandSide = false; 
    6271                  
    6272                  
     6307 
     6308 
    62736309                if (t1 != null && t2 != null) { 
    62746310                        Type result; 
     
    63376373        public Type visitBitwiseAndExpression(GNode n) { 
    63386374                // C99 6.5.10 
    6339          
     6375 
    63406376                final Node n1 = n.getGeneric(0); 
    63416377                final Node n2; 
    6342         if(n.size() >2) { 
    6343            if(n.getGeneric(1) == null) 
    6344                n2 = n.getGeneric(2); 
    6345            else 
    6346                n2 = null; 
    6347         } else { 
    6348          n2 = n.getGeneric(1); 
    6349         } 
     6378                if(n.size() >2) { 
     6379                        if(n.getGeneric(1) == null) 
     6380                                n2 = n.getGeneric(2); 
     6381                        else 
     6382                                n2 = null; 
     6383                } else { 
     6384                        n2 = n.getGeneric(1); 
     6385                } 
    63506386 
    63516387                final Type t1 = (Type) dispatch(n1); 
     
    63686404                                                                        c().mask(t2.getConstant().bigIntValue(), result))); 
    63696405                                } catch (IllegalStateException x) { 
    6370                                     x.printStackTrace(); 
    6371                     result = result.constant(new StaticReference(result)); 
     6406                                        x.printStackTrace(); 
     6407                                        result = result.constant(new StaticReference(result)); 
    63726408                                } 
    63736409                        } 
     
    64196455        public Type visitBitwiseOrExpression(GNode n) { 
    64206456                // C99 6.5.12 
    6421          
     6457 
    64226458                final Node n1 = n.getGeneric(0); 
    64236459                final Node n2; 
    6424         if(n.size() > 2) 
    6425            n2 = n.getGeneric(2); 
    6426         else 
    6427            n2 = n.getGeneric(1); 
     6460                if(n.size() > 2) 
     6461                        n2 = n.getGeneric(2); 
     6462                else 
     6463                        n2 = n.getGeneric(1); 
    64286464 
    64296465                final Type t1 = (Type) dispatch(n1); 
     
    64626498                final Node n1 = n.getGeneric(0); 
    64636499                final Node n2; 
    6464         if (n.size() > 2) 
    6465             n2 = n.getGeneric(2); 
    6466         else  
    6467             n2 = n.getGeneric(1); 
    6468                  
    6469         final Type t1 = (Type) dispatch(n1); 
     6500                if (n.size() > 2) 
     6501                        n2 = n.getGeneric(2); 
     6502                else  
     6503                        n2 = n.getGeneric(1); 
     6504 
     6505                final Type t1 = (Type) dispatch(n1); 
    64706506                final Type t2 = (Type) dispatch(n2); 
    64716507 
     
    65046540                final boolean stmtexpr = isStmtAsExpr; 
    65056541                isStmtAsExpr = false; 
    6506          
     6542 
    65076543                String name = table.freshName("BranchStatements"); 
    65086544                if (1 <= DEBUG) { 
     
    65196555                for (int i = 0; i < size; i++) { 
    65206556                        try { 
    6521              
    6522             Object o = dispatch(n.getNode(i)); 
     6557 
     6558                                Object o = dispatch(n.getNode(i)); 
    65236559 
    65246560                                if ((size - 2 == i) && (o instanceof Type)) { 
     
    65306566                                } 
    65316567                        } catch (NullPointerException e) { 
    6532                             e.printStackTrace(); 
    6533                 System.err.println("Exception "); 
     6568                                e.printStackTrace(); 
     6569                                System.err.println("Exception "); 
    65346570                        } 
    65356571                } 
    65366572 
    65376573                table.exit(); 
    6538                  
    6539         hasScope = scope; 
     6574 
     6575                hasScope = scope; 
    65406576                return stmtexpr ? result : VoidT.TYPE; 
    65416577        } 
     
    68556891                if (scope || stmtexpr) { 
    68566892                        String name = table.freshName("block"); 
    6857             table.enter(name); 
     6893                        table.enter(name); 
    68586894                        table.mark(n); 
    68596895                } 
     
    69897025                if(kind.equals("FunctionMacro")) { 
    69907026                        name = define.getGeneric(0).getString(0); 
     7027                        macrosManager.updateDefine(name); 
    69917028                } else if(kind.equals("ObjectMacro")) { 
    6992                         name = define.getGeneric(0).getGeneric(0).getString(0); 
     7029                        name = define.getGeneric(0).getGeneric(0).getString(0);                  
     7030                        macrosManager.updateDefine(name); 
    69937031                } else if(kind.equals("Undef")) { 
    69947032                        return; 
    69957033                } 
    6996          
    6997         if(isConditionallyDefined(define) && configOptions.size() > 0) {  
     7034 
     7035                if(isConditionallyDefined(define) && configOptions.size() > 0) {  
    69987036                        if(0 != conditionStack.size() && !name.equals("")) { 
    69997037                                if(markedConfigOptions.size() > 0) // We add this function only if the condition is based on a config option 
     
    70047042                                }catch(NullPointerException npe) { 
    70057043                                        System.err.println("Problem with the conditional definitions visitDefine " + define.getLocation() 
    7006                             ); 
     7044                                        ); 
    70077045                                        npe.printStackTrace(); 
    70087046                                        conditionalDefs.put(name, null); 
     
    70847122 
    70857123                                        // Check for previous definitions. 
    7086                                         if (table.current().isDefinedLocally(name)) { 
    7087                                                 Type previous = (Type) table.current().lookupLocally( 
    7088                                                                 name); 
    7089  
    7090                                                 reportPrevious(name, previous); 
    7091  
    7092                                         } else { 
     7124                                        if (!table.current().isDefinedLocally(name)) { 
     7125                         
    70937126                                                table.current().define(name, 
    70947127                                                                new AliasT(name, type).locate(n).seal()); 
     
    71677200                                                                                        && previous 
    71687201                                                                                        .hasAttribute(Constants.ATT_DEFINED)) { 
    7169                                                                                 reportPrevious(name, previous); 
    71707