diff options
-rw-r--r-- | frontend/check.icl | 36 | ||||
-rw-r--r-- | frontend/checkFunctionBodies.dcl | 2 | ||||
-rw-r--r-- | frontend/checkFunctionBodies.icl | 18 |
3 files changed, 23 insertions, 33 deletions
diff --git a/frontend/check.icl b/frontend/check.icl index 79aeb2c..3709f49 100644 --- a/frontend/check.icl +++ b/frontend/check.icl @@ -72,7 +72,6 @@ where # (gv, st_vars, error) = find gv st_vars error = (gv, [st_var:st_vars], error) - checkTypeClasses :: !Index !Index !*{#ClassDef} !*{#MemberDef} !*{#CheckedTypeDef} !*{#DclModule} !*TypeHeaps !*CheckState -> (!*{#ClassDef}, !*{#MemberDef}, !*{#CheckedTypeDef}, !*{#DclModule}, !*TypeHeaps, !*CheckState) checkTypeClasses class_index module_index class_defs member_defs type_defs modules type_heaps cs=:{cs_symbol_table,cs_error} @@ -142,7 +141,6 @@ where check_specials mod_index fun_type fun_index SP_None next_inst_index all_instances heaps error = (SP_None, next_inst_index, all_instances, heaps, error) - checkSpecialsOfInstances :: !Index !Index ![ClassInstance] !Index ![ClassInstance] ![FunType] {# FunType} *{! [Special] } !*Heaps !*ErrorAdmin -> (!Index, ![ClassInstance], ![FunType], !*{! [Special]}, !*Heaps, !*ErrorAdmin) checkSpecialsOfInstances mod_index first_mem_index [class_inst=:{ins_members,ins_specials} : class_insts] next_inst_index all_class_instances all_specials @@ -666,7 +664,6 @@ where = (tc_types, checkError ds_ident.id_name "illegal specialization" error) = (tc_types, error) - initializeContextVariables :: ![TypeContext] !*VarHeap -> (![TypeContext], !*VarHeap) initializeContextVariables contexts var_heap = mapSt add_variable_to_context contexts var_heap @@ -675,19 +672,33 @@ where # (new_info_ptr, var_heap) = newPtr VI_Empty var_heap = ({ context & tc_var = new_info_ptr}, var_heap) +ident_for_errors_from_fun_symb_and_fun_kind :: Ident DefOrImpFunKind -> Ident; +ident_for_errors_from_fun_symb_and_fun_kind {id_name} (FK_ImpFunction fun_name_is_location_dependent) + | fun_name_is_location_dependent && size id_name>0 + # beautiful_name = if (id_name.[0]==backslash) "lambda" "comprehension" + = { id_name=beautiful_name, id_info=nilPtr } +ident_for_errors_from_fun_symb_and_fun_kind {id_name} (FK_DefFunction fun_name_is_location_dependent) + | fun_name_is_location_dependent && size id_name>0 + # beautiful_name = if (id_name.[0]==backslash) "lambda" "comprehension" + = { id_name=beautiful_name, id_info=nilPtr } +ident_for_errors_from_fun_symb_and_fun_kind fun_symb _ + = fun_symb + checkFunction :: !Index !Index !Level !*{#FunDef} !*ExpressionInfo !*Heaps !*CheckState -> (!*{#FunDef},!*ExpressionInfo, !*Heaps, !*CheckState); checkFunction mod_index fun_index def_level fun_defs e_info=:{ef_type_defs,ef_modules,ef_class_defs,ef_is_macro_fun} heaps=:{hp_var_heap,hp_expression_heap,hp_type_heaps} cs=:{cs_error} # (fun_def,fun_defs) = fun_defs![fun_index] # {fun_symb,fun_pos,fun_body,fun_type,fun_kind} = fun_def - cs = { cs & cs_error = push_error_admin_beautifully fun_symb fun_pos fun_kind cs_error } + # function_ident_for_errors = ident_for_errors_from_fun_symb_and_fun_kind fun_symb fun_kind + # cs = {cs & cs_error = pushErrorAdmin (newPosition function_ident_for_errors fun_pos) cs_error} + (fun_type, ef_type_defs, ef_class_defs, ef_modules, hp_var_heap, hp_type_heaps, cs) = check_function_type fun_type mod_index ef_type_defs ef_class_defs ef_modules hp_var_heap hp_type_heaps cs e_info = { e_info & ef_type_defs = ef_type_defs, ef_class_defs = ef_class_defs, ef_modules = ef_modules } e_state = { es_var_heap = hp_var_heap, es_expr_heap = hp_expression_heap, es_type_heaps = hp_type_heaps, es_dynamics = [], es_calls = [], es_fun_defs = fun_defs, es_dynamic_expr_count = 0} e_input = { ei_expr_level = inc def_level, ei_fun_index = fun_index, ei_fun_level = inc def_level, ei_mod_index = mod_index } - (fun_body, free_vars, e_state, e_info, cs) = checkFunctionBodies fun_body e_input e_state e_info cs + (fun_body, free_vars, e_state, e_info, cs) = checkFunctionBodies fun_body function_ident_for_errors e_input e_state e_info cs # {es_fun_defs,es_calls,es_var_heap,es_expr_heap,es_type_heaps,es_dynamics} = e_state (ef_type_defs, ef_modules, es_type_heaps, es_expr_heap, cs) = @@ -730,17 +741,6 @@ where get_calls (STE_FunctionOrMacro [x:xs]) = (x,xs) get_calls ste_kind = abort "get_calls (check.icl)" // <<- ste_kind - push_error_admin_beautifully {id_name} fun_pos (FK_ImpFunction fun_name_is_location_dependent) cs_error - | fun_name_is_location_dependent && size id_name>0 - # beautiful_name = if (id_name.[0]==backslash) "lambda" "comprehension" - = pushErrorAdmin (newPosition { id_name=beautiful_name, id_info=nilPtr } fun_pos) cs_error - push_error_admin_beautifully {id_name} fun_pos (FK_DefFunction fun_name_is_location_dependent) cs_error - | fun_name_is_location_dependent && size id_name>0 - # beautiful_name = if (id_name.[0]==backslash) "lambda" "comprehension" - = pushErrorAdmin (newPosition { id_name=beautiful_name, id_info=nilPtr } fun_pos) cs_error - push_error_admin_beautifully fun_symb fun_pos _ cs_error - = pushErrorAdmin (newPosition fun_symb fun_pos) cs_error - checkFunctions :: !Index !Level !Index !Index !*{#FunDef} !*ExpressionInfo !*Heaps !*CheckState -> (!*{#FunDef}, !*ExpressionInfo, !*Heaps, !*CheckState) checkFunctions mod_index level from_index to_index fun_defs e_info heaps cs | from_index == to_index @@ -1656,12 +1656,9 @@ check_module2 mod_name mod_imported_objects mod_imports mod_type icl_global_func (icl_sizes_without_added_dcl_defs, sizes) = memcpy sizes (dcl_modules, local_defs, cdefs, icl_sizes, cs) = combineDclAndIclModule mod_type init_dcl_modules local_defs cdefs sizes cs - | not cs.cs_error.ea_ok = (False, abort "evaluated error 1 (check.icl)", {}, {}, No, {}, cs.cs_x.x_main_dcl_module_n,heaps, cs.cs_predef_symbols, cs.cs_symbol_table, cs.cs_error.ea_file, []) - # icl_common = createCommonDefinitions cdefs - (local_defs,dcl_modules,icl_common,cs) = renumber_icl_definitions_as_dcl_definitions mod_type local_defs dcl_modules icl_common {icl_sizes.[i] \\ i<-[0..cMacroDefs-1]} cs @@ -2368,7 +2365,6 @@ updateExplImpForMarkedLocalSymbol mod_index decl {ste_kind=STE_ExplImpComponentN updateExplImpForMarkedLocalSymbol _ _ entry dcl_modules expl_imp_infos cs_symbol_table = (dcl_modules, expl_imp_infos, cs_symbol_table) - //1.3 memcpy :: u:(a b) -> (!.(c b),!v:(a b)) | Array a & createArray_u , createArrayc_u , size_u , update_u , uselect_u b & Array c, [u <= v]; //3.1 diff --git a/frontend/checkFunctionBodies.dcl b/frontend/checkFunctionBodies.dcl index 5f655a8..fd75a04 100644 --- a/frontend/checkFunctionBodies.dcl +++ b/frontend/checkFunctionBodies.dcl @@ -21,5 +21,5 @@ import syntax, checksupport , ei_mod_index :: !Index } -checkFunctionBodies :: !FunctionBody !.ExpressionInput !*ExpressionState !*ExpressionInfo !*CheckState +checkFunctionBodies :: !FunctionBody !Ident !.ExpressionInput !*ExpressionState !*ExpressionInfo !*CheckState -> (FunctionBody,[FreeVar],!.ExpressionState,.ExpressionInfo,!.CheckState); diff --git a/frontend/checkFunctionBodies.icl b/frontend/checkFunctionBodies.icl index 065a7ac..ab5128a 100644 --- a/frontend/checkFunctionBodies.icl +++ b/frontend/checkFunctionBodies.icl @@ -55,12 +55,14 @@ cEndWithSelection :== False :: RecordKind = RK_Constructor | RK_Update | RK_UpdateToConstructor ![AuxiliaryPattern] -checkFunctionBodies :: !FunctionBody !.ExpressionInput !*ExpressionState !*ExpressionInfo !*CheckState -> (FunctionBody,[FreeVar],!.ExpressionState,.ExpressionInfo,!.CheckState); -checkFunctionBodies (ParsedBody [{pb_args,pb_rhs={rhs_alts,rhs_locals}, pb_position} : bodies]) e_input=:{ei_expr_level,ei_mod_index} +checkFunctionBodies :: !FunctionBody !Ident !.ExpressionInput !*ExpressionState !*ExpressionInfo !*CheckState -> (FunctionBody,[FreeVar],!.ExpressionState,.ExpressionInfo,!.CheckState); +checkFunctionBodies (ParsedBody [{pb_args,pb_rhs={rhs_alts,rhs_locals}, pb_position} : bodies]) function_ident_for_errors e_input=:{ei_expr_level,ei_mod_index} e_state=:{es_var_heap, es_fun_defs} e_info cs + # (aux_patterns, (var_env, array_patterns), {ps_var_heap, ps_fun_defs}, e_info, cs) = check_patterns pb_args {pi_def_level = ei_expr_level, pi_mod_index = ei_mod_index, pi_is_node_pattern = False} ([], []) {ps_var_heap = es_var_heap, ps_fun_defs = es_fun_defs} e_info cs + (rhs_expr, free_vars, e_state, e_info, cs) = checkRhs [] rhs_alts rhs_locals e_input { e_state & es_var_heap = ps_var_heap, es_fun_defs = ps_fun_defs } e_info cs (dynamics_in_rhs, e_state) @@ -104,9 +106,11 @@ where check_function_bodies free_vars fun_args [{pb_args,pb_rhs={rhs_alts,rhs_locals},pb_position} : bodies] e_input=:{ei_expr_level,ei_mod_index} e_state=:{es_var_heap,es_fun_defs} e_info cs + # cs = pushErrorAdmin (newPosition function_ident_for_errors pb_position) cs # (aux_patterns, (var_env, array_patterns), {ps_var_heap, ps_fun_defs}, e_info, cs) = check_patterns pb_args { pi_def_level = ei_expr_level, pi_mod_index = ei_mod_index, pi_is_node_pattern = False } ([], []) {ps_var_heap = es_var_heap, ps_fun_defs = es_fun_defs} e_info cs + # cs = popErrorAdmin cs e_state = { e_state & es_var_heap = ps_var_heap, es_fun_defs = ps_fun_defs} (rhs_expr, free_vars, e_state, e_info, cs) = checkRhs free_vars rhs_alts rhs_locals e_input e_state e_info cs (rhs_expr, free_vars, e_state=:{es_dynamics=dynamics_in_rhs}, e_info, cs) @@ -1042,8 +1046,6 @@ where = (SK_Function { glob_object = def_index, glob_module = ei_mod_index}, st_arity, ft_priority, cIsAFunction, e_state, { e_info & ef_modules = ef_modules }, cs) - - checkPattern :: !ParsedExpr !(Optional (Bind Ident VarInfoPtr)) !PatternInput !(![Ident], ![ArrayPattern]) !*PatternState !*ExpressionInfo !*CheckState -> (!AuxiliaryPattern, !(![Ident], ![ArrayPattern]), !*PatternState, !*ExpressionInfo, !*CheckState) checkPattern (PE_List [exp]) opt_var p_input accus ps e_info cs=:{cs_symbol_table} @@ -1274,8 +1276,6 @@ checkPattern (PE_ArrayPattern selections) opt_var p_input (var_env, array_patter checkPattern expr opt_var p_input accus ps e_info cs = abort "checkPattern: do not know how to handle pattern" ---> expr - - checkPatternConstructor :: !Index !Bool !SymbolTableEntry !Ident !(Optional (Bind Ident VarInfoPtr)) !*PatternState !*ExpressionInfo !*CheckState -> (!AuxiliaryPattern, !*PatternState, !*ExpressionInfo, !*CheckState); checkPatternConstructor _ _ {ste_kind = STE_Empty} ident _ ps e_info cs=:{cs_error} @@ -1334,8 +1334,6 @@ checkBoundPattern {bind_src,bind_dst} opt_var p_input (var_env, array_patterns) = checkPattern bind_src opt_var p_input (var_env, array_patterns) ps e_info { cs & cs_error = checkError bind_dst "variable expected" cs.cs_error } - - checkPatternVariable :: !Level !SymbolTableEntry !Ident !VarInfoPtr !*CheckState -> !*CheckState checkPatternVariable def_level entry=:{ste_def_level,ste_kind} ident=:{id_info} var_info cs=:{cs_symbol_table,cs_error} | ste_kind == STE_Empty || def_level > ste_def_level @@ -1343,8 +1341,6 @@ checkPatternVariable def_level entry=:{ste_def_level,ste_kind} ident=:{id_info} = { cs & cs_symbol_table = cs_symbol_table <:= (id_info,entry)} = { cs & cs_error = checkError ident "(pattern variable) already defined" cs_error } - - checkIdentPattern :: !Bool !Ident !(Optional (Bind Ident VarInfoPtr)) !PatternInput !(![Ident], ![ArrayPattern]) !*PatternState !*ExpressionInfo !*CheckState -> (!AuxiliaryPattern, !(![Ident], ![ArrayPattern]), !*PatternState, !*ExpressionInfo, !*CheckState) checkIdentPattern is_expr_list id=:{id_name,id_info} opt_var {pi_def_level, pi_mod_index} accus=:(var_env, array_patterns) @@ -1357,8 +1353,6 @@ checkIdentPattern is_expr_list id=:{id_name,id_info} opt_var {pi_def_level, pi_m # (pattern, ps, e_info, cs) = checkPatternConstructor pi_mod_index is_expr_list entry id opt_var ps e_info { cs & cs_symbol_table = cs_symbol_table } = (pattern, accus, ps, e_info, cs) - - convertSubPatterns :: [AuxiliaryPattern] Expression Position *(Heap VarInfo) *(Heap ExprInfo) u:[Ptr ExprInfo] *CheckState -> *(!.[FreeVar],!Expression,!Position,!*Heap VarInfo,!*Heap ExprInfo,!u:[Ptr ExprInfo],!*CheckState); convertSubPatterns [] result_expr pattern_position var_store expr_heap opt_dynamics cs = ([], result_expr, pattern_position, var_store, expr_heap, opt_dynamics, cs) |