Skip to content

Commit

Permalink
Add ability to import jars using import statement (simple wrapper aro…
Browse files Browse the repository at this point in the history
…ud library.load)
  • Loading branch information
nick-paul committed Dec 31, 2024
1 parent b8dcd18 commit 187092e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion base/importlib.aya
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def importlib::aya_dir :(sys.ad)
.# Dictionary of files which have been imported
def importlib::imported :{}

def importlib::loaded_jars []

def importlib::path [
importlib.aya_dir "std" :9s + + .# <aya>/base
]
Expand Down Expand Up @@ -164,7 +166,9 @@ def importlib::import {__name : importlib^,
__name importlib.from_path
} (__name :T ::str =) {
{ .# Determine load command based on string type
(__name ".aya" H) {
(__name ".jar" H) {
__name importlib.load_library
} (__name ".aya" H) {
__name importlib.from_file
} (__name.[0] '/ =) {
__name importlib.load_file
Expand All @@ -181,6 +185,13 @@ def importlib::import {__name : importlib^,
}


def importlib::load_library {jar_file : importlib^,
importlib.loaded_jars jar_file H ! {
jar_file :(library.load) ;
jar_file importlib.loaded_jars .B ;
} ?
}


def importlib::is_exportall {
{ .# try
Expand Down
8 changes: 8 additions & 0 deletions src/web/WebAvailableNamedInstructionStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public void execute(BlockEvaluator blockEvaluator) {
// Unimplemented
throw new UnimplementedError();
}
},

new NamedOperator("library.load", "load a jar file") {
@Override
public void execute(BlockEvaluator blockEvaluator) {
// Unimplemented
throw new UnimplementedError();
}
}
);
}
Expand Down

0 comments on commit 187092e

Please sign in to comment.