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
40 changes: 0 additions & 40 deletions runtime/src/main/java/dev/ionfusion/fusion/FusionSexp.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,46 +421,6 @@ static List<Object> unsafeSexpToJavaList(Evaluator eval, Object sexp)
}


/**
* @param sexp must be a proper sexp; it is not type-checked!
*/
static IonSexp unsafeCopyToIonSexp(Evaluator eval,
Object sexp,
ValueFactory factory,
boolean throwOnConversionFailure)
throws FusionException
{
BaseSexp base = (BaseSexp) sexp;
return base.copyToIonValue(eval, factory, throwOnConversionFailure);
}

/**
* @param sexp must be a proper sexp; it is not type-checked!
*/
static IonSexp unsafeCopyToIonSexp(Evaluator eval,
Object sexp,
ValueFactory factory)
throws FusionException
{
BaseSexp base = (BaseSexp) sexp;
return base.copyToIonValue(eval, factory, true);
}

/**
* @param sexp must be a proper sexp; it is not type-checked!
*
* @return null if the sexp and its contents cannot be ionized.
*/
static IonSexp unsafeCopyToIonSexpMaybe(Evaluator eval,
Object sexp,
ValueFactory factory)
throws FusionException
{
BaseSexp base = (BaseSexp) sexp;
return base.copyToIonValue(eval, factory, false);
}


//========================================================================


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,12 @@ Binding resolveMaybe(BaseSymbol name,

//==================================================================================


/**
* For each storage slot, hold a symbol for reporting its name.
* These are only used for reporting forward reference errors and are not unique.
* From here it is attached to an expanded `module` form as a syntax property,
* and from there to {@link dev.ionfusion.fusion.ModuleForm.CompiledModule}.
*/
private final List<BaseSymbol> myDefinedNames = new ArrayList<>();

private final SyntaxWrap myWrap = new ModuleWrap();
Expand Down Expand Up @@ -570,13 +575,14 @@ public Object doEval(Evaluator eval, Store store)


/**
* A reference to a module-level variable in the lexically enclosing
* namespace.
* A reference to a module-level variable in the lexically enclosing namespace.
*/
static final class CompiledModuleVariableReference
implements CompiledForm
{
private final int myAddress;

/** Used to make an identifier for forward-reference errors. */
private final ResourcePosition myPosition;

CompiledModuleVariableReference(int address, ResourcePosition position)
Expand Down
9 changes: 4 additions & 5 deletions runtime/src/main/java/dev/ionfusion/fusion/NamedValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
interface NamedValue <T>
{
/**
* Suggests a name for the given value, if it can accept it.
* Suggests a name for the given value if it can accept it.
*/
@SuppressWarnings("unchecked")
static void inferObjectName(Object value, Object name)
static <T> void inferObjectName(Object value, T name)
{
if (value instanceof NamedValue)
{
((NamedValue<Object>)value).inferObjectName(name);
((NamedValue<T>)value).inferObjectName(name);
}
}

Expand All @@ -35,8 +35,7 @@ default void inferObjectName(T name)
}

/**
* Produces a Fusion value that's the object's name for the purpose of the
* {@code object_name} function.
* Returns a Fusion value that's the result for the {@code object_name} function.
* The result must not change between invocations.
*
* @return the object name. If null, {@code object_name} returns void.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ interface NamespaceStore
{
ModuleRegistry getRegistry();

/**
* Provides runtime access to module-level definitions from outside the module.
*/
Object lookupImport(int moduleAddress, int bindingAddress);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
* Implements {@code object_name}.
*
* @see NamedValue
* @see <a href="http://tinyurl.com/object-name">Racket Reference for
* object-name</a>
* @see <a href="http://tinyurl.com/object-name">Racket Reference for object-name</a>
*/
class ObjectNameProc
extends Procedure1
Expand All @@ -21,7 +20,7 @@ Object doApply(Evaluator eval, Object arg)
{
if (arg instanceof NamedValue)
{
Object o = ((NamedValue) arg).objectName();
Object o = ((NamedValue<?>) arg).objectName();
if (o != null)
{
return o;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ int size(Evaluator eval)


@Override
SyntaxValue get(Evaluator eval, int index)
SyntaxValue<?> get(Evaluator eval, int index)
throws FusionException
{
return (SyntaxValue) unsafePairDot(eval, unwrap(eval), index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ final boolean isAnyNull()
final void write(Evaluator eval, Appendable out)
throws IOException, FusionException
{
Object content = unwrap(eval);
// Be careful not to propagate context here! This is called from `toString()`,
// which is called asynchronously by debuggers, which can cause context loss if
// it happens at the wrong time.
Object content = getContent();

// When possible, only write the explicit wrapper on the outside edge.
if (eval != null && (boolean) WRITE_EXPLICIT_SYNTAX.currentValue(eval))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ SyntaxWraps addWraps(SyntaxWraps wraps)
int prefixLen = wraps.myWraps.length;
int suffixLen = this.myWraps.length;

if (suffixLen == 0) return this; // Nothing to add
if (prefixLen == 0) return this; // Nothing to prepend

int len = prefixLen + suffixLen;

Expand Down
Loading