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-23 07:52:56 +08:00
|
|
|
open import Luau.RuntimeError using (RuntimeErrorᴮ; RuntimeErrorᴱ; local; return; TypeMismatch; UnboundVariable; SEGV; app₁; app₂; block; bin₁; bin₂)
|
|
|
|
open import Luau.RuntimeType.ToString using (runtimeTypeToString)
|
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-23 07:52:56 +08:00
|
|
|
open import Luau.Value.ToString using (valueToString)
|
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ᴱ (UnboundVariable x) = "variable " ++ varToString x ++ " is unbound"
|
|
|
|
errToStringᴱ (SEGV a x) = "address " ++ addrToString a ++ " is unallocated"
|
2022-02-19 06:47:23 +08:00
|
|
|
errToStringᴱ (app₁ E) = errToStringᴱ E
|
|
|
|
errToStringᴱ (app₂ E) = errToStringᴱ E
|
2022-02-23 07:52:56 +08:00
|
|
|
errToStringᴱ (bin₁ E) = errToStringᴱ E
|
|
|
|
errToStringᴱ (bin₂ E) = errToStringᴱ E
|
2022-02-10 07:14:29 +08:00
|
|
|
errToStringᴱ (block b E) = errToStringᴮ E ++ "\n in call of function " ++ varToString b
|
2022-02-23 07:52:56 +08:00
|
|
|
errToStringᴱ (TypeMismatch t v _) = "value " ++ valueToString v ++ " is not a " ++ runtimeTypeToString t
|
2022-02-10 07:14:29 +08:00
|
|
|
|
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 06:47:23 +08:00
|
|
|
|