Jatha Software

org.jatha.dynatype
Class StandardLispPackage

java.lang.Object
  extended by org.jatha.dynatype.StandardLispValue
      extended by org.jatha.dynatype.StandardLispPackage
All Implemented Interfaces:
Comparable, LispPackage, LispValue

public class StandardLispPackage
extends StandardLispValue
implements LispPackage

An implementation of ANSI Common LISP packages, including defpackage, export, import, etc.

See Also:
Jatha

Field Summary
protected  LispValue f_name
          The LISP string giving the name of the package.
protected  LispValue f_nicknames
           
protected  SymbolTable f_shadowingSymbols
          The shadowing symbols of this package.
protected  SymbolTable f_symbolTable
          SYMTAB is the local symbol table for this package.
protected  LispValue f_uses
           
 
Fields inherited from class org.jatha.dynatype.StandardLispValue
f_lisp
 
Constructor Summary
StandardLispPackage()
           
StandardLispPackage(Jatha lisp, LispValue name)
          Creates a new package.
StandardLispPackage(Jatha lisp, LispValue name, LispValue nicknames)
          Creates a package with a list of nicknames.
StandardLispPackage(Jatha lisp, LispValue name, LispValue nicknames, LispValue usesList)
           
StandardLispPackage(Jatha lisp, LispValue pname, LispValue pnicknames, LispValue puses, SymbolTable symtab)
          Creates a package with a list of nicknames and a list of exported symbols.
StandardLispPackage(Jatha lisp, LispValue pname, LispValue pnicknames, LispValue puses, SymbolTable symtab, SymbolTable shadows)
          Creates a package with a list of nicknames and a list of exported symbols.
StandardLispPackage(Jatha lisp, String name)
          Creates a new package.
 
Method Summary
 LispValue addSymbol(LispString name, LispValue symbol)
          Stores a new symbol in this package.
 LispValue export(LispValue symbols)
          Declares the symbol or symbols as exported symbols.
private  LispString getAsString(LispValue inp)
           
 LispValue getExternalSymbol(LispString str)
          Returns the external symbol with the given name
 LispString getName()
          Returns the name of this package as a LispString.
 LispValue getNicknames()
          Returns a list of the nicknames of this package.
 LispValue getSymbol(LispString str)
          Returns the symbol with the given name.
 SymbolTable getSymbolTable()
          Returns the symbol table for this package.
 LispValue getUses()
          Returns a list of package names that this package uses.
 void internal_prin1(PrintStream os)
           
 void internal_princ(PrintStream os)
           
 void internal_print(PrintStream os)
           
 LispValue lisp_import(LispValue symbols)
          Imports the given symbols into the current package.
(package private)  LispValue makeSymbolsFromList(LispValue symbolList)
           
 void setNicknames(LispValue nicknames)
          Sets the nicknames-list
 void setUses(LispValue uses)
          Sets the uses for this package.
 LispValue shadow(LispValue symbols)
           
 LispValue shadowing_import(LispValue symbols)
          Imports the given symbols into the current package shadowing list.
 String toString()
          toString() returns a printed representation of the form (as printed by (prin1)) in a Java string.
private  LispValue transformToStrings(LispValue list)
           
 LispValue type_of()
           
 LispValue typep(LispValue type)
           
 boolean uses(LispValue pkg)
          Returns true if this package uses the given package
 
Methods inherited from class org.jatha.dynatype.StandardLispValue
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_consp, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_listp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, butlast, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, documentation, eighth, elt, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_princ_as_cdr, internal_print_as_cdr, iterator, keywordp, last, length, lessThan, lessThanOrEqual, lisp_null, list, listp, max, member, min, multiply, nconc, negate, neql, ninth, nreverse, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, pop, position, prin1, princ, print, push, radiansToDegrees, rassoc, readFromString, reciprocal, remhash, remove, rest, reverse, rplaca, rplacd, sec, second, set_special, setf_documentation, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, showStackTrace, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, zerop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jatha.dynatype.LispValue
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_consp, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_listp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, butlast, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, documentation, eighth, elt, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_princ_as_cdr, internal_print_as_cdr, iterator, keywordp, last, length, lessThan, lessThanOrEqual, lisp_null, list, listp, max, member, min, multiply, nconc, negate, neql, ninth, nreverse, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, pop, position, prin1, princ, print, push, radiansToDegrees, rassoc, readFromString, reciprocal, remhash, remove, rest, reverse, rplaca, rplacd, sec, second, set_special, setf_documentation, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, zerop
 

Field Detail

f_symbolTable

protected SymbolTable f_symbolTable
SYMTAB is the local symbol table for this package.


f_shadowingSymbols

protected SymbolTable f_shadowingSymbols
The shadowing symbols of this package. Read CLTL, chapter 11.5 for more information.


f_name

protected LispValue f_name
The LISP string giving the name of the package.


f_nicknames

protected LispValue f_nicknames

f_uses

protected LispValue f_uses
Constructor Detail

StandardLispPackage

public StandardLispPackage()

StandardLispPackage

public StandardLispPackage(Jatha lisp,
                           String name)
Creates a new package. Caller should verify that none exists by the same name before calling this function.

Parameters:
name - - a string giving the name of the new package

StandardLispPackage

