1 package kawa.standard; 2 import gnu.bytecode.*; 3 import gnu.mapping.*; 4 import gnu.expr.*; 5 6 public class prim_throw extends Procedure1 implements Inlineable 7 { 8 public static final prim_throw primitiveThrow = new prim_throw(); 9 10 public static void throw_it (Object arg1) 11 throws Throwable 12 { 13 throw ((Throwable ) arg1); 14 } 15 16 public Object apply1 (Object arg1) 17 throws Throwable 18 { 19 throw_it(arg1); 20 return Values.empty; 21 } 22 23 private static ClassType javaThrowableType; 24 25 public void compile (ApplyExp exp, Compilation comp, Target target) 26 { 27 gnu.bytecode.CodeAttr code = comp.getCode(); 29 exp.getArgs()[0].compile(comp, Target.pushObject); 30 if (javaThrowableType == null) 31 javaThrowableType = new ClassType("java.lang.Throwable"); 32 code.emitCheckcast(javaThrowableType); 33 code.emitThrow(); 34 } 35 36 public Type getReturnType (Expression[] args) 37 { 38 return Type.neverReturnsType; 39 } 40 } 41 | Popular Tags |