Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into perffix
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Feb 11, 2016
2 parents b95e6eb + a2c7ddf commit 443a059
Show file tree
Hide file tree
Showing 59 changed files with 1,741 additions and 771 deletions.
16 changes: 8 additions & 8 deletions Compiler/FFrontEnd/FBuiltin.mo
Expand Up @@ -133,9 +133,9 @@ protected constant SCode.Prefixes commonPrefixesNotFinal =
SCode.NOT_REPLACEABLE());

protected
constant SCode.Attributes attrConst = SCode.ATTR({},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.CONST(),Absyn.BIDIR());
constant SCode.Attributes attrParam = SCode.ATTR({},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR());
constant SCode.Attributes attrParamVectorNoDim = SCode.ATTR({Absyn.NOSUB()},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR());
constant SCode.Attributes attrConst = SCode.ATTR({},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.CONST(),Absyn.BIDIR(),Absyn.NONFIELD());
constant SCode.Attributes attrParam = SCode.ATTR({},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NONFIELD());
constant SCode.Attributes attrParamVectorNoDim = SCode.ATTR({Absyn.NOSUB()},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.PARAM(),Absyn.BIDIR(),Absyn.NONFIELD());

//
// The primitive types
Expand Down Expand Up @@ -487,39 +487,39 @@ protected constant SCode.Element timeComp =
SCode.COMPONENT(
"time",
SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(),Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(),
SCode.noComment, NONE(), Absyn.dummyInfo);

protected constant SCode.Element startTimeComp =
SCode.COMPONENT(
"startTime",
SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(),Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(),
SCode.noComment, NONE(), Absyn.dummyInfo);

protected constant SCode.Element finalTimeComp =
SCode.COMPONENT(
"finalTime",
SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(),Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(),
SCode.noComment, NONE(), Absyn.dummyInfo);

protected constant SCode.Element objectiveIntegrandComp =
SCode.COMPONENT(
"objectiveIntegrand",
SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(),Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(),
SCode.noComment, NONE(), Absyn.dummyInfo);

protected constant SCode.Element objectiveVarComp =
SCode.COMPONENT(
"objectiveVar",
SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(),Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(),
SCode.noComment, NONE(), Absyn.dummyInfo);

Expand Down
49 changes: 14 additions & 35 deletions Compiler/FFrontEnd/FCore.mo
Expand Up @@ -510,7 +510,7 @@ algorithm

case (id) then stringGet(id,1) == 36; // "$"

case (_) then false;
else false;

end matchcontinue;
end isImplicitScope;
Expand Down Expand Up @@ -695,10 +695,10 @@ public function isTyped
input Status is;
output Boolean b;
algorithm
b := matchcontinue(is)
b := match(is)
case(VAR_UNTYPED()) then false;
case(_) then true;
end matchcontinue;
else true;
end match;
end isTyped;

public function getCachedInitialGraph "get the initial environment from the cache"
Expand Down Expand Up @@ -735,43 +735,22 @@ public function getRecordConstructorName
input Name inName;
output Name outName;
algorithm
outName := matchcontinue(inName)

case (_)
equation
true = Config.acceptMetaModelicaGrammar();
then
inName;

else inName + recordConstructorSuffix;

end matchcontinue;
outName := if Config.acceptMetaModelicaGrammar() then inName else inName + recordConstructorSuffix;
end getRecordConstructorName;

public function getRecordConstructorPath
input Absyn.Path inPath;
output Absyn.Path outPath;
protected
Name lastId;
algorithm
outPath := matchcontinue(inPath)
local
Absyn.Path path;
Name lastId;

case (_)
equation
true = Config.acceptMetaModelicaGrammar();
then
inPath;

else
equation
lastId = Absyn.pathLastIdent(inPath);
lastId = getRecordConstructorName(lastId);
path = Absyn.pathSetLastIdent(inPath, Absyn.makeIdentPathFromString(lastId));
then
path;

