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

static S evalJava_prep(S code) {
  ret evalJava_prep(code, "calc");
}

static S evalJava_prep(S code, S mainName) {
  ret evalJava_prep(code, mainName, "");
}

static new ThreadLocal<S> evalJava_prep_args;

sS evalJava_prep(S code, S mainName, S preCode) {
  new EvalJavaPrep prep;
  LS tok = evalJava_prePrep(code, prep);
  code = tok_addReturn(tok);
  S returnType = containsReturnWithArgument(code) ? "Object" : "void";
  S main =
    lines(prep.global)
    + "static " + returnType + " " + mainName + "(" + unnull(evalJava_prep_args!) + ") throws Exception {\n" 
      + preCode + code + "\n" + "}";
  ret main;
}

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: 687 / 817
Version history: 21 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)