public StandardLispPackage(Jatha lisp,
                           LispValue name)
Creates a new package. Caller should verify that none exists by the same name before calling this function.Þ

Parameters:
name - - a LISP string giving the name of the package

StandardLispPackage

public StandardLispPackage(Jatha lisp,
                           LispValue name,
                           LispValue nicknames)
Creates a package with a list of nicknames.

Parameters:
name - - a LISP string giving the name.
nicknames - - a LISP list of nicknames (all strings)

StandardLispPackage

public StandardLispPackage(Jatha lisp,
                           LispValue name,
                           LispValue nicknames,
                           LispValue usesList)

StandardLispPackage

public StandardLispPackage(Jatha lisp,
                           LispValue pname,
                           LispValue pnicknames,
                           LispValue puses,
                           SymbolTable symtab)
Creates a package with a list of nicknames and a list of exported symbols.

Parameters:
pname - a LISP string giving the name.
pnicknames - a LISP list of nicknames (all strings)
puses - a LISP list of exported symbols (all strings)
symtab - a symbol table to use for this package.

StandardLispPackage

public StandardLispPackage(Jatha lisp,
                           LispValue pname,
                           LispValue pnicknames,
                           LispValue puses,
                           SymbolTable symtab,
                           SymbolTable shadows)
Creates a package with a list of nicknames and a list of exported symbols.

Parameters:
pname - a LISP string giving the name.
pnicknames - a LISP list of nicknames (all strings)
puses - a LISP list of exported symbols (all strings)
symtab - a symbol table to use for this package.
shadows - a shadowing symbol table to use for this package.
Method Detail

getSymbolTable

public SymbolTable getSymbolTable()
Description copied from interface: LispPackage
Returns the symbol table for this package.

Specified by:
getSymbolTable in interface LispPackage

internal_princ

public void internal_princ(PrintStream os)
Specified by:
internal_princ in interface LispValue
Overrides:
internal_princ in class StandardLispValue

internal_prin1

public void internal_prin1(PrintStream os)
Specified by:
internal_prin1 in interface LispValue
Overrides:
internal_prin1 in class StandardLispValue

internal_print

public void internal_print(PrintStream os)
Specified by:
internal_print in interface LispValue
Overrides:
internal_print in class StandardLispValue

toString

public String toString()
Description copied from class: StandardLispValue
toString() returns a printed representation of the form (as printed by (prin1)) in a Java string.

Specified by:
toString in interface LispValue
Overrides:
toString in class StandardLispValue
Returns:
String The value in a string.

transformToStrings

private LispValue transformToStrings(LispValue list)

getAsString

private LispString getAsString(LispValue inp)

getExternalSymbol

public LispValue getExternalSymbol(LispString str)
Description copied from interface: LispPackage
Returns the external symbol with the given name

Specified by:
getExternalSymbol in interface LispPackage
Parameters:
str - a LispString corresponding to the symbol.

addSymbol

public LispValue addSymbol(LispString name,
                           LispValue symbol)
Stores a new symbol in this package. The lookup key is a LispString giving the print name. The value is a LispSymbol - or LispNil.

Specified by:
addSymbol in interface LispPackage

getSymbol

public LispValue getSymbol(LispString str)
Description copied from interface: LispPackage
Returns the symbol with the given name.

Specified by:
getSymbol in interface LispPackage

makeSymbolsFromList

LispValue makeSymbolsFromList(LispValue symbolList)

export

public LispValue export(LispValue symbols)
Declares the symbol or symbols as exported symbols. The symbol can be a symbol or list of symbols.

Specified by:
export in interface LispPackage

lisp_import

public LispValue lisp_import(LispValue symbols)
Imports the given symbols into the current package. The symbol can be a symbol or list of symbols. Note: this method name is altered because of a conflict with a Java reserved word.


shadowing_import

public LispValue shadowing_import(LispValue symbols)
Imports the given symbols into the current package shadowing list.


shadow

public LispValue shadow(LispValue symbols)

type_of

public LispValue type_of()
Specified by:
type_of in interface LispValue
Overrides:
type_of in class StandardLispValue

typep

public LispValue typep(LispValue type)
Specified by:
typep in interface LispValue
Overrides:
typep in class StandardLispValue

getName

public LispString getName()
Description copied from interface: LispPackage
Returns the name of this package as a LispString.

Specified by:
getName in interface LispPackage

getNicknames

public LispValue getNicknames()
Returns a list of the nicknames of this package. Each element of the list is a LispString.

Specified by:
getNicknames in interface LispPackage

setNicknames

public void setNicknames(LispValue nicknames)
Sets the nicknames-list

Specified by:
setNicknames in interface LispPackage

getUses

public LispValue getUses()
Description copied from interface: LispPackage
Returns a list of package names that this package uses. Contains either symbols or strings.

Specified by:
getUses in interface LispPackage

setUses

public void setUses(LispValue uses)
Description copied from interface: LispPackage
Sets the uses for this package.

Specified by:
setUses in interface LispPackage
Parameters:
uses - the uses of this package

uses

public boolean uses(LispValue pkg)
Returns true if this package uses the given package

Specified by:
uses in interface LispValue
Overrides:
uses in class StandardLispValue

Jatha Software