Changeset 13777


Ignore:
Timestamp:
01/15/12 13:06:26 (9 years ago)
Author:
ehuelsmann
Message:

Record optional parameters in generic function objects for quick retrieval.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

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

    r13775 r13777  
    6767    slots[StandardGenericFunctionClass.SLOT_INDEX_REQUIRED_ARGS] =
    6868      lambdaList;
     69    slots[StandardGenericFunctionClass.SLOT_INDEX_OPTIONAL_ARGS] =
     70      NIL;
    6971    numberOfRequiredArgs = lambdaList.length();
    7072    slots[StandardGenericFunctionClass.SLOT_INDEX_INITIAL_METHODS] =
     
    248250  };
    249251
     252  private static final Primitive GF_OPTIONAL_ARGS
     253    = new pf_gf_optional_args();
     254  @DocString(name="gf-optional-args")
     255  private static final class pf_gf_optional_args extends Primitive
     256  {
     257    pf_gf_optional_args()
     258    {
     259      super("gf-optional-args", PACKAGE_SYS, true);
     260    }
     261    @Override
     262    public LispObject execute(LispObject arg)
     263    {
     264      return checkStandardGenericFunction(arg).slots[StandardGenericFunctionClass.SLOT_INDEX_OPTIONAL_ARGS];
     265    }
     266  };
     267
     268  private static final Primitive _SET_GF_OPTIONAL_ARGS
     269    = new pf__set_gf_optional_args();
     270  @DocString(name="%set-gf-optional-args")
     271  private static final class pf__set_gf_optional_args extends Primitive
     272  {
     273    pf__set_gf_optional_args()
     274    {
     275      super("%set-gf-optional-args", PACKAGE_SYS, true);
     276    }
     277    @Override
     278    public LispObject execute(LispObject first, LispObject second)
     279    {
     280      final StandardGenericFunction gf = checkStandardGenericFunction(first);
     281      gf.slots[StandardGenericFunctionClass.SLOT_INDEX_OPTIONAL_ARGS] = second;
     282      return second;
     283    }
     284  };
     285
    250286  private static final Primitive GENERIC_FUNCTION_INITIAL_METHODS
    251287    = new pf_generic_function_initial_methods();
  • trunk/abcl/src/org/armedbear/lisp/StandardGenericFunctionClass.java

    r12288 r13777  
    4141  public static final int SLOT_INDEX_LAMBDA_LIST               = 1;
    4242  public static final int SLOT_INDEX_REQUIRED_ARGS             = 2;
    43   public static final int SLOT_INDEX_INITIAL_METHODS           = 3;
    44   public static final int SLOT_INDEX_METHODS                   = 4;
    45   public static final int SLOT_INDEX_METHOD_CLASS              = 5;
    46   public static final int SLOT_INDEX_METHOD_COMBINATION        = 6;
    47   public static final int SLOT_INDEX_ARGUMENT_PRECEDENCE_ORDER = 7;
    48   public static final int SLOT_INDEX_CLASSES_TO_EMF_TABLE      = 8;
    49   public static final int SLOT_INDEX_DOCUMENTATION             = 9;
     43  public static final int SLOT_INDEX_OPTIONAL_ARGS             = 3;
     44  public static final int SLOT_INDEX_INITIAL_METHODS           = 4;
     45  public static final int SLOT_INDEX_METHODS                   = 5;
     46  public static final int SLOT_INDEX_METHOD_CLASS              = 6;
     47  public static final int SLOT_INDEX_METHOD_COMBINATION        = 7;
     48  public static final int SLOT_INDEX_ARGUMENT_PRECEDENCE_ORDER = 8;
     49  public static final int SLOT_INDEX_CLASSES_TO_EMF_TABLE      = 9;
     50  public static final int SLOT_INDEX_DOCUMENTATION             = 10;
    5051
    5152  public StandardGenericFunctionClass()
     
    5960        pkg.intern("LAMBDA-LIST"),
    6061        pkg.intern("REQUIRED-ARGS"),
     62        pkg.intern("OPTIONAL-ARGS"),
    6163        pkg.intern("INITIAL-METHODS"),
    6264        pkg.intern("METHODS"),
Note: See TracChangeset for help on using the changeset viewer.