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

21
LINES

< > BotCompany Repo | #1005446 // evalJava_prep - prepare JavaX code for evaluation

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

Libraryless. Click here for Pure Java version (8603L/50K).

1  
static S evalJava_prep(S code) {
2  
  ret evalJava_prep(code, "calc");
3  
}
4  
5  
static S evalJava_prep(S code, S mainName) {
6  
  ret evalJava_prep(code, mainName, "");
7  
}
8  
9  
static new ThreadLocal<S> evalJava_prep_args;
10  
11  
sS evalJava_prep(S code, S mainName, S preCode) {
12  
  new EvalJavaPrep prep;
13  
  LS tok = evalJava_prePrep(code, prep);
14  
  code = tok_addReturn(tok);
15  
  S returnType = containsReturnWithArgument(code) ? "Object" : "void";
16  
  S main =
17  
    lines(prep.global)
18  
    + "static " + returnType + " " + mainName + "(" + unnull(evalJava_prep_args!) + ") throws Exception {\n" 
19  
      + preCode + code + "\n" + "}";
20  
  ret main;
21  
}

Author comment

Began life as a copy of #1005407

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1005446
Snippet name: evalJava_prep - prepare JavaX code for evaluation
Eternal ID of this version: #1005446/22
Text MD5: 8c111d8a4de8067f34756fff1cfda89b
Transpilation MD5: f41308a5ae142c410afa4dfaf3d32a00
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-20 00:26:25
Source code size: 637 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 686 / 816
Version history: 21 change(s)
Referenced in: [show references]