java.lang.Object
org.kink_lang.kink.internal.sym.SymRegistryImpl
- All Implemented Interfaces:
SymRegistry
The bidirectional registry of syms and sym-handles.
A sym-handle is an int value between 1 and 0x3fff_ffff
corresponding to a sym.
A handle is generated when handleFor(String)
is called for the sym for the first time.
The registry can be accessed from multiple threads concurrently.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum sym handle of preloaded control syms.static final int
Sym handle of "repr". -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Registers or gets the handle of the sym.static boolean
isPreloaded
(int handle) Whether the handle is a preloaded fun.boolean
isValidHandle
(int handle) Returns true if the handle is registered.symFor
(int handle) Returns the corresponding sym for the handle.
-
Field Details
-
MAX_PRELOADED_CONTROL
public static final int MAX_PRELOADED_CONTROLThe maximum sym handle of preloaded control syms. -
REPR
public static final int REPRSym handle of "repr".
-
-
Constructor Details
-
SymRegistryImpl
public SymRegistryImpl()Constructs a sym handle.
-
-
Method Details
-
handleFor
Registers or gets the handle of the sym.- Specified by:
handleFor
in interfaceSymRegistry
- Parameters:
sym
- the sym.- Returns:
- the handle.
- Throws:
IllegalStateException
- if the sym is not registered yet, and the registry does not have capacity for the new sym.
-
symFor
Returns the corresponding sym for the handle.- Specified by:
symFor
in interfaceSymRegistry
- Parameters:
handle
- the handle.- Returns:
- the corresponding sym for the handle.
- Throws:
IllegalArgumentException
- if the specified handle is not registered.
-
isValidHandle
public boolean isValidHandle(int handle) Returns true if the handle is registered.- Specified by:
isValidHandle
in interfaceSymRegistry
- Parameters:
handle
- the handle.- Returns:
- true if the handle is registered.
-
isPreloaded
public static boolean isPreloaded(int handle) Whether the handle is a preloaded fun.- Parameters:
handle
- the handle to test.- Returns:
- whether the handle is a preloaded fun.
-