Changeset c8e35cd in OpenModelica
- Timestamp:
- 2024-05-23T12:53:11+02:00 (3 weeks ago)
- Branches:
- master
- Children:
- 8cc47a0c, f191ed8
- Parents:
- d5dbbd9b
- git-author:
- Per Östlund <per.ostlund@…> (05/23/24 12:53:11)
- git-committer:
- GitHub <noreply@…> (05/23/24 12:53:11)
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/NFFrontEnd/NFEquation.mo
r901e52a8 rc8e35cd 1527 1527 end match; 1528 1528 1529 s := FlatModelicaUtil.appendElementSourceComment(source(eq), s);1529 s := FlatModelicaUtil.appendElementSourceComment(source(eq), NFFlatModelicaUtil.ElementType.EQUATION, s); 1530 1530 end toFlatStream; 1531 1531 -
OMCompiler/Compiler/NFFrontEnd/NFFlatModel.mo
r018ac8eb rc8e35cd 234 234 String name = className(flatModel); 235 235 algorithm 236 s := IOStream.append(s, "//! base 0.1.0\n"); 236 237 s := IOStream.append(s, "package '" + name + "'\n"); 237 238 flat_model.variables := reconstructRecordInstances(flat_model.variables); … … 282 283 end for; 283 284 284 s := FlatModelicaUtil.appendElementSourceCommentAnnotation(flat_model.source, " ", ";\n", s); 285 s := FlatModelicaUtil.appendElementSourceCommentAnnotation(flat_model.source, 286 NFFlatModelicaUtil.ElementType.ROOT_CLASS, " ", ";\n", s); 285 287 s := IOStream.append(s, " end '" + name + "';\n"); 286 288 s := IOStream.append(s, "end '" + name + "';\n"); -
OMCompiler/Compiler/NFFrontEnd/NFFlatModelicaUtil.mo
rb3681ace rc8e35cd 43 43 import Util; 44 44 45 // Used to indicate what type of element an annotation comes from, to allow 46 // filtering out specific annotations for dumping. 47 type ElementType = enumeration( 48 ROOT_CLASS, 49 CLASS, 50 FUNCTION, 51 COMPONENT, 52 EQUATION, 53 ALGORITHM, 54 OTHER 55 ); 56 45 57 function appendElementSourceCommentString 46 58 input DAE.ElementSource source; … … 52 64 function appendElementSourceCommentAnnotation 53 65 input DAE.ElementSource source; 66 input ElementType elementType; 54 67 input String indent; 55 68 input String ending; 56 69 input output IOStream.IOStream s; 57 70 algorithm 58 s := appendCommentAnnotation(ElementSource.getOptComment(source), indent, ending, s);71 s := appendCommentAnnotation(ElementSource.getOptComment(source), elementType, indent, ending, s); 59 72 end appendElementSourceCommentAnnotation; 60 73 61 74 function appendElementSourceComment 62 75 input DAE.ElementSource source; 63 input output IOStream.IOStream s; 64 algorithm 65 s := appendComment(ElementSource.getOptComment(source), s); 76 input ElementType elementType; 77 input output IOStream.IOStream s; 78 algorithm 79 s := appendComment(ElementSource.getOptComment(source), elementType, s); 66 80 end appendElementSourceComment; 67 81 68 82 function appendComment 69 83 input Option<SCode.Comment> comment; 84 input ElementType elementType; 70 85 input output IOStream.IOStream s; 71 86 algorithm 72 87 s := appendCommentString(comment, s); 73 s := appendCommentAnnotation(comment, " ", "", s);88 s := appendCommentAnnotation(comment, elementType, " ", "", s); 74 89 end appendComment; 75 90 … … 95 110 function appendCommentAnnotation 96 111 input Option<SCode.Comment> comment; 112 input ElementType elementType; 97 113 input String indent; 98 114 input String ending; … … 105 121 SOME(SCode.Annotation.ANNOTATION(modification = mod)))) 106 122 algorithm 107 mod := DAEDump.filterStructuralMods(mod); 123 mod := match elementType 124 case ElementType.ROOT_CLASS then filterRootClassAnnotations(mod); 125 else DAEDump.filterStructuralMods(mod); 126 end match; 108 127 109 128 if not SCodeUtil.isEmptyMod(mod) then … … 120 139 end appendCommentAnnotation; 121 140 141 function filterRootClassAnnotations 142 input output SCode.Mod mod; 143 protected 144 function filter 145 input SCode.SubMod smod; 146 output Boolean keep; 147 algorithm 148 keep := match smod.ident 149 case "experiment" then true; 150 else false; 151 end match; 152 end filter; 153 algorithm 154 mod := SCodeUtil.filterSubMods(mod, filter); 155 end filterRootClassAnnotations; 156 122 157 function appendAnnotationMod 123 158 input SCode.Mod mod; -
OMCompiler/Compiler/NFFrontEnd/NFFunction.mo
rd9f2966 rc8e35cd 881 881 s := IOStream.append(s, ", "); 882 882 s := IOStream.append(s, stringDelimitList(getDerivedInputNames(fn), ", ")); 883 s := FlatModelicaUtil.appendComment(SCodeUtil.getElementComment(InstNode.definition(fn.node)), s); 883 s := FlatModelicaUtil.appendComment(SCodeUtil.getElementComment(InstNode.definition(fn.node)), 884 NFFlatModelicaUtil.ElementType.FUNCTION, s); 884 885 s := IOStream.append(s, ")"); 885 886 else … … 931 932 if not SCodeUtil.emptyModOrEquality(annMod) then 932 933 cmt := SCode.COMMENT(SOME(SCode.ANNOTATION(annMod)), NONE()); 933 s := FlatModelicaUtil.appendCommentAnnotation(SOME(cmt), indent + " ", ";\n", s); 934 s := FlatModelicaUtil.appendCommentAnnotation(SOME(cmt), 935 NFFlatModelicaUtil.ElementType.FUNCTION, indent + " ", ";\n", s); 934 936 end if; 935 937 -
OMCompiler/Compiler/NFFrontEnd/NFStatement.mo
rb727a78 rc8e35cd 1031 1031 end match; 1032 1032 1033 s := FlatModelicaUtil.appendElementSourceComment(source(stmt), s);1033 s := FlatModelicaUtil.appendElementSourceComment(source(stmt), NFFlatModelicaUtil.ElementType.ALGORITHM, s); 1034 1034 end toFlatStream; 1035 1035 -
OMCompiler/Compiler/NFFrontEnd/NFVariable.mo
r018ac8eb rc8e35cd 583 583 584 584 s := toFlatStreamBinding(var.binding, printBindingType, s); 585 s := FlatModelicaUtil.appendComment(var.comment, s);585 s := FlatModelicaUtil.appendComment(var.comment, NFFlatModelicaUtil.ElementType.COMPONENT, s); 586 586 end toFlatStream; 587 587 -
testsuite/flattening/modelica/scodeinst/CombineSubscripts3.mo
rd3aac72 rc8e35cd 21 21 22 22 // Result: 23 // //! base 0.1.0 23 24 // package 'CombineSubscripts3' 24 25 // model 'CombineSubscripts3' -
testsuite/openmodelica/basemodelica/ArrayBinding1.mo
rc3d1dae rc8e35cd 13 13 14 14 // Result: 15 // //! base 0.1.0 15 16 // package 'ArrayBinding1' 16 17 // model 'ArrayBinding1' -
testsuite/openmodelica/basemodelica/Comments.mo
r77614c7 rc8e35cd 11 11 x + y = 0 "Some equation" annotation(__A = true); 12 12 x - y = 1 "Some other equation"; 13 annotation(version = "1.0.0" );13 annotation(version = "1.0.0", experiment(StopTime = 1.0)); 14 14 end Comments; 15 15 16 16 // Result: 17 // //! base 0.1.0 17 18 // package 'Comments' 18 19 // model 'Comments' "Model to test comments in Flat Modelica output" … … 22 23 // 'x' + 'y' = 0.0 "Some equation"; 23 24 // 'x' - 'y' = 1.0 "Some other equation"; 25 // annotation(experiment(StopTime = 1.0)); 24 26 // end 'Comments'; 25 27 // end 'Comments'; -
testsuite/openmodelica/basemodelica/Expression1.mo
r46a181d rc8e35cd 20 20 21 21 // Result: 22 // //! base 0.1.0 22 23 // package 'Expression1' 23 24 // function 'f' -
testsuite/openmodelica/basemodelica/InStreamNominalThreshold.mo
rd9f2966 rc8e35cd 36 36 37 37 // Result: 38 // //! base 0.1.0 38 39 // package 'InStreamNominalThreshold' 39 40 // function '$OMC$PositiveMax' -
testsuite/openmodelica/basemodelica/Record1.mo
rd5dbbd9b rc8e35cd 18 18 19 19 // Result: 20 // //! base 0.1.0 20 21 // package 'Record1' 21 22 // record 'R' -
testsuite/openmodelica/basemodelica/Record2.mo
rd5dbbd9b rc8e35cd 21 21 22 22 // Result: 23 // //! base 0.1.0 23 24 // package 'Record2' 24 25 // record 'R' -
testsuite/openmodelica/basemodelica/SD.mo
r77614c7 rc8e35cd 43 43 44 44 // Result: 45 // //! base 0.1.0 45 46 // package 'SD' 46 47 // model 'SD' -
testsuite/openmodelica/basemodelica/SimpleCoolingCycle.mo
r46a181d rc8e35cd 55 55 56 56 // Result: 57 // //! base 0.1.0 57 58 // package 'SimpleCoolingCycle' 58 59 // function 'SimpleCoolingCycle.heatExchange_CounterFlowNTU.MediumA.specificHeatCapacityCp' -
testsuite/openmodelica/basemodelica/Tables.mos
r46a181d rc8e35cd 28 28 // true 29 29 // true 30 // "[openmodelica/basemodelica/Tables.mo:3 2:3-46:43:writable] Warning: Pure function ''Test33'.'Modelica.Utilities.Strings.isEmpty'' contains a call to impure function ''Test33'.'Modelica.Utilities.Strings.Advanced.skipWhiteSpace''.30 // "[openmodelica/basemodelica/Tables.mo:33:3-47:43:writable] Warning: Pure function ''Test33'.'Modelica.Utilities.Strings.isEmpty'' contains a call to impure function ''Test33'.'Modelica.Utilities.Strings.Advanced.skipWhiteSpace''. 31 31 // " 32 32 // "Tables_res.mat"
Note: See TracChangeset
for help on using the changeset viewer.