edu.vub.at.objects.natives
Class NATNumeric

java.lang.Object
  extended byedu.vub.at.objects.natives.NATNil
      extended byedu.vub.at.objects.natives.NATByCopy
          extended byedu.vub.at.objects.natives.grammar.NATAbstractGrammar
              extended byedu.vub.at.objects.natives.grammar.AGExpression
                  extended byedu.vub.at.objects.natives.NATNumeric
All Implemented Interfaces:
ATAbstractGrammar, ATConversions, ATExpression, ATNil, ATNumeric, ATObject, ATStatement, java.io.Serializable
Direct Known Subclasses:
NATFraction, NATNumber

public abstract class NATNumeric
extends AGExpression
implements ATNumeric

A common superclass of both numbers and fractions to factor out common base-level behaviour.

Author:
tvc
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.vub.at.objects.natives.NATNil
_INSTANCE_
 
Constructor Summary
NATNumeric()
           
 
Method Summary
 NATNumeric asNativeNumeric()
           
 ATBoolean base__opeql_(ATNumeric other)
          a = b iff (a <=> b) == 0
 ATBoolean base__opgtx__opeql_(ATNumeric other)
          a >= b iff (a <=> b) !
 ATBoolean base__opgtx_(ATNumeric other)
          a > b iff (a <=> b) == +1
 ATBoolean base__opltx__opeql_(ATNumeric other)
          a <= b iff (a <=> b) !
 ATBoolean base__opltx_(ATNumeric other)
          a < b iff (a <=> b) == -1
 ATBoolean base__opnot__opeql_(ATNumeric other)
          a !
 ATFraction base_cos()
          NUM(n).cos() => FRC(Math.cos(n))
 ATFraction base_expt(ATNumeric pow)
          NUM(n).expt(NUM(e)) => FRC(Math.pow(n,e))
 ATFraction base_log()
          NUM(n).log() => FRC(log(e,n))
 ATFraction base_sin()
          NUM(n).sin() => FRC(Math.sin(n))
 ATFraction base_sqrt()
          NUM(n).sqrt() => FRC(Math.sqrt(n))
 ATFraction base_tan()
          NUM(n).tan() => FRC(Math.tan(n))
protected abstract  double getJavaValue()
          Template method that should return the value of the underlying number or fraction as a double
 ATTable meta_getStripes()
          Returns the stripes of this object.
 
Methods inherited from class edu.vub.at.objects.natives.grammar.AGExpression
base_asExpression
 
Methods inherited from class edu.vub.at.objects.natives.NATByCopy
meta_pass, meta_resolve
 
Methods inherited from class edu.vub.at.objects.natives.NATNil
asAmbientTalkObject, asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeTable, asNativeText, base__opeql__opeql_, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asFarReference, base_asField, base_asHandler, base_asMessage, base_asMessageCreation, base_asMethod, base_asMirror, base_asNumber, base_asSplice, base_asStatement, base_asStripe, base_asSymbol, base_asTable, base_asUnquoteSplice, base_asVariableAssignment, base_init, base_isBoolean, base_isCallFrame, base_isClosure, base_isFarReference, base_isMessageCreation, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, base_new, createChild, equals, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText, meta_addField, meta_addMethod, meta_assignField, meta_assignVariable, meta_clone, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_newInstance, meta_print, meta_quote, meta_receive, meta_respondsTo, meta_select, meta_send, meta_share, readResolve, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.vub.at.objects.ATNumeric
base__opdiv_, base__opltx__opeql__opgtx_, base__opmns_, base__oppls_, base__optms_, base_addFraction, base_addNumber, base_divideFraction, base_divideNumber, base_gequalsFraction, base_gequalsNumber, base_subtractFraction, base_subtractNumber, base_timesFraction, base_timesNumber
 
Methods inherited from interface edu.vub.at.objects.ATObject
base__opeql__opeql_, base_init, base_new, meta_addField, meta_addMethod, meta_assignField, meta_assignVariable, meta_clone, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_newInstance, meta_pass, meta_print, meta_quote, meta_receive, meta_resolve, meta_respondsTo, meta_select, meta_send, meta_share
 
