01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2001 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package nice.lang.inline;
12:
13: /**
14: Returns from a method, possibly with a value.
15:
16: The first argument is the returned value.
17:
18: @version $Date: 2003/04/29 11:17:07 $
19: @author Daniel Bonniot (Daniel.Bonniot@inria.fr)
20: */
21:
22: import gnu.bytecode.*;
23: import gnu.mapping.*;
24: import gnu.expr.*;
25:
26: public class Return extends Procedure1 implements Inlineable {
27: public static Return create(String param) {
28: return instance;
29: }
30:
31: public static final Return instance = new Return();
32:
33: public void compile(ApplyExp exp, Compilation comp, Target target) {
34: gnu.bytecode.CodeAttr code = comp.getCode();
35: Expression[] args = exp.getArgs();
36:
37: if (args != null && args.length != 0)
38: args[0].compile(comp, Target.pushValue(code.getMethod()
39: .getReturnType()));
40:
41: code.emitReturn();
42: }
43:
44: public Type getReturnType(Expression[] args) {
45: return Type.neverReturnsType;
46: }
47:
48: /****************************************************************
49: * Interpretation
50: ****************************************************************/
51:
52: public Object apply1(Object arg1) {
53: return arg1;
54: }
55: }
|