]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java
(refs #7541) Added support for module deprecation
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / compilation / Elaboration.java
index ff5ee3b2902fa0384258f246776d534dbed0d617..f7f745841460bdbfc30aacbd0a35b5174620208f 100644 (file)
@@ -169,12 +169,17 @@ public class Elaboration {
 
         module = new ConcreteModule(moduleName);
         compilationContext.module = module;
-        if(moduleHeader != null && moduleHeader.defaultLocalName != null)
-               module.setDefaultLocalName(moduleHeader.defaultLocalName);
+        if(moduleHeader != null) {
+            if(moduleHeader.defaultLocalName != null)
+                module.setDefaultLocalName(moduleHeader.defaultLocalName);
+            if(moduleHeader.deprecated != null)
+                module.setDeprecation(moduleHeader.deprecated);
+        }
         try {
             if(timer != null)
                 timer.suspendTimer();
             importedEnvironment = localEnvironmentFactory.createEnvironment(
+                    compilationContext,
                     importsAst.toArray(new ImportDeclaration[importsAst.size()]));
             if(timer != null)
                 timer.continueTimer();
@@ -712,7 +717,7 @@ public class Elaboration {
                     type);
             if(callJava != null) {
                 NameExistenceChecks.checkIfValueExists(errorLog, javaMethod.location,
-                        importedEnvironment, name);
+                        importedEnvironment, module, name);
                 SCLValue value = module.addValue(name, callJava);
                 value.definitionLocation = javaMethod.methodName.location;
                 if(isPrivate)
@@ -1137,7 +1142,7 @@ public class Elaboration {
                 value.setType(constructor.getType());
                 
                 NameExistenceChecks.checkIfValueExists(errorLog, constructor.loc,
-                        importedEnvironment, constructor.name.name);
+                        importedEnvironment, module, constructor.name.name);
                 if(module.addValue(value)) {
                     errorLog.log(constructor.loc,
                             "Value " + constructor.name.name + " is already defined.");
@@ -1152,7 +1157,7 @@ public class Elaboration {
                 SCLValue value = method.createValue();
                 value.definitionLocation = method.location;
                 NameExistenceChecks.checkIfValueExists(errorLog, Locations.NO_LOCATION,
-                        importedEnvironment, value.getName().name);
+                        importedEnvironment, module, value.getName().name);
 
                 if(module.addValue(value)) {
                     String name = method.getName();
@@ -1172,7 +1177,7 @@ public class Elaboration {
             
             long location = valueDefinitionsAst.getLocation(name);
             NameExistenceChecks.checkIfValueExists(errorLog, location,
-                    importedEnvironment, value.getName().name);
+                    importedEnvironment, module, value.getName().name);
             value.definitionLocation = location;
             if(module.addValue(value))
                 errorLog.log(location, "Value " + name + " is already defined.");
@@ -1215,6 +1220,25 @@ public class Elaboration {
         
         for(String name : valueDefinitionsAst.getValueNames()) {
             ArrayList<DValueAst> defs = valueDefinitionsAst.getDefinition(name);
+            if(defs.size() != 1 || !(defs.get(0).value instanceof EPreCHRRulesetConstructor))
+                continue;
+            try {
+                SCLValue value = module.getValue(name);
+                TranslationContext context = createTranslationContext();
+                Expression expression = context.translateCases2(defs);
+                value.setExpression(expression);
+                
+                if(exportMap != null && exportMap.remove(name) == null)
+                    value.addProperty(PrivateProperty.INSTANCE);
+            } catch(RuntimeException e) {
+                errorLog.setExceptionPosition(defs.get(0).location);
+                throw e;
+            }
+        }
+        for(String name : valueDefinitionsAst.getValueNames()) {
+            ArrayList<DValueAst> defs = valueDefinitionsAst.getDefinition(name);
+            if(defs.size() == 1 && defs.get(0).value instanceof EPreCHRRulesetConstructor)
+                continue;
             try {
                 SCLValue value = module.getValue(name);
                 TranslationContext context = createTranslationContext();