Skip to content

Commit

Permalink
- Enabled SCodeFlatten by default.
Browse files Browse the repository at this point in the history
- Updated the test suite to comply with SCodeFlatten.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8768 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed May 2, 2011
1 parent 25b3338 commit 2d410db
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
7 changes: 4 additions & 3 deletions Compiler/FrontEnd/SCodeCheck.mo
Expand Up @@ -187,9 +187,10 @@ algorithm
case (SCodeEnv.CLASS(cls = SCode.CLASS(prefixes = SCode.PREFIXES(
replaceablePrefix = SCode.REPLACEABLE(cc = _)), info = info)), _, _)
equation
err_str = Absyn.pathString(inPath);
Error.addSourceMessage(Error.ERROR_FROM_HERE, {}, inOriginInfo);
Error.addSourceMessage(Error.REPLACEABLE_BASE_CLASS, {err_str}, info);
// Disabled until it's decided whether this is an error or not.
//err_str = Absyn.pathString(inPath);
//Error.addSourceMessage(Error.ERROR_FROM_HERE, {}, inOriginInfo);
//Error.addSourceMessage(Error.REPLACEABLE_BASE_CLASS, {err_str}, info);
then
();
end match;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/SCodeDependency.mo
Expand Up @@ -503,7 +503,7 @@ algorithm
// Remove all 'extends ExternalObject'.
el := Util.listFilter(inElements, isNotExternalObject);
// Check if length of the new list is different to the old, i.e. if we
// actually found an removed any 'extends ExternalObject'.
// actually found and removed any 'extends ExternalObject'.
false := (listLength(el) == listLength(inElements));
// Ok, we have an external object, check that it's valid.
el_names := Util.listMap(el, SCode.elementName);
Expand Down
8 changes: 0 additions & 8 deletions Compiler/FrontEnd/SCodeFlatten.mo
Expand Up @@ -113,16 +113,8 @@ algorithm
Env env;
SCode.Program prog;

case (_, _)
equation
false = RTOpts.debugFlag("scodeFlatten");
then
inProgram;

case (_, prog)
equation
true = RTOpts.debugFlag("scodeFlatten");

//System.startTimer();

env = SCodeEnv.buildInitialEnv();
Expand Down
27 changes: 21 additions & 6 deletions Compiler/FrontEnd/SCodeFlattenExtends.mo
Expand Up @@ -49,19 +49,34 @@ public import SCodeHashTable;

protected import BaseHashTable;
protected import Debug;
protected import RTOpts;

public function flattenProgram
"Flattens the last class in a program."
input SCode.Program inProgram;
input SCodeEnv.Env inEnv;
output SCode.Program outProgram;
protected
SCodeHashTable.HashTable hashTable;
algorithm
SOME(hashTable) := SCodeHashTable.hashTableFromProgram(inProgram, inEnv, NONE(), 1);
SOME(hashTable) := handleExtends(SOME(hashTable), inEnv);
Debug.fcall("scodeHash", BaseHashTable.dumpHashTable, hashTable);
outProgram := SCodeHashTable.programFromHashTable(hashTable);
outProgram := matchcontinue(inProgram, inEnv)
local
SCodeHashTable.HashTable hashTable;

case (_, _)
equation
false = RTOpts.debugFlag("scodeFlatten");
then
inProgram;

else
equation
SOME(hashTable) = SCodeHashTable.hashTableFromProgram(inProgram, inEnv, NONE(), 1);
SOME(hashTable) = handleExtends(SOME(hashTable), inEnv);
Debug.fcall("scodeHash", BaseHashTable.dumpHashTable, hashTable);
outProgram = SCodeHashTable.programFromHashTable(hashTable);
then
outProgram;

end matchcontinue;
end flattenProgram;

protected function handleExtends
Expand Down
8 changes: 8 additions & 0 deletions Compiler/FrontEnd/SCodeLookup.mo
Expand Up @@ -1108,9 +1108,17 @@ public function qualifyPath
algorithm
outPath := matchcontinue(inPath, inEnv, inInfo, inErrorType)
local
Absyn.Ident id;
Absyn.Path path;
Env env;

// Never fully qualify builtin types.
case (Absyn.IDENT(name = id), _, _, _)
equation
_ = lookupBuiltinType(id);
then
inPath;

case (_, _, _, _)
equation
(_, path, env) = lookupName(inPath, inEnv, inInfo, inErrorType);
Expand Down

0 comments on commit 2d410db

Please sign in to comment.