Skip to content

Commit

Permalink
- Fix some duplicate declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Nov 9, 2010
1 parent 68cc076 commit ce7007f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackendDAECreate.mo
Expand Up @@ -736,7 +736,7 @@ protected function lowerVarkind
input DAE.Flow inFlow;
input DAE.Stream inStream;
input BackendDAE.BinTree inBinTree;
input option<DAE.VariableAttributes> daeAttr;
input Option<DAE.VariableAttributes> daeAttr;
output BackendDAE.VarKind outVarKind;
output BackendDAE.BinTree outBinTree;
algorithm
Expand Down
50 changes: 28 additions & 22 deletions Compiler/DFA.mo
Expand Up @@ -1484,7 +1484,7 @@ protected
Absyn.AlgorithmItem algItem;
algorithm
(dfaEnv, invalidDecls, cache) := getMatchContinueInvalidDeclsAndInitialEnv(inputVarList, resVarList, cache, localEnv, info);
checkShadowing(declList,invalidDecls);
Util.SUCCESS() := checkShadowing(declList,invalidDecls,Util.SUCCESS());
(outCache, cases) := matchContinueToSwitch2(patMat, caseLocalDecls, inputVarList, resVarList, rhlist, elseRhSide, cache, localEnv, invalidDecls, dfaEnv, info);
alg := Absyn.ALG_MATCHCASES(matchType,inputVarList,cases);
algItem := Absyn.ALGORITHMITEM(alg, NONE(), info);
Expand Down Expand Up @@ -1528,7 +1528,7 @@ algorithm

case ({}, {firstDecls}, _, _, {}, SOME(RIGHTHANDSIDE(_,body,result,_)), localCache, _, _, _, info)
equation
checkShadowing(firstDecls,invalidDecls);
Util.SUCCESS() = checkShadowing(firstDecls,invalidDecls,Util.SUCCESS());
exp2 = createListFromExpression(result,resVarList);
algs3 = createLastAssignments(resVarList,exp2,info);
algs = {};
Expand All @@ -1539,7 +1539,7 @@ algorithm
case (firstCase :: restCase, firstDecls :: restDecls,inputVarList, resVarList, RIGHTHANDSIDE(localList,body,result,_) :: restRh, elseRhSide, localCache, localEnv, invalidDecls, initialDfaEnv, info)
equation
dfaEnv = initialDfaEnv;
checkShadowing(firstDecls,invalidDecls);
Util.SUCCESS() = checkShadowing(firstDecls,invalidDecls,Util.SUCCESS());

exp2 = createListFromExpression(result,resVarList);

Expand Down Expand Up @@ -1581,8 +1581,10 @@ end getMatchContinueInvalidDeclsAndInitialEnv;
protected function checkShadowing
input list<Absyn.ElementItem> elItems;
input list<String> invalidDecls;
input Util.Status status "call with Util.SUCCESS() if no errors have occurred yet";
output Util.Status outStatus;
algorithm
_ := matchcontinue (elItems, invalidDecls)
outStatus := matchcontinue (elItems, invalidDecls, status)
local
list<String> elIdents;
list<Boolean> boolList;
Expand All @@ -1591,59 +1593,63 @@ algorithm
Absyn.ElementItem elt;
String str;

case ({}, _) then ();
case ({}, _, status) then status;

case (Absyn.ELEMENTITEM(Absyn.ELEMENT(info = info, specification = spec)) :: elItems, invalidDecls)
case (Absyn.ELEMENTITEM(Absyn.ELEMENT(info = info, specification = spec)) :: elItems, invalidDecls, status)
equation
elIdents = getElementSpecComponentNames(spec);
checkShadowing2(info, elIdents, invalidDecls);
checkShadowing(elItems, invalidDecls);
then ();
status = checkShadowing2(info, elIdents, invalidDecls, status);
status = checkShadowing(elItems, invalidDecls, status);
then status;

