KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > lisp > CompiledClosure


1 /*
2  * CompiledClosure.java
3  *
4  * Copyright (C) 2004 Peter Graves
5  * $Id: CompiledClosure.java,v 1.2 2004/07/21 18:10:05 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.lisp;
23
24 public class CompiledClosure extends Function
25 {
26     private final ClosureTemplateFunction ctf;
27     private final LispObject[][] context;
28
29     public CompiledClosure(ClosureTemplateFunction ctf, LispObject[][] context)
30     {
31         this.ctf = ctf;
32         this.context = context;
33     }
34
35     protected final LispObject[] processArgs(LispObject[] args, int extra)
36         throws ConditionThrowable
37     {
38         return ctf.processArgs(args, extra);
39     }
40
41     public LispObject execute() throws ConditionThrowable
42     {
43         LispObject[] args = new LispObject[0];
44         return ctf.execute(args, context);
45     }
46
47     public LispObject execute(LispObject arg) throws ConditionThrowable
48     {
49         LispObject[] args = new LispObject[1];
50         args[0] = arg;
51         return ctf.execute(args, context);
52     }
53
54     public LispObject execute(LispObject first, LispObject second)
55         throws ConditionThrowable
56     {
57         LispObject[] args = new LispObject[2];
58         args[0] = first;
59         args[1] = second;
60         return ctf.execute(args, context);
61     }
62
63     public LispObject execute(LispObject first, LispObject second,
64                               LispObject third)
65         throws ConditionThrowable
66     {
67         LispObject[] args = new LispObject[3];
68         args[0] = first;
69         args[1] = second;
70         args[2] = third;
71         return ctf.execute(args, context);
72     }
73
74     public LispObject execute(LispObject first, LispObject second,
75                               LispObject third, LispObject fourth)
76         throws ConditionThrowable
77     {
78         LispObject[] args = new LispObject[4];
79         args[0] = first;
80         args[1] = second;
81         args[2] = third;
82         args[3] = fourth;
83         return ctf.execute(args, context);
84     }
85
86     public LispObject execute(LispObject[] args) throws ConditionThrowable
87     {
88         return ctf.execute(args, context);
89     }
90 }
91
Popular Tags