mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fixes System.arraycopy behavior when src == dest
This commit is contained in:
parent
6c599c2886
commit
8e99b4589e
|
@ -74,9 +74,17 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin {
|
|||
String dest = context.getParameterName(3);
|
||||
String destPos = context.getParameterName(4);
|
||||
String length = context.getParameterName(5);
|
||||
writer.append("if (" + src + " !== " + dest + " || " + destPos + " < " + srcPos + ") {").indent().newLine();
|
||||
writer.append("for (var i = 0; i < " + length + "; i = (i + 1) | 0) {").indent().softNewLine();
|
||||
writer.append(dest + ".data[" + destPos + "++] = " + src + ".data[" + srcPos + "++];").softNewLine();
|
||||
writer.outdent().append("}").softNewLine();
|
||||
writer.outdent().append("} else {").indent().softNewLine();
|
||||
writer.append(srcPos + " = (" + srcPos + " + " + length + ") | 0;").softNewLine();
|
||||
writer.append(destPos + " = (" + destPos + " + " + length + ") | 0;").softNewLine();
|
||||
writer.append("for (var i = 0; i < " + length + "; i = (i + 1) | 0) {").indent().softNewLine();
|
||||
writer.append(dest + ".data[--" + destPos + "] = " + src + ".data[--" + srcPos + "];").softNewLine();
|
||||
writer.outdent().append("}").softNewLine();
|
||||
writer.outdent().append("}").softNewLine();
|
||||
}
|
||||
|
||||
private void generateCurrentTimeMillis(SourceWriter writer) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue
Block a user