2022-02-09 23:14:29 +00:00
|
|
|
module Luau.RuntimeError where
|
|
|
|
|
|
|
|
open import Agda.Builtin.Equality using (_≡_)
|
2022-02-12 01:03:26 +00:00
|
|
|
open import Luau.Heap using (Heap; _[_])
|
2022-02-09 23:14:29 +00:00
|
|
|
open import FFI.Data.Maybe using (just; nothing)
|
2022-02-18 19:09:00 +00:00
|
|
|
open import FFI.Data.String using (String)
|
|
|
|
open import Luau.Syntax using (Block; Expr; nil; var; addr; block_is_end; _$_; local_←_; return; done; _∙_; number)
|
2022-02-18 22:47:23 +00:00
|
|
|
open import Luau.Value using (val)
|
2022-02-09 23:14:29 +00:00
|
|
|
|
2022-02-12 01:03:26 +00:00
|
|
|
data RuntimeErrorᴮ {a} (H : Heap a) : Block a → Set
|
|
|
|
data RuntimeErrorᴱ {a} (H : Heap a) : Expr a → Set
|
2022-02-09 23:14:29 +00:00
|
|
|
|
|
|
|
data RuntimeErrorᴱ H where
|
2022-02-18 22:47:23 +00:00
|
|
|
NilIsNotAFunction : ∀ {V} → RuntimeErrorᴱ H (nil $ val V)
|
|
|
|
NumberIsNotAFunction : ∀ n {V} → RuntimeErrorᴱ H (number n $ val V)
|
2022-02-09 23:14:29 +00:00
|
|
|
UnboundVariable : ∀ x → RuntimeErrorᴱ H (var x)
|
2022-02-12 01:03:26 +00:00
|
|
|
SEGV : ∀ a → (H [ a ] ≡ nothing) → RuntimeErrorᴱ H (addr a)
|
2022-02-18 22:47:23 +00:00
|
|
|
app₁ : ∀ {M N} → RuntimeErrorᴱ H M → RuntimeErrorᴱ H (M $ N)
|
|
|
|
app₂ : ∀ {M N} → RuntimeErrorᴱ H N → RuntimeErrorᴱ H (M $ N)
|
2022-02-09 23:14:29 +00:00
|
|
|
block : ∀ b {B} → RuntimeErrorᴮ H B → RuntimeErrorᴱ H (block b is B end)
|
|
|
|
|
|
|
|
data RuntimeErrorᴮ H where
|
|
|
|
local : ∀ x {M B} → RuntimeErrorᴱ H M → RuntimeErrorᴮ H (local x ← M ∙ B)
|
|
|
|
return : ∀ {M B} → RuntimeErrorᴱ H M → RuntimeErrorᴮ H (return M ∙ B)
|