Skip to content

Commit aae7864

Browse files
authored
Add ExprSplitter (#425)
* Add ExprSplitter and remove `prepare_thunk` and `split_expressions` The main motivation is to eliminate their need to `eval`, which feels like a code smell. * Restrict new releases to still-supported Julia versions * Fix doctests
1 parent 64d719f commit aae7864

18 files changed

+337
-251
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ os:
77

88
julia:
99
- 1.0
10-
- 1.3
11-
- 1.4
10+
- 1
1211
- nightly
1312

1413
arch:
@@ -28,7 +27,7 @@ codecov: true
2827
jobs:
2928
include:
3029
- stage: "Documentation"
31-
julia: 1.4
30+
julia: 1
3231
os: linux
3332
arch: x64
3433
script:

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "JuliaInterpreter"
22
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
3-
version = "0.7.26"
3+
version = "0.8.0"
44

55
[deps]
66
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
@@ -10,7 +10,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1010

1111
[compat]
1212
CodeTracking = "0.5.9, 1"
13-
julia = "1"
13+
julia = "~1.0, 1.5"
1414

1515
[extras]
1616
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

appveyor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
environment:
22
matrix:
33
- julia_version: 1.0
4-
- julia_version: 1.1
5-
- julia_version: 1.2
64
- julia_version: 1
75
- julia_version: nightly
86

docs/Manifest.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
55

66
[[CodeTracking]]
77
deps = ["InteractiveUtils", "UUIDs"]
8-
git-tree-sha1 = "ef95614491ce00eff5ebc3bbb957cf8b3b3dd3e8"
8+
git-tree-sha1 = "9c173f62af93cce8af2bd3527d160b6ddd6eaf81"
99
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
10-
version = "0.5.10"
10+
version = "1.0.0"
1111

1212
[[Dates]]
1313
deps = ["Printf"]
@@ -19,15 +19,15 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1919

2020
[[DocStringExtensions]]
2121
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
22-
git-tree-sha1 = "88bb0edb352b16608036faadcc071adda068582a"
22+
git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1"
2323
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
24-
version = "0.8.1"
24+
version = "0.8.3"
2525

2626
[[Documenter]]
2727
deps = ["Base64", "Dates", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
28-
git-tree-sha1 = "d497bcc45bb98a1fbe19445a774cfafeabc6c6df"
28+
git-tree-sha1 = "395fa1554c69735802bba37d9e7d9586fd44326c"
2929
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
30-
version = "0.24.5"
30+
version = "0.24.11"
3131

3232
[[InteractiveUtils]]
3333
deps = ["Markdown"]
@@ -43,7 +43,7 @@ version = "0.21.0"
4343
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
4444
path = ".."
4545
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
46-
version = "0.7.13"
46+
version = "0.8.0"
4747

4848
[[LibGit2]]
4949
deps = ["Printf"]
@@ -64,9 +64,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"
6464

6565
[[Parsers]]
6666
deps = ["Dates", "Test"]
67-
git-tree-sha1 = "f8f5d2d4b4b07342e5811d2b6428e45524e241df"
67+
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
6868
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
69-
version = "1.0.2"
69+
version = "1.0.10"
7070

7171
[[Pkg]]
7272
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]

docs/src/dev_reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
## Frame creation
1010

1111
```@docs
12+
Frame(mod::Module, ex::Expr)
13+
ExprSplitter
1214
JuliaInterpreter.enter_call
1315
JuliaInterpreter.enter_call_expr
1416
JuliaInterpreter.prepare_frame
1517
JuliaInterpreter.determine_method_for_expr
1618
JuliaInterpreter.prepare_args
1719
JuliaInterpreter.prepare_call
18-
JuliaInterpreter.prepare_thunk
19-
JuliaInterpreter.split_expressions
2020
JuliaInterpreter.get_call_framecode
2121
JuliaInterpreter.optimize!
2222
```
@@ -73,7 +73,7 @@ JuliaInterpreter.dummy_breakpoint
7373
## Types
7474

7575
```@docs
76-
JuliaInterpreter.Frame
76+
Frame
7777
JuliaInterpreter.FrameCode
7878
JuliaInterpreter.FrameData
7979
JuliaInterpreter.FrameInstance

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ At present, note that some of this functionality requires that you be running
9494
It is, in addition, possible to halt execution when otherwise an error would be thrown.
9595
This functionality is enabled using [`break_on`](@ref) and disabled with [`break_off`](@ref):
9696

97-
```jldoctest demo1
97+
```jldoctest demo1; filter=r"none:\d"
9898
julia> function f_outer()
9999
println("before error")
100100
f_inner()
@@ -139,7 +139,7 @@ Stacktrace:
139139

140140
Finally, you can set breakpoints using [`@bp`](@ref):
141141

142-
```jldoctest demo1
142+
```jldoctest demo1; filter=r"none:\d"
143143
julia> function myfunction(x, y)
144144
a = 1
145145
b = 2

docs/src/internals.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ or `JuliaInterpreter.finish_and_return!(frame)` to also obtain the return value.
143143
## More complex expressions
144144

145145
Sometimes you might have a whole sequence of expressions you want to run.
146-
In such cases, your first thought should be `prepare_thunk`.
146+
In such cases, your first thought should be to construct the `Frame` manually.
147147
Here's a demonstration:
148148

149149
```jldoctest; setup=(using JuliaInterpreter; JuliaInterpreter.clear_caches())
@@ -154,7 +154,7 @@ ex = quote
154154
@test x + y == 3
155155
end
156156
157-
frame = JuliaInterpreter.prepare_thunk(Main, ex)
157+
frame = Frame(Main, ex)
158158
JuliaInterpreter.finish_and_return!(frame)
159159
160160
# output
@@ -179,7 +179,7 @@ Here's a demonstration of the problem:
179179

180180
```julia
181181
ex = :(map(x->x^2, [1, 2, 3]))
182-
frame = JuliaInterpreter.prepare_thunk(Main, ex)
182+
frame = Frame(Main, ex)
183183
julia> JuliaInterpreter.finish_and_return!(frame)
184184
ERROR: this frame needs to be run a top level
185185
```
@@ -226,13 +226,12 @@ julia> JuliaInterpreter.finish_and_return!(frame, true)
226226
9
227227
```
228228
229-
Here's a more fine-grained look at what's happening under the hood (and a robust strategy
230-
for more complex situations where there may be nested calls of new methods):
229+
In other cases, such as nested calls of new methods, you may need to allow the world age to update
230+
between evaluations. In such cases you want to use `ExprSplitter`:
231231
232232
```julia
233-
modexs, _ = JuliaInterpreter.split_expressions(Main, ex)
234-
for (mod, e) in modexs
235-
frame = JuliaInterpreter.prepare_thunk(mod, e)
233+
for (mod, e) in ExprSplitter(Main, ex)
234+
frame = Frame(mod, e)
236235
while true
237236
JuliaInterpreter.through_methoddef_or_done!(frame) === nothing && break
238237
end

0 commit comments

Comments
 (0)