use of dyvilx.tools.compiler.library.Library in project Dyvil by Dyvil.
the class Package method resolvePackage.
public Package resolvePackage(String name) {
final Package pack = this.subPackages.get(name);
if (pack != null) {
return pack;
}
String internal = this.internalName + name;
for (Library library : rootPackage.compiler.config.libraries) {
if (library.isSubPackage(internal)) {
return this.createSubPackage(name);
}
}
return null;
}
use of dyvilx.tools.compiler.library.Library in project Dyvil by Dyvil.
the class LibraryCommand method execute.
@Override
public void execute(DyvilREPL repl, String argument) {
if (argument == null) {
repl.getErrorOutput().println(I18n.get("command.library.missing", this.getUsage()));
return;
}
final File path = new File(argument);
try {
final Library library = Library.load(path);
library.loadLibrary();
repl.getCompiler().config.libraries.add(library);
repl.getOutput().println(I18n.get("command.library.success", library));
} catch (FileNotFoundException ex) {
repl.getErrorOutput().println(ex);
}
}
use of dyvilx.tools.compiler.library.Library in project Dyvil by Dyvil.
the class TestThread method getCommand.
public String[] getCommand() {
final List<Library> libraries = this.compiler.config.libraries;
StringBuilder classpath = new StringBuilder();
classpath.append(this.compiler.config.getOutputDir());
for (Library library : libraries) {
classpath.append(':').append(library.getFile());
}
final List<String> command = new ArrayList<>();
command.add("java");
command.add("-cp");
command.add(classpath.toString());
command.add(this.compiler.config.getMainType());
command.addAll(this.compiler.config.getMainArgs());
return command.toArray(String.class);
}
use of dyvilx.tools.compiler.library.Library in project Dyvil by Dyvil.
the class DyvilCompiler method loadLibraries.
public void loadLibraries() {
final List<Library> libraries = this.config.libraries;
// Make sure to add the dyvil and java libraries at the end
libraries.add(Library.dyvilLibrary);
libraries.add(Library.javaLibrary);
final int libs = libraries.size();
final long startTime = System.nanoTime();
// Loads libraries
for (Library library : libraries) {
library.loadLibrary();
}
Package.initRoot(this);
final long endTime = System.nanoTime();
this.log(I18n.get("library.found", libs == 1 ? I18n.get("libraries.1") : I18n.get("libraries.n", libs), Util.toTime(endTime - startTime)));
}
use of dyvilx.tools.compiler.library.Library in project Dyvil by Dyvil.
the class Package method loadClass.
public static IClass loadClass(String fileName, Name name, IClassConsumer consumer) {
final DyvilCompiler compiler = rootPackage.compiler;
for (Library library : compiler.config.libraries) {
final InputStream inputStream = library.getInputStream(fileName);
if (inputStream != null) {
final ExternalClass externalClass = new ExternalClass(name);
consumer.addClass(externalClass);
return ClassReader.loadClass(compiler, externalClass, inputStream);
}
}
return null;
}
Aggregations