Completing parser to parse generic/template return types; adding standard method...
authorrtrimana <rtrimana@uci.edu>
Wed, 9 Nov 2016 21:36:41 +0000 (13:36 -0800)
committerrtrimana <rtrimana@uci.edu>
Wed, 9 Nov 2016 21:36:41 +0000 (13:36 -0800)
config/iotpolicy/camerapolicy.pol
iotjava/Makefile
iotjava/iotpolicy/IoTCompiler.java
iotjava/iotpolicy/parser/Parser.java
iotjava/iotpolicy/tree/InterfaceDecl.java
iotjava/iotrmi/C++/sample/TestClass_Stub.hpp
iotjava/iotrmi/Java/sample/TestClass_Stub.java
others/javacup/iotparser.cup

index c2aa98bdf476264ccf8b9723440c507f31142580..d85eb53ce25f061402294d7481e73584c6128d8f 100644 (file)
@@ -1,6 +1,6 @@
 public interface Camera {
 
 public interface Camera {
 
-    public void MethodA(int A, int B);
+    public List<Float> MethodA(int A, int B);
     public void MethodA(int A, int B, int AB);
     public int MethodB(int C, String D[]);
     public String MethodC(String E, List<Integer> F);
     public void MethodA(int A, int B, int AB);
     public int MethodB(int C, String D[]);
     public String MethodC(String E, List<Integer> F);
index feafe5160c1deb5f2360afb39a8db6a25b857ace..50792f49439f4754138bc66e9ff9e402dc519db0 100644 (file)
@@ -32,8 +32,8 @@ PHONY += compile
 compile:
        cd $(BIN_DIR)/iotpolicy/output_files; cp *.java ./Java
        cd $(BIN_DIR)/iotpolicy/output_files; cp *.hpp ./Cplus
 compile:
        cd $(BIN_DIR)/iotpolicy/output_files; cp *.java ./Java
        cd $(BIN_DIR)/iotpolicy/output_files; cp *.hpp ./Cplus
-       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:.. *.java
-       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./*.hpp --std=c++11 -pthread -pg
+       #cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) *.java
+       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./*.hpp --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
 
 PHONY += clean
 clean:
 
 PHONY += clean
 clean:
index 8849c4d5dc55ea7471a2df4025c536be204e76b3..94029cad39c9e16d5040fef0578123b142466d52 100644 (file)
@@ -3,6 +3,8 @@ package iotpolicy;
 import java_cup.runtime.ComplexSymbolFactory;
 import java_cup.runtime.ScannerBuffer;
 import java.io.*;
 import java_cup.runtime.ComplexSymbolFactory;
 import java_cup.runtime.ScannerBuffer;
 import java.io.*;
+import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -48,6 +50,8 @@ public class IoTCompiler {
        private Map<String,String> mapPrimitives;
        private Map<String,String> mapNonPrimitivesJava;
        private Map<String,String> mapNonPrimitivesCplus;
        private Map<String,String> mapPrimitives;
        private Map<String,String> mapNonPrimitivesJava;
        private Map<String,String> mapNonPrimitivesCplus;
+       // Other data structures
+       private Map<String,Integer> mapIntfaceObjId;    // Maps interface name to object Id
        private PrintWriter pw;
        private String dir;
        private String subdir;
        private PrintWriter pw;
        private String dir;
        private String subdir;
@@ -72,6 +76,7 @@ public class IoTCompiler {
                mapIntfacePTH = new HashMap<String,ParseTreeHandler>();
                mapIntDeclHand = new HashMap<String,DeclarationHandler>();
                mapInt2NewInts = new HashMap<String,Map<String,Set<String>>>();
                mapIntfacePTH = new HashMap<String,ParseTreeHandler>();
                mapIntDeclHand = new HashMap<String,DeclarationHandler>();
                mapInt2NewInts = new HashMap<String,Map<String,Set<String>>>();
+               mapIntfaceObjId = new HashMap<String,Integer>();
                mapPrimitives = new HashMap<String,String>();
                        arraysToMap(mapPrimitives, IoTRMITypes.primitivesJava, IoTRMITypes.primitivesCplus);
                mapNonPrimitivesJava = new HashMap<String,String>();
                mapPrimitives = new HashMap<String,String>();
                        arraysToMap(mapPrimitives, IoTRMITypes.primitivesJava, IoTRMITypes.primitivesCplus);
                mapNonPrimitivesJava = new HashMap<String,String>();
@@ -85,7 +90,7 @@ public class IoTCompiler {
 
 
        /**
 
 
        /**
-        * setParseTree() sets parse tree based on policy files.
+        * setDataStructures() sets parse tree and other data structures based on policy files.
         * <p>
         * It also generates parse tree (ParseTreeHandler) and
         * copies useful information from parse tree into
         * <p>
         * It also generates parse tree (ParseTreeHandler) and
         * copies useful information from parse tree into
@@ -95,11 +100,10 @@ public class IoTCompiler {
         * returned from tree-parsing for further process.
         *
         */
         * returned from tree-parsing for further process.
         *
         */
-       public void setParseTree(String origInt, ParseNode pnPol, ParseNode pnReq) {
+       public void setDataStructures(String origInt, ParseNode pnPol, ParseNode pnReq) {
 
                ParseTreeHandler ptHandler = new ParseTreeHandler(origInt, pnPol, pnReq);
                DeclarationHandler decHandler = new DeclarationHandler();
 
                ParseTreeHandler ptHandler = new ParseTreeHandler(origInt, pnPol, pnReq);
                DeclarationHandler decHandler = new DeclarationHandler();
-
                // Process ParseNode and generate Declaration objects
                ptHandler.processInterfaceDecl();
                InterfaceDecl intDecl = ptHandler.getInterfaceDecl();
                // Process ParseNode and generate Declaration objects
                ptHandler.processInterfaceDecl();
                InterfaceDecl intDecl = ptHandler.getInterfaceDecl();
@@ -113,6 +117,9 @@ public class IoTCompiler {
 
                mapIntfacePTH.put(origInt, ptHandler);
                mapIntDeclHand.put(origInt, decHandler);
 
                mapIntfacePTH.put(origInt, ptHandler);
                mapIntDeclHand.put(origInt, decHandler);
+               // Set object Id counter to 0 for each interface
+               mapIntfaceObjId.put(origInt, new Integer(0));
+               //System.out.println("\nInterface: " + origInt + "\n\n");
        }
 
 
        }
 
 
@@ -253,6 +260,83 @@ public class IoTCompiler {
        }
 
 
        }
 
 
+       /**
+        * HELPER: writePropertiesJavaStub() writes the properties of the stub class
+        */
+       private void writePropertiesJavaStub(String intface) {
+
+               println("private IoTRMICall rmiCall;");
+               //println("private IoTRMIObject rmiObj;");
+               println("private String address;");
+               println("private int[] ports;\n");
+               // Get the object Id
+               Integer objId = mapIntfaceObjId.get(intface);
+               println("private final static int objectId = " + objId + ";");
+               mapIntfaceObjId.put(intface, objId++);
+               println("\n");
+       }
+
+
+       /**
+        * HELPER: writeConstructorJavaStub() writes the constructor of the stub class
+        */
+       private void writeConstructorJavaStub(String intface) {
+
+               println("public " + intface + "(int _port, String _address, int _rev, int[] _ports) throws Exception {");
+               println("address = _address;");
+               println("ports = _ports;");
+               println("rmiCall = new IoTRMICall(_port, _address, _rev);");
+               println("}\n");
+       }
+
+
+       /**
+        * HELPER: writeStdMethodBodyJavaStub() writes the standard method body in the stub class
+        */
+       private void writeStdMethodBodyJavaStub(InterfaceDecl intDecl, List<String> methParams,
+                       List<String> methPrmTypes, String method) {
+
+               println("int methodId = " + intDecl.getMethodNumId(method) + ";");
+               String retType = intDecl.getMethodType(method);
+               println("Class<?> retType = " + getSimpleType(retType) + ".class;");
+               // Generate array of parameter types
+               print("Class<?>[] paramCls = new Class<?>[] { ");
+               for (int i = 0; i < methParams.size(); i++) {
+                       print(getSimpleType(methPrmTypes.get(i)) + ".class");
+                       // Check if this is the last element (don't print a comma)
+                       if (i != methParams.size() - 1) {
+                               print(", ");
+                       }
+               }
+               println(" };");
+               // Generate array of parameter objects
+               print("Object[] paramObj = new Object[] { ");
+               for (int i = 0; i < methParams.size(); i++) {
+                       print(getSimpleIdentifier(methParams.get(i)));
+                       // Check if this is the last element (don't print a comma)
+                       if (i != methParams.size() - 1) {
+                               print(", ");
+                       }
+               }
+               println(" };");
+               // Check if this is "void"
+               if (retType.equals("void")) {
+                       println("rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);");
+               } else { // We do have a return value
+               // Check if the return value NONPRIMITIVES
+                       if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) {
+                               String[] retGenValType = getTypeOfGeneric(retType);
+                               println("Class<?> retGenValType = " + retGenValType[0] + ".class;");
+                               println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, retGenValType, paramCls, paramObj);");
+                               println("return (" + retType + ")retObj;");
+                       } else {
+                               println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);");
+                               println("return (" + retType + ")retObj;");
+                       }
+               }
+       }
+
+
        /**
         * HELPER: writeMethodJavaStub() writes the method of the stub class
         */
        /**
         * HELPER: writeMethodJavaStub() writes the method of the stub class
         */
