ObjectWeb ASM 9.7 is required on the classpath for javac (not needed at runtime for the generated .class files).
From the project root (Windows PowerShell example):
javac -encoding UTF-8 -cp "lib\asm-9.7.jar" -d out_classes src\*.java
java -cp "out_classes;lib\asm-9.7.jar" mainOn Unix-like systems, use : instead of ; in the classpath.
After a successful compile of each source program, artifacts are written under out/:
out/program_<N>.ll— LLVM IR text (verify withclangorlliwhen LLVM is installed).out/compile/Program<N>.class— JVM bytecode from ASM; run withjava -cp out compile.Program<N>.out/java_src/compile/Program<N>.java— readable Java source generated from the AST; compile withjavacto compare with the ASM path.out/ts_src/compile/Program<N>.ts— TypeScript emitted from the same AST; compile withtscand run with Node to compare stdout with Java / JVM.
tsc / node on generated TypeScript (requires Node.js and TypeScript: npm install -g typescript):
tsc --outDir out\ts_js --rootDir out\ts_src --module commonjs --target ES2020 --strict out\ts_src\compile\Program1.ts
node out\ts_js\compile\Program1.jsEmit lands in out/ts_js/compile/Program<N>.js. Toggle isTypeScriptVerbose and runTscAfterCompile in src/main.java to print the .ts or run tsc + node automatically after each program. Compare [node out/ts_js/compile/ProgramN.js] lines in the log with [java compile.ProgramN from javac] and the JVM run when those are enabled; all should print the same sequence as the language print statements.
javac / java on generated Java (project root; ASM is not needed for this step):
javac -encoding UTF-8 -d out\javac_classes out\java_src\compile\Program1.java
java -cp out\javac_classes compile.Program1Classes land in out/javac_classes/compile/Program<N>.class, separate from out/compile/Program<N>.class (ASM), so you can compare bytecode (e.g. javap -c) or run both and compare stdout.
In src/main.java, toggle isLlvmVerbose, isJvmVerbose, isJavaSourceVerbose, isTypeScriptVerbose, runJvmAfterCompile, runJavacAfterCompile, and runTscAfterCompile to print artifacts or launch subprocesses.
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
The workspace contains two folders by default, where:
src: the folder to maintain sourceslib: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the bin folder by default.
If you want to customize the folder structure, open
.vscode/settings.jsonand update the related settings there.
The JAVA PROJECTS view allows you to manage your dependencies. More details can be found here.