]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java
(refs #7386) Minor SCL tools improvements
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / compilation / Elaboration.java
index 6499ab4fe7d09fac0fd4f793fd4b3e7b2f6da80d..ff5ee3b2902fa0384258f246776d534dbed0d617 100644 (file)
@@ -41,6 +41,7 @@ import org.simantics.scl.compiler.elaboration.fundeps.Fundep;
 import org.simantics.scl.compiler.elaboration.java.JavaMethodDeclaration;
 import org.simantics.scl.compiler.elaboration.macros.StandardMacroRule;
 import org.simantics.scl.compiler.elaboration.modules.DeprecatedProperty;
+import org.simantics.scl.compiler.elaboration.modules.DerivedProperty;
 import org.simantics.scl.compiler.elaboration.modules.InlineProperty;
 import org.simantics.scl.compiler.elaboration.modules.MethodImplementation;
 import org.simantics.scl.compiler.elaboration.modules.PrivateProperty;
@@ -60,7 +61,9 @@ import org.simantics.scl.compiler.environment.AmbiguousNameException;
 import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.environment.EnvironmentFactory;
 import org.simantics.scl.compiler.environment.Environments;
+import org.simantics.scl.compiler.errors.CompilationError;
 import org.simantics.scl.compiler.errors.ErrorLog;
+import org.simantics.scl.compiler.errors.ErrorSeverity;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
 import org.simantics.scl.compiler.internal.codegen.effects.ThreadLocalVariable;
@@ -178,7 +181,7 @@ public class Elaboration {
             compilationContext.environment = new EnvironmentOfModule(importedEnvironment, module);
         } catch (ImportFailureException e) {
             for(ImportFailure failure : e.failures)
-                errorLog.log(failure.location, failure.toString());
+                errorLog.log(new CompilationError(failure.location, failure.toString(), ErrorSeverity.IMPORT_ERROR));
             return;
         }
         for(ImportDeclaration importAst : importsAst)
@@ -375,7 +378,7 @@ public class Elaboration {
             dataTypes.add(dataType);
             for(int j=0;j<constructors.length;++j) {
                 ConstructorAst constructor = dataTypeAst.constructors[j];
-                String name = constructor.name;
+                String name = constructor.name.text;
                 Type[] parameterTypes = new Type[constructor.parameters.length];
                 for(int i=constructor.parameters.length-1;i>=0;--i)
                     parameterTypes[i] = context.toType(constructor.parameters[i]);
@@ -602,6 +605,7 @@ public class Elaboration {
                     String fullName = instancePrefix + valueName;
                     long loc = valueDefs.getDefinition(valueName).get(0).location;
                     valueDefinitionsAst.addFrom(valueDefs, valueName, fullName);
+                    valueDefinitionsAst.setDerived(fullName);
                     /*valueDefinitionsAst.addAnnotation(fullName, new DAnnotationAst(new EVar("@private"), 
                             Collections.<Expression>emptyList()));*/
                     TypeClassMethod method = typeClass.methods.get(valueName);
@@ -1111,6 +1115,7 @@ public class Elaboration {
             int constructorTag = 0;
             for(Constructor constructor : dataType.constructors) {
                 SCLValue value = new SCLValue(constructor.name);
+                value.definitionLocation = constructor.loc;
                 SCLConstructor sclConstructor = 
                         new SCLConstructor(
                                 constructor.name.name,
@@ -1171,6 +1176,8 @@ public class Elaboration {
             value.definitionLocation = location;
             if(module.addValue(value))
                 errorLog.log(location, "Value " + name + " is already defined.");
+            if(valueDefinitionsAst.isDerived(name))
+                value.addProperty(DerivedProperty.INSTANCE);
         }
         for(DValueTypeAst valueTypeAst : typeAnnotationsAst)
             for(EVar name : valueTypeAst.names) {