From 5e0ae917d07740b9a06f3255591245acfcd9389e Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 13 Jul 2020 22:21:26 -0700 Subject: 6645 - heap allocations in Mu - allocate var - populate var, n Both rely on the type of `var` to compute the size of the allocation. No need to repeat the name of the type like in C, C++ or Java. --- mu_instructions | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mu_instructions') diff --git a/mu_instructions b/mu_instructions index 7b38a1f8..c23606ec 100644 --- a/mu_instructions +++ b/mu_instructions @@ -258,4 +258,12 @@ out/reg: (addr T) <- lookup in: (handle T) "8b/-> *(epb+" (in.stack-offset+4) ") " reg "/r32" "81 0/subop/add %" reg " 4/imm32" # skip payload->allocid +# Allocating memory + +allocate in: (addr handle T) + => "(allocate Heap " size-of(T) " " in ")" + +populate in: (addr handle array T), num # can be literal or variable on stack or register + => "(allocate-array2 Heap " size-of(T) " " num " " in ")" + vim:ft=mu:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0