Commit 7db90a55 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Implement dup; Update the readme.

parent a683a499
......@@ -70,6 +70,17 @@ public enum StackMapType
return this != TOP && this != NOTHING;
}
/**
* Is this a valid type for storing of a value?
*
* @return {@code true} if this is not nothing or the top type.
* @since 2017/03/31
*/
public final boolean isValid()
{
return this != NOTHING && this != TOP;
}
/**
* Returns {@code true} if this is a wide type.
*
......
......@@ -427,6 +427,10 @@ final class __OpParser__
case ClassByteCodeIndex.NEW:
return __executeNew(pool.get(input.readUnsignedShort()).
<ClassNameSymbol>get(true, ClassNameSymbol.class));
// Duplicate variables
case ClassByteCodeIndex.DUP:
return __executeDup();
// {@squirreljme.error AY38 Defined operation cannot be
// used in Java ME programs. (The operation)}
......@@ -450,7 +454,6 @@ final class __OpParser__
case ClassByteCodeIndex.SASTORE:
case ClassByteCodeIndex.POP:
case ClassByteCodeIndex.POP2:
case ClassByteCodeIndex.DUP:
case ClassByteCodeIndex.DUP_X1:
case ClassByteCodeIndex.DUP_X2:
case ClassByteCodeIndex.DUP2:
......@@ -556,6 +559,37 @@ final class __OpParser__
}
}
/**
* Duplicates the topmost entry on the stack.
*
* @since 2017/03/31
*/
private int[] __executeDup()
{
// Get
__SMTState__ smwork = this._smwork;
__SMTStack__ stack = smwork._stack;
// Get the element on the top of the stack
int top = stack.top();
StackMapType tt = stack.get(top - 1);
// {@squirreljme.error AY0q The specified type cannot be duplicated
// on the stack. (The type at the top of the stack)}
if (!tt.isValid() || tt.isWide())
throw new ClassFormatException(String.format("AY0q %s", tt));
// Push this type to the top
stack.push(tt);
// Generate the copy
this.writer.copy(tt, CodeVariable.of(true, top - 1),
CodeVariable.of(true, top));
// Implicit next
return IMPLICIT_NEXT;
}
/**
* Executes an invoke of a method.
*
......
......@@ -30,28 +30,32 @@ Note that Java ME 8 has a Java 7 virtual machine with specific limitations.
## Repository
* [Online repository](http://multiphasicapps.net/)
* SquirrelJME uses `fossil` <http://fossil-scm.org/>.
* The repository may be cloned with:
([HTTPS](https://multiphasicapps.net/))
* SquirrelJME uses `fossil` <http://fossil-scm.org/>.
* The repository may be cloned with:
* One of these commands
* `fossil clone -u http://multiphasicapps.net/ squirreljme.fossil`
* `mkdir squireljme`
* `cd squirreljme`
* `fossil open ../squirreljme.fossil`
* Trunk Source Snapshot (`fossil serve` only):
* [TAR.GZ](/tarball/squirreljme-trunk.tar.gz?uuid=trunk)
* [ZIP](/zip/squirreljme-trunk.zip?uuid=trunk)
* Read-Only Mirrors:
* Bitbucket: <https://bitbucket.org/mpasteven/squirreljme>
* GitHub: <http://github.com/mpasteven/SquirrelJME>
* GitLab: <https://gitlab.com/mpasteven/SquirrelJME>
* Tor: <http://squirrelzarhffxz.onion/>
(`fossil clone -u http://squirrelzarhffxz.onion/ squirreljme.fossil`)
* `fossil clone -u https://multiphasicapps.net/ squirreljme.fossil`
* `mkdir squireljme`
* `cd squirreljme`
* `fossil open ../squirreljme.fossil`
* Trunk Source Snapshot (`fossil serve` only):
* [TAR.GZ](/tarball/squirreljme-trunk.tar.gz?uuid=trunk)
* [ZIP](/zip/squirreljme-trunk.zip?uuid=trunk)
* Read-Only Mirrors:
* Bitbucket: <https://bitbucket.org/mpasteven/squirreljme>
* GitHub: <https://github.com/mpasteven/SquirrelJME>
* GitLab: <https://gitlab.com/mpasteven/SquirrelJME>
* Tor: <http://squirrelzarhffxz.onion/>
(`fossil clone -u http://squirrelzarhffxz.onion/ squirreljme.fossil`)
## Documents
* [Code of Conduct](code-of-conduct.mkd)
* [Developer Notes](/uv/developer-notes/index.mkd)
* [Alternative URL](http://multiphasicapps.net/uv/developer-notes/index.mkd)
(Links to the main repository)
([HTTPS](https://multiphasicapps.net/uv/developer-notes/index.mkd);
Links to the main repository, do not follow via Tor use the direct link)
* [Manual](assets/manual/index.mkd)
* [Project Scope](scope.mkd)
* [Why?](assets/manual/user/why.mkd)
......
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