mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix some bugs
This commit is contained in:
parent
dd25ae4759
commit
71195c04ce
|
@ -64,8 +64,9 @@ public class TObject {
|
|||
.getPlatformClass().getMetadata().getArrayItem() == null) {
|
||||
throw new TCloneNotSupportedException();
|
||||
}
|
||||
Platform.getPlatformObject(this).setId(Platform.nextObjectId());
|
||||
return Platform.clone(this);
|
||||
Object result = Platform.clone(this);
|
||||
Platform.getPlatformObject(result).setId(Platform.nextObjectId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Rename("notify")
|
||||
|
|
|
@ -47,6 +47,15 @@ public final class TSystem extends TObject {
|
|||
}
|
||||
if (srcType != targetType) {
|
||||
if (!srcType.isPrimitive() && !targetType.isPrimitive()) {
|
||||
Object[] srcArray = (Object[])(Object)src;
|
||||
int pos = srcPos;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
Object elem = srcArray[pos++];
|
||||
if (!targetType.isInstance(elem)) {
|
||||
doArrayCopy(src, srcPos, dest, destPos, i);
|
||||
throw new TArrayStoreException();
|
||||
}
|
||||
}
|
||||
doArrayCopy(src, srcPos, dest, destPos, length);
|
||||
return;
|
||||
} else if (!srcType.isPrimitive() || !targetType.isPrimitive()) {
|
||||
|
|
|
@ -35,13 +35,10 @@ package org.teavm.classlib.java.util;
|
|||
import java.util.Arrays;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import org.teavm.classlib.java.io.TSerializable;
|
||||
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||
import org.teavm.classlib.java.lang.TIllegalStateException;
|
||||
import org.teavm.classlib.java.lang.TObject;
|
||||
import org.teavm.classlib.java.lang.*;
|
||||
import org.teavm.javascript.spi.Rename;
|
||||
|
||||
public class THashMap<K, V> extends TAbstractMap<K, V> implements TSerializable {
|
||||
public class THashMap<K, V> extends TAbstractMap<K, V> implements TCloneable, TSerializable {
|
||||
transient int elementCount;
|
||||
transient HashEntry<K, V>[] elementData;
|
||||
transient int modCount = 0;
|
||||
|
|
|
@ -109,7 +109,7 @@ class TDecomposedCharSet extends TJointSet {
|
|||
* Read testString until we met a decomposed char boundary and
|
||||
* decompose obtained portion of testString
|
||||
*/
|
||||
while ((readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH) && !TLexer.isDecomposedCharBoundary(curChar)) {
|
||||
while ((readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH)) {
|
||||
|
||||
if (TLexer.hasDecompositionNonNullCanClass(curChar)) {
|
||||
|
||||
|
@ -146,30 +146,6 @@ class TDecomposedCharSet extends TJointSet {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some optimization since length of decomposed char is <= 3 usually
|
||||
*/
|
||||
switch (readCodePoints) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
|
||||
case 3:
|
||||
int i1 = TLexer.getCanonicalClass(decCodePoint[1]);
|
||||
int i2 = TLexer.getCanonicalClass(decCodePoint[2]);
|
||||
|
||||
if ((i2 != 0) && (i1 > i2)) {
|
||||
i1 = decCodePoint[1];
|
||||
decCodePoint[1] = decCodePoint[2];
|
||||
decCodePoint[2] = i1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
decCodePoint = TLexer.getCanonicalOrder(decCodePoint, readCodePoints);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare decomposedChar with decomposed char that was just read from
|
||||
* testString
|
||||
|
|
|
@ -146,12 +146,6 @@ class TLexer {
|
|||
|
||||
// table that contains canonical decomposition mappings
|
||||
private static TIntArrHash decompTable = null;
|
||||
|
||||
// table that contains canonical combining classes
|
||||
private static TIntHash canonClassesTable = null;
|
||||
|
||||
private static int canonClassesTableSize;
|
||||
|
||||
/*
|
||||
* Table that contains information about Unicode codepoints with single
|
||||
* codepoint decomposition
|
||||
|
@ -330,51 +324,6 @@ class TLexer {
|
|||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rearrange codepoints according to canonical order.
|
||||
*
|
||||
* @param inputInts
|
||||
* - array that contains Unicode codepoints
|
||||
* @param length
|
||||
* - index of last Unicode codepoint plus 1
|
||||
*
|
||||
* @return array that contains rearranged codepoints.
|
||||
*/
|
||||
static int[] getCanonicalOrder(int[] inputInts, int length) {
|
||||
int inputLength = (length < inputInts.length) ? length : inputInts.length;
|
||||
|
||||
/*
|
||||
* Simple bubble-sort algorithm. Note that many codepoints have 0
|
||||
* canonical class, so this algorithm works almost lineary in
|
||||
* overwhelming majority of cases. This is due to specific of Unicode
|
||||
* combining classes and codepoints.
|
||||
*/
|
||||
for (int i = 1; i < inputLength; i++) {
|
||||
int j = i - 1;
|
||||
int iCanonicalClass = getCanonicalClass(inputInts[i]);
|
||||
int ch;
|
||||
|
||||
if (iCanonicalClass == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (j > -1) {
|
||||
if (getCanonicalClass(inputInts[j]) > iCanonicalClass) {
|
||||
j = j - 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ch = inputInts[i];
|
||||
for (int k = i; k > j + 1; k--) {
|
||||
inputInts[k] = inputInts[k - 1];
|
||||
}
|
||||
inputInts[j + 1] = ch;
|
||||
}
|
||||
|
||||
return inputInts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reread current character, may be require if previous token changes mode
|
||||
|
@ -1062,20 +1011,6 @@ class TLexer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets canonical class for given codepoint from decomposition mappings
|
||||
* table.
|
||||
*
|
||||
* @param - ch Unicode codepoint
|
||||
* @return canonical class for given Unicode codepoint that is represented
|
||||
* by ch.
|
||||
*/
|
||||
static int getCanonicalClass(int ch) {
|
||||
int canClass = canonClassesTable.get(ch);
|
||||
|
||||
return (canClass == canonClassesTableSize) ? 0 : canClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if given codepoint is a canonical decomposition of another
|
||||
* codepoint.
|
||||
|
@ -1126,23 +1061,6 @@ class TLexer {
|
|||
return high;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Unicode codepoint if it is a boundary of decomposed Unicode
|
||||
* codepoint.
|
||||
*
|
||||
* @param ch
|
||||
* - Unicode codepoint to test
|
||||
* @return true if given codepoint is a boundary.
|
||||
*/
|
||||
static boolean isDecomposedCharBoundary(int ch) {
|
||||
int canClass = canonClassesTable.get(ch);
|
||||
|
||||
// Lexer.getCanonicalClass(ch) == 0
|
||||
boolean isBoundary = (canClass == canonClassesTableSize);
|
||||
|
||||
return isBoundary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the curr. character index.
|
||||
*/
|
||||
|
|
|
@ -561,8 +561,7 @@ public final class TPattern implements Serializable {
|
|||
} else {
|
||||
readCodePoints++;
|
||||
|
||||
while ((readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH) && !lexemes.isEmpty() && lexemes.isLetter() &&
|
||||
!TLexer.isDecomposedCharBoundary(lexemes.peek())) {
|
||||
while ((readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH) && !lexemes.isEmpty() && lexemes.isLetter()) {
|
||||
codePoints[readCodePoints++] = lexemes.next();
|
||||
}
|
||||
|
||||
|
|
|
@ -383,6 +383,7 @@ function $rt_declClass(cls, data) {
|
|||
m.binaryName = "L" + data.name + ";";
|
||||
m.enum = data.enum;
|
||||
m.item = null;
|
||||
m.primitive = false;
|
||||
cls.prototype.constructor = cls;
|
||||
cls.classObject = null;
|
||||
cls.$clinit = data.clinit ? data.clinit : function() {};
|
||||
|
|
|
@ -23,9 +23,9 @@ import org.teavm.jso.JSObject;
|
|||
* @author Alexey Andreev
|
||||
*/
|
||||
public interface PlatformConsole extends JSObject {
|
||||
@JSMethod("rt_putStdout")
|
||||
@JSMethod("$rt_putStdout")
|
||||
void output(int b);
|
||||
|
||||
@JSMethod("rt_putStderr")
|
||||
@JSMethod("$rt_putStderr")
|
||||
void error(int b);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class PlatformGenerator implements Generator, Injector, DependencyPlugin
|
|||
method.getResult().propagate(agent.getType("java.lang.Class"));
|
||||
return;
|
||||
case "clone":
|
||||
method.getVariable(0).connect(method.getResult());
|
||||
method.getVariable(1).connect(method.getResult());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user