Skip to content

Commit c38ecc3

Browse files
committed
comments only
1 parent 74a42f4 commit c38ecc3

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed
15 Bytes
Binary file not shown.
15 Bytes
Binary file not shown.

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ public boolean visit(EnhancedForStatement node) {
529529

530530
/**
531531
* allow for primitive boxing or unboxing. See test.Test_Chars.java
532+
*
532533
* @param template
533534
* @param v
534535
* @param varName
@@ -538,19 +539,24 @@ public boolean visit(EnhancedForStatement node) {
538539
private void writeReplaceV(String template, String v, String varName, ITypeBinding vType, ITypeBinding eType) {
539540
String s = template.replace(v, varName);
540541
if (vType != eType) {
541-
if (!eType.isPrimitive()) {
542-
// So we know the expression is boxed -- Character, for example
543-
// Character does not use .objectValue, but we implement it here
544-
s += ".objectValue()";
545-
if (vType.getName().equals("int"))
542+
if (vType.isPrimitive()) {
543+
if (eType.isPrimitive()) {
544+
// this is a conversion of an char[] to an int -- the only
545+
// possibility allowed, I think
546546
s += CHARCODEAT0;
547-
} else if (!vType.isPrimitive()) {
547+
} else {
548+
// So we know the expression is boxed -- Character, for
549+
// example
550+
// Character does not use .objectValue, but we implement it
551+
// here
552+
if (vType.getName().equals("int"))
553+
s += ".intValue()";
554+
else
555+
s += ".objectValue()";
556+
}
557+
} else if (eType.isPrimitive()) {
548558
// So we know the expression is unboxed -- char, for example
549-
// but it could be Character to int
550559
s = "new " + getPrimitiveTYPE(eType.getName()) + s;
551-
} else {
552-
// this is a conversion of an char[] to an int -- the only possibility allowed, I think
553-
s += CHARCODEAT0;
554560
}
555561
}
556562
buffer.append(s);

0 commit comments

Comments
 (0)