1 package org.simantics.scl.compiler.internal.header;
5 import org.simantics.scl.compiler.elaboration.expressions.EVar;
6 import org.simantics.scl.compiler.elaboration.expressions.annotations.AnnotationUtils;
7 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
8 import org.simantics.scl.compiler.errors.ErrorLog;
9 import org.simantics.scl.compiler.internal.parsing.declarations.DModuleHeader;
11 public class ModuleHeader {
12 public String classLoader;
13 public long classLoaderLocation;
14 public String defaultLocalName;
15 public boolean fields;
16 public List<EVar> export;
18 private void read(ErrorLog errorLog, DModuleHeader header) {
19 for(FieldAssignment assignment : header.fields)
20 switch(assignment.name) {
22 if(assignment.value == null)
23 errorLog.log(assignment.location, "Property classLoader needs to be given a string value.");
25 classLoader = AnnotationUtils.extractString(assignment.value);
26 if(classLoader == null)
27 errorLog.log(assignment.value.location, "Expected bundle name here.");
29 classLoaderLocation = assignment.location;
33 if(assignment.value == null)
34 errorLog.log(assignment.location, "Property export needs to be given a string list value.");
36 export = AnnotationUtils.extractIdentifierList(assignment.value);
38 errorLog.log(assignment.value.location, "Expected a list of exported items.");
41 case "defaultLocalName":
42 if(assignment.value == null)
43 errorLog.log(assignment.location, "Property defaultLocalName needs to be given a string value.");
45 defaultLocalName = AnnotationUtils.extractString(assignment.value);
46 if(defaultLocalName == null)
47 errorLog.log(assignment.value.location, "Expected string here.");
51 if(assignment.value != null)
52 errorLog.log(assignment.location, "No value expected for property fields.");
56 errorLog.logWarning(assignment.location, "Unknown module header field was skipped.");
60 public static ModuleHeader process(ErrorLog errorLog, DModuleHeader header) {
63 ModuleHeader result = new ModuleHeader();
64 result.read(errorLog, header);