source: trunk/abcl/src/org/armedbear/lisp/SpecialOperator.java @ 12252

Last change on this file since 12252 was 12252, checked in by ehuelsmann, 15 years ago

Annotate dubious uses of ConditionThrowable? with FIXME's.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1/*
2 * SpecialOperator.java
3 *
4 * Copyright (C) 2002-2005 Peter Graves
5 * $Id: SpecialOperator.java 12252 2009-11-05 21:52:10Z ehuelsmann $
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 * As a special exception, the copyright holders of this library give you
22 * permission to link this library with independent modules to produce an
23 * executable, regardless of the license terms of these independent
24 * modules, and to copy and distribute the resulting executable under
25 * terms of your choice, provided that you also meet, for each linked
26 * independent module, the terms and conditions of the license of that
27 * module.  An independent module is a module which is not derived from
28 * or based on this library.  If you modify this library, you may extend
29 * this exception to your version of the library, but you are not
30 * obligated to do so.  If you do not wish to do so, delete this
31 * exception statement from your version.
32 */
33
34package org.armedbear.lisp;
35
36public class SpecialOperator extends Operator
37{
38    private int callCount;
39    private int hotCount;
40
41    public SpecialOperator(Symbol symbol)
42    {
43        symbol.setSymbolFunction(this);
44        setLambdaName(symbol);
45    }
46
47    public SpecialOperator(Symbol symbol, String arglist)
48    {
49        symbol.setSymbolFunction(this);
50        setLambdaName(symbol);
51        setLambdaList(new SimpleString(arglist));
52    }
53
54    public SpecialOperator(String name, Package pkg, boolean exported,
55                           String arglist)
56    {
57        try {
58            Symbol symbol;
59            if (exported)
60                symbol = pkg.internAndExport(name.toUpperCase());
61            else
62                symbol = pkg.intern(name.toUpperCase());
63            symbol.setSymbolFunction(this);
64            setLambdaName(symbol);
65            setLambdaList(new SimpleString(arglist));
66        }
67        catch (ConditionThrowable t) {
68            // ### FIXME exception
69            Debug.assertTrue(false);
70        }
71    }
72
73    @Override
74    public LispObject execute() throws ConditionThrowable
75    {
76        return error(new UndefinedFunction(getLambdaName()));
77    }
78
79    @Override
80    public LispObject execute(LispObject arg) throws ConditionThrowable
81    {
82        return error(new UndefinedFunction(getLambdaName()));
83    }
84
85    @Override
86    public LispObject execute(LispObject first, LispObject second)
87        throws ConditionThrowable
88    {
89        return error(new UndefinedFunction(getLambdaName()));
90    }
91
92    @Override
93    public LispObject execute(LispObject first, LispObject second,
94                              LispObject third)
95        throws ConditionThrowable
96    {
97        return error(new UndefinedFunction(getLambdaName()));
98    }
99
100    @Override
101    public LispObject execute(LispObject first, LispObject second,
102                              LispObject third, LispObject fourth)
103        throws ConditionThrowable
104    {
105        return error(new UndefinedFunction(getLambdaName()));
106    }
107
108    @Override
109    public LispObject execute(LispObject first, LispObject second,
110                              LispObject third, LispObject fourth,
111                              LispObject fifth)
112        throws ConditionThrowable
113    {
114        return error(new UndefinedFunction(getLambdaName()));
115    }
116
117    @Override
118    public LispObject execute(LispObject first, LispObject second,
119                              LispObject third, LispObject fourth,
120                              LispObject fifth, LispObject sixth)
121        throws ConditionThrowable
122    {
123        return error(new UndefinedFunction(getLambdaName()));
124    }
125
126    @Override
127    public LispObject execute(LispObject first, LispObject second,
128                              LispObject third, LispObject fourth,
129                              LispObject fifth, LispObject sixth,
130                              LispObject seventh)
131        throws ConditionThrowable
132    {
133        return error(new UndefinedFunction(getLambdaName()));
134    }
135
136    @Override
137    public LispObject execute(LispObject first, LispObject second,
138                              LispObject third, LispObject fourth,
139                              LispObject fifth, LispObject sixth,
140                              LispObject seventh, LispObject eighth)
141        throws ConditionThrowable
142    {
143        return error(new UndefinedFunction(getLambdaName()));
144    }
145
146    @Override
147    public LispObject execute(LispObject[] args) throws ConditionThrowable
148    {
149        return error(new UndefinedFunction(getLambdaName()));
150    }
151
152    @Override
153    public String writeToString() throws ConditionThrowable
154    {
155        StringBuffer sb = new StringBuffer("#<SPECIAL-OPERATOR ");
156        sb.append(lambdaName.writeToString());
157        sb.append(">");
158        return sb.toString();
159    }
160
161    // Profiling.
162    @Override
163    public final int getCallCount()
164    {
165        return callCount;
166    }
167
168    @Override
169    public final void setCallCount(int n)
170    {
171        callCount = n;
172    }
173
174    @Override
175    public final void incrementCallCount()
176    {
177        ++callCount;
178    }
179
180    @Override
181    public final int getHotCount()
182    {
183        return hotCount;
184    }
185
186    @Override
187    public final void setHotCount(int n)
188    {
189        callCount = n;
190    }
191
192    @Override
193    public final void incrementHotCount()
194    {
195        ++hotCount;
196    }
197}
Note: See TracBrowser for help on using the repository browser.