annotate src/core.sml @ 188:8e9f97508f0d

Datatype representation optimization
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 19:49:21 -0400
parents 88d46972de53
children 9bbf4d383381
rev   line source
adamc@16 1 (* Copyright (c) 2008, Adam Chlipala
adamc@16 2 * All rights reserved.
adamc@16 3 *
adamc@16 4 * Redistribution and use in source and binary forms, with or without
adamc@16 5 * modification, are permitted provided that the following conditions are met:
adamc@16 6 *
adamc@16 7 * - Redistributions of source code must retain the above copyright notice,
adamc@16 8 * this list of conditions and the following disclaimer.
adamc@16 9 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@16 10 * this list of conditions and the following disclaimer in the documentation
adamc@16 11 * and/or other materials provided with the distribution.
adamc@16 12 * - The names of contributors may not be used to endorse or promote products
adamc@16 13 * derived from this software without specific prior written permission.
adamc@16 14 *
adamc@16 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@16 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@16 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@16 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@16 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@16 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@16 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@16 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@16 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@16 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@16 25 * POSSIBILITY OF SUCH DAMAGE.
adamc@16 26 *)
adamc@16 27
adamc@16 28 structure Core = struct
adamc@16 29
adamc@16 30 type 'a located = 'a ErrorMsg.located
adamc@16 31
adamc@16 32 datatype kind' =
adamc@16 33 KType
adamc@16 34 | KArrow of kind * kind
adamc@16 35 | KName
adamc@16 36 | KRecord of kind
adamc@87 37 | KUnit
adamc@16 38
adamc@16 39 withtype kind = kind' located
adamc@16 40
adamc@16 41 datatype con' =
adamc@16 42 TFun of con * con
adamc@16 43 | TCFun of string * kind * con
adamc@16 44 | TRecord of con
adamc@16 45
adamc@16 46 | CRel of int
adamc@16 47 | CNamed of int
adamc@48 48 | CFfi of string * string
adamc@16 49 | CApp of con * con
adamc@16 50 | CAbs of string * kind * con
adamc@16 51
adamc@16 52 | CName of string
adamc@16 53
adamc@16 54 | CRecord of kind * (con * con) list
adamc@16 55 | CConcat of con * con
adamc@69 56 | CFold of kind * kind
adamc@16 57
adamc@87 58 | CUnit
adamc@87 59
adamc@16 60 withtype con = con' located
adamc@16 61
adamc@188 62 datatype datatype_kind = datatype Elab.datatype_kind
adamc@188 63
adamc@177 64 datatype patCon =
adamc@177 65 PConVar of int
adamc@188 66 | PConFfi of {mod : string, datatyp : string, con : string, arg : con option, kind : datatype_kind}
adamc@177 67
adamc@177 68 datatype pat' =
adamc@177 69 PWild
adamc@182 70 | PVar of string * con
adamc@177 71 | PPrim of Prim.t
adamc@188 72 | PCon of datatype_kind * patCon * pat option
adamc@182 73 | PRecord of (string * pat * con) list
adamc@177 74
adamc@177 75 withtype pat = pat' located
adamc@177 76
adamc@16 77 datatype exp' =
adamc@16 78 EPrim of Prim.t
adamc@16 79 | ERel of int
adamc@16 80 | ENamed of int
adamc@188 81 | ECon of datatype_kind * patCon * exp option
adamc@48 82 | EFfi of string * string
adamc@48 83 | EFfiApp of string * string * exp list
adamc@16 84 | EApp of exp * exp
adamc@26 85 | EAbs of string * con * con * exp
adamc@16 86 | ECApp of exp * con
adamc@16 87 | ECAbs of string * kind * exp
adamc@16 88
adamc@29 89 | ERecord of (con * exp * con) list
adamc@16 90 | EField of exp * con * { field : con, rest : con }
adamc@149 91 | ECut of exp * con * { field : con, rest : con }
adamc@73 92 | EFold of kind
adamc@16 93
adamc@182 94 | ECase of exp * (pat * exp) list * { disc : con, result : con }
adamc@177 95
adamc@102 96 | EWrite of exp
adamc@102 97
adamc@110 98 | EClosure of int * exp list
adamc@110 99
adamc@16 100 withtype exp = exp' located
adamc@16 101
adamc@144 102 datatype export_kind =
adamc@144 103 Link
adamc@144 104 | Action
adamc@144 105
adamc@16 106 datatype decl' =
adamc@16 107 DCon of string * int * kind * con
adamc@163 108 | DDatatype of string * int * (string * int * con option) list
adamc@109 109 | DVal of string * int * con * exp * string
adamc@125 110 | DValRec of (string * int * con * exp * string) list
adamc@144 111 | DExport of export_kind * int
adamc@16 112
adamc@16 113 withtype decl = decl' located
adamc@16 114
adamc@16 115 type file = decl list
adamc@16 116
adamc@16 117 end