Skip to content

Commit

Permalink
- Removed check for redeclaration of protected elements, since it's a…
Browse files Browse the repository at this point in the history
…ctually

  allowed.
- Implemented support for cardinality of connector arrays.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10616 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Nov 30, 2011
1 parent cd44d7a commit 3c72b90
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 56 deletions.
52 changes: 25 additions & 27 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -2148,51 +2148,41 @@ protected function cevalBuiltinCardinality "function: cevalBuiltinCardinality
input Env.Env inEnv;
input list<DAE.Exp> inExpExpLst;
input Boolean inBoolean;
input Option<Interactive.SymbolTable> inInteractiveInteractiveSymbolTableOption;
input Option<Interactive.SymbolTable> inST;
input Msg inMsg;
output Env.Cache outCache;
output Values.Value outValue;
output Option<Interactive.SymbolTable> outInteractiveInteractiveSymbolTableOption;
output Option<Interactive.SymbolTable> outST;
protected
DAE.Exp exp;
algorithm
(outCache,outValue,outInteractiveInteractiveSymbolTableOption):=
match (inCache,inEnv,inExpExpLst,inBoolean,inInteractiveInteractiveSymbolTableOption,inMsg)
local
Integer cnt;
list<Env.Frame> env;
DAE.ComponentRef cr;
Boolean impl;
Option<Interactive.SymbolTable> st;
Msg msg;
Env.Cache cache;
case (cache,env,{DAE.CREF(componentRef = cr)},impl,st,msg)
equation
(cache,cnt) = cevalCardinality(cache,env, cr);
then
(cache,Values.INTEGER(cnt),st);
end match;
outCache := inCache;
outST := inST;
{exp} := inExpExpLst;
outValue := cevalCardinality(exp, inEnv);
end cevalBuiltinCardinality;

protected function cevalCardinality "function: cevalCardinality
author: PA
counts the number of connect occurences of the
component ref in equations in current scope."
input Env.Cache inCache;
input DAE.Exp inExp;
input Env.Env inEnv;
input DAE.ComponentRef inComponentRef;
output Env.Cache outCache;
output Integer outInteger;
output Values.Value outValue;
algorithm
(outCache,outInteger) :=
match (inCache,inEnv,inComponentRef)
outValue := match(inExp, inEnv)
local
Env.Env env;
list<DAE.ComponentRef> cr_lst,cr_lst2,cr_totlst,crs;
Integer res;
Integer res, dim;
DAE.ComponentRef cr;
Env.Cache cache;
DAE.ComponentRef prefix,currentPrefix;
Absyn.Ident currentPrefixIdent;
case (cache,env ,cr)
list<DAE.Exp> expl;
list<Values.Value> vals;

case (DAE.CREF(componentRef = cr), env)
equation
(env as (Env.FRAME(connectionSet = (crs,prefix))::_)) = Env.stripForLoopScope(env);
cr_lst = List.select1(crs, ComponentReference.crefContainedIn, cr);
Expand All @@ -2216,7 +2206,15 @@ algorithm
print("prefix =");print(ComponentReference.printComponentRefStr(prefix));print("\n");*/
// print("env:");print(Env.printEnvStr(env));
then
(cache,res);
Values.INTEGER(res);

case (DAE.ARRAY(array = expl), _)
equation
vals = List.map1(expl, cevalCardinality, inEnv);
dim = listLength(vals);
then
Values.ARRAY(vals, {dim});

end match;
end cevalCardinality;

Expand Down
25 changes: 0 additions & 25 deletions Compiler/FrontEnd/SCodeCheck.mo
Expand Up @@ -339,7 +339,6 @@ algorithm
ty = "component";
checkRedeclarationReplaceable(name, ty, repl, inInfo, info);
checkRedeclarationFinal(name, ty, fin, inInfo, info);
checkRedeclarationVisibility(name, ty, vis, inInfo, info);
checkRedeclarationVariability(name, ty, var, inInfo, info);
true = intEq(err_count, Error.getNumErrorMessages());
then
Expand All @@ -358,7 +357,6 @@ algorithm
ty = SCodeDump.restrictionStringPP(res);
checkRedeclarationReplaceable(name, ty, repl, inInfo, info);
checkRedeclarationFinal(name, ty, fin, inInfo, info);
checkRedeclarationVisibility(name, ty, vis, inInfo, info);
true = intEq(err_count, Error.getNumErrorMessages());
then
();
Expand Down Expand Up @@ -388,29 +386,6 @@ algorithm
end match;
end checkRedeclarationReplaceable;

protected function checkRedeclarationVisibility
input SCode.Ident inName;
input String inType;
input SCode.Visibility inVisibility;
input Absyn.Info inOriginInfo;
input Absyn.Info inInfo;
algorithm
_ := match(inName, inType, inVisibility, inOriginInfo, inInfo)
local
String err_str;

case (_, _, SCode.PROTECTED(), _, _)
equation
err_str = "protected " +& inType +& " " +& inName;
Error.addSourceMessage(Error.ERROR_FROM_HERE, {}, inOriginInfo);
Error.addSourceMessage(Error.INVALID_REDECLARE, {err_str}, inInfo);
then
();

case (_, _, SCode.PUBLIC(), _, _) then ();
end match;
end checkRedeclarationVisibility;

protected function checkRedeclarationFinal
input SCode.Ident inName;
input String inType;
Expand Down
10 changes: 6 additions & 4 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -2939,12 +2939,14 @@ algorithm
Env.Cache cache;
Prefix.Prefix pre;

case (cache,env,{(exp as Absyn.CREF(componentRef = cr))},_,impl,pre,info)
case (cache, env, {exp}, _, impl, pre, info)
equation
(cache,(exp_1 as DAE.CREF(cr_1,_)),DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
exp_1 = Expression.makeBuiltinCall("cardinality", {exp_1}, DAE.T_INTEGER_DEFAULT);
(cache, exp_1, DAE.PROP(tp1, _), _) =
elabExp(cache, env, exp, impl, NONE(), true, pre, info);
tp1 = Types.liftArrayListDims(DAE.T_INTEGER_DEFAULT, Types.getDimensions(tp1));
exp_1 = Expression.makeBuiltinCall("cardinality", {exp_1}, tp1);
then
(cache, exp_1, DAE.PROP(DAE.T_INTEGER_DEFAULT,DAE.C_CONST()));
(cache, exp_1, DAE.PROP(tp1, DAE.C_CONST()));
end match;
end elabBuiltinCardinality;

Expand Down

0 comments on commit 3c72b90

Please sign in to comment.