Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use class path as default module search path.
Will (hopefully) be useful during bootstrapping.
  • Loading branch information
jnthn committed Apr 14, 2013
1 parent 7a47938 commit d26aaf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1908,6 +1908,7 @@ QAST::OperationsJAST.map_classlib_core_op('loadcompunit', $TYPE_OPS, 'loadcompun
QAST::OperationsJAST.map_classlib_core_op('iscompunit', $TYPE_OPS, 'iscompunit', [$RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('compunitmainline', $TYPE_OPS, 'compunitmainline', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('compunitcodes', $TYPE_OPS, 'compunitcodes', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('jvmclasspaths', $TYPE_OPS, 'jvmclasspaths', [], $RT_OBJ, :tc);

class QAST::CompilerJAST {
# Responsible for handling issues around code references, building the
Expand Down
12 changes: 9 additions & 3 deletions nqp-src/ModuleLoader.pm
Expand Up @@ -7,11 +7,17 @@ knowhow ModuleLoader {

# Put any explicitly specified path on the start of the list.
my $explicit;
# XXX TODO: Exceptions.
#try { $explicit := %*COMPILING<%?OPTIONS>{$explicit_path}; }
if !nqp::isnull($explicit) && nqp::defined($explicit) {
if !nqp::isnull($explicit) {
try { $explicit := %*COMPILING<%?OPTIONS>{$explicit_path}; }
}
if nqp::defined($explicit) {
nqp::push(@search_paths, $explicit);
}
else {
for nqp::jvmclasspaths() {
nqp::push(@search_paths, $_)
}
}

# Add CWD.
nqp::push(@search_paths, '.');
Expand Down
11 changes: 11 additions & 0 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -3376,4 +3376,15 @@ public static SixModelObject compunitcodes(SixModelObject obj, ThreadContext tc)
result.bind_pos_boxed(tc, i, res.cu.codeRefs[i]);
return result;
}
public static SixModelObject jvmclasspaths(ThreadContext tc) {
SixModelObject Array = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.listType;
SixModelObject Str = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.strBoxType;
SixModelObject result = Array.st.REPR.allocate(tc, Array.st);
result.initialize(tc);
String cpStr = System.getProperty("java.class.path");
String[] cps = cpStr.split("[:;]");
for (int i = 0; i < cps.length; i++)
result.push_boxed(tc, box_s(cps[i], Str, tc));
return result;
}
}

0 comments on commit d26aaf7

Please sign in to comment.