aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
index 356323cc..05f42ae2 100644
--- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
@@ -647,7 +647,7 @@ public class ShidCodeGen {
compileNativeFunctionDeclaration(nativeFunctionDeclaration, context);
case TypedNativeTypeDeclarationNode nativeTypeDeclarationNode ->
- throw new UnsupportedOperationException("TODO");
+ compileNativeTypeDeclaration(nativeTypeDeclarationNode, context);
case TypedStructDefinitionNode structDefinition ->
compileStructDefinition(structDefinition, context);
@@ -680,6 +680,23 @@ public class ShidCodeGen {
return context.addInstruction(storeInstruction);
}
+ private static Context compileNativeTypeDeclaration(
+ TypedNativeTypeDeclarationNode node,
+ Context context
+ ) {
+ var nativeType = node.typeOrConstructor().toType();
+
+ context = context.addInstruction(new ShidDeclareNativeType(
+ nativeType,
+ node.source()
+ ));
+
+ var localName = context.shedVariableToLocal(nativeType.name());
+ var storeInstruction = new ShidLocalStore(localName, node.source());
+
+ return context.addInstruction(storeInstruction);
+ }
+
private static Context compileReference(TypedReferenceNode node, Context context) {
var shidVariable = context.shedVariableToShidVariable(node.name());