Class SpreadBlock

java.lang.Object
com.cloudbees.groovy.cps.impl.SpreadBlock
All Implemented Interfaces:
Block, Serializable

public class SpreadBlock extends Object implements Block
Handles SpreadExpression similarly to the way that SpreadMapBlock handles SpreadMapExpression, but with a groovy-cps-specific SpreadBlock.SpreadList marker class.

We use a marker class because we cannot easily mimic the way that Groovy normally handles SpreadExpression. To do so, we would need modifications to CpsTransformer for list and argument list visitors akin to AsmClassGenerator.despreadList, a new implementation of Block that would fix those expressions and then call ScriptBytecodeAdapter.despreadList(java.lang.Object[], java.lang.Object[], int[]), and a variant of FunctionCallBlock that takes a single Block which is expected to evaluate to Object[] (rather than a Block[]) so that the result of despreadList can be used directly as the arguments array for the function call.

See Also:
  • Constructor Details

  • Method Details

    • eval

      public Next eval(Env e, Continuation k)
      Description copied from interface: Block
      Executes this expression, then pass the result to the given continuation when it's available.

      To be more precise, this method does not evaluate the expression by itself synchronously. Instead, the evaluation is done by the caller by repeatedly step executing the resulting Next object.

      Specified by:
      eval in interface Block
    • despreadList

      public static Object[] despreadList(Object[] list)