107 lines
3.4 KiB
OCaml
107 lines
3.4 KiB
OCaml
(***********************************************************************)
|
|
(* *)
|
|
(* Caml Special Light *)
|
|
(* *)
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
(* *)
|
|
(* Copyright 1995 Institut National de Recherche en Informatique et *)
|
|
(* Automatique. Distributed only by permission. *)
|
|
(* *)
|
|
(***********************************************************************)
|
|
|
|
(* $Id$ *)
|
|
|
|
(* The "lambda" intermediate code *)
|
|
|
|
open Asttypes
|
|
open Typedtree
|
|
|
|
type primitive =
|
|
Pidentity
|
|
(* Globals *)
|
|
| Pgetglobal of Ident.t
|
|
| Psetglobal of Ident.t
|
|
(* Operations on heap blocks *)
|
|
| Pmakeblock of int * mutable_flag
|
|
| Pfield of int
|
|
| Psetfield of int * bool
|
|
| Pfloatfield of int
|
|
| Psetfloatfield of int
|
|
(* External call *)
|
|
| Pccall of Primitive.description
|
|
(* Exceptions *)
|
|
| Praise
|
|
(* Boolean operations *)
|
|
| Psequand | Psequor | Pnot
|
|
(* Integer operations *)
|
|
| Pnegint | Paddint | Psubint | Pmulint | Pdivint | Pmodint
|
|
| Pandint | Porint | Pxorint
|
|
| Plslint | Plsrint | Pasrint
|
|
| Pintcomp of comparison
|
|
| Poffsetint of int
|
|
| Poffsetref of int
|
|
(* Float operations *)
|
|
| Pintoffloat | Pfloatofint
|
|
| Pnegfloat | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat
|
|
| Pfloatcomp of comparison
|
|
(* String operations *)
|
|
| Pstringlength | Pstringrefu | Pstringsetu | Pstringrefs | Pstringsets
|
|
(* Array operations *)
|
|
| Pmakearray of array_kind
|
|
| Parraylength of array_kind
|
|
| Parrayrefu of array_kind
|
|
| Parraysetu of array_kind
|
|
| Parrayrefs of array_kind
|
|
| Parraysets of array_kind
|
|
(* Compaction of sparse switches *)
|
|
| Ptranslate of (int * int * int) array
|
|
|
|
and comparison =
|
|
Ceq | Cneq | Clt | Cgt | Cle | Cge
|
|
|
|
and array_kind =
|
|
Pgenarray | Paddrarray | Pintarray | Pfloatarray
|
|
|
|
type structured_constant =
|
|
Const_base of constant
|
|
| Const_pointer of int
|
|
| Const_block of int * structured_constant list
|
|
| Const_float_array of string list
|
|
|
|
type lambda =
|
|
Lvar of Ident.t
|
|
| Lconst of structured_constant
|
|
| Lapply of lambda * lambda list
|
|
| Lfunction of Ident.t * lambda
|
|
| Llet of Ident.t * lambda * lambda
|
|
| Lletrec of (Ident.t * lambda) list * lambda
|
|
| Lprim of primitive * lambda list
|
|
| Lswitch of lambda * int * (int * lambda) list * int * (int * lambda) list
|
|
| Lstaticfail
|
|
| Lcatch of lambda * lambda
|
|
| Ltrywith of lambda * Ident.t * lambda
|
|
| Lifthenelse of lambda * lambda * lambda
|
|
| Lsequence of lambda * lambda
|
|
| Lwhile of lambda * lambda
|
|
| Lfor of Ident.t * lambda * lambda * direction_flag * lambda
|
|
| Lshared of lambda * int option ref
|
|
| Lassign of Ident.t * lambda
|
|
|
|
val const_unit: structured_constant
|
|
val lambda_unit: lambda
|
|
val share_lambda: lambda -> lambda
|
|
val name_lambda: lambda -> (Ident.t -> lambda) -> lambda
|
|
val name_lambda_list: lambda list -> (lambda list -> lambda) -> lambda
|
|
val is_guarded: lambda -> bool
|
|
|
|
module IdentSet: Set.S with type elt = Ident.t
|
|
val free_variables: lambda -> IdentSet.t
|
|
|
|
type compilenv
|
|
|
|
val empty_env: compilenv
|
|
val add_env: Ident.t -> lambda -> compilenv -> compilenv
|
|
val transl_access: compilenv -> Ident.t -> lambda
|
|
|
|
val transl_path: Path.t -> lambda
|