@@ -273,12 +357,9 @@ public class IoTCompiler {
                                }
                        }
                        println(") {");
                                }
                        }
                        println(") {");
-                       // Check if this is not "void"
-                       if (!intDecl.getMethodType(method).equals("void")) {
-                               String retStmt = generateReturnStmt(intDecl.getMethodType(method));
-                               println("return " + retStmt + ";");
-                       }
-                       println("}"); println("");
+                       // Now, write the body of stub!
+                       writeStdMethodBodyJavaStub(intDecl, methParams, methPrmTypes, method);
+                       println("}\n");
                }
        }
 
                }
        }
 
@@ -304,11 +385,15 @@ public class IoTCompiler {
                                InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                                // Pass in set of methods and get import classes
                                Set<String> importClasses = getImportClasses(intMeth.getValue(), intDecl);
                                InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                                // Pass in set of methods and get import classes
                                Set<String> importClasses = getImportClasses(intMeth.getValue(), intDecl);
-                               printImportStatements(importClasses);
+                               List<String> stdImportClasses = getStandardJavaImportClasses();
+                               List<String> allImportClasses = getAllImportClasses(stdImportClasses, importClasses);
+                               printImportStatements(allImportClasses); println("");
                                // Write interface header
                                // Write interface header
-                               println("");
-                               println("public class " + newStubClass + " implements " + newIntface + " {");
-                               println("");
+                               println("public class " + newStubClass + " implements " + newIntface + " {\n");
+                               // Write properties
+                               writePropertiesJavaStub(intface);
+                               // Write constructor
+                               writeConstructorJavaStub(newStubClass);
                                // Write methods
                                writeMethodJavaStub(intMeth.getValue(), intDecl);
                                println("}");
                                // Write methods
                                writeMethodJavaStub(intMeth.getValue(), intDecl);
                                println("}");
@@ -328,7 +413,7 @@ public class IoTCompiler {
 
                        List<String> methParams = intDecl.getMethodParams(method);
                        List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
 
                        List<String> methParams = intDecl.getMethodParams(method);
                        List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
-                       print("virtual " + convertType(intDecl.getMethodType(method)) + " " +
+                       print("virtual " + checkAndGetCplusType(intDecl.getMethodType(method)) + " " +
                                intDecl.getMethodId(method) + "(");
                        for (int i = 0; i < methParams.size(); i++) {
                                // Check for params with driver class types and exchange it 
                                intDecl.getMethodId(method) + "(");
                        for (int i = 0; i < methParams.size(); i++) {
                                // Check for params with driver class types and exchange it 
@@ -365,23 +450,22 @@ public class IoTCompiler {
                        FileWriter fw = new FileWriter(dir + "/" + intface + ".hpp");
                        pw = new PrintWriter(new BufferedWriter(fw));
                        // Write file headers
                        FileWriter fw = new FileWriter(dir + "/" + intface + ".hpp");
                        pw = new PrintWriter(new BufferedWriter(fw));
                        // Write file headers
+                       println("#ifndef _" + intface.toUpperCase() + "_HPP__");
+                       println("#define _" + intface.toUpperCase() + "_HPP__");
                        println("#include <iostream>");
                        // Pass in set of methods and get include classes
                        DeclarationHandler decHandler = mapIntDeclHand.get(intface);
                        InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                        List<String> methods = intDecl.getMethods();
                        Set<String> includeClasses = getIncludeClasses(methods, intDecl);
                        println("#include <iostream>");
                        // Pass in set of methods and get include classes
                        DeclarationHandler decHandler = mapIntDeclHand.get(intface);
                        InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                        List<String> methods = intDecl.getMethods();
                        Set<String> includeClasses = getIncludeClasses(methods, intDecl);
-                       printIncludeStatements(includeClasses);
-                       println("");
-                       println("using namespace std;");
-                       println("");
-                       println("class " + intface);
-                       println("{");
+                       printIncludeStatements(includeClasses); println("");
+                       println("using namespace std;\n");
+                       println("class " + intface); println("{");
                        println("public:");
                        // Write methods
                        writeMethodCplusInterface(methods, intDecl);
                        println("public:");
                        // Write methods
                        writeMethodCplusInterface(methods, intDecl);
-                       print("}");
-                       println(";");
+                       println("};");
+                       println("#endif");
                        pw.close();
                        System.out.println("IoTCompiler: Generated local interface " + intface + ".hpp...");
                }
                        pw.close();
                        System.out.println("IoTCompiler: Generated local interface " + intface + ".hpp...");
                }
@@ -409,20 +493,22 @@ public class IoTCompiler {
                                DeclarationHandler decHandler = mapIntDeclHand.get(intface);
                                InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                                // Write file headers
                                DeclarationHandler decHandler = mapIntDeclHand.get(intface);
                                InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                                // Write file headers
+                               println("#ifndef _" + newIntface.toUpperCase() + "_HPP__");
+                               println("#define _" + newIntface.toUpperCase() + "_HPP__");
                                println("#include <iostream>");
                                // Pass in set of methods and get import classes
                                Set<String> includeClasses = getIncludeClasses(intMeth.getValue(), intDecl);
                                println("#include <iostream>");
                                // Pass in set of methods and get import classes
                                Set<String> includeClasses = getIncludeClasses(intMeth.getValue(), intDecl);
-                               printIncludeStatements(includeClasses);
-                               println("");
-                               println("using namespace std;");
-                               println("");
+                               List<String> stdIncludeClasses = getStandardCplusIncludeClasses();
+                               List<String> allIncludeClasses = getAllImportClasses(stdIncludeClasses, includeClasses);
+                               printIncludeStatements(allIncludeClasses); println("");                 
+                               println("using namespace std;\n");
                                println("class " + newIntface);
                                println("{");
                                println("public:");
                                // Write methods
                                writeMethodCplusInterface(intMeth.getValue(), intDecl);
                                println("class " + newIntface);
                                println("{");
                                println("public:");
                                // Write methods
                                writeMethodCplusInterface(intMeth.getValue(), intDecl);
-                               print("}");
-                               println(";");
+                               println("};");
+                               println("#endif");
                                pw.close();
                                System.out.println("IoTCompiler: Generated interface " + newIntface + ".hpp...");
                        }
                                pw.close();
                                System.out.println("IoTCompiler: Generated interface " + newIntface + ".hpp...");
                        }
@@ -439,7 +525,7 @@ public class IoTCompiler {
 
                        List<String> methParams = intDecl.getMethodParams(method);
                        List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
 
                        List<String> methParams = intDecl.getMethodParams(method);
                        List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
-                       print(convertType(intDecl.getMethodType(method)) + " " +
+                       print(checkAndGetCplusType(intDecl.getMethodType(method)) + " " +
                                intDecl.getMethodId(method) + "(");
                        for (int i = 0; i < methParams.size(); i++) {
                                String methPrmType = checkAndGetCplusType(methPrmTypes.get(i));
                                intDecl.getMethodId(method) + "(");
                        for (int i = 0; i < methParams.size(); i++) {
                                String methPrmType = checkAndGetCplusType(methPrmTypes.get(i));
@@ -451,16 +537,102 @@ public class IoTCompiler {
                                }
                        }
                        println(") { ");
                                }
                        }
                        println(") { ");
-                       // Check if this is not "void"
-                       if (!intDecl.getMethodType(method).equals("void")) {
-                               String retStmt = generateReturnStmt(intDecl.getMethodType(method));
-                               if (retStmt.equals("null")) { // null = NULL in C++
-                                       retStmt = "NULL";
-                               }
-                               println("return " + retStmt + ";");
+                       writeStdMethodBodyCplusStub(intDecl, methParams, methPrmTypes, method);
+                       println("}\n");
+               }
+       }
+
+
+       /**
+        * HELPER: writeStdMethodBodyCplusStub() writes the standard method body in the stub class
+        */
+       private void writeStdMethodBodyCplusStub(InterfaceDecl intDecl, List<String> methParams,
+                       List<String> methPrmTypes, String method) {
+
+               println("int numParam = " + methParams.size() + ";");
+               println("int methodId = " + intDecl.getMethodNumId(method) + ";");
+               String retType = intDecl.getMethodType(method);
+               println("string retType = \"" + checkAndGetCplusType(retType) + "\";");
+               // Generate array of parameter types
+               print("string paramCls[] = { ");
+               for (int i = 0; i < methParams.size(); i++) {
+                       print("\"" + checkAndGetCplusType(methPrmTypes.get(i)) + "\"");
+                       // Check if this is the last element (don't print a comma)
+                       if (i != methParams.size() - 1) {
+                               print(", ");
                        }
                        }
-                       println("}"); println("");
                }
                }
