Class Declaration
- Direct Known Subclasses:
DeclaredFunction,DeclaredImplementation,DeclaredParameter,DeclaredVariable
A Declaration is the common abstraction for all language constructs
that may appear as named declarations within a lexical or semantic scope,
including variables, functions, parameters, and implementations.
This sealed abstract class restricts extension to its permitted subclasses
(DeclaredVariable, DeclaredFunction,
DeclaredParameter, and DeclaredImplementation), preserving
the integrity of the declaration model.
Each declaration records the depth at which it appears in the
languageās scope hierarchy. The depth corresponds to the lexical nesting
level of the surrounding context (for example, global scope, function body,
or control-flow block).
This class is immutable: the depth of a declaration is assigned at construction time and cannot be modified.
- Author:
- Chakib Daii
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe lexical or semantic depth at which this declaration was introduced. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetDepth()Returns the depth of this declaration within the scope hierarchy.
-
Field Details
-
depth
protected final int depthThe lexical or semantic depth at which this declaration was introduced.Depth
0typically represents the global or root scope. Incremental values represent deeper nested scopes.
-
-
Constructor Details
-
Declaration
public Declaration(int depth) Creates a new declaration at the specified depth.- Parameters:
depth- the scope depth where this declaration appears
-
-
Method Details
-
getDepth
public int getDepth()Returns the depth of this declaration within the scope hierarchy.- Returns:
- the declaration depth
-