Skip to content

Commit

Permalink
- Removed checks for duplicate elements and type names that are the s…
Browse files Browse the repository at this point in the history
…ame as the

component name from SCodeUtil.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15551 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Mar 12, 2013
1 parent 70ad1c0 commit fe922ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 71 deletions.
59 changes: 0 additions & 59 deletions Compiler/FrontEnd/NFSCodeCheck.mo
Expand Up @@ -52,65 +52,6 @@ protected import List;
protected import SCodeDump;
protected import Util;

public function checkDuplicateElements
input SCode.Program inProgram;
algorithm
_ := match(inProgram)
local
SCode.Program sp;
list<String> names;

case (sp)
equation
names = SCode.elementNames(sp);
names = List.sort(names,Util.strcmpBool);
(_,names) = Util.splitUniqueOnBool(names,stringEqual);
checkForDuplicateElements(names,sp);
List.map_0(sp,checkDuplicateElementsInClass);
then ();
end match;
end checkDuplicateElements;

public function checkDuplicateElementsInClass
input SCode.Element el;
algorithm
_ := match el
local
SCode.Program sp;
list<SCode.Element> elts;
Absyn.Info info;

case SCode.CLASS(classDef=SCode.PARTS(elementLst=elts),info=info)
equation
checkDuplicateElements(elts);
then ();
case SCode.CLASS(classDef=SCode.CLASS_EXTENDS(composition=SCode.PARTS(elementLst=elts)),info=info)
equation
checkDuplicateElements(elts);
then ();
else ();
end match;
end checkDuplicateElementsInClass;

protected function checkForDuplicateElements
"Verifies that the input is empty; else an error message is printed"
input list<String> duplicateNames;
input SCode.Program program;
algorithm
_ := match (duplicateNames,program)
local
String msg,id;
SCode.Element elt;
case ({},_) then ();
case (id::_,_)
equation
elt = SCode.getElementNamedFromElts(id,program);
msg = stringDelimitList(duplicateNames, ",");
Error.addSourceMessage(Error.DOUBLE_DECLARATION_OF_ELEMENTS,{msg},SCode.elementInfo(elt));
then fail();
end match;
end checkForDuplicateElements;

public function checkRecursiveShortDefinition
input Absyn.TypeSpec inTypeSpec;
input String inTypeName;
Expand Down
5 changes: 4 additions & 1 deletion Compiler/FrontEnd/NFSCodeEnv.mo
Expand Up @@ -725,8 +725,11 @@ protected function extendEnvWithVar
protected
String var_name;
Util.StatefulBoolean is_used;
Absyn.TypeSpec ty;
Absyn.Info info;
algorithm
SCode.COMPONENT(name = var_name) := inVar;
SCode.COMPONENT(name = var_name, typeSpec = ty, info = info) := inVar;
true := NFSCodeCheck.checkIdentNotEqTypeName(var_name, ty, info);
is_used := Util.makeStatefulBoolean(false);
outEnv := extendEnvWithItem(VAR(inVar, SOME(is_used)), inEnv, var_name);
end extendEnvWithVar;
Expand Down
11 changes: 0 additions & 11 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -60,7 +60,6 @@ protected import MetaUtil;
protected import System;
protected import Types;
protected import Util;
protected import NFSCodeCheck;
protected import NFSCodeFlatten;
protected import SCodeDump;

Expand Down Expand Up @@ -107,15 +106,6 @@ algorithm
spAbsyn = List.fold(inClasses, translate2, {});
spAbsyn = listReverse(spAbsyn);

// NOTE: we check duplicates separately for builtin
// and for absyn to allow duplicates of
// ModelicaBuiltin.mo and MetaModelicaBuiltin.mo

// check duplicates in builtin (initial) functions
NFSCodeCheck.checkDuplicateElements(spInitial);
// check duplicates in absyn
NFSCodeCheck.checkDuplicateElements(spAbsyn);

sp = listAppend(spInitial, spAbsyn);
then
sp;
Expand Down Expand Up @@ -1458,7 +1448,6 @@ algorithm
(attr as Absyn.ATTR(flowPrefix = fl,streamPrefix=st,parallelism=parallelism,variability = variability,direction = di,arrayDim = ad)),typeSpec = t,
components = (Absyn.COMPONENTITEM(component = Absyn.COMPONENT(name = n,arrayDim = d,modification = m),comment = comment,condition=cond) :: xs)),info)
equation
true = NFSCodeCheck.checkIdentNotEqTypeName(n, t, info);
// Debug.fprintln(Flags.TRANSLATE, "translating component: " +& n +& " final: " +& SCode.finalStr(SCode.boolFinal(finalPrefix)));
setHasInnerOuterDefinitionsHandler(io); // signal the external flag that we have inner/outer definitions
setHasStreamConnectorsHandler(st); // signal the external flag that we have stream connectors
Expand Down

0 comments on commit fe922ff

Please sign in to comment.