From 8ae1e2dad3d43a75874e7cbb479601b5abae3b78 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Jul 2023 14:04:22 +0100 Subject: Pass data layout to alloc --- .../java/org/shedlang/compiler/patio/ast/PatioSerializer.java | 2 +- .../shedlang/compiler/patio/ast/instructions/PatioAlloc.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java index 9447ab14..c38851f7 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -73,7 +73,7 @@ public class PatioSerializer { treeList( treeIdentifier("alloc"), localRefToTree(alloc.target()), - treeInt(alloc.bytes()) + dataLayoutToTree(alloc.layout()) ); case PatioCallPointer callPointer -> diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java index 5dad5de6..279ae0db 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java @@ -1,11 +1,16 @@ package org.shedlang.compiler.patio.ast.instructions; import org.shedlang.compiler.patio.ast.PatioLocalRef; +import org.shedlang.compiler.patio.ast.types.PatioDataLayout; import org.shedlang.compiler.sources.Source; /** - * Allocate the given number of bytes, and store the pointer to the allocated - * memory in the target local. + * Allocate space for the given data layout, and store the pointer to the + * allocated memory in the target local. */ -public record PatioAlloc(PatioLocalRef target, int bytes, Source source) implements PatioInstruction { +public record PatioAlloc( + PatioLocalRef target, + PatioDataLayout layout, + Source source +) implements PatioInstruction { } -- cgit v1.2.3