Class IndyMath

java.lang.Object
org.codehaus.groovy.vmplugin.v8.IndyMath

public class IndyMath extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    and(int a, int b)
    Performs a bitwise AND on two int values.
    static long
    and(long a, long b)
    Performs a bitwise AND on two long values.
    static boolean
    Choose a method to replace the originally chosen metaMethod to have a more efficient call path.
    static double
    div(double a, double b)
    Divides one double value by another.
    static int
    leftShift(int a, int b)
    Left-shifts an int value.
    static long
    leftShift(long a, long b)
    Left-shifts a long value.
    static double
    minus(double a, double b)
    Subtracts one double value from another.
    static int
    minus(int a, int b)
    Subtracts one int value from another.
    static long
    minus(long a, long b)
    Subtracts one long value from another.
    static int
    mod(int a, int b)
    Returns Groovy's modulo result for two int values.
    static long
    mod(long a, long b)
    Returns Groovy's modulo result for two long values.
    static double
    multiply(double a, double b)
    Multiplies two double values.
    static int
    multiply(int a, int b)
    Multiplies two int values.
    static long
    multiply(long a, long b)
    Multiplies two long values.
    static double
    next(double d)
    Returns the successor of a double value.
    static int
    next(int i)
    Returns the successor of an int value.
    static long
    next(long l)
    Returns the successor of a long value.
    static int
    or(int a, int b)
    Performs a bitwise OR on two int values.
    static long
    or(long a, long b)
    Performs a bitwise OR on two long values.
    static double
    plus(double a, double b)
    Adds two double values.
    static int
    plus(int a, int b)
    Adds two int values.
    static long
    plus(long a, long b)
    Adds two long values.
    static double
    previous(double d)
    Returns the predecessor of a double value.
    static int
    previous(int i)
    Returns the predecessor of an int value.
    static long
    previous(long l)
    Returns the predecessor of a long value.
    static int
    remainder(int a, int b)
    Returns the remainder of dividing two int values.
    static long
    remainder(long a, long b)
    Returns the remainder of dividing two long values.
    static int
    rightShift(int a, int b)
    Right-shifts an int value.
    static long
    rightShift(long a, long b)
    Right-shifts a long value.
    static int
    xor(int a, int b)
    Performs a bitwise XOR on two int values.
    static long
    xor(long a, long b)
    Performs a bitwise XOR on two long values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IndyMath

      public IndyMath()
  • Method Details

    • chooseMathMethod

      public static boolean chooseMathMethod(Selector info, MetaMethod metaMethod)
      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 two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the sum
    • minus

      public static int minus(int a, int b)
      Subtracts one int value from another.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the difference
    • multiply

      public static int multiply(int a, int b)
      Multiplies two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the product
    • remainder

      public static int remainder(int a, int b)
      Returns the remainder of dividing two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the remainder
    • mod

      public static int mod(int a, int b)
      Returns Groovy's modulo result for two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the modulo result
    • or

      public static int or(int a, int b)
      Performs a bitwise OR on two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the bitwise OR result
    • xor

      public static int xor(int a, int b)
      Performs a bitwise XOR on two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the bitwise XOR result
    • and

      public static int and(int a, int b)
      Performs a bitwise AND on two int values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the bitwise AND result
    • leftShift

      public static int leftShift(int a, int b)
      Left-shifts an int value.
      Parameters:
      a - the value to shift
      b - the shift distance
      Returns:
      the shifted result
    • rightShift

      public static int rightShift(int a, int b)
      Right-shifts an int value.
      Parameters:
      a - the value to shift
      b - the shift distance
      Returns:
      the shifted result
    • plus

      public static long plus(long a, long b)
      Adds two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the sum
    • minus

      public static long minus(long a, long b)
      Subtracts one long value from another.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the difference
    • multiply

      public static long multiply(long a, long b)
      Multiplies two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the product
    • remainder

      public static long remainder(long a, long b)
      Returns the remainder of dividing two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the remainder
    • mod

      public static long mod(long a, long b)
      Returns Groovy's modulo result for two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the modulo result
    • or

      public static long or(long a, long b)
      Performs a bitwise OR on two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the bitwise OR result
    • xor

      public static long xor(long a, long b)
      Performs a bitwise XOR on two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the bitwise XOR result
    • and

      public static long and(long a, long b)
      Performs a bitwise AND on two long values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the bitwise AND result
    • leftShift

      public static long leftShift(long a, long b)
      Left-shifts a long value.
      Parameters:
      a - the value to shift
      b - the shift distance
      Returns:
      the shifted result
    • rightShift

      public static long rightShift(long a, long b)
      Right-shifts a long value.
      Parameters:
      a - the value to shift
      b - the shift distance
      Returns:
      the shifted result
    • plus

      public static double plus(double a, double b)
      Adds two double values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the sum
    • minus

      public static double minus(double a, double b)
      Subtracts one double value from another.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the difference
    • multiply

      public static double multiply(double a, double b)
      Multiplies two double values.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the product
    • div

      public static double div(double a, double b)
      Divides one double value by another.
      Parameters:
      a - the left operand
      b - the right operand
      Returns:
      the quotient
    • next

      public static int next(int i)
      Returns the successor of an int value.
      Parameters:
      i - the input value
      Returns:
      i + 1
    • next

      public static long next(long l)
      Returns the successor of a long value.
      Parameters:
      l - the input value
      Returns:
      l + 1
    • next

      public static double next(double d)
      Returns the successor of a double value.
      Parameters:
      d - the input value
      Returns:
      d + 1
    • previous

      public static int previous(int i)
      Returns the predecessor of an int value.
      Parameters:
      i - the input value
      Returns:
      i - 1
    • previous

      public static long previous(long l)
      Returns the predecessor of a long value.
      Parameters:
      l - the input value
      Returns:
      l - 1
    • previous

      public static double previous(double d)
      Returns the predecessor of a double value.
      Parameters:
      d - the input value
      Returns:
      d - 1