Skip to content

Commit

Permalink
- Fixes for bug #1285 #1286
Browse files Browse the repository at this point in the history
ErrorExt.mo
- added ErrorExt.isTopCheckpoint to ErrorExt.mo and errorext.cpp
  + used in Inst.mo to check if we should rollback or not.

Inst.mo
- moved the case for basic type instantiation from Inst.instClassdef2 
  into its own function: Inst.instClassdefBasicType and added 
  checkpoint/rollback to it to get rid of the "wrong errors/warnings" 
  due to instantiation as a basic type.
- replaced equality(x = y)/failure(equality(x = y)) with 
  true = stringEqual(x, y) respectively false = stringEqual(x, y)
- propagated prefix to more functions
- added Inst.checkExtendsForTypeRestiction to check for extends
  restrictions in Modelica 3.1, but is unused for now as it will
  get rid of some of the error reporting.

InstExtends.mo
- propagated prefix to more functions
- propagate the final prefix to the component modifier.
- the problem with InstExtends.mo is that when we only copy 
  the classes/components from an extends clause we loose the
  scope information and the errors become less localized:
  For example, see the changes in 
   testsuite/mosfiles-nosim/FinalTests.mos
  We should fix this by propagating more information inside
  the modifiers (i.e. the scope where they were created).

Lookup.mo
- small changes due to propagation of prefix to more functions

System.mo
- added System.refEqual to check for reference (pointer) equality

Exp.mo
- the current Exp.crefEqual was moved to Exp.crefEqualStringCompare
  to be easier to switch between crefEqual with/without string comparison
- checks for pointer equality via Static.equalCref in some of the 
  object comparison functions.

SCode.mo
- SCode.printClassdefStr now handles ALL alternatives 
  and has better printing of enumerations

ConnectionGraph.mo
- small documentation update
- use Exp.crefEqualNoStringCompare instead of Exp.crefEqual

Compiler/omc_release/Makefile.omdev.mingw
- make omc.exe Large Address Aware via -Wl,-large-address-aware flag
- this will give omc the possibility of allocating more memory

testsuite/dependency
- added tests for +d=usedep so at least we know when we break them
  because MathCore uses the dependency all the time.
- also tests fixes of bug 1286.

testsuite/mofiles/InnerOuterWithExtends.mo
- tests for bug 1285 (this one)

testsuite/libraries/msl221/OneWayRectifierBG.mos
testsuite/libraries/msl221/TestNand.mos
testsuite/mosfiles-nosim/interactive_api_attributes.mos
- these tests are different now when we suppress the errors/warnings 
  from instantiation as basic type.
- the tests are more correct now as for example in OneWayRectifierBG
  we had a warning that parameter does not have a default value *even*
  if it *does* (well, a recursive one, but still it does).
- in TestNand.mos the warning about the use of == on reals is gone but
  anyway is used in an algorithm, so it had no value.
- in interactive_api_attributes.mos the "inner" warning is gone now
  and it should be.
testsuite/mosfiles-nosim/FinalTests.mos
- this test produces less errors which in this case is a bit bad
  as the missing error messages pointed you in the right direction.
- however, these error messages were generated while we tried to
  instantiate the class as a basic type (which was wrong anyway).
- we should fix this test by adding source information (the scope/prefix)  
  to modifiers and then when we try to merge them (final vs. modification)
  we can output this information. 

testsuite/libraries/msl31/Modelica.Mechanics.MultiBody.mos
- fixes for loading of ModelicaServices
- also check that the instantiation of 
   Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
  works.

testsuite/libraries/multibody/elementary/RollingWheel.mos
- small equation migration due to changes in sorting of
  inner/outer.



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6184 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 23, 2010
1 parent ba95050 commit 793269b
Show file tree
Hide file tree
Showing 9 changed files with 800 additions and 196 deletions.
30 changes: 13 additions & 17 deletions Compiler/ConnectionGraph.mo
Expand Up @@ -62,14 +62,12 @@ public import HashTableCG;
public import Util;
public import Connect;

/* A list of edges
*/
public type Edges = list<tuple<DAE.ComponentRef,DAE.ComponentRef>>;
/* A list of edges, each edge associated with two lists of DAE elements
* (these elements represent equations to be added if the edge
* is preserved or broken)
*/
public type DaeEdges = list<tuple<DAE.ComponentRef,DAE.ComponentRef,list<DAE.Element>>>;
public type Edges = list<tuple<DAE.ComponentRef,DAE.ComponentRef>> "A list of edges";

public type DaeEdges = list<tuple<DAE.ComponentRef,DAE.ComponentRef,list<DAE.Element>>>
"A list of edges, each edge associated with two lists of DAE elements
(these elements represent equations to be added if the edge
is preserved or broken)";

public
uniontype ConnectionGraph "Input structure for connection breaking algorithm. It is collected during instantiation phase."
Expand All @@ -82,14 +80,9 @@ uniontype ConnectionGraph "Input structure for connection breaking algorithm. It
end GRAPH;
end ConnectionGraph;

/*
* Initial connection graph with no edges in it.
*/
public constant ConnectionGraph EMPTY = GRAPH( true, {}, {}, {}, {} );
/*
* Initial connection graph with updateGraph set to false.
*/
public constant ConnectionGraph NOUPDATE_EMPTY = GRAPH( false, {}, {}, {}, {} );
public constant ConnectionGraph EMPTY = GRAPH( true, {}, {}, {}, {} ) "Initial connection graph with no edges in it.";

