@@ -566,33 +566,17 @@ private static TypeSpec buildTopClass(OpsSpec spec) {
566
566
.addJavadoc ("Returns an API that builds init operations.\n " + initScopeComment )
567
567
.build ());
568
568
569
+ TypeVariableName T = TypeVariableName .get ("T" ).withBounds (Names .Operand );
569
570
opsBuilder .addMethod (
570
- MethodSpec .methodBuilder ("withInitScope " )
571
- .addTypeVariable (TypeVariableName . get ( "R" ) )
571
+ MethodSpec .methodBuilder ("liftToInitScope " )
572
+ .addTypeVariable (T )
572
573
.addModifiers (Modifier .PUBLIC )
573
- .addParameter (
574
- ParameterizedTypeName .get (
575
- ClassName .get (Function .class ), Names .Ops , TypeVariableName .get ("R" )),
576
- "block" )
577
- .returns (TypeVariableName .get ("R" ))
578
- .addStatement ("return block.apply(initScope())" )
579
- .addJavadoc (
580
- "Call {@code block} with an init scope.\n "
581
- + initScopeComment
582
- + "\n @see #initScope()" )
583
- .build ());
584
-
585
- opsBuilder .addMethod (
586
- MethodSpec .methodBuilder ("withInitScope" )
587
- .addModifiers (Modifier .PUBLIC )
588
- .addParameter (
589
- ParameterizedTypeName .get (ClassName .get (Consumer .class ), Names .Ops ), "block" )
590
- .returns (TypeName .VOID )
591
- .addStatement ("block.accept(initScope())" )
592
- .addJavadoc (
593
- "Call {@code block} with an init scope.\n "
594
- + initScopeComment
595
- + "\n @see #initScope()" )
574
+ .addParameter (T , "op" )
575
+ .returns (T )
576
+ .addStatement ("scope.env().registerInitOp(op.op())" )
577
+ .addStatement ("return op" )
578
+ .addJavadoc ("Make {@code op} an init operation, doing the same for all of it's inputs (and control inputs).\n " + initScopeComment +
579
+ "\n @throws IllegalArgumentException if the op or one of its inputs can't be made an init op." )
596
580
.build ());
597
581
598
582
opsBuilder .addMethod (
0 commit comments