aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-01-12 22:10:24 +0000
committerMichael Williamson <mike@zwobble.org>2025-01-12 22:10:24 +0000
commit519f9c3b940f4dbdde6ecf7861db9102ed43b8eb (patch)
tree8b8ef6ed239129b0df27eb2ea853f141960670a5 /src/main/java
parent56886a8b005bfe6f89b0d8eae59a542ca011149a (diff)
Compile native function declarations into Shid
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java17
1 files changed, 16 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 2c371d4b..a7fcff19 100644
--- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
@@ -609,7 +609,7 @@ public class ShidCodeGen {
compileFunctionDefinition(functionDefinition, context);
case TypedNativeFunctionDeclarationNode nativeFunctionDeclaration ->
- throw new UnsupportedOperationException("TODO");
+ compileNativeFunctionDeclaration(nativeFunctionDeclaration, context);
case TypedStructDefinitionNode structDefinition ->
compileStructDefinition(structDefinition, context);
@@ -619,6 +619,21 @@ public class ShidCodeGen {
};
}
+ private static Context compileNativeFunctionDeclaration(
+ TypedNativeFunctionDeclarationNode node,
+ Context context
+ ) {
+ context = context.addInstruction(new ShidDeclareNativeFunction(
+ node.name(),
+ node.source()
+ ));
+
+ var localName = context.shedVariableToLocal(node.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());