+               println(" };");
+               // Generate array of parameter objects
+               print("void* paramObj[] = { ");
+               for (int i = 0; i < methParams.size(); i++) {
+                       print("&" + checkAndGetCplusType(getSimpleIdentifier(methParams.get(i))));
+                       // Check if this is the last element (don't print a comma)
+                       if (i != methParams.size() - 1) {
+                               print(", ");
+                       }
+               }
+               println(" };");
+               // Check if this is "void"
+               if (retType.equals("void")) {
+                       println("void* retObj = NULL;");
+                       println("rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);");
+               } else { // We do have a return value
+                       if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES)
+                               println(checkAndGetCplusType(retType) + " retVal;");
+                       else
+                               println(checkAndGetCplusType(retType) + " retVal = " + generateCplusInitializer(retType) + ";");
+                       println("void* retObj = &retVal;");
+                       println("rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);");
+                       println("return retVal;");
+               }
+       }
+
+
+       /**
+        * HELPER: writePropertiesCplusStub() writes the properties of the stub class
+        */
+       private void writePropertiesCplusStub(String intface) {
+
+               println("IoTRMICall\t\t\t*rmiCall;");
+               //println("IoTRMIObject\t\t\t*rmiObj;");
+               println("string\t\t\t\taddress;");
+               println("vector<int>\t\t\tports;\n");
+               // Get the object Id
+               Integer objId = mapIntfaceObjId.get(intface);
+               println("const static int\tobjectId = " + objId + ";");
+               mapIntfaceObjId.put(intface, objId++);
+               println("\n");
+       }
+
+
+       /**
+        * HELPER: writeConstructorCplusStub() writes the constructor of the stub class
+        */
+       private void writeConstructorCplusStub(String newStubClass) {
+
+               println(newStubClass + 
+                       "(int _port, const char* _address, int _rev, bool* _bResult, vector<int> _ports) {");
+               println("address = _address;");
+               println("ports = _ports;");
+               println("rmiCall = new IoTRMICall(_port, _address, _rev, _bResult);");
+               println("}\n");
+       }
+
+
+       /**
+        * HELPER: writeDeconstructorCplusStub() writes the deconstructor of the stub class
+        */
+       private void writeDeconstructorCplusStub(String newStubClass) {
+
+               println("~" + newStubClass + "() {");
+               println("if (rmiCall != NULL) {");
+               println("delete rmiCall;");
+               println("rmiCall = NULL;");
+               println("}");
+               println("}");
+               println("");
+               // Check if this is callback!!! and print "delete rmiObj and vecCBObj"
        }
 
 
        }
 
 
@@ -481,19 +653,25 @@ public class IoTCompiler {
                                FileWriter fw = new FileWriter(path + "/" + newStubClass + ".hpp");
                                pw = new PrintWriter(new BufferedWriter(fw));
                                // Write file headers
                                FileWriter fw = new FileWriter(path + "/" + newStubClass + ".hpp");
                                pw = new PrintWriter(new BufferedWriter(fw));
                                // Write file headers
+                               println("#ifndef _" + newStubClass.toUpperCase() + "_HPP__");
+                               println("#define _" + newStubClass.toUpperCase() + "_HPP__");
                                println("#include <iostream>");
                                println("#include \"" + newIntface + ".hpp\""); println("");            
                                println("using namespace std;"); println("");
                                println("class " + newStubClass + " : public " + newIntface); println("{");
                                println("#include <iostream>");
                                println("#include \"" + newIntface + ".hpp\""); println("");            
                                println("using namespace std;"); println("");
                                println("class " + newStubClass + " : public " + newIntface); println("{");
-                               println("public:"); println("");
+                               println("private:\n");
+                               writePropertiesCplusStub(intface);
+                               println("public:\n");
                                // Add default constructor and destructor
                                println(newStubClass + "() { }"); println("");
                                // Add default constructor and destructor
                                println(newStubClass + "() { }"); println("");
-                               println("~" + newStubClass + "() { }"); println("");
+                               writeConstructorCplusStub(newStubClass);
+                               writeDeconstructorCplusStub(newStubClass);
                                DeclarationHandler decHandler = mapIntDeclHand.get(intface);
                                InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                                // Write methods
                                writeMethodCplusStub(intMeth.getValue(), intDecl);
                                print("}"); println(";");
                                DeclarationHandler decHandler = mapIntDeclHand.get(intface);
                                InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
                                // Write methods
                                writeMethodCplusStub(intMeth.getValue(), intDecl);
                                print("}"); println(";");
+                               println("#endif");
                                pw.close();
                                System.out.println("IoTCompiler: Generated stub class " + newIntface + ".hpp...");
                        }
                                pw.close();
                                System.out.println("IoTCompiler: Generated stub class " + newIntface + ".hpp...");
                        }
@@ -501,6 +679,36 @@ public class IoTCompiler {
        }
 
 
        }
 
 
+       /**
+        * generateInitializer() generate initializer based on type
+        */
+       public String generateCplusInitializer(String type) {
+
+               // Generate dummy returns for now
+               if (type.equals("short")||
+                       type.equals("int")      ||
+                       type.equals("long") ||
+                       type.equals("float")||
+                       type.equals("double")) {
+
+                       return "0";
+               } else if ( type.equals("String") ||
+                                       type.equals("string")) {
+  
+                       return "\"\"";
+               } else if ( type.equals("char") ||
+                                       type.equals("byte")) {
+
+                       return "\' \'";
+               } else if ( type.equals("boolean")) {
+
+                       return "false";
+               } else {
+                       return "NULL";
+               }
+       }
+
+
        /**
         * generateReturnStmt() generate return statement based on methType
         */
        /**
         * generateReturnStmt() generate return statement based on methType
         */
