Skip to content

Commit

Permalink
corrected a bug concerning the " constant Real Coeff[3]={-5,-5,-5};"
Browse files Browse the repository at this point in the history
this could not be instatiated because Coeff[2] could not be found

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2385 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x02lucpo committed May 17, 2006
1 parent 0c13278 commit 79d6e05
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 48 deletions.
12 changes: 6 additions & 6 deletions Compiler/Ceval.mo
Expand Up @@ -76,6 +76,7 @@ public import OpenModelica.Compiler.DAELow;

public import OpenModelica.Compiler.Absyn;

public import OpenModelica.Compiler.Types;
public
uniontype Msg
record MSG "Give error message" end MSG;
Expand All @@ -90,8 +91,6 @@ protected import OpenModelica.Compiler.Static;

protected import OpenModelica.Compiler.Print;

protected import OpenModelica.Compiler.Types;

protected import OpenModelica.Compiler.ModUtil;

protected import OpenModelica.Compiler.System;
Expand Down Expand Up @@ -2522,8 +2521,8 @@ algorithm
SimCodegen.generateInitData(indexed_dlow_1, classname, filenameprefix, init_filename,
starttime_r, stoptime_r, interval_r);
makefilename = generateMakefilename(filenameprefix);
compileModel(filenameprefix, libs, file_dir) " Util.string_append_list({\"make -f \",cname_str, \".makefile\\n\"}) => s_call &
" ;
compileModel(filenameprefix, libs, file_dir);
//" Util.string_append_list({\"make -f \",cname_str, \".makefile\\n\"}) => s_call &"
then
(filenameprefix,method_str,st,init_filename);
case (_,_,_,_)
Expand Down Expand Up @@ -5085,9 +5084,9 @@ algorithm
end matchcontinue;
end cevalCref;

