Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building the compiler

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" main

On 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 with clang or lli when LLVM is installed).
  • out/compile/Program<N>.class — JVM bytecode from ASM; run with java -cp out compile.Program<N>.
  • out/java_src/compile/Program<N>.java — readable Java source generated from the AST; compile with javac to compare with the ASM path.
  • out/ts_src/compile/Program<N>.ts — TypeScript emitted from the same AST; compile with tsc and 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.js

Emit 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.Program1

Classes 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.

Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

Folder Structure

The workspace contains two folders by default, where:

  • src: the folder to maintain sources
  • lib: 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.json and update the related settings there.

Dependency Management

The JAVA PROJECTS view allows you to manage your dependencies. More details can be found here.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages