2022-02-10 07:14:29 +08:00
|
|
|
module Luau.RuntimeError.ToString where
|
|
|
|
|
2022-02-19 03:09:00 +08:00
|
|
|
open import Agda.Builtin.Float using (primShowFloat)
|
2022-02-10 07:14:29 +08:00
|
|
|
open import FFI.Data.String using (String; _++_)
|
2022-02-19 03:09:00 +08:00
|
|
|
open import Luau.RuntimeError using (RuntimeErrorᴮ; RuntimeErrorᴱ; local; return; NilIsNotAFunction; NumberIsNotAFunction; UnboundVariable; SEGV; app; block)
|
2022-02-10 07:14:29 +08:00
|
|
|
open import Luau.Addr.ToString using (addrToString)
|
2022-02-19 03:09:00 +08:00
|
|
|
open import Luau.Syntax.ToString using (exprToString)
|
2022-02-10 07:14:29 +08:00
|
|
|
open import Luau.Var.ToString using (varToString)
|
2022-02-19 03:09:00 +08:00
|
|
|
open import Luau.Syntax using (name; _$_)
|
2022-02-10 07:14:29 +08:00
|
|
|
|
2022-02-12 09:03:26 +08:00
|
|
|
errToStringᴱ : ∀ {a H B} → RuntimeErrorᴱ {a} H B → String
|
|
|
|
errToStringᴮ : ∀ {a H B} → RuntimeErrorᴮ {a} H B → String
|
2022-02-10 07:14:29 +08:00
|
|
|
|
|
|
|
errToStringᴱ NilIsNotAFunction = "nil is not a function"
|
2022-02-19 03:09:00 +08:00
|
|
|
errToStringᴱ (NumberIsNotAFunction n) = "number " ++ primShowFloat n ++ " is not a function"
|
2022-02-10 07:14:29 +08:00
|
|
|
errToStringᴱ (UnboundVariable x) = "variable " ++ varToString x ++ " is unbound"
|
|
|
|
errToStringᴱ (SEGV a x) = "address " ++ addrToString a ++ " is unallocated"
|
|
|
|
errToStringᴱ (app E) = errToStringᴱ E
|
|
|
|
errToStringᴱ (block b E) = errToStringᴮ E ++ "\n in call of function " ++ varToString b
|
|
|
|
|
2022-02-12 09:03:26 +08:00
|
|
|
errToStringᴮ (local x E) = errToStringᴱ E ++ "\n in definition of " ++ varToString (name x)
|
2022-02-10 07:14:29 +08:00
|
|
|
errToStringᴮ (return E) = errToStringᴱ E ++ "\n in return statement"
|
2022-02-19 03:09:00 +08:00
|
|
|
|