summaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java1
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/builtins/NativeTypes.java9
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerGlobalContext.java9
3 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java b/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java
index 7c2c6cc..f37bb8f 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/HobgoblinCompiler.java
@@ -38,6 +38,7 @@ public class HobgoblinCompiler {
var typeCheckerContext = TypeCheckerGlobalContext.initial();
typeCheckerContext.addNativeType(NativeTypes.INT_32);
+ typeCheckerContext.addNativeTypeConstructor(NativeTypes.LIST);
var typedNamespaceNode = TypeChecker.typeCheckNamespace(untypedNamespaceNode, typeCheckerContext);
typedNamespaceNodes.add(typedNamespaceNode);
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/builtins/NativeTypes.java b/src/main/java/org/zwobble/hobgoblin/compiler/builtins/NativeTypes.java
index edbc3fe..3ff1dce 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/builtins/NativeTypes.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/builtins/NativeTypes.java
@@ -1,7 +1,16 @@
package org.zwobble.hobgoblin.compiler.builtins;
import org.zwobble.hobgoblin.compiler.types.SimpleNativeType;
+import org.zwobble.hobgoblin.compiler.types.TypeConstructor;
+import org.zwobble.hobgoblin.compiler.types.TypeParam;
+
+import java.util.List;
public class NativeTypes {
public static SimpleNativeType INT_32 = new SimpleNativeType("Int32");
+
+ public static TypeConstructor<SimpleNativeType> LIST = new TypeConstructor<>(
+ List.of(new TypeParam("T")),
+ new SimpleNativeType("List")
+ );
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerGlobalContext.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerGlobalContext.java
index 4692127..82a7e96 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerGlobalContext.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerGlobalContext.java
@@ -1,9 +1,6 @@
package org.zwobble.hobgoblin.compiler.typechecker;
-import org.zwobble.hobgoblin.compiler.types.NamespaceName;
-import org.zwobble.hobgoblin.compiler.types.SimpleNativeType;
-import org.zwobble.hobgoblin.compiler.types.Type;
-import org.zwobble.hobgoblin.compiler.types.TypeLevelValueType;
+import org.zwobble.hobgoblin.compiler.types.*;
import java.util.HashMap;
import java.util.Map;
@@ -22,6 +19,10 @@ public class TypeCheckerGlobalContext {
this.nativeTypes.put(type.name(), new TypeLevelValueType(type));
}
+ public void addNativeTypeConstructor(TypeConstructor<SimpleNativeType> typeConstructor) {
+ this.nativeTypes.put(typeConstructor.genericType().name(), new TypeLevelValueType(typeConstructor));
+ }
+
public TypeCheckerNamespaceContext enterNamespace(NamespaceName namespaceName) {
return TypeCheckerNamespaceContext.initial(namespaceName, this.nativeTypes);
}