Interface BlockCreator

All Superinterfaces:
SimpleTyped, Typed

public sealed interface BlockCreator extends SimpleTyped
A code block. All blocks have a type and if that type is not void, the block must yield a value (or exit some other way).
  • Method Details

    • type

      ClassDesc type()
      Returns the type of this block (may be void). If the type is non-void, then the block must yield a value if it does not exit explicitly some other way.
      Specified by:
      type in interface SimpleTyped
      Specified by:
      type in interface Typed
      Returns:
      the type of this block (may be void)
    • yield

      void yield(Expr value)
      Yield a value from this block. If control falls out of a block, an implicit yield(Constant.ofVoid()) is added to terminate it.
      Parameters:
      value - the value to yield (must not be null)
      Throws:
      IllegalArgumentException - if the value type does not match the type of the block
    • yieldNull

      default void yieldNull()
      Yield a null value from this block.
      Throws:
      IllegalArgumentException - if this block's type is primitive or void
    • active

      boolean active()
      Returns true if the current block is activated (in scope), or false if it is not. Blocks which are not active may not have operations added to them. Blocks are inactive when a nested scope is active or when the block is terminated.
      Returns:
      true if the current block is activated (in scope), or false if it is not
    • done

      boolean done()
      Returns true if the block is done, or false if it is not.
      Returns:
      true if the block is done, or false if it is not
    • isContainedBy

      boolean isContainedBy(BlockCreator other)
      Returns true if this block is contained by the given block, or false if it is not.
      Parameters:
      other - the containing block (must not be null)
      Returns:
      true if this block is contained by the given block, or false if it is not
    • contains

      default boolean contains(BlockCreator other)
      Returns true if this block contains the given block, or false if it does not.
      Parameters:
      other - the contained block (must not be null)
      Returns:
      true if this block contains the given block, or false if it does not
    • contains

      default boolean contains(LocalVar var)
      Returns true if this block contains the block that owns the given variable, or false if it does not.
      Parameters:
      var - the variable (must not be null)
      Returns:
      true if this block contains the block that owns the given variable, or false if it does not
    • localVar

      LocalVar localVar(String name, GenericType type, Expr value)
      Declare a local variable with given name and type, which is initialized to the given value.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      type - the variable type (must not be null)
      value - the variable initial value (must not be null)
      Returns:
      the local variable (not null)
    • localVar

      LocalVar localVar(String name, ClassDesc type, Expr value)
      Declare a local variable with given name and type, which is initialized to the given value.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      type - the variable type (must not be null)
      value - the variable initial value (must not be null)
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, Class<?> type, Expr value)
      Declare a local variable with given name and type, which is initialized to the given value.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      type - the variable type (must not be null)
      value - the variable initial value (must not be null)
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, Expr value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is the type of the value.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value (must not be null)
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, boolean value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is boolean.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, int value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is int.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, long value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is long.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, float value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is float.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, double value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is double.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(String name, String value)
      Declare a local variable with given name, which is initialized to the given value. The type of the new variable is String.

      Variable names are not strictly required to be unique, but it is a good practice.

      Parameters:
      name - the variable name (must not be null)
      value - the variable initial value (must not be null)
      Returns:
      the local variable (not null)
    • localVar

      default LocalVar localVar(Var original)
      Declare a local variable, which is initialized to the given variable's current value. The name and type of the new variable are the same as the name and type of the original.
      Parameters:
      original - the original variable (must not be null)
      Returns:
      the new local variable (not null)
    • get

      Expr get(Assignable var, MemoryOrder mode)
      Read a value from memory with the given atomicity mode.
      Parameters:
      var - the assignable (must not be null)
      mode - the atomicity mode for the access (must not be null)
      Returns:
      the memory value (not null)
    • get

      default Expr get(Assignable var)
      Read a value from memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      Returns:
      the memory value (not null)
    • getStaticField

      default Expr getStaticField(FieldDesc desc)
      Read the value from a static field.
      Parameters:
      desc - the field descriptor (must not be null)
      Returns:
      the memory value (not null)
    • set

      void set(Assignable var, Expr value, MemoryOrder mode)
      Write a value to memory with the given atomicity mode.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write (must not be null)
      mode - the atomicity mode for the access (must not be null)
    • set

      default void set(Assignable var, Expr value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write (must not be null)
    • set

      default void set(Assignable var, Const value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write (must not be null)
    • set

      default void set(Assignable var, ConstantDesc value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write (must not be null)
    • set

      default void set(Assignable var, Constable value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write (must not be null)
    • set

      default void set(Assignable var, String value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write (must not be null)
    • set

      default void set(Assignable var, int value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write
    • set

      default void set(Assignable var, long value)
      Write a value to memory using the declared atomicity mode for the assignable.
      Parameters:
      var - the assignable (must not be null)
      value - the value to write
    • setStaticField

      default void setStaticField(FieldDesc desc, Expr value)
      Write the value to a static field.
      Parameters:
      desc - the field descriptor (must not be null)
      value - the value to write (must not be null)
    • swap

      default void swap(Assignable var1, Assignable var2)
      Swap the values of two variables without requiring an intermediate temporary variable.
      Parameters:
      var1 - the first variable (must not be null)
      var2 - the second variable (must not be null)
    • rotate

      default void rotate(Assignable var1, Assignable var2, Assignable var3)
      Rotate the values of three variables one position to the right without requiring an intermediate temporary variable. The rightmost value is moved to the leftmost variable.
      Parameters:
      var1 - the first variable (must not be null)
      var2 - the second variable (must not be null)
      var3 - the third variable (must not be null)
    • rotate

      default void rotate(Assignable var1, Assignable var2, Assignable var3, Assignable var4)
      Rotate the values of four variables one position to the right without requiring an intermediate temporary variable. The rightmost value is moved to the leftmost variable.
      Parameters:
      var1 - the first variable (must not be null)
      var2 - the second variable (must not be null)
      var3 - the third variable (must not be null)
      var4 - the fourth variable (must not be null)
    • inc

      void inc(Assignable var, Const amount)
      Increment some variable by a constant amount. This is not an atomic operation.
      Parameters:
      var - the variable to modify (must not be null)
      amount - the constant amount to increase by (must not be null)
    • inc

      default void inc(Assignable var, int amount)
      Increment some variable by a constant amount. This is not an atomic operation.
      Parameters:
      var - the variable to modify (must not be null)
      amount - the constant amount to increase by
    • inc

      default void inc(Assignable var)
      Increment some variable by one. This is not an atomic operation.
      Parameters:
      var - the variable to modify (must not be null)
    • dec

      void dec(Assignable var, Const amount)
      Decrement some variable by a constant amount. This is not an atomic operation.
      Parameters:
      var - the variable to modify (must not be null)
      amount - the constant amount to decrease by (must not be null)
    • dec

      default void dec(Assignable var, int amount)
      Decrement some variable by a constant amount. This is not an atomic operation.
      Parameters:
      var - the variable to modify (must not be null)
      amount - the constant amount to decrease by
    • dec

      default void dec(Assignable var)
      Decrement some variable by one. This is not an atomic operation.
      Parameters:
      var - the variable to modify (must not be null)
    • compareAndSet

      Expr compareAndSet(Assignable var, Expr expected, Expr update)
      Atomically sets the value of var to update if its current value is equal to expected.
      Parameters:
      var - the variable to update (must not be null)
      expected - the expected comparison value (must not be null)
      update - the new value to set (must not be null)
      Returns:
      a boolean-typed expression that is true if the update succeeded or false if it did not
    • weakCompareAndSet

      Expr weakCompareAndSet(Assignable var, Expr expected, Expr update, MemoryOrder order)
      Atomically sets the value of var to update if its current value is equal to expected. The comparison is "weak", meaning that it may fail sporadically. The given memory order is used, and must be one of:
      Parameters:
      var - the variable to update (must not be null)
      expected - the expected comparison value (must not be null)
      update - the new value to set (must not be null)
      order - the memory order which is used for the operation (must not be null)
      Returns:
      a boolean-typed expression that is true if the update succeeded or false if it did not
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically, or if order is not one of the allowed values
    • weakCompareAndSet

      default Expr weakCompareAndSet(Assignable var, Expr expected, Expr update)
      Atomically sets the value of var to update if its current value is equal to expected, using volatile memory ordering. The comparison is "weak", meaning that it may fail sporadically.
      Parameters:
      var - the variable to update (must not be null)
      expected - the expected comparison value (must not be null)
      update - the new value to set (must not be null)
      Returns:
      a boolean-typed expression that is true if the update succeeded or false if it did not
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically
    • compareAndExchange

      Expr compareAndExchange(Assignable var, Expr expected, Expr update, MemoryOrder order)
    • compareAndExchange

      default Expr compareAndExchange(Assignable var, Expr expected, Expr update)
    • getAndSet

      Expr getAndSet(Assignable var, Expr newValue, MemoryOrder order)
      Atomically get and set the value of the target assignable expression. The given memory order is used, and must be one of:
      Parameters:
      var - the target assignable expression (must not be null)
      newValue - the value to store (must not be null)
      order - the memory order (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically, or if order is not one of the allowed values
    • getAndSet

      default Expr getAndSet(Assignable var, Expr newValue)
      Atomically get and set the value of the target assignable expression using volatile semantics.
      Parameters:
      var - the target assignable expression (must not be null)
      newValue - the value to store (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically
    • getAndAdd

      Expr getAndAdd(Assignable var, Expr amount, MemoryOrder order)
      Atomically get, add, and store the value of the target assignable expression. The given memory order is used, and must be one of:
      Parameters:
      var - the target assignable expression (must not be null)
      amount - the value to add to the target (must not be null)
      order - the memory order (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically, or if order is not one of the allowed values
    • getAndAdd

      default Expr getAndAdd(Assignable var, Expr amount)
      Atomically get, add, and store the value of the target assignable expression using volatile semantics.
      Parameters:
      var - the target assignable expression (must not be null)
      amount - the value to add to the target (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically
    • getAndBitwiseOr

      Expr getAndBitwiseOr(Assignable var, Expr other, MemoryOrder order)
      Atomically get, bitwise-or, and store the value of the target assignable expression. The given memory order is used, and must be one of:
      Parameters:
      var - the target assignable expression (must not be null)
      other - the value to bitwise-or with the target (must not be null)
      order - the memory order (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically, or if order is not one of the allowed values
    • getAndBitwiseOr

      default Expr getAndBitwiseOr(Assignable var, Expr other)
      Atomically get, bitwise-or, and store the value of the target assignable expression with volatile semantics.
      Parameters:
      var - the target assignable expression (must not be null)
      other - the value to bitwise-or with the target (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically
    • getAndBitwiseAnd

      Expr getAndBitwiseAnd(Assignable var, Expr other, MemoryOrder order)
      Atomically get, bitwise-and, and store the value of the target assignable expression. The given memory order is used, and must be one of:
      Parameters:
      var - the target assignable expression (must not be null)
      other - the value to bitwise-and with the target (must not be null)
      order - the memory order (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically, or if order is not one of the allowed values
    • getAndBitwiseAnd

      default Expr getAndBitwiseAnd(Assignable var, Expr other)
      Atomically get, bitwise-and, and store the value of the target assignable expression with volatile semantics.
      Parameters:
      var - the target assignable expression (must not be null)
      other - the value to bitwise-and with the target (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically
    • getAndBitwiseXor

      Expr getAndBitwiseXor(Assignable var, Expr other, MemoryOrder order)
      Atomically get, bitwise-xor, and store the value of the target assignable expression. The given memory order is used, and must be one of:
      Parameters:
      var - the target assignable expression (must not be null)
      other - the value to bitwise-xor with the target (must not be null)
      order - the memory order (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically, or if order is not one of the allowed values
    • getAndBitwiseXor

      default Expr getAndBitwiseXor(Assignable var, Expr other)
      Atomically get, bitwise-xor, and store the value of the target assignable expression with volatile semantics.
      Parameters:
      var - the target assignable expression (must not be null)
      other - the value to bitwise-xor with the target (must not be null)
      Returns:
      the previous value of the target expression (not null)
      Throws:
      IllegalArgumentException - if the target variable cannot be accessed atomically
    • fullFence

      default void fullFence()
      Emit a full fence.
    • acquireFence

      default void acquireFence()
      Emit an acquire fence.
    • releaseFence

      default void releaseFence()
    • loadLoadFence

      default void loadLoadFence()
    • storeStoreFence

      default void storeStoreFence()
    • reachabilityFence

      default void reachabilityFence(Expr obj)
      Emit a reachability fence for the given object expression.
      Parameters:
      obj - the object expression (must not be null)
      Throws:
      IllegalArgumentException - if the expression is not a reference type
    • newEmptyArray

      Expr newEmptyArray(ClassDesc componentType, Expr size)
      Create a new, empty array of the given type with given size.
      Parameters:
      componentType - the component type (must not be null)
      size - the size of the array (must not be null)
      Returns:
      the expression for the new array (not null)
    • newEmptyArray

      default Expr newEmptyArray(ClassDesc componentType, int size)
      Create a new, empty array of the given type with given size.
      Parameters:
      componentType - the component type (must not be null)
      size - the size of the array
      Returns:
      the expression for the new array (not null)
    • newEmptyArray

      default Expr newEmptyArray(Class<?> componentType, Expr size)
      Create a new, empty array of the given type with given size.
      Parameters:
      componentType - the component type (must not be null)
      size - the size of the array (must not be null)
      Returns:
      the expression for the new array (not null)
    • newEmptyArray

      default Expr newEmptyArray(Class<?> componentType, int size)
      Create a new, empty array of the given type with given size.
      Parameters:
      componentType - the component type (must not be null)
      size - the size of the array
      Returns:
      the expression for the new array (not null)
    • newArray

      <T> Expr newArray(ClassDesc componentType, List<T> values, Function<T,? extends Expr> mapper)
      Create a new array with the given type, initialized with the given values.
      Parameters:
      componentType - the component type (must not be null)
      values - the values to assign into the array after mapping (must not be null)
      mapper - function that turns values into expressions (must not be null)
      Returns:
      the expression for the new array (not null)
    • newArray

      default Expr newArray(ClassDesc componentType, List<? extends Expr> values)
      Create a new array with the given type, initialized with the given values.
      Parameters:
      componentType - the component type (must not be null)
      values - the values to assign into the array (must not be null)
      Returns:
      the expression for the new array (not null)
    • newArray

      default Expr newArray(ClassDesc componentType, Expr... values)
      Create a new array with the given type, initialized with the given values.
      Parameters:
      componentType - the component type (must not be null)
      values - the values to assign into the array (must not be null)
      Returns:
      the expression for the new array (not null)
    • newArray

      default <T> Expr newArray(Class<?> componentType, List<T> values, Function<T,? extends Expr> mapper)
      Create a new array with the given type, initialized with the given values.
      Parameters:
      componentType - the component type (must not be null)
      values - the values to assign into the array after mapping (must not be null)
      mapper - function that turns values into expressions (must not be null)
      Returns:
      the expression for the new array (not null)
    • newArray

      default Expr newArray(Class<?> componentType, List<? extends Expr> values)
      Create a new array with the given type, initialized with the given values.
      Parameters:
      componentType - the component type (must not be null)
      values - the values to assign into the array (must not be null)
      Returns:
      the expression for the new array (not null)
    • newArray

      default Expr newArray(Class<?> componentType, Expr... values)
      Create a new array with the given type, initialized with the given values.
      Parameters:
      componentType - the component type (must not be null)
      values - the values to assign into the array (must not be null)
      Returns:
      the expression for the new array (not null)
    • isNull

      default Expr isNull(Expr input)
    • isNotNull

      default Expr isNotNull(Expr input)
    • eq

      Expr eq(Expr a, Expr b)
      The equality operator. The arguments must be of the same type kind. This works equivalently to the == operator in Java for primitive and reference values. For object equality using Object.equals(java.lang.Object), see exprEquals(Expr, Expr).
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument (must not be null)
      Returns:
      the boolean result expression
      See Also:
    • eq

      default Expr eq(Expr a, int b)
      The equality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the == operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • eq

      default Expr eq(Expr a, long b)
      The equality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the == operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • eq

      default Expr eq(Expr a, float b)
      The equality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the == operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • eq

      default Expr eq(Expr a, double b)
      The equality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the == operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ne

      Expr ne(Expr a, Expr b)
      The inequality operator. The arguments must be of the same type kind. This works equivalently to the != operator in Java for primitive and reference values. For object equality using Object.equals(java.lang.Object), see exprEquals(Expr, Expr).
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument (must not be null)
      Returns:
      the boolean result expression
      See Also:
    • ne

      default Expr ne(Expr a, int b)
      The inequality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the != operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ne

      default Expr ne(Expr a, long b)
      The inequality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the != operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ne

      default Expr ne(Expr a, float b)
      The inequality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the != operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ne

      default Expr ne(Expr a, double b)
      The inequality operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the != operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • lt

      Expr lt(Expr a, Expr b)
      The less-than operator. The arguments must be of the same type kind. This works equivalently to the < operator in Java for primitive values. This operation does not support reference values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • lt

      default Expr lt(Expr a, int b)
      The less-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the < operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • lt

      default Expr lt(Expr a, long b)
      The less-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the < operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • lt

      default Expr lt(Expr a, float b)
      The less-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the < operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • lt

      default Expr lt(Expr a, double b)
      The less-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the < operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • gt

      Expr gt(Expr a, Expr b)
      The greater-than operator. The arguments must be of the same type kind. This works equivalently to the > operator in Java for primitive values. This operation does not support reference values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • gt

      default Expr gt(Expr a, int b)
      The greater-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the > operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • gt

      default Expr gt(Expr a, long b)
      The greater-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the > operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • gt

      default Expr gt(Expr a, float b)
      The greater-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the > operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • gt

      default Expr gt(Expr a, double b)
      The greater-than operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the > operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • le

      Expr le(Expr a, Expr b)
      The less-than-or-equals operator. The arguments must be of the same type kind. This works equivalently to the <= operator in Java for primitive values. This operation does not support reference values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • le

      default Expr le(Expr a, int b)
      The less-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the <= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • le

      default Expr le(Expr a, long b)
      The less-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the <= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • le

      default Expr le(Expr a, float b)
      The less-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the <= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • le

      default Expr le(Expr a, double b)
      The less-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the <= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ge

      Expr ge(Expr a, Expr b)
      The greater-than-or-equals operator. The arguments must be of the same type kind. This works equivalently to the >= operator in Java for primitive values. This operation does not support reference values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ge

      default Expr ge(Expr a, int b)
      The greater-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the >= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ge

      default Expr ge(Expr a, long b)
      The greater-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the >= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ge

      default Expr ge(Expr a, float b)
      The greater-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the >= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • ge

      default Expr ge(Expr a, double b)
      The greater-than-or-equals operator. The second argument will be cast to the same type kind as the first argument. This works equivalently to the >= operator in Java for primitive values.
      Parameters:
      a - the left-hand argument (must not be null)
      b - the right-hand argument
      Returns:
      the boolean result expression
    • cmp

      Expr cmp(Expr a, Expr b)
      The general comparison operator. The arguments must be of the same type kind.

      For primitives, this returns -1, 0, or 1 if the second argument is less than, equal to, or greater than the first argument, respectively.

      For reference values, this returns the result of natural-order comparisons using Comparable.compareTo(Object). If the static type of either value does not implement this interface, the class will not verify.

      Comparisons between floating point values will have behavior equivalent to that of the Float.compare(float, float) or Double.compare(double, double) methods, particularly as this relates to NaN and negative-zero values.

      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the comparison result expression (not null)
    • cmpl

      Expr cmpl(Expr a, Expr b)
      The general comparison operator. This method behaves equivalently to cmp(io.quarkus.gizmo2.Expr, io.quarkus.gizmo2.Expr) in all respects, except that floating point value comparison will result in a -1 if either value is NaN, and that negative zero is considered equal to positive zero.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the comparison result expression (not null)
    • cmpg

      Expr cmpg(Expr a, Expr b)
      The general comparison operator. This method behaves equivalently to cmp(io.quarkus.gizmo2.Expr, io.quarkus.gizmo2.Expr) in all respects, except that floating point value comparison will result in a 1 if either value is NaN, and that negative zero is considered equal to positive zero.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the comparison result expression (not null)
    • and

      Expr and(Expr a, Expr b)
      The bitwise and operator. The arguments must be of the same type kind. This method works equivalently to the & operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • and

      default Expr and(Expr a, int b)
      The bitwise and operator. This method works equivalently to the & operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • and

      default Expr and(Expr a, long b)
      The bitwise and operator. This method works equivalently to the & operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • or

      Expr or(Expr a, Expr b)
      The bitwise or operator. The arguments must be of the same type kind. This method works equivalently to the | operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • or

      default Expr or(Expr a, int b)
      The bitwise or operator. This method works equivalently to the | operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • or

      default Expr or(Expr a, long b)
      The bitwise or operator. This method works equivalently to the | operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • xor

      Expr xor(Expr a, Expr b)
      The bitwise xor operator. The arguments must be of the same type kind. This method works equivalently to the ^ operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • xor

      default Expr xor(Expr a, int b)
      The bitwise xor operator. This method works equivalently to the ^ operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • xor

      default Expr xor(Expr a, long b)
      The bitwise xor operator. This method works equivalently to the ^ operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • complement

      Expr complement(Expr a)
      The bitwise complement operator. This method works equivalently to the ~ operator in Java.
      Parameters:
      a - the argument (must not be null)
      Returns:
      the operation result (not null)
    • shl

      Expr shl(Expr a, Expr b)
      The bitwise left-shift operator. The arguments must be of the same type kind. This method works equivalently to the << operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • shl

      default Expr shl(Expr a, int b)
      The bitwise left-shift operator. This method works equivalently to the << operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • shl

      default Expr shl(Expr a, long b)
      The bitwise left-shift operator. This method works equivalently to the << operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • shr

      Expr shr(Expr a, Expr b)
      The bitwise signed-right-shift operator. The arguments must be of the same type kind. This method works equivalently to the >> operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • shr

      default Expr shr(Expr a, int b)
      The bitwise signed-right-shift operator. This method works equivalently to the >> operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • shr

      default Expr shr(Expr a, long b)
      The bitwise signed-right-shift operator. This method works equivalently to the >> operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • ushr

      Expr ushr(Expr a, Expr b)
      The bitwise unsigned-right-shift operator. The arguments must be of the same type kind. This method works equivalently to the >>> operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • ushr

      default Expr ushr(Expr a, int b)
      The bitwise unsigned-right-shift operator. This method works equivalently to the >>> operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • ushr

      default Expr ushr(Expr a, long b)
      The bitwise unsigned-right-shift operator. This method works equivalently to the >>> operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • add

      Expr add(Expr a, Expr b)
      The arithmetic addition operator. The arguments must be of the same type kind. This method works equivalently to the + operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • add

      default Expr add(Expr a, int b)
      The arithmetic addition operator. This method works equivalently to the + operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • add

      default Expr add(Expr a, long b)
      The arithmetic addition operator. This method works equivalently to the + operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • add

      default Expr add(Expr a, float b)
      The arithmetic addition operator. This method works equivalently to the + operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • add

      default Expr add(Expr a, double b)
      The arithmetic addition operator. This method works equivalently to the + operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • sub

      Expr sub(Expr a, Expr b)
      The arithmetic subtraction operator. The arguments must be of the same type kind. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(Expr a, int b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(Expr a, long b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(Expr a, float b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(Expr a, double b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(int a, Expr b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(long a, Expr b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(float a, Expr b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • sub

      default Expr sub(double a, Expr b)
      The arithmetic subtraction operator. This method works equivalently to the - operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • mul

      Expr mul(Expr a, Expr b)
      The arithmetic multiplication operator. The arguments must be of the same type kind. This method works equivalently to the * operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • mul

      default Expr mul(Expr a, int b)
      The arithmetic multiplication operator. This method works equivalently to the * operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • mul

      default Expr mul(Expr a, long b)
      The arithmetic multiplication operator. This method works equivalently to the * operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • mul

      default Expr mul(Expr a, float b)
      The arithmetic multiplication operator. This method works equivalently to the * operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • mul

      default Expr mul(Expr a, double b)
      The arithmetic multiplication operator. This method works equivalently to the * operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • div

      Expr div(Expr a, Expr b)
      The arithmetic division operator. The arguments must be of the same type kind. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • div

      default Expr div(Expr a, int b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • div

      default Expr div(Expr a, long b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • div

      default Expr div(Expr a, float b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • div

      default Expr div(Expr a, double b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • div

      default Expr div(int a, Expr b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • div

      default Expr div(long a, Expr b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • div

      default Expr div(float a, Expr b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • div

      default Expr div(double a, Expr b)
      The arithmetic division operator. This method works equivalently to the / operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • rem

      Expr rem(Expr a, Expr b)
      The arithmetic remainder operator. The arguments must be of the same type kind. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(Expr a, int b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(Expr a, long b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(Expr a, float b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(Expr a, double b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument (must not be null)
      b - the second argument
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(int a, Expr b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(long a, Expr b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(float a, Expr b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • rem

      default Expr rem(double a, Expr b)
      The arithmetic remainder operator. This method works equivalently to the % operator in Java.
      Parameters:
      a - the first argument
      b - the second argument (must not be null)
      Returns:
      the operation result (not null)
    • neg

      Expr neg(Expr a)
      The arithmetic negation operator. This method works equivalently to the - unary operator in Java.
      Parameters:
      a - the argument
      Returns:
      the operation result (must not be null)
    • addAssign

      void addAssign(Assignable var, Expr arg)
      Add the argument to the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • subAssign

      void subAssign(Assignable var, Expr arg)
      Subtract the argument from the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • mulAssign

      void mulAssign(Assignable var, Expr arg)
      Multiply the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • divAssign

      void divAssign(Assignable var, Expr arg)
      Divide the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • remAssign

      void remAssign(Assignable var, Expr arg)
      Divide the argument with the variable value and assign the remainder back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • andAssign

      void andAssign(Assignable var, Expr arg)
      Bitwise-AND the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • orAssign

      void orAssign(Assignable var, Expr arg)
      Bitwise-OR the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • xorAssign

      void xorAssign(Assignable var, Expr arg)
      Bitwise-XOR (exclusive OR) the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • shlAssign

      void shlAssign(Assignable var, Expr arg)
      Bitwise-left-shift the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • shrAssign

      void shrAssign(Assignable var, Expr arg)
      Arithmetically bitwise-right-shift the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • ushrAssign

      void ushrAssign(Assignable var, Expr arg)
      Logically bitwise-right-shift the argument with the variable value and assign it back.
      Parameters:
      var - the variable (must not be null)
      arg - the argument value (must not be null)
    • logicalNot

      default Expr logicalNot(Expr a)
      Returns an expression which is the logical (boolean) opposite of the input expression.
      Parameters:
      a - the input expression (must not be null)
      Returns:
      an expression which is the logical (boolean) opposite of the input expression
    • logicalOr

      default Expr logicalOr(Expr cond, Consumer<BlockCreator> other)
      Perform a short-circuiting logical-OR operation (the || operator).
      Parameters:
      cond - the condition to evaluate (must not be null)
      other - the expression to evaluate if cond is false
      Returns:
      the boolean result of the operation (not null)
    • logicalAnd

      default Expr logicalAnd(Expr cond, Consumer<BlockCreator> other)
      Perform a short-circuiting logical-AND operation (the && operator).
      Parameters:
      cond - the condition to evaluate (must not be null)
      other - the expression to evaluate if cond is true
      Returns:
      the boolean result of the operation (not null)
    • cond

      default Expr cond(Class<?> type, Expr cond, Consumer<BlockCreator> ifTrue, Consumer<BlockCreator> ifFalse)
      Evaluate a conditional expression (the ?: operator).
      Parameters:
      type - the result type (must not be null)
      cond - the boolean condition to evaluate (must not be null)
      ifTrue - the expression to yield if the value was true (must not be null)
      ifFalse - the expression to yield if the value was false (must not be null)
      Returns:
      the result value (must not be null)
    • cond

      Expr cond(ClassDesc type, Expr cond, Consumer<BlockCreator> ifTrue, Consumer<BlockCreator> ifFalse)
      Evaluate a conditional expression (the ?: operator).
      Parameters:
      type - the result type (must not be null)
      cond - the boolean condition to evaluate (must not be null)
      ifTrue - the expression to yield if the value was true (must not be null)
      ifFalse - the expression to yield if the value was false (must not be null)
      Returns:
      the result value (must not be null)
    • lambda

      default Expr lambda(Class<?> type, Consumer<LambdaCreator> builder)
      Construct a lambda instance with the given type.

      Note that all values used in the lambda but created outside of it, including this, must be captured using CapturingCreator.capture(String, Expr) or CapturingCreator.capture(Var).

      Parameters:
      type - the type of the lambda (must not be null)
      builder - the builder for the lambda body (must not be null)
      Returns:
      the lambda object (not null)
    • lambda

      default Expr lambda(MethodDesc sam, Consumer<LambdaCreator> builder)
      Construct a lambda instance with the given type.

      Note that all values used in the lambda but created outside of it, including this, must be captured using CapturingCreator.capture(String, Expr) or CapturingCreator.capture(Var).

      Parameters:
      sam - the descriptor of the single abstract method of the lambda (must not be null)
      builder - the builder for the lambda body (must not be null)
      Returns:
      the lambda object (not null)
    • lambda

      Expr lambda(MethodDesc sam, ClassDesc owner, Consumer<LambdaCreator> builder)
      Construct a lambda instance with the given type.

      Note that all values used in the lambda but created outside of it, including this, must be captured using CapturingCreator.capture(String, Expr) or CapturingCreator.capture(Var).

      Parameters:
      sam - the descriptor of the single abstract method of the lambda (must not be null)
      owner - the type of the final lambda (must not be null)
      builder - the builder for the lambda body (must not be null)
      Returns:
      the lambda object (not null)
    • newAnonymousClass

      Expr newAnonymousClass(ConstructorDesc superCtor, List<? extends Expr> args, Consumer<AnonymousClassCreator> builder)
      Create a new anonymous class instance. Unlike Java anonymous classes, the anonymous class definition created here may implement additional interfaces. The type of the returned instance is the anonymous class type.

      Note that all values used in the anonymous class but created outside of it, including this, must be captured using CapturingCreator.capture(String, Expr) or CapturingCreator.capture(Var).

      Parameters:
      superCtor - the superclass constructor to invoke (must not be null)
      args - the constructor arguments (must not be null)
      builder - the builder for the anonymous class (must not be null)
      Returns:
      the anonymous class instance (not null)
    • newAnonymousClass

      default Expr newAnonymousClass(ClassDesc interface_, Consumer<AnonymousClassCreator> builder)
      Create a new anonymous class instance which implements the given interface. The type of the returned instance is the anonymous class type.

      Note that all values used in the anonymous class but created outside of it, including this, must be captured using CapturingCreator.capture(String, Expr) or CapturingCreator.capture(Var).

      Parameters:
      interface_ - the interface to implement (must not be null)
      builder - the builder for the anonymous class (must not be null)
      Returns:
      the anonymous class instance (not null)
    • newAnonymousClass

      default Expr newAnonymousClass(Class<?> supertype, Consumer<AnonymousClassCreator> builder)
      Create a new anonymous class instance which extends the given class or implements the given interface. If the given supertype is a class, it has to have a zero-parameter constructor. The type of the returned instance is the anonymous class type.

      Note that all values used in the anonymous class but created outside of it, including this, must be captured using CapturingCreator.capture(String, Expr) or CapturingCreator.capture(Var).

      Parameters:
      supertype - the supertype to extend or implement (must not be null)
      builder - the builder for the anonymous class (must not be null)
      Returns:
      the anonymous class instance (not null)
    • cast

      Expr cast(Expr a, GenericType toType)
      Cast a value to the given type. For primitives, the appropriate conversion is applied. For objects, a class cast is performed.
      Parameters:
      a - the value to cast (must not be null)
      toType - the type to cast to (must not be null)
      Returns:
      the cast value (not null)
      See Also:
    • cast

      Expr cast(Expr a, ClassDesc toType)
      Cast a value to the given type. For primitives, the appropriate conversion is applied. For objects, a class cast is performed.
      Parameters:
      a - the value to cast (must not be null)
      toType - the type to cast to (must not be null)
      Returns:
      the cast value (not null)
      See Also:
    • cast

      default Expr cast(Expr a, Class<?> toType)
      Cast a value to the given type. For primitives, the appropriate conversion is applied. For objects, a class cast is performed.
      Parameters:
      a - the value to cast (must not be null)
      toType - the type to cast to (must not be null)
      Returns:
      the cast value (not null)
      See Also:
    • uncheckedCast

      Expr uncheckedCast(Expr a, GenericType toType)
      Cast an object value to the given type without a type check. If the cast is invalid, then class validation will fail.
      Parameters:
      a - the value to cast (must not be null)
      toType - the type to cast to (must not be null)
      Returns:
      the cast value (not null)
      See Also:
    • uncheckedCast

      Expr uncheckedCast(Expr a, ClassDesc toType)
      Cast an object value to the given type without a type check. If the cast is invalid, then class validation will fail.
      Parameters:
      a - the value to cast (must not be null)
      toType - the type to cast to (must not be null)
      Returns:
      the cast value (not null)
      See Also:
    • uncheckedCast

      default Expr uncheckedCast(Expr a, Class<?> toType)
      Cast an object value to the given type without a type check. If the cast is invalid, then class validation will fail.
      Parameters:
      a - the value to cast (must not be null)
      toType - the type to cast to (must not be null)
      Returns:
      the cast value (not null)
      See Also:
    • box

      Expr box(Expr a)
      Box the given primitive value into its corresponding box type.
      Parameters:
      a - the primitive value (must not be null)
      Returns:
      the boxed value (not null)
    • unbox

      Expr unbox(Expr a)
      Unbox the given boxed value into its corresponding primitive type.
      Parameters:
      a - the boxed value (must not be null)
      Returns:
      the primitive value (not null)
    • instanceOf

      default Expr instanceOf(Expr obj, Class<?> type)
      Test whether the given object implements the given type.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to test against (must not be null)
      Returns:
      the boolean result of the check (not null)
    • instanceOf

      Expr instanceOf(Expr obj, ClassDesc type)
      Test whether the given object implements the given type.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to test against (must not be null)
      Returns:
      the boolean result of the check (not null)
    • instanceOf

      Expr instanceOf(Expr obj, GenericType type)
      Test whether the given object implements the given type.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to test against (must not be null)
      Returns:
      the boolean result of the check (not null)
    • new_

      Expr new_(GenericType genericType, ConstructorDesc ctor, List<? extends Expr> args)
      Construct a new instance.
      Parameters:
      genericType - the generic type of the new object (must not be null)
      ctor - the constructor to call (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      Expr new_(ConstructorDesc ctor, List<? extends Expr> args)
      Construct a new instance.
      Parameters:
      ctor - the constructor to call (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ConstructorDesc ctor)
      Construct a new instance.
      Parameters:
      ctor - the constructor to call (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ConstructorDesc ctor, Expr arg0)
      Construct a new instance.
      Parameters:
      ctor - the constructor to call (must not be null)
      arg0 - the sole arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ConstructorDesc ctor, Expr arg0, Expr arg1)
      Construct a new instance.
      Parameters:
      ctor - the constructor to call (must not be null)
      arg0 - the first argument to pass to the constructor (must not be null)
      arg1 - the second argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ConstructorDesc ctor, Expr... args)
      Construct a new instance.
      Parameters:
      ctor - the constructor to call (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ClassDesc type, List<? extends Expr> args)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ClassDesc type)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ClassDesc type, Expr arg0)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      arg0 - the sole argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ClassDesc type, Expr arg0, Expr arg1)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      arg0 - the first argument to pass to the constructor (must not be null)
      arg1 - the second argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(ClassDesc type, Expr... args)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(GenericType type, List<? extends Expr> args)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(GenericType type)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(GenericType type, Expr arg0)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      arg0 - the sole argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(GenericType type, Expr arg0, Expr arg1)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      arg0 - the first argument to pass to the constructor (must not be null)
      arg1 - the second argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(GenericType type, Expr... args)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(Class<?> type, List<? extends Expr> args)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(Class<?> type)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(Class<?> type, Expr arg0)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      arg0 - the sole argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(Class<?> type, Expr arg0, Expr arg1)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      arg0 - the first argument to pass to the constructor (must not be null)
      arg1 - the second argument to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • new_

      default Expr new_(Class<?> type, Expr... args)
      Construct a new instance.
      Parameters:
      type - the type to construct (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the new object (not null)
    • invokeStatic

      Expr invokeStatic(GenericType genericReturnType, MethodDesc method, List<? extends Expr> args)
      Invoke a static method.
      Parameters:
      genericReturnType - the generic return type (must not be null)
      method - the method to call (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeStatic

      Expr invokeStatic(MethodDesc method, List<? extends Expr> args)
      Invoke a static method.
      Parameters:
      method - the method to call (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeStatic

      default Expr invokeStatic(MethodDesc method)
      Invoke a static method.
      Parameters:
      method - the method to call (must not be null)
      Returns:
      the method call result (not null)
    • invokeStatic

      default Expr invokeStatic(MethodDesc method, Expr arg0)
      Invoke a static method.
      Parameters:
      method - the method to call (must not be null)
      arg0 - the sole argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeStatic

      default Expr invokeStatic(MethodDesc method, Expr arg0, Expr arg1)
      Invoke a static method.
      Parameters:
      method - the method to call (must not be null)
      arg0 - the first argument to pass to the method (must not be null)
      arg1 - the second argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeStatic

      default Expr invokeStatic(MethodDesc method, Expr... args)
      Invoke a static method.
      Parameters:
      method - the method to call (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeVirtual

      Expr invokeVirtual(GenericType genericReturnType, MethodDesc method, Expr instance, List<? extends Expr> args)
      Invoke a virtual method.
      Parameters:
      genericReturnType - the generic return type (must not be null)
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeVirtual

      Expr invokeVirtual(MethodDesc method, Expr instance, List<? extends Expr> args)
      Invoke a virtual method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeVirtual

      default Expr invokeVirtual(MethodDesc method, Expr instance)
      Invoke a virtual method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      Returns:
      the method call result (not null)
    • invokeVirtual

      default Expr invokeVirtual(MethodDesc method, Expr instance, Expr arg0)
      Invoke a virtual method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the sole argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeVirtual

      default Expr invokeVirtual(MethodDesc method, Expr instance, Expr arg0, Expr arg1)
      Invoke a virtual method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the first argument to pass to the method (must not be null)
      arg1 - the second argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeVirtual

      default Expr invokeVirtual(MethodDesc method, Expr instance, Expr... args)
      Invoke a virtual method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      Expr invokeSpecial(GenericType genericReturnType, MethodDesc method, Expr instance, List<? extends Expr> args)
      Invoke a method using "special" semantics.
      Parameters:
      genericReturnType - the generic return type (must not be null)
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      Expr invokeSpecial(MethodDesc method, Expr instance, List<? extends Expr> args)
      Invoke a method using "special" semantics.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      default Expr invokeSpecial(MethodDesc method, Expr instance)
      Invoke a method using "special" semantics.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      default Expr invokeSpecial(MethodDesc method, Expr instance, Expr arg0)
      Invoke a method using "special" semantics.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the sole argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      default Expr invokeSpecial(MethodDesc method, Expr instance, Expr arg0, Expr arg1)
      Invoke a method using "special" semantics.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the first argument to pass to the method (must not be null)
      arg1 - the second argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      default Expr invokeSpecial(MethodDesc method, Expr instance, Expr... args)
      Invoke a method using "special" semantics.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeSpecial

      Expr invokeSpecial(ConstructorDesc ctor, Expr instance, List<? extends Expr> args)
      Invoke a constructor using "special" semantics.
      Parameters:
      ctor - the constructor to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the constructor call result (not null, usually Const.ofVoid())
    • invokeSpecial

      default Expr invokeSpecial(ConstructorDesc ctor, Expr instance)
      Invoke a constructor using "special" semantics.
      Parameters:
      ctor - the constructor to call (must not be null)
      instance - the invocation target (must not be null)
      Returns:
      the constructor call result (not null, usually Const.ofVoid())
    • invokeSpecial

      default Expr invokeSpecial(ConstructorDesc ctor, Expr instance, Expr arg0)
      Invoke a constructor using "special" semantics.
      Parameters:
      ctor - the constructor to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the sole argument to pass to the constructor (must not be null)
      Returns:
      the constructor call result (not null, usually Const.ofVoid())
    • invokeSpecial

      default Expr invokeSpecial(ConstructorDesc ctor, Expr instance, Expr arg0, Expr arg1)
      Invoke a constructor using "special" semantics.
      Parameters:
      ctor - the constructor to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the first argument to pass to the constructor (must not be null)
      arg1 - the second argument to pass to the constructor (must not be null)
      Returns:
      the constructor call result (not null, usually Const.ofVoid())
    • invokeSpecial

      default Expr invokeSpecial(ConstructorDesc ctor, Expr instance, Expr... args)
      Invoke a constructor using "special" semantics.
      Parameters:
      ctor - the constructor to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the constructor (must not be null)
      Returns:
      the constructor call result (not null, usually Const.ofVoid())
    • invokeInterface

      Expr invokeInterface(GenericType genericReturnType, MethodDesc method, Expr instance, List<? extends Expr> args)
      Invoke an interface method.
      Parameters:
      genericReturnType - the generic return type (must not be null)
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeInterface

      Expr invokeInterface(MethodDesc method, Expr instance, List<? extends Expr> args)
      Invoke an interface method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeInterface

      default Expr invokeInterface(MethodDesc method, Expr instance)
      Invoke an interface method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      Returns:
      the method call result (not null)
    • invokeInterface

      default Expr invokeInterface(MethodDesc method, Expr instance, Expr arg0)
      Invoke an interface method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the sole argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeInterface

      default Expr invokeInterface(MethodDesc method, Expr instance, Expr arg0, Expr arg1)
      Invoke an interface method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      arg0 - the first argument to pass to the method (must not be null)
      arg1 - the second argument to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeInterface

      default Expr invokeInterface(MethodDesc method, Expr instance, Expr... args)
      Invoke an interface method.
      Parameters:
      method - the method to call (must not be null)
      instance - the invocation target (must not be null)
      args - the arguments to pass to the method (must not be null)
      Returns:
      the method call result (not null)
    • invokeDynamic

      Expr invokeDynamic(DynamicCallSiteDesc callSiteDesc, List<? extends Expr> args)
    • invokeDynamic

      default Expr invokeDynamic(DynamicCallSiteDesc callSiteDesc, Expr... args)
    • forEach

      void forEach(Expr items, BiConsumer<BlockCreator,? super LocalVar> builder)
      Build a for-each loop over an array or collection.
      Parameters:
      items - the array or collection (must not be null)
      builder - the builder for the loop body (must not be null)
    • block

      void block(Consumer<BlockCreator> nested)
      Create a nested block.
      Parameters:
      nested - the builder for the block body (must not be null)
    • blockExpr

      Expr blockExpr(ClassDesc type, Consumer<BlockCreator> nested)
      Create a block expression of given type. The block must yield(Expr) its result.
      Parameters:
      type - the output type (must not be null)
      nested - the builder for the block body (must not be null)
      Returns:
      the returned value (not null)
    • blockExpr

      default Expr blockExpr(Class<?> type, Consumer<BlockCreator> nested)
      Create a block expression of given type. The block must yield(Expr) its result.
      Parameters:
      type - the output type (must not be null)
      nested - the builder for the block body (must not be null)
      Returns:
      the returned value (not null)
    • ifInstanceOf

      default void ifInstanceOf(Expr obj, Class<?> type, BiConsumer<BlockCreator,? super LocalVar> ifTrue)
      If the given object is an instance of the given type, then execute the block with the narrowed object.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to check for (must not be null)
      ifTrue - the builder for a block to run if the type was successfully narrowed (must not be null)
    • ifInstanceOf

      void ifInstanceOf(Expr obj, ClassDesc type, BiConsumer<BlockCreator,? super LocalVar> ifTrue)
      If the given object is an instance of the given type, then execute the block with the narrowed object.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to check for (must not be null)
      ifTrue - the builder for a block to run if the type was successfully narrowed (must not be null)
    • ifNotInstanceOf

      default void ifNotInstanceOf(Expr obj, Class<?> type, Consumer<BlockCreator> ifFalse)
      If the given object is not an instance of the given type, then execute the given block.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to check for (must not be null)
      ifFalse - the builder for a block to run if the type did not match (must not be null)
    • ifNotInstanceOf

      void ifNotInstanceOf(Expr obj, ClassDesc type, Consumer<BlockCreator> ifFalse)
      If the given object is not an instance of the given type, then execute the given block.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to check for (must not be null)
      ifFalse - the builder for a block to run if the type did not match (must not be null)
    • ifInstanceOfElse

      default void ifInstanceOfElse(Expr obj, Class<?> type, BiConsumer<BlockCreator,? super LocalVar> ifTrue, Consumer<BlockCreator> ifFalse)
      If the given object is an instance of the given type, then execute the first block with the narrowed object, otherwise execute the other block.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to check for (must not be null)
      ifTrue - the builder for a block to run if the type was successfully narrowed (must not be null)
      ifFalse - the builder for a block to run if the type did not match (must not be null)
    • ifInstanceOfElse

      void ifInstanceOfElse(Expr obj, ClassDesc type, BiConsumer<BlockCreator,? super LocalVar> ifTrue, Consumer<BlockCreator> ifFalse)
      If the given object is an instance of the given type, then execute the first block with the narrowed object, otherwise execute the other block.
      Parameters:
      obj - the object to test (must not be null)
      type - the type to check for (must not be null)
      ifTrue - the builder for a block to run if the type was successfully narrowed (must not be null)
      ifFalse - the builder for a block to run if the type did not match (must not be null)
    • if_

      void if_(Expr cond, Consumer<BlockCreator> whenTrue)
      A general if conditional.
      Parameters:
      cond - the boolean condition expression (must not be null)
      whenTrue - the builder for a block to execute if the condition is true (must not be null)
    • ifNot

      void ifNot(Expr cond, Consumer<BlockCreator> whenFalse)
      An inverted if conditional.
      Parameters:
      cond - the boolean condition expression (must not be null)
      whenFalse - the builder for a block to execute if the condition is false (must not be null)
    • ifElse

      void ifElse(Expr cond, Consumer<BlockCreator> whenTrue, Consumer<BlockCreator> whenFalse)
      A general if-else conditional.
      Parameters:
      cond - the boolean condition expression (must not be null)
      whenTrue - the builder for a block to execute if the condition is true (must not be null)
      whenFalse - the builder for a block to execute if the condition is false (must not be null)
    • ifNull

      default void ifNull(Expr obj, Consumer<BlockCreator> whenTrue)
      An if (obj == null) conditional.
      Parameters:
      obj - the object reference to test (must not be null)
      whenTrue - the builder for a block to execute if the object reference is null (must not be null)
    • ifNotNull

      default void ifNotNull(Expr obj, Consumer<BlockCreator> whenTrue)
      An if (obj != null) conditional.
      Parameters:
      obj - the object reference to test (must not be null)
      whenTrue - the builder for a block to execute if the object reference is not null (must not be null)
    • switchEnum

      default void switchEnum(Expr val, Consumer<SwitchCreator> builder)
      Construct a switch statement for enum constants.
      Parameters:
      val - the value to switch on (must not be null)
      builder - the builder for the switch statement (must not be null)
    • switchEnum

      Expr switchEnum(ClassDesc outputType, Expr val, Consumer<SwitchCreator> builder)
      Construct a switch expression for enum constants.
      Parameters:
      outputType - the output type of this switch (must not be null)
      val - the value to switch on (must not be null)
      builder - the builder for the switch statement (must not be null)
      Returns:
      the switch expression result (not null)
    • switchEnum

      default Expr switchEnum(Class<?> outputType, Expr val, Consumer<SwitchCreator> builder)
      Construct a switch expression for enum constants.
      Parameters:
      outputType - the output type of this switch (must not be null)
      val - the value to switch on (must not be null)
      builder - the builder for the switch statement (must not be null)
      Returns:
      the switch expression result (not null)
    • switch_

      default void switch_(Expr val, Consumer<SwitchCreator> builder)
      Construct a switch statement. The type of the switch value must be of one of these supported types:
      • int (which includes byte, char, short, and boolean)
      • long
      • java.lang.String
      • java.lang.Class
      The type of the switch creator depends on the type of the value. For enum switches, use switchEnum(Expr, Consumer).
      Parameters:
      val - the value to switch on (must not be null)
      builder - the builder for the switch statement (must not be null)
    • switch_

      Expr switch_(ClassDesc outputType, Expr val, Consumer<SwitchCreator> builder)
      Construct a switch expression. The type of the switch value must be of one of these supported types:
      • int (which includes byte, char, short, and boolean)
      • long
      • java.lang.String
      • java.lang.Class
      The type of the switch creator depends on the type of the value. For enum switches, use switchEnum(Expr, Consumer).
      Parameters:
      outputType - the output type of this switch (must not be null)
      val - the value to switch on (must not be null)
      builder - the builder for the switch statement (must not be null)
      Returns:
      the switch expression result (not null)
    • switch_

      default Expr switch_(Class<?> outputType, Expr val, Consumer<SwitchCreator> builder)
      Construct a switch expression. The type of the switch value must be of one of these supported types:
      • int (which includes byte, char, short, and boolean)
      • long
      • java.lang.String
      • java.lang.Class
      The type of the switch creator depends on the type of the value. For enum switches, use switchEnum(Expr, Consumer).
      Parameters:
      outputType - the output type of this switch (must not be null)
      val - the value to switch on (must not be null)
      builder - the builder for the switch statement (must not be null)
      Returns:
      the switch expression result (not null)
    • break_

      void break_(BlockCreator outer)
      Exit the given enclosing block. Blocks that have a non-void type may not be the target of a break.
      Parameters:
      outer - the block to break (must not be null)
    • continue_

      void continue_(BlockCreator loop)
      Resume the next iteration of an enclosing loop. A block creator is a loop if it was created using one of: To repeat an iteration, see goto_(BlockCreator).
      Parameters:
      loop - the loop to continue (must not be null)
      Throws:
      IllegalArgumentException - if the given block creator does not correspond to a loop
    • goto_

      void goto_(BlockCreator outer)
      Jump to the start of the given enclosing block. Blocks which are part of an expression-accepting operation may not be the target of goto_.
      Parameters:
      outer - the block to restart (must not be null)
    • gotoStart

      default void gotoStart()
      Jump to the start of this block.
    • gotoCase

      void gotoCase(SwitchCreator switch_, Const case_)
      Jump to a specific case in the given enclosing switch. If the case is not represented in the switch, then it will be as if gotoDefault(SwitchCreator) was called instead.
      Parameters:
      switch_ - the enclosing switch (must not be null)
      case_ - the constant representing the case to go to (must not be null)
    • gotoCase

      default void gotoCase(SwitchCreator switch_, int case_)
      Jump to a specific case in the given enclosing switch. If the case is not represented in the switch, then it will be as if gotoDefault(SwitchCreator) was called instead.
      Parameters:
      switch_ - the enclosing switch (must not be null)
      case_ - the constant representing the case to go to (must not be null)
    • gotoCase

      default void gotoCase(SwitchCreator switch_, String case_)
      Jump to a specific case in the given enclosing switch. If the case is not represented in the switch, then it will be as if gotoDefault(SwitchCreator) was called instead.
      Parameters:
      switch_ - the enclosing switch (must not be null)
      case_ - the constant representing the case to go to (must not be null)
    • gotoCase

      default void gotoCase(SwitchCreator switch_, Enum<?> case_)
      Jump to a specific case in the given enclosing switch. If the case is not represented in the switch, then it will be as if gotoDefault(SwitchCreator) was called instead.
      Parameters:
      switch_ - the enclosing switch (must not be null)
      case_ - the constant representing the case to go to (must not be null)
    • gotoCase

      default void gotoCase(SwitchCreator switch_, Class<?> case_)
      Jump to a specific case in the given enclosing switch. If the case is not represented in the switch, then it will be as if gotoDefault(SwitchCreator) was called instead.
      Parameters:
      switch_ - the enclosing switch (must not be null)
      case_ - the constant representing the case to go to (must not be null)
    • gotoDefault

      void gotoDefault(SwitchCreator switch_)
      Jump to the default case in the given enclosing switch.
      Parameters:
      switch_ - the enclosing switch (must not be null)
    • loop

      void loop(Consumer<BlockCreator> body)
      Enter a loop. The loop may be exited by calling break_(BlockCreator) on the loop's block.
      Parameters:
      body - the loop body (must not be null)
    • while_

      void while_(Consumer<BlockCreator> cond, Consumer<BlockCreator> body)
      Enter a while loop. The loop may be exited early by calling break_(BlockCreator) on the loop's block.
      Parameters:
      cond - the condition which is evaluated at the top of the block (must not be null)
      body - the loop body (must not be null)
    • doWhile

      void doWhile(Consumer<BlockCreator> body, Consumer<BlockCreator> cond)
      Enter a do-while loop. The loop may be exited early by calling break_(BlockCreator) on the loop's block.
      Parameters:
      body - the loop body (must not be null)
      cond - the condition which is evaluated at the bottom of the block (must not be null)
    • try_

      void try_(Consumer<TryCreator> body)
      Enter a try block.
      Parameters:
      body - the handler to produce the try, catch, and/or finally sections
    • autoClose

      void autoClose(Expr resource, BiConsumer<BlockCreator,? super LocalVar> body)
      Open a resource and run the given body with the resource, automatically closing it at the end.
      Parameters:
      resource - the resource to automatically close (must not be null)
      body - the creator for the body of the resource operation (must not be null)
    • autoClose

      void autoClose(Var resource, Consumer<BlockCreator> body)
      Open a resource and run the given body with the resource, automatically closing it at the end.
      Parameters:
      resource - the resource to automatically close (must not be null)
      body - the creator for the body of the resource operation (must not be null)
    • synchronized_

      void synchronized_(Expr monitor, Consumer<BlockCreator> body)
      Create a synchronized block. When the given body is executed, the monitor of given monitor is locked.
      Parameters:
      monitor - the expression of the object whose monitor is to be locked (must not be null)
      body - the creator for the body of the block (must not be null)
    • locked

      void locked(Expr jucLock, Consumer<BlockCreator> body)
      Create a block which holds a Lock. When the given body is executed, the given lock is held.
      Parameters:
      jucLock - the expression of the lock object to be locked (must not be null)
      body - the creator for the body of the block (must not be null)
    • return_

      void return_()
      Return from the current method.
    • return_

      void return_(Expr val)
      Return from the current method.
      Parameters:
      val - the return value (must not be null)
    • return_

      default void return_(String val)
      Return from the current method.
      Parameters:
      val - the return value (must not be null)
    • return_

      default void return_(Class<?> val)
      Return from the current method.
      Parameters:
      val - the return value (must not be null)
    • return_

      default void return_(boolean val)
      Return from the current method.
      Parameters:
      val - the return value
    • return_

      default void return_(int val)
      Return from the current method.
      Parameters:
      val - the return value
    • returnTrue

      default void returnTrue()
      Return true from the current method.
    • returnFalse

      default void returnFalse()
      Return false from the current method.
    • returnIntZero

      default void returnIntZero()
      Return 0 from the current method.
    • returnNull

      void returnNull()
      Return null from the current method.
    • throw_

      void throw_(Expr val)
      Throw the given exception object.
      Parameters:
      val - the exception object (must not be null)
    • throw_

      default void throw_(ClassDesc type)
      Throw a new exception of the given type.
      Parameters:
      type - the exception type (must not be null)
    • throw_

      default void throw_(ClassDesc type, String message)
      Throw a new exception of the given type with a message.
      Parameters:
      type - the exception type (must not be null)
      message - the message (must not be null)
    • throw_

      default void throw_(ClassDesc type, Expr message)
      Throw a new exception of the given type with a message.
      Parameters:
      type - the exception type (must not be null)
      message - the message (must not be null)
    • throw_

      default void throw_(Class<? extends Throwable> type)
      Throw a new exception of the given type.
      Parameters:
      type - the exception type (must not be null)
    • throw_

      default void throw_(Class<? extends Throwable> type, String message)
      Throw a new exception of the given type with a message.
      Parameters:
      type - the exception type (must not be null)
      message - the message
    • throw_

      default void throw_(Class<? extends Throwable> type, Expr message)
      Throw a new exception of the given type with a message.
      Parameters:
      type - the exception type (must not be null)
      message - the message
    • exprHashCode

      Expr exprHashCode(Expr expr)
      Generates call to one of the static methods to compute a hash code of given expression. That is:
      • for reference types, Objects.hashCode(expr)
      • for primitive types, the static hashCode(expr) method on the corresponding wrapper class
      Parameters:
      expr - the expression, which can be of any type (must not be null)
      Returns:
      an int expression representing the hash code of given expression (not null)
    • objHashCode

      @Deprecated default Expr objHashCode(Expr expr)
      Deprecated.
      use exprHashCode(Expr) instead.
      Parameters:
      expr - the expression, which can be of any type (must not be null)
      Returns:
      an int expression representing the hash code of given expression (not null)
    • exprEquals

      Expr exprEquals(Expr a, Expr b)
      Generates call to the Objects#equals(a, b) method if at least one of the given expressions is of a reference type (boxing the other if primitive). If both expressions are of a primitive type, this is equivalent to eq(Expr, Expr).
      Parameters:
      a - the first expression (must not be null)
      b - the second expression (must not be null)
      Returns:
      a boolean expression representing the equality between the two values (not null)
    • objEquals

      @Deprecated default Expr objEquals(Expr a, Expr b)
      Deprecated.
      Parameters:
      a - the first expression (must not be null)
      b - the second expression (must not be null)
      Returns:
      a boolean expression representing the equality between the two values (not null)
    • exprToString

      Expr exprToString(Expr expr)
      Generates call to one of the String#valueOf(expr) overloads, based on the type of the argument.
      Parameters:
      expr - the expression, which can be of any type
      Returns:
      a String expression representing the string value of given expression (not null)
    • objToString

      @Deprecated default Expr objToString(Expr expr)
      Deprecated.
      use exprToString(Expr) instead.
      Parameters:
      expr - the expression, which can be of any type
      Returns:
      a String expression representing the string value of given expression (not null)
    • arrayHashCode

      Expr arrayHashCode(Expr expr)
      Generates call to one of the Arrays#hashCode(expr) overloads, based on the type of the argument, or to Arrays#deepHashCode(expr) in case of multidimensional arrays.
      Parameters:
      expr - the array instance (must not be null)
      Returns:
      an int expression representing the hash code of given array (not null)
    • arrayEquals

      Expr arrayEquals(Expr a, Expr b)
      Generates call to one of the Arrays#equals(a, b) overloads, based on the type of the first argument, or to Arrays#deepEquals(a, b) in case of multidimensional arrays.
      Parameters:
      a - the first array instance (must not be null)
      b - the second array instance (must not be null)
      Returns:
      a boolean expression representing the equality between the two arrays (not null)
    • arrayToString

      Expr arrayToString(Expr expr)
      Generates call to one of the Arrays#toString(expr) overloads, based on the type of the argument, or to Arrays#deepToString(expr) in case of multidimensional arrays.
      Parameters:
      expr - the array instance (must not be null)
      Returns:
      a String expression representing the string value of given array (not null)
    • withObject

      default ObjectOps withObject(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Object. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Object
    • withClass

      default ClassOps withClass(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Class. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Class
    • withString

      default StringOps withString(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of String. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of String
    • withCollection

      default CollectionOps withCollection(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Collection. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Collection
    • withList

      default ListOps withList(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of List. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of List
    • withSet

      default SetOps withSet(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Set. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Set
    • withMap

      default MapOps withMap(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Map. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Map
    • withIterator

      default IteratorOps withIterator(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Iterator. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Iterator
    • withOptional

      default OptionalOps withOptional(Expr receiver)
      Returns a convenience wrapper for accessing instance methods of Optional. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      receiver - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Optional
    • withThrowable

      default ThrowableOps withThrowable(Expr throwable)
      Returns a convenience wrapper for accessing instance methods of Throwable. Note that the returned instance must not be reused; only a single method may be called on it.
      Parameters:
      throwable - the instance to invoke upon (must not be null)
      Returns:
      a convenience wrapper for accessing instance methods of Throwable
    • classForName

      Expr classForName(Expr className)
      Generate a call to Class.forName(String) which uses the defining class loader of this class.
      Parameters:
      className - the class name (must not be null)
      Returns:
      the loaded class expression (not null)
    • listOf

      <T> Expr listOf(List<T> items, Function<T,? extends Expr> mapper)
      Generate a call to List.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the items to add to the list after mapping (must not be null)
      mapper - function that turns values of type T into expressions (must not be null and must not produce null)
      Returns:
      the list expression (not null)
      See Also:
    • listOf

      default Expr listOf(List<? extends Expr> items)
      Generate a call to List.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the items to add to the list (must not be null)
      Returns:
      the list expression (not null)
      See Also:
    • listOf

      default Expr listOf(Expr... items)
      Generate a call to List.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the items to add to the list (must not be null)
      Returns:
      the list expression (not null)
      See Also:
    • setOf

      <T> Expr setOf(List<T> items, Function<T,? extends Expr> mapper)
      Generate a call to Set.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the items to add to the set after mapping (must not be null)
      mapper - function that turns values of type T into expressions (must not be null and must not produce null)
      Returns:
      the list expression (not null)
      See Also:
    • setOf

      default Expr setOf(List<? extends Expr> items)
      Generate a call to Set.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the items to add to the list (must not be null)
      Returns:
      the set expression (not null)
      See Also:
    • setOf

      default Expr setOf(Expr... items)
      Generate a call to Set.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the items to add to the set (must not be null)
      Returns:
      the set expression (not null)
      See Also:
    • mapOf

      Expr mapOf(List<? extends Expr> items)
      Generate a call to Map.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the keys and values from which the map is populated
      Returns:
      map expression (not null)
      See Also:
    • mapOf

      default Expr mapOf(Expr... items)
      Generate a call to Map.of() or one of its variants, based on the number of arguments.
      Parameters:
      items - the keys and values from which the map is populated
      Returns:
      map expression (not null)
      See Also:
    • mapEntry

      Expr mapEntry(Expr key, Expr value)
      Generate a call to Map.entry(Object, Object).
      Parameters:
      key - the key for the new entry (must not be null)
      value - the value for the new entry (must not be null)
      Returns:
      the new map entry (not null)
    • optionalOf

      Expr optionalOf(Expr value)
      Generate a call to Optional.of(Object).
      Parameters:
      value - the expression to pass in to the call (must not be null)
      Returns:
      optional expression (not null)
      See Also:
    • optionalOfNullable

      Expr optionalOfNullable(Expr value)
      Generate a call to Optional.ofNullable(Object).
      Parameters:
      value - the expression to pass in to the call (must not be null)
      Returns:
      optional expression (not null)
      See Also:
    • optionalEmpty

      Expr optionalEmpty()
      Generate a call to Optional.empty().
      Returns:
      the empty optional expression (not null)
    • iterate

      Expr iterate(Expr items)
      Iterate the given target. In other words, generate a call to Iterable.iterator().
      Parameters:
      items - the iterable object expression (must not be null)
      Returns:
      the iterator expression (not null)
    • currentThread

      Expr currentThread()
      Returns an expression representing the current thread from the perspective of the running method body.
      Returns:
      an expression representing the current thread from the perspective of the running method body
    • close

      void close(Expr closeable)
      Close the given target.
      Parameters:
      closeable - the closeable object (must not be null)
    • line

      void line(int lineNumber)
      Change the current line number from this point.
      Parameters:
      lineNumber - the line number
    • printf

      void printf(String format, List<? extends Expr> values)
      Insert a printf statement.
      Parameters:
      format - the format string (must not be null)
      values - the value expression(s) (must not be null)
    • printf

      default void printf(String format, Expr... values)
      Insert a printf statement.
      Parameters:
      format - the format string (must not be null)
      values - the value expression(s) (must not be null)
    • assert_

      void assert_(Consumer<BlockCreator> assertion, String message)
      Produce an assertion.
      Parameters:
      assertion - the assertion expression maker (must not be null)
      message - the message to print if the assertion fails (must not be null)