From 67acb2d4414acee3af392ba2cebb1e329cfee0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Fri, 5 Jan 2018 10:37:15 +0100 Subject: [PATCH] The attributes of a pre-var is the same as the var Belonging to [master]: - OpenModelica/OMCompiler#2097 - OpenModelica/OpenModelica-testsuite#814 --- Compiler/FrontEnd/ComponentReference.mo | 9 +++++++++ Compiler/Template/CodegenCFunctions.tpl | 2 +- Compiler/Template/SimCodeTV.mo | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Compiler/FrontEnd/ComponentReference.mo b/Compiler/FrontEnd/ComponentReference.mo index 78010ddca64..723912886e2 100644 --- a/Compiler/FrontEnd/ComponentReference.mo +++ b/Compiler/FrontEnd/ComponentReference.mo @@ -2078,6 +2078,15 @@ algorithm outCref := makeCrefQual(DAE.previousNamePrefix, DAE.T_UNKNOWN_DEFAULT, {}, inCref); end crefPrefixPrevious; +public function crefRemovePrePrefix + input output DAE.ComponentRef cref; +algorithm + cref := match cref + case DAE.CREF_QUAL(ident=DAE.preNamePrefix) then cref.componentRef; + else cref; + end match; +end crefRemovePrePrefix; + public function crefPrefixStart "public function crefPrefixStart Appends $START to a cref, so a => $START.a" input DAE.ComponentRef inCref; diff --git a/Compiler/Template/CodegenCFunctions.tpl b/Compiler/Template/CodegenCFunctions.tpl index 425915c2f16..59901558faa 100644 --- a/Compiler/Template/CodegenCFunctions.tpl +++ b/Compiler/Template/CodegenCFunctions.tpl @@ -6984,7 +6984,7 @@ end varAttributes; template crefAttributes(ComponentRef cr) ::= - match cref2simvar(cr, getSimCode()) + match cref2simvar(crefRemovePrePrefix(cr), getSimCode()) case var as SIMVAR(index=-1, varKind=JAC_VAR()) then "dummyREAL_ATTRIBUTE" case var as SIMVAR(__) then if intLt(index,0) then error(sourceInfo(), 'varAttributes got negative index=<%index%> for <%crefStr(name)%>') else diff --git a/Compiler/Template/SimCodeTV.mo b/Compiler/Template/SimCodeTV.mo index 8fd33118cab..c6c2cdf4e49 100644 --- a/Compiler/Template/SimCodeTV.mo +++ b/Compiler/Template/SimCodeTV.mo @@ -3244,6 +3244,10 @@ package ComponentReference output DAE.ComponentRef outCR; end popCref; + function crefRemovePrePrefix + input DAE.ComponentRef inCR; + output DAE.ComponentRef outCR; + end crefRemovePrePrefix; end ComponentReference; package Expression