Skip to content

Commit

Permalink
refactor(syntax): replace ecmasl dynamic types with smtml.ty
Browse files Browse the repository at this point in the history
  • Loading branch information
andreffnascimento committed Jun 27, 2024
1 parent 995b342 commit c75dd8e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 54 deletions.
4 changes: 2 additions & 2 deletions ECMA-SL/semantics/core/concrete/interpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ module M (Instrument : Instrument.M) = struct
(* TODO:x should change?*)
Random.self_init ();
match t with
| Type.IntType -> Value.Int (Random.int 128)
| Type.FltType -> Value.Real (Random.float 128.0)
| Type.Ty_int -> Value.Int (Random.int 128)
| Type.Ty_real -> Value.Real (Random.float 128.0)
| _ -> Log.fail "not implemented: symbolic %a" Type.pp t )

and eval_expr (state : state) (e : Expr.t) : Value.t =
Expand Down
17 changes: 0 additions & 17 deletions ECMA-SL/semantics/core/functorial/symbolic_value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,6 @@ module M = struct
fun vs -> E.(make (List vs))
| ArrayExpr -> assert false

let eval_type (t : Type.t) =
let open Ty in
match t with
| NullType -> Log.fail "eval_type null"
| IntType -> Ty_int
| FltType -> Ty_real
| StrType -> Ty_str
| BoolType -> Ty_bool
| SymbolType -> Log.fail "eval_type symbol"
| LocType -> Log.fail "eval_type loc"
| ArrayType -> Log.fail "eval_type array"
| ListType -> Ty_list
| TupleType -> Log.fail "eval_type tuple"
| TypeType -> Log.fail "eval_type type"
| CurryType -> Ty_app

let rec eval_expr (store : store) (e : Expr.t) : value =
match e.it with
| Val v -> E.value v
Expand Down Expand Up @@ -270,7 +254,6 @@ module M = struct
| _ -> Log.fail "error" )
| Symbolic (t, x) -> (
let x' = eval_expr store x in
let t = eval_type t in
match E.view x' with
| Val (Value.Str x') -> E.(make (Symbol (Symbol.make t x')))
| _ -> Log.fail "error" )
Expand Down
36 changes: 1 addition & 35 deletions ECMA-SL/syntax/share/type.ml
Original file line number Diff line number Diff line change
@@ -1,35 +1 @@
open EslBase

type t =
| NullType
| IntType
| FltType
| StrType
| BoolType
| SymbolType
| LocType
| ArrayType
| ListType
| TupleType
| TypeType
| CurryType

let equal (t1 : t) (t2 : t) : bool = t1 = t2

let pp (ppf : Fmt.t) (t : t) : unit =
let open Fmt in
match t with
| NullType -> pp_str ppf "__$Null"
| IntType -> pp_str ppf "__$Int"
| FltType -> pp_str ppf "__$Flt"
| StrType -> pp_str ppf "__$Str"
| BoolType -> pp_str ppf "__$Bool"
| SymbolType -> pp_str ppf "__$Symbol"
| LocType -> pp_str ppf "__$Obj"
| ArrayType -> pp_str ppf "__$Array"
| ListType -> pp_str ppf "__$List"
| TupleType -> pp_str ppf "__$Tuple"
| TypeType -> pp_str ppf "__$Type"
| CurryType -> pp_str ppf "__$Curry"

let str (t : t) : string = Fmt.str "%a" pp t
include Smtml.Ty

0 comments on commit c75dd8e

Please sign in to comment.