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

35
LINES

< > BotCompany Repo | #1032260 // test_tok_ifCast

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

Transpiled version (4355L) is out of date.

1  
svoid test_tok_ifCast(bool optimized default true) {
2  
  testTranspilationFunction tok_ifCast(
3  
    "if (a cast B) a = a.x; print(a);",
4  
    "if (a instanceof B) a = ((B) a).x; print(a);",
5  
    "if (a cast B && a.y) a = a.x; print(a);",
6  
    "if (a instanceof B && ((B) a).y) a = ((B) a).x; print(a);",
7  
    [[
8  
      if (contents cast S && isRelativeOrAbsoluteURL(contents))
9  
        ret hstylesheetsrc(contents);
10  
      else    
11  
        ret htag("style", contents);
12  
    ]],
13  
    [[
14  
      if (contents instanceof S && isRelativeOrAbsoluteURL((S) contents))
15  
        ret hstylesheetsrc((S) contents);
16  
      else    
17  
        ret htag("style", contents);
18  
    ]],
19  
    "if (a cast int[]) { x = a; } if (a cast long[]) { y = a; }",
20  
    optimized ? "if (a instanceof int[]) { x = (int[]) a; }"
21  
      + " if (a instanceof long[]) { y = (long[]) a; }"
22  
      : "if (a instanceof int[]) { x = ((int[]) a); }"
23  
      + " if (a instanceof long[]) { y = ((long[]) a); }",
24  
    "if (a cast B) a = x(a);",
25  
    "if (a instanceof B) a = x((B) a);",
26  
    
27  
    // type parameters (slightly dirty)
28  
    "if (a cast Map<O>) b = a;",
29  
    "if (a instanceof Map) b = (Map<O>) a;",
30  
    
31  
    // variable name = function name
32  
    "if (map cast Map) ret map(map);",
33  
    "if (map instanceof Map) ret map((Map) map);",
34  
  );
35  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, wnsclhtenguj

No comments. add comment

Snippet ID: #1032260
Snippet name: test_tok_ifCast
Eternal ID of this version: #1032260/12
Text MD5: a394c52cbfb0519b1f9d787e1775a8bb
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-23 00:38:16
Source code size: 1313 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 177 / 290
Version history: 11 change(s)
Referenced in: [show references]