Skip to content

Commit

Permalink
Change tag name from kind to $kind in instance API (#9109)
Browse files Browse the repository at this point in the history
- Use `$kind` instead of `kind` as the tag name for expressions in the
  instance API, to make it possible to differentiate between expressions
  and annotations.
  • Loading branch information
perost committed Jun 16, 2022
1 parent 7dffec6 commit e191036
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 47 deletions.
8 changes: 4 additions & 4 deletions OMCompiler/Compiler/NFFrontEnd/NFCall.mo
Expand Up @@ -836,7 +836,7 @@ public
case TYPED_CALL()
algorithm
path := Function.nameConsiderBuiltin(call.fn);
json := JSON.addPair("kind", JSON.makeString("call"), json);
json := JSON.addPair("$kind", JSON.makeString("call"), json);
json := JSON.addPair("name", JSON.makeString(AbsynUtil.pathString(path)), json);
json := JSON.addPair("arguments", JSON.makeArray(
list(Expression.toJSON(a) for a in call.arguments)), json);
Expand All @@ -845,7 +845,7 @@ public

case TYPED_ARRAY_CONSTRUCTOR()
algorithm
json := JSON.addPair("kind", JSON.makeString("array_constructor"), json);
json := JSON.addPair("$kind", JSON.makeString("array_constructor"), json);
json := JSON.addPair("exp", Expression.toJSON(call.exp), json);
json := JSON.addPair("iterators", iterators_json(call.iters), json);
then
Expand All @@ -854,7 +854,7 @@ public
case TYPED_REDUCTION()
algorithm
path := Function.nameConsiderBuiltin(call.fn);
json := JSON.addPair("kind", JSON.makeString("reduction"), json);
json := JSON.addPair("$kind", JSON.makeString("reduction"), json);
json := JSON.addPair("name", JSON.makeString(AbsynUtil.pathString(path)), json);
json := JSON.addPair("exp", Expression.toJSON(call.exp), json);
json := JSON.addPair("iterators", iterators_json(call.iters), json);
Expand All @@ -863,7 +863,7 @@ public

else
algorithm
json := JSON.addPair("kind", JSON.makeString("call"), json);
json := JSON.addPair("$kind", JSON.makeString("call"), json);
then
();

Expand Down
4 changes: 2 additions & 2 deletions OMCompiler/Compiler/NFFrontEnd/NFComponentRef.mo
Expand Up @@ -1179,7 +1179,7 @@ public
case CREF()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("cref"), json);
json := JSON.addPair("$kind", JSON.makeString("cref"), json);
json := JSON.addPair("parts", JSON.makeArray(toJSON_impl(cref)), json);
then
json;
Expand All @@ -1189,7 +1189,7 @@ public
case WILD()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("cref"), json);
json := JSON.addPair("$kind", JSON.makeString("cref"), json);
json := JSON.addPair("parts", JSON.makeArray(
{JSON.fromPair("name", JSON.makeString("_"))}), json);
then
Expand Down
38 changes: 19 additions & 19 deletions OMCompiler/Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -5852,7 +5852,7 @@ public
case Expression.ENUM_LITERAL()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("enum"), json);
json := JSON.addPair("$kind", JSON.makeString("enum"), json);
json := JSON.addPair("name", JSON.makeString(Expression.toString(exp)), json);
json := JSON.addPair("index", JSON.makeInteger(exp.index), json);
then
Expand All @@ -5866,7 +5866,7 @@ public
case Expression.TYPENAME()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("typename"), json);
json := JSON.addPair("$kind", JSON.makeString("typename"), json);
json := JSON.addPair("name", JSON.makeString(Type.toString(exp.ty)), json);
then
json;
Expand All @@ -5883,7 +5883,7 @@ public
case Expression.RANGE()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("range"), json);
json := JSON.addPair("$kind", JSON.makeString("range"), json);
json := JSON.addPair("start", toJSON(exp.start), json);

if isSome(exp.step) then
Expand All @@ -5897,7 +5897,7 @@ public
case Expression.TUPLE()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("tuple"), json);
json := JSON.addPair("$kind", JSON.makeString("tuple"), json);
json := JSON.addPair("elements",
JSON.makeArray(list(toJSON(e) for e in exp.elements)), json);
then
Expand All @@ -5906,7 +5906,7 @@ public
case Expression.RECORD()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("record"), json);
json := JSON.addPair("$kind", JSON.makeString("record"), json);
json := JSON.addPair("name", JSON.makeString(AbsynUtil.pathString(exp.path)), json);
json := JSON.addPair("elements",
JSON.makeArray(list(toJSON(e) for e in exp.elements)), json);
Expand All @@ -5919,7 +5919,7 @@ public
case Expression.SIZE()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("size"), json);
json := JSON.addPair("$kind", JSON.makeString("size"), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);

