Thanks to visit codestin.com
Credit goes to github.com

Skip to content

major refactoring of legacy only #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 28, 2023
Merged

Conversation

BobHanson
Copy link
Collaborator

The old 2012 version 4.2 transpiler was brought up to speed and integrated into the SwingJS java2script transpiler as an optional second transpiler (using .j2sjmol instead of .j2s as a config file). All of the recognized bugs in the 4.2 transpiler were fixed as part of the process, including issues with global c$ and f$ (Clazz.pu$h and Claz.p0p removed; anonymous function wrappers added), unnecessary final static literals (removed), unnecessary Clazz.prepareStatics (removed), missing boxing and unboxing in field and variable initializers, unnecessary requirements for loading classes in instanceof and in exception checking (because a class that has not been loaded cannot be a match for those), failure to convert char to int in switch cases, lack of Java 8 string-based switch, limitation of Java 4 syntax in general, and probably a few other issues.

The code was streamlined and reorganized to have only two high-level ASTVisitor classes (J2SLegacyVisitor and J2SDependencyVisitor), with additional static methods in J2SUtil. The legacy transpiler was switched from being a compiler option (in .project) to being a second CompilationParticipant option (same participant as the SwingJS transpiler), with added options allowing direct JavaScript insertion into site/jsmol/j2s.

The workflow was immensely simplified. No longer any need for Eclipse Luna (using Eclipse Photon 4.8.0 now) or any limitation to Java 6 (using Java 8 now). A single ANT task creates dist_to_jsmol/Jmol-j2s-site.zip, and a single ANT task in the Jmol project unzips that into its site/ directory. Nothing more than that. The JSmol project is not specifically just for the HTML and non-Jmol-related project files that are pulled into site/ (such as all the HTML test files, jQuery, the Jmol object, etc.)

This Jmol-specific transpiler should still not be used for any other project, as it is a highly streamlined Java package (no StringBuilder or StringBuffer classes, for example) limited to only about 120 Java classes. No java.awt, no javax.swing, no sun.* -- just the classes in java.io, java.lang, java.net, and java.util that Jmol needs.

Older files are still available in the unused/ folder.

Bob Hanson 2023.11.28

benzoid and others added 20 commits June 9, 2023 09:55
AbstractStringBuilder

Also removing java.util.regex as unnecessary for Jmol
switch(String)
try(resource)
- ensures exception matching and instanceOf do not load classes (because
if the class does not already exist, there is necessarily no match.

- class name refactoring to clarify what is an ASTVisitor and what is
just a Java2Script helper.
clarification of "Helpers" vs "Visitors"
better subclassing
consolidation of code for accessing Helpers
removes @j2sSuffix and @j2sPrefix removed (never used in Jmol)
swaths of comments removed.
Change con.err() to con.error()
@BobHanson BobHanson merged commit c6c042b into java2script:master Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants