1 | sS dm_processEmbeddedSafeEvals(S s, O... _) { |
2 | Map<S> evalCache = cast optPar evalCache(_); |
3 | |
4 | if (!contains(s, "{=")) ret s; |
5 | LS tok = javaTok(s); |
6 | Map<Int> bracketMap = curlyBracketMap(tok); |
7 | for (int i = 1; i < l(tok)-4; i += 2) { |
8 | continue unless eq(tok.get(i), "{") && eqGet(tok, i+1, "") && eqGet(tok, i+2, "="); |
9 | // eval found |
10 | |
11 | int j = or(bracketMap.get(i), l(tok)); |
12 | S code = joinSubList(tok, i+4, j-1); |
13 | |
14 | if (!isSafeCodeFragment(code)) |
15 | replaceTokens(tok, i+2, i+4, "UNSAFE: "); |
16 | else { |
17 | S result = mapGet(evalCache, code); |
18 | if (result == null) { |
19 | print("Evaluating: " + code); |
20 | try { |
21 | result = strOrEmpty(dm_javaEvalOrInterpret(code)); |
22 | } catch e { |
23 | printStackTrace(e); |
24 | result = ""; |
25 | } |
26 | mapPut(evalCache, code, result); |
27 | } |
28 | replaceTokens(tok, i, j+1, result); |
29 | } |
30 | |
31 | i = j-2; |
32 | } |
33 | ret trim(join(tok)); |
34 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022318 |
Snippet name: | dm_processEmbeddedSafeEvals |
Eternal ID of this version: | #1022318/10 |
Text MD5: | a7cfa43f0029b84b5edd52dbc750fe9c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-23 21:30:02 |
Source code size: | 978 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 288 / 349 |
Version history: | 9 change(s) |
Referenced in: | [show references] |