1 package org.simantics.scl.compiler.elaboration.java;
3 import org.cojen.classfile.TypeDesc;
4 import org.osgi.service.component.annotations.Component;
5 import org.simantics.scl.compiler.common.names.Name;
6 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
7 import org.simantics.scl.compiler.elaboration.expressions.EApply;
8 import org.simantics.scl.compiler.elaboration.expressions.EExternalConstant;
9 import org.simantics.scl.compiler.elaboration.expressions.Expression;
10 import org.simantics.scl.compiler.elaboration.macros.MacroRule;
11 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
12 import org.simantics.scl.compiler.internal.codegen.types.StandardTypeConstructor;
13 import org.simantics.scl.compiler.module.ConcreteModule;
14 import org.simantics.scl.compiler.module.repository.ModuleRepository;
15 import org.simantics.scl.compiler.types.TCon;
16 import org.simantics.scl.compiler.types.Type;
17 import org.simantics.scl.compiler.types.Types;
18 import org.simantics.scl.compiler.types.kinds.Kinds;
21 public class ReflectionJavaModule extends ConcreteModule {
23 public static ReflectionJavaModule INSTANCE = new ReflectionJavaModule();
25 public ReflectionJavaModule() {
26 super("SCL/ReflectionJava");
28 // ModuleRepository type
29 TCon ModuleRepository = Types.con(getName(), "ModuleRepository");
30 StandardTypeConstructor markerConstructor = new StandardTypeConstructor(ModuleRepository,
31 Kinds.STAR, TypeDesc.forClass(ModuleRepository.class));
32 markerConstructor.external = true;
33 addTypeDescriptor("ModuleRepository", markerConstructor);
35 // MODULE_REPOSITORY value
36 SCLValue value = new SCLValue(Name.create(getName(), "MODULE_REPOSITORY"));
37 value.setType(Types.functionE(Types.PUNIT, Types.NO_EFFECTS, ModuleRepository));
38 value.setMacroRule(new MacroRule() {
40 public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
41 if(apply.parameters.length != 1)
43 return new EExternalConstant(context.getCompilationContext().moduleRepository, ModuleRepository);
48 setParentClassLoader(getClass().getClassLoader());