end matchcontinue;
if Config.acceptMetaModelicaGrammar() then
outPath := inPath;
else
lastId := Absyn.pathLastIdent(inPath);
lastId := getRecordConstructorName(lastId);
outPath := Absyn.pathSetLastIdent(inPath, Absyn.makeIdentPathFromString(lastId));
end if;
end getRecordConstructorPath;

annotation(__OpenModelica_Interface="frontend");
Expand Down
62 changes: 26 additions & 36 deletions Compiler/FFrontEnd/FGraph.mo
Expand Up @@ -600,7 +600,7 @@ algorithm
c = SCode.COMPONENT(
name,
SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR(), Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT(""), NONE()), SCode.NOMOD(),
SCode.noComment, NONE(), Absyn.dummyInfo);
v = DAE.TYPES_VAR(
Expand Down Expand Up @@ -636,7 +636,7 @@ algorithm
then
str;

case (_) then "<global scope>";
else "<global scope>";

end matchcontinue;
end printGraphPathStr;
Expand Down Expand Up @@ -748,7 +748,7 @@ algorithm
true = stringEq(name, FCore.forScopeName);
then true;

case(_) then false;
else false;

end matchcontinue;
end inForLoopScope;
Expand All @@ -766,7 +766,7 @@ algorithm
true = stringEq(name, FCore.forIterScopeName) or stringEq(name, FCore.parForIterScopeName);
then true;

case(_) then false;
else false;
end matchcontinue;
end inForOrParforIterLoopScope;

Expand Down Expand Up @@ -897,12 +897,12 @@ public function restrictionToScopeType
input SCode.Restriction inRestriction;
output Option<FCore.ScopeType> outType;
algorithm
outType := matchcontinue(inRestriction)
outType := match(inRestriction)
case SCode.R_FUNCTION(SCode.FR_PARALLEL_FUNCTION()) then SOME(FCore.PARALLEL_SCOPE());
case SCode.R_FUNCTION(SCode.FR_KERNEL_FUNCTION()) then SOME(FCore.PARALLEL_SCOPE());
case SCode.R_FUNCTION(_) then SOME(FCore.FUNCTION_SCOPE());
case _ then SOME(FCore.CLASS_SCOPE());
end matchcontinue;
else SOME(FCore.CLASS_SCOPE());
end match;
end restrictionToScopeType;

public function scopeTypeToRestriction
Expand Down Expand Up @@ -1071,33 +1071,27 @@ protected function pathStripGraphScopePrefix2
input Boolean stripPartial;
output Absyn.Path outPath;
algorithm
outPath := matchcontinue(inPath, inEnvPath, stripPartial)
outPath := match(inPath, inEnvPath, stripPartial)
local
Absyn.Ident id1, id2;
Absyn.Path path;
Absyn.Path env_path;

case (Absyn.QUALIFIED(name = id1, path = path),
Absyn.QUALIFIED(name = id2, path = env_path), _)
equation
true = stringEqual(id1, id2);
Absyn.QUALIFIED(name = id2, path = env_path), _) guard stringEqual(id1, id2)
then
pathStripGraphScopePrefix2(path, env_path, stripPartial);

case (Absyn.QUALIFIED(name = id1, path = path),
Absyn.IDENT(name = id2), _)
equation
true = stringEqual(id1, id2);
Absyn.IDENT(name = id2), _) guard stringEqual(id1, id2)
then
path;

// adrpo: leave it as stripped as you can if you can't match it above and stripPartial is true
case (Absyn.QUALIFIED(name = id1), env_path, true)
equation
false = stringEqual(id1, Absyn.pathFirstIdent(env_path));
case (Absyn.QUALIFIED(name = id1), env_path, true) guard not stringEqual(id1, Absyn.pathFirstIdent(env_path))
then
inPath;
end matchcontinue;
end match;
end pathStripGraphScopePrefix2;

