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