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

21
LINES

< > BotCompany Repo | #1012910 // safeInterpretedJavaEval

JavaX fragment (include)

static O safeInterpretedJavaEval(S s) {
  ret safeInterpretedJavaEval(javaTok(s));
}

static O safeInterpretedJavaEval(L<S> tok) {
  Pair<S, L<S>> p = tok_parseFunctionCall(tok);
  if (p != null)
    ret callAndMakeOrDirect_safe(p.a, map safeInterpretedJavaEval(p.b));
  if (lCodeTokens(tok) == 2 && eqGet(tok, 1, "#") && isIdentifier(get(tok, 3)))
    ret ai_getVar("#" + get(tok, 3));
  if (lCodeTokens(tok) == 1) {
    S t = get(tok, 1);
    if (isQuoted(t)) ret unquote(t);
    if (isInteger(t)) ret parseInt(t);
    if (eq(t, "null")) ret null;
    if (eq(t, "false")) ret false;
    if (eq(t, "true")) ret true;
    if (isIdentifier(t)) ret ai_getVar(t);
  }
  fail("Can't interpret: " + join(tok));
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012910
Snippet name: safeInterpretedJavaEval
Eternal ID of this version: #1012910/8
Text MD5: 77b2a15cf712f849ef7e2abdcef7e005
Author: stefan
Category: javax / eval
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-19 23:10:32
Source code size: 727 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 394 / 429
Version history: 7 change(s)
Referenced in: [show references]