Package org.daiitech.naftah.builtin.lang
Class DeclaredImplementation
java.lang.Object
org.daiitech.naftah.builtin.lang.Declaration
org.daiitech.naftah.builtin.lang.DeclaredImplementation
Represents a declared implementation (similar to a class or object blueprint) in the Naftah scripting language.
A DeclaredImplementation encapsulates the original parse context,
its name, object fields (variables), and the functions defined within the implementation.
This class extends Declaration and is immutable once created.
It preserves the depth at which the implementation is declared, supporting
scope resolution and context management.
Typical usage includes defining object fields and implementation-specific functions, and resolving them during execution or code analysis.
- Author:
- Chakib Daii
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<String,DeclaredFunction<?>> Map of functions declared within this implementation.private final StringThe name of the implementation.private final Map<String,DeclaredVariable> Map of object fields declared within this implementation.private final NaftahParser.ImplementationDeclarationContextThe original ANTLR parse context for the implementation declaration.Fields inherited from class org.daiitech.naftah.builtin.lang.Declaration
depth -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDeclaredImplementation(int depth, NaftahParser.ImplementationDeclarationContext originalContext, Map<String, DeclaredVariable> objectFields, Map<String, DeclaredFunction<?>> implementationFunctions) Private constructor for creating aDeclaredImplementation. -
Method Summary
Modifier and TypeMethodDescriptionReturns the map of functions declared in this implementation.getName()Returns the name of this implementation.Returns the map of object fields declared in this implementation.Returns the original ANTLR parse context for this implementation.static DeclaredImplementationof(int depth, NaftahParser.ImplementationDeclarationContext originalContext, Map<String, DeclaredVariable> objectFields, Map<String, DeclaredFunction<?>> implementationFunctions) Factory method to create aDeclaredImplementation.toString()Returns a string representation of the declared implementation in Arabic.Methods inherited from class org.daiitech.naftah.builtin.lang.Declaration
getDepth
-
Field Details
-
originalContext
The original ANTLR parse context for the implementation declaration. -
name
The name of the implementation. -
objectFields
Map of object fields declared within this implementation. Keyed by field name. -
implementationFunctions
Map of functions declared within this implementation. Keyed by function name.
-
-
Constructor Details
-
DeclaredImplementation
private DeclaredImplementation(int depth, NaftahParser.ImplementationDeclarationContext originalContext, Map<String, DeclaredVariable> objectFields, Map<String, DeclaredFunction<?>> implementationFunctions) Private constructor for creating aDeclaredImplementation.- Parameters:
depth- the depth in the context hierarchy where declaredoriginalContext- the original ANTLR parse contextobjectFields- map of declared object fieldsimplementationFunctions- map of declared functions
-
-
Method Details
-
of
public static DeclaredImplementation of(int depth, NaftahParser.ImplementationDeclarationContext originalContext, Map<String, DeclaredVariable> objectFields, Map<String, DeclaredFunction<?>> implementationFunctions) Factory method to create aDeclaredImplementation.- Parameters:
depth- the depth in the context hierarchyoriginalContext- the original ANTLR parse contextobjectFields- map of object fieldsimplementationFunctions- map of functions- Returns:
- a new instance of
DeclaredImplementation
-
getOriginalContext
Returns the original ANTLR parse context for this implementation.- Returns:
- the original implementation declaration context
-
getName
Returns the name of this implementation.- Returns:
- the implementation name
-
getObjectFields
Returns the map of object fields declared in this implementation.- Returns:
- the object fields map
-
getImplementationFunctions
Returns the map of functions declared in this implementation.- Returns:
- the implementation functions map
-
toString
Returns a string representation of the declared implementation in Arabic.
-