Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ static boolean unsafeFreeIdentifierEqual(Evaluator eval,

/**
* Provides the site where an identifier was bound.
* The result is only valid when the identifier is taked from fully-expanded
* code.
* The result is only valid when the identifier is from fully expanded code.
* <p>
* Based on Racket's <a href="http://docs.racket-lang.org/reference/stxcmp.html?q=member#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29">{@code identifier-binding}</a>.
*
Expand All @@ -157,7 +156,7 @@ static boolean unsafeFreeIdentifierEqual(Evaluator eval,
static BindingSite unsafeIdentifierBinding(Evaluator eval, Object id)
throws FusionException
{
return ((SyntaxSymbol) id).uncachedResolve().getBindingSite();
return ((SyntaxSymbol) id).resolve().getBindingSite();
}


Expand Down
37 changes: 6 additions & 31 deletions runtime/src/main/java/dev/ionfusion/fusion/SyntaxSymbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ SyntaxSymbol copyReplacingBinding(Binding binding)
{
SyntaxSymbol copy =
new SyntaxSymbol(getWraps(), getPosition(), getProperties(), getName());
copy.myBoundId = uncachedResolveBoundIdentifier().copyReplacingBinding(binding);
copy.myBoundId = resolveBoundIdentifier().copyReplacingBinding(binding);
return copy;
}

Expand All @@ -112,19 +112,6 @@ String stringValue()
}


/**
* Resolves this identifier to a {@link BoundIdentifier}, but doesn't cache
* the result if it has not been previously resolved.
*
* @return not null.
*/
BoundIdentifier uncachedResolveBoundIdentifier()
{
if (myBoundId != null) return myBoundId;

return myWraps.resolveBoundIdentifier(getName());
}

/**
* Resolves this identifier to a {@link BoundIdentifier}, permanently
* caching the result.
Expand All @@ -135,7 +122,7 @@ BoundIdentifier resolveBoundIdentifier()
{
if (myBoundId == null)
{
myBoundId = uncachedResolveBoundIdentifier();
myBoundId = myWraps.resolveBoundIdentifier(getName());
}
return myBoundId;
}
Expand All @@ -154,18 +141,6 @@ Binding resolve()
}


/**
* Resolves this identifier, but doesn't cache the result if it has not
* been previously resolved.
*
* @return not null, but maybe a {@link FreeBinding}.
*/
Binding uncachedResolve()
{
return uncachedResolveBoundIdentifier().getBinding();
}


/**
* Resolves this identifier, but doesn't cache the result if it has not
* been previously resolved.
Expand Down Expand Up @@ -270,15 +245,15 @@ SyntaxValue<?> doExpand(Expander expander, Environment env)

boolean boundIdentifierEqual(SyntaxSymbol that)
{
BoundIdentifier thisId = this.uncachedResolveBoundIdentifier();
BoundIdentifier thatId = that.uncachedResolveBoundIdentifier();
BoundIdentifier thisId = this.resolveBoundIdentifier();
BoundIdentifier thatId = that.resolveBoundIdentifier();
return thisId.equals(thatId);
}

boolean freeIdentifierEqual(SyntaxSymbol that)
{
Binding thisBinding = this.uncachedResolve();
Binding thatBinding = that.uncachedResolve();
Binding thisBinding = this.resolve();
Binding thatBinding = that.resolve();
return thisBinding.sameTarget(thatBinding);
}

Expand Down
Loading