Skip to content

Commit e6fe1a8

Browse files
committed
java2script and SwingJS
slightly better (byte) = (byte) where we do not need integer conversion. various collected changes
1 parent a8dbbda commit e6fe1a8

File tree

13 files changed

+55
-32
lines changed

13 files changed

+55
-32
lines changed
18.3 KB
Binary file not shown.
49 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200225000007
1+
20200227134114
18.3 KB
Binary file not shown.
49 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200225000007
1+
20200227134114

sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class CorePlugin extends Plugin {
3030
// if you change the x.x.x number, be sure to also indicate that in
3131
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3232

33+
// BH 2020.02.26 -- 3.2.9-v1b allows (byte) = (byte) to not use |0
3334
// BH 2020.02.20 -- 3.2.9-v1a reverses c,args order in new_(c,args,...) when both have expressions
3435
// BH 2020.02.18 -- 3.2.8-v2 fixes import static missing $I$ defs.
3536
// BH 2020.02.05 -- 3.2.8-v1 reworking of functional interfaces; no longer unqualified

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137137

138-
//BH 2020.02.18 -- 3.2.9-v1a order of 1st two parameters in new_ should be reversed
138+
//BH 2020.02.26 -- 3.2.9-v1b allows (byte) = (byte) to not use |0
139+
//BH 2020.02.20 -- 3.2.9-v1a order of 1st two parameters in new_ should be reversed
139140
//BH 2020.02.18 -- 3.2.8-v2 fixes no-argument call to varargs constructor
140141
//BH 2020.02.18 -- 3.2.8-v2 fixes import static missing $I$ defs
141142
//BH 2020.02.05 -- 3.2.8-v1 reworking of functional interfaces; no longer unqualified
@@ -4503,29 +4504,38 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
45034504
// double, float
45044505
break;
45054506
case "long":
4506-
if (!fromIntType || isDiv) {
4507+
if (isDiv || !fromIntType) {
45074508
more = "|0)";
45084509
addParens = true;
45094510
} else {
45104511
left = null;
45114512
}
45124513
break;
45134514
case "int":
4514-
if (!isDiv && (op != null && (!isDiv && fromIntType) || fromChar || rightName.equals("short")
4515-
|| rightName.equals("byte"))) {
4515+
if (!isDiv && (op != null && fromIntType
4516+
|| fromChar
4517+
|| rightName.equals("short")
4518+
|| rightName.equals("byte")
4519+
)
4520+
) {
45164521
left = null;
45174522
} else {
45184523
more = "|0)";
45194524
addParens = true;
45204525
}
45214526
break;
45224527
case "short":
4523-
if ((rightName.equals("short") || rightName.equals("byte")) && !isDiv) {
4528+
if (!isDiv && (rightName.equals("short") || rightName.equals("byte"))) {
45244529
left = null;
45254530
break;
45264531
}
45274532
//$FALL-THROUGH$
45284533
case "byte":
4534+
//
4535+
if (!isDiv && rightName.equals("byte")) {
4536+
left = null;
4537+
break;
4538+
}
45294539
if (temp_processingArrayIndex) {
45304540
more = "|0)";
45314541
addParens = true;
@@ -4540,7 +4550,6 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
45404550
if (isAssignment && left == null) {
45414551
buffer.append(op);
45424552
}
4543-
// buffer.append("OP_" + op + " " + isAssignment + " left=" + left + "PREFIX_" + prefix + "_PREFIX");
45444553
buffer.append(prefix);
45454554
if (classIntArray != null) {
45464555
if (addParens)
@@ -4567,13 +4576,17 @@ private boolean addPrimitiveTypedExpression(Expression left, IVariableBinding as
45674576
buffer.append(")");
45684577
}
45694578
if (classIntArray != null) {
4570-
// this is necessary because in JavaScript, (a=3.5) will be 3.5, not
4571-
// a:
4579+
// this is necessary because in JavaScript,
45724580
// a = new Int8Array(1)
4573-
// (a[0]=3.4, a[0])
4574-
// 3
4581+
// (a[0]=3.4) will be 3.4, not 3:
4582+
//
45754583
// (a[0]=3.4)
45764584
// 3.4
4585+
//
4586+
// so we need:
4587+
//
4588+
// (a[0]=3.4, a[0])
4589+
// 3
45774590
buffer.append(", ").append(classIntArray);
45784591
if (addParens)
45794592
buffer.append(")");
18.3 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/io/File.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ int getPrefixLength() {
214214

215215
/* -- Constructors -- */
216216

217+
/**
218+
* Creates a new <code>File</code> instance by converting the given
219+
* pathname string into an abstract pathname. If the given string is
220+
* the empty string, then the result is the empty abstract pathname.
221+
*
222+
* @param pathname A pathname string
223+
* @throws NullPointerException
224+
* If the <code>pathname</code> argument is <code>null</code>
225+
*/
226+
public File(String pathname) {
227+
this("", pathname);
228+
// if (pathname == null) {
229+
// throw new NullPointerException();
230+
// }
231+
// this.path = fs.normalize(pathname);
232+
// this.prefixLength = fs.prefixLength(this.path);
233+
}
234+
217235
/**
218236
* Internal constructor for already-normalized pathname strings.
219237
*/
@@ -235,29 +253,13 @@ private File(String child, File parent) {
235253
}
236254

237255
private String resolve(String path, String child) {
256+
if (path == "." && child.startsWith("./"))
257+
return child;
238258
if (child.length() > 0 && !child.startsWith("/") && !path.endsWith("/"))
239259
path += "/";
240260
return path + child;
241261
}
242262

243-
/**
244-
* Creates a new <code>File</code> instance by converting the given
245-
* pathname string into an abstract pathname. If the given string is
246-
* the empty string, then the result is the empty abstract pathname.
247-
*
248-
* @param pathname A pathname string
249-
* @throws NullPointerException
250-
* If the <code>pathname</code> argument is <code>null</code>
251-
*/
252-
public File(String pathname) {
253-
this("", pathname);
254-
// if (pathname == null) {
255-
// throw new NullPointerException();
256-
// }
257-
// this.path = fs.normalize(pathname);
258-
// this.prefixLength = fs.prefixLength(this.path);
259-
}
260-
261263
/* Note: The two-argument File constructors do not interpret an empty
262264
parent abstract pathname as the current user directory. An empty parent
263265
instead causes the child to be resolved against the system-dependent

0 commit comments

Comments
 (0)