case ((elt as Absyn.ELEMENTITEM(Absyn.ELEMENT(info = info, specification = spec))) :: elItems, invalidDecls)
case ((elt as Absyn.ELEMENTITEM(Absyn.ELEMENT(info = info, specification = spec))) :: elItems, invalidDecls, status)
equation
failure(_ = getElementSpecComponentNames(spec));
str = Dump.unparseElementitemStr(0,elt);
Error.addSourceMessage(Error.META_INVALID_LOCAL_ELEMENT, {str}, info);
then fail();
then Util.FAILURE();
end matchcontinue;
end checkShadowing;

protected function checkShadowing2
input Absyn.Info info;
input list<String> elIdents;
input list<String> invalidDecls;
input Util.Status status;
output Util.Status outStatus;
algorithm
_ := matchcontinue (info, elIdents, invalidDecls)
outStatus := matchcontinue (info, elIdents, invalidDecls, status)
local
String elIdent;

case (_, {}, _) then ();
case (_, {}, _, status) then status;

case (info, elIdent::elIdents, invalidDecls)
case (info, elIdent::elIdents, invalidDecls, status)
equation
checkShadowing3(info,elIdent,invalidDecls);
checkShadowing2(info,elIdents,invalidDecls);
then ();
status = checkShadowing3(info,elIdent,invalidDecls,status);
status = checkShadowing2(info,elIdents,invalidDecls,status);
then status;
end matchcontinue;
end checkShadowing2;

protected function checkShadowing3
input Absyn.Info info;
input String elIdent;
input list<String> invalidDecls;
input Util.Status status;
output Util.Status outStatus;
algorithm
_ := matchcontinue (info, elIdent, invalidDecls)
outStatus := matchcontinue (info, elIdent, invalidDecls, status)

case (_, elIdent, invalidDecls)
case (_, elIdent, invalidDecls, status)
equation
false = listMember(elIdent, invalidDecls);
then ();
then status;

case (info, elIdent, _)
case (info, elIdent, _, status)
equation
Error.addSourceMessage(Error.MATCH_SHADOWING, {elIdent}, info);
then fail();
then Util.FAILURE();
end matchcontinue;
end checkShadowing3;

Expand Down
23 changes: 10 additions & 13 deletions Compiler/Inst.mo
Expand Up @@ -8296,15 +8296,15 @@ algorithm
Absyn.Path t;
SCode.Mod m;
Option<SCode.Comment> comment;
DAE.Mod cmod,m_1,classmod,mm,mod,mod_1,mod_2,mod_3,mods,mods_original;
DAE.Mod cmod,m_1,classmod,mm,mod_1,mod_2,mod_3,mods,mods_original;
SCode.Class cl;
list<Env.Frame> cenv,env2,compenv,env2_1,env_1;
list<Absyn.ComponentRef> crefs,crefs2,crefs3,crefs_1,crefs_2;
Connect.Sets csets,csets_1;
Connect.Sets csets_1;
Option<DAE.EqMod> eq;
list<DAE.Dimension> dims;
DAE.Binding binding,binding_1;
Absyn.ComponentRef cref,owncref;
Absyn.ComponentRef owncref;
Option<Absyn.Exp> cond;
DAE.Var tyVar;
Env.InstStatus is;
Expand Down Expand Up @@ -8406,23 +8406,21 @@ algorithm
local
tuple<DAE.TType, Option<Absyn.Path>> ty;
String n,id,str,str2,str3;
Boolean finalPrefix,repl,prot,flowPrefix,streamPrefix;
list<Absyn.Subscript> ad,subscr;
Boolean repl,flowPrefix,streamPrefix;
list<Absyn.Subscript> subscr;
SCode.Accessibility acc;
SCode.Variability param;
Absyn.Direction dir;
Absyn.Path t;
SCode.Mod m;
Option<SCode.Comment> comment;
DAE.Mod cmod,m_1,classmod,mm,mod,mod_1,mod_2,mod_3,mods;
SCode.Class cl;
list<Env.Frame> cenv,env2,compenv,env2_1,env_1;
DAE.Mod m_1,classmod,mm,mod_1,mod_2,mod_3,mods;
list<Env.Frame> env2,compenv,env2_1,env_1;
list<Absyn.ComponentRef> crefs,crefs2,crefs3,crefs_1,crefs_2;
Connect.Sets csets,csets_1;
Connect.Sets csets_1;
Option<DAE.EqMod> eq;
list<DAE.Dimension> dims;
DAE.Binding binding,binding_1;
Absyn.ComponentRef cref,owncref;
Absyn.ComponentRef owncref;
Option<Absyn.Exp> cond;
DAE.Var tyVar;
Env.InstStatus is;
Expand Down Expand Up @@ -14027,8 +14025,7 @@ algorithm
(outCache,outEnv,outIH,outSets,outUpdatedComps) :=
matchcontinue (cache,env,inIH,pre,mod,crefs,ci_state,csets,impl,updatedComps)
local
list<Env.Frame> env_1,env_2,env;
Connect.Sets csets;
list<Env.Frame> env_1,env_2;
DAE.Mod mods;
Absyn.ComponentRef cr;
list<Absyn.ComponentRef> rest;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Mod.mo
Expand Up @@ -1157,7 +1157,7 @@ end lookupCompModification12;

