mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 22:35:43 +08:00
5187e64f88
* First cut interpreter
22 lines
1008 B
Agda
22 lines
1008 B
Agda
module Luau.RuntimeError where
|
|
|
|
open import Agda.Builtin.Equality using (_≡_)
|
|
open import Luau.Heap using (Heap; lookup)
|
|
open import FFI.Data.Maybe using (just; nothing)
|
|
open import Luau.Syntax using (Block; Expr; nil; var; addr; function⟨_⟩_end; block_is_end; _$_; local_←_; function_⟨_⟩_end; return; done; _∙_)
|
|
|
|
data RuntimeErrorᴮ (H : Heap) : Block → Set
|
|
data RuntimeErrorᴱ (H : Heap) : Expr → Set
|
|
|
|
data RuntimeErrorᴱ H where
|
|
NilIsNotAFunction : ∀ {M} → RuntimeErrorᴱ H (nil $ M)
|
|
UnboundVariable : ∀ x → RuntimeErrorᴱ H (var x)
|
|
SEGV : ∀ a → (lookup H a ≡ nothing) → RuntimeErrorᴱ H (addr a)
|
|
app : ∀ {M N} → RuntimeErrorᴱ H M → RuntimeErrorᴱ H (M $ N)
|
|
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)
|
|
|