]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java
c49b49abed9da680c60a525602bd28a4b17026e2
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / header / ModuleHeader.java
1 package org.simantics.scl.compiler.internal.header;
2
3 import org.simantics.scl.compiler.elaboration.expressions.annotations.AnnotationUtils;
4 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
5 import org.simantics.scl.compiler.errors.ErrorLog;
6 import org.simantics.scl.compiler.internal.parsing.declarations.DModuleHeader;
7
8 public class ModuleHeader {
9     public String classLoader;
10     public long classLoaderLocation;
11     
12     private void read(ErrorLog errorLog, DModuleHeader header) {
13         for(FieldAssignment assignment : header.fields)
14             switch(assignment.name) {
15             case "classLoader":
16                 if(assignment.value == null)
17                     errorLog.log(assignment.location, "Property classLoader needs to be given a string value.");
18                 else {
19                     classLoader = AnnotationUtils.extractString(assignment.value);
20                     if(classLoader == null)
21                         errorLog.log(assignment.value.location, "Expected bundle name here.");
22                     else 
23                         classLoaderLocation = assignment.location;
24                 }
25                 break;
26             default:
27                 errorLog.logWarning(assignment.location, "Unknown module header field was skipped.");
28             }
29     }
30     
31     public static ModuleHeader process(ErrorLog errorLog, DModuleHeader header) {
32         if(header == null)
33             return null;
34         ModuleHeader result = new ModuleHeader();
35         result.read(errorLog, header);
36         return result;
37     }
38 }