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).

1  
sclass CompressionRegime_JavaXEval_AnyType implements CompressionRegime_AnyType<IJavaExpr> {
2  
  settable bool quickEval = true;
3  
  settable bool fullEval = false;
4  
  
5  
  byte[] metaCompress(byte[] c) {
6  
    //ret gzipBytes(c);
7  
    ret c;
8  
  }
9  
  
10  
  public byte[] decompressorToBytes(IJavaExpr decompressor) {
11  
    ret metaCompress(toUtf8(str(decompressor)));
12  
  }
13  
  
14  
  public IJavaExpr decompressorFromBytes(byte[] compressed) {
15  
    print("decompressorFromBytes");
16  
    ret javaExpr(fromUtf8(gunzipBytes(compressed)));
17  
  }
18  
  
19  
  public O runDecompressor(IJavaExpr code) {
20  
    if (code == null) null;
21  
    
22  
    if (quickEval) try {
23  
      ret code.quickEval();
24  
    } catch e {
25  
      if (!fullEval)
26  
        rethrow(e);
27  
      else
28  
        printStackTrace(e);
29  
    }
30  
      
31  
    if (fullEval) {
32  
      print("*** FULL JAVA EVAL ***");
33  
      ret dm_javaEval(str(code));
34  
    }
35  
    
36  
    fail("No way to eval " + shorten(100, sfu(code)));
37  
  }
38  
  
39  
  public swappable CompressionRegime_AnyType fullRegime() { null; }
40  
}

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: 223 / 392
Version history: 18 change(s)
Referenced in: [show references]