Package org.codehaus.groovy.vmplugin.v8
Class IndyMath
java.lang.Object
org.codehaus.groovy.vmplugin.v8.IndyMath
This class contains math operations used by indy instead of the normal
meta method and call site caching system. The goal is to avoid boxing, thus
use primitive types for parameters and return types where possible.
WARNING: This class is for internal use only. Do not use it outside the
org.codehaus.groovy.vmplugin.v8 package of groovy-core.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intand(int a, int b) Performs a bitwise AND on twointvalues.static longand(long a, long b) Performs a bitwise AND on twolongvalues.static booleanchooseMathMethod(Selector info, MetaMethod metaMethod) Choose a method to replace the originally chosen metaMethod to have a more efficient call path.static doublediv(double a, double b) Divides onedoublevalue by another.static intleftShift(int a, int b) Left-shifts anintvalue.static longleftShift(long a, long b) Left-shifts alongvalue.static doubleminus(double a, double b) Subtracts onedoublevalue from another.static intminus(int a, int b) Subtracts oneintvalue from another.static longminus(long a, long b) Subtracts onelongvalue from another.static intmod(int a, int b) Returns Groovy's modulo result for twointvalues.static longmod(long a, long b) Returns Groovy's modulo result for twolongvalues.static doublemultiply(double a, double b) Multiplies twodoublevalues.static intmultiply(int a, int b) Multiplies twointvalues.static longmultiply(long a, long b) Multiplies twolongvalues.static doublenext(double d) Returns the successor of adoublevalue.static intnext(int i) Returns the successor of anintvalue.static longnext(long l) Returns the successor of alongvalue.static intor(int a, int b) Performs a bitwise OR on twointvalues.static longor(long a, long b) Performs a bitwise OR on twolongvalues.static doubleplus(double a, double b) Adds twodoublevalues.static intplus(int a, int b) Adds twointvalues.static longplus(long a, long b) Adds twolongvalues.static doubleprevious(double d) Returns the predecessor of adoublevalue.static intprevious(int i) Returns the predecessor of anintvalue.static longprevious(long l) Returns the predecessor of alongvalue.static intremainder(int a, int b) Returns the remainder of dividing twointvalues.static longremainder(long a, long b) Returns the remainder of dividing twolongvalues.static intrightShift(int a, int b) Right-shifts anintvalue.static longrightShift(long a, long b) Right-shifts alongvalue.static intxor(int a, int b) Performs a bitwise XOR on twointvalues.static longxor(long a, long b) Performs a bitwise XOR on twolongvalues.
-
Constructor Details
-
IndyMath
public IndyMath()
-
-
Method Details
-
chooseMathMethod
Choose a method to replace the originally chosen metaMethod to have a more efficient call path. -
plus
public static int plus(int a, int b) Adds twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the sum
-
minus
public static int minus(int a, int b) Subtracts oneintvalue from another.- Parameters:
a- the left operandb- the right operand- Returns:
- the difference
-
multiply
public static int multiply(int a, int b) Multiplies twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the product
-
remainder
public static int remainder(int a, int b) Returns the remainder of dividing twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the remainder
-
mod
public static int mod(int a, int b) Returns Groovy's modulo result for twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the modulo result
-
or
public static int or(int a, int b) Performs a bitwise OR on twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the bitwise OR result
-
xor
public static int xor(int a, int b) Performs a bitwise XOR on twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the bitwise XOR result
-
and
public static int and(int a, int b) Performs a bitwise AND on twointvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the bitwise AND result
-
leftShift
public static int leftShift(int a, int b) Left-shifts anintvalue.- Parameters:
a- the value to shiftb- the shift distance- Returns:
- the shifted result
-
rightShift
public static int rightShift(int a, int b) Right-shifts anintvalue.- Parameters:
a- the value to shiftb- the shift distance- Returns:
- the shifted result
-
plus
public static long plus(long a, long b) Adds twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the sum
-
minus
public static long minus(long a, long b) Subtracts onelongvalue from another.- Parameters:
a- the left operandb- the right operand- Returns:
- the difference
-
multiply
public static long multiply(long a, long b) Multiplies twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the product
-
remainder
public static long remainder(long a, long b) Returns the remainder of dividing twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the remainder
-
mod
public static long mod(long a, long b) Returns Groovy's modulo result for twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the modulo result
-
or
public static long or(long a, long b) Performs a bitwise OR on twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the bitwise OR result
-
xor
public static long xor(long a, long b) Performs a bitwise XOR on twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the bitwise XOR result
-
and
public static long and(long a, long b) Performs a bitwise AND on twolongvalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the bitwise AND result
-
leftShift
public static long leftShift(long a, long b) Left-shifts alongvalue.- Parameters:
a- the value to shiftb- the shift distance- Returns:
- the shifted result
-
rightShift
public static long rightShift(long a, long b) Right-shifts alongvalue.- Parameters:
a- the value to shiftb- the shift distance- Returns:
- the shifted result
-
plus
public static double plus(double a, double b) Adds twodoublevalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the sum
-
minus
public static double minus(double a, double b) Subtracts onedoublevalue from another.- Parameters:
a- the left operandb- the right operand- Returns:
- the difference
-
multiply
public static double multiply(double a, double b) Multiplies twodoublevalues.- Parameters:
a- the left operandb- the right operand- Returns:
- the product
-
div
public static double div(double a, double b) Divides onedoublevalue by another.- Parameters:
a- the left operandb- the right operand- Returns:
- the quotient
-
next
public static int next(int i) Returns the successor of anintvalue.- Parameters:
i- the input value- Returns:
i + 1
-
next
public static long next(long l) Returns the successor of alongvalue.- Parameters:
l- the input value- Returns:
l + 1
-
next
public static double next(double d) Returns the successor of adoublevalue.- Parameters:
d- the input value- Returns:
d + 1
-
previous
public static int previous(int i) Returns the predecessor of anintvalue.- Parameters:
i- the input value- Returns:
i - 1
-
previous
public static long previous(long l) Returns the predecessor of alongvalue.- Parameters:
l- the input value- Returns:
l - 1
-
previous
public static double previous(double d) Returns the predecessor of adoublevalue.- Parameters:
d- the input value- Returns:
d - 1
-