Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1033361 // JECompressionRegime

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (14743L/93K).

sclass JECompressionRegime<Data> is CompressionRegime_AnyType<IJavaExpr<Data>> {
  settable bool quickEval = true;
  settable bool fullEval = false;
  
  byte[] metaCompress(byte[] c) {
    //ret gzipBytes(c);
    ret c;
  }
  
  public byte[] decompressorToBytes(IJavaExpr decompressor) {
    ret metaCompress(toUtf8(str(decompressor)));
  }
  
  public IJavaExpr decompressorFromBytes(byte[] compressed) {
    print("decompressorFromBytes");
    ret javaExpr(fromUtf8(gunzipBytes(compressed)));
  }
  
  public O runDecompressor(IJavaExpr code) {
    if (code == null) null;
    
    if (quickEval) try {
      ret code.quickEval();
    } catch e {
      if (!fullEval)
        rethrow(e);
      else
        printStackTrace(e);
    }
      
    if (fullEval) {
      print("*** FULL JAVA EVAL ***");
      ret dm_javaEval(str(code));
    }
    
    fail("No way to eval " + shorten(100, sfu(code)));
  }
  
  public swappable CompressionRegime_AnyType fullRegime() { null; }
}

Author comment

Began life as a copy of #1033160

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033361
Snippet name: JECompressionRegime
Eternal ID of this version: #1033361/4
Text MD5: 866fd5827648ee7c798651e3c010dcce
Transpilation MD5: 8d08838bb5bde6929c199fc13eab8f79
Author: stefan
Category: javax / recognition by compression
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-25 02:41:39
Source code size: 1018 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 203 / 304
Version history: 3 change(s)
Referenced in: [show references]