protected function cevalCrefBinding "function: cevalCrefBinding
public function cevalCrefBinding "function: cevalCrefBinding
Helper function to ceval_cref. Evaluates varaibles by evaluating
Helper function to ceval_cref. Evaluates variables by evaluating
their bindings.
signature: ceval_cref_binding : (Env.Env, Exp.ComponentRef,
Expand Down Expand Up @@ -5118,6 +5117,7 @@ algorithm
Exp.Exp elexp,iterexp,exp;
case (env,cr,Types.VALBOUND(valBound = v),impl,msg) /* Exp.CREF_IDENT(id,subsc) */
equation
Debug.fprint("tcvt", "+++++++ cevalCrefBinding Types.VALBOUND\n");
cr_1 = Exp.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;
subsc = Exp.crefLastSubs(cr);
(_,tp,_) = Lookup.lookupVar(env, cr_1) "Exp.CREF_IDENT(id,{})" ;
Expand Down
98 changes: 60 additions & 38 deletions Compiler/Lookup.mo
Expand Up @@ -85,6 +85,8 @@ protected import OpenModelica.Compiler.Connect;

protected import OpenModelica.Compiler.Error;

protected import OpenModelica.Compiler.Values;

public function lookupType "adrpo -- not used
with \"Util.rml\"
with \"Print.rml\"
Expand Down Expand Up @@ -1943,52 +1945,71 @@ algorithm
end matchcontinue;
end checkSubscripts;

protected function lookupInVar "function: lookupInVar
Searches for the rest of a qualified variable when first part of
variable name has been found.
protected function checkSubscriptsBinding "function: checkSubscriptsBinding
This function checks a list of subscripts agains type, and removes
dimensions from the type according to the subscripting.
"
input Types.Type inType;
input Exp.ComponentRef inComponentRef;
output Types.Attributes outAttributes;
output Types.Type outType;
input Types.Binding inBinding;
input list<Exp.Subscript> inExpSubscriptLst;
output Types.Binding outBinding;
algorithm
(outAttributes,outType,outBinding):=
matchcontinue (inType,inComponentRef)
outBinding:=
matchcontinue (inType,inBinding,inExpSubscriptLst)
local
Boolean fl;
SCode.Accessibility acc;
SCode.Variability vt;
Absyn.Direction di;
tuple<Types.TType, Option<Absyn.Path>> ty_1,ty_2,ty,ty_3;
Types.Binding t,t_1;
Types.ArrayDim dim;
Option<Absyn.Path> p;
list<Exp.Subscript> ys,s;
Integer sz,ind;
list<Exp.Exp> se;
Types.Binding binding;
String id;
list<Exp.Subscript> ss;
Types.Attributes attr;
Exp.ComponentRef vs;
case (ty,Exp.CREF_IDENT(ident = id,subscriptLst = ss)) /* Public components */
equation
(Types.VAR(_,Types.ATTR(fl,acc,vt,di),false,ty_1,binding)) = Types.lookupComponent(ty, id);
ty_2 = checkSubscripts(ty_1, ss);
then
(Types.ATTR(fl,acc,vt,di),ty_2,binding);
case (ty,Exp.CREF_IDENT(ident = id,subscriptLst = ss)) /* Protected components */
Exp.Exp exp;
Option<Values.Value> eExp "evaluatedExp; evaluated exp" ;
Types.Const const "constant" ;
Values.Value v,v2;
case (binding,{}) then binding;
case (Types.UNBOUND(),_) then Types.UNBOUND();
case (Types.EQBOUND(exp,eExp,const),
(Exp.INDEX(a = Exp.ICONST(integer = ind)) :: ys))
equation
Debug.fprint("tcvt", "*** checkSubscriptsBinding Types.EQBOUND\n");
t_1 = checkSubscriptsBinding(Types.EQBOUND(Exp.ASUB(exp,ind),eExp,const), ys);
then
t_1;



case (Types.VALBOUND(v),(Exp.INDEX(a = Exp.ICONST(integer = ind)) :: ys))
equation
Debug.fprint("tcvt", "*** checkSubscriptsBinding before ntharrayelt Types.VALBOUND\n");
v2= Values.nthArrayelt(v,ind);
Debug.fprint("tcvt", "*** checkSubscriptsBinding after ntharrayelt Types.VALBOUND\n");
t_1 = checkSubscriptsBinding(Types.VALBOUND(v2), ys);
then t_1;


case (binding,_)
equation
Debug.fprint("tcvt", "*** checkSubscriptsBinding binding\n");


then binding;


case (binding,s)
local String str;
equation
(Types.VAR(_,_,true,_,_)) = Types.lookupComponent(ty, id);
Error.addMessage(Error.REFERENCE_PROTECTED, {id});
Debug.fprint("failtrace", "- checkSubscriptsBinding failed ( ");
str = Types.printBindingStr(binding);
Debug.fprint("failtrace", str);
Debug.fprint("failtrace", ")\n");
then
fail();
case (ty,Exp.CREF_QUAL(ident = id,subscriptLst = ss,componentRef = vs))
equation
(Types.VAR(_,Types.ATTR(fl,acc,vt,di),_,ty_1,_)) = Types.lookupComponent(ty, id);
ty_2 = checkSubscripts(ty_1, ss);
(attr,ty_3,binding) = lookupInVar(ty_2, vs);
then
(attr,ty_3,binding);
case (_,_) /* Debug.fprint(\"failtrace\", \"- lookup_in_var failed\\n\") */ then fail();
end matchcontinue;
end lookupInVar;
end checkSubscriptsBinding;



protected function lookupVarF "function: lookupVarF
Expand All @@ -2012,7 +2033,7 @@ algorithm
SCode.Variability vt;
Absyn.Direction di;
tuple<Types.TType, Option<Absyn.Path>> ty,ty_1;
Types.Binding bind,binding;
Types.Binding bind,binding,binding2;
Env.BinTree ht;
list<Exp.Subscript> ss;
list<Env.Frame> compenv;
Expand All @@ -2022,6 +2043,7 @@ algorithm
equation
(Types.VAR(n,Types.ATTR(f,acc,vt,di),_,ty,bind),_,_,_) = lookupVar2(ht, id);
ty_1 = checkSubscripts(ty, ss);
// binding2 = checkSubscriptsBinding(bind,ss);
then
(Types.ATTR(f,acc,vt,di),ty_1,bind);
case (ht,Exp.CREF_QUAL(ident = id,subscriptLst = ss,componentRef = ids)) /* Qualified variables looked up through component environment. */
Expand Down
11 changes: 10 additions & 1 deletion Compiler/Static.mo
Expand Up @@ -806,7 +806,10 @@ algorithm
(Exp.BCONST(x),Types.PROP((Types.T_BOOL({}),NONE),Types.C_CONST()));
case (env,Absyn.CREF(componentReg = cr),impl)
equation
Debug.fprint("tcvt","before elabCref in elabGraphicsExp\n");

(exp,prop,_) = elabCref(env, cr, impl);
Debug.fprint("tcvt","after elabCref in elabGraphicsExp\n");
then
(exp,prop);
case (env,(exp as Absyn.BINARY(exp1 = e1,op = op,exp2 = e2)),impl) /* Binary and unary operations */
Expand Down Expand Up @@ -5952,6 +5955,7 @@ algorithm
SCode.Variability variability_1,variability,var;
Types.Binding binding_1,bind;
Ident s,str,scope;
Types.Binding binding;
case (_,cr,acc,_,(t as (Types.T_NOTYPE(),_)),_) /* If type not yet determined, component must be referencing itself.
constantness undecidable since binding not available,
return C_VAR */
Expand All @@ -5975,8 +5979,13 @@ algorithm
e = crefVectorize(Exp.CREF(cr_1,t), tt);
then
(e,Types.C_VAR(),acc);
case (_,cr,_,SCode.CONST(),t,Types.VALBOUND(valBound = v))
case (env,cr,acc,SCode.CONST(),t,binding)
//local Exp.Type t;
equation


v = Ceval.cevalCrefBinding(env,cr,binding,false,Ceval.MSG());

e = valueExp(v);
et = Types.typeOfValue(v);
(e_1,_) = Types.matchType(e, et, t);
Expand Down
8 changes: 6 additions & 2 deletions Compiler/Types.mo
Expand Up @@ -2580,6 +2580,7 @@ algorithm
list<Type> tys_1,tys1,tys2;
list<Ident> l;
list<Var> v;
String str;
case (Exp.ARRAY(array = elist),(T_ARRAY(arrayDim = DIM(integerOption = SOME(dim1)),arrayType = ty1),_),(T_ARRAY(arrayDim = DIM(integerOption = SOME(dim2)),arrayType = ty2),p))
equation
(dim1 == dim2) = true "Array expressions" ;
Expand Down Expand Up @@ -2676,10 +2677,13 @@ algorithm
(Exp.TUPLE(elist_1),(T_TUPLE(tys_1),p2));
case (exp,(T_ENUM(),_),(T_ENUMERATION(names = l,varLst = v),p2)) then (exp,(T_ENUMERATION(l,v),p2));
case (e,(T_INTEGER(varLstInt = v),_),(T_REAL(varLstReal = _),p)) then (Exp.CAST(Exp.REAL(),e),(T_REAL(v),p));
case (_,t1,t2)
case (exp,t1,t2)
equation
Debug.fprint("tcvt", "- type conversion failed: ");
Debug.fcall("tcvt", printType, t1);
str = Exp.printExpStr(exp);
Debug.fprint("tcvt", str);
Debug.fprint("tcvt", " ");
Debug.fcall("tcvt", printType, t1);
Debug.fprint("tcvt", ", ");
Debug.fcall("tcvt", printType, t2);
Debug.fprint("tcvt", "\n");
Expand Down
3 changes: 2 additions & 1 deletion Compiler/Util.mo
Expand Up @@ -76,7 +76,8 @@ end ReplacePattern;

protected constant list<ReplacePattern> replaceStringPatterns={REPLACEPATTERN(".","$point"),
REPLACEPATTERN("[","$leftBracket"),REPLACEPATTERN("]","$rightBracket"),
REPLACEPATTERN("(","$leftParanthesis"),REPLACEPATTERN(")","$rightParanthesis"),REPLACEPATTERN(",","$comma")};
REPLACEPATTERN("(","$leftParanthesis"),REPLACEPATTERN(")","$rightParanthesis"),
REPLACEPATTERN(",","$comma")};

protected import OpenModelica.Compiler.System;

Expand Down

0 comments on commit 79d6e05

Please sign in to comment.