Transpiled version (5877L) is out of date.
1 | svoid tok_selfType(L<S> tok) {
|
2 | int i; |
3 | mainLoop: while ((i = jfind(tok, "selfType", (_tok, nIdx) -> {
|
4 | S prev = get(_tok, nIdx-1); |
5 | S next = get(_tok, nIdx+3); |
6 | ret isIdentifier(next) |
7 | || eqOneOf(next, ".", "(")
|
8 | || eq(prev, "(") && eq(next, ")")
|
9 | || eqOneOf(prev, "instanceof", "cast"); |
10 | })) >= 0) {
|
11 | // Now find class name by going backwards. |
12 | |
13 | int j = i, level = 1; |
14 | while (j > 0 && level > 0) {
|
15 | S t = tok.get(j); |
16 | if (t.equals("}")) ++level;
|
17 | if (t.equals("{")) --level;
|
18 | j -= 2; |
19 | } |
20 | |
21 | // search for class name |
22 | while (j > 0) {
|
23 | S t = tok.get(j); |
24 | if (eqOneOf(t, "class", "interface", "enum") && isIdentifier(get(tok, j+2))) {
|
25 | S type = tok_typeArgs_declToInvocation(tok_scanType(tok, j+2)); |
26 | |
27 | if (eqGet(tok, i+2, ".") && eqGet(tok, i+4, "class")) |
28 | type = tok_dropTypeParameters(type); |
29 | |
30 | tokSet_reTok(tok, i, type); |
31 | continue mainLoop; |
32 | } |
33 | j -= 2; |
34 | } |
35 | |
36 | tok.set(i, "Object"); // avoid endless loop if no outer class found |
37 | } |
38 | } |
Began life as a copy of #1023533
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1025303 |
| Snippet name: | tok_selfType - "selfType" to enclosing class name |
| Eternal ID of this version: | #1025303/17 |
| Text MD5: | 0c04943da5431428faaf26a994fa1b4f |
| Author: | stefan |
| Category: | javax / transpiling |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2023-02-21 16:55:22 |
| Source code size: | 1126 bytes / 38 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 668 / 891 |
| Version history: | 16 change(s) |
| Referenced in: | [show references] |