01: package kawa.standard;
02:
03: import gnu.bytecode.*;
04: import gnu.mapping.*;
05: import gnu.expr.*;
06:
07: public class prim_throw extends Procedure1 implements Inlineable {
08: public static final prim_throw primitiveThrow = new prim_throw();
09:
10: public static void throw_it(Object arg1) throws Throwable {
11: throw ((Throwable) arg1);
12: }
13:
14: public Object apply1(Object arg1) throws Throwable {
15: throw_it(arg1);
16: return Values.empty;
17: }
18:
19: private static ClassType javaThrowableType;
20:
21: public void compile(ApplyExp exp, Compilation comp, Target target) {
22: // Check that exp.args.length == 1. FIXME!
23: gnu.bytecode.CodeAttr code = comp.getCode();
24: exp.getArgs()[0].compile(comp, Target.pushObject);
25: if (javaThrowableType == null)
26: javaThrowableType = new ClassType("java.lang.Throwable");
27: code.emitCheckcast(javaThrowableType);
28: code.emitThrow();
29: }
30:
31: public Type getReturnType(Expression[] args) {
32: return Type.neverReturnsType;
33: }
34: }
|