110775Slancea(* 2 Copyright (c) 2009, 2015-16 David C. J. Matthews 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License version 2.1 as published by the Free Software Foundation. 7 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public 14 License along with this library; if not, write to the Free Software 15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16*) 17 18signature TYPEIDCODESIG = 19sig 20 type typeId 21 type codetree 22 type codeBinding 23 type types 24 type typeConstrs 25 type typeConstrSet 26 type typeVarForm 27 type typeVarMap 28 type level 29 30 val codeId: typeId * level -> codetree 31 val codeGenerativeId: 32 { source: typeId, isEq: bool, isDatatype: bool, mkAddr: int->int, level: level} -> codetree 33 34 val createDatatypeFunctions: 35 {typeConstr: typeConstrSet, eqStatus: bool, boxedCode: codetree, sizeCode: codetree } list * 36 (int->int) * level * typeVarMap * bool -> codeBinding list 37 38 val codeForUniqueId: unit->codetree 39 40 (* Generate a function of the form t*int->pretty for values of type t. *) 41 val printerForType: types * level * typeVarMap -> codetree 42 (* Generate a function of the form (t,t) -> bool. *) 43 val equalityForType: types * level * typeVarMap -> codetree 44 45 val applyToInstance: 46 { value: types, equality: bool, printity: bool} list * level * typeVarMap * (level -> codetree) -> codetree 47 48 structure TypeVarMap: 49 sig 50 (* Cache of type values and map of type variables. *) 51 type typeVarMap = typeVarMap 52 val defaultTypeVarMap: (int->int) * level -> typeVarMap (* The end of the chain. *) 53 (* Add a set of type variables to the map. *) 54 val extendTypeVarMap: (typeVarForm * (level->codetree)) list * (int->int) * level * typeVarMap -> typeVarMap 55 (* Look up a type variable and return the type it's mapped to. *) 56 val mapTypeVars: typeVarMap -> typeVarForm -> types option 57 (* Mark in the cache chain that some type constructors are new. *) 58 val markTypeConstructors: typeConstrs list * (int->int) * level * typeVarMap -> typeVarMap 59 (* Get the set of cached type values that have been created after this entry. *) 60 val getCachedTypeValues: typeVarMap -> codeBinding list 61 end 62 63 val defaultTypeCode: codetree 64 65 val justForEqualityTypes: bool 66 67 structure Sharing: 68 sig 69 type typeId = typeId 70 type codetree = codetree 71 type types = types 72 type typeConstrs= typeConstrs 73 type typeConstrSet=typeConstrSet 74 type typeVarForm=typeVarForm 75 type typeVarMap = typeVarMap 76 type codeBinding = codeBinding 77 type level = level 78 end 79end; 80