Skip to content

Commit

Permalink
- Fixed function name prefixing in the new instantiation.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18326 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Nov 27, 2013
1 parent 68c3d90 commit e5a8bfb
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions Compiler/FrontEnd/NFInst.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ algorithm
(entry, base_env) = NFLookup.lookupSimpleNameUnresolved(name_str, inEnv);
is_class = NFEnv.isClassEntry(entry);
opt_prefix = NFEnv.scopePrefixOpt(base_env);
prefix = makeCrefPrefix(opt_prefix, base_env);
prefix = makeNamePrefix(opt_prefix, base_env);

// Look up the whole cref and prefix it.
(entry, env) = NFLookup.lookupVariableName(inCrefPath, inEnv, inInfo);
Expand All @@ -2147,9 +2147,9 @@ algorithm
end matchcontinue;
end prefixCref;

protected function makeCrefPrefix
"Creates a cref prefix given the prefix from the environment where the first
part of the cref was found."
protected function makeNamePrefix
"Creates a name prefix given the prefix from the environment where the first
part of the name was found."
input Option<Prefix> inPrefix;
input Env inEnv;
output Prefix outPrefix;
Expand All @@ -2164,7 +2164,7 @@ algorithm
case (NONE(), _) then NFInstUtil.envPrefix(inEnv);

end match;
end makeCrefPrefix;
end makeNamePrefix;

protected function prefixCref2
input DAE.ComponentRef inCref;
Expand Down Expand Up @@ -2266,6 +2266,36 @@ algorithm
end match;
end instPackageConstant;

protected function prefixPath
input Absyn.Path inPath;
input Env inCurrentEnv;
output Absyn.Path outPath;
algorithm
outPath := match(inPath, inCurrentEnv)
local
String first_id;
Option<Prefix> opt_prefix;
Prefix prefix;
Env env;
Entry entry;
Absyn.Path path;

case (Absyn.FULLYQUALIFIED(_), _) then inPath;

else
equation
first_id = Absyn.pathFirstIdent(inPath);
(entry, env) = NFLookup.lookupSimpleNameUnresolved(first_id, inCurrentEnv);

opt_prefix = NFEnv.scopePrefixOpt(env);
prefix = makeNamePrefix(opt_prefix, env);
path = NFInstUtil.prefixPath(inPath, prefix);
then
path;

end match;
end prefixPath;

protected function instFunctionCall
input Absyn.ComponentRef inName;
input list<Absyn.Exp> inPositionalArgs;
Expand Down Expand Up @@ -2374,8 +2404,7 @@ algorithm
path = Absyn.crefToPath(inName);
(entry, env) = NFLookup.lookupFunctionName(path, inEnv, inInfo);
is_builtin = NFEnv.entryHasBuiltinOrigin(entry);
prefix = NFEnv.scopePrefix(inEnv);
path = instFunctionName(path, is_builtin, inEnv, prefix);
path = instFunctionName(path, is_builtin, inEnv);
(cls, ty, (consts, functions)) =
instFunctionEntry(path, entry, is_builtin, env, inGlobals);
is_record = Types.isRecord(ty);
Expand All @@ -2398,13 +2427,11 @@ protected function instFunctionName
input Absyn.Path inPath;
input Boolean inBuiltin;
input Env inEnv;
input Prefix inPrefix;
output Absyn.Path outPath;
algorithm
outPath := match(inPath, inBuiltin, inEnv, inPrefix)
case (_, true, _, _) then inPath; // Don't prefix builtin functions.
//else prefixPath(inPath, inPrefix, inEnv);
else inPath;
outPath := match(inPath, inBuiltin, inEnv)
case (_, true, _) then inPath; // Don't prefix builtin functions.
else prefixPath(inPath, inEnv);
end match;
end instFunctionName;

Expand Down

0 comments on commit e5a8bfb

Please sign in to comment.