forked from JavaTX/JavaCompilerCore
Fix up Character
This commit is contained in:
parent
e88d4428c5
commit
75b9020cf9
@ -1,3 +1,6 @@
|
||||
import java.lang.Character;
|
||||
|
||||
public class Literal {
|
||||
m() { return null; }
|
||||
m2() { return 'C'; }
|
||||
}
|
@ -136,7 +136,7 @@ public class Codegen {
|
||||
} else if (type.equals(TargetType.Short) || type.equals(TargetType.short_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
|
||||
} else if (type.equals(TargetType.Char) || type.equals(TargetType.char_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Char", "valueOf", "(C)Ljava/lang/Char;", false);
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ public class Codegen {
|
||||
} else if (type.equals(TargetType.Short)) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false);
|
||||
} else if (type.equals(TargetType.Char)) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Char", "charValue", "()C", false);
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ public class ASTFactory {
|
||||
} else if (type.getTypeName().equals("boolean")) {
|
||||
return new RefType(new JavaClassName("java.lang.Boolean"), new ArrayList<>(), new NullToken(), true);
|
||||
} else if (type.getTypeName().equals("char")) {
|
||||
return new RefType(new JavaClassName("java.lang.Char"), new ArrayList<>(), new NullToken(), true);
|
||||
return new RefType(new JavaClassName("java.lang.Character"), new ArrayList<>(), new NullToken(), true);
|
||||
} else if (type.getTypeName().equals("short")) {
|
||||
return new RefType(new JavaClassName("java.lang.Short"), new ArrayList<>(), new NullToken(), true);
|
||||
} else if (type.getTypeName().equals("double")) {
|
||||
|
@ -227,6 +227,8 @@ public class TYPEStmt implements StatementVisitor {
|
||||
private final RefType string = new RefType(ASTFactory.createClass(String.class).getClassName(), new NullToken());
|
||||
private final RefType bool = new RefType(ASTFactory.createClass(Boolean.class).getClassName(), new NullToken());
|
||||
|
||||
private final RefType charr = new RefType(ASTFactory.createClass(Character.class).getClassName(), new NullToken());
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
if (unaryExpr.operation == UnaryExpr.Operation.POSTDECREMENT || unaryExpr.operation == UnaryExpr.Operation.POSTINCREMENT || unaryExpr.operation == UnaryExpr.Operation.PREDECREMENT || unaryExpr.operation == UnaryExpr.Operation.PREINCREMENT) {
|
||||
@ -452,6 +454,10 @@ public class TYPEStmt implements StatementVisitor {
|
||||
constraintsSet.addUndConstraint(new Pair(literal.getType(), bool, PairOperator.EQUALSDOT));
|
||||
return;
|
||||
}
|
||||
if (literal.value instanceof Character) {
|
||||
constraintsSet.addUndConstraint(new Pair(literal.getType(), charr, PairOperator.EQUALSDOT));
|
||||
return;
|
||||
}
|
||||
if (literal.value != null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -824,6 +824,7 @@ public class TestComplete {
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
|
||||
assertNull(clazz.getDeclaredMethod("m").invoke(instance));
|
||||
assertEquals(clazz.getDeclaredMethod("m2").invoke(instance), 'C');
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user