aboutsummaryrefslogtreecommitdiff
path: root/frontend/type.icl
diff options
context:
space:
mode:
authorjohnvg2012-08-02 11:08:38 +0000
committerjohnvg2012-08-02 11:08:38 +0000
commit6fefdc2bdbf518c1c22f6a130bb803abe9f174d7 (patch)
tree2d495b0532246eab6870886d84f03907531f8bae /frontend/type.icl
parentoptimize is constructor functions (diff)
add pattern match test using =: in expressions,
add constructors PE_Matches and IsConstructor in module syntax git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@2130 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'frontend/type.icl')
-rw-r--r--frontend/type.icl13
1 files changed, 12 insertions, 1 deletions
diff --git a/frontend/type.icl b/frontend/type.icl
index d7462f1..eab10c7 100644
--- a/frontend/type.icl
+++ b/frontend/type.icl
@@ -1834,6 +1834,18 @@ where
= ({ at_type = TA tuple_type tst_args, at_attribute = TA_Unique }, No, (reqs, ts))
= ( hd tst_args, No, (reqs, ts))
+ requirements ti (IsConstructor expr {glob_object={ds_arity,ds_index,ds_ident},glob_module} _ _ _ _) (reqs,ts)
+ # cp = CP_Expression expr
+ ({tst_result,tst_args,tst_attr_env}, ts) = standardLhsConstructorType cp ds_index glob_module ti ts
+ (e_type, opt_expr_ptr, (reqs, ts)) = requirements ti expr (reqs,ts)
+ reqs = { reqs & req_attr_coercions = tst_attr_env ++ reqs.req_attr_coercions,
+ req_type_coercions = [{ tc_demanded = tst_result, tc_offered = e_type, tc_position = cp, tc_coercible = True } : reqs.req_type_coercions ] }
+ ts_attr_store = ts.ts_attr_store
+ bool_type = { at_attribute = TA_TempVar ts_attr_store, at_type = basicBoolType.box}
+ ts & ts_attr_store = inc ts_attr_store,
+ ts_expr_heap = storeAttribute opt_expr_ptr tst_result.at_attribute ts.ts_expr_heap
+ = (bool_type, No, (reqs, ts))
+
requirements _ (AnyCodeExpr _ _ _) (reqs, ts)
# (fresh_v, ts) = freshAttributedVariable ts
= (fresh_v, No, (reqs, ts))
@@ -2268,7 +2280,6 @@ typeProgram :: !{! Group} !Int !*{# FunDef} !IndexRange !(Optional Bool) !Commo
-> (!Bool, !*{# FunDef}, !ArrayAndListInstances, !{# CommonDefs}, !{# {# FunType} }, !*TypeDefInfos,!*Heaps,!*PredefinedSymbols,!*File,!*File)
typeProgram comps main_dcl_module_n fun_defs specials list_inferred_types icl_defs imports icl_qualified_imports dcl_modules used_module_numbers
td_infos heaps=:{hp_var_heap, hp_expression_heap, hp_type_heaps,hp_generic_heap} predef_symbols file out
-
#! fun_env_size = size fun_defs
# ts_error = {ea_file = file, ea_loc = [], ea_ok = True }