Skip to content

Commit 4e85ae7

Browse files
authored
Merge pull request #136 from JuliaDebug/teh/misc
Docstring and dangling API update issue
2 parents ab60978 + 4e0e26c commit 4e85ae7

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

docs/src/dev_reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Function reference
22

3-
## Top-level
3+
## Running the interpreter
44

55
```@docs
66
@interpret
@@ -93,4 +93,5 @@ JuliaInterpreter.linenumber
9393
JuliaInterpreter.statementnumber
9494
JuliaInterpreter.Variable
9595
JuliaInterpreter.locals
96+
JuliaInterpreter.whichtt
9697
```

src/interpret.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ lookup_var(frame, ref::GlobalRef) = getfield(ref.mod, ref.name)
1010
function lookup_var(frame, slot::SlotNumber)
1111
val = frame.framedata.locals[slot.id]
1212
val !== nothing && return val.value
13-
error("slot ", slot, " with name ", frame.framecode.code.slotnames[slot.id], " not assigned")
13+
error("slot ", slot, " with name ", frame.framecode.src.slotnames[slot.id], " not assigned")
1414
end
1515

1616
function lookup_expr(frame, e::Expr)

src/utils.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ function to_function(@nospecialize(x))
2525
isa(x, GlobalRef) ? getfield(x.mod, x.name) : x
2626
end
2727

28+
"""
29+
method = whichtt(tt)
30+
31+
Like `which` except it operates on the complete tuple-type `tt`.
32+
"""
2833
function whichtt(@nospecialize(tt))
2934
m = ccall(:jl_gf_invoke_lookup, Any, (Any, UInt), tt, typemax(UInt))
3035
m === nothing && return nothing

test/interpret.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ f113(;x) = x
334334
return x
335335
end
336336
frame = JuliaInterpreter.enter_call(f_multi, 1)
337+
nlocals = length(frame.framedata.locals)
338+
@test_throws ErrorException("slot _4 with name x not assigned") JuliaInterpreter.lookup_var(frame, Core.SlotNumber(nlocals))
337339
stack = [frame]
338340
locals = JuliaInterpreter.locals(frame)
339341
@test length(locals) == 2

0 commit comments

Comments
 (0)