Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.memoire.silk
Class SilkPrimitive  view SilkPrimitive download SilkPrimitive.java

java.lang.Object
  extended bycom.memoire.silk.SilkSchemeUtils
      extended bycom.memoire.silk.SilkProcedure
          extended bycom.memoire.silk.SilkPrimitive

public class SilkPrimitive
extends SilkProcedure

A primitive is a procedure that is defined as part of the SilkScheme report, and is implemented in Java code.


Field Summary
private static int ABS
           
private static int ACOS
           
private static int APPEND
           
private static int APPLY
           
private static int ASIN
           
private static int ASSOC
           
private static int ASSQ
           
private static int ASSV
           
private static int ATAN
           
private static int BOOLEANQ
           
private static int CALLCC
           
private static int CALLWITHINPUTFILE
           
private static int CALLWITHOUTPUTFILE
           
private static int CAR
           
private static int CDR
           
private static int CEILING
           
private static int CHARALPHABETICQ
           
private static int CHARCICMP
           
private static int CHARCMP
           
private static int CHARDOWNCASE
           
private static int CHARLOWERCASEQ
           
private static int CHARNUMERICQ
           
private static int CHARQ
           
private static int CHARTOINTEGER
           
private static int CHARUPCASE
           
private static int CHARUPPERCASEQ
           
private static int CHARWHITESPACEQ
           
(package private) static int CLASS
           
private static int CLOSEINPUTPORT
           
private static int CLOSEOUTPUTPORT
           
private static int CONS
           
private static int COS
           
private static int CURRENTINPUTPORT
           
private static int CURRENTOUTPUTPORT
           
private static int CXR
           
private static int DISPLAY
           
private static int DIVIDE
           
private static int EOF_OBJECT
           
private static int EOFOBJECTQ
           
private static int EQ
           
private static int EQQ
           
private static int EQUALQ
           
private static int EQVQ
           
(package private) static int ERROR
           
private static int EVAL
           
private static int EVENQ
           
private static int EXACTQ
           
(package private) static int EXIT
           
private static int EXP
           
private static int EXPT
           
private static int FLOOR
           
private static int FORCE
           
private static int FOREACH
           
private static int GCD
           
private static int GE
           
private static int GT
           
(package private)  int idNumber
           
private static int INEXACTQ
           
private static int INPUTPORTQ
           
private static int INTEGERQ
           
private static int INTEGERTOCHAR
           
private static int LCM
           
private static int LE
           
private static int LENGTH
           
private static int LIST
           
private static int LISTQ
           
private static int LISTREF
           
(package private) static int LISTSTAR
           
private static int LISTTAIL
           
private static int LISTTOSTRING
           
private static int LISTTOVECTOR
           
private static int LOAD
           
private static int LOG
           
private static int LT
           
(package private) static int MACROEXPAND
           
private static int MAKESTRING
           
private static int MAKEVECTOR
           
private static int MAP
           
private static int MAX
           
(package private)  int maxArgs
           
private static int MEMBER
           
private static int MEMQ
           
private static int MEMV
           
(package private) static int METHOD
           
private static int MIN
           
(package private)  int minArgs
           
private static int MINUS
           
private static int MODULO
           
private static int NEGATIVEQ
           
(package private) static int NEW
           
private static int NEWLINE
           
private static int NOT
           
private static int NULLQ
           
private static int NUMBERQ
           
private static int NUMBERTOSTRING
           
private static int ODDQ
           
private static int OPENINPUTFILE
           
private static int OPENOUTPUTFILE
           
private static int OUTPUTPORTQ
           
private static int PAIRQ
           
private static int PEEKCHAR
           
private static int PLUS
           
private static int POSITIVEQ
           
private static int PROCEDUREQ
           
private static int QUOTIENT
           
private static int READ
           
private static int READCHAR
           
private static int REMAINDER
           
private static int REVERSE
           
private static int ROUND
           
private static int SECOND
           
(package private) static int SETCAR
           
(package private) static int SETCDR
           
private static int SIN
           
private static int SQRT
           
private static int STRING
           
private static int STRINGAPPEND
           
private static int STRINGCICMP
           
private static int STRINGCMP
           
private static int STRINGLENGTH
           
private static int STRINGQ
           
private static int STRINGREF
           
