Skip to content

Commit

Permalink
- A lot of changes to SCodeInst, mostly related to typing of components.
Browse files Browse the repository at this point in the history
- Hijacked SCodeMod and moved modifier handling code from SCodeInst there.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11046 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Feb 8, 2012
1 parent ebce39f commit e015a73
Show file tree
Hide file tree
Showing 9 changed files with 2,233 additions and 873 deletions.
30 changes: 30 additions & 0 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -2897,6 +2897,36 @@ algorithm
end match;
end prefixOptPath;

public function suffixPath
"Adds a suffix to a path. Ex:
suffixPath(a.b.c, 'd') => a.b.c.d"
input Path inPath;
input Ident inSuffix;
output Path outPath;
algorithm
outPath := match(inPath, inSuffix)
local
Ident name;
Path path;

case (IDENT(name), _)
then QUALIFIED(name, IDENT(inSuffix));

case (QUALIFIED(name, path), _)
equation
path = suffixPath(path, inSuffix);
then
QUALIFIED(name, path);

case (FULLYQUALIFIED(path), _)
equation
path = suffixPath(path, inSuffix);
then
FULLYQUALIFIED(path);

end match;
end suffixPath;

public function pathSuffixOf "returns true if suffix_path is a suffix of path"
input Path suffix_path;
input Path path;
Expand Down
19 changes: 19 additions & 0 deletions Compiler/FrontEnd/ComponentReference.mo
Expand Up @@ -223,6 +223,25 @@ algorithm
end match;
end crefToPath;

public function crefToPathIgnoreSubs
input DAE.ComponentRef inComponentRef;
output Absyn.Path outPath;
algorithm
outPath := match(inComponentRef)
local
DAE.Ident i;
Absyn.Path p;
DAE.ComponentRef c;

case DAE.CREF_IDENT(ident = i) then Absyn.IDENT(i);
case DAE.CREF_QUAL(ident = i, componentRef = c)
equation
p = crefToPathIgnoreSubs(c);
then
Absyn.QUALIFIED(i, p);
end match;
end crefToPathIgnoreSubs;

public function pathToCref
"function: pathToCref
This function converts a Absyn.Path to a ComponentRef."
Expand Down
26 changes: 18 additions & 8 deletions Compiler/FrontEnd/SCode.mo
Expand Up @@ -723,10 +723,9 @@ public function isParameterOrConst
output Boolean outBoolean;
algorithm
outBoolean := match (inVariability)
case (VAR()) then false;
case (DISCRETE()) then false;
case (PARAM()) then true;
case (CONST()) then true;
case PARAM() then true;
case CONST() then true;
else false;
end match;
end isParameterOrConst;

Expand All @@ -737,10 +736,8 @@ public function isConstant
output Boolean outBoolean;
algorithm
outBoolean := match (inVariability)
case (VAR()) then false;
case (DISCRETE()) then false;
case (PARAM()) then false;
case (CONST()) then true;
case CONST() then true;
else false;
end match;
end isConstant;

Expand Down Expand Up @@ -3737,5 +3734,18 @@ algorithm
end match;
end getModifierInfo;

public function getModifierBinding
input Mod inMod;
output Option<Absyn.Exp> outBinding;
algorithm
outBinding := match(inMod)
local
Absyn.Exp binding;

case MOD(binding = SOME((binding, _))) then SOME(binding);
else NONE();
end match;
end getModifierBinding;

end SCode;

0 comments on commit e015a73

Please sign in to comment.