|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.deri.iris.compiler.BuiltinRegister
public final class BuiltinRegister
Holds the registry of built-in atoms that the parser can use to translate predicates to built-ins as the logic program is parsed.
Before a built-in can be recognized by the parser it must first be registered with the associated BuiltinRegister. The BuiltinRegister uses instances of the built-ins to get their predicate names and their class instances. The BuiltinRegister basically holds a map between predicate symbol and class instance. This class initialises itself with all the standard IRIS built-ins.
To add more, simply call registerBuiltin() with an instance of the new built-in type.
To unregister a built-in call unregisterBuiltin(). However, beware that unregistering any of the standard built-ins can lead to undefined behaviour.
| Constructor Summary | |
|---|---|
BuiltinRegister()
Constructs a new built-in register and register all the standard IRIS built-ins. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object o)
|
int |
getBuiltinArity(String s)
Returns the arity of a registered built-in. |
Class<?> |
getBuiltinClass(String s)
Returns the class of a registered built-in. |
int |
hashCode()
|
void |
registerBuiltin(IBuiltinAtom builtin)
Registers a single built-in. |
String |
toString()
Returns a short description of this object. |
void |
unregisterBuiltin(IBuiltinAtom builtin)
De-registers a single built-in. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BuiltinRegister()
| Method Detail |
|---|
public void registerBuiltin(IBuiltinAtom builtin)
builtin - an instance of the built-in to register
IllegalArgumentException - if the class is nullpublic void unregisterBuiltin(IBuiltinAtom builtin)
builtin - an instance of the built-in to de-register
IllegalArgumentException - if the class is nullpublic int getBuiltinArity(String s)
s - the name (predicate symbol) of the built-in
public Class<?> getBuiltinClass(String s)
s - the name (predicate symbol) of the built-in
null if such a built-in hasn't been registered yetpublic String toString()
Returns a short description of this object. The format of the returned string is undocumented and subject to change.
An example return string could be: [ADD[3,
org.deri.iris.builtins.AddBuiltin],SUBTRACT[3,
org.deri.builtins.SubtractBuiltin]]
toString in class Objectpublic boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||