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/patio/PatioCodeGenTuples.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java
index b7198683..c3e1c964 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java
@@ -1,6 +1,7 @@
package org.shedlang.compiler.patio;
import org.shedlang.compiler.patio.ast.instructions.*;
+import org.shedlang.compiler.patio.ast.operands.PatioInt;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
import org.shedlang.compiler.patio.ast.operands.PatioOperand;
import org.shedlang.compiler.patio.ast.types.PatioDataLayout;
@@ -20,6 +21,23 @@ public class PatioCodeGenTuples {
Source source,
PatioCodeGenContext context
) {
+ var tupleResult = context.allocateVal(
+ PatioCodeGenLocalSpace.TUPLE,
+ PatioCodeGenTypes.VALUE_TYPE
+ );
+ var tuple = tupleResult.value();
+ context = tupleResult.context();
+
+ if (elements.size() == 0) {
+ context = context.addInstruction(new PatioLocalStore(
+ tuple,
+ new PatioInt(0),
+ source
+ ));
+
+ return context.toResult(tuple);
+ }
+
var tuplePointerResult = context.allocateVal(
PatioCodeGenLocalSpace.TUPLE_POINTER,
PatioTypes.DATA_POINTER
@@ -47,13 +65,6 @@ public class PatioCodeGenTuples {
));
}
- var tupleResult = context.allocateVal(
- PatioCodeGenLocalSpace.TUPLE,
- PatioCodeGenTypes.VALUE_TYPE
- );
- var tuple = tupleResult.value();
- context = tupleResult.context();
-
context = context.addInstruction(new PatioDataPtrToInt(
tuple,
tuplePointer,