Transpiled version (40577L) is out of date.
// script that recognizes images or performs some kind of analysis on an image concept G22Analyzer > G22LeftArrowScript { new Ref<G22GalleryImage> exampleImage; @Override GazelleV_LeftArrowScriptParser makeParser() { var parser = super.makeParser(); parser.addVar("image", BufferedImage.class, false); parser.addVar("imageStream", SourceTriggeredStream.class, false); parser.addVar("context", G22AnalysisContext.class, false); ret parser; } class CompiledAnalyzer > LASCompileResult { settable double timeout = 10; G22AnalysisContext createAnalysisContext(BufferedImage image) { ret new G22AnalysisContext(g22utils(), image); } // evaluate directly without registration or timeout O get_impl(G22AnalysisContext context) { new FlexibleVarContext ctx; ctx.set(image := context.image); ctx.set(imageStream := context.imageStream); ctx.set(+context); ret parsedScript.get(ctx); } O get_impl(BufferedImage image) { ret get_impl(createAnalysisContext(image)); } O get(BufferedImage image) { ret get(createAnalysisContext(image)); } O get(G22AnalysisContext context) { if (context.analyzerResults.containsKey(analyzer())) { O value = context.analyzerResults.get(analyzer()); if (value == G22AnalysisContext.calculating) fail("Recursive call to analyzer " + this); ret ((OKOrError) value).getMandatory(); } context.analyzerResults.put(analyzer(), G22AnalysisContext.calculating); var result = okOrError(-> { if (parsedScript == null) rethrow(compileError); if (context.image == null && context.imageStream == null) fail("Need image or imageStream"); ret g22utils().evalRegisteredCode(timeout, str(G22Analyzer.this), -> get_impl(context)); }); context.analyzerResults.put(analyzer(), result); ret result.getMandatory(); } } selfType analyzer() { this; } LASCompileResult newCompileResult() { ret new CompiledAnalyzer; } CompiledAnalyzer compileForAutoRun() { ret (CompiledAnalyzer) super.compileForAutoRun(); } }
Began life as a copy of #1034256
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034598 |
Snippet name: | G22Analyzer - special left-arrow script for image analyzers |
Eternal ID of this version: | #1034598/13 |
Text MD5: | 83830137829080497bf5bbc0b2e8af2e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-02 19:12:35 |
Source code size: | 2289 bytes / 67 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 178 / 356 |
Version history: | 12 change(s) |
Referenced in: | [show references] |