add runtime value data type

This commit is contained in:
tali 2023-11-29 16:48:24 -05:00
parent b17531b799
commit ee5ca040c7
2 changed files with 20 additions and 0 deletions

19
lib/runtime/value.ml Normal file
View File

@ -0,0 +1,19 @@
type t =
| Nil
| True
| False
| Int of int64
(* | Obj of vtable * slots *)
let equal v1 v2 =
match v1, v2 with
| Int x, Int y -> Int64.equal x y
| _, _ -> v1 == v2
let to_string = function
| Nil -> "nil"
| True -> "true"
| False -> "false"
| Int n -> Int64.to_string n
let pp ppf v = Format.pp_print_string ppf (to_string v)

View File

@ -1,6 +1,7 @@
module Syn = Spice_syntax.Ast module Syn = Spice_syntax.Ast
module Lir = Spice_lower.Lir module Lir = Spice_lower.Lir
module Code = Spice_runtime.Code module Code = Spice_runtime.Code
module Value = Spice_runtime.Value
exception Error of string exception Error of string