Skip to content

Commit fe922ff

Browse files
committed
- Removed checks for duplicate elements and type names that are the same as the
component name from SCodeUtil. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15551 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 70ad1c0 commit fe922ff

File tree

3 files changed

+4
-71
lines changed

3 files changed

+4
-71
lines changed

Compiler/FrontEnd/NFSCodeCheck.mo

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -52,65 +52,6 @@ protected import List;
5252
protected import SCodeDump;
5353
protected import Util;
5454

55-
public function checkDuplicateElements
56-
input SCode.Program inProgram;
57-
algorithm
58-
_ := match(inProgram)
59-
local
60-
SCode.Program sp;
61-
list<String> names;
62-
63-
case (sp)
64-
equation
65-
names = SCode.elementNames(sp);
66-
names = List.sort(names,Util.strcmpBool);
67-
(_,names) = Util.splitUniqueOnBool(names,stringEqual);
68-
checkForDuplicateElements(names,sp);
69-
List.map_0(sp,checkDuplicateElementsInClass);
70-
then ();
71-
end match;
72-
end checkDuplicateElements;
73-
74-
public function checkDuplicateElementsInClass
75-
input SCode.Element el;
76-
algorithm
77-
_ := match el
78-
local
79-
SCode.Program sp;
80-
list<SCode.Element> elts;
81-
Absyn.Info info;
82-
83-
case SCode.CLASS(classDef=SCode.PARTS(elementLst=elts),info=info)
84-
equation
85-
checkDuplicateElements(elts);
86-
then ();
87-
case SCode.CLASS(classDef=SCode.CLASS_EXTENDS(composition=SCode.PARTS(elementLst=elts)),info=info)
88-
equation
89-
checkDuplicateElements(elts);
90-
then ();
91-
else ();
92-
end match;
93-
end checkDuplicateElementsInClass;
94-
95-
protected function checkForDuplicateElements
96-
"Verifies that the input is empty; else an error message is printed"
97-
input list<String> duplicateNames;
98-
input SCode.Program program;
99-
algorithm
100-
_ := match (duplicateNames,program)
101-
local
102-
String msg,id;
103-
SCode.Element elt;
104-
case ({},_) then ();
105-
case (id::_,_)
106-
equation
107-
elt = SCode.getElementNamedFromElts(id,program);
108-
msg = stringDelimitList(duplicateNames, ",");
109-
Error.addSourceMessage(Error.DOUBLE_DECLARATION_OF_ELEMENTS,{msg},SCode.elementInfo(elt));
110-
then fail();
111-
end match;
112-
end checkForDuplicateElements;
113-
11455
public function checkRecursiveShortDefinition
11556
input Absyn.TypeSpec inTypeSpec;
11657
input String inTypeName;

Compiler/FrontEnd/NFSCodeEnv.mo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,11 @@ protected function extendEnvWithVar
725725
protected
726726
String var_name;
727727
Util.StatefulBoolean is_used;
728+
Absyn.TypeSpec ty;
729+
Absyn.Info info;
728730
algorithm
729-
SCode.COMPONENT(name = var_name) := inVar;
731+
SCode.COMPONENT(name = var_name, typeSpec = ty, info = info) := inVar;
732+
true := NFSCodeCheck.checkIdentNotEqTypeName(var_name, ty, info);
730733
is_used := Util.makeStatefulBoolean(false);
731734
outEnv := extendEnvWithItem(VAR(inVar, SOME(is_used)), inEnv, var_name);
732735
end extendEnvWithVar;

Compiler/FrontEnd/SCodeUtil.mo

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ protected import MetaUtil;
6060
protected import System;
6161
protected import Types;
6262
protected import Util;
63-
protected import NFSCodeCheck;
6463
protected import NFSCodeFlatten;
6564
protected import SCodeDump;
6665

@@ -107,15 +106,6 @@ algorithm
107106
spAbsyn = List.fold(inClasses, translate2, {});
108107
spAbsyn = listReverse(spAbsyn);
109108

110-
// NOTE: we check duplicates separately for builtin
111-
// and for absyn to allow duplicates of
112-
// ModelicaBuiltin.mo and MetaModelicaBuiltin.mo
113-
114-
// check duplicates in builtin (initial) functions
115-
NFSCodeCheck.checkDuplicateElements(spInitial);
116-
// check duplicates in absyn
117-
NFSCodeCheck.checkDuplicateElements(spAbsyn);
118-
119109
sp = listAppend(spInitial, spAbsyn);
120110
then
121111
sp;
@@ -1458,7 +1448,6 @@ algorithm
14581448
(attr as Absyn.ATTR(flowPrefix = fl,streamPrefix=st,parallelism=parallelism,variability = variability,direction = di,arrayDim = ad)),typeSpec = t,
14591449
components = (Absyn.COMPONENTITEM(component = Absyn.COMPONENT(name = n,arrayDim = d,modification = m),comment = comment,condition=cond) :: xs)),info)
14601450
equation
1461-
true = NFSCodeCheck.checkIdentNotEqTypeName(n, t, info);
14621451
// Debug.fprintln(Flags.TRANSLATE, "translating component: " +& n +& " final: " +& SCode.finalStr(SCode.boolFinal(finalPrefix)));
14631452
setHasInnerOuterDefinitionsHandler(io); // signal the external flag that we have inner/outer definitions
14641453
setHasStreamConnectorsHandler(st); // signal the external flag that we have stream connectors

0 commit comments

Comments
 (0)