summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Methodical/eh/basics/tryfaulttrycatchfn.il
blob: 025e43d0f47c681b070eb6ed36e78581841cf6bb (plain)
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
// try fault, error case


.assembly extern System.Console
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
  .ver 4:0:0:0
}
.assembly extern mscorlib {}
.assembly extern common {}
.assembly test {}
.module test.exe

.method public static void middle() {
    .maxstack  1
  
    .try
    {
      ldstr      "In try - fault"
      call       void [System.Console]System.Console::WriteLine(string)
      newobj     instance void [mscorlib]System.ArithmeticException::.ctor()
      throw
      leave.s    done

    }  
    fault
    {
      ldstr      "In fault"
      call       void [System.Console]System.Console::WriteLine(string)
      endfault
    }  
    ldstr      "Unreached"
    call       void [System.Console]System.Console::WriteLine(string)
done:
    ret
}


.method public static int32 main() {
    .entrypoint
    .maxstack  2
    .locals init (
	  class [mscorlib]System.IO.StringWriter expectedOut,
	  class [common]TestUtil.TestLog testLog
	)
    
    newobj     instance void [mscorlib]System.IO.StringWriter::.ctor()
    stloc.s    expectedOut
    ldloc.s    expectedOut
    ldstr      "In try - catch"
    callvirt   instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
    ldloc.s    expectedOut
    ldstr      "In try - fault"
    callvirt   instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
    ldloc.s    expectedOut
    ldstr      "In fault"
    callvirt   instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
    ldloc.s    expectedOut
    ldstr      "In catch"
    callvirt   instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
    ldloc.s    expectedOut
    newobj     instance void [common]TestUtil.TestLog::.ctor(object)
    stloc.s    testLog

    ldloc.s    testLog
    callvirt   instance void [common]TestUtil.TestLog::StartRecording()

    .try {
      ldstr      "In try - catch"
      call       void [System.Console]System.Console::WriteLine(string)

      call       void middle()
      leave.s    done
    } 
    catch [mscorlib]System.Exception 
    {
      ldstr      "In catch"
      call       void [System.Console]System.Console::WriteLine(string)
      leave.s done
    }
  done:
    ldloc.s    testLog
    callvirt   instance void [common]TestUtil.TestLog::StopRecording()
  
    ldloc.s    testLog
    callvirt   instance int32 [common]TestUtil.TestLog::VerifyOutput()
    
    ret
}