Skip to content

Commit c9673cd

Browse files
author
KDr2
committed
update docs/comments
1 parent e1ae835 commit c9673cd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tapedfunction.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ mutable struct Tape
66
owner
77
end
88

9+
"""
10+
Instruction
11+
12+
An `Instruction` stands for a function call
13+
"""
914
mutable struct Instruction{F} <: AbstractInstruction
1015
fun::F
1116
input::Tuple
1217
output
1318
tape::Tape
1419
end
1520

21+
22+
"""
23+
NewInstruction
24+
25+
A `NewInstruction` stands for a `new` operator, which only appears in
26+
an inner constructor. Its represtation in IRCode is not a function call,
27+
so we need a new intruction type to represent it on tapes.
28+
"""
1629
mutable struct NewInstruction <: AbstractInstruction
1730
input::Tuple
1831
output
@@ -79,6 +92,7 @@ function Base.show(io::IO, tp::Tape)
7992
end
8093

8194
function (instr::Instruction{F})() where F
95+
# Catch run-time exceptions / errors.
8296
try
8397
output = instr.fun(map(val, instr.input)...)
8498
instr.output.val = output
@@ -90,6 +104,7 @@ end
90104

91105

92106
function (instr::NewInstruction)()
107+
# Catch run-time exceptions / errors.
93108
try
94109
expr = Expr(:new, map(val, instr.input)...)
95110
output = eval(expr)

0 commit comments

Comments
 (0)