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

40
LINES

< > BotCompany Repo | #1033160 // CompressionRegime_JavaXEval_AnyType

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

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

sclass CompressionRegime_JavaXEval_AnyType implements CompressionRegime_AnyType<IJavaExpr> {
  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 #1033082

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033160
Snippet name: CompressionRegime_JavaXEval_AnyType
Eternal ID of this version: #1033160/19
Text MD5: 134041a8558de88184ab3ed0273c11b8
Transpilation MD5: c85a58548252bc4bfc4754513785148c
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 01:02:30
Source code size: 1030 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 222 / 391
Version history: 18 change(s)
Referenced in: [show references]