Skip to content

Commit

Permalink
Add state machine operators
Browse files Browse the repository at this point in the history
Co-authored-by: Fredrik Bagge Carlson <[email protected]>
  • Loading branch information
YingboMa and baggepinnen committed Feb 12, 2024
1 parent ce7c201 commit 487b28a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export parse_expr_to_symbolic

include("error_hints.jl")
include("struct.jl")
include("operators.jl")

# Hacks to make wrappers "nicer"
const NumberTypes = Union{AbstractFloat,Integer,Complex{<:AbstractFloat},Complex{<:Integer}}
Expand Down
25 changes: 25 additions & 0 deletions src/operators.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function activeState end
function entry end
function ticksInState end
function timeInState end

for (s, T) in [(:timeInState, :Real),
(:ticksInState, :Integer),
(:entry, :Bool),
(:activeState, :Bool)]
seed = hash(s)
@eval begin
$s(x) = wrap(term($s, x))
SymbolicUtils.promote_symtype(::typeof($s), _...) = $T
function SymbolicUtils.show_call(io, ::typeof($s), args)
if isempty(args)
print(io, $s, "()")
else
print(io, $s, "(", nameof(only(args)), ")")
end
end
end
if s != :activeState
@eval $s() = wrap(term($s))
end
end

0 comments on commit 487b28a

Please sign in to comment.