Changeset 10197


Ignore:
Timestamp:
10/23/05 14:53:27 (16 years ago)
Author:
piso
Message:

Symbol refactoring (work in progress).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r10196 r10197  
    33 *
    44 * Copyright (C) 2002-2005 Peter Graves
    5  * $Id: Primitives.java,v 1.839 2005-10-23 14:28:26 piso Exp $
     5 * $Id: Primitives.java,v 1.840 2005-10-23 14:53:27 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    23522352
    23532353    // ### type-of
    2354     private static final Primitive TYPE_OF = new Primitive("type-of", "object")
     2354    private static final Primitive TYPE_OF =
     2355        new Primitive(Symbol.TYPE_OF, "object")
    23552356    {
    23562357        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    23612362
    23622363    // ### class-of
    2363     private static final Primitive CLASS_OF = new Primitive("class-of", "object")
     2364    private static final Primitive CLASS_OF =
     2365        new Primitive(Symbol.CLASS_OF, "object")
    23642366    {
    23652367        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    23802382    };
    23812383
    2382     // ### function-lambda-expression
    2383     // function-lambda-expression function => lambda-expression, closure-p, name
     2384    // ### function-lambda-expression function =>
     2385    // lambda-expression, closure-p, name
    23842386    private static final Primitive FUNCTION_LAMBDA_EXPRESSION =
    2385         new Primitive("function-lambda-expression", "function")
     2387        new Primitive(Symbol.FUNCTION_LAMBDA_EXPRESSION, "function")
    23862388    {
    23872389        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    24152417                value3 = ((StandardGenericFunction)arg).getGenericFunctionName();
    24162418            } else
    2417                 return signal(new TypeError(arg, Symbol.FUNCTION));
     2419                return signalTypeError(arg, Symbol.FUNCTION);
    24182420            return LispThread.currentThread().setValues(value1, value2, value3);
    24192421        }
     
    24232425    // This needs to be public for LispAPI.java.
    24242426    public static final Primitive FUNCALL =
    2425         new Primitive("funcall", "function &rest args")
     2427        new Primitive(Symbol.FUNCALL, "function &rest args")
    24262428    {
    24272429        public LispObject execute() throws ConditionThrowable
     
    24852487    // ### apply
    24862488    public static final Primitive APPLY =
    2487         new Primitive("apply", "function &rest args")
     2489        new Primitive(Symbol.APPLY, "function &rest args")
    24882490    {
    24892491        public LispObject execute() throws ConditionThrowable
     
    25382540                return funcall(first, funArgs, LispThread.currentThread());
    25392541            }
    2540             return signal(new TypeError(third, Symbol.LIST));
     2542            return signalTypeError(third, Symbol.LIST);
    25412543        }
    25422544        public LispObject execute(final LispObject[] args) throws ConditionThrowable
     
    25562558                return funcall(args[0], funArgs, LispThread.currentThread());
    25572559            }
    2558             return signal(new TypeError(spread, Symbol.LIST));
     2560            return signalTypeError(spread, Symbol.LIST);
    25592561        }
    25602562    };
     
    25622564    // ### mapcar
    25632565    private static final Primitive MAPCAR =
    2564         new Primitive("mapcar", "function &rest lists")
     2566        new Primitive(Symbol.MAPCAR, "function &rest lists")
    25652567    {
    25662568        public LispObject execute(LispObject fun, LispObject list)
     
    26532655    // ### mapc
    26542656    private static final Primitive MAPC =
    2655         new Primitive("mapc", "function &rest lists")
     2657        new Primitive(Symbol.MAPC, "function &rest lists")
    26562658    {
    26572659        public LispObject execute(LispObject fun, LispObject list)
     
    27222724    // ### macroexpand
    27232725    private static final Primitive MACROEXPAND =
    2724         new Primitive("macroexpand", "form &optional env")
     2726        new Primitive(Symbol.MACROEXPAND, "form &optional env")
    27252727    {
    27262728        public LispObject execute(LispObject form) throws ConditionThrowable
     
    27412743    // ### macroexpand-1
    27422744    private static final Primitive MACROEXPAND_1 =
    2743         new Primitive("macroexpand-1", "form &optional env")
     2745        new Primitive(Symbol.MACROEXPAND_1, "form &optional env")
    27442746    {
    27452747        public LispObject execute(LispObject form) throws ConditionThrowable
     
    27602762    // ### gensym
    27612763    private static final Primitive GENSYM =
    2762         new Primitive("gensym", "&optional x")
     2764        new Primitive(Symbol.GENSYM, "&optional x")
    27632765    {
    27642766        public LispObject execute() throws ConditionThrowable
     
    27922794
    27932795    // ### string
    2794     private static final Primitive STRING = new Primitive("string", "x")
     2796    private static final Primitive STRING = new Primitive(Symbol.STRING, "x")
    27952797    {
    27962798        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    28052807    // symbol's name is the given string or a copy of it."
    28062808    private static final Primitive INTERN =
    2807         new Primitive("intern", "string &optional package")
     2809        new Primitive(Symbol.INTERN, "string &optional package")
    28082810    {
    28092811        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    28342836    // unintern symbol &optional package => generalized-boolean
    28352837    private static final Primitive UNINTERN =
    2836         new Primitive("unintern", "symbol &optional package")
     2838        new Primitive(Symbol.UNINTERN, "symbol &optional package")
    28372839    {
    28382840        public LispObject execute(LispObject[] args) throws ConditionThrowable
     
    28522854    // ### find-package
    28532855    private static final Primitive FIND_PACKAGE =
    2854         new Primitive("find-package", "name")
     2856        new Primitive(Symbol.FIND_PACKAGE, "name")
    28552857    {
    28562858        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    29742976    // ### use-package packages-to-use &optional package => t
    29752977    private static final Primitive USE_PACKAGE =
    2976         new Primitive("use-package", "packages-to-use &optional package")
     2978        new Primitive(Symbol.USE_PACKAGE, "packages-to-use &optional package")
    29772979    {
    29782980        public LispObject execute(LispObject[] args) throws ConditionThrowable
     
    30393041    // ### export symbols &optional package
    30403042    private static final Primitive EXPORT =
    3041         new Primitive("export", "symbols &optional package")
    3042     {
    3043         public LispObject execute(LispObject arg) throws ConditionThrowable
    3044         {
     3043        new Primitive(Symbol.EXPORT, "symbols &optional package")
     3044    {
     3045        public LispObject execute(LispObject arg) throws ConditionThrowable
     3046        {
     3047            final Package pkg = (Package) Symbol._PACKAGE_.symbolValue();
    30453048            if (arg instanceof Cons) {
    3046                 Package pkg = getCurrentPackage();
    30473049                for (LispObject list = arg; list != NIL; list = list.cdr())
    30483050                    pkg.export(checkSymbol(list.car()));
    30493051            } else
    3050                 getCurrentPackage().export(checkSymbol(arg));
     3052                pkg.export(checkSymbol(arg));
    30513053            return T;
    30523054        }
     
    30673069    // ### find-symbol string &optional package => symbol, status
    30683070    private static final Primitive FIND_SYMBOL =
    3069         new Primitive("find-symbol", "string &optional package")
     3071        new Primitive(Symbol.FIND_SYMBOL, "string &optional package")
    30703072    {
    30713073        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    31543156    };
    31553157
    3156     // ### getf
    3157     // getf plist indicator &optional default => value
     3158    // ### getf plist indicator &optional default => value
    31583159    private static final Primitive GETF =
    3159         new Primitive("getf", "plist indicator &optional default")
     3160        new Primitive(Symbol.GETF, "plist indicator &optional default")
    31603161    {
    31613162        public LispObject execute(LispObject plist, LispObject indicator)
     
    31643165            return getf(plist, indicator, NIL);
    31653166        }
    3166 
    31673167        public LispObject execute(LispObject plist, LispObject indicator,
    31683168                                  LispObject defaultValue)
     
    31753175    // ### get symbol indicator &optional default => value
    31763176    private static final Primitive GET =
    3177         new Primitive("get", "symbol indicator &optional default")
     3177        new Primitive(Symbol.GET, "symbol indicator &optional default")
    31783178    {
    31793179        public LispObject execute(LispObject symbol, LispObject indicator)
     
    31823182            return get(symbol, indicator, NIL);
    31833183        }
    3184 
    31853184        public LispObject execute(LispObject symbol, LispObject indicator,
    31863185                                  LispObject defaultValue)
     
    31913190    };
    31923191
    3193     // ### %put
    3194     // %put symbol indicator value => value
     3192    // ### %put symbol indicator value => value
    31953193    private static final Primitive _PUT =
    31963194        new Primitive("%put", PACKAGE_SYS, true)
     
    32043202            }
    32053203            catch (ClassCastException e) {
    3206                 return signal(new TypeError(symbol, Symbol.SYMBOL));
     3204                return signalTypeError(symbol, Symbol.SYMBOL);
    32073205            }
    32083206        }
     
    32153213            }
    32163214            catch (ClassCastException e) {
    3217                 return signal(new TypeError(symbol, Symbol.SYMBOL));
     3215                return signalTypeError(symbol, Symbol.SYMBOL);
    32183216            }
    32193217        }
     
    32223220    // ### macrolet
    32233221    private static final SpecialOperator MACROLET =
    3224         new SpecialOperator("macrolet", "definitions &rest body")
     3222        new SpecialOperator(Symbol.MACROLET, "definitions &rest body")
    32253223    {
    32263224        public LispObject execute(LispObject args, Environment env)
     
    32793277    // ### tagbody
    32803278    private static final SpecialOperator TAGBODY =
    3281         new SpecialOperator("tagbody", "&rest statements")
     3279        new SpecialOperator(Symbol.TAGBODY, "&rest statements")
    32823280    {
    32833281        public LispObject execute(LispObject args, Environment env)
     
    33403338
    33413339    // ### go
    3342     private static final SpecialOperator GO = new SpecialOperator("go", "tag")
     3340    private static final SpecialOperator GO =
     3341        new SpecialOperator(Symbol.GO, "tag")
    33433342    {
    33443343        public LispObject execute(LispObject args, Environment env)
     
    33583357    // ### block
    33593358    private static final SpecialOperator BLOCK =
    3360         new SpecialOperator("block", "name &rest forms")
     3359        new SpecialOperator(Symbol.BLOCK, "name &rest forms")
    33613360    {
    33623361        public LispObject execute(LispObject args, Environment env)
     
    33983397    // ### return-from
    33993398    private static final SpecialOperator RETURN_FROM =
    3400         new SpecialOperator("return-from", "name &optional value")
     3399        new SpecialOperator(Symbol.RETURN_FROM, "name &optional value")
    34013400    {
    34023401        public LispObject execute(LispObject args, Environment env)
     
    34303429
    34313430    // ### catch
    3432     private static final SpecialOperator CATCH = new SpecialOperator("catch", "tag &body body")
     3431    private static final SpecialOperator CATCH =
     3432        new SpecialOperator(Symbol.CATCH, "tag &body body")
    34333433    {
    34343434        public LispObject execute(LispObject args, Environment env)
     
    34673467
    34683468    // ### throw
    3469     private static final SpecialOperator THROW = new SpecialOperator("throw", "tag result")
     3469    private static final SpecialOperator THROW =
     3470        new SpecialOperator(Symbol.THROW, "tag result")
    34703471    {
    34713472        public LispObject execute(LispObject args, Environment env)
     
    34843485    // ### unwind-protect
    34853486    private static final SpecialOperator UNWIND_PROTECT =
    3486         new SpecialOperator("unwind-protect", "protected &body cleanup")
     3487        new SpecialOperator(Symbol.UNWIND_PROTECT, "protected &body cleanup")
    34873488    {
    34883489        public LispObject execute(LispObject args, Environment env)
     
    35133514    // ### eval-when
    35143515    private static final SpecialOperator EVAL_WHEN =
    3515         new SpecialOperator("eval-when", "situations &rest forms")
     3516        new SpecialOperator(Symbol.EVAL_WHEN, "situations &rest forms")
    35163517    {
    35173518        public LispObject execute(LispObject args, Environment env)
     
    35203521            LispObject situations = args.car();
    35213522            if (situations != NIL) {
    3522                 final LispThread thread = LispThread.currentThread();
    35233523                if (memq(Keyword.EXECUTE, situations) ||
    35243524                    memq(Symbol.EVAL, situations))
    35253525                {
    3526                     return progn(args.cdr(), env, thread);
     3526                    return progn(args.cdr(), env, LispThread.currentThread());
    35273527                }
    35283528            }
     
    35353535    // Should be a macro.
    35363536    private static final SpecialOperator MULTIPLE_VALUE_BIND =
    3537         new SpecialOperator("multiple-value-bind", "vars value-form &body body") {
     3537        new SpecialOperator(Symbol.MULTIPLE_VALUE_BIND,
     3538                            "vars value-form &body body")
     3539    {
    35383540        public LispObject execute(LispObject args, Environment env)
    35393541            throws ConditionThrowable
     
    36163618    // ### multiple-value-prog1
    36173619    private static final SpecialOperator MULTIPLE_VALUE_PROG1 =
    3618         new SpecialOperator("multiple-value-prog1", "values-form &rest forms")
     3620        new SpecialOperator(Symbol.MULTIPLE_VALUE_PROG1,
     3621                            "values-form &rest forms")
    36193622    {
    36203623        public LispObject execute(LispObject args, Environment env)
     
    36383641    // ### multiple-value-call
    36393642    private static final SpecialOperator MULTIPLE_VALUE_CALL =
    3640         new SpecialOperator("multiple-value-call", "fun &rest args")
     3643        new SpecialOperator(Symbol.MULTIPLE_VALUE_CALL, "fun &rest args")
    36413644    {
    36423645        public LispObject execute(LispObject args, Environment env)
     
    36813684    // Should be a macro.
    36823685    private static final SpecialOperator AND =
    3683         new SpecialOperator("and", "&rest forms")
     3686        new SpecialOperator(Symbol.AND, "&rest forms")
    36843687    {
    36853688        public LispObject execute(LispObject args, Environment env)
     
    37063709    // Should be a macro.
    37073710    private static final SpecialOperator OR =
    3708         new SpecialOperator("or", "&rest forms")
     3711        new SpecialOperator(Symbol.OR, "&rest forms")
    37093712    {
    37103713        public LispObject execute(LispObject args, Environment env)
Note: See TracChangeset for help on using the changeset viewer.