summaryrefslogtreecommitdiff
path: root/src/Values.ml
diff options
context:
space:
mode:
authorSon Ho2021-11-03 12:38:52 +0100
committerSon Ho2021-11-03 12:38:52 +0100
commitd7981190632dcac8e5579e41252ed47e2e5b0879 (patch)
tree24a7250bef57d0cd0061ef990d58237e19061a37 /src/Values.ml
parentb582131d54a41a707c4ab75c3bc03251601fb230 (diff)
Add Values.ml and Expressions.ml
Diffstat (limited to 'src/Values.ml')
-rw-r--r--src/Values.ml40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Values.ml b/src/Values.ml
new file mode 100644
index 00000000..006cc8da
--- /dev/null
+++ b/src/Values.ml
@@ -0,0 +1,40 @@
+open Identifiers
+open Types
+
+module VarId = IdGen ()
+
+module FunDefId = IdGen ()
+
+type var = {
+ index : VarId.id; (** Unique variable identifier *)
+ name : string option;
+ ty : ety;
+ (** The variable type - erased type, because variables are not used
+ ** in function signatures *)
+}
+(** A variable *)
+
+(** A scalar value
+
+ Note that we use unbounded integers everywhere.
+ We then harcode the boundaries for the different types.
+ *)
+type scalar_value =
+ | Isize of Big_int.big_int
+ | I8 of Big_int.big_int
+ | I16 of Big_int.big_int
+ | I32 of Big_int.big_int
+ | I64 of Big_int.big_int
+ | I128 of Big_int.big_int
+ | Usize of Big_int.big_int
+ | U8 of Big_int.big_int
+ | U16 of Big_int.big_int
+ | U32 of Big_int.big_int
+ | U64 of Big_int.big_int
+ | U128 of Big_int.big_int
+
+type constant_value =
+ | Scalar of scalar_value
+ | Bool of bool
+ | Char of char
+ | String of string