public constant ConnectionGraph NOUPDATE_EMPTY = GRAPH( false, {}, {}, {}, {} ) "Initial connection graph with updateGraph set to false.";

public function handleOverconstrainedConnections
"author: adrpo
Expand Down Expand Up @@ -829,10 +822,13 @@ algorithm
HashTableCG.HashTable partition;
DAE.ComponentRef ref1, ref2;

// they are the same
case(partition,ref1,ref2)
equation
true = Exp.crefEqual(ref1, ref2);
true = Exp.crefEqualNoStringCompare(ref1, ref2);
then (partition, false);

// not the same, add it
case(partition,ref1,ref2)
equation
partition = HashTableCG.add((ref1,ref2), partition);
Expand Down
22 changes: 20 additions & 2 deletions Compiler/ErrorExt.mo
Expand Up @@ -140,11 +140,29 @@ end printErrorsNoWarning;

public function rollBack "rolls back error messages until the latest checkpoint,
deleting all error messages added since that point in time. A unique identifier for the checkpoint must be provided
The application will exit with return code -1 if this identifier does not match.
"
The application will exit with return code -1 if this identifier does not match."
input String id "unique identifier";
external "C" ;
end rollBack;

public function isTopCheckpoint
"@author: adrpo
This function checks if the specified checkpoint exists AT THE TOP OF THE STACK!.
You can use it to rollBack/delete a checkpoint, but you're
not sure that it exists (due to MetaModelica backtracking)."
input String id "unique identifier";
output Boolean isThere "tells us if the checkpoint exists (true) or doesn't (false)";
external "C" ;
end isTopCheckpoint;

public function getLastDeletedCheckpoint
"@author: adrpo
This function returns the last deleted checkpoint id.
Is needed to see if the previous phase generated some
error messages or not"
output String lastCheckpoint ;
external "C" ;
end getLastDeletedCheckpoint;

end ErrorExt;

42 changes: 38 additions & 4 deletions Compiler/Exp.mo
Expand Up @@ -1186,10 +1186,21 @@ algorithm
end matchcontinue;
end joinCrefs;


public function crefEqual
"function: crefEqual
Returns true if two component references are equal"
Returns true if two component references are equal.
No string comparison of unparsed crefs is performed!"
input ComponentRef inComponentRef1;
input ComponentRef inComponentRef2;
output Boolean outBoolean;
algorithm
outBoolean := crefEqualStringCompare(inComponentRef1,inComponentRef2);
end crefEqual;

public function crefEqualStringCompare
"function: crefEqualStringCompare
Returns true if two component references are equal,
comparing strings in no other solution is found"
input ComponentRef inComponentRef1;
input ComponentRef inComponentRef2;
output Boolean outBoolean;
Expand All @@ -1199,6 +1210,14 @@ algorithm
Ident n1,n2,s1,s2;
list<Subscript> idx1,idx2;
ComponentRef cr1,cr2;

// check for pointer equality first, if they point to the same thing, they are equal
case (inComponentRef1,inComponentRef2)
equation
true = System.refEqual(inComponentRef1,inComponentRef2);
then
true;

// simple identifiers
case (DAE.CREF_IDENT(ident = n1,subscriptLst = {}),DAE.CREF_IDENT(ident = n2,subscriptLst = {}))
equation
Expand Down Expand Up @@ -1245,7 +1264,7 @@ algorithm
case (DAE.CREF_QUAL(ident = n1,subscriptLst = idx1,componentRef = cr1),DAE.CREF_QUAL(ident = n2,subscriptLst = idx2,componentRef = cr2))
equation
true = stringEqual(n1, n2);
true = crefEqual(cr1, cr2);
true = crefEqualStringCompare(cr1, cr2);
true = subscriptEqual(idx1, idx2);
then
true;
Expand Down Expand Up @@ -1291,7 +1310,7 @@ algorithm
// the crefs are not equal!
case (_,_) then false;
end matchcontinue;
end crefEqual;
end crefEqualStringCompare;

public function crefEqualNoStringCompare
"function: crefEqualNoStringCompare
Expand All @@ -1308,6 +1327,14 @@ algorithm
Ident n1,n2,s1,s2;
list<Subscript> idx1,idx2;
ComponentRef cr1,cr2;

// check for pointer equality first, if they point to the same thing, they are equal
case (inComponentRef1,inComponentRef2)
equation
true = System.refEqual(inComponentRef1,inComponentRef2);
then
true;

// simple identifiers
case (DAE.CREF_IDENT(ident = n1,subscriptLst = idx1),DAE.CREF_IDENT(ident = n2,subscriptLst = idx2))
equation
Expand Down Expand Up @@ -8790,6 +8817,13 @@ algorithm
list<Exp> expl1,expl2;
Type tp1,tp2;

// check for pointer equality first, if they point to the same thing, they are equal
case (inExp1,inExp2)
equation
true = System.refEqual(inExp1,inExp2);
then
true;

// integers
case (DAE.ICONST(integer = c1),DAE.ICONST(integer = c2)) then (c1 == c2);
// reals
Expand Down

0 comments on commit 793269b

Please sign in to comment.