@@ -602,6 +810,7 @@ public class IoTCompiler {
                newline=false;
        }
 
                newline=false;
        }
 
+
        /**
         * This function converts Java to C++ type for compilation
         */
        /**
         * This function converts Java to C++ type for compilation
         */
@@ -722,6 +931,50 @@ public class IoTCompiler {
        }
 
 
        }
 
 
+       // Generate a set of standard classes for import statements
+       private List<String> getStandardJavaImportClasses() {
+
+               List<String> importClasses = new ArrayList<String>();
+               // Add the standard list first
+               importClasses.add("java.io.IOException");
+               importClasses.add("java.util.List");
+               importClasses.add("java.util.ArrayList");
+               importClasses.add("iotrmi.Java.IoTRMICall");
+               importClasses.add("iotrmi.Java.IoTRMIObject");
+
+               return importClasses;
+       }
+
+
+       // Generate a set of standard classes for import statements
+       private List<String> getStandardCplusIncludeClasses() {
+
+               List<String> importClasses = new ArrayList<String>();
+               // Add the standard list first
+               importClasses.add("<vector>");
+               importClasses.add("\"IoTRMICall.hpp\"");
+               importClasses.add("\"IoTRMIObject.hpp\"");
+
+               return importClasses;
+       }
+
+
+       // Generate a set of standard classes for import statements
+       private List<String> getAllImportClasses(Collection<String> stdImportClasses, Collection<String> importClasses) {
+
+               List<String> allImportClasses = new ArrayList<String>(stdImportClasses);
+               // Iterate over the list of import classes
+               for (String str : importClasses) {
+                       if (!stdImportClasses.contains(str)) {
+                               stdImportClasses.add(str);
+                       }
+               }
+
+               return allImportClasses;
+       }
+
+
+
        // Generate a set of classes for import statements
        private Set<String> getImportClasses(Collection<String> methods, InterfaceDecl intDecl) {
 
        // Generate a set of classes for import statements
        private Set<String> getImportClasses(Collection<String> methods, InterfaceDecl intDecl) {
 
@@ -766,7 +1019,7 @@ public class IoTCompiler {
        }
 
 
        }
 
 
-       private void printImportStatements(Set<String> importClasses) {
+       private void printImportStatements(Collection<String> importClasses) {
 
                for(String cls : importClasses) {
                        println("import " + cls + ";");
 
                for(String cls : importClasses) {
                        println("import " + cls + ";");
@@ -774,7 +1027,7 @@ public class IoTCompiler {
        }
 
 
        }
 
 
-       private void printIncludeStatements(Set<String> includeClasses) {
+       private void printIncludeStatements(Collection<String> includeClasses) {
 
                for(String cls : includeClasses) {
                        println("#include " + cls);
 
                for(String cls : includeClasses) {
                        println("#include " + cls);
@@ -793,6 +1046,18 @@ public class IoTCompiler {
        }
 
 
        }
 
 
+       // This helper function strips off array declaration, e.g. D[] becomes D
+       private String getSimpleIdentifier(String ident) {
+
+               // Handle [ for array declaration
+               String substr = ident;
+               if (ident.contains("[]")) {
+                       substr = ident.split("\\[\\]")[0];
+               }
+               return substr;
+       }
+
+
        private String checkAndGetCplusType(String paramType) {
 
                if (getParamCategory(paramType) == ParamCategory.PRIMITIVES) {
        private String checkAndGetCplusType(String paramType) {
 
                if (getParamCategory(paramType) == ParamCategory.PRIMITIVES) {
@@ -905,7 +1170,7 @@ public class IoTCompiler {
                                ParseNode pnReq = IoTCompiler.parseFile(args[i+1]);
                                // Get interface name
                                String intface = ParseTreeHandler.getOrigIntface(pnPol);
                                ParseNode pnReq = IoTCompiler.parseFile(args[i+1]);
                                // Get interface name
                                String intface = ParseTreeHandler.getOrigIntface(pnPol);
-                               comp.setParseTree(intface, pnPol, pnReq);
+                               comp.setDataStructures(intface, pnPol, pnReq);
                                comp.getMethodsForIntface(intface);
                                i = i + 2;
                        // 1) Check if this is the last option before "-java" or "-cplus"
                                comp.getMethodsForIntface(intface);
                                i = i + 2;
                        // 1) Check if this is the last option before "-java" or "-cplus"
index 14d67b79e8331c1c20c821af8d81cc557f238190..7d6086c0669e44c647b86f322aa4359cbc2bcb9f 100644 (file)
@@ -16,7 +16,6 @@ import java_cup.runtime.XMLElement;
 
 import iotpolicy.tree.ParseNode;
 
 
 import iotpolicy.tree.ParseNode;
 
-
 /** CUP v0.11b 20160615 (GIT 4ac7450) generated parser.
   */
 @SuppressWarnings({"rawtypes"})
 /** CUP v0.11b 20160615 (GIT 4ac7450) generated parser.
   */
 @SuppressWarnings({"rawtypes"})
@@ -40,20 +39,21 @@ public class Parser extends java_cup.runtime.lr_parser {
   /** Production table. */
   protected static final short _production_table[][] = 
     unpackFromStrings(new String[] {
   /** Production table. */
   protected static final short _production_table[][] = 
     unpackFromStrings(new String[] {
-    "\000\054\000\002\002\003\000\002\002\004\000\002\002" +
+    "\000\056\000\002\002\003\000\002\002\004\000\002\002" +
     "\003\000\002\002\003\000\002\002\003\000\002\003\011" +
     "\000\002\004\004\000\002\004\002\000\002\005\011\000" +
     "\003\000\002\002\003\000\002\002\003\000\002\003\011" +
     "\000\002\004\004\000\002\004\002\000\002\005\011\000" +
-    "\002\005\011\000\002\006\004\000\002\006\002\000\002" +
-    "\007\005\000\002\007\004\000\002\007\005\000\002\007" +
-    "\004\000\002\007\007\000\002\007\007\000\002\007\010" +
-    "\000\002\007\010\000\002\011\004\000\002\011\002\000" +
-    "\002\012\007\000\002\013\004\000\002\013\002\000\002" +
-    "\014\006\000\002\014\006\000\002\015\004\000\002\015" +
-    "\002\000\002\016\012\000\002\017\003\000\002\017\005" +
-    "\000\002\017\002\000\002\020\007\000\002\021\004\000" +
-    "\002\021\002\000\002\022\004\000\002\022\003\000\002" +
-    "\023\007\000\002\024\004\000\002\024\002\000\002\025" +
-    "\005\000\002\025\005\000\002\025\010" });
+    "\002\005\011\000\002\005\014\000\002\005\014\000\002" +
+    "\006\004\000\002\006\002\000\002\007\005\000\002\007" +
+    "\004\000\002\007\005\000\002\007\004\000\002\007\007" +
+    "\000\002\007\007\000\002\007\010\000\002\007\010\000" +
+    "\002\011\004\000\002\011\002\000\002\012\007\000\002" +
+    "\013\004\000\002\013\002\000\002\014\006\000\002\014" +
+    "\006\000\002\015\004\000\002\015\002\000\002\016\012" +
+    "\000\002\017\003\000\002\017\005\000\002\017\002\000" +
+    "\002\020\007\000\002\021\004\000\002\021\002\000\002" +
+    "\022\004\000\002\022\003\000\002\023\007\000\002\024" +
+    "\004\000\002\024\002\000\002\025\005\000\002\025\005" +
+    "\000\002\025\010" });
 
   /** Access to production table. */
   public short[][] production_table() {return _production_table;}
 
   /** Access to production table. */
   public short[][] production_table() {return _production_table;}
@@ -61,64 +61,73 @@ public class Parser extends java_cup.runtime.lr_parser {
   /** Parse-action table. */
   protected static final short[][] _action_table = 
     unpackFromStrings(new String[] {
   /** Parse-action table. */
   protected static final short[][] _action_table = 
     unpackFromStrings(new String[] {
-    "\000\140\000\014\002\uffe5\015\012\022\uffe5\025\007\026" +
+    "\000\157\000\014\002\uffe3\015\012\022\uffe3\025\007\026" +
     "\011\001\002\000\004\002\001\001\002\000\004\002\ufffd" +
     "\011\001\002\000\004\002\001\001\002\000\004\002\ufffd" +
-    "\001\002\000\004\002\ufffe\001\002\000\004\030\134\001" +
-    "\002\000\006\002\uffff\022\120\001\002\000\004\030\100" +
+    "\001\002\000\004\002\ufffe\001\002\000\004\030\153\001" +
+    "\002\000\006\002\uffff\022\137\001\002\000\004\030\117" +
     "\001\002\000\004\016\015\001\002\000\004\002\014\001" +
     "\002\000\004\002\000\001\002\000\004\030\016\001\002" +
     "\000\004\012\017\001\002\000\010\013\ufffa\015\ufffa\017" +
     "\001\002\000\004\016\015\001\002\000\004\002\014\001" +
     "\002\000\004\002\000\001\002\000\004\030\016\001\002" +
     "\000\004\012\017\001\002\000\010\013\ufffa\015\ufffa\017" +
-    "\ufffa\001\002\000\010\013\uffec\015\022\017\uffec\001\002" +
+    "\ufffa\001\002\000\010\013\uffea\015\022\017\uffea\001\002" +
     "\000\010\013\ufffb\015\ufffb\017\ufffb\001\002\000\006\027" +
     "\045\030\044\001\002\000\006\013\026\017\025\001\002" +
     "\000\010\013\ufffb\015\ufffb\017\ufffb\001\002\000\006\027" +
     "\045\030\044\001\002\000\006\013\026\017\025\001\002" +
-    "\000\006\013\uffed\017\uffed\001\002\000\004\030\027\001" +
+    "\000\006\013\uffeb\017\uffeb\001\002\000\004\030\027\001" +
     "\002\000\004\002\ufffc\001\002\000\004\012\030\001\002" +
     "\002\000\004\002\ufffc\001\002\000\004\012\030\001\002" +
-    "\000\010\013\uffe9\020\uffe9\021\uffe9\001\002\000\010\013" +
-    "\034\020\033\021\035\001\002\000\010\013\uffea\020\uffea" +
-    "\021\uffea\001\002\000\004\014\041\001\002\000\006\013" +
-    "\uffeb\017\uffeb\001\002\000\004\014\036\001\002\000\004" +
+    "\000\010\013\uffe7\020\uffe7\021\uffe7\001\002\000\010\013" +
+    "\034\020\033\021\035\001\002\000\010\013\uffe8\020\uffe8" +
+    "\021\uffe8\001\002\000\004\014\041\001\002\000\006\013" +
+    "\uffe9\017\uffe9\001\002\000\004\014\036\001\002\000\004" +
     "\031\037\001\002\000\004\004\040\001\002\000\010\013" +
     "\031\037\001\002\000\004\004\040\001\002\000\010\013" +
-    "\uffe7\020\uffe7\021\uffe7\001\002\000\004\031\042\001\002" +
-    "\000\004\004\043\001\002\000\010\013\uffe8\020\uffe8\021" +
-    "\uffe8\001\002\000\004\030\073\001\002\000\004\030\046" +
-    "\001\002\000\004\006\047\001\002\000\010\007\ufff6\027" +
-    "\ufff6\030\ufff6\001\002\000\010\007\052\027\054\030\051" +
-    "\001\002\000\006\010\060\030\061\001\002\000\004\004" +
-    "\057\001\002\000\010\007\ufff7\027\ufff7\030\ufff7\001\002" +
-    "\000\004\030\055\001\002\000\012\005\056\007\ufff4\027" +
-    "\ufff4\030\ufff4\001\002\000\010\007\ufff5\027\ufff5\030\ufff5" +
-    "\001\002\000\010\013\ufff9\015\ufff9\017\ufff9\001\002\000" +
-    "\006\027\064\030\063\001\002\000\012\005\062\007\ufff2" +
-    "\027\ufff2\030\ufff2\001\002\000\010\007\ufff3\027\ufff3\030" +
-    "\ufff3\001\002\000\004\011\070\001\002\000\004\011\065" +
-    "\001\002\000\004\030\066\001\002\000\012\005\067\007" +
-    "\ufff1\027\ufff1\030\ufff1\001\002\000\010\007\uffef\027\uffef" +
-    "\030\uffef\001\002\000\004\030\071\001\002\000\012\005" +
-    "\072\007\ufff0\027\ufff0\030\ufff0\001\002\000\010\007\uffee" +
-    "\027\uffee\030\uffee\001\002\000\004\006\074\001\002\000" +
-    "\010\007\ufff6\027\ufff6\030\ufff6\001\002\000\010\007\076" +
-    "\027\054\030\051\001\002\000\004\004\077\001\002\000" +
-    "\010\013\ufff8\015\ufff8\017\ufff8\001\002\000\004\012\101" +
-    "\001\002\000\010\013\uffd9\027\uffd9\030\uffd9\001\002\000" +
-    "\010\013\104\027\106\030\103\001\002\000\006\010\111" +
-    "\030\112\001\002\000\004\002\uffdb\001\002\000\010\013" +
-    "\uffda\027\uffda\030\uffda\001\002\000\004\030\107\001\002" +
-    "\000\004\004\110\001\002\000\010\013\uffd8\027\uffd8\030" +
-    "\uffd8\001\002\000\004\030\114\001\002\000\004\004\113" +
-    "\001\002\000\010\013\uffd7\027\uffd7\030\uffd7\001\002\000" +
-    "\004\011\115\001\002\000\004\030\116\001\002\000\004" +
-    "\004\117\001\002\000\010\013\uffd6\027\uffd6\030\uffd6\001" +
-    "\002\000\004\030\122\001\002\000\006\002\uffe6\022\uffe6" +
-    "\001\002\000\004\023\123\001\002\000\010\005\uffe1\024" +
-    "\uffe1\030\125\001\002\000\006\005\126\024\127\001\002" +
-    "\000\006\005\uffe3\024\uffe3\001\002\000\004\030\133\001" +
-    "\002\000\004\016\130\001\002\000\004\030\131\001\002" +
-    "\000\004\004\132\001\002\000\006\002\uffe4\022\uffe4\001" +
-    "\002\000\006\005\uffe2\024\uffe2\001\002\000\004\012\135" +
-    "\001\002\000\006\013\uffde\030\uffde\001\002\000\006\013" +
-    "\141\030\140\001\002\000\006\013\uffdf\030\uffdf\001\002" +
-    "\000\010\005\142\013\uffdc\030\uffdc\001\002\000\004\002" +
-    "\uffe0\001\002\000\006\013\uffdd\030\uffdd\001\002" });
+    "\uffe5\020\uffe5\021\uffe5\001\002\000\004\031\042\001\002" +
+    "\000\004\004\043\001\002\000\010\013\uffe6\020\uffe6\021" +
+    "\uffe6\001\002\000\006\010\073\030\074\001\002\000\004" +
+    "\030\046\001\002\000\004\006\047\001\002\000\010\007" +
+    "\ufff4\027\ufff4\030\ufff4\001\002\000\010\007\052\027\054" +
+    "\030\051\001\002\000\006\010\060\030\061\001\002\000" +
+    "\004\004\057\001\002\000\010\007\ufff5\027\ufff5\030\ufff5" +
+    "\001\002\000\004\030\055\001\002\000\012\005\056\007" +
+    "\ufff2\027\ufff2\030\ufff2\001\002\000\010\007\ufff3\027\ufff3" +
+    "\030\ufff3\001\002\000\010\013\ufff9\015\ufff9\017\ufff9\001" +
+    "\002\000\006\027\064\030\063\001\002\000\012\005\062" +
+    "\007\ufff0\027\ufff0\030\ufff0\001\002\000\010\007\ufff1\027" +
+    "\ufff1\030\ufff1\001\002\000\004\011\070\001\002\000\004" +
+    "\011\065\001\002\000\004\030\066\001\002\000\012\005" +
+    "\067\007\uffef\027\uffef\030\uffef\001\002\000\010\007\uffed" +
+    "\027\uffed\030\uffed\001\002\000\004\030\071\001\002\000" +
+    "\012\005\072\007\uffee\027\uffee\030\uffee\001\002\000\010" +
+    "\007\uffec\027\uffec\030\uffec\001\002\000\006\027\102\030" +
+    "\101\001\002\000\004\006\075\001\002\000\010\007\ufff4" +
+    "\027\ufff4\030\ufff4\001\002\000\010\007\077\027\054\030" +
+    "\051\001\002\000\004\004\100\001\002\000\010\013\ufff8" +
+    "\015\ufff8\017\ufff8\001\002\000\004\011\111\001\002\000" +
+    "\004\011\103\001\002\000\004\030\104\001\002\000\004" +
+    "\006\105\001\002\000\010\007\ufff4\027\ufff4\030\ufff4\001" +
+    "\002\000\010\007\107\027\054\030\051\001\002\000\004" +
+    "\004\110\001\002\000\010\013\ufff7\015\ufff7\017\ufff7\001" +
+    "\002\000\004\030\112\001\002\000\004\006\113\001\002" +
+    "\000\010\007\ufff4\027\ufff4\030\ufff4\001\002\000\010\007" +
+    "\115\027\054\030\051\001\002\000\004\004\116\001\002" +
+    "\000\010\013\ufff6\015\ufff6\017\ufff6\001\002\000\004\012" +
+    "\120\001\002\000\010\013\uffd7\027\uffd7\030\uffd7\001\002" +
+    "\000\010\013\123\027\125\030\122\001\002\000\006\010" +
+    "\130\030\131\001\002\000\004\002\uffd9\001\002\000\010" +
+    "\013\uffd8\027\uffd8\030\uffd8\001\002\000\004\030\126\001" +
+    "\002\000\004\004\127\001\002\000\010\013\uffd6\027\uffd6" +
+    "\030\uffd6\001\002\000\004\030\133\001\002\000\004\004" +
+    "\132\001\002\000\010\013\uffd5\027\uffd5\030\uffd5\001\002" +
+    "\000\004\011\134\001\002\000\004\030\135\001\002\000" +
+    "\004\004\136\001\002\000\010\013\uffd4\027\uffd4\030\uffd4" +
+    "\001\002\000\004\030\141\001\002\000\006\002\uffe4\022" +
+    "\uffe4\001\002\000\004\023\142\001\002\000\010\005\uffdf" +
+    "\024\uffdf\030\144\001\002\000\006\005\145\024\146\001" +
+    "\002\000\006\005\uffe1\024\uffe1\001\002\000\004\030\152" +
+    "\001\002\000\004\016\147\001\002\000\004\030\150\001" +
+    "\002\000\004\004\151\001\002\000\006\002\uffe2\022\uffe2" +
+    "\001\002\000\006\005\uffe0\024\uffe0\001\002\000\004\012" +
+    "\154\001\002\000\006\013\uffdc\030\uffdc\001\002\000\006" +
+    "\013\160\030\157\001\002\000\006\013\uffdd\030\uffdd\001" +
+    "\002\000\010\005\161\013\uffda\030\uffda\001\002\000\004" +
+    "\002\uffde\001\002\000\006\013\uffdb\030\uffdb\001\002" });
 
   /** Access to parse-action table. */
   public short[][] action_table() {return _action_table;}
 
   /** Access to parse-action table. */
   public short[][] action_table() {return _action_table;}
@@ -126,9 +135,9 @@ public class Parser extends java_cup.runtime.lr_parser {
   /** <code>reduce_goto</code> table. */
   protected static final short[][] _reduce_table = 
     unpackFromStrings(new String[] {
   /** <code>reduce_goto</code> table. */
   protected static final short[][] _reduce_table = 
     unpackFromStrings(new String[] {
-    "\000\140\000\014\002\012\003\003\015\007\020\005\023" +
+    "\000\157\000\014\002\012\003\003\015\007\020\005\023" +
     "\004\001\001\000\002\001\001\000\002\001\001\000\002" +
     "\004\001\001\000\002\001\001\000\002\001\001\000\002" +
-    "\001\001\000\002\001\001\000\004\016\120\001\001\000" +
+    "\001\001\000\002\001\001\000\004\016\137\001\001\000" +
     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
     "\001\001\000\002\001\001\000\002\001\001\000\004\004" +
     "\017\001\001\000\006\005\020\011\022\001\001\000\002" +
     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
     "\001\001\000\002\001\001\000\002\001\001\000\004\004" +
     "\017\001\001\000\006\005\020\011\022\001\001\000\002" +
@@ -145,20 +154,26 @@ public class Parser extends java_cup.runtime.lr_parser {
     "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
     "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
-    "\002\001\001\000\002\001\001\000\002\001\001\000\004" +
-    "\006\074\001\001\000\004\007\052\001\001\000\002\001" +
-    "\001\000\002\001\001\000\002\001\001\000\004\024\101" +
-    "\001\001\000\004\025\104\001\001\000\002\001\001\000" +
     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
-    "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
+    "\001\001\000\004\006\075\001\001\000\004\007\052\001" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
     "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
-    "\002\001\001\000\002\001\001\000\004\017\123\001\001" +
+    "\004\006\105\001\001\000\004\007\052\001\001\000\002" +
+    "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
+    "\001\000\004\006\113\001\001\000\004\007\052\001\001" +
+    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
+    "\004\024\120\001\001\000\004\025\123\001\001\000\002" +
+    "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
+    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
     "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
-    "\001\001\000\002\001\001\000\002\001\001\000\004\021" +
-    "\135\001\001\000\004\022\136\001\001\000\002\001\001" +
-    "\000\002\001\001\000\002\001\001\000\002\001\001" });
+    "\001\001\000\002\001\001\000\002\001\001\000\004\017" +
+    "\142\001\001\000\002\001\001\000\002\001\001\000\002" +
+    "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
+    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
+    "\000\004\021\154\001\001\000\004\022\155\001\001\000" +
+    "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
+    "\001\001" });
 
   /** Access to <code>reduce_goto</code> table. */
   public short[][] reduce_table() {return _reduce_table;}
 
   /** Access to <code>reduce_goto</code> table. */
   public short[][] reduce_table() {return _reduce_table;}
@@ -416,7 +431,61 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 10: // paramlist ::= paramlist param 
+          case 10: // meth ::= PUBLIC IDENT LANG TYPE RANG IDENT LPAR paramlist RPAR SEMICOLON 
+            {
+              ParseNode RESULT =null;
+               int clsmethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-8)).left;
+               int clsmethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-8)).right;
+               Object clsmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-8)).value;
+               int typegenleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).left;
+               int typegenright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).right;
+               Object typegen = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-6)).value;
+               int idmethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
+               int idmethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).right;
+               Object idmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
+               int plleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int plright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               ParseNode pl = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               
+               ParseNode pn = new ParseNode("method");
+               pn.addChild("method_class").setLiteral((String)clsmeth + "<" + typegen + ">");
+               pn.addChild("method_ident").setLiteral(idmeth);
+               pn.addChild(pl);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("meth",3, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-9)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 11: // meth ::= PUBLIC IDENT LANG IDENT RANG IDENT LPAR paramlist RPAR SEMICOLON 
+            {
+              ParseNode RESULT =null;
+               int clsmethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-8)).left;
+               int clsmethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-8)).right;
+               Object clsmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-8)).value;
+               int clsgenleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).left;
+               int clsgenright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).right;
+               Object clsgen = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-6)).value;
+               int idmethleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
+               int idmethright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).right;
+               Object idmeth = (Object)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-4)).value;
+               int plleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
+               int plright = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).right;
+               ParseNode pl = (ParseNode)((java_cup.runtime.Symbol) CUP$Parser$stack.elementAt(CUP$Parser$top-2)).value;
+               
+               ParseNode pn = new ParseNode("method");
+               pn.addChild("method_class").setLiteral((String)clsmeth + "<" + clsgen + ">");
+               pn.addChild("method_ident").setLiteral(idmeth);
+               pn.addChild(pl);
+               RESULT = pn;
+       
+              CUP$Parser$result = parser.getSymbolFactory().newSymbol("meth",3, ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-9)), ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()), RESULT);
+            }
+          return CUP$Parser$result;
+
+          /*. . . . . . . . . . . . . . . . . . . .*/
+          case 12: // paramlist ::= paramlist param 
             {
               ParseNode RESULT =null;
                int plleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int plleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -434,7 +503,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 11: // paramlist ::= 
+          case 13: // paramlist ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -446,7 +515,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 12: // param ::= TYPE IDENT COMMA 
+          case 14: // param ::= TYPE IDENT COMMA 
             {
               ParseNode RESULT =null;
                int typeprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
             {
               ParseNode RESULT =null;
                int typeprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
@@ -466,7 +535,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 13: // param ::= TYPE IDENT 
+          case 15: // param ::= TYPE IDENT 
             {
               ParseNode RESULT =null;
                int typeprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int typeprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -486,7 +555,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 14: // param ::= IDENT IDENT COMMA 
+          case 16: // param ::= IDENT IDENT COMMA 
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
@@ -506,7 +575,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 15: // param ::= IDENT IDENT 
+          case 17: // param ::= IDENT IDENT 
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -526,7 +595,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 16: // param ::= IDENT LANG TYPE RANG IDENT 
+          case 18: // param ::= IDENT LANG TYPE RANG IDENT 
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
@@ -549,7 +618,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 17: // param ::= IDENT LANG IDENT RANG IDENT 
+          case 19: // param ::= IDENT LANG IDENT RANG IDENT 
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-4)).left;
@@ -572,7 +641,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 18: // param ::= IDENT LANG TYPE RANG IDENT COMMA 
+          case 20: // param ::= IDENT LANG TYPE RANG IDENT COMMA 
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
@@ -595,7 +664,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 19: // param ::= IDENT LANG IDENT RANG IDENT COMMA 
+          case 21: // param ::= IDENT LANG IDENT RANG IDENT COMMA 
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
             {
               ParseNode RESULT =null;
                int clsprmleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
@@ -618,7 +687,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 20: // capablist ::= capablist capab 
+          case 22: // capablist ::= capablist capab 
             {
               ParseNode RESULT =null;
                int clleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int clleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -636,7 +705,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 21: // capablist ::= 
+          case 23: // capablist ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -648,7 +717,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 22: // capab ::= CAPABILITY IDENT BEGIN capabcont END 
+          case 24: // capab ::= CAPABILITY IDENT BEGIN capabcont END 
             {
               ParseNode RESULT =null;
                int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
             {
               ParseNode RESULT =null;
                int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
@@ -668,7 +737,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 23: // capabcont ::= capabcont cont 
+          case 25: // capabcont ::= capabcont cont 
             {
               ParseNode RESULT =null;
                int ccontleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int ccontleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -686,7 +755,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 24: // capabcont ::= 
+          case 26: // capabcont ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -698,7 +767,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 25: // cont ::= DESCRIPTION ASSIGN STRINGCONST SEMICOLON 
+          case 27: // cont ::= DESCRIPTION ASSIGN STRINGCONST SEMICOLON 
             {
               ParseNode RESULT =null;
                int dscleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
             {
               ParseNode RESULT =null;
                int dscleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
@@ -717,7 +786,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 26: // cont ::= METHOD ASSIGN STRINGCONST SEMICOLON 
+          case 28: // cont ::= METHOD ASSIGN STRINGCONST SEMICOLON 
             {
               ParseNode RESULT =null;
                int mtdleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
             {
               ParseNode RESULT =null;
                int mtdleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
@@ -736,7 +805,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 27: // reqlist ::= reqlist require 
+          case 29: // reqlist ::= reqlist require 
             {
               ParseNode RESULT =null;
                int rlleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int rlleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -754,7 +823,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 28: // reqlist ::= 
+          case 30: // reqlist ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -766,7 +835,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 29: // require ::= REQUIRES IDENT WITH capintlist AS INTERFACE IDENT SEMICOLON 
+          case 31: // require ::= REQUIRES IDENT WITH capintlist AS INTERFACE IDENT SEMICOLON 
             {
               ParseNode RESULT =null;
                int idintleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).left;
             {
               ParseNode RESULT =null;
                int idintleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-6)).left;
@@ -790,7 +859,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 30: // capintlist ::= IDENT 
+          case 32: // capintlist ::= IDENT 
             {
               ParseNode RESULT =null;
                int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
             {
               ParseNode RESULT =null;
                int idcapleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
@@ -806,7 +875,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 31: // capintlist ::= capintlist COMMA IDENT 
+          case 33: // capintlist ::= capintlist COMMA IDENT 
             {
               ParseNode RESULT =null;
                int cilleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
             {
               ParseNode RESULT =null;
                int cilleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
@@ -824,7 +893,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 32: // capintlist ::= 
+          case 34: // capintlist ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -836,7 +905,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 33: // enumdec ::= ENUM IDENT BEGIN enumlist END 
+          case 35: // enumdec ::= ENUM IDENT BEGIN enumlist END 
             {
               ParseNode RESULT =null;
                int idenumdecleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
             {
               ParseNode RESULT =null;
                int idenumdecleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
@@ -856,7 +925,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 34: // enumlist ::= enumlist enummem 
+          case 36: // enumlist ::= enumlist enummem 
             {
               ParseNode RESULT =null;
                int elleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int elleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -874,7 +943,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 35: // enumlist ::= 
+          case 37: // enumlist ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -886,7 +955,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 36: // enummem ::= IDENT COMMA 
+          case 38: // enummem ::= IDENT COMMA 
             {
               ParseNode RESULT =null;
                int idenumleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int idenumleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -902,7 +971,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 37: // enummem ::= IDENT 
+          case 39: // enummem ::= IDENT 
             {
               ParseNode RESULT =null;
                int idenumleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
             {
               ParseNode RESULT =null;
                int idenumleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.peek()).left;
@@ -918,7 +987,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 38: // structdec ::= STRUCT IDENT BEGIN structlist END 
+          case 40: // structdec ::= STRUCT IDENT BEGIN structlist END 
             {
               ParseNode RESULT =null;
                int idstructdecleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
             {
               ParseNode RESULT =null;
                int idstructdecleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-3)).left;
@@ -938,7 +1007,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 39: // structlist ::= structlist structmem 
+          case 41: // structlist ::= structlist structmem 
             {
               ParseNode RESULT =null;
                int slleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
             {
               ParseNode RESULT =null;
                int slleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-1)).left;
@@ -956,7 +1025,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 40: // structlist ::= 
+          case 42: // structlist ::= 
             {
               ParseNode RESULT =null;
                
             {
               ParseNode RESULT =null;
                
@@ -968,7 +1037,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 41: // structmem ::= TYPE IDENT SEMICOLON 
+          case 43: // structmem ::= TYPE IDENT SEMICOLON 
             {
               ParseNode RESULT =null;
                int typestrleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
             {
               ParseNode RESULT =null;
                int typestrleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
@@ -988,7 +1057,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 42: // structmem ::= IDENT IDENT SEMICOLON 
+          case 44: // structmem ::= IDENT IDENT SEMICOLON 
             {
               ParseNode RESULT =null;
                int clsstrleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
             {
               ParseNode RESULT =null;
                int clsstrleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-2)).left;
@@ -1008,7 +1077,7 @@ class CUP$Parser$actions {
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
           return CUP$Parser$result;
 
           /*. . . . . . . . . . . . . . . . . . . .*/
-          case 43: // structmem ::= IDENT LANG IDENT RANG IDENT SEMICOLON 
+          case 45: // structmem ::= IDENT LANG IDENT RANG IDENT SEMICOLON 
             {
               ParseNode RESULT =null;
                int clsstrleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
             {
               ParseNode RESULT =null;
                int clsstrleft = ((java_cup.runtime.Symbol)CUP$Parser$stack.elementAt(CUP$Parser$top-5)).left;
index 2cd1d54347a498b9d5ade16d04615dd5e8fe2682..69ad7964ac18eb50132b0a6926dc566da7efd00c 100644 (file)
@@ -99,6 +99,15 @@ public class InterfaceDecl extends Declaration {
        }
 
 
        }
 
 
+       /**
+        * getMethodNumId() gets Id number for a method
+        */
+       public int getMethodNumId(String method) {
+
+               return listMethods.indexOf(method);
+       }
+
+
        /**
         * getMethodIds() gets method identifiers
         */
        /**
         * getMethodIds() gets method identifiers
         */
index 4f99476a61d66ddee0c629235bed45f8bcdf4520..660b6a7e877e331023be46f235dd3a02eded056d 100644 (file)
@@ -38,12 +38,13 @@ class TestClass_Stub : public TestClassInterface {
                string                                          stringC;
                //CallBackInterface                     cb;
                IoTRMICall                                      *rmiCall;
                string                                          stringC;
                //CallBackInterface                     cb;
                IoTRMICall                                      *rmiCall;
-               IoTRMIObject                            *rmiObj;
                string                                          address;
                vector<int>                                     ports;
                string                                          address;
                vector<int>                                     ports;
-               vector<CallBackInterface*>      vecCBObj;
+               const static int                        objectId = 0;   // Default value is 0
 
 
-               int             objectId = 0;   // Default value is 0
+               // Specific for callbacks
+               IoTRMIObject                            *rmiObj;
+               vector<CallBackInterface*>      vecCBObj;
                static int      objIdCnt;
 };
 
                static int      objIdCnt;
 };
 
@@ -81,6 +82,7 @@ TestClass_Stub::~TestClass_Stub() {
                delete rmiObj;
                rmiObj = NULL;
        }
                delete rmiObj;
                rmiObj = NULL;
        }
+       // Special for callbacks!!!
        for(CallBackInterface* cb : vecCBObj) {
                delete cb;
                cb = NULL;
        for(CallBackInterface* cb : vecCBObj) {
                delete cb;
                cb = NULL;
index 89e6a6e05a391886b3ad0cf5c3d825f92a74787d..9e2006d31f23ead3ad092c30a6614599510bdc02 100644 (file)
@@ -16,18 +16,24 @@ public class TestClass_Stub implements TestClassInterface {
         * Class Properties
         */
        private IoTRMICall rmiCall;
         * Class Properties
         */
        private IoTRMICall rmiCall;
+       private IoTRMIObject rmiObj;
        private String address;
        private int[] ports;
        private String address;
        private int[] ports;
-       private List<CallBackInterface> listCBObj;
-       private IoTRMIObject rmiObj;
 
        /**
         * Class Constants
         */
 
        /**
         * Class Constants
         */
-       private final static int NUM_CB_OBJ = 1;
        private int objectId = 0;       // Default value is 0
        private int objectId = 0;       // Default value is 0
+
+
+       /**
+        * Properties and constants for Callbacks!
+        */
+       private List<CallBackInterface> listCBObj;
+       private final static int NUM_CB_OBJ = 1;
        private static int objIdCnt = 0; // Counter for callback object Ids
 
        private static int objIdCnt = 0; // Counter for callback object Ids
 
+
        /**
         * Constructors
         */
        /**
         * Constructors
         */
@@ -36,6 +42,8 @@ public class TestClass_Stub implements TestClassInterface {
                address = _address;
                ports = _ports;
                rmiCall = new IoTRMICall(_port, _address, _rev);
                address = _address;
                ports = _ports;
                rmiCall = new IoTRMICall(_port, _address, _rev);
+
+               // Only for callbacks!!!
                listCBObj = new ArrayList<CallBackInterface>();
                ___initCallBack();
        }
                listCBObj = new ArrayList<CallBackInterface>();
                ___initCallBack();
        }
index be96c46279e9c48ccbffd9c8d6bf4887bfc53c41..00db795902a1743a441e2d75014cff7563fdbd4c 100644 (file)
@@ -121,6 +121,23 @@ meth       ::= PUBLIC TYPE:typemeth IDENT:idmeth LPAR paramlist:pl RPAR SEMICOLO
                pn.addChild(pl);
                RESULT = pn;
        :}
                pn.addChild(pl);
                RESULT = pn;
        :}
+       /* generic/template return value with one type, e.g. set<int> */
+    | PUBLIC IDENT:clsmeth LANG TYPE:typegen RANG IDENT:idmeth LPAR paramlist:pl RPAR SEMICOLON
+       {:
+               ParseNode pn = new ParseNode("method");
+               pn.addChild("method_class").setLiteral((String)clsmeth + "<" + typegen + ">");
+               pn.addChild("method_ident").setLiteral(idmeth);
+               pn.addChild(pl);
+               RESULT = pn;
+       :}
+    | PUBLIC IDENT:clsmeth LANG IDENT:clsgen RANG IDENT:idmeth LPAR paramlist:pl RPAR SEMICOLON
+       {:
+               ParseNode pn = new ParseNode("method");
+               pn.addChild("method_class").setLiteral((String)clsmeth + "<" + clsgen + ">");
+               pn.addChild("method_ident").setLiteral(idmeth);
+               pn.addChild(pl);
+               RESULT = pn;
+       :}
     ;
 paramlist  ::= paramlist:pl param:p
        {:
     ;
 paramlist  ::= paramlist:pl param:p
        {:
@@ -161,7 +178,7 @@ param      ::= TYPE:typeprm IDENT:idprm COMMA
                pn.addChild("param_ident").setLiteral(idprm);
                RESULT = pn;
        :}
                pn.addChild("param_ident").setLiteral(idprm);
                RESULT = pn;
        :}
-       /* generic/template with one type, e.g. list<int> */
+       /* generic/template with one type, e.g. set<int> */
     | IDENT:clsprm LANG TYPE:typegen RANG IDENT:idprm
        {:
                ParseNode pn = new ParseNode("param");
     | IDENT:clsprm LANG TYPE:typegen RANG IDENT:idprm
        {:
                ParseNode pn = new ParseNode("param");
@@ -177,7 +194,7 @@ param      ::= TYPE:typeprm IDENT:idprm COMMA
                RESULT = pn;
        :}
        /* Add comma at the end... */
                RESULT = pn;
        :}
        /* Add comma at the end... */
-       /* generic/template with one type, e.g. list<int> */
+       /* generic/template with one type, e.g. set<int> */
     | IDENT:clsprm LANG TYPE:typegen RANG IDENT:idprm COMMA
        {:
                ParseNode pn = new ParseNode("param");
     | IDENT:clsprm LANG TYPE:typegen RANG IDENT:idprm COMMA
        {:
                ParseNode pn = new ParseNode("param");