public function mkComponentNode "This function adds a component to the graph."
Expand Down Expand Up @@ -1254,21 +1248,21 @@ public function classInfToScopeType
input ClassInf.State inState;
output Option<FCore.ScopeType> outType;
algorithm
outType := matchcontinue(inState)
outType := match(inState)
case ClassInf.FUNCTION() then SOME(FCore.FUNCTION_SCOPE());
case _ then SOME(FCore.CLASS_SCOPE());
end matchcontinue;
else SOME(FCore.CLASS_SCOPE());
end match;
end classInfToScopeType;

public function isEmpty
"returns true if empty graph"
input Graph inGraph;
output Boolean b;
algorithm
b := matchcontinue(inGraph)
b := match(inGraph)
case (FCore.EG(_)) then true;
else false;
end matchcontinue;
end match;
end isEmpty;

public function isNotEmpty
Expand All @@ -1291,21 +1285,19 @@ public function inFunctionScope
input Graph inGraph;
output Boolean inFunction;
algorithm
inFunction := matchcontinue(inGraph)
inFunction := match(inGraph)
local
Scope s;
Ref r;

case FCore.G(scope = s)
equation
true = checkScopeType(s, SOME(FCore.FUNCTION_SCOPE())) or
checkScopeType(s, SOME(FCore.PARALLEL_SCOPE()));
case FCore.G(scope = s) guard checkScopeType(s, SOME(FCore.FUNCTION_SCOPE())) or
checkScopeType(s, SOME(FCore.PARALLEL_SCOPE()))
then
true;

case _ then false;
else false;

end matchcontinue;
end match;
end inFunctionScope;

public function getScopeName " Returns the name of a scope, if no name exist, the function fails."
Expand Down Expand Up @@ -1449,7 +1441,7 @@ algorithm
then
SOME(Absyn.IDENT(id));

case (_) then NONE();
else NONE();

end matchcontinue;
end getGraphPathNoImplicitScope_dispatch;
Expand Down Expand Up @@ -1888,23 +1880,21 @@ public function graphPrefixOf2
input Scope inEnv;
output Boolean outIsPrefix;
algorithm
outIsPrefix := matchcontinue(inPrefixEnv, inEnv)
outIsPrefix := match(inPrefixEnv, inEnv)
local
String n1, n2;
Scope rest1, rest2;
Ref r1, r2;

case ({}, _::_) then true;

case (r1 :: rest1, r2 :: rest2)
equation
true = stringEq(FNode.refName(r1), FNode.refName(r2));
case (r1 :: rest1, r2 :: rest2) guard stringEq(FNode.refName(r1), FNode.refName(r2))
then
graphPrefixOf2(rest1, rest2);

else false;

end matchcontinue;
end match;
end graphPrefixOf2;

public function setStatus
Expand Down
17 changes: 6 additions & 11 deletions Compiler/FFrontEnd/FGraphDump.mo
Expand Up @@ -111,7 +111,7 @@ protected function addNodes
input list<Ref> inRefs;
output tuple<GraphML.GraphInfo,Integer> gout;
algorithm
gout := matchcontinue(gin, inRefs)
gout := match(gin, inRefs)
local
tuple<GraphML.GraphInfo,Integer> g;
list<Ref> rest;
Expand All @@ -120,23 +120,18 @@ algorithm
case (_, {}) then gin;

case (g, n::rest)
equation
// if not userdefined or top, skip it
true = not FNode.isRefTop(n) and
not FNode.isRefUserDefined(n);
g = addNodes(g, rest);
then
g;
guard not FNode.isRefTop(n) and
not FNode.isRefUserDefined(n)
then addNodes(g, rest);


case (g, n::rest)
equation
g = addNode(g, FNode.fromRef(n));
g = addNodes(g, rest);
then
g;
then addNodes(g, rest);

end matchcontinue;
end match;
end addNodes;

protected function addNode
Expand Down

0 comments on commit 443a059

Please sign in to comment.