private static int STRINGSET
           
private static int STRINGTOLIST
           
private static int STRINGTONUMBER
           
private static int STRINGTOSYMBOL
           
private static int STRINQ
           
private static int SUBSTRING
           
private static int SYMBOLQ
           
private static int SYMBOLTOSTRING
           
private static int TAN
           
private static int THIRD
           
(package private) static int TIMECALL
           
private static int TIMES
           
private static int TRUNCATE
           
private static int VECTOR
           
private static int VECTORLENGTH
           
private static int VECTORQ
           
private static int VECTORREF
           
private static int VECTORSET
           
private static int VECTORTOLIST
           
private static int WRITE
           
private static int ZEROQ
           
 
Fields inherited from class com.memoire.silk.SilkProcedure
name
 
Fields inherited from class com.memoire.silk.SilkSchemeUtils
FALSE, ONE, TRUE, ZERO
 
Constructor Summary
SilkPrimitive(int id, int minArgs, int maxArgs)
           
 
Method Summary
(package private) static java.lang.Object append(java.lang.Object args)
           
(package private) static java.lang.Object append2(java.lang.Object x, java.lang.Object y)
           
 java.lang.Object apply(SilkScheme interp, java.lang.Object args)
          Apply a primitive to a list of arguments.
static int charCompare(java.lang.Object x, java.lang.Object y, boolean ci)
          Return <0 if x is alphabetically first, >0 if y is first, 0 if same.
(package private) static java.lang.Object gcd(java.lang.Object args)
           
(package private) static long gcd2(long a, long b)
           
static SilkEnvironment installSilkPrimitives(SilkEnvironment env)
           
(package private) static boolean isExact(java.lang.Object x)
           
(package private) static boolean isList(java.lang.Object x)
           
(package private) static java.lang.Object lcm(java.lang.Object args)
           
(package private) static SilkPair map(SilkProcedure proc, java.lang.Object args, SilkScheme interp, SilkPair result)
          Map proc over a list of lists of args, in the given interpreter.
static java.lang.Object memberAssoc(java.lang.Object obj, java.lang.Object list, char m, char eq)
           
(package private) static java.lang.Object numberToString(java.lang.Object x, java.lang.Object y)
           
static java.lang.Object numCompare(java.lang.Object args, char op)
           
static java.lang.Object numCompute(java.lang.Object args, char op, double result)
           
(package private) static SilkInputPort openInputFile(java.lang.Object filename)
           
(package private) static java.io.PrintWriter openOutputFile(java.lang.Object filename)
           
(package private) static int sign(int x)
          Return the sign of the argument: +1, -1, or 0.
static char[] stringAppend(java.lang.Object args)
           
static int stringCompare(java.lang.Object x, java.lang.Object y, boolean ci)
          Return <0 if x is alphabetically first, >0 if y is first, 0 if same.
(package private) static java.lang.Object stringToNumber(java.lang.Object x, java.lang.Object y)
           
 
Methods inherited from class com.memoire.silk.SilkProcedure
proc, toString
 
Methods inherited from class com.memoire.silk.SilkSchemeUtils
chr, chr, cons, equal, eqv, error, first, inPort, length, list, list, listStar, listToString, listToVector, num, num, outPort, p, p, rest, reverse, second, setFirst, setRest, str, stringify, stringify, stringify, sym, third, truth, truth, vec, vectorToList, warn, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minArgs

int minArgs

maxArgs

int maxArgs

idNumber

int idNumber

EQ

private static final int EQ
See Also:
Constant Field Values

LT

private static final int LT
See Also:
Constant Field Values

GT

private static final int GT
See Also:
Constant Field Values

GE

private static final int GE
See Also:
Constant Field Values

LE

private static final int LE
See Also:
Constant Field Values

ABS

private static final int ABS
See Also:
Constant Field Values

EOF_OBJECT

private static final int EOF_OBJECT
See Also:
Constant Field Values

EQQ

private static final int EQQ
See Also:
Constant Field Values

EQUALQ

private static final int EQUALQ
See Also:
Constant Field Values

FORCE

private static final int FORCE
See Also:
Constant Field Values

CAR

private static final int CAR
See Also:
Constant Field Values

FLOOR

private static final int FLOOR
See Also:
Constant Field Values

