Skip to content

Commit df214de

Browse files
committed
- Added Error.addMultiSourceMessage for errors with multiple sources.
- Big update of new new instantiation. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15455 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0069830 commit df214de

File tree

11 files changed

+1793
-329
lines changed

11 files changed

+1793
-329
lines changed

Compiler/FrontEnd/Absyn.mo

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5883,4 +5883,39 @@ algorithm
58835883
end match;
58845884
end isInitial;
58855885

5886+
public function importPath
5887+
"Return the path of the given import."
5888+
input Import inImport;
5889+
output Path outPath;
5890+
algorithm
5891+
outPath := match(inImport)
5892+
local
5893+
Path path;
5894+
5895+
case NAMED_IMPORT(path = path) then path;
5896+
case QUAL_IMPORT(path = path) then path;
5897+
case UNQUAL_IMPORT(path = path) then path;
5898+
case GROUP_IMPORT(prefix = path) then path;
5899+
5900+
end match;
5901+
end importPath;
5902+
5903+
public function importName
5904+
"Returns the import name of a named or qualified import."
5905+
input Import inImport;
5906+
output Ident outName;
5907+
algorithm
5908+
outName := match(inImport)
5909+
local
5910+
Ident name;
5911+
Path path;
5912+
5913+
// Named import has a given name, 'import D = A.B.C' => D.
5914+
case NAMED_IMPORT(name = name) then name;
5915+
// Qualified import uses the last identifier, 'import A.B.C' => C.
5916+
case QUAL_IMPORT(path = path) then pathLastIdent(path);
5917+
5918+
end match;
5919+
end importName;
5920+
58865921
end Absyn;

Compiler/FrontEnd/Inst.mo

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7635,7 +7635,7 @@ algorithm
76357635
Env.Cache cache;
76367636
SCode.Element c1, c2;
76377637
Absyn.Path tpath1, tpath2;
7638-
Absyn.Info aInfo;
7638+
Absyn.Info old_info, new_info;
76397639
SCode.Prefixes prefixes1, prefixes2;
76407640
SCode.Attributes attr1,attr2;
76417641
Absyn.TypeSpec tp1,tp2;
@@ -7650,13 +7650,14 @@ algorithm
76507650
// NOTE: Should be type identical instead? see spec.
76517651
// p.23, check of flattening. "Check that duplicate elements are identical".
76527652
true = SCode.elementEqual(oldElt,newElt);
7653-
then ();
7653+
then
7654+
();
76547655

76557656
// adrpo: see if they are not syntactically equivalent, but semantically equivalent!
76567657
// see Modelica Spec. 3.1, page 66.
76577658
// COMPONENT
7658-
case (cache,env,(oldElt as SCode.COMPONENT(n1, prefixes1, attr1, tp1 as Absyn.TPATH(tpath1, ad1), smod1, _, cond1, aInfo),oldMod),
7659-
(newElt as SCode.COMPONENT(n2, prefixes2, attr2, tp2 as Absyn.TPATH(tpath2, ad2), smod2, _, cond2, _),newMod))
7659+
case (cache,env,(oldElt as SCode.COMPONENT(n1, prefixes1, attr1, tp1 as Absyn.TPATH(tpath1, ad1), smod1, _, cond1, old_info),oldMod),
7660+
(newElt as SCode.COMPONENT(n2, prefixes2, attr2, tp2 as Absyn.TPATH(tpath2, ad2), smod2, _, cond2, new_info),newMod))
76607661
equation
76617662
// see if the most stuff is the same!
76627663
true = stringEq(n1, n2);
@@ -7675,13 +7676,15 @@ algorithm
76757676
// add a warning and let it continue!
76767677
s1 = SCodeDump.unparseElementStr(oldElt);
76777678
s2 = SCodeDump.unparseElementStr(newElt);
7678-
Error.addSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_SYNTACTICALLY_IDENTICAL,{s1,s2}, aInfo);
7679-
then ();
7679+
Error.addMultiSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_SYNTACTICALLY_IDENTICAL,
7680+
{s1, s2}, {old_info, new_info});
7681+
then
7682+
();
76807683

76817684
// adrpo: handle bug: https://trac.modelica.org/Modelica/ticket/627
76827685
// TODO! FIXME! REMOVE! remove when the bug is fixed!
7683-
case (cache,env,(oldElt as SCode.COMPONENT(n1, prefixes1, attr1, tp1 as Absyn.TPATH(tpath1, ad1), smod1, _, cond1, aInfo),oldMod),
7684-
(newElt as SCode.COMPONENT(n2, prefixes2, attr2, tp2 as Absyn.TPATH(tpath2, ad2), smod2, _, cond2, _),newMod))
7686+
case (cache,env,(oldElt as SCode.COMPONENT(n1, prefixes1, attr1, tp1 as Absyn.TPATH(tpath1, ad1), smod1, _, cond1, old_info),oldMod),
7687+
(newElt as SCode.COMPONENT(n2, prefixes2, attr2, tp2 as Absyn.TPATH(tpath2, ad2), smod2, _, cond2, new_info),newMod))
76857688
equation
76867689
// see if the most stuff is the same!
76877690
true = stringEq(n1, n2);
@@ -7703,17 +7706,20 @@ algorithm
77037706
s2 = SCodeDump.unparseElementStr(newElt);
77047707
s = "Inherited elements are not identical: bug: https://trac.modelica.org/Modelica/ticket/627\n\tfirst: " +&
77057708
s1 +& "\n\tsecond: " +& s2 +& "\nContinue ....";
7706-
Error.addSourceMessage(Error.COMPILER_WARNING, {s}, aInfo);
7709+
Error.addMultiSourceMessage(Error.COMPILER_WARNING, {s}, {old_info, new_info});
77077710
then ();
77087711

77097712
// fail baby and add a source message!
7710-
case (cache, env, (oldElt as SCode.COMPONENT(info=aInfo),oldMod),(newElt,newMod))
7713+
case (cache, env, (oldElt as SCode.COMPONENT(info = old_info),oldMod),
7714+
(newElt as SCode.COMPONENT(info = new_info),newMod))
77117715
equation
77127716
s1 = SCodeDump.unparseElementStr(oldElt);
77137717
s2 = SCodeDump.unparseElementStr(newElt);
7714-
Error.addSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_IDENTICAL,{s1,s2}, aInfo);
7715-
//print(" *** error message added *** \n");
7716-
then fail();
7718+
Error.addMultiSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_IDENTICAL,
7719+
{s1, s2}, {old_info, new_info});
7720+
then
7721+
fail();
7722+
77177723
end matchcontinue;
77187724
end checkMultipleElementsIdentical;
77197725

Compiler/FrontEnd/NFBuiltin.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public constant list<SCode.Element> BUILTIN_REAL_ATTRIBUTES = {
179179
BUILTIN_REAL_MAX,
180180
BUILTIN_REAL_START,
181181
BUILTIN_ATTR_FIXED,
182+
BUILTIN_REAL_NOMINAL,
182183
BUILTIN_ATTR_STATESELECT
183184
};
184185

@@ -226,7 +227,7 @@ public constant SCode.Element BUILTIN_STRING = SCode.CLASS("String",
226227

227228

228229
// Builtin variable time:
229-
protected constant SCode.Element BUILTIN_TIME = SCode.COMPONENT("time", SCode.defaultPrefixes,
230+
public constant SCode.Element BUILTIN_TIME = SCode.COMPONENT("time", SCode.defaultPrefixes,
230231
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
231232
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(), NONE(), NONE(), Absyn.dummyInfo);
232233

0 commit comments

Comments
 (0)