]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java
(refs #6923) Explicit export annotation for SCL modules
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / compilation / Elaboration.java
index 9dbd94691a82cd27bab16a4a7be498e39fee2852..1cba44207ee7c124de787ceff3b7631421084c1b 100644 (file)
@@ -1098,7 +1098,8 @@ public class Elaboration {
                                 constructor.getParameterTypes());
                 if(dataType.constructors.length == 1 && (
                         dataType.getTypeDesc() == null ||
-                        dataType.constructors[0].javaName.equals(MethodBuilderBase.getClassName(dataType.getTypeDesc()))))
+                        (dataType.constructors[0].javaName != null &&
+                        dataType.constructors[0].javaName.equals(MethodBuilderBase.getClassName(dataType.getTypeDesc())))))
                     sclConstructor.setOnlyConstructor(true);
                 value.setValue(sclConstructor);
                 value.setType(constructor.getType());
@@ -1170,6 +1171,14 @@ public class Elaboration {
                     typeMap.put(name.name, valueTypeAst);
             }
         
+        THashMap<String, EVar> exportMap = null;
+        if(moduleHeader != null && moduleHeader.export != null) {
+            exportMap = new THashMap<String, EVar>();
+            for(EVar export : moduleHeader.export)
+                if(exportMap.put(export.name, export) != null)
+                    errorLog.log(export.location, "The symbol " + export.name + " is exported multiple times.");
+        }
+        
         for(String name : valueDefinitionsAst.getValueNames()) {
             ArrayList<DValueAst> defs = valueDefinitionsAst.getDefinition(name);
             try {
@@ -1187,11 +1196,16 @@ public class Elaboration {
                     for(DAnnotationAst annotation : annotations) {
                         handleAnnotation(value, defs, annotation);
                     }
+                if(exportMap != null && exportMap.remove(name) == null)
+                    value.addProperty(PrivateProperty.INSTANCE);
             } catch(RuntimeException e) {
                 errorLog.setExceptionPosition(defs.get(0).location);
                 throw e;
             }
         }
+        if(exportMap != null)
+            for(EVar export : exportMap.values())
+                errorLog.log(export.location, "The symbol " + export.name + " is not defined in the module.");
         for(String name : relationDefinitionsAst.getRelationNames()) {
             ArrayList<DRelationAst> definitions = relationDefinitionsAst.getDefinition(name);
             if(definitions.size() > 1) {
@@ -1229,6 +1243,8 @@ public class Elaboration {
             }
         }
         else if(annotation.id.text.equals("@private")) {
+            if(moduleHeader != null && moduleHeader.export != null)
+                errorLog.log(annotation.location, "Annotation @private is not used when module header contains export property.");
             value.addProperty(PrivateProperty.INSTANCE);
         }
         else if(annotation.id.text.equals("@deprecated")) {