Skip to content

Commit

Permalink
- Removing old code
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 20, 2010
1 parent 8870a97 commit 5fb9bbe
Showing 1 changed file with 0 additions and 163 deletions.
163 changes: 0 additions & 163 deletions Compiler/MetaUtil.mo
Expand Up @@ -91,96 +91,6 @@ algorithm
end matchcontinue;
end simplifyListExp;

public function listToConsCell "function: listToConsCell
Author: KS
In the C-code, a list constructor will consist of
several cons constructor. For instance:
list(1,2,3,4) will be written as
mk_cons(1,mk_cons(2,mk_cons(3,mk_cons(4,mk_nil())))),
(the constants 1,2,3,4 each will be wrapped with a create-constant
function call)
"
input list<String> varList;
input list<DAE.Exp> expList;
output String outString;
algorithm
outString :=
matchcontinue (varList,expList)
case ({},_)
local
String s;
equation
s = "mmc_mk_nil()";
then s;
case (firstVar :: restVar,firstExp :: restExp)
local
String firstVar,s,s2;
list<String> restVar;
list<DAE.Exp> restExp;
DAE.Exp firstExp;
equation
firstVar = createConstantCExp(firstExp,firstVar);
s2 = listToConsCell(restVar,restExp);
s = System.stringAppendList({"mmc_mk_cons(",firstVar,",",s2,")"});
then s;
end matchcontinue;
end listToConsCell;

public function createConstantCExp "function: createConstantCExp2"
input DAE.Exp exp;
input String inExp;
output String s;
DAE.ExpType expType;
algorithm
expType := Exp.typeof(exp);
s := createConstantCExp2(expType, inExp);
end createConstantCExp;

protected function createConstantCExp2 "function: createConstantCExp2"
input DAE.ExpType exp;
input String inExp;
output String s;
algorithm
s :=
matchcontinue(exp,inExp)
local
String localInExp,outStr;
case (DAE.ET_INT(),localInExp)
equation
outStr = System.stringAppendList({"mmc_mk_icon(",localInExp,")"});
then outStr;
case (DAE.ET_REAL(),localInExp)
equation
outStr = System.stringAppendList({"mmc_mk_rcon(",localInExp,")"});
then outStr;
case (DAE.ET_BOOL(),localInExp)
equation
outStr = System.stringAppendList({"mmc_mk_icon(",localInExp,")"});
then outStr;
case (DAE.ET_STRING(),localInExp)
equation
outStr = System.stringAppendList({"mmc_mk_scon(",localInExp,")"});
then outStr;
case (DAE.ET_COMPLEX(name = path, varLst = varLst),localInExp)
local
list<DAE.ExpVar> varLst;
list<String> vars, vars1;
list<DAE.ExpType> types;
String str,name;
Absyn.Path path;
equation
vars = Util.listMap(varLst, Exp.varName);
str = stringAppend(localInExp,".");
vars1 = Util.listMap1r(vars, stringAppend, str);
types = Util.listMap(varLst, Exp.varType);
outStr = listToBoxes(vars1,types,-1,Absyn.pathString(path));
then outStr;

case (_,localInExp) then localInExp;

end matchcontinue;
end createConstantCExp2;

public function fixListConstructorsInArgs "function: fixListConstructorsInArgs
Author: KS
In a function call, an Absyn.ARRAY() will be transformed into an Absyn.LIST()
Expand Down Expand Up @@ -844,79 +754,6 @@ algorithm
end matchcontinue;
end reparseType;

public function mmc_mk_box "function: mmc_mk_box
Chooses mmc_mk_box<n>(ctor, ...) or mmc_mk_box(<n>
depending on the size of the box. /sjoelund"
input Integer numBoxes;
input String val;
output String out;
String numStr,tmp1,tmp2,tmp3;
algorithm
numStr := intString(numBoxes);
tmp1 := "(" +& numStr +& ",";
tmp2 := numStr +& "(";
tmp3 := Util.if_(numBoxes > 9, tmp1, tmp2); // mmc_mk_box<n>( or mmc_mk_box(<n>,
out := System.stringAppendList({"mmc_mk_box",tmp3,val,")"});
end mmc_mk_box;

//Generates the mk_box<size>(<index>,<data>::<data>)
public function listToBoxes "function: listToBoxes
MetaModelica extension, added by simbj"
input list<String> varList;
input list<DAE.ExpType> expList;
input Integer index;
input String name;
output String outString;
algorithm
outString := matchcontinue (varList,expList,index,name)
local
String boxStr,expStr;
list<String> varList;
Integer numberOfVariables,index;
String tmp1,tmp2,tmp3,tmp4,tmp5;

case (varList,expList,index,name)
equation
numberOfVariables = listLength(expList)+1;
expStr = createExpStr(varList,expList);
tmp1 = intString(numberOfVariables);
tmp2 = intString(index+3 /* 0 and 1 are reserved by other types. 2 is reserved by regular records */);
tmp3 = "(" +& tmp1 +& ",";
tmp4 = tmp1 +& "(";
tmp5 = Util.if_(numberOfVariables > 9, tmp3, tmp4); // mmc_mk_box<n>( or mmc_mk_box(<n>,
name = Util.stringReplaceChar(name, ".", "_");
expStr = System.stringAppendList({tmp2,",&",name,"__desc",expStr});
expStr = mmc_mk_box(numberOfVariables, expStr);
then expStr;

case (_,_,_,_)
equation
Debug.fprint("failtrace", "- MetaUtil.listToBoxes failed\n");
then fail();
end matchcontinue;
end listToBoxes;

public function createExpStr
input list<String> varList;
input list<DAE.ExpType> expList;
output String outString;
algorithm
outString := matchcontinue(varList,expList)
local
list<String> restVar;
list<DAE.ExpType> restExp;
String firstVar,restStr;
DAE.ExpType firstExp;
case ({},{}) then "";
case (firstVar::restVar,firstExp::restExp)
equation
firstVar = createConstantCExp2(firstExp,firstVar);
restStr = createExpStr(restVar,restExp);
firstVar = System.stringAppendList({",",firstVar,restStr});
then firstVar;
end matchcontinue;
end createExpStr;

/* These functions are helper functions for the Uniontypes, added by simbj */
public function getRestriction
input Absyn.Element el;
Expand Down

0 comments on commit 5fb9bbe

Please sign in to comment.