Compiler Design 2023

Testcase “short_circuit” of Assignment 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
; Jassmin assembly code
; MiniC v. 1.0
.class public short_circuit
.super java/lang/Object

.method static <clinit>()V
   .limit stack 1
   .limit locals 0
   return
.end method

.method public <init>()V
   .limit stack 1
   .limit locals 1
   .var 0 is this Lshort_circuit; from Label0 to Label1

  Label0:
   aload_0
   invokespecial java/lang/Object/<init>()V
  Label1:
   return
.end method

.method public f()Z
  Label0:
   ; CallStmt, line 2
   ; CallExpr
   ; ActualParam
   ldc "Error: && shortcircuit evaluation not done!\n"
   invokestatic lang/System/putString(Ljava/lang/String;)V
   ; ReturnStmt, line 3
   iconst_0
   ireturn
  Label1:
   .limit locals 1
   .limit stack 150
.end method

.method public ff()Z
  Label0:
   ; CallStmt, line 7
   ; CallExpr
   ; ActualParam
   ldc "Error: || shortcircuit evaluation not done!\n"
   invokestatic lang/System/putString(Ljava/lang/String;)V
   ; ReturnStmt, line 8
   iconst_0
   ireturn
  Label1:
   .limit locals 1
   .limit stack 150
.end method

.method public static main([Ljava/lang/String;)V
  Label0:
   new short_circuit
   dup
   invokespecial short_circuit/<init>()V
   astore_1
   ; IfStmt, line 13
   iconst_0
   ifeq Label2
   ; CallExpr
   ; "this"-pointer is the first ActualParam with instance methods:
   aload_1
   invokevirtual short_circuit/f()Z
   ifeq Label2
   iconst_1
   goto Label3
  Label2:
   iconst_0
  Label3:
   ifeq Label4
   goto Label5
  Label4:
  Label5:
   ; IfStmt, line 15
   iconst_1
   ifne Label6
   ; CallExpr
   ; "this"-pointer is the first ActualParam with instance methods:
   aload_1
   invokevirtual short_circuit/ff()Z
   ifne Label6
   iconst_0
   goto Label7
  Label6:
   iconst_1
  Label7:
   ifeq Label8
   goto Label9
  Label8:
  Label9:
  Label1:
   return
   .limit locals 2
   .limit stack 150
.end method