diff options
| -rw-r--r-- | examples/06-imports/hobgoblin.json5 | 9 | ||||
| -rw-r--r-- | examples/06-imports/output/java/.gitignore | 2 | ||||
| -rw-r--r-- | examples/06-imports/output/java/pom.xml | 47 | ||||
| -rw-r--r-- | examples/06-imports/output/java/src/main/java/org/zwobble/example/Main.java | 11 | ||||
| -rw-r--r-- | examples/06-imports/src/line.hob | 7 | ||||
| -rw-r--r-- | examples/06-imports/src/point.hob | 5 | ||||
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java | 3 |
7 files changed, 82 insertions, 2 deletions
diff --git a/examples/06-imports/hobgoblin.json5 b/examples/06-imports/hobgoblin.json5 new file mode 100644 index 0000000..1ec9568 --- /dev/null +++ b/examples/06-imports/hobgoblin.json5 @@ -0,0 +1,9 @@ +{ + outputs: [ + { + generator: "java-types", + path: "output/java/src/gen/java", + packageName: "org.zwobble.example.types" + }, + ], +} diff --git a/examples/06-imports/output/java/.gitignore b/examples/06-imports/output/java/.gitignore new file mode 100644 index 0000000..ff511d4 --- /dev/null +++ b/examples/06-imports/output/java/.gitignore @@ -0,0 +1,2 @@ +/src/gen/ +/target/ diff --git a/examples/06-imports/output/java/pom.xml b/examples/06-imports/output/java/pom.xml new file mode 100644 index 0000000..506947e --- /dev/null +++ b/examples/06-imports/output/java/pom.xml @@ -0,0 +1,47 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.zwobble.hobgoblin.examples</groupId> + <artifactId>example</artifactId> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>25</maven.compiler.source> + <maven.compiler.target>25</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>org.zwobble.precisely</groupId> + <artifactId>precisely</artifactId> + <version>0.1.5</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.6.1</version> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>src/gen/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/examples/06-imports/output/java/src/main/java/org/zwobble/example/Main.java b/examples/06-imports/output/java/src/main/java/org/zwobble/example/Main.java new file mode 100644 index 0000000..5a48480 --- /dev/null +++ b/examples/06-imports/output/java/src/main/java/org/zwobble/example/Main.java @@ -0,0 +1,11 @@ +package org.zwobble.example; + +import org.zwobble.example.types.point.Point; + +public class Main { + public static void main() { + Point point = new Point(10, 25); + int x = point.x(); + int y = point.y(); + } +} diff --git a/examples/06-imports/src/line.hob b/examples/06-imports/src/line.hob new file mode 100644 index 0000000..53ea271 --- /dev/null +++ b/examples/06-imports/src/line.hob @@ -0,0 +1,7 @@ +import {Point} from ../point; + +/// A straight line from one point to another. +struct Line { + field start: Point; + field end: Point; +} diff --git a/examples/06-imports/src/point.hob b/examples/06-imports/src/point.hob new file mode 100644 index 0000000..87f9953 --- /dev/null +++ b/examples/06-imports/src/point.hob @@ -0,0 +1,5 @@ +/// A 2D point. +struct Point { + field x: Int32; + field y: Int32; +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java b/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java index e9a8122..a8d8dee 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java @@ -86,8 +86,6 @@ public class HobgoblinCompiler { importNode.namespaceName() ); if (!handledNamespaceNames.contains(importedNamespaceName)) { - System.out.println(namespaceNodesByName); - System.out.println(importedNamespaceName); unhandledDependencies.add( // TODO: better error Optional.ofNullable(namespaceNodesByName.get(importedNamespaceName)).orElseThrow() @@ -97,6 +95,7 @@ public class HobgoblinCompiler { if (unhandledDependencies.isEmpty()) { handledNamespaceNames.add(namespaceNode.namespaceName()); + sortedNamespaceNodes.add(namespaceNode); } else { pendingNamespaceNodes.add(namespaceNode); pendingNamespaceNodes.addAll(unhandledDependencies); |
