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;
10 public class ModuleHeader {
11 public String classLoader;
12 public long classLoaderLocation;
13 public String defaultLocalName;
14 public List<EVar> export;
17 public boolean fields;
19 private void read(ErrorLog errorLog, FieldAssignment[] fields) {
20 for(FieldAssignment assignment : fields)
21 switch(assignment.name) {
23 if(assignment.value == null)
24 errorLog.log(assignment.location, "Property classLoader needs to be given a string value.");
26 classLoader = AnnotationUtils.extractString(assignment.value);
27 if(classLoader == null)
28 errorLog.log(assignment.value.location, "Expected bundle name here.");
30 classLoaderLocation = assignment.location;
34 if(assignment.value == null)
35 errorLog.log(assignment.location, "Property export needs to be given a string list value.");
37 export = AnnotationUtils.extractIdentifierList(assignment.value);
39 errorLog.log(assignment.value.location, "Expected a list of exported items.");
42 case "defaultLocalName":
43 if(assignment.value == null)
44 errorLog.log(assignment.location, "Property defaultLocalName needs to be given a string value.");
46 defaultLocalName = AnnotationUtils.extractString(assignment.value);
47 if(defaultLocalName == null)
48 errorLog.log(assignment.value.location, "Expected string here.");
52 if(assignment.value != null)
53 errorLog.log(assignment.location, "No value expected for property fields.");
57 if(assignment.value != null)
58 errorLog.log(assignment.location, "No value expected for property chr.");
62 errorLog.logWarning(assignment.location, "Unknown module header field was skipped.");
66 public static ModuleHeader process(ErrorLog errorLog, FieldAssignment[] fields) {
69 ModuleHeader result = new ModuleHeader();
70 result.read(errorLog, fields);