aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorronny2002-10-14 23:06:24 +0000
committerronny2002-10-14 23:06:24 +0000
commit4147cc9bb6a8589fb7a365894baa087aeb02df8b (patch)
tree9ce0561562f57d3e20d8abceb6d5f691209773ac
parentbug fix convert root cases (diff)
new type code and type code constructor representation
clean-up and renamed functions from StdDynamic git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1234 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r--frontend/check.icl32
-rw-r--r--frontend/convertDynamics.icl376
-rw-r--r--frontend/overloading.icl135
-rw-r--r--frontend/parse.icl34
-rw-r--r--frontend/postparse.icl54
-rw-r--r--frontend/predef.dcl243
-rw-r--r--frontend/predef.icl81
-rw-r--r--frontend/syntax.dcl4
-rw-r--r--frontend/type.icl4
-rw-r--r--frontend/type_io_common.dcl2
-rw-r--r--frontend/type_io_common.icl6
11 files changed, 528 insertions, 443 deletions
diff --git a/frontend/check.icl b/frontend/check.icl
index 0986851..719691d 100644
--- a/frontend/check.icl
+++ b/frontend/check.icl
@@ -2490,11 +2490,6 @@ check_module2 mod_name mod_modification_time mod_imported_objects mod_imports mo
(dcls_import_list, dcl_modules, cs)
= addImportedSymbolsToSymbolTable nr_of_modules (Yes dcl_macros) modules_in_component_set imports_ikh dcl_modules cs
- (x_main_dcl_module,cs) = cs!cs_x.x_main_dcl_module_n
- cs = cs
- <=< adjustPredefSymbol PD_ModuleConsSymbol x_main_dcl_module STE_Constructor
-
-
(dcl_modules, icl_functions,macro_defs,hp_expression_heap, cs)
= checkExplicitImportCompleteness imports.si_explicit dcl_modules icl_functions macro_defs heaps.hp_expression_heap cs
@@ -3443,15 +3438,34 @@ where
<=< adjustPredefSymbol PD_Dyn_DynamicTemp mod_index STE_Type
<=< adjustPredefSymbol PD_Dyn_Type mod_index STE_Type
<=< adjustPredefSymbol PD_Dyn_TypeScheme mod_index STE_Constructor
+ <=< adjustPredefSymbol PD_Dyn_TypeCons mod_index STE_Constructor
<=< adjustPredefSymbol PD_Dyn_TypeApp mod_index STE_Constructor
<=< adjustPredefSymbol PD_Dyn_TypeVar mod_index STE_Constructor
<=< adjustPredefSymbol PD_Dyn_TypePatternVar mod_index STE_Constructor
- <=< adjustPredefSymbol PD_Dyn_ModuleID mod_index STE_Constructor
- <=< adjustPredefSymbol PD_Dyn_Unifier mod_index STE_Type
+ <=< adjustPredefSymbol PD_Dyn_UnificationEnvironment mod_index STE_Type
+ <=< adjustPredefSymbol PD_Dyn_initial_unification_environment mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_bind_global_type_pattern_var mod_index STE_DclFunction
<=< adjustPredefSymbol PD_Dyn_unify mod_index STE_DclFunction
- <=< adjustPredefSymbol PD_Dyn_initial_unifier mod_index STE_DclFunction
<=< adjustPredefSymbol PD_Dyn_normalise mod_index STE_DclFunction
- <=< adjustPredefSymbol PD_Dyn_bind_global_type_pattern_var mod_index STE_DclFunction)
+
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorInt mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorChar mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorReal mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorBool mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorDynamic mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorFile mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructorWorld mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_Arrow mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_List mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_StrictList mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_UnboxedList mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_TailStrictList mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_StrictTailStrictList mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_UnboxedTailStrictList mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_Tuple mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_LazyArray mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_StrictArray mod_index STE_DclFunction
+ <=< adjustPredefSymbol PD_Dyn_TypeCodeConstructor_UnboxedArray mod_index STE_DclFunction)
# (pre_mod, cs_predef_symbols) = cs_predef_symbols![PD_StdGeneric]
# type_bimap = predefined_idents.[PD_TypeBimap]
diff --git a/frontend/convertDynamics.icl b/frontend/convertDynamics.icl
index 3c04535..6b3ccb8 100644
--- a/frontend/convertDynamics.icl
+++ b/frontend/convertDynamics.icl
@@ -13,11 +13,8 @@ extended_unify_and_coerce no yes :== no; // change also _unify and _coerce in St
import type_io;
//import pp;
-/*2.0
-from type_io_common import class toString (..),instance toString GlobalTCType;
-0.2*/
-:: TypeCodeVariableInfo = TCI_TypeTerm | TCI_TypeVar !Expression
+:: TypeCodeVariableInfo = TCI_TypeVar !Expression | TCI_TypePatternVar !Expression
:: DynamicValueAliasInfo :== BoundVar
:: *ConversionState =
@@ -27,9 +24,8 @@ from type_io_common import class toString (..),instance toString GlobalTCType;
, ci_new_variables :: ![FreeVar]
, ci_type_pattern_var_count :: !Int
+ , ci_type_var_count :: !Int
// data needed to generate coercions
- , ci_module_id_symbol :: Expression
- , ci_module_id_var :: Optional LetBind
, ci_type_constructor_used_in_dynamic_patterns :: !*{#Bool}
}
@@ -49,6 +45,9 @@ from type_io_common import class toString (..),instance toString GlobalTCType;
F :: !a .b -> .b
F a b = b
+fatal :: {#Char} {#Char} -> .a
+fatal function_name message
+ = abort ("convertDynamics, " +++ function_name +++ ": " +++ message)
//write_tcl_file :: !Int {#DclModule} CommonDefs !*File [String] -> (.Bool,.File)
//write_tcl_file :: !Int {#DclModule} CommonDefs !*File [String] _ _ !*TypeHeaps !*PredefinedSymbols -> (.Bool,.File,!*TypeHeaps,!*PredefinedSymbols)
@@ -71,7 +70,7 @@ write_tcl_file main_dcl_module_n dcl_mods=:{[main_dcl_module_n] = main_dcl_modul
// dynamic pattern matches
#! type_constructors_in_dynamic_patterns
- = collect_type_constructors_in_dynamic_patterns 0 (size global_type_instances) []
+ = collect_type_constructors_in_dynamic_patterns 0 (size global_type_instances) []
#! (tcl_file,write_type_info_state)
= write_type_info type_constructors_in_dynamic_patterns tcl_file write_type_info_state
@@ -91,60 +90,37 @@ write_tcl_file main_dcl_module_n dcl_mods=:{[main_dcl_module_n] = main_dcl_modul
= (True,tcl_file,type_heaps,predefined_symbols)
where
+
collect_type_constructors_in_dynamic_patterns :: !Int !Int [TypeSymbIdent] -> [TypeSymbIdent]
collect_type_constructors_in_dynamic_patterns i limit type_constructors_in_dynamic_patterns
- | i == limit
- = type_constructors_in_dynamic_patterns
-
- | isGTT_Constructor global_type_instances.[i]
- # (GTT_Constructor type_name=:{type_name={id_name}} module_name used_in_application_of_type_dependent_function)
- = global_type_instances.[i]
- | used_in_application_of_type_dependent_function || ci_type_constructor_used_in_dynamic_patterns.[i]
- = collect_type_constructors_in_dynamic_patterns (inc i) limit [type_name:type_constructors_in_dynamic_patterns]
- = collect_type_constructors_in_dynamic_patterns (inc i) limit type_constructors_in_dynamic_patterns
- = collect_type_constructors_in_dynamic_patterns (inc i) limit type_constructors_in_dynamic_patterns
- where
- isGTT_Constructor (GTT_Constructor _ _ _) = True
- isGTT_Constructor _ = False
-
+ = []
+
f write_type_info_state=:{wtis_type_heaps}
= (wtis_type_heaps,{write_type_info_state & wtis_type_heaps = abort "convertDynamics.icl"});
+
+
/*2.0
f (Yes tcl_file)
= tcl_file;
0.2*/
+
convertDynamicPatternsIntoUnifyAppls :: {! GlobalTCType} !{# CommonDefs} !Int !*{! Group} !*{#FunDef} !*PredefinedSymbols !*VarHeap !*TypeHeaps !*ExpressionHeap (Optional *File) {# DclModule} !IclModule [String]
-> (!*{! Group}, !*{#FunDef}, !*PredefinedSymbols, !*{#{# CheckedTypeDef}}, !ImportedConstructors, !*VarHeap, !*TypeHeaps, !*ExpressionHeap, (Optional *File))
convertDynamicPatternsIntoUnifyAppls global_type_instances common_defs main_dcl_module_n groups fun_defs predefined_symbols var_heap type_heaps expr_heap tcl_file dcl_mods icl_mod directly_imported_dcl_modules
#! (dynamic_representation,predefined_symbols)
= create_dynamic_and_selector_idents common_defs predefined_symbols
-/*
- # (module_symb,module_id,predefined_symbols)
- = get_module_id_app predefined_symbols
- # ({pds_module=pds_type_id_module, pds_def=pds_type_id_def} , predefined_symbols) = predefined_symbols![PD_TypeID]
- # type_id
- = { type_name = common_defs.[pds_type_id_module].com_type_defs.[pds_type_id_def].td_name
- , type_arity = 0
- , type_index = { glob_object = pds_type_id_def, glob_module = pds_type_id_module}
- , type_prop = { tsp_sign = BottomSignClass, tsp_propagation = NoPropClass, tsp_coercible = True }
- }
-*/
- # type_id = undef
- # (module_symb,module_id,predefined_symbols)
- = get_module_id_app predefined_symbols
#! nr_of_funs = size fun_defs
#! s_global_type_instances = size global_type_instances
# imported_types = {com_type_defs \\ {com_type_defs} <-: common_defs }
# (groups, (fun_defs, {ci_predef_symb, ci_var_heap, ci_expr_heap, ci_type_constructor_used_in_dynamic_patterns}))
- = convert_groups 0 groups global_type_instances type_id module_id dynamic_representation (fun_defs, {
+ = convert_groups 0 groups global_type_instances dynamic_representation (fun_defs, {
ci_predef_symb = predefined_symbols, ci_var_heap = var_heap, ci_expr_heap = expr_heap,
ci_new_variables = [],
+ ci_type_var_count = -1,
ci_type_pattern_var_count = 0,
- ci_module_id_symbol = App module_symb,
- ci_module_id_var = No,
ci_type_constructor_used_in_dynamic_patterns = createArray s_global_type_instances False
})
@@ -163,13 +139,13 @@ convertDynamicPatternsIntoUnifyAppls global_type_instances common_defs main_dcl_
= (groups, fun_defs, ci_predef_symb, imported_types, [], ci_var_heap, type_heaps, ci_expr_heap, tcl_file)
where
- convert_groups group_nr groups global_type_instances type_id module_id dynamic_representation fun_defs_and_ci
+ convert_groups group_nr groups global_type_instances dynamic_representation fun_defs_and_ci
| group_nr == size groups
= (groups, fun_defs_and_ci)
# (group, groups) = groups![group_nr]
- = convert_groups (inc group_nr) groups global_type_instances type_id module_id dynamic_representation (foldSt (convert_function group_nr global_type_instances type_id module_id dynamic_representation) group.group_members fun_defs_and_ci)
+ = convert_groups (inc group_nr) groups global_type_instances dynamic_representation (foldSt (convert_function group_nr global_type_instances dynamic_representation) group.group_members fun_defs_and_ci)
- convert_function group_nr global_type_instances type_id module_id dynamic_representation fun (fun_defs, ci)
+ convert_function group_nr global_type_instances dynamic_representation fun (fun_defs, ci)
# (fun_def, fun_defs) = fun_defs![fun]
{fun_body, fun_type, fun_info} = fun_def
| isEmpty fun_info.fi_dynamics
@@ -179,8 +155,6 @@ where
// of its use. In some very specific cases, the let generated here is superfluous.
# (TransformedBody fun_body=:{tb_rhs})
= fun_body
- # (tb_rhs, ci)
- = share_module_identification tb_rhs module_id ci
# fun_body
= {fun_body & tb_rhs = tb_rhs}
# fun_body
@@ -189,7 +163,7 @@ where
# (unify_subst_var, ci)
= newVariable "unify_subst" VI_Empty ci
# ci
- = {ci & ci_type_pattern_var_count = 0}
+ = {ci & ci_type_pattern_var_count = 0, ci_type_var_count = -1}
# (fun_body, ci) = convertDynamics {cinp_st_args = [], cinp_dynamic_representation = dynamic_representation,
cinp_glob_type_inst = global_type_instances,
@@ -197,34 +171,6 @@ where
= ({fun_defs & [fun] = { fun_def & fun_body = fun_body, fun_info = { fun_info & fi_local_vars = ci.ci_new_variables ++ fun_info.fi_local_vars }}},
{ ci & ci_new_variables = [] })
- where
- share_module_identification rhs module_id ci
- # (dst=:{var_info_ptr},ci)
- = newVariable "module_id" VI_Empty ci
- # dst_fv
- = varToFreeVar dst 1
- # let_bind
- = { lb_src = module_id
- , lb_dst = dst_fv
- , lb_position = NoPos
- }
-
- # ci
- = { ci &
- ci_new_variables = [ dst_fv : ci.ci_new_variables ]
- , ci_module_id_var = Yes let_bind
- }
-
- # (let_info_ptr, ci) = let_ptr2 [toAType TE] ci
- # rhs
- = Let { let_strict_binds = [],
- let_lazy_binds = [let_bind],
- let_expr = rhs,
- let_info_ptr = let_info_ptr,
- let_expr_position = NoPos
- }
- = (rhs, ci)
-
class convertDynamics a :: !ConversionInput !a !*ConversionState -> (!a, !*ConversionState)
@@ -250,8 +196,8 @@ instance convertDynamics TransformedBody where
convertDynamics cinp body=:{tb_args,tb_rhs} ci=:{ci_var_heap}
// this actually marks all arguments as type terms (also the regular arguments
// and dictionaries)
- # ci_var_heap
- = foldSt mark_var tb_args ci_var_heap
+// # ci_var_heap
+// = foldSt mark_var tb_args ci_var_heap
# (tb_rhs, ci)
= convertDynamics cinp tb_rhs {ci & ci_var_heap = ci_var_heap}
# (global_tpvs, subst, ci)
@@ -260,9 +206,9 @@ instance convertDynamics TransformedBody where
= share_init_subst subst global_tpvs tb_rhs ci
= ({body & tb_rhs = tb_rhs}, ci)
where
- mark_var :: FreeVar *VarHeap -> *VarHeap
- mark_var {fv_info_ptr} var_heap
- = writePtr fv_info_ptr (VI_TypeCodeVariable TCI_TypeTerm) var_heap
+// mark_var :: FreeVar *VarHeap -> *VarHeap
+// mark_var {fv_info_ptr} var_heap
+// = writePtr fv_info_ptr (VI_TypeCodeVariable TCI_TypeTerm) var_heap
collect_global_type_pattern_var :: FreeVar ([LetBind], BoundVar, *ConversionState) -> ([LetBind], BoundVar, *ConversionState)
collect_global_type_pattern_var {fv_info_ptr} (l, subst, ci)
@@ -271,7 +217,7 @@ instance convertDynamics TransformedBody where
# ci
= {ci & ci_var_heap = ci_var_heap}
= case var_info of
- VI_TypeCodeVariable (TCI_TypeVar tpv)
+ VI_TypeCodeVariable (TCI_TypePatternVar tpv)
# (bind_global_tpv_symb, ci)
= getSymbol PD_Dyn_bind_global_type_pattern_var SK_Function 3 ci
# type_code
@@ -293,13 +239,16 @@ instance convertDynamics TransformedBody where
share_init_subst :: BoundVar [LetBind] Expression *ConversionState
-> (Expression, *ConversionState)
- share_init_subst subst global_tpv_binds rhs ci=:{ci_type_pattern_var_count}
+ share_init_subst subst global_tpv_binds rhs ci=:{ci_type_pattern_var_count, ci_type_var_count}
# (initial_unifier_symb, ci)
- = getSymbol PD_Dyn_initial_unifier SK_Function 1 ci
+ = getSymbol PD_Dyn_initial_unification_environment SK_Function 2 ci
# let_bind_initial_subst
= { lb_src = App { app_symb = initial_unifier_symb,
- app_args = [BasicExpr (BVInt ci_type_pattern_var_count)],
+ app_args =
+ [ BasicExpr (BVInt ci_type_pattern_var_count)
+ , BasicExpr (BVInt (~ci_type_var_count-1))
+ ],
app_info_ptr = nilPtr }
, lb_dst = varToFreeVar subst 1
, lb_position = NoPos
@@ -335,13 +284,9 @@ instance convertDynamics (Bind a b) | convertDynamics a where
instance convertDynamics Expression where
convertDynamics cinp (TypeCodeExpression tce) ci
- # (type_code, ci)
+ # (dyn_type_code, ci)
= convertExprTypeCode cinp tce ci
- # (normalise_symb, ci)
- = getSymbol PD_Dyn_normalise SK_Function 2 ci
- # normalise_call
- = App { app_symb = normalise_symb, app_args = [ Var cinp.cinp_subst_var, type_code], app_info_ptr = nilPtr }
- = (normalise_call, ci)
+ = (dyn_type_code, ci)
convertDynamics cinp (Var var) ci
# (info, ci_var_heap)
= readPtr var.var_info_ptr ci.ci_var_heap
@@ -469,17 +414,9 @@ convertDynamic cinp=:{cinp_dynamic_representation={dr_type_ident}}
= convertDynamics cinp dyn_expr ci
# (dyn_type_code, ci)
= convertExprTypeCode cinp dyn_type_code ci
-
- # (normalise_symb, ci)
- = getSymbol PD_Dyn_normalise SK_Function 2 ci
-
- # normalise_call
- = App { app_symb = normalise_symb, app_args = [ Var cinp.cinp_subst_var, dyn_type_code], app_info_ptr = nilPtr }
-
= (App { app_symb = dr_type_ident,
- app_args = [dyn_expr, normalise_call],
+ app_args = [dyn_expr, dyn_type_code],
app_info_ptr = nilPtr }, ci)
-
convertDynamicCase cinp=:{cinp_dynamic_representation={dr_dynamic_symbol, dr_dynamic_type}}
kees=:{case_guards=DynamicPatterns alts, case_info_ptr, case_default} ci
# (value_var, ci)
@@ -619,127 +556,173 @@ convertExprTypeCode
:: !ConversionInput !TypeCodeExpression !*ConversionState
-> (!Expression, !*ConversionState)
convertExprTypeCode cinp tce ci
- # (expr, binds, ci)
- = convertTypeCode cinp tce [] ci
+ # (type_code, (has_var, binds, ci))
+ = convertTypeCode False cinp tce (False, [], ci)
// sanity check ...
| not (isEmpty binds)
= abort "unexpected binds in expression type code"
// ... sanity check
- = (expr, ci)
+ # (normalise_symb, ci)
+ = getSymbol PD_Dyn_normalise SK_Function 2 ci
+ # type_code
+ = App { app_symb = normalise_symb,
+ app_args = [ BasicExpr (BVB has_var), Var cinp.cinp_subst_var, type_code], app_info_ptr = nilPtr }
+ = (type_code, ci)
convertPatternTypeCode :: !ConversionInput !TypeCodeExpression !*ConversionState
-> (!Expression, ![LetBind], !*ConversionState)
convertPatternTypeCode cinp tce ci
- = convertTypeCode cinp tce [] ci
+ # (type_code, (has_var, binds, ci))
+ = convertTypeCode True cinp tce (False, [], ci)
+ = (type_code, binds, ci)
-convertTypeCode :: !ConversionInput !TypeCodeExpression ![LetBind] !*ConversionState
- -> (!Expression, ![LetBind], !*ConversionState)
-convertTypeCode _ (TCE_Var var_info_ptr) binds ci=:{ci_var_heap}
+convertTypeCode :: !Bool !ConversionInput !TypeCodeExpression (!Bool, ![LetBind], !*ConversionState)
+ -> (!Expression, (!Bool, ![LetBind], !*ConversionState))
+convertTypeCode pattern _ (TCE_Var var_info_ptr) (has_var, binds, ci=:{ci_var_heap})
# (var_info, ci_var_heap)
= readPtr var_info_ptr ci_var_heap
ci
= {ci & ci_var_heap = ci_var_heap}
= case var_info of
- // sanity check ...
- VI_TypeCodeVariable TCI_TypeTerm
- -> abort "unexpected type term"
- // ... sanity check
- VI_TypeCodeVariable (TCI_TypeVar expr)
- -> (expr, binds, ci)
+ VI_TypeCodeVariable (TCI_TypeVar tv)
+ -> (tv, (has_var, binds, ci))
+ VI_TypeCodeVariable (TCI_TypePatternVar tpv)
+ -> (tpv, (True, binds, ci))
_
# (expr, ci)
= createTypePatternVariable ci
# ci
= {ci & ci_var_heap
- = writePtr var_info_ptr (VI_TypeCodeVariable (TCI_TypeVar expr)) ci.ci_var_heap}
- -> (expr, binds, ci)
-convertTypeCode _ (TCE_TypeTerm var_info_ptr) binds ci=:{ci_var_heap}
- // sanity check ...
+ = writePtr var_info_ptr (VI_TypeCodeVariable (TCI_TypePatternVar expr)) ci.ci_var_heap}
+ -> (expr, (True, binds, ci))
+convertTypeCode pattern _ (TCE_TypeTerm var_info_ptr) (has_var, binds, ci=:{ci_var_heap})
# (var_info, ci_var_heap)
= readPtr var_info_ptr ci_var_heap
ci
= {ci & ci_var_heap = ci_var_heap}
-// # ci
= case var_info of
- VI_TypeCodeVariable TCI_TypeTerm
- # (expr, ci)
- = createTypePatternVariable ci
- # ci
- = {ci & ci_var_heap
- = writePtr var_info_ptr (VI_TypeCodeVariable (TCI_TypeVar expr)) ci.ci_var_heap}
- -> (expr, binds, ci)
- VI_TypeCodeVariable (TCI_TypeVar expr)
- -> (expr, binds, ci)
- info
- -> abort "type term expected instead of unknown"
-/*
- // ... sanity check
- # var
- // FIXME, share vars & proper name
- = {var_name = a_ij_var_name, var_info_ptr = var_info_ptr,
- var_expr_ptr = nilPtr}
- = (Var var, binds, ci)
-*/
-convertTypeCode cinp (TCE_Constructor index typecode_exprs) binds ci
+ VI_TypeCodeVariable (TCI_TypeVar tv)
+ -> (tv, (has_var, binds, ci))
+ VI_TypeCodeVariable (TCI_TypePatternVar tpv)
+ -> (tpv, (True, binds, ci))
+ _
+ # (expr, ci)
+ = createTypePatternVariable ci
+ # ci
+ = {ci & ci_var_heap
+ = writePtr var_info_ptr (VI_TypeCodeVariable (TCI_TypePatternVar expr)) ci.ci_var_heap}
+ -> (expr, (True, binds, ci))
+
+convertTypeCode pattern cinp (TCE_App t arg) (has_var, binds, ci)
# (typeapp_symb, ci)
= getSymbol PD_Dyn_TypeApp SK_Constructor 2 ci
- # (constructor, ci)
- = get_constructor cinp.cinp_glob_type_inst index ci
- (module_id, ci)
- = get_module_id ci
- (typecode_exprs, binds, ci)
- = convertTypeCodes cinp typecode_exprs binds ci
+ # (typecode_t, st)
+ = convertTypeCode pattern cinp t (has_var, binds, ci)
+ # (typecode_arg, st)
+ = convertTypeCode pattern cinp arg st
= (App {app_symb = typeapp_symb,
- app_args = [constructor, module_id, typecode_exprs],
- app_info_ptr = nilPtr}, binds, ci)
+ app_args = [typecode_t, typecode_arg],
+ app_info_ptr = nilPtr}, st)
+convertTypeCode pattern cinp (TCE_Constructor index []) (has_var, binds, ci)
+ # (typecons_symb, ci)
+ = getSymbol PD_Dyn_TypeCons SK_Constructor 1 ci
+ # (constructor, ci)
+ = typeConstructor cinp.cinp_glob_type_inst.[index] ci
+ = (App {app_symb = typecons_symb,
+ app_args = [constructor],
+ app_info_ptr = nilPtr}, (has_var, binds, ci))
where
- get_module_id ci=:{ci_module_id_var=Yes {lb_dst}}
- = (Var (freeVarToVar lb_dst),ci)
+ constructorExp :: Index ((Global Index) -> SymbKind) Int !*ConversionState
+ -> (Expression, !*ConversionState)
+ constructorExp index symb_kind arity ci
+ # (cons_symb, ci)
+ = getSymbol index symb_kind arity ci
+ = (App {app_symb = cons_symb, app_args = [], app_info_ptr = nilPtr}, ci)
- get_constructor :: !{!GlobalTCType} Index !*ConversionState -> (Expression,!*ConversionState)
- get_constructor glob_type_inst index ci=:{ci_type_constructor_used_in_dynamic_patterns}
- # cons_string
- = BasicExpr (BVS ("\"" +++ toString glob_type_inst.[index] +++ "\""))
- = (cons_string, ci)
-
- convertTypeCodes _ [] binds ci
- # (nil_symb, ci) = getSymbol PD_NilSymbol SK_Constructor 0 ci
- = (App { app_symb = nil_symb,
- app_args = [],
- app_info_ptr = nilPtr},binds, ci)
+ typeConstructor (GTT_PredefTypeConstructor {glob_object=type_index}) ci
+ | PD_Arity2TupleTypeIndex <= type_index && type_index <= PD_Arity32TupleTypeIndex
+ # arity
+ = type_index - PD_Arity2TupleTypeIndex + 2
+ # (tuple_symb, ci)
+ = getSymbol PD_Dyn_TypeCodeConstructor_Tuple SK_Function 1 ci
+ = (App {app_symb = tuple_symb, app_args = [BasicExpr (BVInt arity)], app_info_ptr = nilPtr}, ci)
+ // otherwise
+ # predef_type_index
+ = type_index + FirstTypePredefinedSymbolIndex
+ = constructorExp (predefinedTypeConstructor predef_type_index) SK_Function 0 ci
+ typeConstructor (GTT_Constructor cons_symb _) ci
+ = (App {app_symb = cons_symb, app_args = [], app_info_ptr = nilPtr}, ci)
+ typeConstructor (GTT_Basic basic_type) ci
+ = constructorExp (basicTypeConstructor basic_type) SK_Function 0 ci
+ typeConstructor GTT_Function ci
+ = constructorExp PD_Dyn_TypeCodeConstructor_Arrow SK_Function 0 ci
+
+ basicTypeConstructor BT_Int
+ = PD_Dyn_TypeCodeConstructorInt
+ basicTypeConstructor BT_Char
+ = PD_Dyn_TypeCodeConstructorChar
+ basicTypeConstructor BT_Real
+ = PD_Dyn_TypeCodeConstructorReal
+ basicTypeConstructor BT_Bool
+ = PD_Dyn_TypeCodeConstructorBool
+ basicTypeConstructor BT_Dynamic
+ = PD_Dyn_TypeCodeConstructorDynamic
+ basicTypeConstructor BT_File
+ = PD_Dyn_TypeCodeConstructorFile
+ basicTypeConstructor BT_World
+ = PD_Dyn_TypeCodeConstructorWorld
- convertTypeCodes cinp [typecode_expr : typecode_exprs] binds ci
- # (cons_symb, ci)
- = getSymbol PD_ConsSymbol SK_Constructor 2 ci
- # (expr, binds, ci)
- = convertTypeCode cinp typecode_expr binds ci
- # (exprs, binds, ci)
- = convertTypeCodes cinp typecode_exprs binds ci
- = (App { app_symb = cons_symb,
- app_args = [expr , exprs],
- app_info_ptr = nilPtr}, binds, ci)
-convertTypeCode cinp (TCE_UniType uni_vars type_code) binds ci
- # (type_scheme_sym, ci)
- = getSymbol PD_Dyn_TypeScheme SK_Constructor 2 ci
+ predefinedTypeConstructor predef_type_index
+ | predef_type_index == PD_ListType
+ = PD_Dyn_TypeCodeConstructor_List
+ | predef_type_index == PD_StrictListType
+ = PD_Dyn_TypeCodeConstructor_StrictList
+ | predef_type_index == PD_UnboxedListType
+ = PD_Dyn_TypeCodeConstructor_UnboxedList
+ | predef_type_index == PD_TailStrictListType
+ = PD_Dyn_TypeCodeConstructor_TailStrictList
+ | predef_type_index == PD_StrictTailStrictListType
+ = PD_Dyn_TypeCodeConstructor_StrictTailStrictList
+ | predef_type_index == PD_UnboxedTailStrictListType
+ = PD_Dyn_TypeCodeConstructor_UnboxedTailStrictList
+ | predef_type_index == PD_LazyArrayType
+ = PD_Dyn_TypeCodeConstructor_LazyArray
+ | predef_type_index == PD_StrictArrayType
+ = PD_Dyn_TypeCodeConstructor_StrictArray
+ | predef_type_index == PD_UnboxedArrayType
+ = PD_Dyn_TypeCodeConstructor_UnboxedArray
+ // otherwise
+ = fatal "predefinedType" "TC code from predef"
+convertTypeCode pattern cinp (TCE_Constructor index args) st
+ # curried_type
+ = foldl TCE_App (TCE_Constructor index []) args
+ = convertTypeCode pattern cinp curried_type st
+convertTypeCode pattern cinp (TCE_UniType uni_vars type_code) (has_var, binds, ci)
# (tv_symb, ci)
= getSymbol PD_Dyn_TypeVar SK_Constructor 1 ci
- // assign unique numbers for all type variables in the module (for testing)
- # init_count = ci.ci_type_pattern_var_count
+ # init_count
+ = if pattern ci.ci_type_var_count 0
# (count, ci_var_heap)
- = foldSt (mark_uni_var (build_tv tv_symb)) uni_vars (init_count, ci.ci_var_heap)
+ = foldSt (mark_uni_var pattern (build_tv tv_symb)) uni_vars (init_count, ci.ci_var_heap)
# ci
- = {ci & ci_type_pattern_var_count = count, ci_var_heap = ci_var_heap}
-// (type_code_expr, binds, ci)
- = convertTypeCode cinp type_code binds ci
-/* = (App { app_symb = type_scheme_sym,
- app_args = [BasicExpr (BVInt (count - init_count)), type_code_expr],
- app_info_ptr = nilPtr }, binds, ci)
-*/ where
- mark_uni_var :: (Int -> Expression) VarInfoPtr (Int, *VarHeap) -> (Int, *VarHeap)
- mark_uni_var build_var_code var_info_ptr (count, var_heap)
+ = {ci & ci_type_var_count = if pattern count ci.ci_type_var_count, ci_var_heap = ci_var_heap}
+ # (type_code, (has_var, binds, ci))
+ = convertTypeCode pattern cinp type_code (has_var, binds, ci)
+ | count > 0
+ # (type_scheme_sym, ci)
+ = getSymbol PD_Dyn_TypeScheme SK_Constructor 2 ci
+ = (App { app_symb = type_scheme_sym,
+ app_args = [BasicExpr (BVInt count), type_code],
+ app_info_ptr = nilPtr }, (has_var, binds, ci))
+ // otherwise
+ = (type_code, (has_var, binds, ci))
+
+ where
+ mark_uni_var :: Bool (Int -> Expression) VarInfoPtr (Int, *VarHeap) -> (Int, *VarHeap)
+ mark_uni_var pattern build_var_code var_info_ptr (count, var_heap)
# var_info
= VI_TypeCodeVariable (TCI_TypeVar (build_var_code count))
- = (count+1, writePtr var_info_ptr var_info var_heap)
+ = (count + (if pattern -1 1), writePtr var_info_ptr var_info var_heap)
build_tv :: SymbIdent Int -> Expression
build_tv tv_symb number
@@ -747,10 +730,10 @@ convertTypeCode cinp (TCE_UniType uni_vars type_code) binds ci
app_args = [BasicExpr (BVInt number)],
app_info_ptr = nilPtr }
-convertTypeCode cinp (TCE_Selector selections var_info_ptr) binds ci
- # (var, binds, ci)
- = convertTypeCode cinp (TCE_Var var_info_ptr) binds ci
- = (Selection NormalSelector var selections, binds, ci)
+convertTypeCode pattern cinp (TCE_Selector selections var_info_ptr) st
+ # (var, st)
+ = convertTypeCode pattern cinp (TCE_Var var_info_ptr) st
+ = (Selection NormalSelector var selections, st)
createTypePatternVariable :: !*ConversionState -> (!Expression, !*ConversionState)
createTypePatternVariable ci
@@ -807,7 +790,7 @@ bool_case_ptr result_type ci=:{ci_expr_heap}
dummy_case_ptr :: !AType !*ConversionState -> (ExprInfoPtr, !*ConversionState)
dummy_case_ptr result_type ci=:{ci_expr_heap}
- # (expr_info_ptr, ci_expr_heap) = newPtr (EI_CaseType { ct_pattern_type = toAType (TB BT_Bool),
+ # (expr_info_ptr, ci_expr_heap) = newPtr (EI_CaseType { ct_pattern_type = toAType TE,
ct_result_type = result_type, //empty_attributed_type,
ct_cons_types = [[empty_attributed_type, empty_attributed_type]]}) ci_expr_heap
= (expr_info_ptr, {ci & ci_expr_heap = ci_expr_heap})
@@ -861,23 +844,4 @@ create_dynamic_and_selector_idents common_defs predefined_symbols
, dr_dynamic_symbol = dynamic_defined_symbol
}, predefined_symbols)
-get_module_id_app :: !*PredefinedSymbols -> (App,Expression,!*PredefinedSymbols)
-get_module_id_app predef_symbols
- // get module id symbol
- # ({pds_module, pds_def}, predef_symbols) = predef_symbols![PD_ModuleConsSymbol]
- # pds_ident = predefined_idents.[PD_ModuleConsSymbol]
- # module_symb =
- { app_symb = { symb_name = pds_ident, symb_kind = SK_Constructor { glob_module = pds_module, glob_object = pds_def} }
- , app_args = []
- , app_info_ptr = nilPtr
- }
-
- # ({pds_module, pds_def}, predef_symbols) = predef_symbols![PD_Dyn_ModuleID]
- # pds_ident = predefined_idents.[PD_Dyn_ModuleID]
- # module_id_symb =
- { app_symb = { symb_name = pds_ident, symb_kind = SK_Constructor { glob_module = pds_module, glob_object = pds_def} }
- , app_args = [App module_symb]
- , app_info_ptr = nilPtr
- }
-
- = (module_symb,App module_id_symb,predef_symbols)
+ \ No newline at end of file
diff --git a/frontend/overloading.icl b/frontend/overloading.icl
index d2b7d24..291b864 100644
--- a/frontend/overloading.icl
+++ b/frontend/overloading.icl
@@ -87,12 +87,11 @@ where
where
compare_types (GTT_Basic bt1) (GTT_Basic bt2)
= bt1 =< bt2
- compare_types (GTT_Constructor cons1 _ _) (GTT_Constructor cons2 _ _)
+ compare_types (GTT_Constructor cons1 _) (GTT_Constructor cons2 _)
= cons1 =< cons2
compare_types _ _
= Equal
-
instanceError symbol types err
# err = errorHeading "Overloading error" err
format = { form_properties = cNoProperties, form_attr_position = No }
@@ -120,6 +119,12 @@ overloadingError op_symb err
-> str+++" [line "+++toString line_nr+++"]"
= { err & ea_file = err.ea_file <<< " internal overloading of \"" <<< str <<< "\" could not be solved\n" }
+typeCodeInDynamicError err=:{ea_ok}
+ # err = errorHeading "Overloading error (warning for now)" err
+ err = {err & ea_ok=ea_ok}
+ = { err & ea_file = err.ea_file <<< "TC context not allowed in dynamic" <<< '\n' }
+
+
/*
As soon as all overloaded variables in an type context are instantiated, context reduction is carried out.
This reduction yields a type class instance (here represented by a an index) and a list of
@@ -532,19 +537,17 @@ where
reduce_TC_context type_code_class tc_type new_contexts special_instances type_pattern_vars var_heap
= reduce_tc_context type_code_class tc_type (new_contexts, special_instances, type_pattern_vars, var_heap)
where
- reduce_tc_context type_code_class (TA cons_id=:{type_index={glob_module}} cons_args) (new_contexts, special_instances=:{si_next_TC_member_index, si_TC_instances}, type_pattern_vars, var_heap)
- # defining_module_name
- = dcl_modules.[glob_module].dcl_name.id_name
+ reduce_tc_context type_code_class (TA cons_id=:{type_index} cons_args) (new_contexts, special_instances=:{si_next_TC_member_index, si_TC_instances}, type_pattern_vars, var_heap)
+ # type_constructor = toTypeCodeConstructor type_index defs
# (inst_index, (si_next_TC_member_index, si_TC_instances))
- = addGlobalTCInstance (GTT_Constructor cons_id defining_module_name False) (si_next_TC_member_index, si_TC_instances)
+ = addGlobalTCInstance type_constructor (si_next_TC_member_index, si_TC_instances)
(rc_red_contexts, instances) = reduce_TC_contexts type_code_class cons_args
(new_contexts, { special_instances & si_next_TC_member_index = si_next_TC_member_index, si_TC_instances = si_TC_instances }, type_pattern_vars, var_heap)
= (CA_GlobalTypeCode { tci_index = inst_index, tci_contexts = rc_red_contexts }, instances)
- reduce_tc_context type_code_class (TAS cons_id=:{type_index={glob_module}} cons_args _) (new_contexts, special_instances=:{si_next_TC_member_index, si_TC_instances}, type_pattern_vars, var_heap)
- # defining_module_name
- = dcl_modules.[glob_module].dcl_name.id_name
+ reduce_tc_context type_code_class (TAS cons_id=:{type_index} cons_args _) (new_contexts, special_instances=:{si_next_TC_member_index, si_TC_instances}, type_pattern_vars, var_heap)
+ # type_constructor = toTypeCodeConstructor type_index defs
# (inst_index, (si_next_TC_member_index, si_TC_instances))
- = addGlobalTCInstance (GTT_Constructor cons_id defining_module_name False) (si_next_TC_member_index, si_TC_instances)
+ = addGlobalTCInstance type_constructor (si_next_TC_member_index, si_TC_instances)
(rc_red_contexts, instances) = reduce_TC_contexts type_code_class cons_args
(new_contexts, { special_instances & si_next_TC_member_index = si_next_TC_member_index, si_TC_instances = si_TC_instances }, type_pattern_vars, var_heap)
= (CA_GlobalTypeCode { tci_index = inst_index, tci_contexts = rc_red_contexts }, instances)
@@ -1294,13 +1297,39 @@ getTCDictionary symb_name var_info_ptr (var_heap, error)
, tci_type_constructors_in_patterns :: ![Index]
}
+
+toTypeCodeConstructor type=:{glob_object=type_index, glob_module=module_index} common_defs
+ | module_index == cPredefinedModuleIndex
+ = GTT_PredefTypeConstructor type
+ // otherwise
+ # tc_type_index
+ = type_index + 1
+ # types
+ = common_defs.[module_index].com_type_defs
+ // sanity check ...
+ # type_name
+ = types.[type_index].td_name.id_name
+ # tc_type_name
+ = types.[tc_type_index].td_name.id_name
+ | "TC;" +++ type_name <> tc_type_name
+ = fatal "toTypeCodeConstructor" ("name mismatch (" +++ type_name +++ ", " +++ tc_type_name +++ ")")
+ // ... sanity check
+ # ({td_rhs=AlgType [{ds_ident, ds_index}:_]})
+ = types.[tc_type_index]
+ # type_constructor
+ = { symb_name = ds_ident
+ , symb_kind = SK_Constructor {glob_module = module_index, glob_object = ds_index}
+ }
+ = GTT_Constructor type_constructor False
+
+fatal :: {#Char} {#Char} -> .a
+fatal function_name message
+ = abort ("overloading, " +++ function_name +++ ": " +++ message)
+
class toTypeCodeExpression type :: !Ident type !(!*TypeCodeInfo,!*VarHeap,!*ErrorAdmin) -> (!TypeCodeExpression, !(!*TypeCodeInfo,!*VarHeap,!*ErrorAdmin))
-instance toTypeCodeExpression Type
-where
- toTypeCodeExpression symb_name type=:(TA cons_id=:{type_index={glob_module}} type_args) (tci=:{tci_next_index,tci_instances,tci_dcl_modules,tci_common_defs},var_heap,error)
- # defining_module_name
- = tci_dcl_modules.[glob_module].dcl_name.id_name
+instance toTypeCodeExpression Type where
+ toTypeCodeExpression symb_name type=:(TA cons_id=:{type_index} type_args) (tci=:{tci_next_index,tci_instances,tci_dcl_modules,tci_common_defs},var_heap,error)
// RWS ...
# type_heaps
= {th_vars = tci.tci_type_var_heap, th_attrs = tci.tci_attr_var_heap}
@@ -1311,9 +1340,12 @@ where
| expanded
= toTypeCodeExpression symb_name type (tci,var_heap,error)
// ... RWS
+ # type_constructor
+ = toTypeCodeConstructor type_index tci_common_defs
# (inst_index, (tci_next_index, tci_instances))
- = addGlobalTCInstance (GTT_Constructor cons_id defining_module_name False) (tci_next_index, tci_instances)
- (type_code_args, tci) = mapSt (toTypeCodeExpression symb_name) type_args ({ tci & tci_next_index = tci_next_index, tci_instances = tci_instances },var_heap,error)
+ = addGlobalTCInstance type_constructor (tci_next_index, tci_instances)
+ (type_code_args, tci)
+ = mapSt (toTypeCodeExpression symb_name) type_args ({ tci & tci_next_index = tci_next_index, tci_instances = tci_instances },var_heap,error)
= (TCE_Constructor inst_index type_code_args, tci)
toTypeCodeExpression symb_name (TAS cons_id type_args _) state
= toTypeCodeExpression symb_name (TA cons_id type_args) state
@@ -1326,18 +1358,30 @@ where
= addGlobalTCInstance GTT_Function (tci_next_index, tci_instances)
(type_code_args, tci) = mapSt (toTypeCodeExpression symb_name) [arg_type, result_type] ({ tci & tci_next_index = tci_next_index, tci_instances = tci_instances },var_heap,error)
= (TCE_Constructor inst_index type_code_args, tci)
- toTypeCodeExpression symb_name (TV {tv_name,tv_info_ptr}) (tci=:{tci_type_var_heap}, var_heap, error)
+ toTypeCodeExpression symb_name (TV var) st
+ = toTypeCodeExpression symb_name var st
+ toTypeCodeExpression symb_name (TFA vars type) (tci=:{tci_type_var_heap}, var_heap, error)
+ # (new_vars, (tci_type_var_heap, var_heap)) = newTypeVariables vars (tci_type_var_heap, var_heap)
+ (type_code, tci) = toTypeCodeExpression symb_name type ({tci & tci_type_var_heap = tci_type_var_heap}, var_heap, error)
+ = (TCE_UniType new_vars type_code, tci)
+ toTypeCodeExpression symb_name (CV var :@: args) st
+ # (type_code_var, st)
+ = toTypeCodeExpression symb_name var st
+ (type_code_args, st)
+ = mapSt (toTypeCodeExpression symb_name) args st
+ = (foldl TCE_App type_code_var type_code_args, st)
+
+
+instance toTypeCodeExpression TypeVar where
+ toTypeCodeExpression symb_name {tv_name,tv_info_ptr} (tci=:{tci_type_var_heap}, var_heap, error)
# (type_info, tci_type_var_heap) = readPtr tv_info_ptr tci_type_var_heap
tci = { tci & tci_type_var_heap = tci_type_var_heap }
= case type_info of
TVI_TypeCode type_code
-> (type_code, (tci,var_heap,error))
_
- -> abort ("toTypeCodeExpression (TV)" ---> ((ptrToInt tv_info_ptr, tv_name)))
- toTypeCodeExpression symb_name (TFA vars type) (tci=:{tci_type_var_heap}, var_heap, error)
- # (new_vars, (tci_type_var_heap, var_heap)) = newTypeVariables vars (tci_type_var_heap, var_heap)
- (type_code, tci) = toTypeCodeExpression symb_name type ({tci & tci_type_var_heap = tci_type_var_heap}, var_heap, error)
- = (TCE_UniType new_vars type_code, tci)
+ -> abort ("toTypeCodeExpression (TypeVar)" ---> ((ptrToInt tv_info_ptr, tv_name)))
+
instance toTypeCodeExpression AType
where
toTypeCodeExpression symb_ident {at_type} tci_and_var_heap_and_error = toTypeCodeExpression symb_ident at_type tci_and_var_heap_and_error
@@ -1501,8 +1545,17 @@ where
# (expression, ui) = updateExpression group_index expression ui
(expressions, ui) = updateExpression group_index expressions ui
= (RecordUpdate cons_symbol expression expressions, ui)
- updateExpression group_index (DynamicExpr dyn=:{dyn_expr,dyn_info_ptr}) ui
- # (dyn_expr, ui) = updateExpression group_index dyn_expr ui
+ updateExpression group_index (DynamicExpr dyn=:{dyn_expr,dyn_info_ptr}) ui=:{ui_has_type_codes}
+ # (dyn_expr, ui) = updateExpression group_index dyn_expr {ui & ui_has_type_codes = False}
+ # ui = check_type_codes_in_dynamic ui
+ with
+ check_type_codes_in_dynamic ui=:{ui_has_type_codes, ui_error}
+ | ui_has_type_codes
+ # ui_error = typeCodeInDynamicError ui_error
+ = {ui & ui_error = ui_error}
+ // otherwise
+ = ui
+ # ui = {ui & ui_has_type_codes=ui_has_type_codes}
(EI_TypeOfDynamic uni_vars type_code, ui_symbol_heap) = readPtr dyn_info_ptr ui.ui_symbol_heap
ui = { ui & ui_symbol_heap = ui_symbol_heap }
= (DynamicExpr { dyn & dyn_expr = dyn_expr, dyn_type_code = type_code }, ui)
@@ -1615,25 +1668,31 @@ where
adjustClassExpression symb_name (Selection opt_type expr selectors) ui
# (expr, ui) = adjustClassExpression symb_name expr ui
= (Selection opt_type expr selectors, ui)
- adjustClassExpression symb_name tce=:(TypeCodeExpression type_code_expression) ui
- # ui = check_type_code type_code_expression ui
- = (tce, {ui & ui_has_type_codes = True})
+ adjustClassExpression symb_name tce=:(TypeCodeExpression type_code) ui
+ # (type_code, ui) = adjust_type_code type_code ui
+ = (TypeCodeExpression type_code, {ui & ui_has_type_codes = True})
where
- check_type_code (TCE_TypeTerm var_info_ptr) ui=:{ui_var_heap,ui_error}
- # (_, (ui_var_heap,ui_error))
+ adjust_type_code (TCE_TypeTerm var_info_ptr) ui=:{ui_var_heap,ui_error}
+ # (var_info_ptr, (ui_var_heap,ui_error))
= getTCDictionary symb_name var_info_ptr (ui_var_heap, ui_error)
- = { ui & ui_var_heap = ui_var_heap, ui_error = ui_error}
- check_type_code (TCE_Constructor index typecode_exprs)
+ # ui
+ = { ui & ui_var_heap = ui_var_heap, ui_error = ui_error}
+ = (TCE_TypeTerm var_info_ptr, ui)
+ adjust_type_code (TCE_Constructor index typecode_exprs)
ui=:{ui_x={x_type_code_info={tci_type_constructors_in_patterns} }}
# ui
= { ui & ui_x.x_type_code_info.tci_type_constructors_in_patterns =
[index:tci_type_constructors_in_patterns] }
- = foldSt check_type_code typecode_exprs ui
- check_type_code (TCE_UniType uni_vars type_code) ui
- = check_type_code type_code ui
- check_type_code _ ui
- = ui
-
+ # (typecode_exprs, ui)
+ = mapSt adjust_type_code typecode_exprs ui
+ = (TCE_Constructor index typecode_exprs, ui)
+ adjust_type_code (TCE_UniType uni_vars type_code) ui
+ # (type_code, ui)
+ = adjust_type_code type_code ui
+ = (TCE_UniType uni_vars type_code, ui)
+ adjust_type_code type_code ui
+ = (type_code, ui)
+
adjustClassExpression symb_name (Let this_let=:{let_strict_binds, let_lazy_binds, let_expr }) ui
# (let_strict_binds, ui) = adjust_let_binds symb_name let_strict_binds ui
(let_lazy_binds, ui) = adjust_let_binds symb_name let_lazy_binds ui
diff --git a/frontend/parse.icl b/frontend/parse.icl
index db56d07..6a5c65c 100644
--- a/frontend/parse.icl
+++ b/frontend/parse.icl
@@ -306,9 +306,6 @@ where
(mod_ident, pState) = stringToIdent mod_name IC_Module pState
pState = check_layout_rule pState
(defs, pState) = want_definitions (SetGlobalContext iclmodule) pState
-// MV ...
- # (defs, pState) = add_module_id mod_name defs pState;
-// ... MV
{ps_scanState,ps_hash_table,ps_error}
= pState
defs = if (ParseOnly && id_name <> "StdOverloaded" && id_name <> "StdArray" && id_name <> "StdEnum" && id_name <> "StdBool" && id_name <> "StdDynamics" && id_name <> "StdGeneric")
@@ -325,37 +322,6 @@ where
mod = { mod_name = file_id, mod_modification_time = modification_time, mod_type = mod_type, mod_imports = [], mod_imported_objects = [], mod_defs = [] }
= (False, mod, hash_table, error <<< "Error [" <<< file_name <<< ',' <<< fp_line <<< "]: incorrect module header",
closeScanner scanState files)
- where
-// MV...
- add_module_id mod_name defs pState
- | not iclmodule
- = (defs,pState);
-
- // It is essential that the type name denoted by ident is an unique type name within the application. Otherwise
- // the static linker will choose one implementation (because the type names are equal) and map the other to the
- // chosen implementation.
- // The zero arity of the _Module constructor makes the code generator, pre-allocate _Module in .data section of
- // the final executable. The module name needed by the dynamic run-time system can then be determined by looking
- // at the descriptor. If however all implementations were mapped to a single one, the dynamic rts could not use
- // the module name anymore because they are all the same.
- # (ident, pState) = stringToIdent ("_" +++ mod_name +++ "_Module") IC_Type pState
- # td = MakeTypeDef ident [] (ConsList []) TA_None [] NoPos
-
- # (pc_cons_name, pState) = stringToIdent "__Module" IC_Expression pState
- # cons
- = {
- pc_cons_name = pc_cons_name
- , pc_arg_types = []
- , pc_args_strictness = NotStrict
- , pc_cons_arity = 0
- , pc_cons_prio = NoPrio
- , pc_exi_vars = []
- , pc_cons_pos = NoPos
- }
- # td
- = { td & td_rhs = ConsList [cons] }
- = ([PD_Type td:defs],pState)
-// ...MV
try_module_header :: !Bool !ScanState -> (!Bool,!ModuleKind,!String,!ScanState)
try_module_header is_icl_mod scanState
diff --git a/frontend/postparse.icl b/frontend/postparse.icl
index 71d9392..8ecb45f 100644
--- a/frontend/postparse.icl
+++ b/frontend/postparse.icl
@@ -1058,7 +1058,7 @@ where
scan_dcl_module :: ParsedModule [ScannedModule] !SearchPaths (ModTimeFunction *Files) *Files *CollectAdmin -> (Bool, [ScannedModule],*Files, *CollectAdmin)
scan_dcl_module mod=:{mod_defs = pdefs} parsed_modules searchPaths modtimefunction files ca
# (_, defs, imports, imported_objects, ca)
- = reorganiseDefinitions False pdefs 0 0 0 0 ca
+ = reorganiseDefinitionsAndAddTypes False pdefs 0 0 0 0 ca
(def_macros, ca) = collectFunctions defs.def_macros False {ca & ca_fun_count=0,ca_rev_fun_defs=[]}
(range, ca) = addFunctionsRange def_macros ca
(rev_fun_defs,ca) = ca!ca_rev_fun_defs
@@ -1079,7 +1079,7 @@ scanModule mod=:{mod_name,mod_type,mod_defs = pdefs} cached_modules support_gene
, ca_rev_fun_defs = []
, ca_hash_table = hash_table
}
- (fun_defs, defs, imports, imported_objects, ca) = reorganiseDefinitions True pdefs 0 0 0 0 ca
+ (fun_defs, defs, imports, imported_objects, ca) = reorganiseDefinitionsAndAddTypes True pdefs 0 0 0 0 ca
(reorganise_icl_ok, ca) = ca!ca_error.pea_ok
@@ -1146,7 +1146,7 @@ where
| not parse_ok
= (False, No,NoIndex, [],cached_modules, files, ca)
# pdefs = mod.mod_defs
- # (_, defs, imports, imported_objects, ca) = reorganiseDefinitions False pdefs 0 0 0 0 ca
+ # (_, defs, imports, imported_objects, ca) = reorganiseDefinitionsAndAddTypes False pdefs 0 0 0 0 ca
# mod = { mod & mod_imports = imports, mod_imported_objects = imported_objects, mod_defs = defs}
# cached_modules = [mod.mod_name:cached_modules]
# (import_ok, parsed_modules,files, ca) = scanModules imports [] cached_modules searchPaths support_generics modtimefunction files ca
@@ -1452,6 +1452,54 @@ reorganiseDefinitions icl_module [] _ _ _ _ ca
def_instances = [], def_funtypes = [],
def_generics = [], def_generic_cases = []}, [], [], ca)
+reorganiseDefinitionsAndAddTypes icl_module defs cons_count sel_count mem_count type_count ca
+ # (rev_defs, ca)
+ = addTypeConstructors defs [] ca
+ = reorganiseDefinitions icl_module (reverse rev_defs) cons_count sel_count mem_count type_count ca
+ where
+ addTypeConstructors [] rev_defs ca
+ = (rev_defs, ca)
+ addTypeConstructors [PD_Type type_def : defs] rev_defs ca
+ # (type_def, tc_def, ca)
+ = addTypeConstructor type_def ca
+ = addTypeConstructors defs [PD_Type tc_def, PD_Type type_def : rev_defs] ca
+ addTypeConstructors [def : defs] rev_defs ca
+ = addTypeConstructors defs [def : rev_defs] ca
+
+addTypeConstructor def=:{td_name, td_attribute, td_attrs, td_args, td_arity, td_pos} ca=:{ca_hash_table}
+ # tc_name = "TC;" +++ td_name.id_name
+ # ({boxed_ident=tc_cons_ident}, ca_hash_table) = putIdentInHashTable tc_name IC_Expression ca_hash_table
+ # ({boxed_ident=tc_type_ident}, ca_hash_table) = putIdentInHashTable tc_name IC_Type ca_hash_table
+ = (def, type_tc_def tc_type_ident tc_cons_ident td_name td_attribute td_attrs td_args
+ td_arity td_pos, { ca & ca_hash_table = ca_hash_table })
+ where
+ type_tc_def type_ident cons_ident type_name attr attrs args arity position
+ = { td_name = type_ident
+ , td_index = NoIndex
+ , td_arity = arity
+ , td_args = args
+ , td_attrs = attrs
+ , td_context = []
+ , td_rhs = ConsList [type_tc_cons cons_ident type_name args arity position]
+ , td_attribute = attr
+ , td_pos = position
+ , td_used_types = []
+ }
+ type_tc_cons cons_ident type_name args arity position
+ = { pc_cons_name = cons_ident
+ , pc_cons_arity = 1
+ , pc_exi_vars = []
+ , pc_arg_types = [type type_name args arity]
+ , pc_args_strictness = NotStrict
+ , pc_cons_prio = NoPrio
+ , pc_cons_pos = position
+ }
+ type type_name args arity
+ = { at_attribute = TA_None
+ , at_type = TA (MakeNewTypeSymbIdent type_name arity)
+ [{at_attribute = TA_None, at_type = TV arg.atv_variable} \\ arg <- args]
+ }
+
belongsToTypeSpec name prio new_name is_infix :==
name == new_name && sameFixity prio is_infix
diff --git a/frontend/predef.dcl b/frontend/predef.dcl
index 70874f9..1be3af7 100644
--- a/frontend/predef.dcl
+++ b/frontend/predef.dcl
@@ -66,146 +66,161 @@ PD_Arity32TupleSymbol :== 87
PD_TypeVar_a0 :== 88
PD_TypeVar_a31 :== 119
-/* Dynamics */
-
-PD_TypeCodeMember :== 120
-PD_TypeCodeClass :== 121
-PD_Dyn_bind_global_type_pattern_var
- :== 122
-PD_Dyn_ModuleID :== 123
-
/* identifiers present in the hashtable */
-PD_StdArray :== 124
-PD_StdEnum :== 125
-PD_StdBool :== 126
+PD_StdArray :== 120
+PD_StdEnum :== 121
+PD_StdBool :== 122
-PD_AndOp :== 127
-PD_OrOp :== 128
+PD_AndOp :== 123
+PD_OrOp :== 124
/* Array functions */
-PD_ArrayClass :== 129
+PD_ArrayClass :== 125
-PD_CreateArrayFun :== 130
-PD__CreateArrayFun :== 131
-PD_ArraySelectFun :== 132
-PD_UnqArraySelectFun :== 133
-PD_ArrayUpdateFun :== 134
-PD_ArrayReplaceFun :== 135
-PD_ArraySizeFun :== 136
-PD_UnqArraySizeFun :== 137
+PD_CreateArrayFun :== 126
+PD__CreateArrayFun :== 127
+PD_ArraySelectFun :== 128
+PD_UnqArraySelectFun :== 129
+PD_ArrayUpdateFun :== 130
+PD_ArrayReplaceFun :== 131
+PD_ArraySizeFun :== 132
+PD_UnqArraySizeFun :== 133
/* Enum/Comprehension functions */
-PD_SmallerFun :== 138
-PD_LessOrEqualFun :== 139
-PD_IncFun :== 140
-PD_SubFun:== 141
-PD_From :== 142
-PD_FromThen :== 143
-PD_FromTo :== 144
-PD_FromThenTo :== 145
+PD_SmallerFun :== 134
+PD_LessOrEqualFun :== 135
+PD_IncFun :== 136
+PD_SubFun :== 137
+PD_From :== 138
+PD_FromThen :== 139
+PD_FromTo :== 140
+PD_FromThenTo :== 141
/* StdMisc */
-PD_StdMisc :== 146
-PD_abort :== 147
-PD_undef :== 148
+PD_StdMisc :== 142
+PD_abort :== 143
+PD_undef :== 144
-PD_Start :== 149
+PD_Start :== 145
-PD_DummyForStrictAliasFun :== 150
+PD_DummyForStrictAliasFun :== 146
-PD_StdStrictLists:==151
+PD_StdStrictLists:==147
-PD_cons:==152
-PD_decons:==153
+PD_cons:==148
+PD_decons:==149
-PD_cons_u:==154
-PD_decons_u:==155
+PD_cons_u:==150
+PD_decons_u:==151
-PD_cons_uts:==156
-PD_decons_uts:==157
+PD_cons_uts:==152
+PD_decons_uts:==153
-PD_nil:==158
-PD_nil_u:==159
-PD_nil_uts:==160
+PD_nil:==154
+PD_nil_u:==155
+PD_nil_uts:==156
-PD_ListClass :== 161
-PD_UListClass :== 162
-PD_UTSListClass :== 163
+PD_ListClass :== 157
+PD_UListClass :== 158
+PD_UTSListClass :== 159
/* Dynamics */
-PD_StdDynamic :== 164
-
-PD_Dyn_DynamicTemp :== 165
-PD_Dyn_Type :== 166
-PD_Dyn_TypeScheme :== 167
-PD_Dyn_TypeApp :== 168
-PD_Dyn_TypeVar :== 169
-PD_Dyn_TypePatternVar :== 170
-PD_Dyn_TypeCons :== 171
-PD_Dyn_tc_name :== 172
-PD_Dyn_Unifier :== 173
-PD_Dyn_unify :== 174
-PD_Dyn_initial_unifier :== 175
-PD_Dyn_normalise :== 176
+// TC class
+PD_TypeCodeMember :== 160
+PD_TypeCodeClass :== 161
+// dynamic module
+PD_StdDynamic :== 162
+// dynamic type
+PD_Dyn_DynamicTemp :== 163
+// type code
+PD_Dyn_Type :== 164
+PD_Dyn_TypeScheme :== 165
+PD_Dyn_TypeApp :== 166
+PD_Dyn_TypeVar :== 167
+PD_Dyn_TypePatternVar :== 168
+PD_Dyn_TypeCons :== 169
+// unification
+PD_Dyn_UnificationEnvironment :== 170
+PD_Dyn_initial_unification_environment :== 171
+PD_Dyn_bind_global_type_pattern_var :== 172
+PD_Dyn_unify :== 173
+PD_Dyn_normalise :== 174
+// predefined type code constructor
+PD_Dyn_TypeCodeConstructorInt :== 175
+PD_Dyn_TypeCodeConstructorChar :== 176
+PD_Dyn_TypeCodeConstructorReal :== 177
+PD_Dyn_TypeCodeConstructorBool :== 178
+PD_Dyn_TypeCodeConstructorDynamic :== 179
+PD_Dyn_TypeCodeConstructorFile :== 180
+PD_Dyn_TypeCodeConstructorWorld :== 181
+PD_Dyn_TypeCodeConstructor_Arrow :== 182
+PD_Dyn_TypeCodeConstructor_List :== 183
+PD_Dyn_TypeCodeConstructor_StrictList :== 184
+PD_Dyn_TypeCodeConstructor_UnboxedList :== 185
+PD_Dyn_TypeCodeConstructor_TailStrictList :== 186
+PD_Dyn_TypeCodeConstructor_StrictTailStrictList :== 187
+PD_Dyn_TypeCodeConstructor_UnboxedTailStrictList :== 188
+PD_Dyn_TypeCodeConstructor_Tuple :== 189
+PD_Dyn_TypeCodeConstructor_LazyArray :== 190
+PD_Dyn_TypeCodeConstructor_StrictArray :== 191
+PD_Dyn_TypeCodeConstructor_UnboxedArray :== 192
/* Generics */
-PD_StdGeneric :== 177
-
-PD_TypeBimap :== 178
-PD_ConsBimap :== 179
-PD_map_to :== 180
-PD_map_from :== 181
-
-PD_TypeUNIT :== 182
-PD_ConsUNIT :== 183
-PD_TypeEITHER :== 184
-PD_ConsLEFT :== 185
-PD_ConsRIGHT :== 186
-PD_TypePAIR :== 187
-PD_ConsPAIR :== 188
-
+PD_StdGeneric :== 193
+
+PD_TypeBimap :== 194
+PD_ConsBimap :== 195
+PD_map_to :== 196
+PD_map_from :== 197
+
+PD_TypeUNIT :== 198
+PD_ConsUNIT :== 199
+PD_TypeEITHER :== 200
+PD_ConsLEFT :== 201
+PD_ConsRIGHT :== 202
+PD_TypePAIR :== 203
+PD_ConsPAIR :== 204
// for constructor info
-PD_TypeCONS :== 189
-PD_ConsCONS :== 190
-PD_TypeFIELD :== 191
-PD_ConsFIELD :== 192
-PD_TypeREC :== 193
-PD_ConsREC :== 194
-PD_GenericInfo :== 195
-PD_NoGenericInfo :== 196
-PD_GenericConsInfo :== 197
-PD_GenericFieldInfo :== 198
-PD_TGenericConsDescriptor :== 199
-PD_CGenericConsDescriptor :== 200
-PD_TGenericFieldDescriptor :== 201
-PD_CGenericFieldDescriptor :== 202
-PD_TGenericTypeDefDescriptor :== 203
-PD_CGenericTypeDefDescriptor :== 204
-PD_TGenConsPrio :== 205
-PD_CGenConsNoPrio :== 206
-PD_CGenConsPrio :== 207
-PD_TGenConsAssoc :== 208
-PD_CGenConsAssocNone :== 209
-PD_CGenConsAssocLeft :== 210
-PD_CGenConsAssocRight :== 211
-PD_TGenType :== 212
-PD_CGenTypeCons :== 213
-PD_CGenTypeVar :== 214
-PD_CGenTypeArrow :== 215
-PD_CGenTypeApp :== 216
-
-
-PD_GenericBimap :== 217
-PD_bimapId :== 218
-
-PD_TypeGenericDict :== 219
-
-PD_ModuleConsSymbol :== 220
-PD_NrOfPredefSymbols :== 221
+PD_TypeCONS :== 205
+PD_ConsCONS :== 206
+PD_TypeFIELD :== 207
+PD_ConsFIELD :== 208
+PD_TypeREC :== 209
+PD_ConsREC :== 210
+PD_GenericInfo :== 211
+PD_NoGenericInfo :== 212
+PD_GenericConsInfo :== 213
+PD_GenericFieldInfo :== 214
+PD_TGenericConsDescriptor :== 215
+PD_CGenericConsDescriptor :== 216
+PD_TGenericFieldDescriptor :== 217
+PD_CGenericFieldDescriptor :== 218
+PD_TGenericTypeDefDescriptor :== 219
+PD_CGenericTypeDefDescriptor :== 220
+PD_TGenConsPrio :== 221
+PD_CGenConsNoPrio :== 222
+PD_CGenConsPrio :== 223
+PD_TGenConsAssoc :== 224
+PD_CGenConsAssocNone :== 225
+PD_CGenConsAssocLeft :== 226
+PD_CGenConsAssocRight :== 227
+PD_TGenType :== 228
+PD_CGenTypeCons :== 229
+PD_CGenTypeVar :== 230
+PD_CGenTypeArrow :== 231
+PD_CGenTypeApp :== 232
+
+
+PD_GenericBimap :== 233
+PD_bimapId :== 234
+
+PD_TypeGenericDict :== 235
+
+PD_NrOfPredefSymbols :== 236
GetTupleConsIndex tup_arity :== PD_Arity2TupleSymbol + tup_arity - 2
GetTupleTypeIndex tup_arity :== PD_Arity2TupleType + tup_arity - 2
diff --git a/frontend/predef.icl b/frontend/predef.icl
index 51c3931..12bee1e 100644
--- a/frontend/predef.icl
+++ b/frontend/predef.icl
@@ -100,25 +100,36 @@ predefined_idents
[PD_StdDynamic] = i UnderscoreSystemDynamicModule_String,
[PD_Dyn_DynamicTemp] = i DynamicRepresentation_String,
- [PD_Dyn_Type] = i "_Type",
- [PD_Dyn_TypeScheme] = i "_TypeScheme",
- // FIXME: change constructor name T_ypeConsSymbol to T_ypeApp (also in dynamic linker)
- [PD_Dyn_TypeApp] = i "T_ypeConsSymbol",
- [PD_Dyn_TypeVar] = i "_TypeVar",
+ [PD_Dyn_Type] = i "TypeCode",
+ [PD_Dyn_TypeScheme] = i "TypeScheme",
+ [PD_Dyn_TypeApp] = i "TypeApp",
+ [PD_Dyn_TypeVar] = i "TypeVar",
+ [PD_Dyn_TypeCons] = i "TypeCons",
[PD_Dyn_TypePatternVar] = i "_TypePatternVar",
- [PD_Dyn_TypeCons] = i "_TypeCons",
- [PD_Dyn_tc_name] = i "_tc_name",
- [PD_Dyn_Unifier] = i "_Unifier",
- [PD_Dyn_unify] = i "_unify",
- [PD_Dyn_initial_unifier] = i "_initial_unifier",
+ [PD_Dyn_UnificationEnvironment] = i "_UnificationEnvironment",
+ [PD_Dyn_initial_unification_environment] = i "_initial_unification_environment",
[PD_Dyn_bind_global_type_pattern_var] = i "_bind_global_type_pattern_var",
- // FIXME: change constructor name ModuleID to _ModuleID (also in dynamic linker?)
- [PD_Dyn_ModuleID] = i "ModuleID",
-
+ [PD_Dyn_unify] = i "_unify",
[PD_Dyn_normalise] = i "_normalise",
- [PD_Dyn_tc_name] = i "_tc_name",
- [PD_Dyn_tc_name] = i "_tc_name",
- [PD_Dyn_tc_name] = i "_tc_name",
+
+ [PD_Dyn_TypeCodeConstructorInt] = i "TypeCodeConstructorInt",
+ [PD_Dyn_TypeCodeConstructorChar] = i "TypeCodeConstructorChar",
+ [PD_Dyn_TypeCodeConstructorReal] = i "TypeCodeConstructorReal",
+ [PD_Dyn_TypeCodeConstructorBool] = i "TypeCodeConstructorBool",
+ [PD_Dyn_TypeCodeConstructorDynamic] = i "TypeCodeConstructorDynamic",
+ [PD_Dyn_TypeCodeConstructorFile] = i "TypeCodeConstructorFile",
+ [PD_Dyn_TypeCodeConstructorWorld] = i "TypeCodeConstructorWorld",
+ [PD_Dyn_TypeCodeConstructor_Arrow] = i "TypeCodeConstructor_Arrow",
+ [PD_Dyn_TypeCodeConstructor_List] = i "TypeCodeConstructor_List",
+ [PD_Dyn_TypeCodeConstructor_StrictList] = i "TypeCodeConstructor_StrictList",
+ [PD_Dyn_TypeCodeConstructor_UnboxedList] = i "TypeCodeConstructor_UnboxedList",
+ [PD_Dyn_TypeCodeConstructor_TailStrictList] = i "TypeCodeConstructor_TailStrictList",
+ [PD_Dyn_TypeCodeConstructor_StrictTailStrictList] = i "TypeCodeConstructor_StrictTailStrictList",
+ [PD_Dyn_TypeCodeConstructor_UnboxedTailStrictList] = i "TypeCodeConstructor_UnboxedTailStrictList",
+ [PD_Dyn_TypeCodeConstructor_Tuple] = i "TypeCodeConstructor_Tuple",
+ [PD_Dyn_TypeCodeConstructor_LazyArray] = i "TypeCodeConstructor_LazyArray",
+ [PD_Dyn_TypeCodeConstructor_StrictArray] = i "TypeCodeConstructor_StrictArray",
+ [PD_Dyn_TypeCodeConstructor_UnboxedArray] = i "TypeCodeConstructor_UnboxedArray",
[PD_StdGeneric] = i "StdGeneric",
[PD_TypeBimap] = i "Bimap",
@@ -167,9 +178,6 @@ predefined_idents
[PD_TypeGenericDict] = i "GenericDict",
- [PD_ModuleConsSymbol] = i "__Module",
-
-
[PD_StdMisc] = i "StdMisc",
[PD_abort] = i "abort",
[PD_undef] = i "undef",
@@ -291,21 +299,37 @@ where
<<- (local_predefined_idents, IC_Class, PD_TypeCodeClass)
<<- (local_predefined_idents, IC_Module, PD_StdDynamic)
-
- <<- (local_predefined_idents, IC_Expression, PD_ModuleConsSymbol)
<<- (local_predefined_idents, IC_Type, PD_Dyn_DynamicTemp)
<<- (local_predefined_idents, IC_Type, PD_Dyn_Type)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeScheme)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeApp)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeVar)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_TypePatternVar)
- <<- (local_predefined_idents, IC_Type, PD_Dyn_TypeCons)
- <<- (local_predefined_idents, IC_Type, PD_Dyn_Unifier)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCons)
+ <<- (local_predefined_idents, IC_Type, PD_Dyn_UnificationEnvironment)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_unify)
- <<- (local_predefined_idents, IC_Expression, PD_Dyn_initial_unifier)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_initial_unification_environment)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_normalise)
<<- (local_predefined_idents, IC_Expression, PD_Dyn_bind_global_type_pattern_var)
- <<- (local_predefined_idents, IC_Expression, PD_Dyn_ModuleID)
+
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorInt)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorChar)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorReal)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorBool)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorDynamic)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorFile)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructorWorld)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_Arrow)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_List)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_StrictList)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_UnboxedList)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_TailStrictList)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_StrictTailStrictList)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_UnboxedTailStrictList)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_Tuple)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_LazyArray)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_StrictArray)
+ <<- (local_predefined_idents, IC_Expression, PD_Dyn_TypeCodeConstructor_UnboxedArray)
<<- (local_predefined_idents, IC_Module, PD_StdGeneric)
<<- (local_predefined_idents, IC_Type, PD_TypeBimap)
@@ -360,11 +384,6 @@ where
# hash_table = hash_table
<<- (local_predefined_idents, IC_Field bimap_type, PD_map_to)
<<- (local_predefined_idents, IC_Field bimap_type, PD_map_from)
-
- # dyn_type_cons_ident = local_predefined_idents.[PD_Dyn_TypeCons]
- # hash_table = hash_table
- <<- (local_predefined_idents, IC_Field dyn_type_cons_ident, PD_Dyn_tc_name)
-
= hash_table
MakeTupleConsSymbIndex arity :== arity - 2 + (PD_Arity2TupleSymbol-FirstConstructorPredefinedSymbolIndex)
@@ -496,6 +515,6 @@ where
= { ft_symb = alias_dummy_id, ft_arity = 1, ft_priority = NoPrio, ft_type = id_symbol_type, ft_pos = NoPos,
ft_specials = SP_None, ft_type_ptr = nilPtr }
-DynamicRepresentation_String :== "_DynamicTemp"
+DynamicRepresentation_String :== "DynamicTemp" // "_DynamicTemp"
diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl
index 99a579d..11b070c 100644
--- a/frontend/syntax.dcl
+++ b/frontend/syntax.dcl
@@ -1278,7 +1278,6 @@ cIsNotStrict :== False
{ dyn_expr :: !Expression
, dyn_opt_type :: !Optional DynamicType
, dyn_info_ptr :: !ExprInfoPtr
-// , dyn_uni_vars :: ![VarInfoPtr] /* filled after type checking */
, dyn_type_code :: !TypeCodeExpression /* filled after type checking */
}
@@ -1302,10 +1301,11 @@ instance == OverloadedListType
| TCE_Var !VarInfoPtr
| TCE_TypeTerm !VarInfoPtr
| TCE_Constructor !Index ![TypeCodeExpression]
+ | TCE_App !TypeCodeExpression !TypeCodeExpression
| TCE_Selector ![Selection] !VarInfoPtr
| TCE_UniType ![VarInfoPtr] !TypeCodeExpression
-:: GlobalTCType = GTT_Basic !BasicType | GTT_Constructor !TypeSymbIdent !String !Bool | GTT_Function
+:: GlobalTCType = GTT_Basic !BasicType | GTT_Constructor !SymbIdent !Bool | GTT_PredefTypeConstructor !(Global Index) | GTT_Function
:: FunctionPattern = FP_Basic !BasicValue !(Optional FreeVar)
diff --git a/frontend/type.icl b/frontend/type.icl
index a8a0e6c..4ded1b0 100644
--- a/frontend/type.icl
+++ b/frontend/type.icl
@@ -2631,8 +2631,8 @@ where
array_first_instance_indices = first_instance_indices si_array_instances
= (array_first_instance_indices,list_first_instance_indices,tail_strict_list_first_instance_indices,fun_defs,type_code_instances,predef_symbols,type_heaps,error)
where
- mark_used_type_constructors_in_applications_of_type_dependent_functions {gtci_index, gtci_type=GTT_Constructor type_symb_ident module_name False}
- = GTT_Constructor type_symb_ident module_name True
+ mark_used_type_constructors_in_applications_of_type_dependent_functions {gtci_index, gtci_type=GTT_Constructor cons False}
+ = GTT_Constructor cons True
mark_used_type_constructors_in_applications_of_type_dependent_functions {gtci_type}
= gtci_type
diff --git a/frontend/type_io_common.dcl b/frontend/type_io_common.dcl
index 8a285da..1e7dabd 100644
--- a/frontend/type_io_common.dcl
+++ b/frontend/type_io_common.dcl
@@ -77,7 +77,7 @@ LowLevelInterfaceModule :== "StdDynamicLowLevelInterface"
FunctionTypeConstructorAsString :== " -> "
-instance toString GlobalTCType
+// instance toString GlobalTCType
create_type_string type_name module_name
:== if (type_name == FunctionTypeConstructorAsString)
diff --git a/frontend/type_io_common.icl b/frontend/type_io_common.icl
index 2b406fe..3d8caf8 100644
--- a/frontend/type_io_common.icl
+++ b/frontend/type_io_common.icl
@@ -76,14 +76,14 @@ UnderscoreSystemModule :== "_system" // implements the predefined module
LowLevelInterfaceModule :== "StdDynamicLowLevelInterface"
FunctionTypeConstructorAsString :== " -> "
-
+/*
instance toString GlobalTCType
where
toString (GTT_Basic basic_type) = create_type_string (toString basic_type) PredefinedModuleName
toString GTT_Function = FunctionTypeConstructorAsString
- toString (GTT_Constructor type_symb_indent mod_name _) = create_type_string type_symb_indent.type_name.id_name mod_name
+ toString (GTT_Constructor _ type_symb_indent mod_name _) = create_type_string type_symb_indent.type_name.id_name mod_name
// +++ (APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES ("'" +++ mod_name) "")
-
+*/
create_type_string type_name module_name
:== if (type_name == FunctionTypeConstructorAsString)
type_name