CEILING

private static final int CEILING
See Also:
Constant Field Values

CONS

private static final int CONS
See Also:
Constant Field Values

DIVIDE

private static final int DIVIDE
See Also:
Constant Field Values

LENGTH

private static final int LENGTH
See Also:
Constant Field Values

LIST

private static final int LIST
See Also:
Constant Field Values

LISTQ

private static final int LISTQ
See Also:
Constant Field Values

APPLY

private static final int APPLY
See Also:
Constant Field Values

MAX

private static final int MAX
See Also:
Constant Field Values

MIN

private static final int MIN
See Also:
Constant Field Values

MINUS

private static final int MINUS
See Also:
Constant Field Values

NEWLINE

private static final int NEWLINE
See Also:
Constant Field Values

NOT

private static final int NOT
See Also:
Constant Field Values

NULLQ

private static final int NULLQ
See Also:
Constant Field Values

NUMBERQ

private static final int NUMBERQ
See Also:
Constant Field Values

PAIRQ

private static final int PAIRQ
See Also:
Constant Field Values

PLUS

private static final int PLUS
See Also:
Constant Field Values

PROCEDUREQ

private static final int PROCEDUREQ
See Also:
Constant Field Values

READ

private static final int READ
See Also:
Constant Field Values

CDR

private static final int CDR
See Also:
Constant Field Values

ROUND

private static final int ROUND
See Also:
Constant Field Values

SECOND

private static final int SECOND
See Also:
Constant Field Values

SYMBOLQ

private static final int SYMBOLQ
See Also:
Constant Field Values

TIMES

private static final int TIMES
See Also:
Constant Field Values

TRUNCATE

private static final int TRUNCATE
See Also:
Constant Field Values

WRITE

private static final int WRITE
See Also:
Constant Field Values

APPEND

private static final int APPEND
See Also:
Constant Field Values

BOOLEANQ

private static final int BOOLEANQ
See Also:
Constant Field Values

SQRT

private static final int SQRT
See Also:
Constant Field Values

EXPT

private static final int EXPT
See Also:
Constant Field Values

REVERSE

private static final int REVERSE
See Also:
Constant Field Values

ASSOC

private static final int ASSOC
See Also:
Constant Field Values

ASSQ

private static final int ASSQ
See Also:
Constant Field Values

ASSV

private static final int ASSV
See Also:
Constant Field Values

MEMBER

private static final int MEMBER
See Also:
Constant Field Values

MEMQ

private static final int MEMQ
See Also:
Constant Field Values

MEMV

private static final int MEMV
See Also:
Constant Field Values

EQVQ

private static final int EQVQ
See Also:
Constant Field Values

LISTREF

private static final int LISTREF
See Also:
Constant Field Values

LISTTAIL

private static final int LISTTAIL
See Also:
Constant Field Values

STRINQ

private static final int STRINQ
See Also:
Constant Field Values

MAKESTRING

private static final int MAKESTRING
See Also:
Constant Field Values

STRING

private static final int STRING
See Also:
Constant Field Values

STRINGLENGTH

private static final int STRINGLENGTH
See Also:
Constant Field Values

STRINGREF

private static final int STRINGREF
See Also:
Constant Field Values

STRINGSET

private static final int STRINGSET
See Also:
Constant Field Values

SUBSTRING

private static final int SUBSTRING
See Also:
Constant Field Values

STRINGAPPEND

private static final int STRINGAPPEND
See Also:
Constant Field Values

STRINGTOLIST

private static final int STRINGTOLIST
See Also:
Constant Field Values

LISTTOSTRING

private static final int LISTTOSTRING
See Also:
Constant Field Values

SYMBOLTOSTRING

private static final int SYMBOLTOSTRING
See Also:
Constant Field Values

STRINGTOSYMBOL

private static final int STRINGTOSYMBOL
See Also:
Constant Field Values

EXP

private static final int EXP
See Also:
Constant Field Values

LOG

private static final int LOG
See Also:
Constant Field Values

SIN

private static final int SIN
See Also:
Constant Field Values

COS

private static final int COS
See Also:
Constant Field Values

TAN

private static final int TAN
See Also:
Constant Field Values

ACOS

private static final int ACOS
See Also:
Constant Field Values

ASIN

