From 026eadeec830bfdc6a4945e9c8fbc251b93e2046 Mon Sep 17 00:00:00 2001 From: Quinton Ashley Date: Tue, 7 Dec 2021 18:27:38 -0500 Subject: [PATCH] 1.0.11 --- jdk.js | 18 +++++------------- jdk/java/time/Instant.js | 12 ++++++++++++ package.json | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 jdk/java/time/Instant.js diff --git a/jdk.js b/jdk.js index 3c383b5..bc08665 100755 --- a/jdk.js +++ b/jdk.js @@ -50,7 +50,7 @@ async init(root) { this.root = root || 'https://unpkg.com/java2js'; this.java = {}; - let pkgs = ['com', 'lang', 'org', 'io', 'util']; + let pkgs = ['com', 'lang', 'org', 'io', 'util', 'time']; for (let pkg of pkgs) { this.java[pkg] = {}; } @@ -274,21 +274,11 @@ script.onerror = (e) => { reject(e); }; - // prevent page loading from the browser's cache - // if (QuintOS.context == 'live') { - // src += '?' + Date.now(); - // } script.innerHTML = trans; document.body.appendChild(script); }); - // try { - // eval(trans); - // } catch (e) { - // console.error(e); - // if (this.ide) this.log.value += e; - // } } } window.jdk = new JDK(); @@ -19211,9 +19201,11 @@ case 'ArrayAccess': // TODO support for three dimensional arrays if (expr.array.array) { - return `${expr.array.array.identifier}[${parseExpr(expr.array.index)}][${parseExpr(expr.index)}]`; + return `${assignParent(expr.array.array.identifier)}[${parseExpr(expr.array.index)}][${parseExpr( + expr.index + )}]`; } - return `${expr.array.identifier}[${parseExpr(expr.index)}]`; + return `${assignParent(expr.array.identifier)}[${parseExpr(expr.index)}]`; case 'ParenthesizedExpression': return `(${parseExpr(expr.expression)})`; default: diff --git a/jdk/java/time/Instant.js b/jdk/java/time/Instant.js new file mode 100644 index 0000000..e7beef6 --- /dev/null +++ b/jdk/java/time/Instant.js @@ -0,0 +1,12 @@ +jdk.imports['java.time.Instant'].load = async () => { + class Instant {} + + Instant.now = () => { + return { + toEpochMilli: () => { + return Date.now(); + } + }; + }; + jdk.java.time.Instant = Instant; +}; diff --git a/package.json b/package.json index 8c2dd13..6f830f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "java2js", - "version": "1.0.10", + "version": "1.0.11", "description": "Converts Java to JavaScript with support for p5.js and QuintOS.", "main": "jdk.js", "scripts": {