Fix Eclipse plugin descriptor
This commit is contained in:
Alexey Andreev 2015-01-13 19:17:18 +04:00
parent eeddfd1298
commit b3a41892a3
8 changed files with 45 additions and 31 deletions

View File

@ -29,6 +29,10 @@
<name>TeaVM Java class library</name>
<description>TeaVM Java class library emulation</description>
<properties>
<teavm.classlib.test.incremental>false</teavm.classlib.test.incremental>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
@ -93,6 +97,7 @@
<properties>
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
</properties>
<incremental>${teavm.classlib.test.incremental}</incremental>
</configuration>
</execution>
</executions>

View File

@ -25,6 +25,7 @@ import org.teavm.javascript.ni.InjectedBy;
*/
public class TClass<T> extends TObject {
TString name;
TString binaryName;
boolean primitive;
boolean array;
boolean isEnum;
@ -42,7 +43,7 @@ public class TClass<T> extends TObject {
public native boolean isAssignableFrom(TClass<?> obj);
public TString getName() {
return new TString(name);
return name;
}
public boolean isPrimitive() {

View File

@ -51,7 +51,7 @@ public class TObject {
@Rename("toString")
public TString toString0() {
return TString.wrap(getClass().getName() + "@" + identity());
return TString.wrap(getClass().getName() + "@" + TInteger.toHexString(identity()));
}
@GeneratedBy(ObjectNativeGenerator.class)

View File

@ -26,6 +26,9 @@ public class ClassTest {
@Test
public void classNameEvaluated() {
assertEquals("java.lang.Object", Object.class.getName());
assertEquals("[Ljava.lang.Object;", Object[].class.getName());
assertEquals("int", int.class.getName());
assertEquals("[I", int[].class.getName());
}
@Test

View File

@ -60,4 +60,11 @@ public class ObjectTest {
public void properInstanceDetected() {
assertTrue(Object.class.isInstance(new Object()));
}
@Test
public void toStringWorks() {
assertTrue(new Object().toString().startsWith("java.lang.Object@"));
assertTrue(new Object[2].toString().startsWith("[Ljava.lang.Object;@"));
assertTrue(new byte[3].toString().startsWith("[B@"));
}
}

View File

@ -178,6 +178,12 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
.append("clsProto.$meta.name").ws().append("!==").ws().append("undefined").ws().append("?").ws()
.append("$rt_str(clsProto.$meta.name)").ws().append(":").ws().append("null;").softNewLine();
}
if (classSource.get(classClass).getField("name") != null) {
writer.append("cls.").appendField(new FieldReference(classClass, "binaryName")).ws().append("=").ws()
.append("clsProto.$meta.binaryName").ws().append("!==").ws().append("undefined").ws()
.append("?").ws()
.append("$rt_str(clsProto.$meta.binaryName)").ws().append(":").ws().append("null;").softNewLine();
}
if (classSource.get(classClass).getField("primitive") != null) {
writer.append("cls.").appendField(new FieldReference(classClass, "primitive"))
.append(" = clsProto.$meta.primitive ? 1 : 0;").newLine();

View File

@ -128,7 +128,9 @@ function $rt_arraycls(cls) {
str += "]";
return str;
}
arraycls.$meta = { item : cls, supertypes : [$rt_objcls()], primitive : false, superclass : $rt_objcls() };
var name = "[" + cls.$meta.binaryName;
arraycls.$meta = { item : cls, supertypes : [$rt_objcls()], primitive : false, superclass : $rt_objcls(),
name : name, binaryName : name };
cls.$array = arraycls;
}
return cls.$array;
@ -140,84 +142,73 @@ function $rt_createcls() {
}
};
}
function $rt_createPrimitiveCls(name, binaryName) {
var cls = $rt_createcls();
cls.$meta.primitive = true;
cls.$meta.name = name;
cls.$meta.binaryName = binaryName;
return cls;
}
var $rt_booleanclsCache = null;
function $rt_booleancls() {
if ($rt_booleanclsCache === null) {
$rt_booleanclsCache = $rt_createcls();
$rt_booleanclsCache.primitive = true;
$rt_booleanclsCache.name = "boolean";
$rt_booleanclsCache = $rt_createPrimitiveCls("boolean", "Z");
}
return $rt_booleanclsCache;
}
var $rt_charclsCache = null;
function $rt_charcls() {
if ($rt_charclsCache === null) {
$rt_charclsCache = $rt_createcls();
$rt_charclsCache.primitive = true;
$rt_charclsCache.name = "char";
$rt_charclsCache = $rt_createPrimitiveCls("char", "C");
}
return $rt_charclsCache;
}
var $rt_byteclsCache = null;
function $rt_bytecls() {
if ($rt_byteclsCache === null) {
$rt_byteclsCache = $rt_createcls();
$rt_byteclsCache.primitive = true;
$rt_byteclsCache.name = "byte";
$rt_byteclsCache = $rt_createPrimitiveCls("byte", "B");
}
return $rt_byteclsCache;
}
var $rt_shortclsCache = null;
function $rt_shortcls() {
if ($rt_shortclsCache === null) {
$rt_shortclsCache = $rt_createcls();
$rt_shortclsCache.primitive = true;
$rt_shortclsCache.name = "short";
$rt_shortclsCache = $rt_createPrimitiveCls("short", "S");
}
return $rt_shortclsCache;
}
var $rt_intclsCache = null;
function $rt_intcls() {
if ($rt_intclsCache === null) {
$rt_intclsCache = $rt_createcls();
$rt_intclsCache.primitive = true;
$rt_intclsCache.name = "int";
$rt_intclsCache = $rt_createPrimitiveCls("int", "I");
}
return $rt_intclsCache;
}
var $rt_longclsCache = null;
function $rt_longcls() {
if ($rt_longclsCache === null) {
$rt_longclsCache = $rt_createcls();
$rt_longclsCache.primitive = true;
$rt_longclsCache.name = "long";
$rt_longclsCache = $rt_createPrimitiveCls("long", "J");
}
return $rt_longclsCache;
}
var $rt_floatclsCache = null;
function $rt_floatcls() {
if ($rt_floatclsCache === null) {
$rt_floatclsCache = $rt_createcls();
$rt_floatclsCache.primitive = true;
$rt_floatclsCache.name = "float";
$rt_floatclsCache = $rt_createPrimitiveCls("float", "F");
}
return $rt_floatclsCache;
}
var $rt_doubleclsCache = null;
function $rt_doublecls() {
if ($rt_doubleclsCache === null) {
$rt_doubleclsCache = $rt_createcls();
$rt_doubleclsCache.primitive = true;
$rt_doubleclsCache.name = "double";
$rt_doubleclsCache = $rt_createPrimitiveCls("double", "D");
}
return $rt_doubleclsCache;
}
var $rt_voidclsCache = null;
function $rt_voidcls() {
if ($rt_voidclsCache === null) {
$rt_voidclsCache = $rt_createcls();
$rt_voidclsCache.primitive = true;
$rt_voidclsCache.name = "void";
$rt_voidclsCache = $rt_createPrimitiveCls("void", "V");
}
return $rt_voidclsCache;
}
@ -383,6 +374,7 @@ function $rt_declClass(cls, data) {
cls.prototype = new Object();
}
cls.$meta.name = data.name;
cls.$meta.binaryName = "L" + data.name + ";";
cls.$meta.enum = data.enum;
cls.prototype.constructor = cls;
cls.$clinit = data.clinit;

View File

@ -6,7 +6,7 @@ Bundle-Version: 0.3.0.qualifer
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .,
lib/asm-debug-all-4.0.3.jar,
lib/asm-debug-all-5.0.3.jar,
lib/cdi-api-1.2.jar,
lib/commons-io-2.4.jar,
lib/jackson-core-asl-1.9.13.jar,