private static final int ASIN
See Also:
Constant Field Values

ATAN

private static final int ATAN
See Also:
Constant Field Values

NUMBERTOSTRING

private static final int NUMBERTOSTRING
See Also:
Constant Field Values

STRINGTONUMBER

private static final int STRINGTONUMBER
See Also:
Constant Field Values

CHARQ

private static final int CHARQ
See Also:
Constant Field Values

CHARALPHABETICQ

private static final int CHARALPHABETICQ
See Also:
Constant Field Values

CHARNUMERICQ

private static final int CHARNUMERICQ
See Also:
Constant Field Values

CHARWHITESPACEQ

private static final int CHARWHITESPACEQ
See Also:
Constant Field Values

CHARUPPERCASEQ

private static final int CHARUPPERCASEQ
See Also:
Constant Field Values

CHARLOWERCASEQ

private static final int CHARLOWERCASEQ
See Also:
Constant Field Values

CHARTOINTEGER

private static final int CHARTOINTEGER
See Also:
Constant Field Values

INTEGERTOCHAR

private static final int INTEGERTOCHAR
See Also:
Constant Field Values

CHARUPCASE

private static final int CHARUPCASE
See Also:
Constant Field Values

CHARDOWNCASE

private static final int CHARDOWNCASE
See Also:
Constant Field Values

STRINGQ

private static final int STRINGQ
See Also:
Constant Field Values

VECTORQ

private static final int VECTORQ
See Also:
Constant Field Values

MAKEVECTOR

private static final int MAKEVECTOR
See Also:
Constant Field Values

VECTOR

private static final int VECTOR
See Also:
Constant Field Values

VECTORLENGTH

private static final int VECTORLENGTH
See Also:
Constant Field Values

VECTORREF

private static final int VECTORREF
See Also:
Constant Field Values

VECTORSET

private static final int VECTORSET
See Also:
Constant Field Values

LISTTOVECTOR

private static final int LISTTOVECTOR
See Also:
Constant Field Values

MAP

private static final int MAP
See Also:
Constant Field Values

FOREACH

private static final int FOREACH
See Also:
Constant Field Values

CALLCC

private static final int CALLCC
See Also:
Constant Field Values

VECTORTOLIST

private static final int VECTORTOLIST
See Also:
Constant Field Values

LOAD

private static final int LOAD
See Also:
Constant Field Values

DISPLAY

private static final int DISPLAY
See Also:
Constant Field Values

INPUTPORTQ

private static final int INPUTPORTQ
See Also:
Constant Field Values

CURRENTINPUTPORT

private static final int CURRENTINPUTPORT
See Also:
Constant Field Values

OPENINPUTFILE

private static final int OPENINPUTFILE
See Also:
Constant Field Values

CLOSEINPUTPORT

private static final int CLOSEINPUTPORT
See Also:
Constant Field Values

OUTPUTPORTQ

private static final int OUTPUTPORTQ
See Also:
Constant Field Values

CURRENTOUTPUTPORT

private static final int CURRENTOUTPUTPORT
See Also:
Constant Field Values

OPENOUTPUTFILE

private static final int OPENOUTPUTFILE
See Also:
Constant Field Values

CLOSEOUTPUTPORT

private static final int CLOSEOUTPUTPORT
See Also:
Constant Field Values

READCHAR

private static final int READCHAR
See Also:
Constant Field Values

PEEKCHAR

private static final int PEEKCHAR
See Also:
Constant Field Values

EVAL

private static final int EVAL
See Also:
Constant Field Values

QUOTIENT

private static final int QUOTIENT
See Also:
Constant Field Values

REMAINDER

private static final int REMAINDER
See Also:
Constant Field Values

MODULO

private static final int MODULO
See Also:
Constant Field Values

THIRD

private static final int THIRD
See Also:
Constant Field Values

EOFOBJECTQ

private static final int EOFOBJECTQ
See Also:
Constant Field Values

GCD

private static final int GCD
See Also:
Constant Field Values

LCM

private static final int LCM
See Also:
Constant Field Values

CXR

private static final int CXR
See Also:
Constant Field Values

ODDQ

private static final int ODDQ
See Also:
Constant Field Values

EVENQ

private static final int EVENQ
See Also:
Constant Field Values

ZEROQ

