Changeset 13310 for trunk/abcl/src/org


Ignore:
Timestamp:
06/07/11 18:07:33 (10 years ago)
Author:
Mark Evenson
Message:

SYS:HASH-TABLE-WEAKNESS provides the weakness property of a hashtable.

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

Legend:

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

    r13309 r13310  
    413413    };
    414414
     415  @DocString(name="hash-table-weakness",
     416             args="hash-table",
     417             doc="Return weakness property of HASH-TABLE, or NIL if it has none.")
     418  private static final Primitive HASH_TABLE_WEAKNESS
     419    = new pf_hash_table_weakness();
     420  private static final class pf_hash_table_weakness extends Primitive {
     421      pf_hash_table_weakness() {
     422          super(Symbol.HASH_TABLE_WEAKNESS, "hash-table");
     423      }
     424      @Override
     425      public LispObject execute(LispObject first)
     426      {
     427          if (first instanceof HashTable) {
     428              return NIL;
     429          } else if (first instanceof WeakHashTable) {
     430              return ((WeakHashTable)first).getWeakness();
     431          }
     432          return error(new TypeError(first, Symbol.HASH_TABLE));
     433      }
     434  };
     435
    415436  protected static HashTable checkHashTable(LispObject ht) {
    416437    if (ht instanceof HashTable) return (HashTable)ht;
  • trunk/abcl/src/org/armedbear/lisp/Symbol.java

    r13273 r13310  
    30463046  public static final Symbol PUTHASH =
    30473047    PACKAGE_SYS.addExternalSymbol("PUTHASH");
     3048  public static final Symbol HASH_TABLE_WEAKNESS =
     3049    PACKAGE_SYS.addExternalSymbol("HASH-TABLE-WEAKNESS");
    30483050  public static final Symbol UNDEFINED_FUNCTION_CALLED =
    30493051    PACKAGE_SYS.addExternalSymbol("UNDEFINED-FUNCTION-CALLED");
  • trunk/abcl/src/org/armedbear/lisp/WeakHashTable.java

    r13309 r13310  
    4646import java.util.concurrent.locks.ReentrantLock;
    4747
    48 
    49 
    50 
    51 
    5248// ??? Replace standard Hashtable when this code is working; maybe not
    5349// because we have additional places for locking here.
     
    7975    final private ReentrantLock lock = new ReentrantLock();
    8076    HashEntry bucketType;
     77    final LispObject weakness;
    8178
    8279    private WeakHashTable(Comparator c, int size, LispObject rehashSize,
     
    8683        this.rehashThreshold = rehashThreshold;
    8784        bucketType = null;
     85        this.weakness = weakness;
    8886        if (weakness.equals(Keyword.KEY)) {
    8987            bucketType = this.new HashEntryWeakKey();
     
    350348    public Symbol getTest() {
    351349        return comparator.getTest();
     350    }
     351   
     352    public LispObject getWeakness() {
     353        return weakness;
    352354    }
    353355
Note: See TracChangeset for help on using the changeset viewer.