if isSome(exp.dimIndex) then
Expand All @@ -5931,7 +5931,7 @@ public
case Expression.BINARY()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("binary_op"), json);
json := JSON.addPair("$kind", JSON.makeString("binary_op"), json);
json := JSON.addPair("lhs", toJSON(exp.exp1), json);
json := JSON.addPair("op", JSON.makeString(Operator.symbol(exp.operator)), json);
json := JSON.addPair("rhs", toJSON(exp.exp2), json);
Expand All @@ -5941,7 +5941,7 @@ public
case Expression.UNARY()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("unary_op"), json);
json := JSON.addPair("$kind", JSON.makeString("unary_op"), json);
json := JSON.addPair("op", JSON.makeString(Operator.symbol(exp.operator)), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);
then
Expand All @@ -5950,7 +5950,7 @@ public
case Expression.LBINARY()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("binary_op"), json);
json := JSON.addPair("$kind", JSON.makeString("binary_op"), json);
json := JSON.addPair("lhs", toJSON(exp.exp1), json);
json := JSON.addPair("op", JSON.makeString(Operator.symbol(exp.operator)), json);
json := JSON.addPair("rhs", toJSON(exp.exp2), json);
Expand All @@ -5960,7 +5960,7 @@ public
case Expression.LUNARY()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("unary_op"), json);
json := JSON.addPair("$kind", JSON.makeString("unary_op"), json);
json := JSON.addPair("op", JSON.makeString(Operator.symbol(exp.operator)), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);
then
Expand All @@ -5969,7 +5969,7 @@ public
case Expression.RELATION()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("relation"), json);
json := JSON.addPair("$kind", JSON.makeString("relation"), json);
json := JSON.addPair("lhs", toJSON(exp.exp1), json);
json := JSON.addPair("op", JSON.makeString(Operator.symbol(exp.operator)), json);
json := JSON.addPair("rhs", toJSON(exp.exp2), json);
Expand All @@ -5979,7 +5979,7 @@ public
case Expression.IF()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("if"), json);
json := JSON.addPair("$kind", JSON.makeString("if"), json);
json := JSON.addPair("condition", toJSON(exp.condition), json);
json := JSON.addPair("true", toJSON(exp.trueBranch), json);
json := JSON.addPair("false", toJSON(exp.falseBranch), json);
Expand All @@ -5989,7 +5989,7 @@ public
case Expression.CAST()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("cast"), json);
json := JSON.addPair("$kind", JSON.makeString("cast"), json);
json := JSON.addPair("type", JSON.makeString(Type.toString(exp.ty)), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);
then
Expand All @@ -5998,23 +5998,23 @@ public
case Expression.BOX()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("box"), json);
json := JSON.addPair("$kind", JSON.makeString("box"), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);
then
json;

case Expression.UNBOX()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("unbox"), json);
json := JSON.addPair("$kind", JSON.makeString("unbox"), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);
then
json;

