Skip to content

Commit

Permalink
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -204,16 +204,7 @@ public Boolean block() throws InterruptedException {

callNode.call(frame, callTarget, new Object[]{});

final String fileName = new File(expandedPath).getName();
final String moduleName;
final int dotIndex = fileName.indexOf('.');
if (dotIndex == -1) {
moduleName = fileName;
} else {
moduleName = fileName.substring(0, dotIndex);
}

final Object initFunction = context.getEnv().importSymbol("@Init_" + moduleName);
final Object initFunction = context.getEnv().importSymbol("@Init_" + getBaseName(expandedPath));

if (!(initFunction instanceof TruffleObject)) {
throw new UnsupportedOperationException();
@@ -253,6 +244,18 @@ public Boolean block() throws InterruptedException {

}

private String getBaseName(String path) {
final String name = new File(path).getName();

final int firstDot = name.indexOf('.');

if (firstDot == -1) {
return name;
} else {
return name.substring(0, firstDot);
}
}

// TODO (pitr-ch 16-Mar-2016): this protects the $LOADED_FEATURES only in this class,
// it can still be accessed and modified (rare) by Ruby code which may cause issues
private final Object loadedFeaturesLock = new Object();

0 comments on commit 5e751ae

Please sign in to comment.