package p.studio.app.animation; import java.nio.file.*; import p.animation.*; import p.studio.api.assets.animation.AnimationService; import p.studio.compiler.models.BuilderPipelineContext; import p.studio.compiler.messages.BuilderPipelineConfig; import p.studio.compiler.workspaces.BuilderPipelineService; import p.studio.compiler.backend.bytecode.BytecodeEmitter; import p.studio.utilities.logs.LogAggregator; /** Runs only with installed product JARs, outside the checkout. No runtime checkout is read. */ public final class AnimationInstalledProbe { public static void verify(Path root,Path corpus)throws Exception{ var f=new AnimationProjectFixture();f.root=root;f.setup(); try{ f.manual.execute(AnimationService.Request.save(f.project,f.uuid,null,f.document())); Files.writeString(root.resolve("src/mod.barrel"),"pub fn frame()->void;pub fn animationProbe()->int;"); Files.writeString(root.resolve("src/main.pbs"),"import { create_hero } from @app:generated/animations/b_"+f.uuid.toString().replace("-","")+";\n"+""" import { AnimationError } from @core:animation; declare global trace:int=0; fn run()->result { let value=create_hero(3)!;let other=create_hero(3)!; value.play("idle")!;value.advance(2)!; if value.sprite().glyph_id!=1 || other.sprite().glyph_id!=0 {let fail=1/0;} trace=42;return ok(()); } [Frame]fn frame()->void {run();} fn animationProbe()->int {return trace;} """); var context=BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false,root.toString()));context.glyphBankLayoutSource=f.layouts; var result=BuilderPipelineService.INSTANCE.compile(context,LogAggregator.stdout()); if(result.diagnostics().stream().anyMatch(d->d.isError()))throw new AssertionError(result.diagnostics()); Files.createDirectories(corpus); for(boolean optimized:new boolean[]{false,true}){ var program=optimized?context.optimizedIrvm:context.irvm; var module=new BytecodeEmitter().emit(program.coherentEmissionPlan()); String prefix="pbs-animation-installed"+(optimized?"-optimized":"");Files.write(corpus.resolve(prefix+".pbx"),module.serialize()); for(int i=0;i