case Expression.SUBSCRIPTED_EXP()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("sub"), json);
json := JSON.addPair("$kind", JSON.makeString("sub"), json);
json := JSON.addPair("exp", toJSON(exp.exp), json);
json := JSON.addPair("subscripts", Subscript.toJSONList(exp.subscripts), json);
then
Expand All @@ -6023,7 +6023,7 @@ public
case Expression.TUPLE_ELEMENT()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("tuple_element"), json);
json := JSON.addPair("$kind", JSON.makeString("tuple_element"), json);
json := JSON.addPair("exp", toJSON(exp.tupleExp), json);
json := JSON.addPair("index", JSON.makeInteger(exp.index), json);
then
Expand All @@ -6032,7 +6032,7 @@ public
case Expression.RECORD_ELEMENT()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("record_element"), json);
json := JSON.addPair("$kind", JSON.makeString("record_element"), json);
json := JSON.addPair("exp", toJSON(exp.recordExp), json);
json := JSON.addPair("index", JSON.makeInteger(exp.index), json);
json := JSON.addPair("field", JSON.makeString(exp.fieldName), json);
Expand All @@ -6042,7 +6042,7 @@ public
case Expression.PARTIAL_FUNCTION_APPLICATION()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("function"), json);
json := JSON.addPair("$kind", JSON.makeString("function"), json);
json := JSON.addPair("name", JSON.makeString(ComponentRef.toString(exp.fn)), json);
json := JSON.addPair("arguments", JSON.makeArray(
list(dump_arg(name, arg) threaded for arg in exp.args, name in exp.argNames)), json);
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/Script/NFApi.mo
Expand Up @@ -1306,7 +1306,7 @@ algorithm
case Absyn.Exp.CALL()
algorithm
json := JSON.emptyObject();
json := JSON.addPair("kind", JSON.makeString("call"), json);
json := JSON.addPair("$kind", JSON.makeString("call"), json);
json := JSON.addPair("name", dumpJSONAbsynCref(exp.function_), json);
json := dumpJSONAbsynFunctionArgs(exp.functionArgs, json);
then
Expand Down
Expand Up @@ -23,7 +23,7 @@ getModelInstance(M, prettyPrint=true);
// \"Icon\": {
// \"graphics\": [
// {
// \"kind\": \"record\",
// \"$kind\": \"record\",
// \"name\": \"Rectangle\",
// \"elements\": [
// true,
Expand All @@ -43,18 +43,18 @@ getModelInstance(M, prettyPrint=true);
// 0
// ],
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"LinePattern.Solid\",
// \"index\": 2
// },
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"FillPattern.None\",
// \"index\": 1
// },
// 0.25,
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"BorderPattern.None\",
// \"index\": 1
// },
Expand All @@ -76,7 +76,7 @@ getModelInstance(M, prettyPrint=true);
// \"Diagram\": {
// \"graphics\": [
// {
// \"kind\": \"record\",
// \"$kind\": \"record\",
// \"name\": \"Ellipse\",
// \"elements\": [
// true,
Expand All @@ -96,12 +96,12 @@ getModelInstance(M, prettyPrint=true);
// 0
// ],
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"LinePattern.Solid\",
// \"index\": 2
// },
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"FillPattern.None\",
// \"index\": 1
// },
Expand All @@ -119,7 +119,7 @@ getModelInstance(M, prettyPrint=true);
// 0,
// 360,
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"EllipseClosure.Chord\",
// \"index\": 2
// }
Expand Down
Expand Up @@ -23,7 +23,7 @@ getModelInstance(M, prettyPrint=true);
// \"Icon\": {
// \"graphics\": [
// {
// \"kind\": \"record\",
// \"$kind\": \"record\",
// \"name\": \"Rectangle\",
// \"elements\": [
// true,
Expand All @@ -43,18 +43,18 @@ getModelInstance(M, prettyPrint=true);
// 0
// ],
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"LinePattern.Solid\",
// \"index\": 2
// },
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"FillPattern.None\",
// \"index\": 1
// },
// 0.25,
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"BorderPattern.None\",
// \"index\": 1
// },
Expand All @@ -72,7 +72,7 @@ getModelInstance(M, prettyPrint=true);
// ]
// },
// {
// \"kind\": \"record\",
// \"$kind\": \"record\",
// \"name\": \"Ellipse\",
// \"elements\": [
// true,
Expand All @@ -92,12 +92,12 @@ getModelInstance(M, prettyPrint=true);
// 0
// ],
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"LinePattern.Solid\",
// \"index\": 2
// },
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"FillPattern.None\",
// \"index\": 1
// },
Expand All @@ -115,7 +115,7 @@ getModelInstance(M, prettyPrint=true);
// 0,
// 360,
// {
// \"kind\": \"enum\",
// \"$kind\": \"enum\",
// \"name\": \"EllipseClosure.Chord\",
// \"index\": 2
// }
Expand Down
Expand Up @@ -127,15 +127,15 @@ getModelInstance(M, prettyPrint = true);
// \"connections\": [
// {
// \"lhs\": {
// \"kind\": \"cref\",
// \"$kind\": \"cref\",
// \"parts\": [
// {
// \"name\": \"c1\"
// }
// ]
// },
// \"rhs\": {
// \"kind\": \"cref\",
// \"$kind\": \"cref\",
// \"parts\": [
// {
// \"name\": \"c3\"
Expand Down Expand Up @@ -167,15 +167,15 @@ getModelInstance(M, prettyPrint = true);
// },
// {
// \"lhs\": {
// \"kind\": \"cref\",
// \"$kind\": \"cref\",
// \"parts\": [
// {
// \"name\": \"c1\"
// }
// ]
// },
// \"rhs\": {
// \"kind\": \"cref\",
// \"$kind\": \"cref\",
// \"parts\": [
// {
// \"name\": \"c2\"
Expand Down

0 comments on commit e191036

Please sign in to comment.