@@ -1037,7 +1037,7 @@ algorithm
10371037 json := JSON . addPairNotNull("dims" , dumpJSONClassDims(node, def), json);
10381038 json := JSON . addPair("restriction" ,
10391039 JSON . makeString(Restriction . toString(InstNode . restriction(node))), json);
1040- json := dumpJSONSCodeMod(SCodeUtil . elementMod(def), json);
1040+ json := dumpJSONSCodeMod(SCodeUtil . elementMod(def), scope, json);
10411041
10421042 json := JSON . addPairNotNull("prefixes" , dumpJSONClassPrefixes(def, node), json);
10431043
@@ -1174,7 +1174,7 @@ algorithm
11741174 ext_def := InstNode . extendsDefinition(node);
11751175
11761176 json := JSON . addPair("$kind" , JSON . makeString("extends" ), json);
1177- json := dumpJSONSCodeMod(SCodeUtil . elementMod(ext_def), json);
1177+ json := dumpJSONSCodeMod(SCodeUtil . elementMod(ext_def), node, json);
11781178 json := dumpJSONCommentOpt(SCodeUtil . getElementComment(ext_def), node, json);
11791179
11801180 if Class . isOnlyBuiltin(InstNode . getClass(node)) then
@@ -1218,13 +1218,13 @@ algorithm
12181218 json := JSON . addPairNotNull("dims" , dumpJSONDims(Util . getOption(odims), {}), json);
12191219 end if ;
12201220
1221- json := dumpJSONSCodeMod(cdef. modifications, json);
1221+ json := dumpJSONSCodeMod(cdef. modifications, scope, json);
12221222 then
12231223 ();
12241224
12251225 case SCode . ClassDef . CLASS_EXTENDS ()
12261226 algorithm
1227- json := dumpJSONSCodeMod(cdef. modifications, json);
1227+ json := dumpJSONSCodeMod(cdef. modifications, scope, json);
12281228 then
12291229 ();
12301230
@@ -1267,7 +1267,7 @@ algorithm
12671267 json := JSON . addPair("$kind" , JSON . makeString("component" ), json);
12681268 json := JSON . addPair("name" , JSON . makeString(InstNode . name(node)), json);
12691269 json := JSON . addPair("type" , dumpJSONComponentType(cls, node, comp. ty, isDeleted = true ), json);
1270- json := dumpJSONSCodeMod(elem. modifications, json);
1270+ json := dumpJSONSCodeMod(elem. modifications, scope, json);
12711271 json := JSON . addPair("condition" , JSON . makeBoolean(false ), json);
12721272 json := JSON . addPairNotNull("prefixes" , dumpJSONAttributes(elem. attributes, elem. prefixes, scope), json);
12731273 json := dumpJSONCommentOpt(SOME (elem. comment), scope, json);
@@ -1285,7 +1285,7 @@ algorithm
12851285 dumpJSONDims(elem. attributes. arrayDims, Type . arrayDims(comp. ty)), json);
12861286 end if ;
12871287
1288- json := dumpJSONSCodeMod(elem. modifications, json);
1288+ json := dumpJSONSCodeMod(elem. modifications, scope, json);
12891289
12901290 is_constant := comp. attributes. variability <= Variability . PARAMETER ;
12911291 if Binding . isExplicitlyBound(comp. binding) then
@@ -1540,7 +1540,7 @@ algorithm
15401540 algorithm
15411541 json := JSON . makeNull();
15421542 json := JSON . addPair("constrainedby" , dumpJSONPath(cc. constrainingClass), json);
1543- json := dumpJSONSCodeMod(cc. modifier, json);
1543+ json := dumpJSONSCodeMod(cc. modifier, scope, json);
15441544 json := dumpJSONCommentOpt(SOME (cc. comment), scope, json);
15451545 then
15461546 json;
@@ -1941,16 +1941,18 @@ end dumpJSONReplaceableElements;
19411941
19421942function dumpJSONSCodeMod
19431943 input SCode . Mod mod;
1944+ input InstNode scope;
19441945 input output JSON json;
19451946protected
19461947 JSON j;
19471948algorithm
1948- j := dumpJSONSCodeMod_impl(mod);
1949+ j := dumpJSONSCodeMod_impl(mod, scope );
19491950 json := JSON . addPairNotNull("modifiers" , j, json);
19501951end dumpJSONSCodeMod;
19511952
19521953function dumpJSONSCodeMod_impl
19531954 input SCode . Mod mod;
1955+ input InstNode scope;
19541956 output JSON json = JSON . makeNull();
19551957protected
19561958 JSON binding_json;
@@ -1959,7 +1961,7 @@ algorithm
19591961 case SCode . Mod . MOD ()
19601962 algorithm
19611963 for m in mod. subModLst loop
1962- json := JSON . addPair(m. ident, dumpJSONSCodeMod_impl(m. mod), json);
1964+ json := JSON . addPair(m. ident, dumpJSONSCodeMod_impl(m. mod, scope ), json);
19631965 end for ;
19641966
19651967 if SCodeUtil . finalBool(mod. finalPrefix) then
@@ -1994,13 +1996,37 @@ algorithm
19941996
19951997 binding_json := JSON . makeString(SCodeDump . unparseElementStr(mod. element));
19961998 json := JSON . addPair("$value" , binding_json, json);
1999+ json := dumpJSONRedeclareType(mod. element, scope, json);
19972000 then
19982001 ();
19992002
20002003 else ();
20012004 end match;
20022005end dumpJSONSCodeMod_impl;
20032006
2007+ function dumpJSONRedeclareType
2008+ input SCode . Element element;
2009+ input InstNode scope;
2010+ input output JSON json;
2011+ protected
2012+ Absyn . Path path;
2013+ InstContext . Type context;
2014+ InstNode cls;
2015+ algorithm
2016+ () := matchcontinue element
2017+ case SCode . Element . COMPONENT ()
2018+ algorithm
2019+ path := AbsynUtil . typeSpecPath(element. typeSpec);
2020+ context := InstContext . set(NFInstContext . RELAXED , NFInstContext . FAST_LOOKUP );
2021+ cls := Lookup . lookupName(path, scope, context, checkAccessViolations = false );
2022+ json := JSON . addPair("$type" , dumpJSONNodePath(cls), json);
2023+ then
2024+ ();
2025+
2026+ else ();
2027+ end matchcontinue;
2028+ end dumpJSONRedeclareType;
2029+
20042030function dumpJSONChoicesAnnotation
20052031 input list< SCode . SubMod > mods;
20062032 input InstNode scope;
@@ -2025,7 +2051,7 @@ algorithm
20252051 else m;
20262052 end match;
20272053
2028- j := JSON . addElement(dumpJSONSCodeMod_impl(m. mod), j);
2054+ j := JSON . addElement(dumpJSONSCodeMod_impl(m. mod, scope ), j);
20292055 end for ;
20302056
20312057 json := JSON . addPair("choice" , j, json);
0 commit comments