Commit fad24f96 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Merge the fourth cherry pick, this should be the last one that is needed for now.

parents 162b4cfe 9a841acd
Pipeline #39262 passed with stages
in 7 minutes and 33 seconds
......@@ -57,8 +57,6 @@
<module name="squirreljme.modules.springcoat-vm.main" target="1.7" />
<module name="squirreljme.modules.springcoat-vm.test" target="1.7" />
<module name="squirreljme.modules.squirrel-quarrel.testFixtures" target="1.7" />
<module name="squirreljme.modules.strings.main" target="1.7" />
<module name="squirreljme.modules.strings.test" target="1.7" />
<module name="squirreljme.modules.strings.testFixtures" target="1.7" />
<module name="squirreljme.modules.summercoat-vm.main" target="1.7" />
<module name="squirreljme.modules.summercoat-vm.test" target="1.7" />
......@@ -105,4 +103,4 @@
<module name="squirreljme.utilities.test" target="1.7" />
</bytecodeTargetLevel>
</component>
</project>
</project>
\ No newline at end of file
......@@ -10,10 +10,7 @@
package cc.squirreljme.plugin.multivm;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.Callable;
import org.gradle.api.Project;
......
......@@ -16,7 +16,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.function.Function;
import org.gradle.api.Action;
import org.gradle.api.Task;
import org.gradle.api.tasks.SourceSet;
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......
......@@ -12,7 +12,6 @@ package cc.squirreljme.vm.springcoat;
import cc.squirreljme.jdwp.JDWPState;
import cc.squirreljme.jdwp.JDWPValue;
import cc.squirreljme.jdwp.views.JDWPViewFrame;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.lang.ref.Reference;
/**
......
......@@ -13,7 +13,6 @@ import cc.squirreljme.jdwp.JDWPState;
import cc.squirreljme.jdwp.JDWPStepTracker;
import cc.squirreljme.jdwp.JDWPThreadSuspension;
import cc.squirreljme.jdwp.views.JDWPViewThread;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.lang.ref.Reference;
import java.util.Arrays;
import java.util.Collections;
......
......@@ -14,7 +14,6 @@ import cc.squirreljme.jdwp.JDWPState;
import cc.squirreljme.jdwp.JDWPValue;
import cc.squirreljme.jdwp.trips.JDWPTripBreakpoint;
import cc.squirreljme.jdwp.views.JDWPViewType;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.springcoat.exceptions.SpringNoSuchFieldException;
import cc.squirreljme.vm.springcoat.exceptions.SpringNoSuchMethodException;
import java.lang.ref.Reference;
......
......@@ -17,7 +17,6 @@ import cc.squirreljme.jvm.mle.constants.MemoryProfileType;
import cc.squirreljme.jvm.mle.constants.VMDescriptionType;
import cc.squirreljme.jvm.mle.constants.VMStatisticType;
import cc.squirreljme.jvm.mle.constants.VMType;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.lang.LineEndingUtils;
import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;
......
......@@ -20,7 +20,6 @@ import cc.squirreljme.jvm.mle.brackets.VMThreadBracket;
import cc.squirreljme.jvm.mle.constants.ThreadModelType;
import cc.squirreljme.jvm.mle.constants.ThreadStatusType;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.springcoat.brackets.TaskObject;
import cc.squirreljme.vm.springcoat.brackets.VMThreadObject;
import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;
......
......@@ -31,6 +31,7 @@ public class MethodInvokeException
* Initializes the invoked exception.
*
* @param __message The message.
* @param __message The message.
* @param __exception The exception that was tossed.
* @param __stackTrace The stack trace for this call.
* @throws NullPointerException On null arguments.
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......
......@@ -9,13 +9,15 @@
package cc.squirreljme.vm.summercoat;
import cc.squirreljme.emulator.profiler.ProfiledThread;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SupervisorPropertyIndex;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import cc.squirreljme.emulator.vm.VMException;
import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.InvalidInstructionException;
import dev.shadowtail.classfile.nncc.NativeCode;
......@@ -29,8 +31,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Deque;
import java.util.LinkedList;
import cc.squirreljme.emulator.profiler.ProfiledThread;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
/**
* This represents a native CPU which may run within its own thread to
......
......@@ -9,12 +9,10 @@
package cc.squirreljme.vm.summercoat;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.SummerCoatJarLibrary;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import dev.shadowtail.jarfile.JarMinimizer;
import cc.squirreljme.vm.SummerCoatJarLibrary;
import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
......
......@@ -10,15 +10,16 @@
package cc.squirreljme.vm.summercoat;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMFactory;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VMThreadModel;
import cc.squirreljme.emulator.vm.VirtualMachine;
import cc.squirreljme.jdwp.JDWPFactory;
import cc.squirreljme.jvm.config.ConfigRomKey;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMFactory;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VirtualMachine;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import dev.shadowtail.packfile.MinimizedPackHeader;
......@@ -32,7 +33,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
/**
* This is the factory which is capable of creating instances of the
......
......@@ -13,12 +13,14 @@ import cc.squirreljme.jvm.aot.Backend;
import cc.squirreljme.jvm.aot.CompileSettings;
import cc.squirreljme.jvm.aot.LinkGlob;
import cc.squirreljme.jvm.aot.RomSettings;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.SummerCoatJarLibrary;
import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.packfile.PackMinimizer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Arrays;
/**
......@@ -55,6 +57,17 @@ public class SummerCoatBackend
}
}
/**
* {@inheritDoc}
* @since 2021/07/18
*/
@Override
public void dumpGlob(byte[] __inGlob, String __name, PrintStream __out)
throws IOException, NullPointerException
{
throw Debugging.todo();
}
/**
* {@inheritDoc}
* @since 2020/11/22
......
......@@ -11,7 +11,6 @@ package cc.squirreljme.jvm.aot.summercoat;
import cc.squirreljme.jvm.aot.CompileSettings;
import cc.squirreljme.jvm.aot.LinkGlob;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.InMemoryClassLibrary;
import dev.shadowtail.jarfile.JarMinimizer;
import java.io.ByteArrayOutputStream;
......
......@@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Collection;
import java.util.ServiceLoader;
/**
......@@ -44,6 +43,20 @@ public interface Backend
String __name, InputStream __in, OutputStream __out)
throws IOException, NullPointerException;
/**
* Dumps the glob that was compiled to a text based format for
* decompilation or otherwise.
*
* @param __inGlob The input glob to dump.
* @param __name The name of the glob.
* @param __out Where the output goes.
* @throws IOException On read errors.
* @throws NullPointerException On null arguments.
* @since 2021/05/16
*/
void dumpGlob(byte[] __inGlob, String __name, PrintStream __out)
throws IOException, NullPointerException;
/**
* Creates a glob that is used for linking compiled classes together.
*
......
......@@ -17,6 +17,8 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
......@@ -111,17 +113,26 @@ public class Main
// Find the backend to use
Backend backend = Main.findBackend(compiler);
// Use explicit input/output
try (InputStream in = new StandardInputStream();
OutputStream out = System.out)
{
// Which mode should occur?
switch (mode)
{
// Compile code
case "compile":
Main.mainCompile(backend, name, args);
Main.mainCompile(backend, in, out, name, args);
break;
// Dump the result of "compile"
case "dumpCompile":
Main.dumpCompile(backend, in, out, name);
break;
// Link multiple libraries into one
case "rom":
Main.mainRom(backend, args);
Main.mainRom(backend, out, args);
break;
// {@squirreljme.error AE02 Unknown mode. (The mode)}
......@@ -129,32 +140,86 @@ public class Main
throw new IllegalArgumentException("AE02 " + mode);
}
}
}
/**
* Dumps the result of the compilation to a readable text format used
* for debugging.
*
* @param __backend The backend to use.
* @param __inGlob The input glob.
* @param __out Where to write the output.
* @param __name The name of the Glob.
* @throws IOException On read/write errors.
* @throws NullPointerException On null arguments.
* @since 2021/05/16
*/
private static void dumpCompile(Backend __backend, InputStream __inGlob,
OutputStream __out, String __name)
throws IOException, NullPointerException
{
if (__backend == null || __inGlob == null || __out == null ||
__name == null)
throw new NullPointerException("NARG");
// Read in the entire contents of the data
byte[] dump;
try (InputStream in = __inGlob;
ByteArrayOutputStream baos = new ByteArrayOutputStream(
Math.max(4096, __inGlob.available())))
{
// Load in a copy
byte[] buf = new byte[8192];
for (;;)
{
int rc = in.read(buf);
// EOF?
if (rc < 0)
break;
baos.write(buf, 0, rc);
}
// Write output
dump = baos.toByteArray();
}
// Dump the output
try (PrintStream out = new PrintStream(__out, true))
{
__backend.dumpGlob(dump, __name, out);
}
}
/**
* Handles the main compilation stage.
*
* @param __backend The backend to use.
* @param __inZip The input stream of the input ZIP.
* @param __outGlob The output stream of the Glob.
* @param __name The name of the library.
* @param __args The arguments to use.
* @throws IOException On read errors.
* @throws NullPointerException On null arguments.
* @since 2020/11/22
*/
private static void mainCompile(Backend __backend, String __name,
Deque<String> __args)
private static void mainCompile(Backend __backend, InputStream __inZip,
OutputStream __outGlob, String __name, Deque<String> __args)
throws IOException, NullPointerException
{
if (__backend == null || __name == null || __args == null)
if (__backend == null || __name == null || __args == null ||
__inZip == null || __outGlob == null)
throw new NullPointerException("NARG");
// Parse compilation arguments
CompileSettings settings = CompileSettings.parse(__args);
// Setup glob for final linking
LinkGlob glob = __backend.linkGlob(settings, __name, System.out);
LinkGlob glob = __backend.linkGlob(settings, __name, __outGlob);
// Read input JAR and perform inline compilation
try (InputStream in = new StandardInputStream();
try (InputStream in = __inZip;
ZipStreamReader zip = new ZipStreamReader(in))
{
// Process JAR entries and compile them into individual class
......@@ -204,15 +269,17 @@ public class Main
* Links the ROM together as one.
*
* @param __backend The backend to use.
* @param __out Where the resultant ROM is to be written.
* @param __args The arguments to the ROM linking.
* @throws IOException On read/write errors.
* @throws NullPointerException On null arguments.
* @since 2020/11/27
*/
public static void mainRom(Backend __backend, Deque<String> __args)
public static void mainRom(Backend __backend, OutputStream __out,
Deque<String> __args)
throws IOException, NullPointerException
{
if (__backend == null || __args == null)
if (__backend == null || __args == null || __out == null)
throw new NullPointerException("NARG");
// Parse rom arguments
......@@ -239,7 +306,7 @@ public class Main
throw new IllegalArgumentException("AE08");
// Perform combined linking
__backend.rom(settings, System.out,
__backend.rom(settings, __out,
libs.toArray(new VMClassLibrary[libs.size()]));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment