X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fheader%2FModuleHeader.java;h=0ab17f83478313ee3f5df5209850ce3178b198ef;hp=33a88ffba83dee70893e841c6cb516407ebca6fb;hb=6573b29e111ea03c3fa88bf1565d47d0fc4faabd;hpb=b2676209b072592da3425c2efb29f51eb5c4a0e0 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java index 33a88ffba..0ab17f834 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java @@ -6,17 +6,19 @@ import org.simantics.scl.compiler.elaboration.expressions.EVar; import org.simantics.scl.compiler.elaboration.expressions.annotations.AnnotationUtils; import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment; import org.simantics.scl.compiler.errors.ErrorLog; -import org.simantics.scl.compiler.internal.parsing.declarations.DModuleHeader; public class ModuleHeader { public String classLoader; public long classLoaderLocation; public String defaultLocalName; - public boolean fields; public List export; - private void read(ErrorLog errorLog, DModuleHeader header) { - for(FieldAssignment assignment : header.fields) + // Features + public boolean chr; + public boolean fields; + + private void read(ErrorLog errorLog, FieldAssignment[] fields) { + for(FieldAssignment assignment : fields) switch(assignment.name) { case "bundle": if(assignment.value == null) @@ -31,37 +33,52 @@ public class ModuleHeader { break; case "export": if(assignment.value == null) - errorLog.log(assignment.location, "Property export needs to be given a string list value."); + errorLog.log(assignment.location, "Property export needs to be given a list of exported symbols."); else { export = AnnotationUtils.extractIdentifierList(assignment.value); if(export == null) - errorLog.log(assignment.value.location, "Expected a list of exported items."); + errorLog.log(assignment.value.location, "Expected a list of exported symbols."); + } + break; + case "features": + if(assignment.value == null) + errorLog.log(assignment.location, "Property features needs to be given a list of features (identifiers)."); + else { + List features = AnnotationUtils.extractIdentifierList(assignment.value); + if(features == null) + errorLog.log(assignment.value.location, "Expected a list of features (identifiers)."); + for(EVar feature : features) + handleFeature(errorLog, feature); } break; case "defaultLocalName": - if(assignment.value == null) + if(assignment.value == null) errorLog.log(assignment.location, "Property defaultLocalName needs to be given a string value."); - else { - defaultLocalName = AnnotationUtils.extractString(assignment.value); - if(defaultLocalName == null) - errorLog.log(assignment.value.location, "Expected string here."); - } - break; - case "fields": - if(assignment.value != null) - errorLog.log(assignment.location, "No value expected for property fields."); - this.fields = true; + else { + defaultLocalName = AnnotationUtils.extractString(assignment.value); + if(defaultLocalName == null) + errorLog.log(assignment.value.location, "Expected string here."); + } break; default: errorLog.logWarning(assignment.location, "Unknown module header field was skipped."); } } - public static ModuleHeader process(ErrorLog errorLog, DModuleHeader header) { - if(header == null) + private void handleFeature(ErrorLog errorLog, EVar feature) { + switch(feature.name) { + case "chr": chr = true; break; + case "fields": fields = true; break; + default: + errorLog.log(feature.location, "Unknown feature " + feature.name + "."); + } + } + + public static ModuleHeader process(ErrorLog errorLog, FieldAssignment[] fields) { + if(fields == null) return null; ModuleHeader result = new ModuleHeader(); - result.read(errorLog, header); + result.read(errorLog, fields); return result; } }