Library
Public interface
Semicoroutines.Semicoroutines — ModuleMain module for Semicoroutines.jl – C# style generators a.k.a. semi-coroutines for Julia
Semicoroutines.@nosave — MacroMacro if used in a @resumable function that creates a not saved variable otherwise throws an error.
Semicoroutines.@resumable — MacroMacro that transforms a function definition in a finite-statemachine:
- Defines a new
mutable structthat implements the iterator interface and is used to store the internal state. - Makes this new type callable having following characteristics:
- implementents the statements from the initial function definition but;
- returns at a
@yieldstatement and; - continues after the
@yieldstatement when called again.
- Defines a constructor function that respects the calling conventions of the initial function definition and returns an object of the new type.
Semicoroutines.@yield — MacroMacro if used in a @resumable function that returns the expr otherwise throws an error.
Internals
Base.IteratorSize — MethodImplements the iteratorsize method of the iterator interface for a subtype of FiniteStateMachineIterator.
Semicoroutines.BoxedUInt8 — TypeMutable struct that contains a single UInt8.
Semicoroutines.FiniteStateMachineIterator — TypeAbstract type used as base type for the type created by the @resumable macro.
Base.eltype — MethodImplements the eltype method of the iterator interface for a subtype of FiniteStateMachineIterator.
Semicoroutines._is_yield — MethodFunction returning whether an expression is a @yield macro
Semicoroutines.get_args — MethodFunction returning the arguments of a function definition
Semicoroutines.get_param_name — MethodFunction returning the name of a where parameter
Semicoroutines.get_slots — MethodFunction returning the slots of a function definition
Semicoroutines.hasreturnvalue — MethodFunction checking the use of a return statement with value
Semicoroutines.make_arg_any — MethodFunction changing the type of a slot arg of a arg = @yield ret or arg = @yield statement to Any.
Semicoroutines.remove_catch_exc — MethodFunction removing the exc symbol of a catch exc statement of a list of slots.
Semicoroutines.transform_arg — MethodFunction that replaces a arg = @yield ret statement by
@yield ret;
arg = arg_where arg_ is the argument of the function containing the expression.
Semicoroutines.transform_continue — MethodFunction that replaces a continue statement by a corresponding @goto with as label the correct location for the next iteration.
Semicoroutines.transform_exc — MethodFunction that replaces a @yield ret or @yield statement by
@yield ret
_arg isa Exception && throw(_arg)to allow that an Exception can be thrown into a @resumable function.
Semicoroutines.transform_for — MethodFunction that replaces a for loop by a corresponding while loop saving explicitely the iterator and its state.
Semicoroutines.transform_let — MethodFunction that replaces a variable _fsmi.x in an expression by x where x is a variable declared in a let block.
Semicoroutines.transform_nosave — MethodFunction that replaces a variable
Semicoroutines.transform_slots — MethodFunction that replaces a variable x in an expression by _fsmi.x where x is a known slot.
Semicoroutines.transform_slots_let — MethodFunction that handles let block
Semicoroutines.transform_try — MethodFunction that replaces a try-catch-finally-end expression having a top level @yield statement in the try part
try
before_statements...
@yield ret
after_statements...
catch exc
catch_statements...
finally
finally_statements...
endwith a sequence of try-catch-end expressions:
try
before_statements...
catch
catch_statements...
@goto _TRY_n
end
@yield ret
try
after_statements...
catch
catch_statements...
end
@label _TRY_n
finally_statements...Semicoroutines.transform_yield — MethodFunction that replaces a @yield ret or @yield statement with
_fsmi._state = n
return ret
@label _STATE_n
_fsmi._state = 0xffSemicoroutines.transform_yield — MethodFunction that replaces a @yield ret or @yield statement with
return ret