Skip to content

Commit b676ce0

Browse files
author
Peter Aronsson
committed
Fixed bug with Diagram in component annotations.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@922 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent b715396 commit b676ce0

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

modeq/dump.rml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,17 @@ relation unparse_class_modification_str: Absyn.Modification => string =
278278

279279
axiom unparse_class_modification_str(Absyn.CLASSMOD([],_)) => ""
280280

281-
rule get_string_list(l,unparse_element_arg_str,",") => s1 &
281+
rule get_string_list(l,unparse_element_arg_str,",") => s1 &
282282
string_append("(",s1) => s2 &
283283
string_append(s2,")") => str
284284
---------------------------------------------------------
285-
unparse_class_modification_str(Absyn.CLASSMOD(l,_)) => str
285+
unparse_class_modification_str(Absyn.CLASSMOD(l,NONE)) => str
286+
287+
rule print_exp_str e => s1 &
288+
Util.string_append_list(["=",s1]) => str
289+
---------------------------------------------------------
290+
unparse_class_modification_str(Absyn.CLASSMOD(_,SOME(e))) => str
291+
286292

287293
end
288294
(**)
@@ -495,8 +501,8 @@ end
495501
relation unparse_annotation_option: Absyn.Annotation option => string =
496502

497503
rule unparse_class_modification_str Absyn.CLASSMOD(mod,NONE) => s1 &
498-
string_append(" annotation(",s1) => s2 &
499-
string_append(s2,")") => str
504+
string_append(" annotation",s1) => s2 &
505+
string_append(s2,"") => str
500506
----------------------------
501507
unparse_annotation_option(SOME(Absyn.ANNOTATION(mod))) => str
502508

modeq/inst.rml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -935,27 +935,11 @@ relation inst_element : (Env, Mod, Prefix, Connect.Sets, ClassInf.State,
935935

936936
Mod.merge(classmod',mm') => mod &
937937
Mod.merge(mod,m') => mod1 &
938-
<<<<<<< inst.rml
939-
Debug.fprintln ("redecl", "Merged modifications") &
940-
Debug.fcall ("redecl", Mod.print_mod, mod1) &
941-
print "inst_element :" & print n & print "before redeclare\n" &
942-
redeclare_type(mod1,comp,env2,pre,impl) => (SCode.COMPONENT(n,final,repl,prot,
943-
=======
944938

945939
redeclare_type(mod1,comp,env2,pre,impl) => (SCode.COMPONENT(n,final,repl,prot,
946-
>>>>>>> 1.127
947940
attr as SCode.ATTR(ad,flow,acc,param,dir),
948-
<<<<<<< inst.rml
949941
t,m),mod',env2') &
950-
print "inst_element :" & print n & print "after redeclare\n" &
951-
Debug.fprintln ("redecl", "Merged modifications") &
952-
Debug.fcall ("redecl", Mod.print_mod, mod') &
953942

954-
955-
=======
956-
t,m),mod',env2') &
957-
958-
>>>>>>> 1.127
959943
Debug.fprint("insttr", "looking for type") &
960944
Debug.fcall("insttr",Dump.print_path,t) &
961945
Debug.fprint("insttr"," in env:") &

modeq/interactive.rml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,15 +1963,15 @@ relation get_componentitems_annotation: Absyn.ComponentItem list => string =
19631963
string_append(s3,str) => res
19641964
----------------------------
19651965
get_componentitems_annotation (Absyn.COMPONENTITEM(_,SOME(Absyn.COMMENT(SOME(
1966-
Absyn.ANNOTATION(Absyn.MODIFICATION(_,_,Absyn.CREF_IDENT("Diagram",_),Absyn.CLASSMOD(mod,_),_)::_)
1966+
Absyn.ANNOTATION(mod as Absyn.MODIFICATION(_,_,Absyn.CREF_IDENT("Placement",_),_,_)::_)
19671967
),_)))::(rest as (_::_))) => res
19681968

19691969
rule get_annotation_string(Placement_records, Absyn.ANNOTATION(mod)) => s1 &
19701970
string_append("{",s1) => s2 &
19711971
string_append(s2,"}") => res
19721972
----------------------------
19731973
get_componentitems_annotation ([Absyn.COMPONENTITEM(_,SOME(Absyn.COMMENT(SOME(
1974-
Absyn.ANNOTATION(Absyn.MODIFICATION(_,_,Absyn.CREF_IDENT("Diagram",_),Absyn.CLASSMOD(mod,_),_)::_)
1974+
Absyn.ANNOTATION(mod as Absyn.MODIFICATION(_,_, Absyn.CREF_IDENT("Placement",_),_,_)::_)
19751975
),_)))]) => res
19761976

19771977
rule get_componentitems_annotation(rest) => str &
@@ -2585,14 +2585,26 @@ end
25852585
**)
25862586
relation record_constructor_to_modification: (Absyn.Exp ) => Absyn.ElementArg =
25872587

2588-
rule Util.list_map(nargs,namedarg_to_modification) => eltarglst &
2588+
rule (* Covers the case annotate=Diagram(x=1,y=2) *)
2589+
Util.list_map(nargs,namedarg_to_modification) => eltarglst &
25892590
let res = Absyn.MODIFICATION(false,Absyn.NON_EACH,cr,Absyn.CLASSMOD(eltarglst,NONE),NONE)
25902591
-----------------------------------
25912592
record_constructor_to_modification(Absyn.CALL(cr,Absyn.FUNCTIONARGS([],nargs))) => res
2593+
2594+
rule (* Covers the case annotate=Diagram(SOMETHING(x=1,y=2)) *)
2595+
Util.list_map(nargs,namedarg_to_modification) => eltarglst &
2596+
record_constructor_to_modification(e) => emod &
2597+
let res = Absyn.MODIFICATION(false, Absyn.NON_EACH,
2598+
cr, Absyn.CLASSMOD(emod::eltarglst, NONE), NONE)
2599+
-----------------------------------
2600+
record_constructor_to_modification(Absyn.CALL(cr,
2601+
Absyn.FUNCTIONARGS([e as Absyn.CALL(_,_)],nargs))) => res
25922602

2593-
rule Print.print_buf "record_constructor_to_modification failed\n"
2603+
2604+
rule Print.print_buf "record_constructor_to_modification failed, exp=" &
2605+
Absyn.print_absyn_exp e & Print.print_buf "\n"
25942606
-------------------------
2595-
record_constructor_to_modification(_) => fail
2607+
record_constructor_to_modification(e) => fail
25962608
end
25972609

25982610
(** relation: namedarg_to_modification
@@ -2609,4 +2621,8 @@ relation namedarg_to_modification: (Absyn.NamedArg) => Absyn.ElementArg =
26092621
rule let res = Absyn.MODIFICATION(false,Absyn.NON_EACH,Absyn.CREF_IDENT(id,[]),Absyn.CLASSMOD([],SOME(e)),NONE)
26102622
----------------------------------------------------------------
26112623
namedarg_to_modification( Absyn.NAMEDARG(id,e)) => res
2624+
2625+
rule Print.print_buf "- namedarg_to_modification failed\n"
2626+
----------------
2627+
namedarg_to_modification(_) => fail
26122628
end

0 commit comments

Comments
 (0)