]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
changed the declaration of Enum_size = Enum.size and Enum_elements = Enum.elements...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 19 Jan 2012 13:18:03 +0000 (13:18 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 19 Jan 2012 13:18:03 +0000 (13:18 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24005 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Enumeration.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Redeclaration.java

index 152d29888e5f63bf2ab4ed6456d3df6c8cdd666d..51996a197f2657531652f7f46537e75944532a1f 100644 (file)
@@ -46,6 +46,9 @@ public class Enumeration extends Variable {
                sb.append(this.name + "_class");\r
                sb.append(" " + this.name);\r
                sb.append(";\n");\r
+               \r
+               sb.append("    parameter Integer " + this.name + "_size = " + this.name + ".size;\n");\r
+               sb.append("    parameter Integer " + this.name + "_elements[:] = " + this.name + ".elements;\n");\r
                return sb.toString();\r
        }\r
        \r
index 9a89df0287d3c2a3ffd113ad9f783182033fa833..c5ece68c5759a043ed687912e42a5707a163fc7b 100644 (file)
@@ -65,17 +65,13 @@ public class Module implements IElement {
      */\r
     public String getDeclaration() {\r
        \r
-       StringBuilder parameters = new StringBuilder();\r
        StringBuilder redeclarations = new StringBuilder();\r
-       \r
-       \r
        if(!getRedeclarations().isEmpty()) {\r
                redeclarations.append("(");\r
                Iterator<Redeclaration> i = getRedeclarations().iterator();\r
                while(i.hasNext()) {\r
                        Redeclaration rd = i.next();\r
                        redeclarations.append(rd.getRedeclaration());\r
-                       parameters.append(rd.getParameters());\r
                        if(i.hasNext())\r
                                redeclarations.append(",");\r
                }\r
@@ -84,7 +80,6 @@ public class Module implements IElement {
        \r
        \r
        StringBuilder sb = new StringBuilder();\r
-       sb.append(parameters);\r
        sb.append("    ");\r
        sb.append(getType().getName());\r
        sb.append(" ");\r
index 40d5ade7f9607b584e79e8182e1de476e77040f5..6f1e8b3c201622fb56346f073643385685a55782 100644 (file)
@@ -28,63 +28,18 @@ public class Redeclaration {
        if(replacedEnumeration == null || replacingEnumeration == null) {\r
                return "";\r
        }\r
-       String separator = getSeparator();\r
        StringBuilder sb = new StringBuilder();\r
        sb.append(replacedEnumeration.getName());\r
        sb.append(".size = ");\r
        sb.append(replacingEnumeration.getName());\r
-       sb.append(separator + "size, ");\r
+       sb.append("_size, ");\r
        sb.append(replacedEnumeration.getName());\r
        sb.append(".elements = ");\r
        sb.append(replacingEnumeration.getName());\r
-       sb.append(separator + "elements");\r
+       sb.append("_elements");\r
        \r
        return sb.toString();\r
     }\r
-    \r
-    /**\r
-     * Change the name of the re-declaration parameters to enable the use of \r
-     * enumerations with same names.\r
-     * \r
-     * @return\r
-     */\r
-    public String getParameters() {\r
-       String separator = getSeparator();\r
-       StringBuilder sb = new StringBuilder();\r
-       sb.append("    parameter Integer " + replacingEnumeration.getName() + separator + "size = " + replacingEnumeration.getName() + ".size;\n");\r
-       sb.append("    parameter Integer " + replacingEnumeration.getName() + separator + "elements[:] = " + replacingEnumeration.getName() + ".elements;\n");\r
-       return sb.toString();\r
-    }\r
-    \r
-    private String getSeparator() {\r
-       return getSeparator(this, "_");\r
-    }\r
-\r
-    /**\r
-     * Add enough separation marks that name conflicts would not exist.\r
-     * \r
-     * @param redeclaration\r
-     * @param separator\r
-     * @return\r
-     */\r
-    private String getSeparator(Redeclaration redeclaration, String separator) {\r
-       if(redeclaration == null || redeclaration.replacedEnumeration == null ||\r
-                       redeclaration.replacedEnumeration.getParentConfiguration() == null)\r
-               return separator = "_";\r
-       for(IElement e : redeclaration.replacedEnumeration.getParentConfiguration().getElements()) {\r
-               if(e instanceof Module) {\r
-                       for(Redeclaration rd : ((Module)e).getRedeclarations()) {\r
-                               if(rd.replacedEnumeration.name.equals(redeclaration.replacedEnumeration.name) &&\r
-                                               rd.replacingEnumeration.equals(redeclaration.replacedEnumeration)) {\r
-                                       String separatorTmp = getSeparator(rd, separator);\r
-                                       if(separatorTmp.length() > separator.length())\r
-                                               separator = separatorTmp;\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       return separator + "_";\r
-    }\r
 \r
        public Enumeration getReplacedEnumeration() {\r
                return replacedEnumeration;\r