File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,26 @@ mutable struct Tape
66 owner
77end
88
9+ """
10+ Instruction
11+
12+ An `Instruction` stands for a function call
13+ """
914mutable struct Instruction{F} <: AbstractInstruction
1015 fun:: F
1116 input:: Tuple
1217 output
1318 tape:: Tape
1419end
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+ """
1629mutable struct NewInstruction <: AbstractInstruction
1730 input:: Tuple
1831 output
@@ -79,6 +92,7 @@ function Base.show(io::IO, tp::Tape)
7992end
8093
8194function (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
90104
91105
92106function (instr:: NewInstruction )()
107+ # Catch run-time exceptions / errors.
93108 try
94109 expr = Expr (:new , map (val, instr. input)... )
95110 output = eval (expr)
You can’t perform that action at this time.
0 commit comments