diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-14 18:29:10 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-14 18:29:10 +0100 |
| commit | 78c3d52bc16fefbe35dbceb778f52618078b0854 (patch) | |
| tree | 3857e0897d02cea9e60dc1b4eb8cd721358bd3d0 /src/main/java | |
| parent | d267088721d40065b1e71521127073b471e84db5 (diff) | |
Use field names on namespace node in StackCompiler
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/stackir/StackCompiler.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java index 8e66db30..6b8452c1 100644 --- a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java +++ b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java @@ -107,18 +107,14 @@ public class StackCompiler { .map(statement -> compileNamespaceStatement(statement)) .reduce(P.vector(), PVector::plusAll); - // TODO: handle exports explicitly - for (var statement : node.body()) { - switch (statement) { - case TypedFunctionDefinitionNode functionDefinition -> - instructions = instructions - .plus(new LocalLoadInstruction(functionDefinition.name(), functionDefinition.source())) - .plus(new NamespaceFieldStoreInstruction( - node.namespaceName(), - functionDefinition.name(), - functionDefinition.source() - )); - } + for (var fieldName : node.fieldNames()) { + instructions = instructions + .plus(new LocalLoadInstruction(fieldName, node.source())) + .plus(new NamespaceFieldStoreInstruction( + node.namespaceName(), + fieldName, + node.source() + )); } return instructions; |
