01: /*
02: * SpecialOperator.java
03: *
04: * Copyright (C) 2002-2003 Peter Graves
05: * $Id: SpecialOperator.java,v 1.6 2003/11/15 11:03:32 beedlem Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * 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 SpecialOperator extends Functional {
25: private final Module module;
26: private final String name;
27: private final int index;
28:
29: private int callCount;
30:
31: public SpecialOperator(String name) {
32: this .module = null;
33: this .name = name.toUpperCase();
34: this .index = 0;
35: setLambdaName(Symbol.addFunction(this .name, this ));
36: }
37:
38: public SpecialOperator(Module module, String name, int index) {
39: this .module = module;
40: this .name = name.toUpperCase();
41: this .index = index;
42: setLambdaName(Symbol.addFunction(this .name, this ));
43: }
44:
45: public final int getFunctionalType() {
46: return FTYPE_SPECIAL_OPERATOR;
47: }
48:
49: public final String getName() {
50: return name;
51: }
52:
53: public LispObject execute(LispObject args, Environment env)
54: throws ConditionThrowable {
55: return module.dispatch(args, env, index);
56: }
57:
58: public String toString() {
59: StringBuffer sb = new StringBuffer("#<SPECIAL-OPERATOR ");
60: sb.append(name);
61: sb.append(">");
62: return sb.toString();
63: }
64:
65: // Profiling.
66: public final int getCallCount() {
67: return callCount;
68: }
69:
70: public final void setCallCount(int n) {
71: callCount = n;
72: }
73:
74: public final void incrementCallCount() {
75: ++callCount;
76: }
77: }
|