Skip to content

Commit

Permalink
Added protected/public flag to DAE.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2741 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 5, 2007
1 parent 23ec061 commit e4d903e
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 112 deletions.
17 changes: 8 additions & 9 deletions Compiler/Codegen.mo
Expand Up @@ -1311,10 +1311,8 @@ algorithm
list<Absyn.Path> cl;
Option<DAE.VariableAttributes> dae_var_attr;
Option<Absyn.Comment> comment;
case ((el as DAE.VAR(componentRef = cr,varible = vk,variable = vd,input_ = ty,binding = {},dimension = st,value = fl,flow_ = cl,variableAttributesOption = dae_var_attr,absynCommentOption = comment))) /*
axiom is_array DAE.VAR(cr,vk,vd,ty,_,{},st,fl,cl) => false
axiom is_array DAE.VAR(cr,vk,vd,ty,_,_::_,st,fl,cl) => true
*/
case ((el as DAE.VAR(componentRef = cr,varible = vk,variable = vd,input_ = ty,binding = {},dimension = st,value = fl,flow_ = cl,variableAttributesOption = dae_var_attr,absynCommentOption = comment)))

equation
Debug.fcall("isarrdb", DAE.dump2, DAE.DAE({el}));
then
Expand Down Expand Up @@ -3118,6 +3116,7 @@ algorithm
Exp.Exp e;
Types.Type tp;
Absyn.InnerOuter io;
DAE.VarProtection prot;
case ((var as DAE.VAR(componentRef = id,varible = vk,variable = vd,input_ = typ,one = NONE,binding = inst_dims,dimension = start,value = flow_,flow_ = class_,variableAttributesOption = dae_var_attr,absynCommentOption = comment)),tnr,context)
equation
is_a = isArray(var);
Expand All @@ -3133,10 +3132,10 @@ algorithm
cfn = cAddVariables(cEmptyFunction, {decl_str});
then
(cfn,tnr);
case ((var as DAE.VAR(componentRef = id,varible = vk,variable = vd,input_ = typ,one = SOME(e),binding = inst_dims,dimension = start,value = flow_,flow_ = class_,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=tp)),tnr,context)
case ((var as DAE.VAR(componentRef = id,varible = vk,variable = vd,protection=prot,input_ = typ,one = SOME(e),binding = inst_dims,dimension = start,value = flow_,flow_ = class_,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=tp)),tnr,context)
equation
(cfn,tnr1) = generateVarDecl(
DAE.VAR(id,vk,vd,typ,NONE,inst_dims,start,flow_,class_,
DAE.VAR(id,vk,vd,prot,typ,NONE,inst_dims,start,flow_,class_,
dae_var_attr,comment,io,tp), tnr, context);
then
(cfn,tnr1);
Expand Down Expand Up @@ -5615,17 +5614,17 @@ algorithm
Types.Type tp;
Boolean b_isOutput;
Integer i1;

DAE.VarProtection prot;
case ({},i,tnr) then (cEmptyFunction,tnr);
case ((var :: rest),i,tnr)
equation
DAE.VAR(componentRef = cref,varible = vk,variable = vd,input_ = ty,one = value,binding = dims,dimension = start,fullType=tp) = var;
DAE.VAR(componentRef = cref,varible = vk,variable = vd,protection=prot,input_ = ty,one = value,binding = dims,dimension = start,fullType=tp) = var;
true = isArray(var);
b_isOutput = isOutput(var);
i1 = Util.if_(b_isOutput,i+1,i);
cref_1 = varNameExternalCref(cref);
dims_1 = listReverse(dims);
extvar = DAE.VAR(cref_1,vk,vd,ty,value,dims_1,NONE,DAE.NON_FLOW(),{},NONE,
extvar = DAE.VAR(cref_1,vk,vd,prot,ty,value,dims_1,NONE,DAE.NON_FLOW(),{},NONE,
NONE,Absyn.UNSPECIFIED(),tp);
(fn,tnr_1) = generateVarDecl(extvar, tnr, funContext);
(restfn,tnr_3) = generateExtcallCopydeclsF77(rest, i1,tnr_1);
Expand Down
26 changes: 18 additions & 8 deletions Compiler/DAE.mo
Expand Up @@ -126,12 +126,18 @@ uniontype VarDirection

end VarDirection;

uniontype VarProtection
record PUBLIC "public variables" end PUBLIC;
record PROTECTED "protected variables" end PROTECTED;
end VarProtection;

public
uniontype Element
record VAR
Exp.ComponentRef componentRef " The variable name";
VarKind varible "varible kind" ;
VarDirection variable "variable, constant, parameter, etc." ;
VarProtection protection "if protected or public";
Type input_ "input, output or bidir" ;
Option<Exp.Exp> one "one of the builtin types" ;
InstDims binding "Binding expression e.g. for parameters" ;
Expand Down Expand Up @@ -451,11 +457,12 @@ algorithm
Option<Absyn.Comment> cmt;
Absyn.InnerOuter io,io2;
Types.Type ftp;
VarProtection prot;
case(var,{}) then {};
case(var,VAR(cr,kind,dir,tp,bind,dim,start,flow_,cls,attr,cmt,io,ftp)::dae) equation
case(var,VAR(cr,kind,dir,prot,tp,bind,dim,start,flow_,cls,attr,cmt,io,ftp)::dae) equation
true = Exp.crefEqual(var,cr);
io2 = removeInnerAttribute(io);
then VAR(cr,kind,dir,tp,bind,dim,start,flow_,cls,attr,cmt,io2,ftp)::dae;
then VAR(cr,kind,dir,prot,tp,bind,dim,start,flow_,cls,attr,cmt,io2,ftp)::dae;
case(var,COMP(id,DAE(elist))::dae) equation
elist2=removeInnerAttr(var,elist);
dae = removeInnerAttr(var,dae);
Expand Down Expand Up @@ -2662,12 +2669,13 @@ algorithm
Element x;
Absyn.InnerOuter io;
Types.Type ftp;
VarProtection prot;
case ({},_) then {};
case ((VAR(componentRef = cr,varible = kind,variable = dir,input_ = tp,one = bind,binding = dim,dimension = start,value = flow_,flow_ = lst,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=ftp) :: xs),newtype)
case ((VAR(componentRef = cr,varible = kind,variable = dir, protection=prot,input_ = tp,one = bind,binding = dim,dimension = start,value = flow_,flow_ = lst,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=ftp) :: xs),newtype)
equation
xs_1 = setComponentType(xs, newtype);
then
(VAR(cr,kind,dir,tp,bind,dim,start,flow_,(newtype :: lst),
(VAR(cr,kind,dir,prot,tp,bind,dim,start,flow_,(newtype :: lst),
dae_var_attr,comment,io,ftp) :: xs_1);
case ((x :: xs),newtype)
equation
Expand Down Expand Up @@ -3257,6 +3265,7 @@ algorithm
Exp.ComponentRef a;
VarKind b;
VarDirection c;
VarProtection prot;
Type d;
Option<Exp.Exp> e,g;
InstDims f;
Expand All @@ -3266,11 +3275,11 @@ algorithm
Option<Absyn.Comment> comment;
Absyn.InnerOuter io;
Types.Type tp;
case (VAR(componentRef = a,varible = b,variable = c,input_ = d,one = e,binding = f,dimension = g,value = h,flow_ = i,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=tp) :: lst)
case (VAR(componentRef = a,varible = b,variable = c,protection = prot,input_ = d,one = e,binding = f,dimension = g,value = h,flow_ = i,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=tp) :: lst)
equation
res = getVariableList(lst);
then
(VAR(a,b,c,d,e,f,g,h,i,dae_var_attr,comment,io,tp) :: res);
(VAR(a,b,c,prot,d,e,f,g,h,i,dae_var_attr,comment,io,tp) :: res);
case (_ :: lst)
equation
res = getVariableList(lst);
Expand Down Expand Up @@ -3486,15 +3495,16 @@ algorithm
tuple<Types.TType, Option<Absyn.Path>> t;
Types.Type tp;
Absyn.InnerOuter io;
VarProtection prot;
case ({}) then {};
case ((VAR(componentRef = cr,varible = a,variable = b,input_ = c,one = d,binding = e,dimension = f,value = g,flow_ = h,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=tp) :: elts))
case ((VAR(componentRef = cr,varible = a,variable = b,protection=prot,input_ = c,one = d,binding = e,dimension = f,value = g,flow_ = h,variableAttributesOption = dae_var_attr,absynCommentOption = comment,innerOuter=io,fullType=tp) :: elts))
equation
str = Exp.printComponentRefStr(cr);
str_1 = Util.stringReplaceChar(str, ".", "_");
elts_1 = toModelicaFormElts(elts);
d_1 = toModelicaFormExpOpt(d);
then
(VAR(Exp.CREF_IDENT(str_1,{}),a,b,c,d_1,e,f,g,h,dae_var_attr,
(VAR(Exp.CREF_IDENT(str_1,{}),a,b,prot,c,d_1,e,f,g,h,dae_var_attr,
comment,io,tp) :: elts_1);
case ((DEFINE(componentRef = cr,exp = e) :: elts))
local Exp.Exp e;
Expand Down

0 comments on commit e4d903e

Please sign in to comment.