luau/prototyping/Luau/Heap.agda
ajeffrey@roblox.com 496a093abb Added step function
2022-02-09 10:39:30 -06:00

31 lines
882 B
Agda
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Luau.Heap where
open import FFI.Data.Maybe using (Maybe; just)
open import FFI.Data.Vector using (Vector; length; snoc)
open import Luau.Addr using (Addr)
open import Luau.Var using (Var)
open import Luau.Syntax using (Block; Expr; nil; addr; function⟨_⟩_end)
data HeapValue : Set where
function⟨_⟩_end : Var Block HeapValue
Heap = Vector HeapValue
data _≡_⊕_↦_ : Heap Heap Addr HeapValue Set where
defn : {H val}
-----------------------------------
(snoc H val) H (length H) val
lookup : Heap Addr Maybe HeapValue
lookup = FFI.Data.Vector.lookup
emp : Heap
emp = FFI.Data.Vector.empty
data AllocResult (H : Heap) (V : HeapValue) : Set where
ok : a H (H H a V) AllocResult H V
alloc : H V AllocResult H V
alloc H V = ok (length H) (snoc H V) defn