Commit c74cadd5 authored by Martin Wierich's avatar Martin Wierich
Browse files

introduced new error message: "StdDynamics not imported"

parent 1c12e0b2
......@@ -883,7 +883,8 @@ checkPattern (PE_List [exp1, exp2 : exps]) opt_var p_input var_env ps e_info cs
checkPattern (PE_DynamicPattern pattern type) opt_var p_input var_env ps e_info cs
# (dyn_pat, var_env, ps, e_info, cs) = checkPattern pattern No p_input var_env ps e_info cs
= (AP_Dynamic dyn_pat type opt_var, var_env, ps, e_info, cs)
// MW was = (AP_Dynamic dyn_pat type opt_var, var_env, ps, e_info, cs)
= (AP_Dynamic dyn_pat type opt_var, var_env, ps, e_info, { cs & cs_needed_modules = cs.cs_needed_modules bitor cNeedStdDynamics })
checkPattern (PE_Basic basic_value) opt_var p_input var_env ps e_info cs
= (AP_Basic basic_value opt_var, var_env, ps, e_info, cs)
......@@ -1275,7 +1276,8 @@ where
-> (patterns, pattern_variables, defaul, var_store, expr_heap, opt_dynamics,
{ cs & cs_error = checkError basic_val "illegal combination of patterns" cs.cs_error})
transform_pattern (AP_Dynamic pattern type opt_var) patterns pattern_variables defaul result_expr var_store expr_heap opt_dynamics cs
# (var_arg, result_expr, var_store, expr_heap, opt_dynamics, cs) = convertSubPattern pattern result_expr var_store expr_heap opt_dynamics cs
# cs = { cs & cs_needed_modules = cs.cs_needed_modules bitor cNeedStdDynamics } // MW++
(var_arg, result_expr, var_store, expr_heap, opt_dynamics, cs) = convertSubPattern pattern result_expr var_store expr_heap opt_dynamics cs
(dynamic_info_ptr, expr_heap) = newPtr (EI_DynamicType type opt_dynamics) expr_heap
pattern = { dp_var = var_arg, dp_type = dynamic_info_ptr, dp_rhs = result_expr, dp_type_patterns_vars = [], dp_type_code = TCE_Empty }
pattern_variables = cons_optional opt_var pattern_variables
......@@ -1479,7 +1481,8 @@ checkExpression free_vars (PE_Dynamic expr opt_type) e_input e_state=:{es_expres
(dyn_expr, free_vars, e_state, e_info, cs) = checkExpression free_vars expr e_input
{e_state & es_dynamics = [dyn_info_ptr : es_dynamics], es_expression_heap = es_expression_heap } e_info cs
= (DynamicExpr { dyn_expr = dyn_expr, dyn_opt_type = opt_type, dyn_info_ptr = dyn_info_ptr, dyn_type_code = TCE_Empty, dyn_uni_vars = [] },
free_vars, e_state, e_info, cs)
// MW was free_vars, e_state, e_info, cs)
free_vars, e_state, e_info, { cs & cs_needed_modules = cs.cs_needed_modules bitor cNeedStdDynamics })
checkExpression free_vars (PE_Basic basic_value) e_input e_state e_info cs
# (basic_type, cs) = typeOfBasicValue basic_value cs
......@@ -2031,7 +2034,8 @@ where
= (Case { case_expr = act_var, case_guards = case_guards, case_default = No, case_ident = No, case_info_ptr = case_expr_ptr },
var_store, expr_heap, opt_dynamics, cs)
transform_pattern_into_cases (AP_Dynamic pattern type opt_var) fun_arg result_expr var_store expr_heap opt_dynamics cs
# (var_arg, result_expr, var_store, expr_heap, opt_dynamics, cs) = convertSubPattern pattern result_expr var_store expr_heap opt_dynamics cs
# cs = { cs & cs_needed_modules = cs.cs_needed_modules bitor cNeedStdDynamics } // MW++
(var_arg, result_expr, var_store, expr_heap, opt_dynamics, cs) = convertSubPattern pattern result_expr var_store expr_heap opt_dynamics cs
(type_case_info_ptr, expr_heap) = newPtr EI_Empty expr_heap
(dynamic_info_ptr, expr_heap) = newPtr (EI_DynamicType type opt_dynamics) expr_heap
(act_var, result_expr, expr_heap) = transform_pattern_variable fun_arg opt_var result_expr expr_heap
......@@ -2397,7 +2401,7 @@ checkModule {mod_type,mod_name,mod_imports,mod_imported_objects,mod_defs = cdefs
(scanned_modules, icl_functions, cs)
= add_modules_to_symbol_table [ dcl_mod, pre_def_mod : scanned_modules ] 0 icl_functions
{ cs_symbol_table = symbol_table, cs_predef_symbols = predef_symbols, cs_error = error }
{ cs_symbol_table = symbol_table, cs_predef_symbols = predef_symbols, cs_error = error, /*MW*/ cs_needed_modules = 0 }
init_dcl_modules = [ initialDclModule scanned_module \\ scanned_module <- scanned_modules ]
(dcl_modules, local_defs, cdefs, sizes, cs)
......@@ -2416,6 +2420,8 @@ checkModule {mod_type,mod_name,mod_imports,mod_imported_objects,mod_defs = cdefs
(_, {ii_modules,ii_funs_and_macros = icl_functions}, heaps, cs) = checkImports mod_imports iinfo heaps cs
cs = { cs & cs_needed_modules = 0 } // MW++
(nr_of_modules, (f_consequences, ii_modules, icl_functions, hp_expression_heap, cs))
= check_completeness_of_all_dcl_modules ii_modules icl_functions heaps.hp_expression_heap cs
......@@ -2445,6 +2451,8 @@ checkModule {mod_type,mod_name,mod_imports,mod_imported_objects,mod_defs = cdefs
(icl_functions, e_info, heaps, cs) = checkMacros cIclModIndex cdefs.def_macros icl_functions e_info heaps cs
(icl_functions, e_info, heaps, cs) = checkFunctions cIclModIndex cGlobalScope 0 nr_of_global_funs icl_functions e_info heaps cs
(e_info, cs) = check_needed_modules_are_imported mod_name ".icl" e_info cs // MW ++
(icl_functions, e_info, heaps, {cs_symbol_table, cs_predef_symbols, cs_error})
= checkInstanceBodies {ir_from = first_inst_index, ir_to = nr_of_functions} icl_functions e_info heaps cs
(icl_imported, dcl_modules, cs_symbol_table) = retrieveImportsFromSymbolTable mod_imports [] e_info.ef_modules cs_symbol_table
......@@ -2658,6 +2666,30 @@ checkModule {mod_type,mod_name,mod_imports,mod_imported_objects,mod_defs = cdefs
(Yes symbol_type) = inst_def.fun_type
= { instance_defs & [ds_index] = { inst_def & fun_type = Yes (makeElemTypeOfArrayFunctionStrict symbol_type ins_offset offset_table) } }
// MW..
check_needed_modules_are_imported mod_name extension e_info cs=:{cs_needed_modules}
# (e_info, cs) = case cs_needed_modules bitand cNeedStdDynamics of
0 -> (e_info, cs)
_ -> check_it PD_StdDynamics mod_name extension e_info cs
# (e_info, cs) = case cs_needed_modules bitand cNeedStdArray of
0 -> (e_info, cs)
_ -> check_it PD_StdArray mod_name extension e_info cs
# (e_info, cs) = case cs_needed_modules bitand cNeedStdEnum of
0 -> (e_info, cs)
_ -> check_it PD_StdEnum mod_name extension e_info cs
= (e_info, cs)
where
check_it pd mod_name extension e_info=:{ef_modules} cs=:{cs_predef_symbols}
#! {pds_ident} = cs_predef_symbols.[pd]
is_imported = any ((==) pds_ident) [ dcl_name \\ {dcl_name}<-:ef_modules ]
| is_imported
= (e_info, cs)
# error_location = { ip_ident = mod_name, ip_line = 1, ip_file = mod_name.id_name+++extension}
cs_error = pushErrorAdmin error_location cs.cs_error
cs_error = checkError pds_ident "not imported" cs_error
cs_error = popErrorAdmin cs_error
= (e_info, { cs & cs_error = cs_error })
// ..MW
arrayFunOffsetToPD_IndexTable member_defs predef_symbols
# nr_of_array_functions = size member_defs
......@@ -2768,7 +2800,8 @@ checkDclModule {mod_name,mod_imports,mod_defs} mod_index modules icl_functions h
dcl_common = createCommonDefinitions mod_defs
dcl_macros = mod_defs.def_macros
(imports, modules, cs) = collect_imported_symbols mod_imports [] modules cs
// MW was (imports, modules, cs) = collect_imported_symbols mod_imports [] modules cs
(imports, modules, cs) = collect_imported_symbols mod_imports [] modules { cs & cs_needed_modules = 0 }
// imports :: [(Index,Declarations)]
......@@ -2801,6 +2834,8 @@ checkDclModule {mod_name,mod_imports,mod_defs} mod_index modules icl_functions h
(icl_functions, e_info, heaps, cs)
= checkMacros mod_index dcl_macros icl_functions e_info heaps { cs & cs_error = cs_error }
(e_info, cs) = check_needed_modules_are_imported mod_name ".dcl" e_info cs // MW ++
com_instance_defs = dcl_common.com_instance_defs
com_instance_defs = { inst_def \\ inst_def <- [ inst_def \\ inst_def <-: com_instance_defs ] ++ new_class_instances }
......
......@@ -14,6 +14,12 @@ cGlobalScope :== 1
cIsNotADclModule :== False
cIsADclModule :== True
// MW..
cNeedStdArray :== 1
cNeedStdEnum :== 2
cNeedStdDynamics:== 4
// ..MW
:: VarHeap :== Heap VarInfo
:: Heaps =
......@@ -24,7 +30,8 @@ cIsADclModule :== True
:: ErrorAdmin = { ea_file :: !.File, ea_loc :: ![IdentPos], ea_ok :: !Bool }
:: CheckState = { cs_symbol_table :: !.SymbolTable, cs_predef_symbols :: !.PredefinedSymbols, cs_error :: !.ErrorAdmin }
:: CheckState = { cs_symbol_table :: !.SymbolTable, cs_predef_symbols :: !.PredefinedSymbols, cs_error :: !.ErrorAdmin,
cs_needed_modules :: !BITVECT } // MW++
// SymbolTable :== {# SymbolTableEntry}
......
......@@ -17,6 +17,12 @@ cGlobalScope :== 1
cIsNotADclModule :== False
cIsADclModule :== True
// MW..
cNeedStdArray :== 1
cNeedStdEnum :== 2
cNeedStdDynamics:== 4
// ..MW
:: Heaps =
{ hp_var_heap ::!.VarHeap
, hp_expression_heap ::!.ExpressionHeap
......@@ -25,7 +31,8 @@ cIsADclModule :== True
:: ErrorAdmin = { ea_file :: !.File, ea_loc :: ![IdentPos], ea_ok :: !Bool }
:: CheckState = { cs_symbol_table :: !.SymbolTable, cs_predef_symbols :: !.PredefinedSymbols, cs_error :: !.ErrorAdmin }
:: CheckState = { cs_symbol_table :: !.SymbolTable, cs_predef_symbols :: !.PredefinedSymbols, cs_error :: !.ErrorAdmin,
cs_needed_modules :: !BITVECT } // MW++
:: ConversionTable :== {# .{# Int }}
......
......@@ -719,8 +719,18 @@ where
check_type_context :: !TypeContext !Index v:{#CheckedTypeDef} !x:{#ClassDef} !u:{#.DclModule} !*TypeHeaps !*CheckState
-> (!TypeContext,!z:{#CheckedTypeDef},!x:{#ClassDef},!w:{#DclModule},!*TypeHeaps,!*CheckState), [u v <= w, v u <= z]
check_type_context tc=:{tc_class=tc_class=:{glob_object=class_name=:{ds_ident={id_name,id_info},ds_arity}},tc_types}
mod_index type_defs class_defs modules heaps cs=:{cs_symbol_table}
check_type_context tc=:{tc_class=tc_class=:{glob_object=class_name=:{ds_ident=ds_ident=:{id_name,id_info},ds_arity}},tc_types}
mod_index type_defs class_defs modules heaps cs=:{cs_symbol_table, cs_predef_symbols}
// MW..
#! {pds_ident} = cs_predef_symbols.[PD_TypeCodeClass]
pre_mod = cs_predef_symbols.[PD_PredefinedModule]
# (modules, cs) = case ds_ident==pds_ident of
True # ({dcl_name}, modules) = modules![mod_index]
| pre_mod.pds_def <> mod_index
-> (modules, { cs & cs_needed_modules = cs.cs_needed_modules bitor cNeedStdDynamics })
-> (modules, cs) // the predefined module does not have to import StdDynamics
_ -> (modules, cs)
// .. MW
#! entry = sreadPtr id_info cs_symbol_table
# (class_index, class_module) = retrieveGlobalDefinition entry STE_Class mod_index
| class_index <> NotFound
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment