Class LocationBasedInternalName
java.lang.Object
org.ek9lang.compiler.support.LocationBasedInternalName
Generates deterministic internal names using SHA-256 hashing.
Two variants are provided:
generate(String, String, IToken, String...)— includes relative source file name, line and position in the hash. Use when the declaration point is stable (e.g. aspect proxy register statements that are in user code, not shifted by compiler directives).generate(String, String...)— uses only semantic context strings. Use when line numbers may shift (e.g. dynamic functions where@IRdirectives inserted above shift the declaration line).
Both produce stable names across compilations (unlike UUID-based names). A dynamic construct's
position-independent ordinal is OrdinalWithinSource. Hold one.
Callers must pass a relative source name (not an absolute path) to ensure
consistent hashes across different build environments.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerate a deterministic internal name from semantic context only.Generate a deterministic internal name from a relative source file and token location.
-
Constructor Details
-
LocationBasedInternalName
public LocationBasedInternalName()
-
-
Method Details
-
generate
public String generate(String prefix, String relativeSourceName, IToken sourceToken, String... additionalContext) Generate a deterministic internal name from a relative source file and token location. Includes the relative source file name, line number, and character position in the hash.- Parameters:
prefix- The name prefix (e.g. "_AspectProxy_")relativeSourceName- The relative source file path (not absolute, for environment stability)sourceToken- The source token providing line and positionadditionalContext- Optional additional strings to include in the hash- Returns:
- A deterministic name like
_AspectProxy_A1B2C3...
-
generate
Generate a deterministic internal name from semantic context only. Does NOT include line numbers, so names remain stable when source lines shift (e.g. when@IRdirectives are added above the declaration).- Parameters:
prefix- The name prefix (e.g. "_Function_")context- One or more context strings that uniquely identify the construct (e.g. source file name, enclosing function FQN, super function name)- Returns:
- A deterministic name like
_Function_A1B2C3...
-