-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from willow-ahrens/compromise-interface
Compromise Interface Redesign
- Loading branch information
Showing
6 changed files
with
122 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "TermInterface" | ||
uuid = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c" | ||
authors = ["Shashi Gowda <[email protected]>", "Alessandro Cheli <[email protected]>"] | ||
version = "0.3.3" | ||
version = "0.4.0" | ||
|
||
[compat] | ||
julia = "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
# This file contains default definitions for TermInterface methods on Julia | ||
# Builtin Expr type. | ||
|
||
istree(x::Expr) = true | ||
exprhead(e::Expr) = e.head | ||
iscall(x::Expr) = x.head == :call | ||
|
||
operation(e::Expr) = expr_operation(e, Val{exprhead(e)}()) | ||
arguments(e::Expr) = expr_arguments(e, Val{exprhead(e)}()) | ||
callhead(e::Expr) = e.head | ||
head(e::Expr) = e.head | ||
children(e::Expr) = e.args | ||
|
||
# See https://docs.julialang.org/en/v1/devdocs/ast/ | ||
expr_operation(e::Expr, ::Union{Val{:call},Val{:macrocall}}) = e.args[1] | ||
expr_operation(e::Expr, ::Union{Val{:ref}}) = getindex | ||
expr_operation(e::Expr, ::Val{T}) where {T} = T | ||
operation(e::Expr) = iscall(e) ? first(children(e)) : error("operation called on a non-function call expression") | ||
arguments(e::Expr) = iscall(e) ? @view(e.args[2:end]) : error("arguments called on a non-function call expression") | ||
|
||
expr_arguments(e::Expr, ::Union{Val{:call},Val{:macrocall}}) = e.args[2:end] | ||
expr_arguments(e::Expr, _) = e.args | ||
|
||
|
||
function similarterm(x::Expr, head, args, symtype = nothing; metadata = nothing, exprhead = exprhead(x)) | ||
expr_similarterm(head, args, Val{exprhead}()) | ||
function maketerm(::Type{Expr}, head, args, symtype=nothing, metadata=nothing) | ||
Expr(head, args...) | ||
end | ||
|
||
|
||
expr_similarterm(head, args, ::Val{:call}) = Expr(:call, head, args...) | ||
expr_similarterm(head, args, ::Val{:macrocall}) = Expr(:macrocall, head, args...) # discard linenumbernodes? | ||
expr_similarterm(head, args, ::Val{eh}) where {eh} = Expr(eh, args...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters