Skip to content

Commit e9380c1

Browse files
author
Stefan Brus
committed
- Absyn.PARTEVALFUNCTION is now turned into Exp.PARTEVALFUNCTION by static
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4456 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 3d566d1 commit e9380c1

File tree

1 file changed

+33
-97
lines changed

1 file changed

+33
-97
lines changed

Compiler/Static.mo

Lines changed: 33 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ algorithm
520520
(cache,e,prop,st_1) = elabPartEvalFunction(cache,env,e1,st,impl,doVect);
521521
then
522522
(cache,e,prop,st_1);*/
523+
case (cache,env,e1 as Absyn.PARTEVALFUNCTION(function_ = _),impl,st,doVect)
524+
local Exp.Exp e;
525+
equation
526+
(cache,e,prop,st_1) = elabPartEvalFunction(cache,env,e1,st,impl,doVect);
527+
then
528+
(cache,e,prop,st_1);
523529
case (cache,env,Absyn.TUPLE(expressions = e),impl,st,doVect) /* PR. Get the properties for each expression in the tuple.
524530
Each expression has its own constflag.
525531
*/
@@ -1832,116 +1838,46 @@ algorithm
18321838
end elabTuple;
18331839

18341840
// stefan
1835-
protected function elabPartEvalFuncArgs
1836-
"function: elabPartEvalFuncArgs
1837-
Helper function to elabPartEvalFunction
1838-
elaborates the arguments and performs constant evaluation where appropriate
1839-
Also gets the names of the named arguments"
1841+
protected function elabPartEvalFunction
1842+
"function: elabPartEvalFunction
1843+
turns an Absyn.PARTEVALFUNCTION into an Exp.PARTEVALFUNCTION"
18401844
input Env.Cache inCache;
18411845
input Env.Env inEnv;
1842-
input Absyn.FunctionArgs inAbsynFunctionArgs;
1843-
input Boolean inBoolean;
1844-
input Option<Interactive.InteractiveSymbolTable> inInteractiveInteractiveSymbolTableOption;
1845-
input Boolean performVectorization;
1846+
input Absyn.Exp inExp;
1847+
input Option<Interactive.InteractiveSymbolTable> inSymbolTableOption;
1848+
input Boolean inImpl;
1849+
input Boolean inVect;
18461850
output Env.Cache outCache;
1847-
output list<Exp.Exp> outExpExpList;
1848-
output list<String> outStringList;
1849-
output Option<Interactive.InteractiveSymbolTable> outInteractiveInteractiveSymbolTableOption;
1850-
1851+
output Exp.Exp outExp;
1852+
output Types.Properties outProperties;
1853+
output Option<Interactive.InteractiveSymbolTable> outSymbolTableOption;
18511854
algorithm
1852-
(outCache,outExpExpList,outStringList,outInteractiveInteractiveSymbolTableOption) :=
1853-
matchcontinue (inCache,inEnv,inAbsynFunctionArgs,inBoolean,inInteractiveInteractiveSymbolTableOption,performVectorization)
1855+
(outCache,outExp,outProperties,outSymbolTableOption) := matchcontinue(inCache,inEnv,inExp,inSymbolTableOption,inImpl,inVect)
18541856
local
18551857
Env.Cache c;
18561858
Env.Env env;
1857-
list<Absyn.NamedArg> n_args;
1858-
list<Absyn.Exp> e_args;
1859-
Boolean impl,doVect;
1859+
Absyn.ComponentRef cref;
1860+
list<Absyn.Exp> posArgs;
1861+
list<Absyn.NamedArg> namedArgs;
18601862
Option<Interactive.InteractiveSymbolTable> st;
1861-
1862-
case (c,env,Absyn.FUNCTIONARGS(args=e_args,argNames=n_args),impl,st,doVect)
1863-
local
1864-
list<String> slst;
1865-
list<Absyn.Exp> elst,elst_1;
1866-
list<Exp.Exp> elabelst;
1867-
list<Types.Properties> plst;
1868-
list<Types.Const> clst;
1869-
equation
1870-
(slst,elst) = Absyn.getNamedFuncArgNamesAndValues(n_args);
1871-
elst_1 = listAppend(elst,e_args);
1872-
(c,elabelst,plst,st) = elabExpList(c,env,elst_1,impl,st,doVect);
1873-
clst = Types.getConstList(plst);
1874-
(c,elabelst,plst) = cevalExpListIfConstant(c,elabelst,plst,clst,impl,env);
1875-
then
1876-
(c,elabelst,slst,st);
1877-
1878-
end matchcontinue;
1879-
end elabPartEvalFuncArgs;
1880-
1881-
// stefan
1882-
protected function cevalExpListIfConstant
1883-
"function: cevalExpListIfConstant
1884-
applies cevalIfConstant to a list of Exp.Exp"
1885-
input Env.Cache inCache;
1886-
input list<Exp.Exp> inExpList;
1887-
input list<Types.Properties> inPropertiesList;
1888-
input list<Types.Const> inConstList;
1889-
input Boolean inBoolean;
1890-
input Env.Env inEnv;
1891-
output Env.Cache outCache;
1892-
output list<Exp.Exp> outExpList;
1893-
output list<Types.Properties> outPropertiesList;
1894-
algorithm
1895-
(outCache,outExpList,outPropertiesList) :=
1896-
matchcontinue(inCache,inExpList,inPropertiesList,inConstList,inBoolean,inEnv)
1897-
local
1898-
Env.Cache c;
1899-
list<Exp.Exp> ecdr;
1900-
list<Types.Properties> pcdr;
1901-
list<Types.Const> ccdr;
1902-
Boolean impl;
1903-
Env.Env env;
1904-
Exp.Exp e,e_1;
1905-
Types.Properties prop,prop_1;
1906-
Types.Const const;
1907-
case (c,{},{},{},impl,env) then (c,{},{});
1908-
case (c,e :: ecdr,prop :: pcdr, const :: ccdr,impl,env)
1863+
Boolean impl,doVect;
1864+
Absyn.Path p;
1865+
list<Exp.Exp> args;
1866+
Exp.Type ty;
1867+
Types.Properties prop;
1868+
case(c,env,Absyn.PARTEVALFUNCTION(cref,Absyn.FUNCTIONARGS(posArgs,namedArgs)),st,impl,doVect)
19091869
equation
1910-
(c,e_1,prop_1) = cevalIfConstant(c,e,prop,const,impl,env);
1911-
(c,ecdr,pcdr) = cevalExpListIfConstant(c,ecdr,pcdr,ccdr,impl,env);
1870+
p = Absyn.crefToPath(cref);
1871+
(c,Exp.CALL(p,args,_,_,ty,_),prop) = elabCallArgs(c,env,p,posArgs,namedArgs,impl,st);
19121872
then
1913-
(c, e_1 :: ecdr, prop_1 :: pcdr);
1914-
end matchcontinue;
1915-
end cevalExpListIfConstant;
1916-
1917-
// stefan
1918-
// Use MetaUtil.generateFuncNameSuffix instead
1919-
// Pass the unelaborated arguments to it as parameters
1920-
/*protected function generateFuncNameSuffix
1921-
"function: generateFuncNameSuffix
1922-
Generates a unique function name using the arg names and their values"
1923-
input list<String> inStringList;
1924-
input list<Exp.Exp> inExpExpList;
1925-
output String outString;
1926-
algorithm
1927-
outString := matchcontinue (inStringList,inExpExpList)
1928-
local
1929-
String s;
1930-
list<String> scdr;
1931-
Exp.Exp e;
1932-
list<Exp.Exp> ecdr;
1933-
case ({},ecdr) then Exp.printExpListStrNoSpace(ecdr);
1934-
case (s :: scdr, e :: ecdr)
1935-
local
1936-
String s1,s2,s3;
1873+
(c,Exp.PARTEVALFUNCTION(p,args,ty),prop,st);
1874+
case(_,_,_,_,_,_)
19371875
equation
1938-
s1 = Exp.printExpStr(e);
1939-
s2 = stringAppend(s,s1);
1940-
s3 = generateFuncNameSuffix(scdr,ecdr);
1876+
Debug.fprintln("failtrace","Static.elabPartEvalFunction failed");
19411877
then
1942-
stringAppend(s2,s3);
1878+
fail();
19431879
end matchcontinue;
1944-
end generateFuncNameSuffix;*/
1880+
end elabPartEvalFunction;
19451881

19461882
protected function elabArray "function: elabArray
19471883

0 commit comments

Comments
 (0)