diff --git a/Makefile b/Makefile index 93059ab1..954639e4 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ POLYGLOT := lib/polyglot/ JAVACPP_PRESETS := lib/javacpp-presets/ SUBMODULES := $(addsuffix .git,$(POLYGLOT) $(JAVACPP_PRESETS)) -# PolyLLVM. -export PLC := $(realpath bin/polyllvmc) +# JLang +export PLC := $(realpath bin/jlangc) # Hack to allow dependency on PolyLLVM source. export PLC_SRC := $(realpath $(shell find compiler/src -name "*.java")) diff --git a/README.md b/README.md index abdccbe1..f6cfab24 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -PolyLLVM +JLang ======== -PolyLLVM adds an LLVM back end to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler, translating Java down to LLVM IR. +JLang adds an LLVM back end to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler, translating Java down to LLVM IR. -Since Polyglot already translates extended Java code into vanilla Java ASTs, PolyLLVM should be interoperable with other Polyglot extensions by default. However, PolyLLVM aims to be extensible itself, so that one can write optimized LLVM translations for language extensions when needed. +Since Polyglot already translates extended Java code into vanilla Java ASTs, JLang should be interoperable with other Polyglot extensions by default. However, JLang aims to be extensible itself, so that one can write optimized LLVM translations for language extensions when needed. -A user manual and developer guide can be found on the [PolyLLVM website](http://gharrma.github.io/polyllvm/). +A user manual and developer guide can be found on the [JLang website](http://dz333.github.io/JLang/). Contributing @@ -15,7 +15,7 @@ Before contributing, please do the following. (1) Read through the rest of this README.
(2) Read through all GitHub issues carefully, to get the most up-to-date picture of the current state of the project.
-(3) Read through the [developer guide](http://gharrma.github.io/polyllvm/developer-guide.html) on the website, to get technical details on the most critical subcomponents of PolyLLVM.
+(3) Read through the [developer guide](http://dz333.github.io/JLang/developer-guide.html) on the website, to get technical details on the most critical subcomponents of JLang.
(4) If you need to work on compiler translations, get familiar with [LLVM IR](https://llvm.org/docs/LangRef.html).
(5) If you need to work on native runtime code, get familiar with [JNI](https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html). @@ -23,21 +23,21 @@ Before contributing, please do the following. Quick start guide ----------------- -PolyLLVM has the following dependencies, which you will need to download and install prior to use. +JLang has the following dependencies, which you will need to download and install prior to use. - [JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html) and [Ant](http://ant.apache.org) are required to build the compiler. Ant is best installed through your preferred package manager. Be sure that the `JAVA_HOME` environment variable is defined and points to the JDK 8 installation (e.g., `/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/`). -- [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html) is required to compile programs with PolyLLVM, since we target Java 7. Be sure that the `JDK7` environment variable is defined and points to the JDK 7 home directory. When trying to run programs compiled with PolyLLVM you will need to set the `JAVA_HOME` environment variable to this value as well (see the test suite Makefile for an example of how to do execute PolyLLVM-compiled binaries). +- [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html) is required to compile programs with JLang, since we target Java 7. Be sure that the `JDK7` environment variable is defined and points to the JDK 7 home directory. When trying to run programs compiled with JLang you will need to set the `JAVA_HOME` environment variable to this value as well (see the test suite Makefile for an example of how to do execute JLang-compiled binaries). -- [LLVM](http://llvm.org) and [Clang](https://clang.llvm.org) are needed to build the runtime and create binaries from Java programs. PolyLLVM is tested with version 5.0.1, which you can download [here](http://releases.llvm.org/download.html#5.0.1). It may be possible to install through a package manager (e.g., `sudo apt install llvm && sudo apt install clang`). After installation be sure that `llc --version` (for example) and `clang++ --version` report consistent versions. You may have to alter your PATH to pick the right version, especially on a Mac for which a version of `Clang` comes bundled with the command line developer tools. +- [LLVM](http://llvm.org) and [Clang](https://clang.llvm.org) are needed to build the runtime and create binaries from Java programs. JLang is tested with version 5.0.1, which you can download [here](http://releases.llvm.org/download.html#5.0.1). It may be possible to install through a package manager (e.g., `sudo apt install llvm && sudo apt install clang`). After installation be sure that `llc --version` (for example) and `clang++ --version` report consistent versions. You may have to alter your PATH to pick the right version, especially on a Mac for which a version of `Clang` comes bundled with the command line developer tools. -- The [Boehm-Demers-Weiser garbage collector](http://www.hboehm.info/gc/) is also required for creating binaries. PolyLLVM is tested with version 7.6.4, which you can download [here](http://www.hboehm.info/gc/gc_source/) or install through a package manager (`brew install boehmgc`). A typical install from source looks like this: `./configure && make && make install`. Note that the garbage collector depends on [libatomic_ops](https://github.com/ivmai/libatomic_ops), which is often available through a package manager. +- The [Boehm-Demers-Weiser garbage collector](http://www.hboehm.info/gc/) is also required for creating binaries. JLang is tested with version 7.6.4, which you can download [here](http://www.hboehm.info/gc/gc_source/) or install through a package manager (`brew install boehmgc`). A typical install from source looks like this: `./configure && make && make install`. Note that the garbage collector depends on [libatomic_ops](https://github.com/ivmai/libatomic_ops), which is often available through a package manager. -- [Git LFS](https://git-lfs.github.com) is required to use PolyLLVM with OpenJDK 7. We use Git LFS to track a zip file containing all OpenJDK 7 Java source files. (The alternative is requiring a checkout and build of the full OpenJDK tree, which is notoriously difficult to configure.) Be sure to do a `git lfs pull` so that `jdk/src.zip` is downloaded; otherwise you will see strange error messages when trying to build. +- [Git LFS](https://git-lfs.github.com) is required to use JLang with OpenJDK 7. We use Git LFS to track a zip file containing all OpenJDK 7 Java source files. (The alternative is requiring a checkout and build of the full OpenJDK tree, which is notoriously difficult to configure.) Be sure to do a `git lfs pull` so that `jdk/src.zip` is downloaded; otherwise you will see strange error messages when trying to build. Note that [Polyglot](https://github.com/polyglot-compiler/polyglot/) is also required, but is tracked as a git submodule and will be built automatically. -Finally, build PolyLLVM by running `make` at the top level of the repository. By default this will build only a "bare-bones" JDK, which is enough to run the [unit tests](tests/isolated). Note that PolyLLVM is usually tested on OS X; see issue #55 for updates on whether the build system supports Linux. +Finally, build JLang by running `make` at the top level of the repository. By default this will build only a "bare-bones" JDK, which is enough to run the [unit tests](tests/isolated). Note that JLang is usually tested on OS X; see issue #55 for updates on whether the build system supports Linux. If you want to run unit tests from IntelliJ, run the `TestAll` class, using the top level of the repository as the working directory. @@ -45,17 +45,17 @@ If you want to run unit tests from IntelliJ, run the `TestAll` class, using the High-level project structure ---------------------------- -- Compiler source files are in the [compiler/src/polyllvm](compiler/src/polyllvm) directory. Most translation code resides in the [extension](compiler/src/polyllvm/extension) subdirectory. +- Compiler source files are in the [compiler/src/jlang](compiler/src/jlang) directory. Most translation code resides in the [extension](compiler/src/jlang/extension) subdirectory. - [runtime](runtime) contains [Java code](runtime/src) and [native code](runtime/native) needed to implement Java semantics at runtime (think: exceptions, JNI, reflection, etc.). -- [tests/isolated](tests/isolated) contains unit tests for translations from Java to LLVM IR. The JUnit test suite compiles and runs these programs with both `javac` and `polyllvm`, then compares the results. +- [tests/isolated](tests/isolated) contains unit tests for translations from Java to LLVM IR. The JUnit test suite compiles and runs these programs with both `javac` and `jlang`, then compares the results. -- [jdk](jdk) provides a way to compile and link OpenJDK 7 with PolyLLVM, and [jdk-lite](jdk-lite) provides a "bare-bones" JDK implementation used for unit testing. +- [jdk](jdk) provides a way to compile and link OpenJDK 7 with JLang, and [jdk-lite](jdk-lite) provides a "bare-bones" JDK implementation used for unit testing. -- [docs](docs) contains documentation for the various subcomponents of PolyLLVM, in the form of Markdown files. These files also provide the content for the [PolyLLVM website](http://gharrma.github.io/polyllvm/). +- [docs](docs) contains documentation for the various subcomponents of JLang, in the form of Markdown files. These files also provide the content for the [JLang website](http://dz333.github.io/jlang/). -- [lib](lib) contains Polyglot (the frontend for PolyLLVM); a fork of [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) to generate Java stubs from LLVM headers; and various supporting `.jar` files. +- [lib](lib) contains Polyglot (the frontend for JLang); a fork of [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) to generate Java stubs from LLVM headers; and various supporting `.jar` files. Status (May 2018) @@ -63,11 +63,11 @@ Status (May 2018) All translations from Java to LLVM IR are complete, with the exception of the `synchronized` keyword (see below on concurrency support). This means that all Java 7 language features---expressions, control flow, exceptions, method dispatch, switch statements, try-with-resources, initializer blocks, implicit type conversions, etc.---are translated robustly and as specified by the [JLS](https://docs.oracle.com/javase/specs/jls/se7/html/index.html). All of our [unit tests](tests/isolated) pass. -However, PolyLLVM is still a work in progress for two important reasons. +However, JLang is still a work in progress for two important reasons. -(1) JDK support. The JDK includes thousands of classes that are critical to the Java ecosystem, such as `java.lang.Class`, `java.util.ArrayList`, `java.io.File`, and `java.net.Socket`. Thus it is important to be able to compile programs that rely on the JDK. So far we can fully support a hand-written "bare-bones" JDK that includes only the JDK classes that are necessary for unit tests (`java.lang.Object`, `java.lang.Class`, `java.lang.System`, etc.). This has allowed us to test the compiler before trying to compile the entire JDK. Support for the full JDK is close, but not finished. Please see [issue #54](https://github.com/gharrma/polyllvm/issues/54) for more information. +(1) JDK support. The JDK includes thousands of classes that are critical to the Java ecosystem, such as `java.lang.Class`, `java.util.ArrayList`, `java.io.File`, and `java.net.Socket`. Thus it is important to be able to compile programs that rely on the JDK. So far we can fully support a hand-written "bare-bones" JDK that includes only the JDK classes that are necessary for unit tests (`java.lang.Object`, `java.lang.Class`, `java.lang.System`, etc.). This has allowed us to test the compiler before trying to compile the entire JDK. Support for the full JDK is close, but not finished. Please see [issue #54](https://github.com/dz333/JLang/issues/54) for more information. -(2) Concurrency support. Support for multiple threads and synchronization has not been started, as JDK support took priority. PolyLLVM will ignore the Java `synchronized` keyword, and the [native runtime code](runtime/native) is generally not thread-safe. Please see [issue #5](https://github.com/gharrma/polyllvm/issues/5) for more information. +(2) Concurrency support. Support for multiple threads and synchronization has not been started, as JDK support took priority. JLang will ignore the Java `synchronized` keyword, and the [native runtime code](runtime/native) is generally not thread-safe. Please see [issue #5](https://github.com/dz333/JLang/issues/5) for more information. All other loose ends (minor bugs, build system issues, etc.) are tracked as GitHub issues as well. If you would like to contribute, please read through all of these tracked issues carefully! diff --git a/bin/polyllvmc b/bin/jlangc similarity index 98% rename from bin/polyllvmc rename to bin/jlangc index cf9b68c5..c73ec9f1 100755 --- a/bin/polyllvmc +++ b/bin/jlangc @@ -31,7 +31,7 @@ extra_cp= args= vmargs= java=java -ext=polyllvm +ext=jlang while true; do case "$1" in @@ -73,7 +73,7 @@ runtime_classpath="$dir/runtime/out/classes" runtime_classpath="$runtime_classpath:$extra_cp" command="$java -ea $vmargs -classpath \"$(fixpath ${compiler_classpath})\" \ -polyllvm.Main \ +jlang.Main \ -classpath \"$(fixpath ${runtime_classpath})\" \ $args" diff --git a/bin/plc b/bin/plc index f0c41e33..efeab4de 100755 --- a/bin/plc +++ b/bin/plc @@ -44,5 +44,5 @@ for d in $directories; do done -$DIR/polyllvmc -d "$outdir" $files && \ +$DIR/jlangc -d "$outdir" $files && \ clang++ -Wno-override-module -L/usr/local/lib/ -lgc -O1 -o "$out" $clangflags "$RUNTIME"/runtime.o `find "$outdir" -name *.ll` diff --git a/build.xml b/build.xml index 110720a3..e5a82b8e 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + - PolyLLVM build file + JLang build file @@ -9,10 +9,10 @@ **************************************** --> - + - + diff --git a/compiler/compiler.iml b/compiler/compiler.iml index cc17df1a..fb2a07e0 100644 --- a/compiler/compiler.iml +++ b/compiler/compiler.iml @@ -7,9 +7,9 @@ - + - \ No newline at end of file + diff --git a/compiler/src/polyllvm/PolyLLVMExtensionInfo.java b/compiler/src/jlang/JLangExtensionInfo.java similarity index 78% rename from compiler/src/polyllvm/PolyLLVMExtensionInfo.java rename to compiler/src/jlang/JLangExtensionInfo.java index ee3fd5f1..ff265879 100644 --- a/compiler/src/polyllvm/PolyLLVMExtensionInfo.java +++ b/compiler/src/jlang/JLangExtensionInfo.java @@ -1,4 +1,4 @@ -package polyllvm; +package jlang; import polyglot.ast.NodeFactory; import polyglot.ext.jl5.ast.JL5ExtFactory_c; @@ -11,19 +11,21 @@ import polyglot.main.Version; import polyglot.types.TypeSystem; import polyglot.util.StringUtil; -import polyllvm.ast.PolyLLVMExtFactory_c; -import polyllvm.ast.PolyLLVMLang_c; -import polyllvm.ast.PolyLLVMNodeFactory_c; -import polyllvm.types.PolyLLVMTypeSystem_c; import javax.tools.JavaFileObject; import javax.tools.JavaFileObject.Kind; + +import jlang.ast.JLangExtFactory_c; +import jlang.ast.JLangLang_c; +import jlang.ast.JLangNodeFactory_c; +import jlang.types.JLangTypeSystem_c; + import java.io.IOException; /** - * Extension information for polyllvm extension. + * Extension information for JLang extension. */ -public class PolyLLVMExtensionInfo extends JL7ExtensionInfo { +public class JLangExtensionInfo extends JL7ExtensionInfo { static { // force Topics to load @SuppressWarnings("unused") @@ -43,35 +45,35 @@ public String[] defaultFileExtensions() { @Override public String compilerName() { - return "polyllvmc"; + return "jlangc"; } @Override protected NodeFactory createNodeFactory() { - return new PolyLLVMNodeFactory_c(PolyLLVMLang_c.instance, - new PolyLLVMExtFactory_c( + return new JLangNodeFactory_c(JLangLang_c.instance, + new JLangExtFactory_c( new JL7ExtFactory_c( new JL5ExtFactory_c()))); } @Override protected TypeSystem createTypeSystem() { - return new PolyLLVMTypeSystem_c(); + return new JLangTypeSystem_c(); } @Override public Scheduler createScheduler() { - return new PolyLLVMScheduler(this); + return new JLangScheduler(this); } @Override protected Options createOptions() { - return new PolyLLVMOptions(this); + return new JLangOptions(this); } @Override public Version version() { - return new polyllvm.Version(); + return new jlang.Version(); } @Override diff --git a/compiler/src/polyllvm/PolyLLVMOptions.java b/compiler/src/jlang/JLangOptions.java similarity index 94% rename from compiler/src/polyllvm/PolyLLVMOptions.java rename to compiler/src/jlang/JLangOptions.java index 38e293f7..3b85497e 100644 --- a/compiler/src/polyllvm/PolyLLVMOptions.java +++ b/compiler/src/jlang/JLangOptions.java @@ -1,4 +1,4 @@ -package polyllvm; +package jlang; import polyglot.ext.jl5.JL5Options; import polyglot.main.OptFlag; @@ -6,14 +6,14 @@ import java.util.Set; -public class PolyLLVMOptions extends JL5Options { +public class JLangOptions extends JL5Options { public String entryPointClass; public boolean entryPointEmitted; public boolean printDesugar; public int maxPasses; - public PolyLLVMOptions(PolyLLVMExtensionInfo extension) { + public JLangOptions(JLangExtensionInfo extension) { super(extension); this.setOutputExtension("ll"); } diff --git a/compiler/src/polyllvm/PolyLLVMScheduler.java b/compiler/src/jlang/JLangScheduler.java similarity index 92% rename from compiler/src/polyllvm/PolyLLVMScheduler.java rename to compiler/src/jlang/JLangScheduler.java index 23e3dcbd..a450a407 100644 --- a/compiler/src/polyllvm/PolyLLVMScheduler.java +++ b/compiler/src/jlang/JLangScheduler.java @@ -1,5 +1,7 @@ -package polyllvm; +package jlang; +import jlang.util.DesugarBarrier; +import jlang.util.JLangDesugared; import polyglot.ast.ClassDecl; import polyglot.ast.Lang; import polyglot.ast.Node; @@ -15,21 +17,19 @@ import polyglot.types.ParsedClassType; import polyglot.util.InternalCompilerError; import polyglot.visit.NodeVisitor; -import polyllvm.util.DesugarBarrier; -import polyllvm.util.PolyLLVMDesugared; /** * Schedules the passes necessary to translate Java down to LLVM IR. */ -public class PolyLLVMScheduler extends JL7Scheduler { +public class JLangScheduler extends JL7Scheduler { - public PolyLLVMScheduler(JLExtensionInfo extInfo) { + public JLangScheduler(JLExtensionInfo extInfo) { super(extInfo); } @Override protected int maxRunCount() { - PolyLLVMOptions options = (PolyLLVMOptions) Options.global; + JLangOptions options = (JLangOptions) Options.global; return (options.maxPasses > 0) ? options.maxPasses : super.maxRunCount(); } @@ -75,7 +75,7 @@ public Node leave(Node old, Node n, NodeVisitor v) { /** Desugar passes which simplify LLVM translation. */ public Goal LLVMDesugared(Job job) { - Goal desugar = new PolyLLVMDesugared(job); + Goal desugar = new JLangDesugared(job); try { desugar.addPrerequisiteGoal(AllSignaturesResolved(job), this); } catch (CyclicDependencyException e) { diff --git a/compiler/src/polyllvm/LLVMEmitted.java b/compiler/src/jlang/LLVMEmitted.java similarity index 91% rename from compiler/src/polyllvm/LLVMEmitted.java rename to compiler/src/jlang/LLVMEmitted.java index 128c6e29..445f0772 100644 --- a/compiler/src/polyllvm/LLVMEmitted.java +++ b/compiler/src/jlang/LLVMEmitted.java @@ -1,7 +1,11 @@ -package polyllvm; +package jlang; import org.bytedeco.javacpp.BytePointer; import org.bytedeco.javacpp.Pointer; + +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; +import jlang.visit.LLVMTranslator; import polyglot.ast.Node; import polyglot.ast.SourceFile; import polyglot.frontend.*; @@ -11,9 +15,6 @@ import polyglot.util.InternalCompilerError; import polyglot.util.OptimalCodeWriter; import polyglot.visit.PrettyPrinter; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.visit.LLVMTranslator; import java.io.File; import java.lang.Override; @@ -45,14 +46,14 @@ private LLVMOutputPass(Goal goal) { @Override public boolean run() { ExtensionInfo extInfo = goal.job().extensionInfo(); - PolyLLVMNodeFactory nf = (PolyLLVMNodeFactory) extInfo.nodeFactory(); - PolyLLVMTypeSystem ts = (PolyLLVMTypeSystem) extInfo.typeSystem(); + JLangNodeFactory nf = (JLangNodeFactory) extInfo.nodeFactory(); + JLangTypeSystem ts = (JLangTypeSystem) extInfo.typeSystem(); Node ast = goal.job().ast(); if (!(ast instanceof SourceFile)) throw new InternalCompilerError("AST root should be a SourceFile"); SourceFile sf = (SourceFile) ast; - if (((PolyLLVMOptions) Options.global).printDesugar) { + if (((JLangOptions) Options.global).printDesugar) { new PrettyPrinter(lang()).printAst(ast, new OptimalCodeWriter(System.out, 80)); } diff --git a/compiler/src/polyllvm/Main.java b/compiler/src/jlang/Main.java similarity index 79% rename from compiler/src/polyllvm/Main.java rename to compiler/src/jlang/Main.java index d36b3429..f2ec7c30 100644 --- a/compiler/src/polyllvm/Main.java +++ b/compiler/src/jlang/Main.java @@ -1,9 +1,9 @@ -package polyllvm; +package jlang; /** * Main is the main program of the compiler extension. * It simply invokes Polyglot's main, passing in the extension's - * PolyLLVMExtensionInfo. + * JLangExtensionInfo. */ public class Main { @@ -11,7 +11,7 @@ public static void main(String[] args) { polyglot.main.Main polyglotMain = new polyglot.main.Main(); try { - polyglotMain.start(args, new PolyLLVMExtensionInfo()); + polyglotMain.start(args, new JLangExtensionInfo()); } catch (polyglot.main.Main.TerminationException e) { System.err.println(e.getMessage()); diff --git a/compiler/src/jlang/Topics.java b/compiler/src/jlang/Topics.java new file mode 100644 index 00000000..57a1d4f9 --- /dev/null +++ b/compiler/src/jlang/Topics.java @@ -0,0 +1,14 @@ +package jlang; + +import polyglot.main.Report; + +/** + * Extension information for JLang extension. + */ +public class Topics { + public static final String jlang = "jlang"; + + static { + Report.topics.add(jlang); + } +} diff --git a/compiler/src/polyllvm/Version.java b/compiler/src/jlang/Version.java similarity index 77% rename from compiler/src/polyllvm/Version.java rename to compiler/src/jlang/Version.java index 63731495..dd59bfb1 100644 --- a/compiler/src/polyllvm/Version.java +++ b/compiler/src/jlang/Version.java @@ -1,12 +1,12 @@ -package polyllvm; +package jlang; /** - * Version information for polyllvm extension + * Version information for JLang extension */ public class Version extends polyglot.main.Version { @Override public String name() { - return "polyllvm"; + return "jlang"; } @Override diff --git a/compiler/src/polyllvm/ast/AddressOf.java b/compiler/src/jlang/ast/AddressOf.java similarity index 92% rename from compiler/src/polyllvm/ast/AddressOf.java rename to compiler/src/jlang/ast/AddressOf.java index b3d4da15..2712d87b 100644 --- a/compiler/src/polyllvm/ast/AddressOf.java +++ b/compiler/src/jlang/ast/AddressOf.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Expr; diff --git a/compiler/src/polyllvm/ast/AddressOf_c.java b/compiler/src/jlang/ast/AddressOf_c.java similarity index 98% rename from compiler/src/polyllvm/ast/AddressOf_c.java rename to compiler/src/jlang/ast/AddressOf_c.java index bec25e57..4154111c 100644 --- a/compiler/src/polyllvm/ast/AddressOf_c.java +++ b/compiler/src/jlang/ast/AddressOf_c.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.*; import polyglot.util.CodeWriter; diff --git a/compiler/src/polyllvm/ast/ESeq.java b/compiler/src/jlang/ast/ESeq.java similarity index 91% rename from compiler/src/polyllvm/ast/ESeq.java rename to compiler/src/jlang/ast/ESeq.java index e41733ca..638a58cd 100644 --- a/compiler/src/polyllvm/ast/ESeq.java +++ b/compiler/src/jlang/ast/ESeq.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Expr; import polyglot.ast.Stmt; diff --git a/compiler/src/polyllvm/ast/ESeq_c.java b/compiler/src/jlang/ast/ESeq_c.java similarity index 93% rename from compiler/src/polyllvm/ast/ESeq_c.java rename to compiler/src/jlang/ast/ESeq_c.java index 236de222..4bd91093 100644 --- a/compiler/src/polyllvm/ast/ESeq_c.java +++ b/compiler/src/jlang/ast/ESeq_c.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.*; import polyglot.util.CodeWriter; @@ -89,8 +89,8 @@ public List acceptCFG(CFGBuilder v, List succs) { private Block blockEquivalent() { List stmtsAndExpr = new ArrayList<>(statements()); - stmtsAndExpr.add(new Eval_c(position(), expr(), new PolyLLVMExt())); - return new Block_c(position(), stmtsAndExpr, new PolyLLVMExt()); + stmtsAndExpr.add(new Eval_c(position(), expr(), new JLangExt())); + return new Block_c(position(), stmtsAndExpr, new JLangExt()); } @Override diff --git a/compiler/src/polyllvm/ast/PolyLLVMAbstractExtFactory_c.java b/compiler/src/jlang/ast/JLangAbstractExtFactory_c.java similarity index 71% rename from compiler/src/polyllvm/ast/PolyLLVMAbstractExtFactory_c.java rename to compiler/src/jlang/ast/JLangAbstractExtFactory_c.java index 13f1bb0d..22615358 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMAbstractExtFactory_c.java +++ b/compiler/src/jlang/ast/JLangAbstractExtFactory_c.java @@ -1,18 +1,18 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Ext; import polyglot.ast.ExtFactory; import polyglot.ext.jl7.ast.JL7AbstractExtFactory_c; -public abstract class PolyLLVMAbstractExtFactory_c +public abstract class JLangAbstractExtFactory_c extends JL7AbstractExtFactory_c - implements PolyLLVMExtFactory { + implements JLangExtFactory { - public PolyLLVMAbstractExtFactory_c() { + public JLangAbstractExtFactory_c() { super(); } - public PolyLLVMAbstractExtFactory_c(ExtFactory nextExtFactory) { + public JLangAbstractExtFactory_c(ExtFactory nextExtFactory) { super(nextExtFactory); } @@ -22,8 +22,8 @@ public Ext extESeq() { if (nextExtFactory() != null) { Ext e2; - if (nextExtFactory() instanceof PolyLLVMExtFactory) { - e2 = ((PolyLLVMExtFactory) nextExtFactory()).extESeq(); + if (nextExtFactory() instanceof JLangExtFactory) { + e2 = ((JLangExtFactory) nextExtFactory()).extESeq(); } else { e2 = nextExtFactory().extExpr(); @@ -39,8 +39,8 @@ public Ext extAddressOf() { if (nextExtFactory() != null) { Ext e2; - if (nextExtFactory() instanceof PolyLLVMExtFactory) { - e2 = ((PolyLLVMExtFactory) nextExtFactory()).extAddressOf(); + if (nextExtFactory() instanceof JLangExtFactory) { + e2 = ((JLangExtFactory) nextExtFactory()).extAddressOf(); } else { e2 = nextExtFactory().extExpr(); @@ -56,8 +56,8 @@ public Ext extLoad() { if (nextExtFactory() != null) { Ext e2; - if (nextExtFactory() instanceof PolyLLVMExtFactory) { - e2 = ((PolyLLVMExtFactory) nextExtFactory()).extLoad(); + if (nextExtFactory() instanceof JLangExtFactory) { + e2 = ((JLangExtFactory) nextExtFactory()).extLoad(); } else { e2 = nextExtFactory().extExpr(); diff --git a/compiler/src/polyllvm/ast/PolyLLVMExt.java b/compiler/src/jlang/ast/JLangExt.java similarity index 78% rename from compiler/src/polyllvm/ast/PolyLLVMExt.java rename to compiler/src/jlang/ast/JLangExt.java index 68607b79..f4008d81 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMExt.java +++ b/compiler/src/jlang/ast/JLangExt.java @@ -1,35 +1,36 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Ext; import polyglot.ast.Ext_c; import polyglot.ast.Node; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.visit.LLVMTranslator; -import polyllvm.visit.DesugarLocally; import java.lang.Override; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMExt extends Ext_c implements PolyLLVMOps { +public class JLangExt extends Ext_c implements JLangOps { private static final long serialVersionUID = SerialVersionUID.generate(); - public static PolyLLVMExt ext(Node n) { + public static JLangExt ext(Node n) { Ext e = n.ext(); - while (e != null && !(e instanceof PolyLLVMExt)) { + while (e != null && !(e instanceof JLangExt)) { e = e.ext(); } if (e == null) { - throw new InternalCompilerError("No PolyLLVM extension object for node " + throw new InternalCompilerError("No JLang extension object for node " + n + " (" + n.getClass() + ")", n.position()); } - return (PolyLLVMExt) e; + return (JLangExt) e; } @Override - public final PolyLLVMLang lang() { - return PolyLLVMLang_c.instance; + public final JLangLang lang() { + return JLangLang_c.instance; } @Override diff --git a/compiler/src/polyllvm/ast/PolyLLVMExtFactory.java b/compiler/src/jlang/ast/JLangExtFactory.java similarity index 52% rename from compiler/src/polyllvm/ast/PolyLLVMExtFactory.java rename to compiler/src/jlang/ast/JLangExtFactory.java index a136c35e..3251b585 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMExtFactory.java +++ b/compiler/src/jlang/ast/JLangExtFactory.java @@ -1,12 +1,12 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Ext; import polyglot.ext.jl7.ast.JL7ExtFactory; /** - * Extension factory for the PolyLLVM extension. + * Extension factory for the JLang extension. */ -public interface PolyLLVMExtFactory extends JL7ExtFactory { +public interface JLangExtFactory extends JL7ExtFactory { Ext extESeq(); diff --git a/compiler/src/polyllvm/ast/PolyLLVMExtFactory_c.java b/compiler/src/jlang/ast/JLangExtFactory_c.java similarity index 57% rename from compiler/src/polyllvm/ast/PolyLLVMExtFactory_c.java rename to compiler/src/jlang/ast/JLangExtFactory_c.java index d1879311..f1e07092 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMExtFactory_c.java +++ b/compiler/src/jlang/ast/JLangExtFactory_c.java @@ -1,257 +1,257 @@ -package polyllvm.ast; +package jlang.ast; +import jlang.extension.*; import polyglot.ast.Ext; import polyglot.ast.ExtFactory; -import polyllvm.extension.*; -public final class PolyLLVMExtFactory_c extends PolyLLVMAbstractExtFactory_c { +public final class JLangExtFactory_c extends JLangAbstractExtFactory_c { - public PolyLLVMExtFactory_c() { + public JLangExtFactory_c() { super(); } @SuppressWarnings("unused") - public PolyLLVMExtFactory_c(ExtFactory nextExtFactory) { + public JLangExtFactory_c(ExtFactory nextExtFactory) { super(nextExtFactory); } @Override protected Ext extTryWithResourcesImpl() { - return new PolyLLVMTryWithResourcesExt(); + return new JLangTryWithResourcesExt(); } @Override protected Ext extNodeImpl() { - return new PolyLLVMExt(); + return new JLangExt(); } @Override protected Ext extClassLitImpl() { - return new PolyLLVMClassLitExt(); + return new JLangClassLitExt(); } @Override protected Ext extESeqImpl() { - return new PolyLLVMEseqExt(); + return new JLangEseqExt(); } @Override protected Ext extNormalAnnotationElemImpl() { - return new PolyLLVMAnnotationElemExt(); + return new JLangAnnotationElemExt(); } @Override protected Ext extInstanceofImpl() { - return new PolyLLVMInstanceofExt(); + return new JLangInstanceofExt(); } @Override protected Ext extIntLitImpl() { - return new PolyLLVMIntLitExt(); + return new JLangIntLitExt(); } @Override protected Ext extLocalDeclImpl() { - return new PolyLLVMLocalDeclExt(); + return new JLangLocalDeclExt(); } @Override protected Ext extAssignImpl() { - return new PolyLLVMAssignExt(); + return new JLangAssignExt(); } @Override protected Ext extBinaryImpl() { - return new PolyLLVMBinaryExt(); + return new JLangBinaryExt(); } @Override protected Ext extExtendedForImpl() { - return new PolyLLVMExtendedForExt(); + return new JLangExtendedForExt(); } @Override protected Ext extLocalImpl() { - return new PolyLLVMLocalExt(); + return new JLangLocalExt(); } @Override protected Ext extAssertImpl() { - return new PolyLLVMAssertExt(); + return new JLangAssertExt(); } @Override protected Ext extReturnImpl() { - return new PolyLLVMReturnExt(); + return new JLangReturnExt(); } @Override protected Ext extSourceFileImpl() { - return new PolyLLVMSourceFileExt(); + return new JLangSourceFileExt(); } @Override protected Ext extClassDeclImpl() { - return new PolyLLVMClassDeclExt(); + return new JLangClassDeclExt(); } @Override protected Ext extCallImpl() { - return new PolyLLVMCallExt(); + return new JLangCallExt(); } @Override protected Ext extIfImpl() { - return new PolyLLVMIfExt(); + return new JLangIfExt(); } @Override public Ext extLoadImpl() { - return new PolyLLVMLoadExt(); + return new JLangLoadExt(); } @Override protected Ext extBooleanLitImpl() { - return new PolyLLVMBooleanLitExt(); + return new JLangBooleanLitExt(); } @Override protected Ext extSwitchImpl() { - return new PolyLLVMSwitchExt(); + return new JLangSwitchExt(); } @Override protected Ext extWhileImpl() { - return new PolyLLVMWhileExt(); + return new JLangWhileExt(); } @Override protected Ext extUnaryImpl() { - return new PolyLLVMUnaryExt(); + return new JLangUnaryExt(); } @Override protected Ext extCharLitImpl() { - return new PolyLLVMCharLitExt(); + return new JLangCharLitExt(); } @Override protected Ext extCastImpl() { - return new PolyLLVMCastExt(); + return new JLangCastExt(); } @Override public Ext extAddressOfImpl() { - return new PolyLLVMAddressOfExt(); + return new JLangAddressOfExt(); } @Override protected Ext extEnumConstantDeclImpl() { - return new PolyLLVMDesugaredNodeExt(); + return new JLangDesugaredNodeExt(); } @Override protected Ext extBranchImpl() { - return new PolyLLVMBranchExt(); + return new JLangBranchExt(); } @Override protected Ext extLabeledImpl() { - return new PolyLLVMLabeledExt(); + return new JLangLabeledExt(); } @Override protected Ext extFloatLitImpl() { - return new PolyLLVMFloatLitExt(); + return new JLangFloatLitExt(); } @Override protected Ext extNullLitImpl() { - return new PolyLLVMNullLitExt(); + return new JLangNullLitExt(); } @Override protected Ext extNewImpl() { - return new PolyLLVMNewExt(); + return new JLangNewExt(); } @Override protected Ext extFieldImpl() { - return new PolyLLVMFieldExt(); + return new JLangFieldExt(); } @Override protected Ext extFieldDeclImpl() { - return new PolyLLVMFieldDeclExt(); + return new JLangFieldDeclExt(); } @Override protected Ext extSpecialImpl() { - return new PolyLLVMSpecialExt(); + return new JLangSpecialExt(); } @Override protected Ext extNewArrayImpl() { - return new PolyLLVMNewArrayExt(); + return new JLangNewArrayExt(); } @Override protected Ext extProcedureDeclImpl() { - return new PolyLLVMProcedureDeclExt(); + return new JLangProcedureDeclExt(); } @Override protected Ext extConstructorCallImpl() { - return new PolyLLVMConstructorCallExt(); + return new JLangConstructorCallExt(); } @Override protected Ext extArrayAccessImpl() { - return new PolyLLVMArrayAccessExt(); + return new JLangArrayAccessExt(); } @Override protected Ext extInitializerImpl() { - return new PolyLLVMInitializerExt(); + return new JLangInitializerExt(); } @Override protected Ext extArrayInitImpl() { - return new PolyLLVMArrayInitExt(); + return new JLangArrayInitExt(); } @Override protected Ext extDoImpl() { - return new PolyLLVMDoExt(); + return new JLangDoExt(); } @Override protected Ext extForImpl() { - return new PolyLLVMForExt(); + return new JLangForExt(); } @Override protected Ext extConditionalImpl() { - return new PolyLLVMConditionalExt(); + return new JLangConditionalExt(); } @Override protected Ext extTryImpl() { - return new PolyLLVMTryExt(); + return new JLangTryExt(); } @Override protected Ext extThrowImpl() { - return new PolyLLVMThrowExt(); + return new JLangThrowExt(); } @Override protected Ext extSynchronizedImpl() { - return new PolyLLVMSynchronizedExt(); + return new JLangSynchronizedExt(); } @Override protected Ext extStringLitImpl() { - return new PolyLLVMStringLitExt(); + return new JLangStringLitExt(); } } diff --git a/compiler/src/polyllvm/ast/PolyLLVMLang.java b/compiler/src/jlang/ast/JLangLang.java similarity index 85% rename from compiler/src/polyllvm/ast/PolyLLVMLang.java rename to compiler/src/jlang/ast/JLangLang.java index 9ab73008..7c37a56d 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMLang.java +++ b/compiler/src/jlang/ast/JLangLang.java @@ -1,14 +1,15 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Node; import polyglot.ext.jl7.ast.J7Lang; -import polyllvm.visit.LLVMTranslator; -import polyllvm.visit.DesugarLocally; import static org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public interface PolyLLVMLang extends J7Lang { +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + +public interface JLangLang extends J7Lang { /** * Simplifies (desugars) this node so that translation to LLVM is easier. diff --git a/compiler/src/polyllvm/ast/PolyLLVMLang_c.java b/compiler/src/jlang/ast/JLangLang_c.java similarity index 58% rename from compiler/src/polyllvm/ast/PolyLLVMLang_c.java rename to compiler/src/jlang/ast/JLangLang_c.java index f5c31ca1..461274af 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMLang_c.java +++ b/compiler/src/jlang/ast/JLangLang_c.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Ext; import polyglot.ast.Lang; @@ -6,19 +6,20 @@ import polyglot.ast.NodeOps; import polyglot.ext.jl7.ast.J7Lang_c; import polyglot.util.InternalCompilerError; -import polyllvm.visit.LLVMTranslator; -import polyllvm.visit.DesugarLocally; import static org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMLang_c extends J7Lang_c implements PolyLLVMLang { - public static final PolyLLVMLang_c instance = new PolyLLVMLang_c(); +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; - public static PolyLLVMLang lang(NodeOps n) { +public class JLangLang_c extends J7Lang_c implements JLangLang { + public static final JLangLang_c instance = new JLangLang_c(); + + public static JLangLang lang(NodeOps n) { while (n != null) { Lang lang = n.lang(); - if (lang instanceof PolyLLVMLang) return (PolyLLVMLang) lang; + if (lang instanceof JLangLang) return (JLangLang) lang; if (n instanceof Ext) n = ((Ext) n).pred(); else return null; @@ -27,51 +28,51 @@ public static PolyLLVMLang lang(NodeOps n) { } - protected PolyLLVMLang_c() { + protected JLangLang_c() { } - protected static PolyLLVMExt polyllvmExt(Node n) { - return PolyLLVMExt.ext(n); + protected static JLangExt jlangExt(Node n) { + return JLangExt.ext(n); } @Override protected NodeOps NodeOps(Node n) { - return polyllvmExt(n); + return jlangExt(n); } - protected PolyLLVMOps PolyLLVMOps(Node n) { - return polyllvmExt(n); + protected JLangOps JLangOps(Node n) { + return jlangExt(n); } @Override public Node desugar(Node n, DesugarLocally v) { - return PolyLLVMOps(n).desugar(v); + return JLangOps(n).desugar(v); } @Override public LLVMTranslator enterTranslateLLVM(Node n, LLVMTranslator v) { - return PolyLLVMOps(n).enterTranslateLLVM(v); + return JLangOps(n).enterTranslateLLVM(v); } @Override public Node leaveTranslateLLVM(Node n, LLVMTranslator v) { - return PolyLLVMOps(n).leaveTranslateLLVM(v); + return JLangOps(n).leaveTranslateLLVM(v); } @Override public Node overrideTranslateLLVM(Node parent, Node n, LLVMTranslator v) { - return PolyLLVMOps(n).overrideTranslateLLVM(parent, v); + return JLangOps(n).overrideTranslateLLVM(parent, v); } @Override public void translateLLVMConditional(Node n, LLVMTranslator v, LLVMBasicBlockRef trueBlock, LLVMBasicBlockRef falseBlock) { - PolyLLVMOps(n).translateLLVMConditional(v, trueBlock, falseBlock); + JLangOps(n).translateLLVMConditional(v, trueBlock, falseBlock); } @Override public LLVMValueRef translateAsLValue(Node n, LLVMTranslator v) { - return PolyLLVMOps(n).translateAsLValue(v); + return JLangOps(n).translateAsLValue(v); } } diff --git a/compiler/src/polyllvm/ast/PolyLLVMNodeFactory.java b/compiler/src/jlang/ast/JLangNodeFactory.java similarity index 72% rename from compiler/src/polyllvm/ast/PolyLLVMNodeFactory.java rename to compiler/src/jlang/ast/JLangNodeFactory.java index 5c5819e1..08e2212b 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMNodeFactory.java +++ b/compiler/src/jlang/ast/JLangNodeFactory.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Expr; import polyglot.ast.Stmt; @@ -7,8 +7,8 @@ import java.util.List; -/** NodeFactory for PolyLLVM. */ -public interface PolyLLVMNodeFactory extends JL7NodeFactory { +/** NodeFactory for JLang. */ +public interface JLangNodeFactory extends JL7NodeFactory { ESeq ESeq(Position pos, List statements, Expr expr); diff --git a/compiler/src/polyllvm/ast/PolyLLVMNodeFactory_c.java b/compiler/src/jlang/ast/JLangNodeFactory_c.java similarity index 65% rename from compiler/src/polyllvm/ast/PolyLLVMNodeFactory_c.java rename to compiler/src/jlang/ast/JLangNodeFactory_c.java index 3ec5cff1..c6540a86 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMNodeFactory_c.java +++ b/compiler/src/jlang/ast/JLangNodeFactory_c.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.*; import polyglot.ext.jl7.ast.JL7NodeFactory_c; @@ -6,10 +6,10 @@ import java.util.List; -/** NodeFactory for PolyLLVM. */ -public class PolyLLVMNodeFactory_c extends JL7NodeFactory_c implements PolyLLVMNodeFactory { +/** NodeFactory for JLang. */ +public class JLangNodeFactory_c extends JL7NodeFactory_c implements JLangNodeFactory { - public PolyLLVMNodeFactory_c(PolyLLVMLang lang, PolyLLVMExtFactory extFactory) { + public JLangNodeFactory_c(JLangLang lang, JLangExtFactory extFactory) { super(lang, extFactory); } @@ -29,7 +29,7 @@ public Load Load(Position pos, Expr expr) { } @Override - public PolyLLVMExtFactory extFactory() { - return (PolyLLVMExtFactory) super.extFactory(); + public JLangExtFactory extFactory() { + return (JLangExtFactory) super.extFactory(); } } diff --git a/compiler/src/polyllvm/ast/PolyLLVMOps.java b/compiler/src/jlang/ast/JLangOps.java similarity index 85% rename from compiler/src/polyllvm/ast/PolyLLVMOps.java rename to compiler/src/jlang/ast/JLangOps.java index 0b60da7d..e0f2614a 100644 --- a/compiler/src/polyllvm/ast/PolyLLVMOps.java +++ b/compiler/src/jlang/ast/JLangOps.java @@ -1,17 +1,18 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Node; import polyglot.ast.NodeOps; -import polyllvm.visit.LLVMTranslator; -import polyllvm.visit.DesugarLocally; import static org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + /** - * Operations any PolyLLVM compatible node must implement. + * Operations any JLang compatible node must implement. */ -public interface PolyLLVMOps extends NodeOps { +public interface JLangOps extends NodeOps { /** * Simplifies (desugars) this node so that translation to LLVM is easier. diff --git a/compiler/src/polyllvm/ast/Load.java b/compiler/src/jlang/ast/Load.java similarity index 89% rename from compiler/src/polyllvm/ast/Load.java rename to compiler/src/jlang/ast/Load.java index 6d819723..406b9076 100644 --- a/compiler/src/polyllvm/ast/Load.java +++ b/compiler/src/jlang/ast/Load.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.Expr; diff --git a/compiler/src/polyllvm/ast/Load_c.java b/compiler/src/jlang/ast/Load_c.java similarity index 98% rename from compiler/src/polyllvm/ast/Load_c.java rename to compiler/src/jlang/ast/Load_c.java index b29a8f41..54c235a9 100644 --- a/compiler/src/polyllvm/ast/Load_c.java +++ b/compiler/src/jlang/ast/Load_c.java @@ -1,4 +1,4 @@ -package polyllvm.ast; +package jlang.ast; import polyglot.ast.*; import polyglot.util.CodeWriter; diff --git a/compiler/src/jlang/ast/package.html b/compiler/src/jlang/ast/package.html new file mode 100644 index 00000000..5325bfb2 --- /dev/null +++ b/compiler/src/jlang/ast/package.html @@ -0,0 +1,5 @@ + +

+AST nodes for the JLang language extension. +

+ diff --git a/compiler/src/polyllvm/extension/PolyLLVMAddressOfExt.java b/compiler/src/jlang/extension/JLangAddressOfExt.java similarity index 66% rename from compiler/src/polyllvm/extension/PolyLLVMAddressOfExt.java rename to compiler/src/jlang/extension/JLangAddressOfExt.java index 3b07138f..8d3210c3 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMAddressOfExt.java +++ b/compiler/src/jlang/extension/JLangAddressOfExt.java @@ -1,13 +1,14 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; -import polyllvm.ast.AddressOf; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMAddressOfExt extends PolyLLVMExt { +import jlang.ast.AddressOf; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangAddressOfExt extends JLangExt { @Override public Node overrideTranslateLLVM(Node parent, LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMAnnotationElemExt.java b/compiler/src/jlang/extension/JLangAnnotationElemExt.java similarity index 72% rename from compiler/src/polyllvm/extension/PolyLLVMAnnotationElemExt.java rename to compiler/src/jlang/extension/JLangAnnotationElemExt.java index b5341c64..b0e81483 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMAnnotationElemExt.java +++ b/compiler/src/jlang/extension/JLangAnnotationElemExt.java @@ -1,10 +1,10 @@ -package polyllvm.extension; +package jlang.extension; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Node; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; -public class PolyLLVMAnnotationElemExt extends PolyLLVMExt { +public class JLangAnnotationElemExt extends JLangExt { @Override public Node overrideTranslateLLVM(Node parent, LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMArrayAccessExt.java b/compiler/src/jlang/extension/JLangArrayAccessExt.java similarity index 91% rename from compiler/src/polyllvm/extension/PolyLLVMArrayAccessExt.java rename to compiler/src/jlang/extension/JLangArrayAccessExt.java index ab98ed9c..fda22a44 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMArrayAccessExt.java +++ b/compiler/src/jlang/extension/JLangArrayAccessExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.types.ClassType; @@ -7,17 +7,18 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.util.Arrays; import java.util.Collections; +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.LLVMBuildLoad; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMArrayAccessExt extends PolyLLVMExt { +public class JLangArrayAccessExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); /** Whether this array access is already guarded by an index bounds check. */ @@ -33,11 +34,11 @@ public ArrayAccess setGuarded() { } public ArrayAccess setGuarded(ArrayAccess c) { - PolyLLVMArrayAccessExt ext = (PolyLLVMArrayAccessExt) PolyLLVMExt.ext(c); + JLangArrayAccessExt ext = (JLangArrayAccessExt) JLangExt.ext(c); if (ext.guarded) return c; if (c == node) { c = Copy.Util.copy(c); - ext = (PolyLLVMArrayAccessExt) PolyLLVMExt.ext(c); + ext = (JLangArrayAccessExt) JLangExt.ext(c); } ext.guarded = true; return c; diff --git a/compiler/src/polyllvm/extension/PolyLLVMArrayInitExt.java b/compiler/src/jlang/extension/JLangArrayInitExt.java similarity index 85% rename from compiler/src/polyllvm/extension/PolyLLVMArrayInitExt.java rename to compiler/src/jlang/extension/JLangArrayInitExt.java index 754be8c8..1c28d3fa 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMArrayInitExt.java +++ b/compiler/src/jlang/extension/JLangArrayInitExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.ArrayInit; import polyglot.ast.Expr; @@ -6,14 +6,15 @@ import polyglot.types.Type; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMArrayInitExt extends PolyLLVMExt { +public class JLangArrayInitExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override @@ -29,7 +30,7 @@ public Node leaveTranslateLLVM(LLVMTranslator v) { LLVMValueRef len = LLVMConstInt( v.utils.toLL(v.ts.Int()), n.elements().size(), /*signExtend*/ 0); - LLVMValueRef array = PolyLLVMNewArrayExt.translateNewArray(v, len, elemType); + LLVMValueRef array = JLangNewArrayExt.translateNewArray(v, len, elemType); if (!n.elements().isEmpty()) { LLVMValueRef base = v.obj.buildArrayBaseElementPtr(array, n.type().toArray()); diff --git a/compiler/src/polyllvm/extension/PolyLLVMAssertExt.java b/compiler/src/jlang/extension/JLangAssertExt.java similarity index 82% rename from compiler/src/polyllvm/extension/PolyLLVMAssertExt.java rename to compiler/src/jlang/extension/JLangAssertExt.java index 8c9b0ebe..e47144e4 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMAssertExt.java +++ b/compiler/src/jlang/extension/JLangAssertExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Assert; import polyglot.ast.Expr; @@ -6,14 +6,15 @@ import polyglot.main.Options; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.util.Collections; import java.util.List; -public class PolyLLVMAssertExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + +public class JLangAssertExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMAssignExt.java b/compiler/src/jlang/extension/JLangAssignExt.java similarity index 93% rename from compiler/src/polyllvm/extension/PolyLLVMAssignExt.java rename to compiler/src/jlang/extension/JLangAssignExt.java index 73de0954..53b6e60d 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMAssignExt.java +++ b/compiler/src/jlang/extension/JLangAssignExt.java @@ -1,19 +1,20 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.util.Arrays; +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.LLVMBuildStore; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMAssignExt extends PolyLLVMExt { +public class JLangAssignExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMBinaryExt.java b/compiler/src/jlang/extension/JLangBinaryExt.java similarity index 97% rename from compiler/src/polyllvm/extension/PolyLLVMBinaryExt.java rename to compiler/src/jlang/extension/JLangBinaryExt.java index b368bb68..899d1532 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMBinaryExt.java +++ b/compiler/src/jlang/extension/JLangBinaryExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Binary; import polyglot.ast.Binary.*; @@ -7,17 +7,18 @@ import polyglot.types.Type; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.Arrays; +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; import static polyglot.ast.Binary.*; -public class PolyLLVMBinaryExt extends PolyLLVMExt { +public class JLangBinaryExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMBooleanLitExt.java b/compiler/src/jlang/extension/JLangBooleanLitExt.java similarity index 85% rename from compiler/src/polyllvm/extension/PolyLLVMBooleanLitExt.java rename to compiler/src/jlang/extension/JLangBooleanLitExt.java index 9e43be72..9f3eae0e 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMBooleanLitExt.java +++ b/compiler/src/jlang/extension/JLangBooleanLitExt.java @@ -1,14 +1,15 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.BooleanLit; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMBooleanLitExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangBooleanLitExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMBranchExt.java b/compiler/src/jlang/extension/JLangBranchExt.java similarity index 83% rename from compiler/src/polyllvm/extension/PolyLLVMBranchExt.java rename to compiler/src/jlang/extension/JLangBranchExt.java index 662cf4ce..83becadd 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMBranchExt.java +++ b/compiler/src/jlang/extension/JLangBranchExt.java @@ -1,14 +1,15 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Branch; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMBuildBr; -public class PolyLLVMBranchExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangBranchExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMCallExt.java b/compiler/src/jlang/extension/JLangCallExt.java similarity index 94% rename from compiler/src/polyllvm/extension/PolyLLVMCallExt.java rename to compiler/src/jlang/extension/JLangCallExt.java index 9dc29203..fb6a58a5 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMCallExt.java +++ b/compiler/src/jlang/extension/JLangCallExt.java @@ -1,6 +1,10 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.*; + +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; +import jlang.visit.LLVMTranslator.DispatchInfo; import polyglot.ast.Call; import polyglot.ast.Node; import polyglot.ast.Special; @@ -8,15 +12,12 @@ import polyglot.util.Copy; import polyglot.util.SerialVersionUID; import polyglot.visit.TypeChecker; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; -import polyllvm.visit.LLVMTranslator.DispatchInfo; import java.lang.Override; import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMCallExt extends PolyLLVMProcedureCallExt { +public class JLangCallExt extends JLangProcedureCallExt { private static final long serialVersionUID = SerialVersionUID.generate(); /** @@ -41,7 +42,7 @@ public Node leaveTranslateLLVM(LLVMTranslator v) { /** Sets {@link this#direct} appropriately. */ public Call determineIfDirect(Call c) { - PolyLLVMCallExt ext = (PolyLLVMCallExt) PolyLLVMExt.ext(c); + JLangCallExt ext = (JLangCallExt) JLangExt.ext(c); if (ext.direct) return c; // Should always remain direct once set. boolean direct = false; @@ -66,7 +67,7 @@ public Call determineIfDirect(Call c) { if (!direct) return c; if (c == node) { c = Copy.Util.copy(c); - ext = (PolyLLVMCallExt) PolyLLVMExt.ext(c); + ext = (JLangCallExt) JLangExt.ext(c); } ext.direct = true; return c; diff --git a/compiler/src/polyllvm/extension/PolyLLVMCastExt.java b/compiler/src/jlang/extension/JLangCastExt.java similarity index 95% rename from compiler/src/polyllvm/extension/PolyLLVMCastExt.java rename to compiler/src/jlang/extension/JLangCastExt.java index 0df4f06c..ab5edcb7 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMCastExt.java +++ b/compiler/src/jlang/extension/JLangCastExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.types.*; @@ -7,17 +7,18 @@ import polyglot.util.Position; import polyglot.util.SerialVersionUID; import polyglot.visit.AscriptionVisitor; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.util.Constants; -import polyllvm.visit.LLVMTranslator; -import polyllvm.visit.DesugarLocally; import java.lang.Override; import java.util.Arrays; import java.util.Collections; +import jlang.ast.JLangExt; +import jlang.util.Constants; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + +import static jlang.extension.JLangCastExt.ConversionContext.*; import static org.bytedeco.javacpp.LLVM.*; -import static polyllvm.extension.PolyLLVMCastExt.ConversionContext.*; /** * We use cast nodes to model both explicit user-added casts and implicit conversions. @@ -34,7 +35,7 @@ * Polyglot claims a conversion is necessary, and then we emit conversion * code when translating {@link Cast} nodes here. */ -public class PolyLLVMCastExt extends PolyLLVMExt { +public class JLangCastExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); /** Conversion context, as specified by the JLS. */ @@ -54,11 +55,11 @@ public Cast context(ConversionContext context) { } public Cast context(Cast c, ConversionContext context) { - PolyLLVMCastExt ext = (PolyLLVMCastExt) PolyLLVMExt.ext(c); + JLangCastExt ext = (JLangCastExt) JLangExt.ext(c); if (ext.context == context) return c; if (c == node) { c = Copy.Util.copy(c); - ext = (PolyLLVMCastExt) PolyLLVMExt.ext(c); + ext = (JLangCastExt) JLangExt.ext(c); } ext.context = context; return c; diff --git a/compiler/src/polyllvm/extension/PolyLLVMCharLitExt.java b/compiler/src/jlang/extension/JLangCharLitExt.java similarity index 77% rename from compiler/src/polyllvm/extension/PolyLLVMCharLitExt.java rename to compiler/src/jlang/extension/JLangCharLitExt.java index 40d8f3ee..c452abca 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMCharLitExt.java +++ b/compiler/src/jlang/extension/JLangCharLitExt.java @@ -1,14 +1,15 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.CharLit; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMCharLitExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangCharLitExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMClassDeclExt.java b/compiler/src/jlang/extension/JLangClassDeclExt.java similarity index 98% rename from compiler/src/polyllvm/extension/PolyLLVMClassDeclExt.java rename to compiler/src/jlang/extension/JLangClassDeclExt.java index 68e7d54a..9f1fe8f5 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMClassDeclExt.java +++ b/compiler/src/jlang/extension/JLangClassDeclExt.java @@ -1,13 +1,14 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.*; + +import jlang.ast.JLangExt; +import jlang.util.Constants; +import jlang.util.LLVMUtils; +import jlang.visit.LLVMTranslator; import polyglot.ast.*; import polyglot.types.*; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.util.Constants; -import polyllvm.util.LLVMUtils; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.Collections; @@ -16,10 +17,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static jlang.util.Constants.REGISTER_CLASS_FUNC; import static org.bytedeco.javacpp.LLVM.*; -import static polyllvm.util.Constants.REGISTER_CLASS_FUNC; -public class PolyLLVMClassDeclExt extends PolyLLVMExt { +public class JLangClassDeclExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMClassLitExt.java b/compiler/src/jlang/extension/JLangClassLitExt.java similarity index 93% rename from compiler/src/polyllvm/extension/PolyLLVMClassLitExt.java rename to compiler/src/jlang/extension/JLangClassLitExt.java index 7ce23da4..26d57131 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMClassLitExt.java +++ b/compiler/src/jlang/extension/JLangClassLitExt.java @@ -1,6 +1,10 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.LLVMValueRef; + +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; import polyglot.ast.ClassLit; import polyglot.ast.Expr; import polyglot.ast.Node; @@ -9,11 +13,8 @@ import polyglot.types.Type; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; -public class PolyLLVMClassLitExt extends PolyLLVMExt { +public class JLangClassLitExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMConditionalExt.java b/compiler/src/jlang/extension/JLangConditionalExt.java similarity index 88% rename from compiler/src/polyllvm/extension/PolyLLVMConditionalExt.java rename to compiler/src/jlang/extension/JLangConditionalExt.java index ca5b4a3b..654790cb 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMConditionalExt.java +++ b/compiler/src/jlang/extension/JLangConditionalExt.java @@ -1,16 +1,17 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Conditional; import polyglot.ast.Expr; import polyglot.ast.Node; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.util.function.BiConsumer; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMConditionalExt extends PolyLLVMExt { +public class JLangConditionalExt extends JLangExt { @Override public Node overrideTranslateLLVM(Node parent, LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMConstructorCallExt.java b/compiler/src/jlang/extension/JLangConstructorCallExt.java similarity index 86% rename from compiler/src/polyllvm/extension/PolyLLVMConstructorCallExt.java rename to compiler/src/jlang/extension/JLangConstructorCallExt.java index caad0123..acd3ea0d 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMConstructorCallExt.java +++ b/compiler/src/jlang/extension/JLangConstructorCallExt.java @@ -1,15 +1,16 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.ConstructorCall; import polyglot.ast.Node; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMGetParam; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMConstructorCallExt extends PolyLLVMProcedureCallExt { +import jlang.visit.LLVMTranslator; + +public class JLangConstructorCallExt extends JLangProcedureCallExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMDesugaredNodeExt.java b/compiler/src/jlang/extension/JLangDesugaredNodeExt.java similarity index 69% rename from compiler/src/polyllvm/extension/PolyLLVMDesugaredNodeExt.java rename to compiler/src/jlang/extension/JLangDesugaredNodeExt.java index 71f43b22..428dbf10 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMDesugaredNodeExt.java +++ b/compiler/src/jlang/extension/JLangDesugaredNodeExt.java @@ -1,11 +1,11 @@ -package polyllvm.extension; +package jlang.extension; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Node; import polyglot.util.InternalCompilerError; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; -public class PolyLLVMDesugaredNodeExt extends PolyLLVMExt { +public class JLangDesugaredNodeExt extends JLangExt { private static final String errorMsg = "This node should be desugared before translating to LLVM IR"; diff --git a/compiler/src/polyllvm/extension/PolyLLVMDoExt.java b/compiler/src/jlang/extension/JLangDoExt.java similarity index 90% rename from compiler/src/polyllvm/extension/PolyLLVMDoExt.java rename to compiler/src/jlang/extension/JLangDoExt.java index 86e6587f..d984d0d9 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMDoExt.java +++ b/compiler/src/jlang/extension/JLangDoExt.java @@ -1,17 +1,18 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; + +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Do; import polyglot.ast.Labeled; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMBuildBr; import static org.bytedeco.javacpp.LLVM.LLVMPositionBuilderAtEnd; -public class PolyLLVMDoExt extends PolyLLVMExt { +public class JLangDoExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMEseqExt.java b/compiler/src/jlang/extension/JLangEseqExt.java similarity index 83% rename from compiler/src/polyllvm/extension/PolyLLVMEseqExt.java rename to compiler/src/jlang/extension/JLangEseqExt.java index a863eeba..88d60f89 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMEseqExt.java +++ b/compiler/src/jlang/extension/JLangEseqExt.java @@ -1,14 +1,15 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; -import polyllvm.ast.ESeq; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMEseqExt extends PolyLLVMExt { +import jlang.ast.ESeq; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangEseqExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMExtendedForExt.java b/compiler/src/jlang/extension/JLangExtendedForExt.java similarity index 90% rename from compiler/src/polyllvm/extension/PolyLLVMExtendedForExt.java rename to compiler/src/jlang/extension/JLangExtendedForExt.java index 69a3c6a3..0d3624e0 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMExtendedForExt.java +++ b/compiler/src/jlang/extension/JLangExtendedForExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.ext.jl5.ast.ExtendedFor; @@ -11,19 +11,20 @@ import polyglot.types.Type; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.util.TypedNodeFactory; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.util.Arrays; import java.util.Collections; import java.util.List; +import jlang.ast.JLangExt; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; +import jlang.util.TypedNodeFactory; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + /** Enhanced for-loops are desugared into normal for-loops. */ -public class PolyLLVMExtendedForExt extends PolyLLVMExt { +public class JLangExtendedForExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { @@ -47,8 +48,8 @@ public Node desugar(DesugarLocally v) { // for (Iterator it = e.iterator(); it.hasNext(); ) { T x = it.next(); ... } private Stmt translateForIterable(ExtendedFor ef, DesugarLocally v) throws SemanticException { Position pos = ef.position(); - PolyLLVMTypeSystem ts = v.ts; - PolyLLVMNodeFactory nf = v.nf; + JLangTypeSystem ts = v.ts; + JLangNodeFactory nf = v.nf; TypedNodeFactory tnf = v.tnf; assert ef.expr().type().isClass(); @@ -105,8 +106,8 @@ private Stmt translateForIterable(ExtendedFor ef, DesugarLocally v) throws Seman // for (T[] a = e, int i = 0; i < a.length; i++) { T x = a[i]; ... } private Stmt translateForArray(ExtendedFor n, DesugarLocally v) { Position pos = n.position(); - PolyLLVMTypeSystem ts = v.ts; - PolyLLVMNodeFactory nf = v.nf; + JLangTypeSystem ts = v.ts; + JLangNodeFactory nf = v.nf; TypedNodeFactory tnf = v.tnf; // Array alias: T[] a = e; diff --git a/compiler/src/polyllvm/extension/PolyLLVMFieldDeclExt.java b/compiler/src/jlang/extension/JLangFieldDeclExt.java similarity index 89% rename from compiler/src/polyllvm/extension/PolyLLVMFieldDeclExt.java rename to compiler/src/jlang/extension/JLangFieldDeclExt.java index ec9cf6cc..4f9e35c9 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMFieldDeclExt.java +++ b/compiler/src/jlang/extension/JLangFieldDeclExt.java @@ -1,17 +1,18 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.FieldDecl; import polyglot.ast.Node; import polyglot.types.FieldInstance; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMFieldDeclExt extends PolyLLVMExt { +public class JLangFieldDeclExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMFieldExt.java b/compiler/src/jlang/extension/JLangFieldExt.java similarity index 90% rename from compiler/src/polyllvm/extension/PolyLLVMFieldExt.java rename to compiler/src/jlang/extension/JLangFieldExt.java index d2382feb..dce37c7b 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMFieldExt.java +++ b/compiler/src/jlang/extension/JLangFieldExt.java @@ -1,17 +1,18 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Field; import polyglot.ast.Node; import polyglot.types.FieldInstance; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMFieldExt extends PolyLLVMExt { +public class JLangFieldExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMFloatLitExt.java b/compiler/src/jlang/extension/JLangFloatLitExt.java similarity index 78% rename from compiler/src/polyllvm/extension/PolyLLVMFloatLitExt.java rename to compiler/src/jlang/extension/JLangFloatLitExt.java index 230cb675..1487253b 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMFloatLitExt.java +++ b/compiler/src/jlang/extension/JLangFloatLitExt.java @@ -1,15 +1,16 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.FloatLit; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMConstReal; import static org.bytedeco.javacpp.LLVM.LLVMTypeRef; -public class PolyLLVMFloatLitExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangFloatLitExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMForExt.java b/compiler/src/jlang/extension/JLangForExt.java similarity index 92% rename from compiler/src/polyllvm/extension/PolyLLVMForExt.java rename to compiler/src/jlang/extension/JLangForExt.java index 18b54940..c8904752 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMForExt.java +++ b/compiler/src/jlang/extension/JLangForExt.java @@ -1,17 +1,18 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; + +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.For; import polyglot.ast.Labeled; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMBuildBr; import static org.bytedeco.javacpp.LLVM.LLVMPositionBuilderAtEnd; -public class PolyLLVMForExt extends PolyLLVMExt { +public class JLangForExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMIfExt.java b/compiler/src/jlang/extension/JLangIfExt.java similarity index 88% rename from compiler/src/polyllvm/extension/PolyLLVMIfExt.java rename to compiler/src/jlang/extension/JLangIfExt.java index ced24b19..8735940d 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMIfExt.java +++ b/compiler/src/jlang/extension/JLangIfExt.java @@ -1,16 +1,17 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.If; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMIfExt extends PolyLLVMExt { +public class JLangIfExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMInitializerExt.java b/compiler/src/jlang/extension/JLangInitializerExt.java similarity index 71% rename from compiler/src/polyllvm/extension/PolyLLVMInitializerExt.java rename to compiler/src/jlang/extension/JLangInitializerExt.java index d18185a7..ad5d54ec 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMInitializerExt.java +++ b/compiler/src/jlang/extension/JLangInitializerExt.java @@ -1,11 +1,11 @@ -package polyllvm.extension; +package jlang.extension; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; -public class PolyLLVMInitializerExt extends PolyLLVMExt { +public class JLangInitializerExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMInstanceofExt.java b/compiler/src/jlang/extension/JLangInstanceofExt.java similarity index 88% rename from compiler/src/polyllvm/extension/PolyLLVMInstanceofExt.java rename to compiler/src/jlang/extension/JLangInstanceofExt.java index 671554d3..e38385bf 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMInstanceofExt.java +++ b/compiler/src/jlang/extension/JLangInstanceofExt.java @@ -1,17 +1,18 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Instanceof; import polyglot.ast.Node; import polyglot.types.ReferenceType; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMInstanceofExt extends PolyLLVMExt { +public class JLangInstanceofExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMIntLitExt.java b/compiler/src/jlang/extension/JLangIntLitExt.java similarity index 79% rename from compiler/src/polyllvm/extension/PolyLLVMIntLitExt.java rename to compiler/src/jlang/extension/JLangIntLitExt.java index 3176dd7b..293210ea 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMIntLitExt.java +++ b/compiler/src/jlang/extension/JLangIntLitExt.java @@ -1,14 +1,15 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.IntLit; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMIntLitExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangIntLitExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMLabeledExt.java b/compiler/src/jlang/extension/JLangLabeledExt.java similarity index 90% rename from compiler/src/polyllvm/extension/PolyLLVMLabeledExt.java rename to compiler/src/jlang/extension/JLangLabeledExt.java index 8585b80f..192da8f2 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMLabeledExt.java +++ b/compiler/src/jlang/extension/JLangLabeledExt.java @@ -1,16 +1,17 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.LLVMBasicBlockRef; + +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Labeled; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMBuildBr; import static org.bytedeco.javacpp.LLVM.LLVMPositionBuilderAtEnd; -public class PolyLLVMLabeledExt extends PolyLLVMExt { +public class JLangLabeledExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMLoadExt.java b/compiler/src/jlang/extension/JLangLoadExt.java similarity index 69% rename from compiler/src/polyllvm/extension/PolyLLVMLoadExt.java rename to compiler/src/jlang/extension/JLangLoadExt.java index 3d4e312a..ee07d2fa 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMLoadExt.java +++ b/compiler/src/jlang/extension/JLangLoadExt.java @@ -1,15 +1,16 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; -import polyllvm.ast.Load; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.Load; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMLoadExt extends PolyLLVMExt { +public class JLangLoadExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMLocalDeclExt.java b/compiler/src/jlang/extension/JLangLocalDeclExt.java similarity index 82% rename from compiler/src/polyllvm/extension/PolyLLVMLocalDeclExt.java rename to compiler/src/jlang/extension/JLangLocalDeclExt.java index c9102533..0da69680 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMLocalDeclExt.java +++ b/compiler/src/jlang/extension/JLangLocalDeclExt.java @@ -1,24 +1,25 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.LocalDecl; import polyglot.ast.Node; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.types.PolyLLVMLocalInstance; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.types.JLangLocalInstance; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMLocalDeclExt extends PolyLLVMExt { +public class JLangLocalDeclExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override public Node leaveTranslateLLVM(LLVMTranslator v) { LocalDecl n = (LocalDecl) node(); - PolyLLVMLocalInstance li = (PolyLLVMLocalInstance) n.localInstance().orig(); + JLangLocalInstance li = (JLangLocalInstance) n.localInstance().orig(); LLVMTypeRef typeRef = v.utils.toLL(n.declType()); LLVMValueRef translation; diff --git a/compiler/src/polyllvm/extension/PolyLLVMLocalExt.java b/compiler/src/jlang/extension/JLangLocalExt.java similarity index 73% rename from compiler/src/polyllvm/extension/PolyLLVMLocalExt.java rename to compiler/src/jlang/extension/JLangLocalExt.java index 9be60f6e..c2a320da 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMLocalExt.java +++ b/compiler/src/jlang/extension/JLangLocalExt.java @@ -1,22 +1,23 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Local; import polyglot.ast.Node; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.types.PolyLLVMLocalInstance; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMBuildLoad; import static org.bytedeco.javacpp.LLVM.LLVMValueRef; -public class PolyLLVMLocalExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.types.JLangLocalInstance; +import jlang.visit.LLVMTranslator; + +public class JLangLocalExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override public Node leaveTranslateLLVM(LLVMTranslator v) { Local n = (Local) node(); - PolyLLVMLocalInstance li = (PolyLLVMLocalInstance) n.localInstance().orig(); + JLangLocalInstance li = (JLangLocalInstance) n.localInstance().orig(); if (li.isSSA()) { // SSA values are already ready to use. @@ -35,7 +36,7 @@ public Node leaveTranslateLLVM(LLVMTranslator v) { @Override public LLVMValueRef translateAsLValue(LLVMTranslator v) { Local n = (Local) node(); - PolyLLVMLocalInstance li = (PolyLLVMLocalInstance) n.localInstance().orig(); + JLangLocalInstance li = (JLangLocalInstance) n.localInstance().orig(); return v.getTranslation(li); } } diff --git a/compiler/src/polyllvm/extension/PolyLLVMNewArrayExt.java b/compiler/src/jlang/extension/JLangNewArrayExt.java similarity index 92% rename from compiler/src/polyllvm/extension/PolyLLVMNewArrayExt.java rename to compiler/src/jlang/extension/JLangNewArrayExt.java index fd7581b7..0609f3a4 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMNewArrayExt.java +++ b/compiler/src/jlang/extension/JLangNewArrayExt.java @@ -1,22 +1,23 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.types.*; import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.Collections; +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + +import static jlang.util.Constants.RUNTIME_ARRAY; +import static jlang.util.Constants.RUNTIME_ARRAY_TYPE; import static org.bytedeco.javacpp.LLVM.*; -import static polyllvm.util.Constants.RUNTIME_ARRAY; -import static polyllvm.util.Constants.RUNTIME_ARRAY_TYPE; -public class PolyLLVMNewArrayExt extends PolyLLVMExt { +public class JLangNewArrayExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override @@ -120,6 +121,6 @@ public static LLVMValueRef translateNewArray(LLVMTranslator v, LLVMValueRef len, LLVMValueRef size = LLVMBuildAdd(v.builder, headerSize, contentSize, "size"); LLVMValueRef[] arg = {len, elemSizeArg}; - return PolyLLVMNewExt.translateWithArgsAndSize(v, arg, size, arrayConstructor); + return JLangNewExt.translateWithArgsAndSize(v, arg, size, arrayConstructor); } } diff --git a/compiler/src/polyllvm/extension/PolyLLVMNewExt.java b/compiler/src/jlang/extension/JLangNewExt.java similarity index 93% rename from compiler/src/polyllvm/extension/PolyLLVMNewExt.java rename to compiler/src/jlang/extension/JLangNewExt.java index 85c3f2ab..c6961725 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMNewExt.java +++ b/compiler/src/jlang/extension/JLangNewExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.New; import polyglot.ast.Node; @@ -6,16 +6,17 @@ import polyglot.types.ReferenceType; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.util.Constants; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.Arrays; import java.util.stream.Stream; +import jlang.util.Constants; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMNewExt extends PolyLLVMProcedureCallExt { +public class JLangNewExt extends JLangProcedureCallExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override @@ -26,7 +27,7 @@ public Node leaveTranslateLLVM(LLVMTranslator v) { // This is an anonymous class! Initialize class data structures. if (n.body() != null) { - PolyLLVMClassDeclExt.initClassDataStructures(v, n.type().toClass(), n.body()); + JLangClassDeclExt.initClassDataStructures(v, n.type().toClass(), n.body()); } // Most of the translation happens in this super call. diff --git a/compiler/src/polyllvm/extension/PolyLLVMNullLitExt.java b/compiler/src/jlang/extension/JLangNullLitExt.java similarity index 74% rename from compiler/src/polyllvm/extension/PolyLLVMNullLitExt.java rename to compiler/src/jlang/extension/JLangNullLitExt.java index 8053bbdf..1b1f28e0 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMNullLitExt.java +++ b/compiler/src/jlang/extension/JLangNullLitExt.java @@ -1,14 +1,15 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; import polyglot.ast.NullLit; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.LLVMConstNull; -public class PolyLLVMNullLitExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangNullLitExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMProcedureCallExt.java b/compiler/src/jlang/extension/JLangProcedureCallExt.java similarity index 95% rename from compiler/src/polyllvm/extension/PolyLLVMProcedureCallExt.java rename to compiler/src/jlang/extension/JLangProcedureCallExt.java index 5c72a585..6bc66c21 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMProcedureCallExt.java +++ b/compiler/src/jlang/extension/JLangProcedureCallExt.java @@ -1,7 +1,11 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM.LLVMTypeRef; import org.bytedeco.javacpp.LLVM.LLVMValueRef; + +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; import polyglot.ast.Expr; import polyglot.ast.Node; import polyglot.ast.ProcedureCall; @@ -10,16 +14,13 @@ import polyglot.types.ProcedureInstance; import polyglot.types.Type; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.util.ArrayList; import java.util.List; import static org.bytedeco.javacpp.LLVM.LLVMBuildBitCast; -abstract class PolyLLVMProcedureCallExt extends PolyLLVMExt { +abstract class JLangProcedureCallExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMProcedureDeclExt.java b/compiler/src/jlang/extension/JLangProcedureDeclExt.java similarity index 97% rename from compiler/src/polyllvm/extension/PolyLLVMProcedureDeclExt.java rename to compiler/src/jlang/extension/JLangProcedureDeclExt.java index 78e73260..86daae74 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMProcedureDeclExt.java +++ b/compiler/src/jlang/extension/JLangProcedureDeclExt.java @@ -1,13 +1,14 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.LLVM; + +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Formal; import polyglot.ast.Node; import polyglot.ast.ProcedureDecl; import polyglot.types.*; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.ArrayList; @@ -16,11 +17,11 @@ import java.util.function.Function; import java.util.stream.Stream; +import static jlang.util.Constants.GET_NATIVE_FUNC; +import static jlang.util.Constants.JNI_ENV_VAR_NAME; import static org.bytedeco.javacpp.LLVM.*; -import static polyllvm.util.Constants.GET_NATIVE_FUNC; -import static polyllvm.util.Constants.JNI_ENV_VAR_NAME; -public class PolyLLVMProcedureDeclExt extends PolyLLVMExt { +public class JLangProcedureDeclExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMReturnExt.java b/compiler/src/jlang/extension/JLangReturnExt.java similarity index 89% rename from compiler/src/polyllvm/extension/PolyLLVMReturnExt.java rename to compiler/src/jlang/extension/JLangReturnExt.java index 88c5d50c..7bd1c6bc 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMReturnExt.java +++ b/compiler/src/jlang/extension/JLangReturnExt.java @@ -1,15 +1,16 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Expr; import polyglot.ast.Node; import polyglot.ast.Return; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMReturnExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangReturnExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMSourceFileExt.java b/compiler/src/jlang/extension/JLangSourceFileExt.java similarity index 92% rename from compiler/src/polyllvm/extension/PolyLLVMSourceFileExt.java rename to compiler/src/jlang/extension/JLangSourceFileExt.java index a4b25343..62f90632 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMSourceFileExt.java +++ b/compiler/src/jlang/extension/JLangSourceFileExt.java @@ -1,23 +1,24 @@ -package polyllvm.extension; +package jlang.extension; import org.bytedeco.javacpp.PointerPointer; + +import jlang.JLangOptions; +import jlang.ast.JLangExt; +import jlang.util.Constants; +import jlang.visit.LLVMTranslator; import polyglot.ast.Node; import polyglot.main.Options; import polyglot.types.TypeSystem; import polyglot.util.SerialVersionUID; -import polyllvm.PolyLLVMOptions; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.util.Constants; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.Map; import java.util.stream.Stream; +import static jlang.util.Constants.ENTRY_TRAMPOLINE; import static org.bytedeco.javacpp.LLVM.*; -import static polyllvm.util.Constants.ENTRY_TRAMPOLINE; -public class PolyLLVMSourceFileExt extends PolyLLVMExt { +public class JLangSourceFileExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override @@ -36,7 +37,7 @@ public Node leaveTranslateLLVM(LLVMTranslator v) { // Call an entry point within the current module if possible. Map entryPoints = v.getEntryPoints(); - PolyLLVMOptions options = (PolyLLVMOptions) Options.global; + JLangOptions options = (JLangOptions) Options.global; String entryPointClass = options.entryPointClass; if (entryPointClass != null) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMSpecialExt.java b/compiler/src/jlang/extension/JLangSpecialExt.java similarity index 85% rename from compiler/src/polyllvm/extension/PolyLLVMSpecialExt.java rename to compiler/src/jlang/extension/JLangSpecialExt.java index fb3bb1e9..6f031276 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMSpecialExt.java +++ b/compiler/src/jlang/extension/JLangSpecialExt.java @@ -1,15 +1,16 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; import polyglot.ast.Special; import polyglot.util.InternalCompilerError; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMSpecialExt extends PolyLLVMExt { +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + +public class JLangSpecialExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMStringLitExt.java b/compiler/src/jlang/extension/JLangStringLitExt.java similarity index 94% rename from compiler/src/polyllvm/extension/PolyLLVMStringLitExt.java rename to compiler/src/jlang/extension/JLangStringLitExt.java index 1f2d6895..e4845165 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMStringLitExt.java +++ b/compiler/src/jlang/extension/JLangStringLitExt.java @@ -1,10 +1,8 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; import polyglot.ast.StringLit; import polyglot.types.ParsedClassType; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.ArrayList; @@ -12,9 +10,12 @@ import java.util.stream.IntStream; import java.util.stream.Stream; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMStringLitExt extends PolyLLVMExt { +public class JLangStringLitExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMSwitchExt.java b/compiler/src/jlang/extension/JLangSwitchExt.java similarity index 96% rename from compiler/src/polyllvm/extension/PolyLLVMSwitchExt.java rename to compiler/src/jlang/extension/JLangSwitchExt.java index 0c1ce384..07dff164 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMSwitchExt.java +++ b/compiler/src/jlang/extension/JLangSwitchExt.java @@ -1,19 +1,20 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.*; +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMSwitchExt extends PolyLLVMExt { +public class JLangSwitchExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMSynchronizedExt.java b/compiler/src/jlang/extension/JLangSynchronizedExt.java similarity index 70% rename from compiler/src/polyllvm/extension/PolyLLVMSynchronizedExt.java rename to compiler/src/jlang/extension/JLangSynchronizedExt.java index 954cadd1..7af5d2bb 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMSynchronizedExt.java +++ b/compiler/src/jlang/extension/JLangSynchronizedExt.java @@ -1,10 +1,10 @@ -package polyllvm.extension; +package jlang.extension; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; import polyglot.ast.Node; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; -public class PolyLLVMSynchronizedExt extends PolyLLVMExt { +public class JLangSynchronizedExt extends JLangExt { private static boolean printedWarning = false; @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMThrowExt.java b/compiler/src/jlang/extension/JLangThrowExt.java similarity index 83% rename from compiler/src/polyllvm/extension/PolyLLVMThrowExt.java rename to compiler/src/jlang/extension/JLangThrowExt.java index 293a32f6..7007dd3d 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMThrowExt.java +++ b/compiler/src/jlang/extension/JLangThrowExt.java @@ -1,16 +1,17 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; import polyglot.ast.Throw; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.util.Constants; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.util.Constants; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMThrowExt extends PolyLLVMExt { +public class JLangThrowExt extends JLangExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMTryExt.java b/compiler/src/jlang/extension/JLangTryExt.java similarity index 98% rename from compiler/src/polyllvm/extension/PolyLLVMTryExt.java rename to compiler/src/jlang/extension/JLangTryExt.java index 77ab41c5..4232f1f6 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMTryExt.java +++ b/compiler/src/jlang/extension/JLangTryExt.java @@ -1,16 +1,17 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Catch; import polyglot.ast.Node; import polyglot.ast.Try; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.util.Constants; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.LinkedHashSet; import java.util.Set; +import jlang.ast.JLangExt; +import jlang.util.Constants; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; /** @@ -39,7 +40,7 @@ * statements can run requisite finally blocks before emitting the ret instruction. This state is * held in the translator, but updated by this class during translation. */ -public class PolyLLVMTryExt extends PolyLLVMExt { +public class JLangTryExt extends JLangExt { /** * An exception frame holds information relevant to a try-catch-finally block, diff --git a/compiler/src/polyllvm/extension/PolyLLVMTryWithResourcesExt.java b/compiler/src/jlang/extension/JLangTryWithResourcesExt.java similarity index 97% rename from compiler/src/polyllvm/extension/PolyLLVMTryWithResourcesExt.java rename to compiler/src/jlang/extension/JLangTryWithResourcesExt.java index 5d4333da..88b97bb1 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMTryWithResourcesExt.java +++ b/compiler/src/jlang/extension/JLangTryWithResourcesExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.ext.jl7.ast.TryWithResources; @@ -6,14 +6,15 @@ import polyglot.types.Flags; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class PolyLLVMTryWithResourcesExt extends PolyLLVMTryExt { +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + +public class JLangTryWithResourcesExt extends JLangTryExt { @Override public Node leaveTranslateLLVM(LLVMTranslator v) { diff --git a/compiler/src/polyllvm/extension/PolyLLVMUnaryExt.java b/compiler/src/jlang/extension/JLangUnaryExt.java similarity index 95% rename from compiler/src/polyllvm/extension/PolyLLVMUnaryExt.java rename to compiler/src/jlang/extension/JLangUnaryExt.java index 7a656153..8f47a819 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMUnaryExt.java +++ b/compiler/src/jlang/extension/JLangUnaryExt.java @@ -1,4 +1,4 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.*; import polyglot.ast.Unary.*; @@ -8,17 +8,18 @@ import polyglot.util.Position; import polyglot.util.SerialVersionUID; import polyglot.visit.AscriptionVisitor; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.DesugarLocally; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.Arrays; +import jlang.ast.JLangExt; +import jlang.visit.DesugarLocally; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; import static polyglot.ast.Unary.*; -public class PolyLLVMUnaryExt extends PolyLLVMExt { +public class JLangUnaryExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/polyllvm/extension/PolyLLVMWhileExt.java b/compiler/src/jlang/extension/JLangWhileExt.java similarity index 87% rename from compiler/src/polyllvm/extension/PolyLLVMWhileExt.java rename to compiler/src/jlang/extension/JLangWhileExt.java index 1163db30..9f3081c6 100644 --- a/compiler/src/polyllvm/extension/PolyLLVMWhileExt.java +++ b/compiler/src/jlang/extension/JLangWhileExt.java @@ -1,16 +1,17 @@ -package polyllvm.extension; +package jlang.extension; import polyglot.ast.Node; import polyglot.ast.While; import polyglot.util.SerialVersionUID; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; +import jlang.ast.JLangExt; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; -public class PolyLLVMWhileExt extends PolyLLVMExt { +public class JLangWhileExt extends JLangExt { private static final long serialVersionUID = SerialVersionUID.generate(); @Override diff --git a/compiler/src/jlang/extension/package.html b/compiler/src/jlang/extension/package.html new file mode 100644 index 00000000..77a517fa --- /dev/null +++ b/compiler/src/jlang/extension/package.html @@ -0,0 +1,5 @@ + +

+AST extensions and delegates for the JLang language extension. +

+ diff --git a/compiler/src/jlang/package.html b/compiler/src/jlang/package.html new file mode 100644 index 00000000..c3b43143 --- /dev/null +++ b/compiler/src/jlang/package.html @@ -0,0 +1,5 @@ + +

+JLang language extension. +

+ diff --git a/compiler/src/polyllvm/structures/ClassObjects.java b/compiler/src/jlang/structures/ClassObjects.java similarity index 97% rename from compiler/src/polyllvm/structures/ClassObjects.java rename to compiler/src/jlang/structures/ClassObjects.java index cd25eeff..4d60acd0 100644 --- a/compiler/src/polyllvm/structures/ClassObjects.java +++ b/compiler/src/jlang/structures/ClassObjects.java @@ -1,10 +1,11 @@ -package polyllvm.structures; +package jlang.structures; import polyglot.types.ReferenceType; -import polyllvm.visit.LLVMTranslator; import java.util.*; +import jlang.visit.LLVMTranslator; + import static org.bytedeco.javacpp.LLVM.*; /** diff --git a/compiler/src/polyllvm/structures/DispatchVector.java b/compiler/src/jlang/structures/DispatchVector.java similarity index 97% rename from compiler/src/polyllvm/structures/DispatchVector.java rename to compiler/src/jlang/structures/DispatchVector.java index 2467e367..327de301 100644 --- a/compiler/src/polyllvm/structures/DispatchVector.java +++ b/compiler/src/jlang/structures/DispatchVector.java @@ -1,4 +1,4 @@ -package polyllvm.structures; +package jlang.structures; import org.bytedeco.javacpp.LLVM.LLVMTypeRef; import org.bytedeco.javacpp.LLVM.LLVMValueRef; diff --git a/compiler/src/polyllvm/structures/DispatchVector_c.java b/compiler/src/jlang/structures/DispatchVector_c.java similarity index 98% rename from compiler/src/polyllvm/structures/DispatchVector_c.java rename to compiler/src/jlang/structures/DispatchVector_c.java index d06a44ba..47f45af2 100644 --- a/compiler/src/polyllvm/structures/DispatchVector_c.java +++ b/compiler/src/jlang/structures/DispatchVector_c.java @@ -1,12 +1,13 @@ -package polyllvm.structures; +package jlang.structures; import org.bytedeco.javacpp.LLVM; import org.bytedeco.javacpp.LLVM.LLVMTypeRef; import org.bytedeco.javacpp.LLVM.LLVMValueRef; + +import jlang.visit.LLVMTranslator; import polyglot.types.ClassType; import polyglot.types.MethodInstance; import polyglot.types.ReferenceType; -import polyllvm.visit.LLVMTranslator; import java.util.HashMap; import java.util.List; diff --git a/compiler/src/polyllvm/structures/ObjectStruct.java b/compiler/src/jlang/structures/ObjectStruct.java similarity index 97% rename from compiler/src/polyllvm/structures/ObjectStruct.java rename to compiler/src/jlang/structures/ObjectStruct.java index 60b93282..d74c8f17 100644 --- a/compiler/src/polyllvm/structures/ObjectStruct.java +++ b/compiler/src/jlang/structures/ObjectStruct.java @@ -1,4 +1,4 @@ -package polyllvm.structures; +package jlang.structures; import org.bytedeco.javacpp.LLVM.LLVMTypeRef; import org.bytedeco.javacpp.LLVM.LLVMValueRef; diff --git a/compiler/src/polyllvm/structures/ObjectStruct_c.java b/compiler/src/jlang/structures/ObjectStruct_c.java similarity index 99% rename from compiler/src/polyllvm/structures/ObjectStruct_c.java rename to compiler/src/jlang/structures/ObjectStruct_c.java index b7a119f5..3ea885bc 100644 --- a/compiler/src/polyllvm/structures/ObjectStruct_c.java +++ b/compiler/src/jlang/structures/ObjectStruct_c.java @@ -1,9 +1,10 @@ -package polyllvm.structures; +package jlang.structures; import org.bytedeco.javacpp.LLVM.*; + +import jlang.visit.LLVMTranslator; import polyglot.types.*; import polyglot.util.InternalCompilerError; -import polyllvm.visit.LLVMTranslator; import java.lang.Override; import java.util.*; diff --git a/compiler/src/polyllvm/test/TestAll.java b/compiler/src/jlang/test/TestAll.java similarity index 89% rename from compiler/src/polyllvm/test/TestAll.java rename to compiler/src/jlang/test/TestAll.java index 8a152e50..4d382517 100644 --- a/compiler/src/polyllvm/test/TestAll.java +++ b/compiler/src/jlang/test/TestAll.java @@ -1,4 +1,4 @@ -package polyllvm.test; +package jlang.test; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/compiler/src/polyllvm/test/TestFunctional.java b/compiler/src/jlang/test/TestFunctional.java similarity index 98% rename from compiler/src/polyllvm/test/TestFunctional.java rename to compiler/src/jlang/test/TestFunctional.java index 5cf6d51f..4b264c67 100644 --- a/compiler/src/polyllvm/test/TestFunctional.java +++ b/compiler/src/jlang/test/TestFunctional.java @@ -1,4 +1,4 @@ -package polyllvm.test; +package jlang.test; import org.junit.BeforeClass; import org.junit.Test; diff --git a/compiler/src/polyllvm/test/TestUtil.java b/compiler/src/jlang/test/TestUtil.java similarity index 99% rename from compiler/src/polyllvm/test/TestUtil.java rename to compiler/src/jlang/test/TestUtil.java index 7e304f2b..3465d5c1 100644 --- a/compiler/src/polyllvm/test/TestUtil.java +++ b/compiler/src/jlang/test/TestUtil.java @@ -1,4 +1,4 @@ -package polyllvm.test; +package jlang.test; import java.io.File; import java.io.IOException; diff --git a/compiler/src/polyllvm/types/PolyLLVMClassFileLazyClassInitializer.java b/compiler/src/jlang/types/JLangClassFileLazyClassInitializer.java similarity index 61% rename from compiler/src/polyllvm/types/PolyLLVMClassFileLazyClassInitializer.java rename to compiler/src/jlang/types/JLangClassFileLazyClassInitializer.java index 2311dd5a..33b331ac 100644 --- a/compiler/src/polyllvm/types/PolyLLVMClassFileLazyClassInitializer.java +++ b/compiler/src/jlang/types/JLangClassFileLazyClassInitializer.java @@ -1,4 +1,4 @@ -package polyllvm.types; +package jlang.types; import polyglot.ext.jl5.types.reflect.JL5ClassFileLazyClassInitializer; import polyglot.types.ClassType; @@ -6,11 +6,11 @@ import polyglot.types.reflect.ClassFile; import polyglot.types.reflect.Method; -public class PolyLLVMClassFileLazyClassInitializer extends JL5ClassFileLazyClassInitializer { +public class JLangClassFileLazyClassInitializer extends JL5ClassFileLazyClassInitializer { - PolyLLVMTypeSystem ts; + JLangTypeSystem ts; - public PolyLLVMClassFileLazyClassInitializer(ClassFile file, PolyLLVMTypeSystem ts) { + public JLangClassFileLazyClassInitializer(ClassFile file, JLangTypeSystem ts) { super(file, ts); this.ts = ts; } @@ -18,7 +18,7 @@ public PolyLLVMClassFileLazyClassInitializer(ClassFile file, PolyLLVMTypeSystem @Override protected MethodInstance methodInstance(Method m, ClassType ct) { MethodInstance mi = super.methodInstance(m, ct); - PolyLLVMParsedClassType_c pct = (PolyLLVMParsedClassType_c) ct; + JLangParsedClassType_c pct = (JLangParsedClassType_c) ct; if (pct.isNewMethod(mi)) { return mi; } else { diff --git a/compiler/src/polyllvm/types/PolyLLVMLocalInstance.java b/compiler/src/jlang/types/JLangLocalInstance.java similarity index 75% rename from compiler/src/polyllvm/types/PolyLLVMLocalInstance.java rename to compiler/src/jlang/types/JLangLocalInstance.java index 82da6eca..f03b415d 100644 --- a/compiler/src/polyllvm/types/PolyLLVMLocalInstance.java +++ b/compiler/src/jlang/types/JLangLocalInstance.java @@ -1,8 +1,8 @@ -package polyllvm.types; +package jlang.types; import polyglot.ext.jl5.types.JL5LocalInstance; -public interface PolyLLVMLocalInstance extends JL5LocalInstance { +public interface JLangLocalInstance extends JL5LocalInstance { /** * Whether this is a compiler-generated variable that should not be diff --git a/compiler/src/polyllvm/types/PolyLLVMLocalInstance_c.java b/compiler/src/jlang/types/JLangLocalInstance_c.java similarity index 81% rename from compiler/src/polyllvm/types/PolyLLVMLocalInstance_c.java rename to compiler/src/jlang/types/JLangLocalInstance_c.java index 08f436eb..d5c0ac66 100644 --- a/compiler/src/polyllvm/types/PolyLLVMLocalInstance_c.java +++ b/compiler/src/jlang/types/JLangLocalInstance_c.java @@ -1,4 +1,4 @@ -package polyllvm.types; +package jlang.types; import polyglot.ext.jl5.types.JL5LocalInstance_c; import polyglot.types.Flags; @@ -6,12 +6,12 @@ import polyglot.types.TypeSystem; import polyglot.util.Position; -public class PolyLLVMLocalInstance_c +public class JLangLocalInstance_c extends JL5LocalInstance_c - implements PolyLLVMLocalInstance { + implements JLangLocalInstance { private final boolean isTemp, isSSA; - public PolyLLVMLocalInstance_c( + public JLangLocalInstance_c( TypeSystem ts, Position pos, Flags flags, Type type, String name, boolean isTemp, boolean isSSA) { super(ts, pos, flags, type, name); diff --git a/compiler/src/polyllvm/types/PolyLLVMParsedClassType_c.java b/compiler/src/jlang/types/JLangParsedClassType_c.java similarity index 84% rename from compiler/src/polyllvm/types/PolyLLVMParsedClassType_c.java rename to compiler/src/jlang/types/JLangParsedClassType_c.java index aa595b00..f2f7ea45 100644 --- a/compiler/src/polyllvm/types/PolyLLVMParsedClassType_c.java +++ b/compiler/src/jlang/types/JLangParsedClassType_c.java @@ -1,5 +1,6 @@ -package polyllvm.types; +package jlang.types; +import jlang.visit.NameAnonClasses; import polyglot.ext.jl5.types.JL5MethodInstance; import polyglot.ext.jl5.types.JL5ParsedClassType_c; import polyglot.frontend.Source; @@ -7,12 +8,11 @@ import polyglot.types.LazyClassInitializer; import polyglot.types.MethodInstance; import polyglot.types.TypeSystem; -import polyllvm.visit.NameAnonClasses; -public class PolyLLVMParsedClassType_c extends JL5ParsedClassType_c { +public class JLangParsedClassType_c extends JL5ParsedClassType_c { - PolyLLVMTypeSystem ts; - public PolyLLVMParsedClassType_c(PolyLLVMTypeSystem ts, LazyClassInitializer init, Source fromSource) { + JLangTypeSystem ts; + public JLangParsedClassType_c(JLangTypeSystem ts, LazyClassInitializer init, Source fromSource) { super(ts, init, fromSource); this.ts = ts; } diff --git a/compiler/src/polyllvm/types/PolyLLVMSubstMethodInstance_c.java b/compiler/src/jlang/types/JLangSubstMethodInstance_c.java similarity index 88% rename from compiler/src/polyllvm/types/PolyLLVMSubstMethodInstance_c.java rename to compiler/src/jlang/types/JLangSubstMethodInstance_c.java index 45f4df7e..ca830138 100644 --- a/compiler/src/polyllvm/types/PolyLLVMSubstMethodInstance_c.java +++ b/compiler/src/jlang/types/JLangSubstMethodInstance_c.java @@ -1,4 +1,4 @@ -package polyllvm.types; +package jlang.types; import polyglot.ext.jl5.types.JL5MethodInstance; import polyglot.ext.jl5.types.JL5MethodInstance_c; @@ -10,14 +10,14 @@ /** * See {@link SubstMethodInstance}. */ -public class PolyLLVMSubstMethodInstance_c extends JL5MethodInstance_c +public class JLangSubstMethodInstance_c extends JL5MethodInstance_c implements SubstMethodInstance { private static final long serialVersionUID = SerialVersionUID.generate(); final protected JL5MethodInstance base; final protected JL5Subst subst; - public PolyLLVMSubstMethodInstance_c(JL5MethodInstance postSubst, + public JLangSubstMethodInstance_c(JL5MethodInstance postSubst, JL5MethodInstance preSubst, JL5Subst subst) { super((JL5TypeSystem) postSubst.typeSystem(), postSubst.position(), postSubst.container(), postSubst.flags(), diff --git a/compiler/src/polyllvm/types/PolyLLVMTypeSystem.java b/compiler/src/jlang/types/JLangTypeSystem.java similarity index 82% rename from compiler/src/polyllvm/types/PolyLLVMTypeSystem.java rename to compiler/src/jlang/types/JLangTypeSystem.java index 371ddf76..5cc1244d 100644 --- a/compiler/src/polyllvm/types/PolyLLVMTypeSystem.java +++ b/compiler/src/jlang/types/JLangTypeSystem.java @@ -1,4 +1,4 @@ -package polyllvm.types; +package jlang.types; import polyglot.ext.jl5.types.JL5MethodInstance; import polyglot.ext.jl5.types.JL5Subst; @@ -9,20 +9,20 @@ import polyglot.types.Type; import polyglot.util.Position; -public interface PolyLLVMTypeSystem extends JL7TypeSystem { +public interface JLangTypeSystem extends JL7TypeSystem { ParsedClassType ArrayObject(); ClassType RuntimeHelper(); @Override - PolyLLVMLocalInstance localInstance(Position pos, Flags flags, Type type, String name); + JLangLocalInstance localInstance(Position pos, Flags flags, Type type, String name); /** * Creates a local instance with the option of making it a temp variable, which * is hidden from the user when debugging. */ - PolyLLVMLocalInstance localInstance( + JLangLocalInstance localInstance( Position pos, Flags flags, Type type, String name, boolean isTemp, boolean isSSA); SubstMethodInstance substMethodInstance(JL5MethodInstance postSubst, diff --git a/compiler/src/polyllvm/types/PolyLLVMTypeSystem_c.java b/compiler/src/jlang/types/JLangTypeSystem_c.java similarity index 78% rename from compiler/src/polyllvm/types/PolyLLVMTypeSystem_c.java rename to compiler/src/jlang/types/JLangTypeSystem_c.java index c09f0c6b..859061d6 100644 --- a/compiler/src/polyllvm/types/PolyLLVMTypeSystem_c.java +++ b/compiler/src/jlang/types/JLangTypeSystem_c.java @@ -1,4 +1,7 @@ -package polyllvm.types; +package jlang.types; + +import static jlang.util.Constants.RUNTIME_ARRAY; +import static jlang.util.Constants.RUNTIME_HELPER; import polyglot.ext.jl5.types.JL5MethodInstance; import polyglot.ext.jl5.types.JL5Subst; @@ -10,22 +13,19 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import static polyllvm.util.Constants.RUNTIME_ARRAY; -import static polyllvm.util.Constants.RUNTIME_HELPER; - -public class PolyLLVMTypeSystem_c extends JL7TypeSystem_c implements PolyLLVMTypeSystem { +public class JLangTypeSystem_c extends JL7TypeSystem_c implements JLangTypeSystem { @Override public ClassFileLazyClassInitializer classFileLazyClassInitializer(ClassFile clazz) { - return new PolyLLVMClassFileLazyClassInitializer(clazz, this); + return new JLangClassFileLazyClassInitializer(clazz, this); } @Override public SubstMethodInstance substMethodInstance( JL5MethodInstance postSubst, JL5MethodInstance preSubst, JL5Subst subst) { - return new PolyLLVMSubstMethodInstance_c(postSubst, preSubst, subst); + return new JLangSubstMethodInstance_c(postSubst, preSubst, subst); } @Override @@ -47,19 +47,19 @@ public ParsedClassType RuntimeHelper() { } @Override - public PolyLLVMLocalInstance localInstance(Position pos, Flags flags, Type type, String name) { + public JLangLocalInstance localInstance(Position pos, Flags flags, Type type, String name) { return localInstance(pos, flags, type, name, /*isTemp*/ false, /*isSSA*/ false); } @Override - public PolyLLVMLocalInstance localInstance( + public JLangLocalInstance localInstance( Position pos, Flags flags, Type type, String name, boolean isTemp, boolean isSSA) { - return new PolyLLVMLocalInstance_c(this, pos, flags, type, name, isTemp, isSSA); + return new JLangLocalInstance_c(this, pos, flags, type, name, isTemp, isSSA); } @Override public ParsedClassType createClassType(LazyClassInitializer init, Source fromSource) { - return new PolyLLVMParsedClassType_c(this, init, fromSource); + return new JLangParsedClassType_c(this, init, fromSource); } @Override diff --git a/compiler/src/polyllvm/types/SubstMethodInstance.java b/compiler/src/jlang/types/SubstMethodInstance.java similarity index 97% rename from compiler/src/polyllvm/types/SubstMethodInstance.java rename to compiler/src/jlang/types/SubstMethodInstance.java index 211e0df9..2a6aa2b4 100644 --- a/compiler/src/polyllvm/types/SubstMethodInstance.java +++ b/compiler/src/jlang/types/SubstMethodInstance.java @@ -1,4 +1,4 @@ -package polyllvm.types; +package jlang.types; import polyglot.ext.jl5.types.JL5MethodInstance; import polyglot.ext.jl5.types.JL5Subst; diff --git a/compiler/src/polyllvm/util/CollectUtils.java b/compiler/src/jlang/util/CollectUtils.java similarity index 97% rename from compiler/src/polyllvm/util/CollectUtils.java rename to compiler/src/jlang/util/CollectUtils.java index 732d4368..7558665f 100644 --- a/compiler/src/polyllvm/util/CollectUtils.java +++ b/compiler/src/jlang/util/CollectUtils.java @@ -1,4 +1,4 @@ -package polyllvm.util; +package jlang.util; import java.lang.reflect.Array; import java.util.List; diff --git a/compiler/src/polyllvm/util/Constants.java b/compiler/src/jlang/util/Constants.java similarity index 86% rename from compiler/src/polyllvm/util/Constants.java rename to compiler/src/jlang/util/Constants.java index f595c452..b81a6c69 100644 --- a/compiler/src/polyllvm/util/Constants.java +++ b/compiler/src/jlang/util/Constants.java @@ -1,4 +1,4 @@ -package polyllvm.util; +package jlang.util; import polyglot.util.CollectionUtil; @@ -6,10 +6,10 @@ import java.util.Set; /** - * PolyLLVM constants for, e.g., important method names and array data layout. + * JLang constants for, e.g., important method names and array data layout. */ public class Constants { - public static final String RUNTIME_PACKAGE = "polyllvm.runtime"; + public static final String RUNTIME_PACKAGE = "jlang.runtime"; public static final String RUNTIME_HELPER = RUNTIME_PACKAGE + ".Helper"; public static final String RUNTIME_ARRAY = RUNTIME_PACKAGE + ".Array"; public static final String RUNTIME_ARRAY_TYPE = RUNTIME_ARRAY + ".Type"; @@ -17,7 +17,7 @@ public class Constants { public static final String PRIMITIVE_CLASS_OBJECT_SUFFIX = "ClassObject"; public static final String CALLOC = "GC_malloc"; - public static final String ENTRY_TRAMPOLINE = "Java_polyllvm_runtime_MainWrapper_main"; + public static final String ENTRY_TRAMPOLINE = "Java_jlang_runtime_MainWrapper_main"; public static final int LLVM_ADDR_SPACE = 0; public static final int CTOR_METHOD_INFO_OFFSET = -2; diff --git a/compiler/src/polyllvm/util/DebugInfo.java b/compiler/src/jlang/util/DebugInfo.java similarity index 97% rename from compiler/src/polyllvm/util/DebugInfo.java rename to compiler/src/jlang/util/DebugInfo.java index c3b9d5b1..92710a17 100644 --- a/compiler/src/polyllvm/util/DebugInfo.java +++ b/compiler/src/jlang/util/DebugInfo.java @@ -1,13 +1,14 @@ -package polyllvm.util; +package jlang.util; import org.bytedeco.javacpp.BytePointer; import org.bytedeco.javacpp.PointerPointer; + +import jlang.visit.LLVMTranslator; import polyglot.ast.*; import polyglot.types.ProcedureInstance; import polyglot.types.Type; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.visit.LLVMTranslator; import java.io.File; import java.util.ArrayDeque; @@ -15,9 +16,9 @@ import java.util.HashMap; import java.util.List; +import static jlang.util.Constants.DEBUG_DWARF_VERSION; +import static jlang.util.Constants.DEBUG_INFO_VERSION; import static org.bytedeco.javacpp.LLVM.*; -import static polyllvm.util.Constants.DEBUG_DWARF_VERSION; -import static polyllvm.util.Constants.DEBUG_INFO_VERSION; /** * Created by Daniel on 2/24/17. @@ -42,7 +43,7 @@ public DebugInfo(LLVMTranslator v, LLVMModuleRef mod, String path) { debugFile = LLVMDIBuilderCreateFile(diBuilder, fileName, fileDir); compileUnit = LLVMDIBuilderCreateCompileUnit( - diBuilder, DW_LANG_Java, fileName, fileDir, "PolyLLVM", 0, "", 0); + diBuilder, DW_LANG_Java, fileName, fileDir, "JLang", 0, "", 0); LLVMAddModuleFlag(mod, Warning, "Debug Info Version", DEBUG_INFO_VERSION); diff --git a/compiler/src/jlang/util/DesugarBarrier.java b/compiler/src/jlang/util/DesugarBarrier.java new file mode 100644 index 00000000..ba2f41db --- /dev/null +++ b/compiler/src/jlang/util/DesugarBarrier.java @@ -0,0 +1,26 @@ +package jlang.util; + +import jlang.JLangScheduler; +import polyglot.frontend.Job; +import polyglot.frontend.goals.Barrier; +import polyglot.frontend.goals.Goal; + +public class DesugarBarrier extends Barrier { + + private final JLangScheduler jlangScheduler; + + public static DesugarBarrier create(JLangScheduler s) { + return new DesugarBarrier(s); + } + + protected DesugarBarrier(JLangScheduler scheduler) { + super(scheduler); + this.jlangScheduler = scheduler; + } + + @Override + public Goal goalForJob(Job job) { + return this.jlangScheduler.LLVMDesugared(job); + } + +} diff --git a/compiler/src/polyllvm/util/PolyLLVMDesugared.java b/compiler/src/jlang/util/JLangDesugared.java similarity index 91% rename from compiler/src/polyllvm/util/PolyLLVMDesugared.java rename to compiler/src/jlang/util/JLangDesugared.java index ff8f0daf..71dfc543 100644 --- a/compiler/src/polyllvm/util/PolyLLVMDesugared.java +++ b/compiler/src/jlang/util/JLangDesugared.java @@ -1,4 +1,4 @@ -package polyllvm.util; +package jlang.util; import polyglot.frontend.*; import polyglot.frontend.goals.AbstractGoal; @@ -7,26 +7,27 @@ import polyglot.types.ParsedClassType; import polyglot.types.SemanticException; import polyglot.util.InternalCompilerError; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.visit.*; import java.util.stream.Stream; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; +import jlang.visit.*; + /** - * Runs all PolyLLVM desugar passes so that the AST is + * Runs all JLang desugar passes so that the AST is * fully desugared and ready for emitting LLVM IR. */ -public class PolyLLVMDesugared extends AbstractGoal { +public class JLangDesugared extends AbstractGoal { private boolean attempted = false; private final Goal[] goals; - public PolyLLVMDesugared(Job job) { + public JLangDesugared(Job job) { super(job); ExtensionInfo extInfo = job.extensionInfo(); - PolyLLVMTypeSystem ts = (PolyLLVMTypeSystem) extInfo.typeSystem(); - PolyLLVMNodeFactory nf = (PolyLLVMNodeFactory) extInfo.nodeFactory(); + JLangTypeSystem ts = (JLangTypeSystem) extInfo.typeSystem(); + JLangNodeFactory nf = (JLangNodeFactory) extInfo.nodeFactory(); goals = new Goal[] { // Visitor passes running after type checking must preserve type information. diff --git a/compiler/src/polyllvm/util/PolyLLVMFreshGen.java b/compiler/src/jlang/util/JLangFreshGen.java similarity index 73% rename from compiler/src/polyllvm/util/PolyLLVMFreshGen.java rename to compiler/src/jlang/util/JLangFreshGen.java index e4b35eee..5609ef58 100644 --- a/compiler/src/polyllvm/util/PolyLLVMFreshGen.java +++ b/compiler/src/jlang/util/JLangFreshGen.java @@ -1,21 +1,21 @@ -package polyllvm.util; +package jlang.util; import java.util.HashMap; import java.util.Map; -public class PolyLLVMFreshGen { +public class JLangFreshGen { - private static PolyLLVMFreshGen instance = null; + private static JLangFreshGen instance = null; Map prefixMap; - private PolyLLVMFreshGen() { + private JLangFreshGen() { prefixMap = new HashMap<>(); } - private static PolyLLVMFreshGen instance() { + private static JLangFreshGen instance() { if (instance == null) { - instance = new PolyLLVMFreshGen(); + instance = new JLangFreshGen(); } return instance; } diff --git a/compiler/src/polyllvm/util/PolyLLVMMangler.java b/compiler/src/jlang/util/JLangMangler.java similarity index 96% rename from compiler/src/polyllvm/util/PolyLLVMMangler.java rename to compiler/src/jlang/util/JLangMangler.java index f3a863d6..67e470c1 100644 --- a/compiler/src/polyllvm/util/PolyLLVMMangler.java +++ b/compiler/src/jlang/util/JLangMangler.java @@ -1,16 +1,16 @@ -package polyllvm.util; +package jlang.util; +import jlang.visit.LLVMTranslator; import polyglot.ast.ClassDecl; import polyglot.types.*; import polyglot.util.InternalCompilerError; -import polyllvm.visit.LLVMTranslator; /** Mangles Java methods and variables for use in LLVM IR. */ -public class PolyLLVMMangler { +public class JLangMangler { private static final int CODE_POINT_PADDED_LENGTH = 4; private final LLVMTranslator v; - public PolyLLVMMangler(LLVMTranslator v) { + public JLangMangler(LLVMTranslator v) { this.v = v; } @@ -75,7 +75,7 @@ private String escapeSignature(String signature) { String sig = signature .replace("_", UNDERSCORE_ESCAPE) .replace("/", "_") - .replace(".", "_") //hacky -> part of Polyllvm not Java spec. TODO is refactor code to use different escapes + .replace(".", "_") //hacky -> part of JLang not Java spec. TODO is refactor code to use different escapes .replace(";", SEMICOLON_ESCAPE) .replace("[", BRACKET_ESCAPE); StringBuffer result = new StringBuffer(sig.length()); @@ -129,7 +129,7 @@ private String jniEscapedSignature(Type t) { } /** - * Similar to {@link PolyLLVMMangler#jniUnescapedSignature(Type)}, but + * Similar to {@link JLangMangler#jniUnescapedSignature(Type)}, but * merges types with the same calling convention treatment. */ private String callingConventionSignature(Type t) { @@ -137,7 +137,7 @@ private String callingConventionSignature(Type t) { } /** - * Similar to {@link PolyLLVMMangler#jniUnescapedSignature(ProcedureInstance)}, but + * Similar to {@link JLangMangler#jniUnescapedSignature(ProcedureInstance)}, but * merges signatures with the same calling convention. */ public String callingConventionSignature(ProcedureInstance pi) { diff --git a/compiler/src/polyllvm/util/LLVMUtils.java b/compiler/src/jlang/util/LLVMUtils.java similarity index 99% rename from compiler/src/polyllvm/util/LLVMUtils.java rename to compiler/src/jlang/util/LLVMUtils.java index b639c6ea..c18a589d 100644 --- a/compiler/src/polyllvm/util/LLVMUtils.java +++ b/compiler/src/jlang/util/LLVMUtils.java @@ -1,6 +1,8 @@ -package polyllvm.util; +package jlang.util; import org.bytedeco.javacpp.PointerPointer; + +import jlang.visit.LLVMTranslator; import polyglot.ext.jl5.types.JL5TypeSystem; import polyglot.ext.jl5.types.RawClass; import polyglot.ext.jl5.types.inference.LubType; @@ -8,7 +10,6 @@ import polyglot.types.*; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.visit.LLVMTranslator; import java.util.ArrayList; import java.util.List; diff --git a/compiler/src/polyllvm/util/Triple.java b/compiler/src/jlang/util/Triple.java similarity index 99% rename from compiler/src/polyllvm/util/Triple.java rename to compiler/src/jlang/util/Triple.java index 05e82bc8..85b9ae24 100644 --- a/compiler/src/polyllvm/util/Triple.java +++ b/compiler/src/jlang/util/Triple.java @@ -24,7 +24,7 @@ * See README for contributors. ******************************************************************************/ -package polyllvm.util; +package jlang.util; import java.util.Objects; diff --git a/compiler/src/polyllvm/util/TypedNodeFactory.java b/compiler/src/jlang/util/TypedNodeFactory.java similarity index 92% rename from compiler/src/polyllvm/util/TypedNodeFactory.java rename to compiler/src/jlang/util/TypedNodeFactory.java index be81bf25..b3447a03 100644 --- a/compiler/src/polyllvm/util/TypedNodeFactory.java +++ b/compiler/src/jlang/util/TypedNodeFactory.java @@ -1,30 +1,31 @@ -package polyllvm.util; +package jlang.util; import polyglot.ast.*; import polyglot.types.*; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyllvm.ast.*; -import polyllvm.extension.PolyLLVMArrayAccessExt; -import polyllvm.extension.PolyLLVMCallExt; -import polyllvm.types.PolyLLVMTypeSystem; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import jlang.ast.*; +import jlang.extension.JLangArrayAccessExt; +import jlang.extension.JLangCallExt; +import jlang.types.JLangTypeSystem; + /** * Helper methods for creating typed nodes. Handles generics. * - * This is used in PolyLLVM, so we don't care about (for example) + * This is used in JLang, so we don't care about (for example) * exception types on method instances. */ public class TypedNodeFactory { - protected final PolyLLVMTypeSystem ts; - protected final PolyLLVMNodeFactory nf; + protected final JLangTypeSystem ts; + protected final JLangNodeFactory nf; - public TypedNodeFactory(PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public TypedNodeFactory(JLangTypeSystem ts, JLangNodeFactory nf) { this.ts = ts; this.nf = nf; } @@ -123,13 +124,13 @@ public MethodDecl MethodDecl( List argTypes = formals.stream().map(Formal::declType).collect(Collectors.toList()); MethodInstance mi = ts.methodInstance( pos, container, flags, returnType, name, argTypes, - Collections.emptyList()); // PolyLLVM does not care about exn types. + Collections.emptyList()); // JLang does not care about exn types. container.addMethod(mi); TypeNode returnTypeNode = nf.CanonicalTypeNode(pos, returnType); Id id = nf.Id(pos, name); return nf.MethodDecl( pos, flags, returnTypeNode, id, formals, - Collections.emptyList(), // PolyLLVM does not care about exn types. + Collections.emptyList(), // JLang does not care about exn types. body, /*javaDoc*/ null) .methodInstance(mi); } @@ -137,10 +138,10 @@ public MethodDecl MethodDecl( public ConstructorDecl ConstructorDecl( Position pos, ParsedClassType container, List formals, Block body) { List argTypes = formals.stream().map(Formal::declType).collect(Collectors.toList()); - Flags flags = Flags.NONE; // Constructor flags not important for PolyLLVM. + Flags flags = Flags.NONE; // Constructor flags not important for JLang. ConstructorInstance ci = ts.constructorInstance( pos, container, flags, argTypes, - Collections.emptyList()); // PolyLLVM does not care about exn types. + Collections.emptyList()); // JLang does not care about exn types. container.addConstructor(ci); return nf.ConstructorDecl( pos, flags, nf.Id(pos, container.name()), @@ -158,7 +159,7 @@ public Call StaticCallForced( List argTypes = Arrays.stream(args).map(Expr::type).collect(Collectors.toList()); MethodInstance mi = ts.methodInstance( pos, container, flags, returnType, name, argTypes, - Collections.emptyList()); // PolyLLVM does not care about exn types. + Collections.emptyList()); // JLang does not care about exn types. Receiver receiver = nf.CanonicalTypeNode(pos, container); return Call(pos, receiver, mi, args); } @@ -189,7 +190,7 @@ private Call Call(Position pos, Receiver receiver, MethodInstance mi, Expr... ar Call c = (Call) nf.Call(pos, receiver, id, args) .methodInstance(mi) .type(mi.returnType()); - PolyLLVMCallExt ext = (PolyLLVMCallExt) PolyLLVMExt.ext(c); + JLangCallExt ext = (JLangCallExt) JLangExt.ext(c); return ext.determineIfDirect(c); } @@ -206,7 +207,7 @@ public ConstructorCall ConstructorCall( } /** - * Assumes that {@link polyllvm.visit.DeclareExplicitAnonCtors} has already declared + * Assumes that {@link jlang.visit.DeclareExplicitAnonCtors} has already declared * explicit constructors for anonymous classes. */ public New New(Position pos, ClassType type, Expr outer, List args, ClassBody body) { @@ -309,7 +310,7 @@ public ArrayAccess ArrayAccess(Expr base, Expr index, boolean alreadyGuarded) { ArrayAccess n = (ArrayAccess) nf.ArrayAccess(base.position(), base, index) .type(base.type().toArray().base()); if (alreadyGuarded) - n = ((PolyLLVMArrayAccessExt) PolyLLVMExt.ext(n)).setGuarded(); + n = ((JLangArrayAccessExt) JLangExt.ext(n)).setGuarded(); return n; } diff --git a/compiler/src/polyllvm/visit/DeclareExplicitAnonCtors.java b/compiler/src/jlang/visit/DeclareExplicitAnonCtors.java similarity index 92% rename from compiler/src/polyllvm/visit/DeclareExplicitAnonCtors.java rename to compiler/src/jlang/visit/DeclareExplicitAnonCtors.java index 3a0b9966..b08c1ccf 100644 --- a/compiler/src/polyllvm/visit/DeclareExplicitAnonCtors.java +++ b/compiler/src/jlang/visit/DeclareExplicitAnonCtors.java @@ -1,24 +1,25 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.ext.jl5.ast.EnumConstantDecl; import polyglot.frontend.Job; import polyglot.types.*; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; + /** * Adds an explicit constructor to each anonymous class (including anonymous enum constants). * Explicit constructors are needed to hold class initialization code. */ public class DeclareExplicitAnonCtors extends DesugarVisitor { - public DeclareExplicitAnonCtors(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DeclareExplicitAnonCtors(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); } diff --git a/compiler/src/polyllvm/visit/DesugarEnums.java b/compiler/src/jlang/visit/DesugarEnums.java similarity index 97% rename from compiler/src/polyllvm/visit/DesugarEnums.java rename to compiler/src/jlang/visit/DesugarEnums.java index 83e57f07..bbcee9a0 100644 --- a/compiler/src/polyllvm/visit/DesugarEnums.java +++ b/compiler/src/jlang/visit/DesugarEnums.java @@ -1,4 +1,4 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.ext.jl5.ast.EnumConstant; @@ -10,20 +10,21 @@ import polyglot.types.Flags; import polyglot.types.ParsedClassType; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; import java.util.*; import java.util.stream.Collectors; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; + /** * Desugar Java enum classes into normal classes. Derived from - * {@link polyglot.ext.jl5.visit.RemoveEnums}, but heavily modified for PolyLLVM. + * {@link polyglot.ext.jl5.visit.RemoveEnums}, but heavily modified for JLang. * Preserves typing. */ public class DesugarEnums extends DesugarVisitor { - public DesugarEnums(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DesugarEnums(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); } diff --git a/compiler/src/polyllvm/visit/DesugarImplicitConversions.java b/compiler/src/jlang/visit/DesugarImplicitConversions.java similarity index 85% rename from compiler/src/polyllvm/visit/DesugarImplicitConversions.java rename to compiler/src/jlang/visit/DesugarImplicitConversions.java index 97ab632c..8bab79d8 100644 --- a/compiler/src/polyllvm/visit/DesugarImplicitConversions.java +++ b/compiler/src/jlang/visit/DesugarImplicitConversions.java @@ -1,5 +1,11 @@ -package polyllvm.visit; +package jlang.visit; +import jlang.ast.JLangExt; +import jlang.ast.JLangNodeFactory; +import jlang.extension.JLangCastExt; +import jlang.extension.JLangCastExt.ConversionContext; +import jlang.types.JLangTypeSystem; +import jlang.util.TypedNodeFactory; import polyglot.ast.*; import polyglot.frontend.Job; import polyglot.types.Type; @@ -7,12 +13,6 @@ import polyglot.util.InternalCompilerError; import polyglot.visit.AscriptionVisitor; import polyglot.visit.NodeVisitor; -import polyllvm.ast.PolyLLVMExt; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.extension.PolyLLVMCastExt; -import polyllvm.extension.PolyLLVMCastExt.ConversionContext; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.util.TypedNodeFactory; /** * Turn implicit casts and type promotions into explicit casts. @@ -25,14 +25,14 @@ public class DesugarImplicitConversions extends AscriptionVisitor { private final TypedNodeFactory tnf; - public DesugarImplicitConversions(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DesugarImplicitConversions(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); this.tnf = new TypedNodeFactory(ts, nf); } @Override - public PolyLLVMTypeSystem typeSystem() { - return (PolyLLVMTypeSystem) super.typeSystem(); + public JLangTypeSystem typeSystem() { + return (JLangTypeSystem) super.typeSystem(); } @Override @@ -80,7 +80,7 @@ && typeSystem().typeEqualsErased(e.type(), toType)) { } Cast cast = tnf.Cast(e, toType); - PolyLLVMCastExt ext = (PolyLLVMCastExt) PolyLLVMExt.ext(cast); + JLangCastExt ext = (JLangCastExt) JLangExt.ext(cast); return ext.context(context); } diff --git a/compiler/src/polyllvm/visit/DesugarInnerClasses.java b/compiler/src/jlang/visit/DesugarInnerClasses.java similarity index 94% rename from compiler/src/polyllvm/visit/DesugarInnerClasses.java rename to compiler/src/jlang/visit/DesugarInnerClasses.java index 8ce63c71..52df57be 100644 --- a/compiler/src/polyllvm/visit/DesugarInnerClasses.java +++ b/compiler/src/jlang/visit/DesugarInnerClasses.java @@ -1,4 +1,4 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.frontend.AbstractPass; @@ -13,14 +13,15 @@ import polyglot.types.ParsedClassType; import polyglot.types.SemanticException; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; + +import static jlang.visit.DeclareEnclosingInstances.ENCLOSING_STR; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import static polyllvm.visit.DeclareEnclosingInstances.ENCLOSING_STR; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; /** * Converts qualified this expressions within inner classes into field accesses on @@ -43,7 +44,7 @@ public static boolean hasEnclosingParameter(ParsedClassType ct) { return ct.isInnerClass() && ct.hasEnclosingInstance(ct.outer()); } - public DesugarInnerClasses(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DesugarInnerClasses(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, "Desugar local classes"); declare = new VisitorGoal(job, new DeclareEnclosingInstances(job, ts, nf)); substitute = new VisitorGoal(job, new SubstituteEnclosingInstances(job, ts, nf)); @@ -69,7 +70,7 @@ public boolean run() { class DeclareEnclosingInstances extends DesugarVisitor { static final String ENCLOSING_STR = "enclosing$"; - DeclareEnclosingInstances(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + DeclareEnclosingInstances(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); } @@ -104,7 +105,7 @@ class SubstituteEnclosingInstances extends DesugarVisitor { // when necessary. When inside constructors, be careful to avoid using the enclosing // instance field before it's initialized. - SubstituteEnclosingInstances(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + SubstituteEnclosingInstances(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); } diff --git a/compiler/src/polyllvm/visit/DesugarInstanceInitializers.java b/compiler/src/jlang/visit/DesugarInstanceInitializers.java similarity index 95% rename from compiler/src/polyllvm/visit/DesugarInstanceInitializers.java rename to compiler/src/jlang/visit/DesugarInstanceInitializers.java index 0e9ff830..fcfc60d0 100644 --- a/compiler/src/polyllvm/visit/DesugarInstanceInitializers.java +++ b/compiler/src/jlang/visit/DesugarInstanceInitializers.java @@ -1,18 +1,19 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.frontend.Job; import polyglot.types.Flags; import polyglot.types.ParsedClassType; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; + /** * Builds class initializers at the top of each constructor. * Preserves typing. @@ -23,7 +24,7 @@ public class DesugarInstanceInitializers extends DesugarVisitor { private static final String SELF_FORMAL_NAME = "selfFormal$"; private static final String INSTANCE_INIT_FUNC = "init$instance"; - public DesugarInstanceInitializers(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DesugarInstanceInitializers(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); } diff --git a/compiler/src/polyllvm/visit/DesugarLocalClasses.java b/compiler/src/jlang/visit/DesugarLocalClasses.java similarity index 96% rename from compiler/src/polyllvm/visit/DesugarLocalClasses.java rename to compiler/src/jlang/visit/DesugarLocalClasses.java index b24a9f69..8f80e390 100644 --- a/compiler/src/polyllvm/visit/DesugarLocalClasses.java +++ b/compiler/src/jlang/visit/DesugarLocalClasses.java @@ -1,4 +1,4 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.frontend.AbstractPass; @@ -10,13 +10,14 @@ import polyglot.frontend.goals.VisitorGoal; import polyglot.types.*; import polyglot.util.Position; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; + +import static jlang.visit.DeclareCaptures.CAPTURE_PREFIX; import java.util.*; import java.util.stream.Collectors; -import static polyllvm.visit.DeclareCaptures.CAPTURE_PREFIX; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; /** * Converts captured local variable accesses to field accesses. @@ -39,7 +40,7 @@ public class DesugarLocalClasses extends AbstractGoal { private final Goal declare, substitute; - public DesugarLocalClasses(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DesugarLocalClasses(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, "Desugar local classes"); CaptureContext captures = new CaptureContext(); // Shared capture context. declare = new VisitorGoal(job, new DeclareCaptures(job, ts, nf, captures)); @@ -108,7 +109,7 @@ class DeclareCaptures extends DesugarVisitor { private final Map localClassNestingLevels = new HashMap<>(); DeclareCaptures( - Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf, CaptureContext captures) { + Job job, JLangTypeSystem ts, JLangNodeFactory nf, CaptureContext captures) { super(job, ts, nf); this.captures = captures; } @@ -215,7 +216,7 @@ class SubstituteCaptures extends DesugarVisitor { private final Deque localClasses = new ArrayDeque<>(); SubstituteCaptures( - Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf, CaptureContext captures) { + Job job, JLangTypeSystem ts, JLangNodeFactory nf, CaptureContext captures) { super(job, ts, nf); this.captures = captures; } diff --git a/compiler/src/polyllvm/visit/DesugarLocally.java b/compiler/src/jlang/visit/DesugarLocally.java similarity index 89% rename from compiler/src/polyllvm/visit/DesugarLocally.java rename to compiler/src/jlang/visit/DesugarLocally.java index 3fdbc82a..1fe3eb19 100644 --- a/compiler/src/polyllvm/visit/DesugarLocally.java +++ b/compiler/src/jlang/visit/DesugarLocally.java @@ -1,4 +1,4 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.frontend.Job; @@ -6,17 +6,18 @@ import polyglot.util.OptimalCodeWriter; import polyglot.visit.AscriptionVisitor; import polyglot.visit.PrettyPrinter; -import polyllvm.ast.PolyLLVMLang; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.util.TypedNodeFactory; import java.util.HashSet; import java.util.Set; +import jlang.ast.JLangLang; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; +import jlang.util.TypedNodeFactory; + /** * Applies local desugar transformations by calling the - * {@link polyllvm.ast.PolyLLVMOps#desugar(DesugarLocally)} method + * {@link jlang.ast.JLangOps#desugar(DesugarLocally)} method * on each node until a fixed point is reached. * * Reaching a fixed point allows desugar transformations to create nodes that @@ -43,7 +44,7 @@ * to almost all expressions.) This is why we extend {@link AscriptionVisitor}. * * An example of a local desugar transformation is for array accesses: - * {@code a[i]} can be desugared to an {@link polyllvm.ast.ESeq} of the form + * {@code a[i]} can be desugared to an {@link jlang.ast.ESeq} of the form * {@code if (i < 0 || a >= a.length) throw new ClassCastException(); a[i]}. * In this case, the generated expression {@code a[i]} must be marked to indicate that * it is already guarded by array index check---otherwise we would desugar infinitely. @@ -54,8 +55,8 @@ */ public class DesugarLocally extends DesugarImplicitConversions { public final Job job; - public final PolyLLVMTypeSystem ts; - public final PolyLLVMNodeFactory nf; + public final JLangTypeSystem ts; + public final JLangNodeFactory nf; public final TypedNodeFactory tnf; /** @@ -64,7 +65,7 @@ public class DesugarLocally extends DesugarImplicitConversions { */ protected Set desugared = new HashSet<>(); - public DesugarLocally(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public DesugarLocally(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); this.job = job; this.ts = ts; @@ -73,8 +74,8 @@ public DesugarLocally(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { } @Override - public PolyLLVMLang lang() { - return (PolyLLVMLang) super.lang(); + public JLangLang lang() { + return (JLangLang) super.lang(); } /** Desugar until fixed point. */ diff --git a/compiler/src/polyllvm/visit/DesugarVisitor.java b/compiler/src/jlang/visit/DesugarVisitor.java similarity index 96% rename from compiler/src/polyllvm/visit/DesugarVisitor.java rename to compiler/src/jlang/visit/DesugarVisitor.java index 3365c186..c97ab9f6 100644 --- a/compiler/src/polyllvm/visit/DesugarVisitor.java +++ b/compiler/src/jlang/visit/DesugarVisitor.java @@ -1,4 +1,4 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.*; import polyglot.ext.jl5.ast.EnumConstantDecl; @@ -7,20 +7,21 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.NodeVisitor; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.util.TypedNodeFactory; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; +import jlang.util.TypedNodeFactory; + /** A visitor convenient for desugar passes. Rethrows semantic exceptions, for example. */ public abstract class DesugarVisitor extends NodeVisitor { public final Job job; - public final PolyLLVMTypeSystem ts; - public final PolyLLVMNodeFactory nf; + public final JLangTypeSystem ts; + public final JLangNodeFactory nf; public final TypedNodeFactory tnf; /** Convenience stack of enclosing classes (including anonymous classes). */ @@ -29,7 +30,7 @@ public abstract class DesugarVisitor extends NodeVisitor { /** Convenience stack of enclosing constructors. */ protected final Deque constructors = new ArrayDeque<>(); - DesugarVisitor(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + DesugarVisitor(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(nf.lang()); this.job = job; this.ts = ts; diff --git a/compiler/src/polyllvm/visit/LLVMTranslator.java b/compiler/src/jlang/visit/LLVMTranslator.java similarity index 96% rename from compiler/src/polyllvm/visit/LLVMTranslator.java rename to compiler/src/jlang/visit/LLVMTranslator.java index 8ad12a67..d64cd0de 100644 --- a/compiler/src/polyllvm/visit/LLVMTranslator.java +++ b/compiler/src/jlang/visit/LLVMTranslator.java @@ -1,21 +1,22 @@ -package polyllvm.visit; +package jlang.visit; import org.bytedeco.javacpp.LLVM.*; + +import jlang.ast.JLangLang; +import jlang.ast.JLangNodeFactory; +import jlang.extension.JLangTryExt.ExceptionFrame; +import jlang.structures.*; +import jlang.types.JLangTypeSystem; +import jlang.util.DebugInfo; +import jlang.util.LLVMUtils; +import jlang.util.JLangMangler; +import jlang.util.TypedNodeFactory; import polyglot.ast.Node; import polyglot.ext.jl5.types.*; import polyglot.types.*; import polyglot.util.InternalCompilerError; import polyglot.util.ListUtil; import polyglot.visit.NodeVisitor; -import polyllvm.ast.PolyLLVMLang; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.extension.PolyLLVMTryExt.ExceptionFrame; -import polyllvm.structures.*; -import polyllvm.types.PolyLLVMTypeSystem; -import polyllvm.util.DebugInfo; -import polyllvm.util.LLVMUtils; -import polyllvm.util.PolyLLVMMangler; -import polyllvm.util.TypedNodeFactory; import java.util.*; import java.util.List; @@ -25,8 +26,8 @@ /** Translates Java into LLVM IR. */ public class LLVMTranslator extends NodeVisitor { - public final PolyLLVMNodeFactory nf; - public final PolyLLVMTypeSystem ts; + public final JLangNodeFactory nf; + public final JLangTypeSystem ts; public final TypedNodeFactory tnf; // Note: using pointer equality here! @@ -38,7 +39,7 @@ public class LLVMTranslator extends NodeVisitor { public final DebugInfo debugInfo; public final LLVMUtils utils; public final ClassObjects classObjs; - public final PolyLLVMMangler mangler; + public final JLangMangler mangler; public final ObjectStruct obj; public final DispatchVector dv; @@ -114,7 +115,7 @@ public List getCtors() { public LLVMTranslator( String filePath, LLVMContextRef context, LLVMModuleRef mod, LLVMBuilderRef builder, - PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + JLangTypeSystem ts, JLangNodeFactory nf) { super(nf.lang()); this.context = context; this.mod = mod; @@ -122,7 +123,7 @@ public LLVMTranslator( this.debugInfo = new DebugInfo(this, mod, filePath); this.utils = new LLVMUtils(this); this.classObjs = new ClassObjects(this); - this.mangler = new PolyLLVMMangler(this); + this.mangler = new JLangMangler(this); this.obj = createObjectStruct(); this.dv = createDispatchVector(); this.nf = nf; @@ -152,8 +153,8 @@ public N visitEdge(Node parent, N child) { } @Override - public PolyLLVMLang lang() { - return (PolyLLVMLang) super.lang(); + public JLangLang lang() { + return (JLangLang) super.lang(); } @Override diff --git a/compiler/src/polyllvm/visit/NameAnonClasses.java b/compiler/src/jlang/visit/NameAnonClasses.java similarity index 86% rename from compiler/src/polyllvm/visit/NameAnonClasses.java rename to compiler/src/jlang/visit/NameAnonClasses.java index 7d9dc556..bdc1f0b5 100644 --- a/compiler/src/polyllvm/visit/NameAnonClasses.java +++ b/compiler/src/jlang/visit/NameAnonClasses.java @@ -1,16 +1,17 @@ -package polyllvm.visit; +package jlang.visit; import polyglot.ast.ClassBody; import polyglot.frontend.Job; import polyglot.types.ClassType; import polyglot.types.ParsedClassType; import polyglot.util.Pair; -import polyllvm.ast.PolyLLVMNodeFactory; -import polyllvm.types.PolyLLVMTypeSystem; import java.util.HashMap; import java.util.Map; +import jlang.ast.JLangNodeFactory; +import jlang.types.JLangTypeSystem; + /** Gives local and anonymous classes globally unique names. */ public class NameAnonClasses extends DesugarVisitor { @@ -20,7 +21,7 @@ public class NameAnonClasses extends DesugarVisitor { */ private final Map, Integer> localClassNameCount = new HashMap<>(); - public NameAnonClasses(Job job, PolyLLVMTypeSystem ts, PolyLLVMNodeFactory nf) { + public NameAnonClasses(Job job, JLangTypeSystem ts, JLangNodeFactory nf) { super(job, ts, nf); } diff --git a/compiler/src/jlang/visit/package.html b/compiler/src/jlang/visit/package.html new file mode 100644 index 00000000..7cfff1de --- /dev/null +++ b/compiler/src/jlang/visit/package.html @@ -0,0 +1,5 @@ + +

+Visitors for the JLang language extension. +

+ diff --git a/compiler/src/polyllvm/Topics.java b/compiler/src/polyllvm/Topics.java deleted file mode 100644 index 46cc89f5..00000000 --- a/compiler/src/polyllvm/Topics.java +++ /dev/null @@ -1,14 +0,0 @@ -package polyllvm; - -import polyglot.main.Report; - -/** - * Extension information for polyllvm extension. - */ -public class Topics { - public static final String polyllvm = "polyllvm"; - - static { - Report.topics.add(polyllvm); - } -} diff --git a/compiler/src/polyllvm/ast/package.html b/compiler/src/polyllvm/ast/package.html deleted file mode 100644 index e081dd6a..00000000 --- a/compiler/src/polyllvm/ast/package.html +++ /dev/null @@ -1,5 +0,0 @@ - -

-AST nodes for the PolyLLVM language extension. -

- diff --git a/compiler/src/polyllvm/extension/package.html b/compiler/src/polyllvm/extension/package.html deleted file mode 100644 index 54dc07d1..00000000 --- a/compiler/src/polyllvm/extension/package.html +++ /dev/null @@ -1,5 +0,0 @@ - -

-AST extensions and delegates for the PolyLLVM language extension. -

- diff --git a/compiler/src/polyllvm/package.html b/compiler/src/polyllvm/package.html deleted file mode 100644 index c903494b..00000000 --- a/compiler/src/polyllvm/package.html +++ /dev/null @@ -1,5 +0,0 @@ - -

-PolyLLVM language extension. -

- diff --git a/compiler/src/polyllvm/util/DesugarBarrier.java b/compiler/src/polyllvm/util/DesugarBarrier.java deleted file mode 100644 index 99cb0c79..00000000 --- a/compiler/src/polyllvm/util/DesugarBarrier.java +++ /dev/null @@ -1,26 +0,0 @@ -package polyllvm.util; - -import polyglot.frontend.Job; -import polyglot.frontend.goals.Barrier; -import polyglot.frontend.goals.Goal; -import polyllvm.PolyLLVMScheduler; - -public class DesugarBarrier extends Barrier { - - private final PolyLLVMScheduler polyllvmScheduler; - - public static DesugarBarrier create(PolyLLVMScheduler s) { - return new DesugarBarrier(s); - } - - protected DesugarBarrier(PolyLLVMScheduler scheduler) { - super(scheduler); - this.polyllvmScheduler = scheduler; - } - - @Override - public Goal goalForJob(Job job) { - return this.polyllvmScheduler.LLVMDesugared(job); - } - -} diff --git a/compiler/src/polyllvm/visit/package.html b/compiler/src/polyllvm/visit/package.html deleted file mode 100644 index e04ce8ab..00000000 --- a/compiler/src/polyllvm/visit/package.html +++ /dev/null @@ -1,5 +0,0 @@ - -

-Visitors for the PolyLLVM language extension. -

- diff --git a/docs/_config.yml b/docs/_config.yml index 1eeba460..6612c119 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,6 +1,6 @@ kramdown: input: GFM hard_wrap: false -project: "polyllvm" +project: "JLang" github: - url: https://github.com/gharrma/polyllvm + url: https://github.com/dz333/JLang diff --git a/docs/developer-guide.md b/docs/developer-guide.md index ed06c7b0..45137904 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -16,10 +16,10 @@ Contents Overview -------- -PolyLLVM is built as an extension to the +JLang is built as an extension to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler. Since -PolyLLVM is a backend only, it does not extend the parser, nor the type -system built into polyglot. PolyLLVM simply adds compiler passes for desugaring +JLang is a backend only, it does not extend the parser, nor the type +system built into polyglot. JLang simply adds compiler passes for desugaring and translating Java ASTs into LLVM IR. The project also contains native code for supporting Java semantics at runtime, @@ -33,7 +33,7 @@ Related Documentation - The [Polyglot tutorial](http://www.cs.cornell.edu/Projects/polyglot/pldi14/tutorial/) should at least be skimmed to get an idea of how Polyglot works. For the purposes -of PolyLLVM, the most important things to know about Polyglot are its type system (especially +of JLang, the most important things to know about Polyglot are its type system (especially how it handles generics), its scheduler framework, its AST visitor framework, and its AST node extension framework (`NodeFactory`, `ExtFactory`, etc.). @@ -77,7 +77,7 @@ into a shared library arbitrarily called `libjdk`. If you want to use the full OpenJDK, you can instead run `JDK=jdk make` at the top level, which will switch to using the `jdk` directory. The makefile in the `jdk` directory will unzip OpenJDK 7 source files, apply a small number of temporary patches that -help work around unimplemented features in PolyLLVM, and then compile everything +help work around unimplemented features in JLang, and then compile everything into `libjdk` as before. Here it will also put your local JDK 7 installation on the dynamically loaded search path of `libjdk`, so that JDK code has access to the native code that is part of OpenJDK 7. @@ -88,16 +88,16 @@ JDK. By default it will also run each test case and store the output in a `.output` file. The Makefiles themselves are the best source of documentation for how to -compile Java files with PolyLLVM, create shared libraries, and link against +compile Java files with JLang, create shared libraries, and link against the native code in your local system JDK. ### Scripts -The `bin/polyllvmc` script is the primary script used to launch PolyLLVM. +The `bin/jlangc` script is the primary script used to launch JLang. It was originally auto-generated by Polyglot. It automatically adds classes -from the runtime to the PolyLLVM classpath, which is necessary because -some PolyLLVM desugar transformations refer directly to runtime classes. -The result to of `polyllvmc` is LLVM IR in the form of a `.ll` file for +from the runtime to the JLang classpath, which is necessary because +some JLang desugar transformations refer directly to runtime classes. +The result to of `jlangc` is LLVM IR in the form of a `.ll` file for each compiled Java file. The `bin/plc` script is intended to automate the linking part of building @@ -135,8 +135,8 @@ through a [fork of javacpp-presets](https://github.com/gharrma/javacpp-presets), which is tracked as a git submodule. Cloning with `--depth 1` is recommended. To build, `cd` into the `llvm` subdirectory and run `mvn install`. This will produce the needed `.jar` files in the `llvm/target` directory. For convenience -we provide up-to-date `.jar` files in the PolyLLVM repository -[directly](https://github.com/gharrma/polyllvm/tree/master/lib), +we provide up-to-date `.jar` files in the JLang repository +[directly](https://github.com/dz333/JLang/tree/master/lib), for OS X and Linux. @@ -144,15 +144,15 @@ Desugaring Passes ----------------- There are currently several desugaring passes that run prior to translation, -executed as part of the `PolyLLVMDesugared` scheduler goal. For example, +executed as part of the `JLangDesugared` scheduler goal. For example, - The `DesugarEnums` pass converts Java enums into normal classes. - The `DesugarInstanceInitializers` searches for class initializer blocks and inline field initializers, and prepends these to object constructors. - The `DesugarLocalClasses` rewrites local classes so that captured local variables are stored as instance fields. -There are more, and they are listed in `PolyLLVMDesugared`. Each pass has Javadoc documentation. +There are more, and they are listed in `JLangDesugared`. Each pass has Javadoc documentation. -There is also the special `DesugarLocally` pass run at the end, which gives each Java AST node a chance to desugar itself locally into something simpler. For example, try-with-resource statements are desugared within `PolyLLVMTryWithResourcesExt` down to normal try-catch blocks as specified by the JLS. +There is also the special `DesugarLocally` pass run at the end, which gives each Java AST node a chance to desugar itself locally into something simpler. For example, try-with-resource statements are desugared within `JLangTryWithResourcesExt` down to normal try-catch blocks as specified by the JLS. Translation Pass @@ -163,13 +163,13 @@ data structure the translator uses is a map from Java `Node` objects to `LLVMValueRef` objects. When translating a Java node, the translation for sub-nodes is retrieved using the `getTranslation` method. -The translations themselves are implemented in each of the `PolyLLVMExt` subclasses +The translations themselves are implemented in each of the `JLangExt` subclasses (roughly one per Java AST node). Most of these translations are documented with Javadoc or inline comments. For example: -- `PolyLLVMBinaryExt` translations all Java binary expressions. -- `PolyLLVMIfExt` translates if-statements. -- `PolyLLVMClassDeclExt` emits runtime type information for the current class (to be used by the runtime). -- `PolyLLVMTryExt` translates try-catch blocks, implementing Itanium ABI zero-cost exception handling. +- `JLangBinaryExt` translations all Java binary expressions. +- `JLangIfExt` translates if-statements. +- `JLangClassDeclExt` emits runtime type information for the current class (to be used by the runtime). +- `JLangTryExt` translates try-catch blocks, implementing Itanium ABI zero-cost exception handling. In addition to traversing the AST, the translator keeps track of various states needed for translation, such as the current function, the current enclosing try-catch block, the current LLVM module, etc. @@ -182,13 +182,13 @@ The translator also exposes various utility classes to aid translation. For exam for accessing fields with LLVM IR. - `DispatchVector` specifies the layout of Java dispatch vectors, and provides methods for indexing into the dispatch vector based on the method desired. -- `PolyLLVMMangler` mangles symbol names. +- `JLangMangler` mangles symbol names. Object Layouts -------------- -See `ObjectStruct_c` for the definitive layout of Java objects used by PolyLLVM. +See `ObjectStruct_c` for the definitive layout of Java objects used by JLang. This layout must be kept in sync with the layouts in `runtime/rep.h`, which is used by native code to work with Java objects. @@ -200,7 +200,7 @@ A Java object currently looks like this: - ... See `DispatchVector_c` for the definitive layout of dispatch vectors generated -by PolyLLVM. These currently look like this: +by JLang. These currently look like this: - Pointer to the `java.lang.Class` object for this class. - Point to the interface method dispatch hash table. - Pointer to a contiguous array of super types, used for relatively fast `instanceof` checks. @@ -246,7 +246,7 @@ The function accesses the dispatch vector of `obj` to retrieve a table containin Arrays ------ -A Java array (e.g., `int[3]`) is implemented as a contiguous region of memory, with one word at the beginning to point to a dispatch vector, and the next word to hold the array length. Arrays must behave as standard Java objects with respect to type information, so for simplicity arrays are implemented as a Java class (see `Array.java` in the `runtime` directory). The catch is that PolyLLVM allocates extra memory for `Array` instances in order to store data elements. +A Java array (e.g., `int[3]`) is implemented as a contiguous region of memory, with one word at the beginning to point to a dispatch vector, and the next word to hold the array length. Arrays must behave as standard Java objects with respect to type information, so for simplicity arrays are implemented as a Java class (see `Array.java` in the `runtime` directory). The catch is that JLang allocates extra memory for `Array` instances in order to store data elements. Arrays are packed, so that an array of chars (for example) uses only two bytes per element. The one exception is that boolean arrays use one byte per element as opposed to one bit. Packed arrays are implemented by casting the array data pointer (in LLVM IR) to the appropriate type before offsetting with an index. @@ -270,7 +270,7 @@ We use native C++ code in many parts of the runtime, including Wherever possible, native C code should be preferred over handwritten or compiler-generated LLVM IR. Native code currently resides in the `runtime/native` directory. -For an example, consider the [native code used to implement `instanceof`](#instanceof). When translating a reference to `instanceof` in Java source code, PolyLLVM emits a call to this native code with the correct arguments. The runtime build system is responsible for compiling runtime code into a shared library which should be linked with user programs. +For an example, consider the [native code used to implement `instanceof`](#instanceof). When translating a reference to `instanceof` in Java source code, JLang emits a call to this native code with the correct arguments. The runtime build system is responsible for compiling runtime code into a shared library which should be linked with user programs. The runtime is also responsible for keeping track of runtime type information, and implementing much of the functionality that the JVM would normally implement. @@ -284,7 +284,7 @@ This is also when the static initializers for the class are run. In order to implement this behavior, we emit class loading checks before every static field access, static method call, or new instance creation. If a class has not been loaded yet, then we call it's "class loading function": -a special function emitted by PolyLLVM for each class that will allocate a new +a special function emitted by JLang for each class that will allocate a new `java.lang.Class` object, ensure the super class has been loaded, run all static initializers, and register runtime type information with native runtime code. @@ -297,7 +297,7 @@ The LLVM C API requires that code be emitted as a collection of basic blocks. Th > After traversing an AST subtree, all paths through the corresponding CFG end at a common block, and the instruction builder is positioned at the end of this block. -For example, an if-statement will (1) build the conditional branch, (2) position the builder at the `true` block, (3) recurse into the `consequent` child, (4) position the builder at the `false` block, and (5) recurse into the `alternative` child. After each recursion it adds a branch to the end block (unless there is already a terminating instruction). Finally, it positions the builder at the end block. See `PolyLLVMIfExt` to see this in action. +For example, an if-statement will (1) build the conditional branch, (2) position the builder at the `true` block, (3) recurse into the `consequent` child, (4) position the builder at the `false` block, and (5) recurse into the `alternative` child. After each recursion it adds a branch to the end block (unless there is already a terminating instruction). Finally, it positions the builder at the end block. See `JLangIfExt` to see this in action. Unneeded AST Nodes @@ -315,7 +315,7 @@ Some AST extensions are unneeded, either because they do not require a translati Debugging Tips -------------- -If you have a PolyLLVM-compiled executable that crashes at runtime, the first +If you have a JLang-compiled executable that crashes at runtime, the first thing to do is use `lldb`. With `lldb` you can find exactly where the program crashes, and see the source code that corresponds to each stack frame. @@ -323,7 +323,7 @@ Once you find where the program is crashing, it's usually helpful to find the corresponding LLVM IR (within the `.ll` files corresponding to the Java class of interest). -Also take a look at PolyLLVM's `-dump-desugared` flag, which will print +Also take a look at JLang's `-dump-desugared` flag, which will print Java ASTs after the desugar passes have run. This desugared output will explicitly show many of Java's implicit language semantics (such as implicit type conversions). diff --git a/docs/index.md b/docs/index.md index 1c5a9013..9582da78 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,21 +6,21 @@ layout: default Overview -------- -PolyLLVM adds an LLVM backend to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler, translating Java into LLVM IR. See the [user manual](user-manual.html) to try it out, and the [developer guide](developer-guide.html) for an overview of the codebase. +JLang adds an LLVM backend to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler, translating Java into LLVM IR. See the [user manual](user-manual.html) to try it out, and the [developer guide](developer-guide.html) for an overview of the codebase. -PolyLLVM supports Java 7, as specified by the [JLS](https://docs.oracle.com/javase/specs/jls/se7/html/index.html). Since Polyglot additionally supports Java language extensions, and since it can generally translate these extensions down to vanilla Java, PolyLLVM should be interoperable with other Polyglot extensions by default. However, PolyLLVM also aims to be extensible, so that one can write direct translations to LLVM for language extensions when needed. +JLang supports Java 7, as specified by the [JLS](https://docs.oracle.com/javase/specs/jls/se7/html/index.html). Since Polyglot additionally supports Java language extensions, and since it can generally translate these extensions down to vanilla Java, JLang should be interoperable with other Polyglot extensions by default. However, JLang also aims to be extensible, so that one can write direct translations to LLVM for language extensions when needed. -To be more concrete, here's what Polyglot + PolyLLVM will allow you to do: +To be more concrete, here's what Polyglot + JLang will allow you to do: (1) Translate Java source files (`.java`) down to LLVM IR (`.ll`), and then from there down to object files (`.o`) using the the [LLVM](https://llvm.org) toolchain. -(2) Link object files together along with PolyLLVM-compiled [OpenJDK](http://openjdk.java.net/projects/jdk7/) classes to create a standalone executable. PolyLLVM implements a runtime to provide the JVM functionality that the JDK expects, such as reflection and cross-language method calls. Native code in the JDK (e.g., low-level networking and I/O code) can be linked directly from your local JDK installation. +(2) Link object files together along with JLang-compiled [OpenJDK](http://openjdk.java.net/projects/jdk7/) classes to create a standalone executable. JLang implements a runtime to provide the JVM functionality that the JDK expects, such as reflection and cross-language method calls. Native code in the JDK (e.g., low-level networking and I/O code) can be linked directly from your local JDK installation. -(3) (Optional) Extend Java with custom language features or type annotations using Polyglot, and either translate these features back into vanilla Java, or write a direct translation into LLVM IR by extending PolyLLVM. +(3) (Optional) Extend Java with custom language features or type annotations using Polyglot, and either translate these features back into vanilla Java, or write a direct translation into LLVM IR by extending JLang. Status ------ -PolyLLVM currently supports all Java 7 language features, except concurrency support. This includes expressions, control flow, exceptions, method dispatch, switch statements, try-with-resources, initializer blocks, implicit type conversions, etc. OpenJDK 7 support is still a work in progress. +JLang currently supports all Java 7 language features, except concurrency support. This includes expressions, control flow, exceptions, method dispatch, switch statements, try-with-resources, initializer blocks, implicit type conversions, etc. OpenJDK 7 support is still a work in progress. -See the [README](https://github.com/gharrma/polyllvm) in the repository for the most up-to-date status. +See the [README](https://github.com/dz333/JLang) in the repository for the most up-to-date status. diff --git a/docs/thread-proposal.md b/docs/thread-proposal.md index 7384bb34..3fb10c85 100644 --- a/docs/thread-proposal.md +++ b/docs/thread-proposal.md @@ -14,7 +14,7 @@ Contents Introduction ------------ -Java provides library support for writing multi-threaded applications, mainly through the `Thread` class, and `Object` methods for synchronization. This proposal details implementing threading support in PolyLLVM using the `pthread` library. +Java provides library support for writing multi-threaded applications, mainly through the `Thread` class, and `Object` methods for synchronization. This proposal details implementing threading support in JLang using the `pthread` library. Object Header ------------- diff --git a/docs/user-manual.md b/docs/user-manual.md index 6b186b07..0c10ccd0 100644 --- a/docs/user-manual.md +++ b/docs/user-manual.md @@ -14,9 +14,9 @@ Contents Installation ------------ -Note: PolyLLVM is not tested on Windows. +Note: JLang is not tested on Windows. -Clone the [repo](https://github.com/gharrma/polyllvm) and build using the "Quick start guide" section of the [README](https://github.com/gharrma/polyllvm/blob/master/README.md). +Clone the [repo](https://github.com/dz333/JLang) and build using the "Quick start guide" section of the [README](https://github.com/dz333/JLang/blob/master/README.md). Compiling Hello World @@ -25,7 +25,7 @@ Compiling Hello World Create a simple `HelloWorld.java` file, printing to stdout using `System.out.println()`. Compile using ``` -$ bin/polyllvmc -cp jdk-lite/out/classes HelloWorld.java +$ bin/jlangc -cp jdk-lite/out/classes HelloWorld.java ``` This will output a file called `HelloWorld.ll`, which will contain human-readable LLVM IR. diff --git a/jdk-lite/Makefile b/jdk-lite/Makefile index c40781af..73c98c53 100644 --- a/jdk-lite/Makefile +++ b/jdk-lite/Makefile @@ -40,7 +40,7 @@ $(CLS_STAMP): $(JAVA_SRC) # Compile JDK Java code (.java --> .ll) $(JAVA_LL): $(JAVA_SRC) $(PLC_SRC) - @echo "Compiling $(words $(JAVA_SRC)) Java files with PolyLLVM (.java --> .ll)" + @echo "Compiling $(words $(JAVA_SRC)) Java files with JLang (.java --> .ll)" @# We compile java.lang.Object separately, since otherwise @# we get duplicate class errors from Polyglot. (TODO) @$(PLC) -c -d $(OUT) $(DEBUG_FLAGS) $(filter %Object.java,$(JAVA_SRC)) > dump.txt diff --git a/jdk-lite/src/java/lang/JLangNotImplementedError.java b/jdk-lite/src/java/lang/JLangNotImplementedError.java new file mode 100644 index 00000000..9bed6068 --- /dev/null +++ b/jdk-lite/src/java/lang/JLangNotImplementedError.java @@ -0,0 +1,12 @@ +package java.lang; + +public class JLangNotImplementedError extends RuntimeException { + + public JLangNotImplementedError() { + super(); + } + + public JLangNotImplementedError(String s) { + super(s); + } +} diff --git a/jdk-lite/src/java/lang/PolyLLVMNotImplementedError.java b/jdk-lite/src/java/lang/PolyLLVMNotImplementedError.java deleted file mode 100644 index 64693dff..00000000 --- a/jdk-lite/src/java/lang/PolyLLVMNotImplementedError.java +++ /dev/null @@ -1,12 +0,0 @@ -package java.lang; - -public class PolyLLVMNotImplementedError extends RuntimeException { - - public PolyLLVMNotImplementedError() { - super(); - } - - public PolyLLVMNotImplementedError(String s) { - super(s); - } -} diff --git a/jdk/Makefile b/jdk/Makefile index e0e34557..4ff709f3 100644 --- a/jdk/Makefile +++ b/jdk/Makefile @@ -12,7 +12,7 @@ CLASSES := $(OUT)/classes NUM_JAVA_FILES := $(shell find $(JDK)/$(SRC) -name "*.java" | wc -l) #Magic Multiplier for now. TODO calculate this a better way RUN_COUNT := $(shell echo "2 * $(NUM_JAVA_FILES)" | bc) -# PolyLLVM flags when compiling the JDK. +# JLANG flags when compiling the JDK. PLC_FLAGS := -assert -method-filter jdk-method-filter.txt -sourcepath $(SRC) all: $(LIBJDK) @@ -27,7 +27,7 @@ $(SRC): | $(SRC).zip @unzip -q -d $@ $(SRC).zip @cp -r $(SRC) $(SRC).orig -# Path JDK sources to work around PolyLLVM unimplemented features. +# Path JDK sources to work around JLang unimplemented features. $(SRC)/patchstamp: | $(SRC) @echo "Patching JDK source files" @for f in `find $(PATCHES) -name "*.patch"`; do patch -p0 < "$$f"; done diff --git a/jdk/README.md b/jdk/README.md index 99495335..881a10a9 100644 --- a/jdk/README.md +++ b/jdk/README.md @@ -1,7 +1,7 @@ JDK === -This directory contains source code for OpenJDK 7, and a build system for compiling the JDK with PolyLLVM to produce a shared library. +This directory contains source code for OpenJDK 7, and a build system for compiling the JDK with JLang to produce a shared library. The OpenJDK codebase is available directly from the [openjdk](http://openjdk.java.net/guide/repositories.html#clone) website, or from one of several git clones such as [this one](https://github.com/dmlloyd/openjdk). However, many JDK Java source files are script-generated, and the build system for JDK 7 is notoriously difficult to configure. So for convenience we track a zip file that contains all JDK sources, prebuilt. This zip file was obtained from [here](https://sourceforge.net/projects/jdk7src/). @@ -10,14 +10,14 @@ Building The Makefile in this directory will: (1) Extract JDK source files from the tracked zip file.
-(2) Apply PolyLLVM-specific patches to work around a few unsupported features such as reflection and threads. These patches should be removed as the corresponding features are implemented.
-(3) Use PolyLLVM to compile the JDK Java source files down to LLVM IR.
+(2) Apply JLang-specific patches to work around a few unsupported features such as reflection and threads. These patches should be removed as the corresponding features are implemented.
+(3) Use JLang to compile the JDK Java source files down to LLVM IR.
(4) Use clang to compile LLVM IR down to object files.
(5) Use clang to link object files from the JDK into a shared library. Notes ----- -- In addition to direct source patches, there is also a file called `jdk-method-filter.txt`, which PolyLLVM uses to filter out about a dozen methods and field initializers that cause problems due to differences between PolyLLVM and javac. The file has a comment for each method explaining why the method causes issues. This takes advantage of Polyglot's `-method-filter` flag. +- In addition to direct source patches, there is also a file called `jdk-method-filter.txt`, which JLang uses to filter out about a dozen methods and field initializers that cause problems due to differences between JLang and javac. The file has a comment for each method explaining why the method causes issues. This takes advantage of Polyglot's `-method-filter` flag. - At the time of writing, we use the `Main.java` file here in order to compile only the slice of the JDK that is required for a Hello World program. This slice is quite large (1000+ files), and includes many of the most important JDK classes. diff --git a/jdk/jdk-method-filter.txt b/jdk/jdk-method-filter.txt index 5184854d..34dcb903 100644 --- a/jdk/jdk-method-filter.txt +++ b/jdk/jdk-method-filter.txt @@ -7,15 +7,15 @@ java.util.RegularEnumSet#iterator(.*) java.util.JumboEnumSet#iterator(.*) -// The methods below cause PolyLLVM to crash. +// The methods below cause JLang to crash. // These methods call `new Condition()`, where Condition is an inner class -// in another file. PolyLLVM crashes because it tries to provide +// in another file. JLang crashes because it tries to provide // the enclosing instance as part of the constructor call, but the // constructor has not yet been update to accept the enclosing instance // (since it is defined in another file). This should be fixed by // updating class types with enclosing instances before they are needed, -// not just when PolyLLVM gets around to desugaring their defining file. +// not just when JLang gets around to desugaring their defining file. java.util.concurrent.locks.ReentrantLock.Sync#newCondition() java.util.concurrent.locks.ReentrantReadWriteLock.Sync#newCondition() @@ -28,6 +28,6 @@ sun.nio.fs.WindowsChannelFactory.Flags#toFlags(.*) // These fields cause a stack overflow due to (very) deeply nested // string concatenation expressions. An alternative might be to increase the -// JVM stack size when running PolyLLVM. +// JVM stack size when running JLang. java.util.LocaleISOData#isoLanguageTable java.util.LocaleISOData#isoCountryTable diff --git a/jdk/patches/java/io/BufferedInputStream.patch b/jdk/patches/java/io/BufferedInputStream.patch index 1206cb8c..e45246ef 100644 --- a/jdk/patches/java/io/BufferedInputStream.patch +++ b/jdk/patches/java/io/BufferedInputStream.patch @@ -14,7 +14,7 @@ - AtomicReferenceFieldUpdater bufUpdater = - AtomicReferenceFieldUpdater.newUpdater - (BufferedInputStream.class, byte[].class, "buf"); -+ // Modified for PolyLLVM. ++ // Modified for JLang. /** * The index one greater than the index of the last valid byte in @@ -30,7 +30,7 @@ - // assert buf == null; - throw new IOException("Stream closed"); - } -+ // Modified for PolyLLVM. ++ // Modified for JLang. buffer = nbuf; } count = pos; @@ -46,7 +46,7 @@ - return; - } - // Else retry in case a new buf was CASed in fill() -+ // Modified for PolyLLVM. ++ // Modified for JLang. + InputStream input = in; + in = null; + if (input != null) diff --git a/jdk/patches/java/io/FileInputStream.patch b/jdk/patches/java/io/FileInputStream.patch index d802012f..74228d30 100644 --- a/jdk/patches/java/io/FileInputStream.patch +++ b/jdk/patches/java/io/FileInputStream.patch @@ -7,7 +7,7 @@ - private static final ThreadLocal runningFinalize = - new ThreadLocal<>(); - -+ // Modified for PolyLLVM. ++ // Modified for JLang. private static boolean isRunningFinalize() { - Boolean val; - if ((val = runningFinalize.get()) != null) @@ -25,7 +25,7 @@ - } finally { - runningFinalize.set(Boolean.FALSE); - } -+ // Modified for PolyLLVM. ++ // Modified for JLang. + close(); } } diff --git a/jdk/patches/java/util/HashTable.patch b/jdk/patches/java/util/HashTable.patch index 78c3b893..ce7604c4 100644 --- a/jdk/patches/java/util/HashTable.patch +++ b/jdk/patches/java/util/HashTable.patch @@ -25,7 +25,7 @@ - } - } - -+ // Modified for PolyLLVM. ++ // Modified for JLang. /** * A randomizing value associated with this instance that is applied to * hash code of keys to make hash collisions harder to find. @@ -41,7 +41,7 @@ // set hashSeed - UNSAFE.putIntVolatile(this, HASHSEED_OFFSET, - sun.misc.Hashing.randomHashSeed(this)); -+ // Modified for PolyLLVM. ++ // Modified for JLang. + this.hashSeed = sun.misc.Hashing.randomHashSeed(this); // Read the original length of the array and number of elements diff --git a/jdk/patches/java/util/concurrent/atomic/AtomicInteger.patch b/jdk/patches/java/util/concurrent/atomic/AtomicInteger.patch index 617a590d..111dacf4 100644 --- a/jdk/patches/java/util/concurrent/atomic/AtomicInteger.patch +++ b/jdk/patches/java/util/concurrent/atomic/AtomicInteger.patch @@ -8,7 +8,7 @@ - valueOffset = unsafe.objectFieldOffset - (AtomicInteger.class.getDeclaredField("value")); - } catch (Exception ex) { throw new Error(ex); } -+ // Modified for PolyLLVM until we have reflection. ++ // Modified for JLang until we have reflection. + valueOffset = 16; } diff --git a/jdk/patches/sun/misc/Hashing.patch b/jdk/patches/sun/misc/Hashing.patch index aae28a99..fcb8abc7 100644 --- a/jdk/patches/sun/misc/Hashing.patch +++ b/jdk/patches/sun/misc/Hashing.patch @@ -11,7 +11,7 @@ - (int) (System.nanoTime() >>> 5), // resolution is poor - (int) (Runtime.getRuntime().freeMemory() >>> 4) // alloc min + System.identityHashCode(instance) -+ // Modified for PolyLLVM. ++ // Modified for JLang. + // System.identityHashCode(Thread.currentThread()), + // (int) Thread.currentThread().getId(), + // (int) (System.currentTimeMillis() >>> 2), // resolution is poor diff --git a/runtime/Makefile b/runtime/Makefile index be10ade1..4ae38384 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -43,7 +43,7 @@ $(NATIVE_OBJ): $(OUT)/%.o: %.cpp # Runtime Java IR (.java --> .ll) $(LL_STAMP): $(CLS_STAMP) $(PLC_SRC) - @echo "Compiling $(words $(JAVA_SRC)) Java files with PolyLLVM (.java --> .ll)" + @echo "Compiling $(words $(JAVA_SRC)) Java files with JLang (.java --> .ll)" @$(PLC) -cp $(JDK_CLASSES) -c -d $(OUT) $(JAVA_SRC) @date > $@ diff --git a/runtime/native/class.cpp b/runtime/native/class.cpp index 494f8754..ecb9a4af 100644 --- a/runtime/native/class.cpp +++ b/runtime/native/class.cpp @@ -64,8 +64,8 @@ static std::unordered_map cnames; extern "C" { -extern void Polyglot_polyllvm_runtime_ObjectArray_load_class(); -extern jclass Polyglot_polyllvm_runtime_ObjectArray_class; +extern void Polyglot_jlang_runtime_ObjectArray_load_class(); +extern jclass Polyglot_jlang_runtime_ObjectArray_class; void RegisterJavaClass(jclass cls, const JavaClassInfo* info) { @@ -114,8 +114,8 @@ void RegisterJavaClass(jclass cls, const JavaClassInfo* info) { //Force this class load function to be called at initialization jclass initArrayKlass() { - Polyglot_polyllvm_runtime_ObjectArray_load_class(); - return Polyglot_polyllvm_runtime_ObjectArray_class; + Polyglot_jlang_runtime_ObjectArray_load_class(); + return Polyglot_jlang_runtime_ObjectArray_class; } //This assumes char* is non-null, C-string with len > 0 diff --git a/runtime/native/class.h b/runtime/native/class.h index 8133b579..d3f4b634 100644 --- a/runtime/native/class.h +++ b/runtime/native/class.h @@ -1,5 +1,5 @@ // Provides reflection-like support, especially for use by JNI. -// PolyLLVM emits static information for each class, and registers +// JLang emits static information for each class, and registers // that information by calling RegisterJavaClass upon loading a class. // The other functions defined here provide access to // class information in an organized way. @@ -19,7 +19,7 @@ extern "C" { // These structs are generated statically for each class, and // exist for the lifetime of the program. -// The layout must precisely mirror the layout defined in PolyLLVM. +// The layout must precisely mirror the layout defined in JLang. // Concrete representation for the opaque type jfieldID. struct JavaFieldInfo { diff --git a/runtime/native/exception.cpp b/runtime/native/exception.cpp index 07731de0..25c3c1d1 100644 --- a/runtime/native/exception.cpp +++ b/runtime/native/exception.cpp @@ -55,7 +55,7 @@ namespace { extern "C" { -void Polyglot_polyllvm_runtime_Exceptions_createClassNotFoundException__Ljava_lang_String_2 (jstring); +void Polyglot_jlang_runtime_Exceptions_createClassNotFoundException__Ljava_lang_String_2 (jstring); // A distinct integer identifying our own exceptions. const uint64_t javaExceptionClass = 8101813523428701805ll; @@ -494,5 +494,5 @@ _Unwind_Reason_Code __java_personality_v0( void throwClassNotFoundException(JNIEnv *env, const char* name) { jstring clazz = env->NewStringUTF(name); - Polyglot_polyllvm_runtime_Exceptions_createClassNotFoundException__Ljava_lang_String_2(clazz); + Polyglot_jlang_runtime_Exceptions_createClassNotFoundException__Ljava_lang_String_2(clazz); } diff --git a/runtime/native/factory.cpp b/runtime/native/factory.cpp index 29f36e83..df8e3eb4 100644 --- a/runtime/native/factory.cpp +++ b/runtime/native/factory.cpp @@ -5,38 +5,38 @@ #include "rep.h" #include "gc.h" -#define ARRAY_CLS "polyllvm.runtime.Array" -// The name must match that used in polyllvm.runtime.Factory, -// and the mangling and calling conventions must match those used by PolyLLVM. +#define ARRAY_CLS "jlang.runtime.Array" +// The name must match that used in jlang.runtime.Factory, +// and the mangling and calling conventions must match those used by JLang. extern "C" { -jbooleanArray Polyglot_polyllvm_runtime_Factory_BooleanArray__I(jint); -jbyteArray Polyglot_polyllvm_runtime_Factory_ByteArray__I (jint); -jcharArray Polyglot_polyllvm_runtime_Factory_CharArray__I (jint); -jshortArray Polyglot_polyllvm_runtime_Factory_ShortArray__I (jint); -jintArray Polyglot_polyllvm_runtime_Factory_IntArray__I (jint); -jlongArray Polyglot_polyllvm_runtime_Factory_LongArray__I (jint); -jfloatArray Polyglot_polyllvm_runtime_Factory_FloatArray__I (jint); -jdoubleArray Polyglot_polyllvm_runtime_Factory_DoubleArray__I (jint); -jobjectArray Polyglot_polyllvm_runtime_Factory_ObjectArray__I (jint); +jbooleanArray Polyglot_jlang_runtime_Factory_BooleanArray__I(jint); +jbyteArray Polyglot_jlang_runtime_Factory_ByteArray__I (jint); +jcharArray Polyglot_jlang_runtime_Factory_CharArray__I (jint); +jshortArray Polyglot_jlang_runtime_Factory_ShortArray__I (jint); +jintArray Polyglot_jlang_runtime_Factory_IntArray__I (jint); +jlongArray Polyglot_jlang_runtime_Factory_LongArray__I (jint); +jfloatArray Polyglot_jlang_runtime_Factory_FloatArray__I (jint); +jdoubleArray Polyglot_jlang_runtime_Factory_DoubleArray__I (jint); +jobjectArray Polyglot_jlang_runtime_Factory_ObjectArray__I (jint); -jstring Polyglot_polyllvm_runtime_Factory_String___3C(jarray); +jstring Polyglot_jlang_runtime_Factory_String___3C(jarray); } // extern "C" -jbooleanArray CreateJavaBooleanArray(jint len) { return Polyglot_polyllvm_runtime_Factory_BooleanArray__I(len); } -jbyteArray CreateJavaByteArray (jint len) { return Polyglot_polyllvm_runtime_Factory_ByteArray__I (len); } -jcharArray CreateJavaCharArray (jint len) { return Polyglot_polyllvm_runtime_Factory_CharArray__I (len); } -jshortArray CreateJavaShortArray (jint len) { return Polyglot_polyllvm_runtime_Factory_ShortArray__I (len); } -jintArray CreateJavaIntArray (jint len) { return Polyglot_polyllvm_runtime_Factory_IntArray__I (len); } -jlongArray CreateJavaLongArray (jint len) { return Polyglot_polyllvm_runtime_Factory_LongArray__I (len); } -jfloatArray CreateJavaFloatArray (jint len) { return Polyglot_polyllvm_runtime_Factory_FloatArray__I (len); } -jdoubleArray CreateJavaDoubleArray (jint len) { return Polyglot_polyllvm_runtime_Factory_DoubleArray__I (len); } -jobjectArray CreateJavaObjectArray (jint len) { return Polyglot_polyllvm_runtime_Factory_ObjectArray__I (len); } +jbooleanArray CreateJavaBooleanArray(jint len) { return Polyglot_jlang_runtime_Factory_BooleanArray__I(len); } +jbyteArray CreateJavaByteArray (jint len) { return Polyglot_jlang_runtime_Factory_ByteArray__I (len); } +jcharArray CreateJavaCharArray (jint len) { return Polyglot_jlang_runtime_Factory_CharArray__I (len); } +jshortArray CreateJavaShortArray (jint len) { return Polyglot_jlang_runtime_Factory_ShortArray__I (len); } +jintArray CreateJavaIntArray (jint len) { return Polyglot_jlang_runtime_Factory_IntArray__I (len); } +jlongArray CreateJavaLongArray (jint len) { return Polyglot_jlang_runtime_Factory_LongArray__I (len); } +jfloatArray CreateJavaFloatArray (jint len) { return Polyglot_jlang_runtime_Factory_FloatArray__I (len); } +jdoubleArray CreateJavaDoubleArray (jint len) { return Polyglot_jlang_runtime_Factory_DoubleArray__I (len); } +jobjectArray CreateJavaObjectArray (jint len) { return Polyglot_jlang_runtime_Factory_ObjectArray__I (len); } jstring CreateJavaString(jcharArray chars) { - return Polyglot_polyllvm_runtime_Factory_String___3C(chars); + return Polyglot_jlang_runtime_Factory_String___3C(chars); } diff --git a/runtime/native/factory.h b/runtime/native/factory.h index 66f03b61..b1afe7f9 100644 --- a/runtime/native/factory.h +++ b/runtime/native/factory.h @@ -1,7 +1,7 @@ // Provides methods to construct common Java objects // needed by native code. These factory methods directly // dispatch to symbols compiled from Java code in -// polyllvm.runtime.Factory. +// jlang.runtime.Factory. #pragma once #include "jni.h" diff --git a/runtime/native/jni_help.h b/runtime/native/jni_help.h index a49a5c43..2b0672d0 100644 --- a/runtime/native/jni_help.h +++ b/runtime/native/jni_help.h @@ -14,7 +14,7 @@ #include "stack_trace.h" typedef uint8_t u_char; -#define POLYGLOT_ARRAY_STORE Polyglot_polyllvm_runtime_Helper_arrayStore___3Ljava_lang_Object_2ILjava_lang_Object_2 +#define POLYGLOT_ARRAY_STORE Polyglot_jlang_runtime_Helper_arrayStore___3Ljava_lang_Object_2ILjava_lang_Object_2 static jboolean mainThreadIsAlive = JNI_FALSE; static jobject mainThread = NULL; @@ -208,7 +208,7 @@ ForwardJavaArgs(const char* sig, va_list args, jvalue* out) { } } -// This type must precisely match the type used by PolyLLVM. +// This type must precisely match the type used by JLang. template using JniTrampolineType = T (*)(void*, const jvalue*); diff --git a/runtime/native/main.cpp b/runtime/native/main.cpp index b8a6116a..8971b3d8 100644 --- a/runtime/native/main.cpp +++ b/runtime/native/main.cpp @@ -10,8 +10,8 @@ extern "C" { -void Polyglot_polyllvm_runtime_MainWrapper_runMain___3Ljava_lang_String_2(jarray args); -jarray Polyglot_polyllvm_runtime_Factory_ObjectArray__I(jint len); +void Polyglot_jlang_runtime_MainWrapper_runMain___3Ljava_lang_String_2(jarray args); +jarray Polyglot_jlang_runtime_Factory_ObjectArray__I(jint len); void Polyglot_java_lang_System_initializeSystemClass__(); } // extern "C" @@ -47,7 +47,7 @@ int main(int argc, char** argv) { // Ignore the 0th argument, which is the name of the program. --argc, ++argv; - jarray args = Polyglot_polyllvm_runtime_Factory_ObjectArray__I(argc); + jarray args = Polyglot_jlang_runtime_Factory_ObjectArray__I(argc); jstring* args_data = reinterpret_cast(Unwrap(args)->Data()); for (int i = 0; i < argc; ++i) { size_t len = strlen(argv[i]); @@ -60,5 +60,5 @@ int main(int argc, char** argv) { args_data[i] = argStr; } Polyglot_java_lang_System_initializeSystemClass__(); - Polyglot_polyllvm_runtime_MainWrapper_runMain___3Ljava_lang_String_2(args); + Polyglot_jlang_runtime_MainWrapper_runMain___3Ljava_lang_String_2(args); } diff --git a/runtime/native/native.h b/runtime/native/native.h index 83d9ed7c..c126e03c 100644 --- a/runtime/native/native.h +++ b/runtime/native/native.h @@ -24,7 +24,7 @@ RegisterJavaNativeFunc( // needs to be searched for in the symbol table. // // The signature of this function must precisely match -// the signature used in PolyLLVM. +// the signature used in JLang. extern "C" void* GetJavaNativeFunc( diff --git a/runtime/src/polyllvm/runtime/Array.java b/runtime/src/jlang/runtime/Array.java similarity index 97% rename from runtime/src/polyllvm/runtime/Array.java rename to runtime/src/jlang/runtime/Array.java index b7932e96..f349094c 100644 --- a/runtime/src/polyllvm/runtime/Array.java +++ b/runtime/src/jlang/runtime/Array.java @@ -1,4 +1,4 @@ -package polyllvm.runtime; +package jlang.runtime; import java.io.Serializable; @@ -48,7 +48,7 @@ static Array createMultidimensional(Type type, int[] lens, int depth) { static Array create(Type type, int len) { // The casts succeeds because Array and type[] are - // equivalent from the perspective of PolyLLVM. + // equivalent from the perspective of JLang. switch (type) { case BOOLEAN: return (Array) (Object) new boolean[len]; case BYTE: return (Array) (Object) new byte [len]; diff --git a/runtime/src/polyllvm/runtime/Exceptions.java b/runtime/src/jlang/runtime/Exceptions.java similarity index 85% rename from runtime/src/polyllvm/runtime/Exceptions.java rename to runtime/src/jlang/runtime/Exceptions.java index 925a6e11..45102856 100644 --- a/runtime/src/polyllvm/runtime/Exceptions.java +++ b/runtime/src/jlang/runtime/Exceptions.java @@ -1,7 +1,7 @@ -package polyllvm.runtime; +package jlang.runtime; class Exceptions { static void createClassNotFoundException(String name) throws ClassNotFoundException { throw new ClassNotFoundException(name) ; } -} \ No newline at end of file +} diff --git a/runtime/src/polyllvm/runtime/Factory.java b/runtime/src/jlang/runtime/Factory.java similarity index 96% rename from runtime/src/polyllvm/runtime/Factory.java rename to runtime/src/jlang/runtime/Factory.java index ba32169b..f932d282 100644 --- a/runtime/src/polyllvm/runtime/Factory.java +++ b/runtime/src/jlang/runtime/Factory.java @@ -1,4 +1,4 @@ -package polyllvm.runtime; +package jlang.runtime; // Helps native code construct common Java objects. class Factory { diff --git a/runtime/src/polyllvm/runtime/Helper.java b/runtime/src/jlang/runtime/Helper.java similarity index 83% rename from runtime/src/polyllvm/runtime/Helper.java rename to runtime/src/jlang/runtime/Helper.java index 189e6986..463b3d16 100644 --- a/runtime/src/polyllvm/runtime/Helper.java +++ b/runtime/src/jlang/runtime/Helper.java @@ -1,7 +1,7 @@ -package polyllvm.runtime; +package jlang.runtime; // Helper functions that implement Java semantics so that the compiler -// doesn't have to. That is, a PolyLLVM translation can sometimes call one of +// doesn't have to. That is, a JLang translation can sometimes call one of // these helper methods rather than translating everything directly. class Helper { diff --git a/runtime/src/polyllvm/runtime/MainWrapper.java b/runtime/src/jlang/runtime/MainWrapper.java similarity index 77% rename from runtime/src/polyllvm/runtime/MainWrapper.java rename to runtime/src/jlang/runtime/MainWrapper.java index 2e162a40..9e56be5b 100644 --- a/runtime/src/polyllvm/runtime/MainWrapper.java +++ b/runtime/src/jlang/runtime/MainWrapper.java @@ -1,10 +1,10 @@ -package polyllvm.runtime; +package jlang.runtime; // Wraps the Java entry point in a try-catch block so that we can // report uncaught exceptions to the client. class MainWrapper { - // This native method is generated by PolyLLVM when it encounters + // This native method is generated by JLang when it encounters // the main method in the client program. static native void main(String[] args); diff --git a/runtime/src/polyllvm/runtime/ObjectArray.java b/runtime/src/jlang/runtime/ObjectArray.java similarity index 81% rename from runtime/src/polyllvm/runtime/ObjectArray.java rename to runtime/src/jlang/runtime/ObjectArray.java index f096a5dd..396708b5 100644 --- a/runtime/src/polyllvm/runtime/ObjectArray.java +++ b/runtime/src/jlang/runtime/ObjectArray.java @@ -1,8 +1,8 @@ -package polyllvm.runtime; +package jlang.runtime; //this is an empty class whose Class Object // we'll use as the basis //for all [].class objects class ObjectArray { -} \ No newline at end of file +} diff --git a/tests/isolated/Makefile b/tests/isolated/Makefile index 05f495e7..cdf2dada 100644 --- a/tests/isolated/Makefile +++ b/tests/isolated/Makefile @@ -64,12 +64,12 @@ $(SOL): $(SRC) $(LL): $(SRC) @echo "Compiling $(words $?) Java file(s) down to LLVM IR" - @$(BASE_DIR)/bin/polyllvmc -cp $(JDK_CLS) -assert $? + @$(BASE_DIR)/bin/jlangc -cp $(JDK_CLS) -assert $? @touch $(LL) %.ll: %.java @echo "Compiling file to LLVM IR" - @$(BASE_DIR)/bin/polyllvmc -cp $(JDK_CLS) -assert $? + @$(BASE_DIR)/bin/jlangc -cp $(JDK_CLS) -assert $? %.binary: %.ll @echo "Creating binary for $<" diff --git a/tests/misc/pthScript b/tests/misc/pthScript index 8d69ebfe..7a18b885 100644 --- a/tests/misc/pthScript +++ b/tests/misc/pthScript @@ -26,7 +26,7 @@ # CmdLineArgs : additional command line args for the Polyglot # compiler; is always enclosed in quotes. -polyllvm.ExtensionInfo "-d out -c" { +jlang.ExtensionInfo "-d out -c" { # Hello.java; IntAdd.java; }