Methods inherited from interface edu.vub.at.objects.coercion.ATConversions
asAmbientTalkObject, asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeTable, asNativeText, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, base_asFarReference, base_asField, base_asHandler, base_asMessage, base_asMessageCreation, base_asMethod, base_asMirror, base_asNumber, base_asSplice, base_asStatement, base_asStripe, base_asSymbol, base_asTable, base_asUnquoteSplice, base_asVariableAssignment, base_isBoolean, base_isCallFrame, base_isClosure, base_isFarReference, base_isMessageCreation, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText
 

Constructor Detail

NATNumeric

public NATNumeric()
Method Detail

getJavaValue

protected abstract double getJavaValue()
Template method that should return the value of the underlying number or fraction as a double


asNativeNumeric

public NATNumeric asNativeNumeric()
                           throws XTypeMismatch
Specified by:
asNativeNumeric in interface ATConversions
Overrides:
asNativeNumeric in class NATNil
Throws:
XTypeMismatch

meta_getStripes

public ATTable meta_getStripes()
                        throws InterpreterException
Description copied from interface: ATObject
Returns the stripes of this object. Note that only the stripes that were attached directly to this object are returned, not all of the parent's stripes as well.

Specified by:
meta_getStripes in interface ATObject
Overrides:
meta_getStripes in class AGExpression
Throws:
InterpreterException

base_cos

public ATFraction base_cos()
NUM(n).cos() => FRC(Math.cos(n))

Specified by:
base_cos in interface ATNumeric

base_sin

public ATFraction base_sin()
NUM(n).sin() => FRC(Math.sin(n))

Specified by:
base_sin in interface ATNumeric

base_tan

public ATFraction base_tan()
NUM(n).tan() => FRC(Math.tan(n))

Specified by:
base_tan in interface ATNumeric

base_log

public ATFraction base_log()
NUM(n).log() => FRC(log(e,n))

Specified by:
base_log in interface ATNumeric

base_sqrt

public ATFraction base_sqrt()
NUM(n).sqrt() => FRC(Math.sqrt(n))

Specified by:
base_sqrt in interface ATNumeric

base_expt

public ATFraction base_expt(ATNumeric pow)
                     throws InterpreterException
NUM(n).expt(NUM(e)) => FRC(Math.pow(n,e))

Specified by:
base_expt in interface ATNumeric
Throws:
InterpreterException

base__opltx_

public ATBoolean base__opltx_(ATNumeric other)
                       throws InterpreterException
a < b iff (a <=> b) == -1

Specified by:
base__opltx_ in interface ATNumeric
Throws:
InterpreterException

base__opgtx_

public ATBoolean base__opgtx_(ATNumeric other)
                       throws InterpreterException
a > b iff (a <=> b) == +1

Specified by:
base__opgtx_ in interface ATNumeric
Throws:
InterpreterException

base__opltx__opeql_

public ATBoolean base__opltx__opeql_(ATNumeric other)
                              throws InterpreterException
a <= b iff (a <=> b) != +1

Specified by:
base__opltx__opeql_ in interface ATNumeric
Throws:
InterpreterException

base__opgtx__opeql_

public ATBoolean base__opgtx__opeql_(ATNumeric other)
                              throws InterpreterException
a >= b iff (a <=> b) != -1

Specified by:
base__opgtx__opeql_ in interface ATNumeric
Throws:
InterpreterException

base__opeql_

public ATBoolean base__opeql_(ATNumeric other)
                       throws InterpreterException
a = b iff (a <=> b) == 0

Specified by:
base__opeql_ in interface ATNumeric
Throws:
InterpreterException

base__opnot__opeql_

public ATBoolean base__opnot__opeql_(ATNumeric other)
                              throws InterpreterException
a != b iff (a <=> b) != 0

Specified by:
base__opnot__opeql_ in interface ATNumeric
Throws:
InterpreterException