source: branches/0.22.x/abcl/src/org/armedbear/lisp/SpecialOperator.java

Last change on this file was 12288, checked in by vvoutilainen, 15 years ago

Don't extend Lisp in LispObject, static import Lisp wherever
necessary. Patch by Douglas R. Miles.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.4 KB
Line 
1/*
2 * SpecialOperator.java
3 *
4 * Copyright (C) 2002-2005 Peter Graves
5 * $Id: SpecialOperator.java 12288 2009-11-29 22:00:12Z vvoutilainen $
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
36import static org.armedbear.lisp.Lisp.*;
37
38public class SpecialOperator extends Operator
39{
40    private int callCount;
41    private int hotCount;
42
43    public SpecialOperator(Symbol symbol)
44    {
45        symbol.setSymbolFunction(this);
46        setLambdaName(symbol);
47    }
48
49    public SpecialOperator(Symbol symbol, String arglist)
50    {
51        symbol.setSymbolFunction(this);
52        setLambdaName(symbol);
53        setLambdaList(new SimpleString(arglist));
54    }
55
56    public SpecialOperator(String name, Package pkg, boolean exported,
57                           String arglist)
58    {
59        Symbol symbol;
60        if (exported)
61           symbol = pkg.internAndExport(name.toUpperCase());
62        else
63           symbol = pkg.intern(name.toUpperCase());
64        symbol.setSymbolFunction(this);
65        setLambdaName(symbol);
66        setLambdaList(new SimpleString(arglist));
67    }
68
69    @Override
70    public LispObject execute()
71    {
72        return error(new UndefinedFunction(getLambdaName()));
73    }
74
75    @Override
76    public LispObject execute(LispObject arg)
77    {
78        return error(new UndefinedFunction(getLambdaName()));
79    }
80
81    @Override
82    public LispObject execute(LispObject first, LispObject second)
83
84    {
85        return error(new UndefinedFunction(getLambdaName()));
86    }
87
88    @Override
89    public LispObject execute(LispObject first, LispObject second,
90                              LispObject third)
91
92    {
93        return error(new UndefinedFunction(getLambdaName()));
94    }
95
96    @Override
97    public LispObject execute(LispObject first, LispObject second,
98                              LispObject third, LispObject fourth)
99
100    {
101        return error(new UndefinedFunction(getLambdaName()));
102    }
103
104    @Override
105    public LispObject execute(LispObject first, LispObject second,
106                              LispObject third, LispObject fourth,
107                              LispObject fifth)
108
109    {
110        return error(new UndefinedFunction(getLambdaName()));
111    }
112
113    @Override
114    public LispObject execute(LispObject first, LispObject second,
115                              LispObject third, LispObject fourth,
116                              LispObject fifth, LispObject sixth)
117
118    {
119        return error(new UndefinedFunction(getLambdaName()));
120    }
121
122    @Override
123    public LispObject execute(LispObject first, LispObject second,
124                              LispObject third, LispObject fourth,
125                              LispObject fifth, LispObject sixth,
126                              LispObject seventh)
127
128    {
129        return error(new UndefinedFunction(getLambdaName()));
130    }
131
132    @Override
133    public LispObject execute(LispObject first, LispObject second,
134                              LispObject third, LispObject fourth,
135                              LispObject fifth, LispObject sixth,
136                              LispObject seventh, LispObject eighth)
137
138    {
139        return error(new UndefinedFunction(getLambdaName()));
140    }
141
142    @Override
143    public LispObject execute(LispObject[] args)
144    {
145        return error(new UndefinedFunction(getLambdaName()));
146    }
147
148    @Override
149    public String writeToString()
150    {
151        StringBuffer sb = new StringBuffer("#<SPECIAL-OPERATOR ");
152        sb.append(lambdaName.writeToString());
153        sb.append(">");
154        return sb.toString();
155    }
156
157    // Profiling.
158    @Override
159    public final int getCallCount()
160    {
161        return callCount;
162    }
163
164    @Override
165    public final void setCallCount(int n)
166    {
167        callCount = n;
168    }
169
170    @Override
171    public final void incrementCallCount()
172    {
173        ++callCount;
174    }
175
176    @Override
177    public final int getHotCount()
178    {
179        return hotCount;
180    }
181
182    @Override
183    public final void setHotCount(int n)
184    {
185        callCount = n;
186    }
187
188    @Override
189    public final void incrementHotCount()
190    {
191        ++hotCount;
192    }
193}
Note: See TracBrowser for help on using the repository browser.