@@ -204,7 +204,7 @@ public function checkRedeclaredElementPrefix
204204 input SCode . Element inReplacement;
205205 input SourceInfo inInfo;
206206algorithm
207- _ := match(inItem, inReplacement, inInfo )
207+ _ := match(inItem, inReplacement)
208208 local
209209 SCode . Replaceable repl;
210210 SCode . Final fin;
@@ -214,58 +214,54 @@ algorithm
214214 SCode . Restriction res;
215215 SCode . Visibility vis1, vis2;
216216 String ty;
217- Integer err_count;
218217 Absyn . TypeSpec ty1, ty2;
218+ Boolean ok;
219219
220220 case (NFSCodeEnv . VAR (var =
221221 SCode . COMPONENT (name = name, prefixes = SCode . PREFIXES (
222222 finalPrefix = fin, replaceablePrefix = repl),
223223 attributes = SCode . ATTR (variability = var ), typeSpec = ty1, info = info)),
224- SCode . COMPONENT (prefixes = SCode . PREFIXES (), typeSpec = ty2), _)
225- equation
226- err_count = Error . getNumErrorMessages();
227- ty = "component" ;
228- checkCompRedeclarationReplaceable(name, repl, ty1, ty2, inInfo, info);
229- checkRedeclarationFinal(name, ty, fin, inInfo, info);
230- checkRedeclarationVariability(name, ty, var , inInfo, info);
224+ SCode . COMPONENT (prefixes = SCode . PREFIXES (), typeSpec = ty2))
225+ algorithm
226+ ty := "component" ;
227+ ok := checkCompRedeclarationReplaceable(name, repl, ty1, ty2, inInfo, info);
228+ ok := checkRedeclarationFinal(name, ty, fin, inInfo, info) and ok;
229+ ok := checkRedeclarationVariability(name, ty, var , inInfo, info) and ok;
231230 // checkRedeclarationVisibility(name, ty, vis1, vis2, inInfo, info);
232- true = intEq(err_count, Error . getNumErrorMessages()) ;
231+ true : = ok ;
233232 then
234233 ();
235234
236235 case (NFSCodeEnv . CLASS (cls =
237236 SCode . CLASS (name = name, prefixes = SCode . PREFIXES (
238237 finalPrefix = fin, replaceablePrefix = repl),
239238 restriction = res, info = info)),
240- SCode . CLASS (prefixes = SCode . PREFIXES ()), _)
241- equation
242- err_count = Error . getNumErrorMessages();
243- ty = SCodeDump . restrictionStringPP(res);
244- checkClassRedeclarationReplaceable(name, ty, repl, inInfo, info);
245- checkRedeclarationFinal(name, ty, fin, inInfo, info);
239+ SCode . CLASS (prefixes = SCode . PREFIXES ()))
240+ algorithm
241+ ty := SCodeDump . restrictionStringPP(res);
242+ ok := checkClassRedeclarationReplaceable(name, ty, repl, inInfo, info);
243+ ok := checkRedeclarationFinal(name, ty, fin, inInfo, info) and ok;
246244 // checkRedeclarationVisibility(name, ty, vis1, vis2, inInfo, info);
247- true = intEq(err_count, Error . getNumErrorMessages()) ;
245+ true : = ok ;
248246 then
249247 ();
250248
251249 case (NFSCodeEnv . VAR (var = SCode . COMPONENT (name = name, info = info)),
252- SCode . CLASS (restriction = res), _)
253- equation
254- ty = SCodeDump . restrictionStringPP(res);
255- ty = "a " + ty;
256- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inInfo);
257- Error . addSourceMessage(Error . INVALID_REDECLARE_AS ,
258- {"component" , name, ty}, info);
250+ SCode . CLASS (restriction = res))
251+ algorithm
252+ ty := SCodeDump . restrictionStringPP(res);
253+ ty := "a " + ty;
254+ Error . addMultiSourceMessage(Error . INVALID_REDECLARE_AS ,
255+ {"component" , name, ty}, {inInfo, info});
259256 then
260257 fail();
261258
262259 case (NFSCodeEnv . CLASS (cls = SCode . CLASS (restriction = res, info = info)),
263- SCode . COMPONENT (name = name), _)
264- equation
265- ty = SCodeDump . restrictionStringPP(res);
266- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inInfo);
267- Error . addSourceMessage(Error . INVALID_REDECLARE_AS ,
268- {ty, name, "a component" }, info);
260+ SCode . COMPONENT (name = name))
261+ algorithm
262+ ty := SCodeDump . restrictionStringPP(res);
263+ Error . addMultiSourceMessage(Error . INVALID_REDECLARE_AS ,
264+ {ty, name, "a component" }, {inInfo, info});
269265 then
270266 fail();
271267
@@ -279,17 +275,18 @@ protected function checkClassRedeclarationReplaceable
279275 input SCode . Replaceable inReplaceable;
280276 input SourceInfo inOriginInfo;
281277 input SourceInfo inInfo;
278+ output Boolean isValid;
282279algorithm
283- _ := match(inName, inType, inReplaceable, inOriginInfo, inInfo)
284- case (_, _, SCode . REPLACEABLE (), _, _) then ();
285-
286- case (_, _, SCode . NOT_REPLACEABLE (), _, _)
287- equation
288- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inOriginInfo);
289- Error . addSourceMessage(Error . REDECLARE_NON_REPLACEABLE ,
290- {inType, inName}, inInfo);
280+ isValid := match inReplaceable
281+ case SCode . NOT_REPLACEABLE () guard not Flags . getConfigBool(Flags . IGNORE_REPLACEABLE )
282+ algorithm
283+ Error . addMultiSourceMessage(Error . REDECLARE_NON_REPLACEABLE ,
284+ {inType, inName}, {inOriginInfo, inInfo});
291285 then
292- ();
286+ false ;
287+
288+ else true ;
289+
293290 end match;
294291end checkClassRedeclarationReplaceable;
295292
@@ -300,27 +297,24 @@ protected function checkCompRedeclarationReplaceable
300297 input Absyn . TypeSpec inType2;
301298 input SourceInfo inOriginInfo;
302299 input SourceInfo inInfo;
300+ output Boolean isValid;
303301algorithm
304- _ := match(inName, inReplaceable, inType1, inType2, inOriginInfo, inInfo)
305- local
306- SCode . Element var ;
307- Absyn . TypeSpec ty1, ty2;
308-
309- case (_, SCode . REPLACEABLE (), _, _, _, _) then ();
310-
311- case (_, SCode . NOT_REPLACEABLE (), _, _, _, _)
302+ isValid := match inReplaceable
303+ case SCode . NOT_REPLACEABLE ()
312304 guard Absyn . pathEqual(Absyn . typeSpecPath(inType1),
313305 Absyn . typeSpecPath(inType2))
314306 then
315- () ;
307+ true ;
316308
317- case (_, SCode . NOT_REPLACEABLE (), _, _, _, _)
318- equation
319- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inOriginInfo);
320- Error . addSourceMessage(Error . REDECLARE_NON_REPLACEABLE ,
321- {"component" , inName}, inInfo);
309+ case SCode . NOT_REPLACEABLE () guard not Flags . getConfigBool(Flags . IGNORE_REPLACEABLE )
310+ algorithm
311+ Error . addMultiSourceMessage(Error . REDECLARE_NON_REPLACEABLE ,
312+ {"component" , inName}, {inOriginInfo, inInfo});
322313 then
323- ();
314+ fail();
315+
316+ else true ;
317+
324318 end match;
325319end checkCompRedeclarationReplaceable;
326320
@@ -330,17 +324,18 @@ protected function checkRedeclarationFinal
330324 input SCode . Final inFinal;
331325 input SourceInfo inOriginInfo;
332326 input SourceInfo inInfo;
327+ output Boolean isValid;
333328algorithm
334- _ := match(inName, inType, inFinal, inOriginInfo, inInfo)
335- case (_, _, SCode . NOT_FINAL (), _, _) then () ;
329+ isValid := match inFinal
330+ case SCode . NOT_FINAL () then true ;
336331
337- case (_, _, SCode . FINAL (), _, _)
338- equation
339- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inOriginInfo);
340- Error . addSourceMessage(Error . INVALID_REDECLARE ,
341- {"final" , inType, inName}, inInfo);
332+ case SCode . FINAL ()
333+ algorithm
334+ Error . addMultiSourceMessage(Error . INVALID_REDECLARE ,
335+ {"final" , inType, inName}, {inOriginInfo, inInfo});
342336 then
343- ();
337+ false ;
338+
344339 end match;
345340end checkRedeclarationFinal;
346341
@@ -350,17 +345,17 @@ protected function checkRedeclarationVariability
350345 input SCode . Variability inVariability;
351346 input SourceInfo inOriginInfo;
352347 input SourceInfo inInfo;
348+ output Boolean isValid;
353349algorithm
354- _ := match(inName, inType, inVariability, inOriginInfo, inInfo)
355- case (_, _, SCode . CONST (), _, _)
356- equation
357- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inOriginInfo);
358- Error . addSourceMessage(Error . INVALID_REDECLARE ,
359- {"constant" , inType, inName}, inInfo);
350+ isValid := match inVariability
351+ case SCode . CONST ()
352+ algorithm
353+ Error . addMultiSourceMessage(Error . INVALID_REDECLARE ,
354+ {"constant" , inType, inName}, {inOriginInfo, inInfo});
360355 then
361- () ;
356+ false ;
362357
363- else () ;
358+ else true ;
364359 end match;
365360end checkRedeclarationVariability;
366361
@@ -371,26 +366,24 @@ protected function checkRedeclarationVisibility
371366 input SCode . Visibility inNewVisibility;
372367 input SourceInfo inOriginInfo;
373368 input SourceInfo inNewInfo;
369+ output Boolean isValid;
374370algorithm
375- _ := match(inName, inType, inOriginalVisibility, inNewVisibility,
376- inOriginInfo, inNewInfo)
377- case (_, _, SCode . PUBLIC (), SCode . PROTECTED (), _, _)
378- equation
379- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inNewInfo);
380- Error . addSourceMessage(Error . INVALID_REDECLARE_AS ,
381- {"public element" , inName, "protected" }, inOriginInfo);
371+ isValid := match (inOriginalVisibility, inNewVisibility)
372+ case (SCode . PUBLIC (), SCode . PROTECTED ())
373+ algorithm
374+ Error . addMultiSourceMessage(Error . INVALID_REDECLARE_AS ,
375+ {"public element" , inName, "protected" }, {inNewInfo, inOriginInfo});
382376 then
383- fail() ;
377+ false ;
384378
385- case (_, _, SCode . PROTECTED (), SCode . PUBLIC (), _, _)
386- equation
387- Error . addSourceMessage(Error . ERROR_FROM_HERE , {}, inNewInfo);
388- Error . addSourceMessage(Error . INVALID_REDECLARE_AS ,
389- {"protected element" , inName, "public" }, inOriginInfo);
379+ case (SCode . PROTECTED (), SCode . PUBLIC ())
380+ algorithm
381+ Error . addMultiSourceMessage(Error . INVALID_REDECLARE_AS ,
382+ {"protected element" , inName, "public" }, {inNewInfo, inOriginInfo});
390383 then
391- fail() ;
384+ false ;
392385
393- else () ;
386+ else true ;
394387 end match;
395388end checkRedeclarationVisibility;
396389
0 commit comments