Changeset 12458


Ignore:
Timestamp:
02/13/10 16:51:02 (11 years ago)
Author:
vvoutilainen
Message:

More stack-friendly SpecialOperators?.

File:
1 edited

Legend:

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

    r12454 r12458  
    812812
    813813    // ### when
    814     private static final SpecialOperator WHEN =
    815     new SpecialOperator(Symbol.WHEN) {
     814    private static final SpecialOperator WHEN = new sf_when();
     815    private static final class sf_when extends SpecialOperator {
     816        sf_when() {
     817            super(Symbol.WHEN);
     818        }
     819
    816820        @Override
    817821        public LispObject execute(LispObject args, Environment env)
     
    831835
    832836    // ### unless
    833     private static final SpecialOperator UNLESS =
    834     new SpecialOperator(Symbol.UNLESS) {
     837    private static final SpecialOperator UNLESS = new sf_unless();
     838    private static final class sf_unless extends SpecialOperator {
     839        sf_unless() {
     840            super(Symbol.UNLESS);
     841        }
     842
    835843        @Override
    836844        public LispObject execute(LispObject args, Environment env)
     
    18531861
    18541862    // ### defmacro
    1855     private static final SpecialOperator DEFMACRO =
    1856     new SpecialOperator(Symbol.DEFMACRO) {
     1863    private static final SpecialOperator DEFMACRO = new sf_defmacro();
     1864    private static final class sf_defmacro extends SpecialOperator {
     1865        sf_defmacro() {
     1866            super(Symbol.DEFMACRO);
     1867        }
     1868
    18571869        @Override
    18581870        public LispObject execute(LispObject args, Environment env)
     
    20142026
    20152027    // ### cond
    2016     private static final SpecialOperator COND =
    2017     new SpecialOperator(Symbol.COND, "&rest clauses") {
     2028    private static final SpecialOperator COND = new sf_cond();
     2029    private static final class sf_cond extends SpecialOperator {
     2030        sf_cond() {
     2031            super(Symbol.COND, "&rest clauses");
     2032        }
     2033
    20182034        @Override
    20192035        public LispObject execute(LispObject args, Environment env)
     
    20412057
    20422058    // ### case
    2043     private static final SpecialOperator CASE =
    2044     new SpecialOperator(Symbol.CASE, "keyform &body cases") {
     2059    private static final SpecialOperator CASE = new sf_case();
     2060    private static final class sf_case extends SpecialOperator {
     2061        sf_case() {
     2062            super(Symbol.CASE, "keyform &body cases");
     2063        }
     2064
    20452065        @Override
    20462066        public LispObject execute(LispObject args, Environment env)
     
    20802100
    20812101    // ### ecase
    2082     private static final SpecialOperator ECASE =
    2083     new SpecialOperator(Symbol.ECASE, "keyform &body cases") {
     2102    private static final SpecialOperator ECASE = new sf_ecase();
     2103    private static final class sf_ecase extends SpecialOperator {
     2104        sf_ecase() {
     2105            super(Symbol.ECASE, "keyform &body cases");
     2106        }
     2107
    20842108        @Override
    20852109        public LispObject execute(LispObject args, Environment env)
     
    35623586
    35633587    // ### macrolet
    3564     private static final SpecialOperator MACROLET =
    3565     new SpecialOperator(Symbol.MACROLET, "definitions &rest body") {
     3588    private static final SpecialOperator MACROLET = new sf_macrolet();
     3589    private static final class sf_macrolet extends SpecialOperator {
     3590        sf_macrolet() {
     3591            super(Symbol.MACROLET, "definitions &rest body");
     3592        }
     3593
    35663594        @Override
    35673595        public LispObject execute(LispObject args, Environment env)
     
    36253653
    36263654    // ### tagbody
    3627     private static final SpecialOperator TAGBODY =
    3628     new SpecialOperator(Symbol.TAGBODY, "&rest statements") {
     3655    private static final SpecialOperator TAGBODY = new sf_tagbody();
     3656    private static final class sf_tagbody extends SpecialOperator {
     3657        sf_tagbody() {
     3658            super(Symbol.TAGBODY, "&rest statements");
     3659        }
     3660
    36293661        @Override
    36303662        public LispObject execute(LispObject args, Environment env)
     
    36423674
    36433675    // ### go
    3644     private static final SpecialOperator GO =
    3645     new SpecialOperator(Symbol.GO, "tag") {
     3676    private static final SpecialOperator GO = new sf_go();
     3677    private static final class sf_go extends SpecialOperator {
     3678        sf_go() {
     3679            super(Symbol.GO, "tag");
     3680        }
     3681
    36463682        @Override
    36473683        public LispObject execute(LispObject args, Environment env)
     
    36613697
    36623698    // ### block
    3663     private static final SpecialOperator BLOCK =
    3664     new SpecialOperator(Symbol.BLOCK, "name &rest forms") {
     3699    private static final SpecialOperator BLOCK = new sf_block();
     3700    private static final class sf_block extends SpecialOperator {
     3701        sf_block() {
     3702            super(Symbol.BLOCK, "name &rest forms");
     3703        }
     3704
    36653705        @Override
    36663706        public LispObject execute(LispObject args, Environment env)
     
    36923732
    36933733    // ### return-from
    3694     private static final SpecialOperator RETURN_FROM =
    3695     new SpecialOperator(Symbol.RETURN_FROM, "name &optional value") {
     3734    private static final SpecialOperator RETURN_FROM = new sf_return_from();
     3735    private static final class sf_return_from extends SpecialOperator {
     3736        sf_return_from() {
     3737            super(Symbol.RETURN_FROM, "name &optional value");
     3738        }
     3739
    36963740        @Override
    36973741        public LispObject execute(LispObject args, Environment env)
     
    37123756
    37133757    // ### catch
    3714     private static final SpecialOperator CATCH =
    3715     new SpecialOperator(Symbol.CATCH, "tag &body body") {
     3758    private static final SpecialOperator CATCH = new sf_catch();
     3759    private static final class sf_catch extends SpecialOperator {
     3760        sf_catch() {
     3761            super(Symbol.CATCH, "tag &body body");
     3762        }
     3763
    37163764        @Override
    37173765        public LispObject execute(LispObject args, Environment env)
     
    37423790
    37433791    // ### throw
    3744     private static final SpecialOperator THROW =
    3745     new SpecialOperator(Symbol.THROW, "tag result") {
     3792    private static final SpecialOperator THROW = new sf_throw();
     3793    private static final class sf_throw extends SpecialOperator {
     3794        sf_throw() {
     3795            super(Symbol.THROW, "tag result");
     3796        }
     3797
    37463798        @Override
    37473799        public LispObject execute(LispObject args, Environment env)
     
    37593811
    37603812    // ### unwind-protect
    3761     private static final SpecialOperator UNWIND_PROTECT =
    3762     new SpecialOperator(Symbol.UNWIND_PROTECT, "protected &body cleanup") {
     3813    private static final SpecialOperator UNWIND_PROTECT = new sf_unwind_protect();
     3814    private static final class sf_unwind_protect extends SpecialOperator {
     3815        sf_unwind_protect() {
     3816            super(Symbol.UNWIND_PROTECT, "protected &body cleanup");
     3817        }
     3818
    37633819        @Override
    37643820        public LispObject execute(LispObject args, Environment env)
     
    37893845
    37903846    // ### eval-when
    3791     private static final SpecialOperator EVAL_WHEN =
    3792     new SpecialOperator(Symbol.EVAL_WHEN, "situations &rest forms") {
     3847    private static final SpecialOperator EVAL_WHEN = new sf_eval_when();
     3848    private static final class sf_eval_when extends SpecialOperator {
     3849        sf_eval_when() {
     3850            super(Symbol.EVAL_WHEN, "situations &rest forms");
     3851        }
     3852
    37933853        @Override
    37943854        public LispObject execute(LispObject args, Environment env)
     
    37983858            if (situations != NIL) {
    37993859                if (memq(Keyword.EXECUTE, situations) ||
    3800                 memq(Symbol.EVAL, situations)) {
     3860                        memq(Symbol.EVAL, situations)) {
    38013861                    return progn(args.cdr(), env, LispThread.currentThread());
    38023862                }
     
    38093869    // multiple-value-bind (var*) values-form declaration* form*
    38103870    // Should be a macro.
    3811     private static final SpecialOperator MULTIPLE_VALUE_BIND =
    3812         new SpecialOperator(Symbol.MULTIPLE_VALUE_BIND,
    3813     "vars value-form &body body") {
     3871    private static final SpecialOperator MULTIPLE_VALUE_BIND = new sf_multiple_value_bind();
     3872    private static final class sf_multiple_value_bind extends SpecialOperator {
     3873        sf_multiple_value_bind() {
     3874            super(Symbol.MULTIPLE_VALUE_BIND,
     3875                  "vars value-form &body body");
     3876        }
     3877
    38143878        @Override
    38153879        public LispObject execute(LispObject args, Environment env)
     
    38763940
    38773941    // ### multiple-value-prog1
    3878     private static final SpecialOperator MULTIPLE_VALUE_PROG1 =
    3879         new SpecialOperator(Symbol.MULTIPLE_VALUE_PROG1,
    3880     "values-form &rest forms") {
     3942    private static final SpecialOperator MULTIPLE_VALUE_PROG1 = new sf_multiple_value_prog1();
     3943    private static final class sf_multiple_value_prog1 extends SpecialOperator {
     3944        sf_multiple_value_prog1() {
     3945            super(Symbol.MULTIPLE_VALUE_PROG1,
     3946                  "values-form &rest forms");
     3947        }
     3948
    38813949        @Override
    38823950        public LispObject execute(LispObject args, Environment env)
     
    38993967
    39003968    // ### multiple-value-call
    3901     private static final SpecialOperator MULTIPLE_VALUE_CALL =
    3902     new SpecialOperator(Symbol.MULTIPLE_VALUE_CALL, "fun &rest args") {
     3969    private static final SpecialOperator MULTIPLE_VALUE_CALL = new sf_multiple_value_call();
     3970    private static final class sf_multiple_value_call extends SpecialOperator {
     3971        sf_multiple_value_call() {
     3972            super(Symbol.MULTIPLE_VALUE_CALL, "fun &rest args");
     3973        }
     3974
    39033975        @Override
    39043976        public LispObject execute(LispObject args, Environment env)
     
    39424014    // ### and
    39434015    // Should be a macro.
    3944     private static final SpecialOperator AND =
    3945     new SpecialOperator(Symbol.AND, "&rest forms") {
     4016    private static final SpecialOperator AND = new sf_and();
     4017    private static final class sf_and extends SpecialOperator {
     4018        sf_and() {
     4019            super(Symbol.AND, "&rest forms");
     4020        }
     4021
    39464022        @Override
    39474023        public LispObject execute(LispObject args, Environment env)
     
    39674043    // ### or
    39684044    // Should be a macro.
    3969     private static final SpecialOperator OR =
    3970     new SpecialOperator(Symbol.OR, "&rest forms") {
     4045    private static final SpecialOperator OR = new sf_or();
     4046    private static final class sf_or extends SpecialOperator {
     4047        sf_or() {
     4048            super(Symbol.OR, "&rest forms");
     4049        }
     4050
    39714051        @Override
    39724052        public LispObject execute(LispObject args, Environment env)
     
    39934073    // Evaluates form and creates a list of the multiple values it returns.
    39944074    // Should be a macro.
    3995     private static final SpecialOperator MULTIPLE_VALUE_LIST =
    3996     new SpecialOperator(Symbol.MULTIPLE_VALUE_LIST, "value-form") {
     4075    private static final SpecialOperator MULTIPLE_VALUE_LIST = new sf_multiple_value_list();
     4076    private static final class sf_multiple_value_list extends SpecialOperator {
     4077        sf_multiple_value_list() {
     4078            super(Symbol.MULTIPLE_VALUE_LIST, "value-form");
     4079        }
     4080
    39974081        @Override
    39984082        public LispObject execute(LispObject args, Environment env)
     
    40184102    // NIL if n >= number of values returned.
    40194103    // Should be a macro.
    4020     private static final SpecialOperator NTH_VALUE =
    4021     new SpecialOperator(Symbol.NTH_VALUE, "n form") {
     4104    private static final SpecialOperator NTH_VALUE = new sf_nth_value();
     4105    private static final class sf_nth_value extends SpecialOperator {
     4106        sf_nth_value() {
     4107            super(Symbol.NTH_VALUE, "n form");
     4108        }
     4109
    40224110        @Override
    40234111        public LispObject execute(LispObject args, Environment env)
Note: See TracChangeset for help on using the changeset viewer.