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

Last change on this file was 12079, checked in by ehuelsmann, 16 years ago

Add API to execute()-able classes for hot spot profiling
next to normal stack profiling.

  • 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 12079 2009-07-31 19:45:54Z 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            Debug.assertTrue(false);
69        }
70    }
71
72    @Override
73    public LispObject execute() throws ConditionThrowable
74    {
75        return error(new UndefinedFunction(getLambdaName()));
76    }
77
78    @Override
79    public LispObject execute(LispObject arg) throws ConditionThrowable
80    {
81        return error(new UndefinedFunction(getLambdaName()));
82    }
83
84    @Override
85    public LispObject execute(LispObject first, LispObject second)
86        throws ConditionThrowable
87    {
88        return error(new UndefinedFunction(getLambdaName()));
89    }
90
91    @Override
92    public LispObject execute(LispObject first, LispObject second,
93                              LispObject third)
94        throws ConditionThrowable
95    {
96        return error(new UndefinedFunction(getLambdaName()));
97    }
98
99    @Override
100    public LispObject execute(LispObject first, LispObject second,
101                              LispObject third, LispObject fourth)
102        throws ConditionThrowable
103    {
104        return error(new UndefinedFunction(getLambdaName()));
105    }
106
107    @Override
108    public LispObject execute(LispObject first, LispObject second,
109                              LispObject third, LispObject fourth,
110                              LispObject fifth)
111        throws ConditionThrowable
112    {
113        return error(new UndefinedFunction(getLambdaName()));
114    }
115
116    @Override
117    public LispObject execute(LispObject first, LispObject second,
118                              LispObject third, LispObject fourth,
119                              LispObject fifth, LispObject sixth)
120        throws ConditionThrowable
121    {
122        return error(new UndefinedFunction(getLambdaName()));
123    }
124
125    @Override
126    public LispObject execute(LispObject first, LispObject second,
127                              LispObject third, LispObject fourth,
128                              LispObject fifth, LispObject sixth,
129                              LispObject seventh)
130        throws ConditionThrowable
131    {
132        return error(new UndefinedFunction(getLambdaName()));
133    }
134
135    @Override
136    public LispObject execute(LispObject first, LispObject second,
137                              LispObject third, LispObject fourth,
138                              LispObject fifth, LispObject sixth,
139                              LispObject seventh, LispObject eighth)
140        throws ConditionThrowable
141    {
142        return error(new UndefinedFunction(getLambdaName()));
143    }
144
145    @Override
146    public LispObject execute(LispObject[] args) throws ConditionThrowable
147    {
148        return error(new UndefinedFunction(getLambdaName()));
149    }
150
151    @Override
152    public String writeToString() throws ConditionThrowable
153    {
154        StringBuffer sb = new StringBuffer("#<SPECIAL-OPERATOR ");
155        sb.append(lambdaName.writeToString());
156        sb.append(">");
157        return sb.toString();
158    }
159
160    // Profiling.
161    @Override
162    public final int getCallCount()
163    {
164        return callCount;
165    }
166
167    @Override
168    public final void setCallCount(int n)
169    {
170        callCount = n;
171    }
172
173    @Override
174    public final void incrementCallCount()
175    {
176        ++callCount;
177    }
178
179    @Override
180    public final int getHotCount()
181    {
182        return hotCount;
183    }
184
185    @Override
186    public final void setHotCount(int n)
187    {
188        callCount = n;
189    }
190
191    @Override
192    public final void incrementHotCount()
193    {
194        ++hotCount;
195    }
196}
Note: See TracBrowser for help on using the repository browser.