1 package gnu.kawa.functions; 2 import gnu.bytecode.*; 3 import gnu.mapping.*; 4 import gnu.expr.*; 5 6 10 11 public class GetModuleClass extends Procedure0 12 implements Inlineable 13 { 14 public static final GetModuleClass getModuleClass 15 = new GetModuleClass(); 16 17 public Object apply0 () 18 { 19 throw new Error ("get-module-class must be inlined"); 20 } 21 22 public void compile (ApplyExp exp, Compilation comp, Target target) 23 { 24 comp.loadClassRef(comp.mainClass); 25 target.compileFromStack(comp, ClassType.make("java.lang.Class")); 26 } 27 28 public gnu.bytecode.Type getReturnType (Expression[] args) 29 { 30 return ClassType.make("java.lang.Class"); 31 } 32 33 private static String CLASS_RESOURCE_NAME = "$class_resource_URI$"; 34 35 39 public static Expression getModuleClassURI (Compilation comp) 40 { 41 Declaration decl = comp.mainLambda.lookup(CLASS_RESOURCE_NAME); 42 if (decl == null) 43 { 44 comp.mustCompileHere(); 45 decl = new Declaration(CLASS_RESOURCE_NAME); 46 decl.setFlag(Declaration.IS_CONSTANT|Declaration.STATIC_SPECIFIED); 47 Method maker = ClassType.make("gnu.text.URI_utils") 48 .getDeclaredMethod("makeClassResourceURI", 1); 49 Expression clas 50 = new ApplyExp(gnu.kawa.functions.GetModuleClass.getModuleClass, 51 Expression.noExpressions); 52 decl.setValue(new ApplyExp(maker, new Expression[] { clas })); 53 comp.mainLambda.add(null, decl); 54 } 55 return new ReferenceExp(decl); 56 } 57 } 58 | Popular Tags |