X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fheader%2FModuleHeader.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fheader%2FModuleHeader.java;h=c49b49abed9da680c60a525602bd28a4b17026e2;hb=66ced93f835205135a84fea73b2fbb8e9d610f7e;hp=0000000000000000000000000000000000000000;hpb=2367c227645db518955fc142ddf6b4c5787eab42;p=simantics%2Fplatform.git 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 new file mode 100644 index 000000000..c49b49abe --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java @@ -0,0 +1,38 @@ +package org.simantics.scl.compiler.internal.header; + +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; + + private void read(ErrorLog errorLog, DModuleHeader header) { + for(FieldAssignment assignment : header.fields) + switch(assignment.name) { + case "classLoader": + if(assignment.value == null) + errorLog.log(assignment.location, "Property classLoader needs to be given a string value."); + else { + classLoader = AnnotationUtils.extractString(assignment.value); + if(classLoader == null) + errorLog.log(assignment.value.location, "Expected bundle name here."); + else + classLoaderLocation = assignment.location; + } + break; + default: + errorLog.logWarning(assignment.location, "Unknown module header field was skipped."); + } + } + + public static ModuleHeader process(ErrorLog errorLog, DModuleHeader header) { + if(header == null) + return null; + ModuleHeader result = new ModuleHeader(); + result.read(errorLog, header); + return result; + } +}