private static final int ZEROQ
See Also:
Constant Field Values

POSITIVEQ

private static final int POSITIVEQ
See Also:
Constant Field Values

NEGATIVEQ

private static final int NEGATIVEQ
See Also:
Constant Field Values

CHARCMP

private static final int CHARCMP
See Also:
Constant Field Values

CHARCICMP

private static final int CHARCICMP
See Also:
Constant Field Values

STRINGCMP

private static final int STRINGCMP
See Also:
Constant Field Values

STRINGCICMP

private static final int STRINGCICMP
See Also:
Constant Field Values

EXACTQ

private static final int EXACTQ
See Also:
Constant Field Values

INEXACTQ

private static final int INEXACTQ
See Also:
Constant Field Values

INTEGERQ

private static final int INTEGERQ
See Also:
Constant Field Values

CALLWITHINPUTFILE

private static final int CALLWITHINPUTFILE
See Also:
Constant Field Values

CALLWITHOUTPUTFILE

private static final int CALLWITHOUTPUTFILE
See Also:
Constant Field Values

NEW

static final int NEW
See Also:
Constant Field Values

CLASS

static final int CLASS
See Also:
Constant Field Values

METHOD

static final int METHOD
See Also:
Constant Field Values

EXIT

static final int EXIT
See Also:
Constant Field Values

SETCAR

static final int SETCAR
See Also:
Constant Field Values

SETCDR

static final int SETCDR
See Also:
Constant Field Values

TIMECALL

static final int TIMECALL
See Also:
Constant Field Values

MACROEXPAND

static final int MACROEXPAND
See Also:
Constant Field Values

ERROR

static final int ERROR
See Also:
Constant Field Values

LISTSTAR

static final int LISTSTAR
See Also:
Constant Field Values
Constructor Detail

SilkPrimitive

public SilkPrimitive(int id,
                     int minArgs,
                     int maxArgs)
Method Detail

installSilkPrimitives

public static SilkEnvironment installSilkPrimitives(SilkEnvironment env)

apply

public java.lang.Object apply(SilkScheme interp,
                              java.lang.Object args)
Apply a primitive to a list of arguments.

Specified by:
apply in class SilkProcedure

stringAppend

public static char[] stringAppend(java.lang.Object args)

memberAssoc

public static java.lang.Object memberAssoc(java.lang.Object obj,
                                           java.lang.Object list,
                                           char m,
                                           char eq)

numCompare

public static java.lang.Object numCompare(java.lang.Object args,
                                          char op)

numCompute

public static java.lang.Object numCompute(java.lang.Object args,
                                          char op,
                                          double result)

sign

static int sign(int x)
Return the sign of the argument: +1, -1, or 0.


charCompare

public static int charCompare(java.lang.Object x,
                              java.lang.Object y,
                              boolean ci)
Return <0 if x is alphabetically first, >0 if y is first, 0 if same. Case insensitive iff ci is true. Error if not both chars.


stringCompare

public static int stringCompare(java.lang.Object x,
                                java.lang.Object y,
                                boolean ci)
Return <0 if x is alphabetically first, >0 if y is first, 0 if same. Case insensitive iff ci is true. Error if not strings.


numberToString

static java.lang.Object numberToString(java.lang.Object x,
                                       java.lang.Object y)

stringToNumber

static java.lang.Object stringToNumber(java.lang.Object x,
                                       java.lang.Object y)

gcd

static java.lang.Object gcd(java.lang.Object args)

gcd2

static long gcd2(long a,
                 long b)

lcm

static java.lang.Object lcm(java.lang.Object args)

isExact

static boolean isExact(java.lang.Object x)

openOutputFile

static java.io.PrintWriter openOutputFile(java.lang.Object filename)

openInputFile

static SilkInputPort openInputFile(java.lang.Object filename)

isList

static boolean isList(java.lang.Object x)

append

static java.lang.Object append(java.lang.Object args)

append2

static java.lang.Object append2(java.lang.Object x,
                                java.lang.Object y)

map

static SilkPair map(SilkProcedure proc,
                    java.lang.Object args,
                    SilkScheme interp,
                    SilkPair result)
Map proc over a list of lists of args, in the given interpreter. If result is non-null, accumulate the results of each call there and return that at the end. Otherwise, just return null.