Adding Java callback support in compiler
[iot2.git] / iotjava / iotpolicy / tree / InterfaceDecl.java
index 69ad7964ac18eb50132b0a6926dc566da7efd00c..30dd3ce002804cb6e0b84a3f9c4f10624416038a 100644 (file)
@@ -38,6 +38,9 @@ public class InterfaceDecl extends Declaration {
        private List<String> listMethodTypes;                           // Method types, e.g. void
        private List<List<String>> listMethodParams;            // Method parameter names, e.g. A, B
        private List<List<String>> listMethodParamTypes;        // Method parameter types, e.g. int, int
+       private Map<String,Integer> mapHelperNumMethodId;       // Helper method Id, e.g. for callbacks, structs.
+
+       private static int helperMethodIdNum = -9999;
 
        /**
         * Class constructors
@@ -50,6 +53,7 @@ public class InterfaceDecl extends Declaration {
                listMethodTypes = new ArrayList<String>();
                listMethodParams = new ArrayList<List<String>>();
                listMethodParamTypes = new ArrayList<List<String>>();
+               mapHelperNumMethodId = new HashMap<String,Integer>();
        }
 
 
@@ -61,6 +65,7 @@ public class InterfaceDecl extends Declaration {
                listMethodTypes = new ArrayList<String>();
                listMethodParams = new ArrayList<List<String>>();
                listMethodParamTypes = new ArrayList<List<String>>();
+               mapHelperNumMethodId = new HashMap<String,Integer>();
        }
 
 
@@ -108,6 +113,20 @@ public class InterfaceDecl extends Declaration {
        }
 
 
+       /**
+        * getHelperMethodNumId() gets Id number for a method
+        */
+       public int getHelperMethodNumId(String method) {
+
+               if (!mapHelperNumMethodId.containsKey(method)) {
+                       mapHelperNumMethodId.put(method, helperMethodIdNum++);
+                       return mapHelperNumMethodId.get(method);
+               } else {
+                       return mapHelperNumMethodId.get(method);
+               }
+       }
+
+
        /**
         * getMethodIds() gets method identifiers
         */