Commit 2ad08487 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

More cherry picking.

parent 8df84618
......@@ -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
// -*- 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>
......
......@@ -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>
......
......@@ -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()]));
}
}
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......
......@@ -22,7 +22,7 @@ public final class JavaManifestKey
protected final String string;
/** The actual input string. */
protected final String inputstring;
protected final String inputString;
/**
* Initializes the manifest key using the given string.
......@@ -45,7 +45,7 @@ public final class JavaManifestKey
this.string = sb.toString();
// Remember input string for case purposes
this.inputstring = __s;
this.inputString = __s;
}
/**
......@@ -81,7 +81,7 @@ public final class JavaManifestKey
*/
public String inputString()
{
return this.inputstring;
return this.inputString;
}
/**
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
......
......@@ -19,6 +19,7 @@ import java.lang.annotation.Target;
/**
* Indicates the API level of the native call.
*
* @deprecated This is SquirrelJME specific and is no longer used.
* @since 2018/12/05
*/
@Documented
......@@ -26,6 +27,7 @@ import java.lang.annotation.Target;
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
ElementType.PARAMETER, ElementType.TYPE})
@Deprecated
public @interface Api
{
/** @return The API level. */
......
......@@ -27,10 +27,10 @@ public interface DataInput
float readFloat()
throws IOException;
void readFully(byte[] __a)
void readFully(byte[] __b)
throws IOException;
void readFully(byte[] __a, int __b, int __c)
void readFully(byte[] __b, int __o, int __l)
throws IOException;
int readInt()
......
......@@ -247,11 +247,12 @@ public final class Class<T>
/**
* Checks if the given class can be assigned to this one, the check is
* in the same order as {code instanceOf Object} that is
* {@code a.getClass().isAssignableFrom(b.getClass()) == (a instanceof b)}.
* in the same order as {@code instanceof Object} that is
* {@code b.getClass().isAssignableFrom(a.getClass()) == (a instanceof b)}
* and {@code (Class<B>)a} does not throw {@link ClassCastException}.
*
* @param __cl The other class type.
* @return If the otehr class can be assigned to this one.
* @return If the other class can be assigned to this one.
* @throws NullPointerException On null arguments.
* @since 2018/09/27
*/
......
......@@ -52,7 +52,8 @@ public class Object
TypeShelf.objectType(this), len);
// Copy everything over
System.arraycopy(this, 0, dest, 0, len);
System.arraycopy(this, 0,
dest, 0, len);
// This array was cloned
return dest;
......
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package lang;
import net.multiphasicapps.tac.TestRunnable;
/**
* Tests array instances and such.
*
* @since 2021/02/07
*/
public class TestArrayInstance
extends TestRunnable
{
/**
* {@inheritDoc}
* @since 2021/02/07
*/
@SuppressWarnings({"ConstantConditions", "RedundantCast"})
@Override
public void test()
throws Throwable
{
super.secondary("same",
(Object)new Integer[0] instanceof Integer[]);
super.secondary("different",
(Object)new Long[0] instanceof Integer[]);
super.secondary("super-compatible",
(Object)new Integer[0] instanceof Number[]);
super.secondary("super-incompatible",
(Object)new String[0] instanceof Number[]);
// Baseline
super.secondary("lower-dims-not-object",
(Object)new Integer[0] instanceof Integer[][]);
super.secondary("higher-dims-not-object",
(Object)new Integer[0][0] instanceof Integer[]);
super.secondary("same-dims-non-to-object",
(Object)new Object[0][0] instanceof Integer[][]);
super.secondary("lower-dims-non-to-object",
(Object)new Object[0] instanceof Integer[][]);
super.secondary("lower-dims-non-to-pure-object",
(Object)new Object() instanceof Integer[][]);
super.secondary("higher-dims-to-object",
(Object)new Object[0][0] instanceof Object[]);
// Inverted
super.secondary("lower-dims-not-object-invert",
(Object)new Integer[0][0] instanceof Integer[]);
super.secondary("higher-dims-not-object-invert",
(Object)new Integer[0] instanceof Integer[][]);
super.secondary("same-dims-non-to-object-invert",
(Object)new Integer[0][0] instanceof Object[][]);
super.secondary("lower-dims-non-to-object-invert",
(Object)new Integer[0][0] instanceof Object[]);
super.secondary("lower-dims-non-to-pure-object-invert",
(Object)new Integer[0][0] instanceof Object);
super.secondary("higher-dims-to-object-invert",
(Object)new Object[0] instanceof Object[][]);
}
}
......@@ -9,7 +9,6 @@
package lang;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.util.Arrays;
import java.util.Objects;
import net.multiphasicapps.tac.TestConsumer;
......
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package lang.interfaces;
/**
* Abstract class that implements A but does not declare a method.
*
* @since 2021/02/19
*/
public abstract class AbstractImplANoMethod
implements InterfaceA
{
}
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package lang.interfaces;
/**
* Extends the abstract method but implements the method.
*
* @since 2021/02/19
*/
public class ImplAbstractImplAWithMethod
extends AbstractImplANoMethod
{
/**
* {@inheritDoc}
* @since 2021/02/19
*/
@Override
public int methodA()
{
return 13;
}
}
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package lang.interfaces;
/**
* Implements interface method A.
*
* @since 2021/02/14
*/
public class ImplementsA
implements InterfaceA
{
/**
* {@inheritDoc}
* @since 2021/02/04
*/
@Override
public int methodA()
{
return 90;
}
}
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