protected function lookupComplexCompModification "Lookups a component modification from a complex constructor
(e.g. record constructor) by name."
input option<DAE.EqMod> eqMod;
input Option<DAE.EqMod> eqMod;
input Absyn.Ident n;
input Boolean finalPrefix;
input Absyn.Each each_;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Static.mo
Expand Up @@ -8780,7 +8780,7 @@ functiontree of a newly created dae"
input Env.Env env;
input Absyn.Path name;
input Boolean builtin "builtin functions create empty dae";
input option<SCode.Class> clOpt "if not present, looked up by name in environment";
input Option<SCode.Class> clOpt "if not present, looked up by name in environment";
input Boolean printErrorMsg "if true, prints an error message if the function could not be instantiated";
output Env.Cache outCache;
output Util.Status status;
Expand All @@ -8794,7 +8794,7 @@ functiontree of a newly created dae"
input Env.Env env;
input Absyn.Path name;
input Boolean builtin "builtin functions create empty dae";
input option<SCode.Class> clOpt "if not present, looked up by name in environment";
input Option<SCode.Class> clOpt "if not present, looked up by name in environment";
input Integer numError "if errors were added, do not add a generic error message";
input Boolean printErrorMsg "if true, prints an error message if the function could not be instantiated";
output Env.Cache outCache;
Expand Down
18 changes: 9 additions & 9 deletions Compiler/Types.mo
Expand Up @@ -5184,13 +5184,13 @@ algorithm
(out,t) := matchcontinue (elist,typeList,printFailtrace)
local
DAE.Exp e;
Type ty, superType;
Type ty, st;
case ({},{},_) then ({}, (DAE.T_NOTYPE(),NONE()));
case (e :: _, ty :: _,printFailtrace)
equation
superType = Util.listReduce(typeList, superType);
elist = listMatchSuperType2(elist,typeList,superType,printFailtrace);
then (elist, superType);
st = Util.listReduce(typeList, superType);
elist = listMatchSuperType2(elist,typeList,st,printFailtrace);
then (elist, st);
case (_,_,_)
equation
Debug.fprintln("failtrace", "- Types.listMatchSuperType failed");
Expand All @@ -5201,22 +5201,22 @@ end listMatchSuperType;
protected function listMatchSuperType2
input list<DAE.Exp> elist;
input list<Type> typeList;
input Type superType;
input Type st;
input Boolean printFailtrace;
output list<DAE.Exp> out;
algorithm
out := matchcontinue (elist, typeList, superType, printFailtrace)
out := matchcontinue (elist, typeList, st, printFailtrace)
local
DAE.Exp e;
list<DAE.Exp> erest;
Type t;
list<Type> trest;
String str;
case ({},{},_,_) then {};
case (e::erest, t::trest, superType, printFailtrace)
case (e::erest, t::trest, st, printFailtrace)
equation
(e,t) = matchType(e,t,superType,printFailtrace);
erest = listMatchSuperType2(erest,trest,superType,printFailtrace);
(e,t) = matchType(e,t,st,printFailtrace);
erest = listMatchSuperType2(erest,trest,st,printFailtrace);
then (e::erest);
case (e::_,_,_,_)
equation
Expand Down

0 comments on commit ce7007f

Please sign in to comment.