diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Catch_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Catch_Statement.java index 18e9bedd737991ad69782b9836bcf9d30e3d3449..b8d3f1433611403181d36cd35816b8e53b7897a5 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Catch_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Catch_Statement.java @@ -20,8 +20,11 @@ import org.eclipse.titan.designer.AST.ReferenceFinder; import org.eclipse.titan.designer.AST.GovernedSimple.CodeSectionType; import org.eclipse.titan.designer.AST.ReferenceFinder.Hit; import org.eclipse.titan.designer.AST.Scope; +import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type; import org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type; import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port; +import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template; +import org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template; import org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance; import org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator; import org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody; @@ -82,7 +85,7 @@ public final class Catch_Statement extends Statement { private final TemplateInstance parameter; private final boolean timeout; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; @@ -94,7 +97,7 @@ public final class Catch_Statement extends Statement { private Signature_Type signature; public Catch_Statement(final Reference portReference, final boolean anyFrom, final Reference signatureReference, final TemplateInstance parameter, - final boolean timeout, final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender, + final boolean timeout, final TemplateInstance fromClause, final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { this.portReference = portReference; this.anyfrom = anyFrom; @@ -277,7 +280,7 @@ public final class Catch_Statement extends Statement { redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -294,7 +297,7 @@ public final class Catch_Statement extends Statement { public static void checkCatch(final CompilationTimeStamp timestamp, final Statement statement, final String statementName, final Reference portReference, final boolean anyFrom, final Reference signatureReference, final TemplateInstance parameter, final boolean timeout, - final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender, final Reference redirectIndex, + final TemplateInstance fromClause, final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { final Port_Type portType = Port_Utility.checkPortReference(timestamp, statement, portReference, anyFrom); @@ -348,7 +351,7 @@ public final class Catch_Statement extends Statement { if (redirectValue != null) { redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTPARAMETER); - Port_Utility.checkValueRedirect(timestamp, redirectValue, null); + redirectValue.checkErroneous(timestamp); } } else { Signature_Type signature = Port_Utility.checkSignatureReference(timestamp, signatureReference); @@ -388,7 +391,7 @@ public final class Catch_Statement extends Statement { // the receive parameter must also be present IType exceptionType = null; boolean exceptionTypeDetermined = false; - final boolean[] valueRedirectChecked = new boolean[] { false }; + //final boolean[] valueRedirectChecked = new boolean[] { false }; if (signature != null) { final SignatureExceptions exceptions = signature.getSignatureExceptions(); @@ -400,8 +403,7 @@ public final class Catch_Statement extends Statement { if (exceptions.getNofExceptions() == 1) { exceptionType = exceptions.getExceptionByIndex(0); } else if (parameter != null) { - exceptionType = Port_Utility.getIncomingType(timestamp, parameter, redirectValue, - valueRedirectChecked); + exceptionType = get_msg_sig_type(timestamp, parameter); if (exceptionType == null) { parameter.getLocation().reportSemanticError(UNKNOWNEXCEPTIONTYPE); @@ -425,14 +427,15 @@ public final class Catch_Statement extends Statement { } if (!exceptionTypeDetermined) { - exceptionType = Port_Utility.getIncomingType(timestamp, parameter, redirectValue, valueRedirectChecked); + exceptionType = get_msg_sig_type(timestamp, parameter); } if (exceptionType != null && parameter != null) { parameter.check(timestamp, exceptionType); - - if (!valueRedirectChecked[0]) { - Port_Utility.checkValueRedirect(timestamp, redirectValue, exceptionType); + //FIXME add extra check + + if (redirectValue != null) { + redirectValue.check(timestamp, exceptionType); } exceptionType = exceptionType.getTypeRefdLast(timestamp); @@ -465,6 +468,17 @@ public final class Catch_Statement extends Statement { Port_Utility.checkTimestampRedirect(timestamp, portType, redirectTimestamp); } + private static IType get_msg_sig_type(final CompilationTimeStamp timestamp, final TemplateInstance templateInstance) { + IType returnValue = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + if (returnValue != null) { + return returnValue; + } + + TTCN3Template template = templateInstance.getTemplateBody(); + ITTCN3Template converteTemplate = template.setLoweridToReference(timestamp); + return converteTemplate.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + } + @Override /** {@inheritDoc} */ public List<Integer> getPossibleExtensionStarterTokens() { @@ -633,7 +647,7 @@ public final class Catch_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, parameter); } expression.expression.append("), "); } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Catch_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Catch_Statement.java index e37ddff92ee12204dd3e4df7006316ef24956267..7b4b77ab7fc48aefdd5a1ec4c136ebfc8d547f89 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Catch_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Catch_Statement.java @@ -49,7 +49,7 @@ public final class Check_Catch_Statement extends Statement { private final TemplateInstance parameter; private final boolean timeout; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; @@ -58,7 +58,7 @@ public final class Check_Catch_Statement extends Statement { private Signature_Type signature; public Check_Catch_Statement(final Reference portReference, final boolean anyFrom, final Reference signatureReference, final TemplateInstance parameter, - final boolean timeout, final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender, + final boolean timeout, final TemplateInstance fromClause, final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { this.portReference = portReference; this.anyfrom = anyFrom; @@ -221,7 +221,7 @@ public final class Check_Catch_Statement extends Statement { redirectValue, redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -404,7 +404,7 @@ public final class Check_Catch_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, parameter); } expression.expression.append("), "); } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Getreply_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Getreply_Statement.java index 741c6598cf9f1ec898fbefc6c5dd8d64272205a6..89ac56ec8bbc67b6b56fb9161dfaa20f57285384 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Getreply_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Getreply_Statement.java @@ -50,14 +50,14 @@ public final class Check_Getreply_Statement extends Statement { private final TemplateInstance parameter; private final TemplateInstance valueMatch; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Parameter_Redirect redirectParameter; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; public Check_Getreply_Statement(final Reference portReference, final boolean anyFrom, final TemplateInstance parameter, final TemplateInstance valueMatch, - final TemplateInstance fromClause, final Reference redirectValue, final Parameter_Redirect redirectParameter, + final TemplateInstance fromClause, final Value_Redirection redirectValue, final Parameter_Redirect redirectParameter, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { this.portReference = portReference; this.anyFrom = anyFrom; @@ -227,7 +227,7 @@ public final class Check_Getreply_Statement extends Statement { redirectParameter, redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -437,7 +437,7 @@ public final class Check_Getreply_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, valueMatch); } if (redirectParameter != null) { expression.expression.append(", "); diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Receive_Port_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Receive_Port_Statement.java index 1c8c6bec0302d2b87051379f27bf4babcf42fbdf..69bf3fd2671a3b405ffaa6fa4c4ea2e23becbae7 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Receive_Port_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Check_Receive_Port_Statement.java @@ -49,13 +49,13 @@ public final class Check_Receive_Port_Statement extends Statement { private final boolean translate; private final TemplateInstance receiveParameter; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; public Check_Receive_Port_Statement(final Reference portReference, final boolean anyFrom, final TemplateInstance receiveParameter, - final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender, final Reference redirectIndex, + final TemplateInstance fromClause, final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp, final boolean translate) { this.portReference = portReference; this.anyFrom = anyFrom; @@ -202,7 +202,7 @@ public final class Check_Receive_Port_Statement extends Statement { redirectValue, redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -369,7 +369,7 @@ public final class Check_Receive_Port_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, receiveParameter); } expression.expression.append(", "); } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Done_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Done_Statement.java index dcaf86fa6f4bac8996f625c9a4fc3530f0c2a5c0..fb3309b22857b28e4837590a1357e0dea94e0fe2 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Done_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Done_Statement.java @@ -28,6 +28,8 @@ import org.eclipse.titan.designer.AST.Scope; import org.eclipse.titan.designer.AST.Value; import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type; import org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type; +import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template; +import org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template; import org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance; import org.eclipse.titan.designer.AST.TTCN3.types.Array_Type; import org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator; @@ -52,14 +54,14 @@ public final class Done_Statement extends Statement { private final Value componentreference; private final TemplateInstance doneMatch; - private final Reference redirectValue; + private final Value_Redirection redirectValue; //when componentReference is null, this show if the killed was called with any component or all component private final boolean isAny; private final boolean any_from; private final Reference redirectIndex; - public Done_Statement(final Value componentreference, final TemplateInstance doneMatch, final Reference redirectValue, final boolean isAny, final boolean any_from, final Reference redirectIndex) { + public Done_Statement(final Value componentreference, final TemplateInstance doneMatch, final Value_Redirection redirectValue, final boolean isAny, final boolean any_from, final Reference redirectIndex) { this.componentreference = componentreference; this.doneMatch = doneMatch; this.redirectValue = redirectValue; @@ -173,8 +175,8 @@ public final class Done_Statement extends Statement { } if (doneMatch != null) { - final boolean[] valueRedirectChecked = new boolean[] { false }; - final IType returnType = Port_Utility.getIncomingType(timestamp, doneMatch, redirectValue, valueRedirectChecked); + //final boolean[] valueRedirectChecked = new boolean[] { false }; + final IType returnType = get_msg_sig_type(timestamp, doneMatch); if (returnType == null) { doneMatch.getLocation().reportSemanticError("Cannot determine the return type for value returning done"); } else { @@ -209,15 +211,14 @@ public final class Done_Statement extends Statement { returnType.getTypeRefdLast(timestamp).set_needs_any_from_done(); } doneMatch.check(timestamp, returnType); - if (!valueRedirectChecked[0]) { - Port_Utility.checkValueRedirect(timestamp, redirectValue, returnType); + //FIXME add extra check + if (redirectValue != null) { + redirectValue.check(timestamp, returnType); } } } else if (redirectValue != null) { - redirectValue.getLocation().reportSemanticError("Redirect cannot be used for the return value without a matching template"); - Port_Utility.checkValueRedirect(timestamp, redirectValue, null); - redirectValue.setUsedOnLeftHandSide(); + redirectValue.checkVerdictOnly(timestamp); } if (redirectIndex != null && referencedType != null) { @@ -236,6 +237,17 @@ public final class Done_Statement extends Statement { lastTimeChecked = timestamp; } + private static IType get_msg_sig_type(final CompilationTimeStamp timestamp, final TemplateInstance templateInstance) { + IType returnValue = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + if (returnValue != null) { + return returnValue; + } + + TTCN3Template template = templateInstance.getTemplateBody(); + ITTCN3Template converteTemplate = template.setLoweridToReference(timestamp); + return converteTemplate.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + } + @Override /** {@inheritDoc} */ public List<Integer> getPossibleExtensionStarterTokens() { @@ -372,7 +384,7 @@ public final class Done_Statement extends Statement { expression.expression.append("null"); } else { // value redirection present - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, doneMatch); } expression.expression.append(", "); diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Getreply_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Getreply_Statement.java index c864a3b2c80f720ed1531808303a1c1f0369538a..9d838284a13e0a8386039035d038ff13b1bc734e 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Getreply_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Getreply_Statement.java @@ -21,8 +21,11 @@ import org.eclipse.titan.designer.AST.GovernedSimple.CodeSectionType; import org.eclipse.titan.designer.AST.ReferenceFinder.Hit; import org.eclipse.titan.designer.AST.Scope; import org.eclipse.titan.designer.AST.Type; +import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type; import org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type; import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port; +import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template; +import org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template; import org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance; import org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator; import org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody; @@ -72,14 +75,14 @@ public final class Getreply_Statement extends Statement { private final TemplateInstance parameter; private final TemplateInstance valueMatch; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Parameter_Redirect redirectParameter; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; public Getreply_Statement(final Reference portReference, final boolean anyFrom, final TemplateInstance parameter, final TemplateInstance valueMatch, - final TemplateInstance fromClause, final Reference redirectValue, final Parameter_Redirect redirectParameter, + final TemplateInstance fromClause, final Value_Redirection redirectValue, final Parameter_Redirect redirectParameter, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { this.portReference = portReference; this.anyFrom = anyFrom; @@ -257,7 +260,7 @@ public final class Getreply_Statement extends Statement { redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -274,7 +277,7 @@ public final class Getreply_Statement extends Statement { public static void checkGetreply(final CompilationTimeStamp timestamp, final Statement source, final String statementName, final Reference portReference, final boolean anyFrom, final TemplateInstance parameter, final TemplateInstance valueMatch, - final TemplateInstance fromClause, final Reference redirectValue, final Parameter_Redirect redirectParameter, + final TemplateInstance fromClause, final Value_Redirection redirectValue, final Parameter_Redirect redirectParameter, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { final Port_Type portType = Port_Utility.checkPortReference(timestamp, source, portReference, anyFrom); if (parameter == null) { @@ -293,7 +296,7 @@ public final class Getreply_Statement extends Statement { if (redirectValue != null) { redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTSIGNATURE); - Port_Utility.checkValueRedirect(timestamp, redirectValue, null); + redirectValue.checkErroneous(timestamp); } if (redirectParameter != null) { @@ -401,7 +404,9 @@ public final class Getreply_Statement extends Statement { } } - Port_Utility.checkValueRedirect(timestamp, redirectValue, returnType); + if (redirectValue != null) { + redirectValue.check(timestamp, returnType); + } } } @@ -415,6 +420,17 @@ public final class Getreply_Statement extends Statement { Port_Utility.checkTimestampRedirect(timestamp, portType, redirectTimestamp); } + private static IType get_msg_sig_type(final CompilationTimeStamp timestamp, final TemplateInstance templateInstance) { + IType returnValue = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + if (returnValue != null) { + return returnValue; + } + + TTCN3Template template = templateInstance.getTemplateBody(); + ITTCN3Template converteTemplate = template.setLoweridToReference(timestamp); + return converteTemplate.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + } + @Override /** {@inheritDoc} */ public List<Integer> getPossibleExtensionStarterTokens() { @@ -610,7 +626,7 @@ public final class Getreply_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, valueMatch); } if (redirectParameter != null) { expression.expression.append(", "); diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Killed_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Killed_Statement.java index 803625e99a78fa2d8b03b47e98fe9f57d743b676..45fdb4120539bbc20e04d4171832702eb99da43b 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Killed_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Killed_Statement.java @@ -41,11 +41,11 @@ public final class Killed_Statement extends Statement { private final boolean isAny; //FIXME does not yet handle value redirection - final Reference redirect; + final Value_Redirection redirect; private final boolean anyFrom; private final Reference redirectIndex; - public Killed_Statement(final Value componentReference, final Reference redirect, final boolean isAny, final boolean any_from, final Reference redirectIndex) { + public Killed_Statement(final Value componentReference, final Value_Redirection redirect, final boolean isAny, final boolean any_from, final Reference redirectIndex) { this.componentReference = componentReference; this.isAny = isAny; this.redirect = redirect; diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Receive_Port_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Receive_Port_Statement.java index 62ebe41c9bac211ab5c1b3972629e3b6a11562e1..8fff80636228176dead88e9c4ef2f7f5ecd34897 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Receive_Port_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Receive_Port_Statement.java @@ -22,9 +22,12 @@ import org.eclipse.titan.designer.AST.Reference; import org.eclipse.titan.designer.AST.ReferenceFinder; import org.eclipse.titan.designer.AST.ReferenceFinder.Hit; import org.eclipse.titan.designer.AST.Scope; +import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type; import org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type; import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port; import org.eclipse.titan.designer.AST.TTCN3.definitions.PortScope; +import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template; +import org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template; import org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance; import org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator; import org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody; @@ -69,13 +72,13 @@ public final class Receive_Port_Statement extends Statement { private final boolean translate; private final TemplateInstance receiveParameter; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; public Receive_Port_Statement(final Reference portReference, final boolean anyFrom, final TemplateInstance receiveParameter, - final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender, + final TemplateInstance fromClause, final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp, final boolean translate) { this.portReference = portReference; this.anyFrom = anyFrom; @@ -127,7 +130,7 @@ public final class Receive_Port_Statement extends Statement { * <code>null</code> if the statement does not redirect the * value. */ - public Reference getRedirectValue() { + public Value_Redirection getRedirectValue() { return redirectValue; } @@ -243,7 +246,7 @@ public final class Receive_Port_Statement extends Statement { redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -286,7 +289,7 @@ public final class Receive_Port_Statement extends Statement { * */ public static void checkReceivingStatement(final CompilationTimeStamp timestamp, final Statement origin, final String statementName, final Reference portReference, final boolean anyFrom, final boolean translate, final TemplateInstance receiveParameter, final TemplateInstance fromClause, - final Reference redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { + final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { Port_Type portType; if (translate) { final PortScope ps = origin.getMyStatementBlock().getScopePort(); @@ -316,13 +319,13 @@ public final class Receive_Port_Statement extends Statement { if (redirectValue != null) { redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTRECEIVEPARAMETER); - Port_Utility.checkValueRedirect(timestamp, redirectValue, null); + redirectValue.checkErroneous(timestamp); } } else { // determine the type of the incoming message IType messageType = null; boolean messageTypeDetermined = false; - final boolean[] valueRedirectChecked = new boolean[] { false }; + //final boolean[] valueRedirectChecked = new boolean[] { false }; if (portType != null) { // the port type is known @@ -335,8 +338,7 @@ public final class Receive_Port_Statement extends Statement { if (inMessages.getNofTypes() == 1) { messageType = inMessages.getTypeByIndex(0); } else { - messageType = Port_Utility.getIncomingType(timestamp, receiveParameter, redirectValue, - valueRedirectChecked); + messageType = get_msg_sig_type(timestamp, receiveParameter); if (messageType == null) { receiveParameter.getLocation().reportSemanticError(UNKNOWNINCOMINGMESSAGE); } else { @@ -368,13 +370,14 @@ public final class Receive_Port_Statement extends Statement { } if (!messageTypeDetermined) { - messageType = Port_Utility.getIncomingType(timestamp, receiveParameter, redirectValue, valueRedirectChecked); + messageType = get_msg_sig_type(timestamp, receiveParameter); } if (messageType != null) { receiveParameter.check(timestamp, messageType); - if (!valueRedirectChecked[0]) { - Port_Utility.checkValueRedirect(timestamp, redirectValue, messageType); + //FIXME extra check + if (redirectValue != null) { + redirectValue.check(timestamp, messageType); } } } @@ -389,6 +392,17 @@ public final class Receive_Port_Statement extends Statement { Port_Utility.checkTimestampRedirect(timestamp, portType, redirectTimestamp); } + private static IType get_msg_sig_type(final CompilationTimeStamp timestamp, final TemplateInstance templateInstance) { + IType returnValue = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + if (returnValue != null) { + return returnValue; + } + + TTCN3Template template = templateInstance.getTemplateBody(); + ITTCN3Template converteTemplate = template.setLoweridToReference(timestamp); + return converteTemplate.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE); + } + @Override /** {@inheritDoc} */ public List<Integer> getPossibleExtensionStarterTokens() { @@ -541,7 +555,7 @@ public final class Receive_Port_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, receiveParameter); } expression.expression.append(", "); } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Single_ValueRedirection.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Single_ValueRedirection.java new file mode 100644 index 0000000000000000000000000000000000000000..f569982a7d9d3b5a8c1ed0c11d21660c5fda36b4 --- /dev/null +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Single_ValueRedirection.java @@ -0,0 +1,232 @@ +/****************************************************************************** + * Copyright (c) 2000-2018 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + ******************************************************************************/ +package org.eclipse.titan.designer.AST.TTCN3.statements; + +import java.util.ArrayList; + +import org.eclipse.titan.designer.AST.ASTNode; +import org.eclipse.titan.designer.AST.ASTVisitor; +import org.eclipse.titan.designer.AST.ILocateableNode; +import org.eclipse.titan.designer.AST.INamedNode; +import org.eclipse.titan.designer.AST.ISubReference; +import org.eclipse.titan.designer.AST.IType; +import org.eclipse.titan.designer.AST.IValue; +import org.eclipse.titan.designer.AST.Location; +import org.eclipse.titan.designer.AST.NULL_Location; +import org.eclipse.titan.designer.AST.Reference; +import org.eclipse.titan.designer.AST.Scope; +import org.eclipse.titan.designer.AST.Value; +import org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable; +import org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException; +import org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReparseUpdater; + +/** + * Class for storing a single element of a value redirect + * Each of these elements can be: + * - a lone variable reference (in this case the whole value is redirected to + * the referenced variable), or + * - the assignment of a field or a field's sub-reference to a variable + * (in this case one of the value's fields, or a sub-reference of one of the + * fields is redirected to the referenced variable; this can only happen if + * the value is a record or set). + * + * @author Kristof Szabados + */ +public class Single_ValueRedirection extends ASTNode implements ILocateableNode, IIncrementallyUpdateable { + + /** reference to the variable the value is redirected to */ + private Reference variableReference; + + /** + * indicates which part (record field or array element) of the value is + * redirected (optional) + */ + private ArrayList<ISubReference> subreferences; + + /** + * indicates whether the redirected field or element should be decoded + * (only used if subrefs is not null) + */ + private boolean decoded; + + /** + * encoding format for decoded universal charstring value redirects + * (only used if subrefs is not null and decoded is true) + */ + private Value encodingString; + + /** + * pointer to the type the redirected field or element is decoded into + * (only used if subrefs is not null and decoded is true), not owned + */ + private IType declarationType; + + private Location location = NULL_Location.INSTANCE; + + public Single_ValueRedirection(final Reference variableReference) { + this.variableReference = variableReference; + subreferences = null; + decoded = false; + encodingString = null; + declarationType = null; + + if (variableReference != null) { + variableReference.setFullNameParent(this); + } + } + + public Single_ValueRedirection(final Reference variableReference, final ArrayList<ISubReference> subreferences, final boolean decoded, final Value encodingString) { + this.variableReference = variableReference; + this.subreferences = subreferences; + this.decoded = decoded; + this.encodingString = encodingString; + declarationType = null; + + if (variableReference != null) { + variableReference.setFullNameParent(this); + } + if (subreferences != null) { + for(ISubReference subreference: subreferences) { + subreference.setFullNameParent(this); + } + } + if (encodingString != null) { + encodingString.setFullNameParent(this); + } + } + + public Reference getVariableReference() { + return variableReference; + } + + public ArrayList<ISubReference> getSubreferences() { + return subreferences; + } + + public boolean isDecoded() { + return decoded; + } + + public IValue getEncodingString() { + return encodingString; + } + + public void setDeclarationType(final IType declarationType) { + this.declarationType = declarationType; + } + + public IType getDeclarationType() { + return declarationType; + } + + @Override + /** {@inheritDoc} */ + public final void setLocation(final Location location) { + this.location = location; + } + + @Override + /** {@inheritDoc} */ + public final Location getLocation() { + return location; + } + + @Override + /** {@inheritDoc} */ + public StringBuilder getFullName(final INamedNode child) { + final StringBuilder builder = super.getFullName(child); + + if (variableReference == child) { + return builder.append(".varref"); + } else if (encodingString == child) { + return builder.append(".<string_encoding>"); + } else if (subreferences != null) { + for(int i = 0; i < subreferences.size(); i++) { + final ISubReference subReference = subreferences.get(i); + + if (subReference == child) { + return builder.append(".fieldrefs.").append(i + 1); + } + } + } + + return builder; + } + + @Override + /** {@inheritDoc} */ + public void setMyScope(final Scope scope) { + super.setMyScope(scope); + + variableReference.setMyScope(scope); + if (subreferences != null) { + for(ISubReference subreference: subreferences) { + subreference.setMyScope(scope); + } + } + if (encodingString != null) { + encodingString.setMyScope(scope); + } + } + + @Override + /** {@inheritDoc} */ + public void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException { + if (isDamaged) { + throw new ReParseException(); + } + + if (variableReference != null) { + variableReference.updateSyntax(reparser, false); + reparser.updateLocation(variableReference.getLocation()); + } + if (subreferences != null) { + for(ISubReference subreference: subreferences) { + if (subreference != null) { + subreference.updateSyntax(reparser, false); + reparser.updateLocation(subreference.getLocation()); + } + } + } + if (encodingString != null) { + encodingString.updateSyntax(reparser, false); + reparser.updateLocation(encodingString.getLocation()); + } + } + + @Override + /** {@inheritDoc} */ + protected boolean memberAccept(final ASTVisitor v) { + switch (v.visit(this)) { + case ASTVisitor.V_ABORT: + return false; + case ASTVisitor.V_SKIP: + return true; + } + + if (variableReference != null && !variableReference.accept(v)) { + return false; + } + if (subreferences != null) { + for(ISubReference subreference: subreferences) { + if (subreference != null && !subreference.accept(v)) { + return false; + } + } + } + if (encodingString != null && !encodingString.accept(v)) { + return false; + } + + if (v.leave(this) == ASTVisitor.V_ABORT) { + return false; + } + + return true; + } +} diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Trigger_Port_Statement.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Trigger_Port_Statement.java index fe1330cd144335100dfe35e44ac8149c9b0a1ec9..b651c9af1debf45358f1fd02bb01a4e464ab049a 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Trigger_Port_Statement.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Trigger_Port_Statement.java @@ -47,13 +47,13 @@ public final class Trigger_Port_Statement extends Statement { private final boolean anyFrom; private final TemplateInstance receiveParameter; private final TemplateInstance fromClause; - private final Reference redirectValue; + private final Value_Redirection redirectValue; private final Reference redirectSender; private final Reference redirectIndex; private final Reference redirectTimestamp; public Trigger_Port_Statement(final Reference portReference, final boolean anyFrom, final TemplateInstance receiveParameter, final TemplateInstance fromClause, - final Reference redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { + final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { this.portReference = portReference; this.anyFrom = anyFrom; this.receiveParameter = receiveParameter; @@ -198,7 +198,7 @@ public final class Trigger_Port_Statement extends Statement { redirectValue, redirectSender, redirectIndex, redirectTimestamp); if (redirectValue != null) { - redirectValue.setUsedOnLeftHandSide(); + //redirectValue.setUsedOnLeftHandSide(); } if (redirectSender != null) { redirectSender.setUsedOnLeftHandSide(); @@ -360,7 +360,7 @@ public final class Trigger_Port_Statement extends Statement { if (redirectValue == null) { expression.expression.append("null"); } else { - redirectValue.generateCode(aData, expression); + redirectValue.generateCode(aData, expression, receiveParameter); } expression.expression.append(", "); } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Value_Redirection.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Value_Redirection.java new file mode 100644 index 0000000000000000000000000000000000000000..26a6863cca00a32375c02a6006055c6666183f54 --- /dev/null +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/statements/Value_Redirection.java @@ -0,0 +1,238 @@ +/****************************************************************************** + * Copyright (c) 2000-2018 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + ******************************************************************************/ +package org.eclipse.titan.designer.AST.TTCN3.statements; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.titan.designer.AST.ASTNode; +import org.eclipse.titan.designer.AST.ASTVisitor; +import org.eclipse.titan.designer.AST.GovernedSimple.CodeSectionType; +import org.eclipse.titan.designer.AST.ILocateableNode; +import org.eclipse.titan.designer.AST.INamedNode; +import org.eclipse.titan.designer.AST.IType; +import org.eclipse.titan.designer.AST.Location; +import org.eclipse.titan.designer.AST.NULL_Location; +import org.eclipse.titan.designer.AST.ReferenceFinder; +import org.eclipse.titan.designer.AST.ReferenceFinder.Hit; +import org.eclipse.titan.designer.AST.Scope; +import org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable; +import org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance; +import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct; +import org.eclipse.titan.designer.compiler.JavaGenData; +import org.eclipse.titan.designer.parsers.CompilationTimeStamp; +import org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException; +import org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReparseUpdater; + +/** + * Represents the value redirection of several operations. + * TODO list of operations. + * + * @author Kristof Szabados + * */ +public class Value_Redirection extends ASTNode implements ILocateableNode, IIncrementallyUpdateable { + + private ArrayList<Single_ValueRedirection> valueRedirections; + + // pointer to the type of the redirected value, not owned here + private IType valueType = null; + + /** + * Indicates whether the value redirect is restricted to only one value of + * type 'verdicttype' */ + private boolean verdictOnly = false; + + private Location location = NULL_Location.INSTANCE; + + /** the time when this was checked the last time. */ + protected CompilationTimeStamp lastTimeChecked; + + public Value_Redirection() { + valueRedirections = new ArrayList<Single_ValueRedirection>(); + } + + public void add(final Single_ValueRedirection single_ValueRedirect){ + if (single_ValueRedirect != null) { + single_ValueRedirect.setFullNameParent(this); + + valueRedirections.add(single_ValueRedirect); + } + } + + /** + * @return {@code true} if at least one of the value redirects has the + * '@decoded' modifier + */ + public boolean has_decoded_modifier() { + for (Single_ValueRedirection redirect : valueRedirections) { + if (redirect.isDecoded()) { + return true; + } + } + + return false; + } + + /** + * Attempts to identify the type of the redirected value. Only those + * single redirects are checked, which redirect the whole value, not + * just a field. If multiple whole-value-redirects of separate types are + * found, then an error is displayed. + * + * @return the found type, if any. + */ + public IType getType(final CompilationTimeStamp timestamp) { + IType returnValue = null; + for (int i = 0; i < valueRedirections.size(); i++) { + final Single_ValueRedirection redirect = valueRedirections.get(i); + + if (redirect.getSubreferences() == null) { + IType variableType = redirect.getVariableReference().checkVariableReference(timestamp); + if (variableType != null) { + if (returnValue == null) { + returnValue = variableType; + } else { + if (!returnValue.isIdentical(timestamp, variableType)) { + getLocation().reportSemanticError("The variable references the whole value is redirected to should be of the same type"); + + return null; + } + } + } + } + } + + return valueType; + } + + @Override + /** {@inheritDoc} */ + public final void setLocation(final Location location) { + this.location = location; + } + + @Override + /** {@inheritDoc} */ + public final Location getLocation() { + return location; + } + + @Override + /** {@inheritDoc} */ + public StringBuilder getFullName(final INamedNode child) { + final StringBuilder builder = super.getFullName(child); + + for (int i = 0; i < valueRedirections.size(); i++) { + final Single_ValueRedirection redirect = valueRedirections.get(i); + + if (redirect == child) { + return builder.append(".redirect_").append(i + 1); + } + } + + return builder; + } + + @Override + /** {@inheritDoc} */ + public void setMyScope(final Scope scope) { + super.setMyScope(scope); + + for (Single_ValueRedirection redirect : valueRedirections) { + redirect.setMyScope(scope); + } + } + + /** + * Sets the code_section attribute for the statements in this parameter assignment to the provided value. + * + * @param codeSection the code section where these statements should be generated. + * */ + public void setCodeSection(final CodeSectionType codeSection) { + for (Single_ValueRedirection redirect : valueRedirections) { + redirect.getVariableReference().setCodeSection(codeSection);; + } + } + + //FIXME comment + public void check(final CompilationTimeStamp timestamp, final IType type) { + if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) { + return; + } + + //FIXME implement + + lastTimeChecked = timestamp; + } + + //FIXME comment + public void checkErroneous(final CompilationTimeStamp timestamp) { + //FIXME implement + } + + //FIXME comment + public void checkVerdictOnly(final CompilationTimeStamp timestamp) { + //FIXME implement + } + + @Override + /** {@inheritDoc} */ + public void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException { + if (isDamaged) { + throw new ReParseException(); + } + + for(Single_ValueRedirection redirect : valueRedirections) { + if (redirect != null) { + redirect.updateSyntax(reparser, false); + reparser.updateLocation(redirect.getLocation()); + } + } + } + + @Override + /** {@inheritDoc} */ + public void findReferences(final ReferenceFinder referenceFinder, final List<Hit> foundIdentifiers) { + //FIXME implement + } + + @Override + /** {@inheritDoc} */ + protected boolean memberAccept(final ASTVisitor v) { + switch (v.visit(this)) { + case ASTVisitor.V_ABORT: + return false; + case ASTVisitor.V_SKIP: + return true; + } + + if (valueRedirections != null) { + for (final Single_ValueRedirection redirect : valueRedirections) { + if (!redirect.accept(v)) { + return false; + } + } + } + + if (v.leave(this) == ASTVisitor.V_ABORT) { + return false; + } + + return true; + } + + public void generateCode( final JavaGenData aData, final ExpressionStruct expression, final TemplateInstance matchedTi ) { + //FIXME implement fully + + //verdict only case + // TODO at the time being not yet filled with anything + if (valueRedirections.size() == 1) { + valueRedirections.get(0).getVariableReference().generateCode(aData, expression); + } + } +} diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/PortRedirect_Helper.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/PortRedirect_Helper.java index 1e2a266379f0270a76a526f6bc897789a2a4e461..5310a73308eb29251cc74c77cd45c6c8dc3be1c6 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/PortRedirect_Helper.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/PortRedirect_Helper.java @@ -8,6 +8,7 @@ package org.eclipse.titan.designer.parsers.ttcn3parser; import org.eclipse.titan.designer.AST.Reference; +import org.eclipse.titan.designer.AST.TTCN3.statements.Value_Redirection; import org.eclipse.titan.designer.parsers.Parser_Helper; /** @@ -15,12 +16,12 @@ import org.eclipse.titan.designer.parsers.Parser_Helper; * */ @Parser_Helper public class PortRedirect_Helper { - public Reference redirectValue; + public Value_Redirection redirectValue; public Reference redirectSender; public Reference redirectIndex; public Reference redirectTimestamp; - public PortRedirect_Helper(final Reference redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { + public PortRedirect_Helper(final Value_Redirection redirectValue, final Reference redirectSender, final Reference redirectIndex, final Reference redirectTimestamp) { this.redirectValue = redirectValue; this.redirectSender = redirectSender; this.redirectIndex = redirectIndex; diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Redirection_Helper.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Redirection_Helper.java index 2ae275c80e1084db9c67a5aad98870cfbf44f4e9..b1339c675105bda8ef6f08db28db05f7f6922e16 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Redirection_Helper.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Redirection_Helper.java @@ -9,6 +9,7 @@ package org.eclipse.titan.designer.parsers.ttcn3parser; import org.eclipse.titan.designer.AST.Reference; import org.eclipse.titan.designer.AST.TTCN3.statements.Parameter_Redirect; +import org.eclipse.titan.designer.AST.TTCN3.statements.Value_Redirection; import org.eclipse.titan.designer.parsers.Parser_Helper; /** @@ -16,13 +17,13 @@ import org.eclipse.titan.designer.parsers.Parser_Helper; * */ @Parser_Helper public class Redirection_Helper { - public Reference redirectValue; + public Value_Redirection redirectValue; public Parameter_Redirect redirectParameters; public Reference senderReference; public Reference indexReference; public Reference timestampReference; - public Redirection_Helper(final Reference redirectValue, final Parameter_Redirect redirectParameters, final Reference senderReference, + public Redirection_Helper(final Value_Redirection redirectValue, final Parameter_Redirect redirectParameters, final Reference senderReference, final Reference indexReference, final Reference timestampReference) { this.redirectValue = redirectValue; this.redirectParameters = redirectParameters; diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Ttcn3Parser.g4 b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Ttcn3Parser.g4 index c07392b7d895749cb8d66821824a86e99597eafc..9c09f8eaed0f6e99e84caebbc12884263df8c342 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Ttcn3Parser.g4 +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/Ttcn3Parser.g4 @@ -4552,7 +4552,7 @@ pr_ConfigurationStatements returns[Statement statement] @init { $statement = null; TemplateInstance doneMatch = null; - Reference reference = null; + Value_Redirection valueRedirection = null; Reference index_reference = null; }: ( s1 = pr_ConnectStatement { $statement = $s1.statement; } @@ -4563,85 +4563,85 @@ pr_ConfigurationStatements returns[Statement statement] pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? - )? { $statement = new Killed_Statement($v.value, reference, false, false, null); } //pr_KilledStatement + )? { $statement = new Killed_Statement($v.value, valueRedirection, false, false, null); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Done_Statement($v.value, doneMatch, reference, false, false, null); } //Done_Statement + { $statement = new Done_Statement($v.value, doneMatch, valueRedirection, false, false, null); } //Done_Statement ) | pr_AnyKeyword ( pr_ComponentKeyword pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Killed_Statement(null, reference, true, false, null); } //pr_KilledStatement + { $statement = new Killed_Statement(null, valueRedirection, true, false, null); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Done_Statement(null, doneMatch, reference, true, false, null); } //Done_Statement + { $statement = new Done_Statement(null, doneMatch, valueRedirection, true, false, null); } //Done_Statement ) | pr_FromKeyword cr = pr_ComponentOrDefaultReference pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } ( index = pr_IndexSpec {index_reference = $index.reference;} )? | index = pr_IndexSpec {index_reference = $index.reference;} ) )? - { $statement = new Killed_Statement($cr.value, reference, true, true, index_reference); } //pr_KilledStatement + { $statement = new Killed_Statement($cr.value, valueRedirection, true, true, index_reference); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } ( index = pr_IndexSpec {index_reference = $index.reference;} )? | index = pr_IndexSpec {index_reference = $index.reference;} ) )? - { $statement = new Done_Statement($cr.value, doneMatch, reference, true, true, index_reference); } //Done_Statement + { $statement = new Done_Statement($cr.value, doneMatch, valueRedirection, true, true, index_reference); } //Done_Statement ) ) | pr_AllKeyword pr_ComponentKeyword pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Killed_Statement(null, reference, false, false, null); } //pr_KilledStatement + { $statement = new Killed_Statement(null, valueRedirection, false, false, null); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Done_Statement(null, doneMatch, reference, false, false, null); } //Done_Statement + { $statement = new Done_Statement(null, doneMatch, valueRedirection, false, false, null); } //Done_Statement ) | s5 = pr_StopTCStatement { $statement = $s5.statement; } | s6 = pr_KillTCStatement { $statement = $s6.statement; } @@ -5379,13 +5379,13 @@ pr_PortRedirect [boolean is_any_from] returns[PortRedirect_Helper helper] @init { $helper = null; - Reference value = null; + Value_Redirection valueRedirection = null; Reference sender = null; Reference index = null; Reference timestamp = null; }: ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { value = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } ( ss = pr_SenderSpec { sender = $ss.reference; } )? ( {$is_any_from}? is = pr_IndexSpec { index = $is.reference; } )? ( ts = pr_TimestampSpec { timestamp = $ts.reference; } )? @@ -5398,24 +5398,34 @@ pr_PortRedirect [boolean is_any_from] ) ) { - $helper = new PortRedirect_Helper(value, sender, index, timestamp); + $helper = new PortRedirect_Helper(valueRedirection, sender, index, timestamp); }; pr_PortRedirectSymbol: PORTREDIRECTSYMBOL ; -pr_ValueSpec returns[Reference reference] +pr_ValueSpec returns[Value_Redirection redirection] @init { - $reference = null; + $redirection = null; }: - vss = pr_ValueStoreSpec { $reference = $vss.reference; } + vss = pr_ValueStoreSpec { + $redirection = new Value_Redirection(); + Single_ValueRedirection single = new Single_ValueRedirection($vss.reference); + single.setLocation(getLocation( $vss.start, $vss.stop)); + $redirection.add(single); + $redirection.setLocation(getLocation( $vss.start, $vss.stop)); + } | pr_ValueKeyword pr_LParen svs = pr_SingleValueSpecList pr_RParen { - $reference = $svs.reference; + $redirection = new Value_Redirection(); + for(Single_ValueRedirection singleRedirection : $svs.valueRedirections) { + $redirection.add(singleRedirection); + } + $redirection.setLocation(getLocation( $start, getStopToken())); } ; @@ -5433,37 +5443,61 @@ pr_ValueKeyword returns[String stringValue]: $stringValue = $VALUE.getText(); }; -pr_SingleValueSpecList returns[Reference reference] +pr_SingleValueSpecList returns[ArrayList<Single_ValueRedirection> valueRedirections] @init { - //TODO: fill - $reference = null; + $valueRedirections = new ArrayList<Single_ValueRedirection>(); + Single_ValueRedirection singleRedirection; }: - pr_SingleValueSpec + s1 = pr_SingleValueSpec {if($s1.singleRedirection != null) {$valueRedirections.add($s1.singleRedirection);};} ( pr_Comma - pr_SingleValueSpec + s2 = pr_SingleValueSpec {if($s2.singleRedirection != null) {$valueRedirections.add($s2.singleRedirection);};} )* ; -pr_SingleValueSpec returns[Reference reference] +pr_SingleValueSpec returns[Single_ValueRedirection singleRedirection] @init { - //TODO: fill - $reference = null; + $singleRedirection = null; + Identifier identifier; + ArrayList<ISubReference> subreferences = new ArrayList<ISubReference>(); + Value string_encoding = null; + boolean is_decoded = false; }: vr = pr_VariableRef { - $reference = $vr.reference; + $singleRedirection = new Single_ValueRedirection($vr.reference); + $singleRedirection.setLocation(getLocation( $vr.start, $vr.stop)); } -| pr_VariableRef +| vr = pr_VariableRef pr_AssignmentChar - pr_DecodedModifier? - pr_PredefOrIdentifier - pr_ExtendedFieldReference? + ( enc = pr_DecodedModifier + { + string_encoding = $enc.value; + is_decoded = $enc.is_decoded; + } + )? + POI = pr_PredefOrIdentifier {FieldSubReference field = new FieldSubReference($POI.identifier); + field.setLocation(getLocation( $POI.start, $POI.stop)); + subreferences.add(field); + } + ( sr = pr_ExtendedFieldReference + { List<ISubReference> tempSubReferences = $sr.subReferences; + if(tempSubReferences != null) { + for(ISubReference subReference2: tempSubReferences) { + subreferences.add(subReference2); + } + } + } + )? + { + $singleRedirection = new Single_ValueRedirection($vr.reference, subreferences, is_decoded, string_encoding); + $singleRedirection.setLocation(getLocation( $vr.start, $vr.stop)); + } ; -pr_PredefOrIdentifier: -( pr_Identifier -| pr_PredefinedType -| pr_NullValue +pr_PredefOrIdentifier returns[ Identifier identifier]: +( id = pr_Identifier {$identifier = $id.identifier;} +| pt = pr_PredefinedType {$identifier = new Identifier(Identifier_type.ID_TTCN, $pt.type.getTypename(), getLocation( $pt.start, $pt.stop));} +| nv = pr_NullValue {$identifier = new Identifier(Identifier_type.ID_NAME, "NULL", getLocation( $nv.start, $nv.stop));} ) ; @@ -5653,8 +5687,8 @@ pr_RedirectWithValueAndParamSpec [boolean is_any_from] returns[Redirection_Helpe }: ( ( vs = pr_ValueSpec ( h = pr_RedirectWithParamSpec[is_any_from] { $helper = $h.helper;} )? - { if ($helper == null) {$helper = new Redirection_Helper($vs.reference, null, null, null, null);} - else {$helper.redirectValue = $vs.reference;} + { if ($helper == null) {$helper = new Redirection_Helper($vs.redirection, null, null, null, null);} + else {$helper.redirectValue = $vs.redirection;} } | h = pr_RedirectWithParamSpec[is_any_from] { $helper = $h.helper;} ) @@ -6864,93 +6898,93 @@ pr_GuardOp returns[Statement statement] @init { $statement = null; TemplateInstance doneMatch = null; - Reference reference = null; + Value_Redirection valueRedirection = null; Reference index_reference = null; }: ( v = pr_ComponentOrDefaultReference pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Killed_Statement($v.value, reference, false, false, null); } //pr_KilledStatement + { $statement = new Killed_Statement($v.value, valueRedirection, false, false, null); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Done_Statement($v.value, doneMatch, reference, false, false, null); } //Done_Statement + { $statement = new Done_Statement($v.value, doneMatch, valueRedirection, false, false, null); } //Done_Statement ) | pr_AnyKeyword ( pr_ComponentKeyword pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Killed_Statement(null, reference, true, false, null); } //pr_KilledStatement + { $statement = new Killed_Statement(null, valueRedirection, true, false, null); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Done_Statement(null, doneMatch, reference, true, false, null); } //Done_Statement + { $statement = new Done_Statement(null, doneMatch, valueRedirection, true, false, null); } //Done_Statement ) | pr_FromKeyword cr = pr_ComponentOrDefaultReference pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } ( index = pr_IndexSpec {index_reference = $index.reference;} )? | index = pr_IndexSpec {index_reference = $index.reference;} ) )? - { $statement = new Killed_Statement($cr.value, reference, true, true, index_reference); } //pr_KilledStatement + { $statement = new Killed_Statement($cr.value, valueRedirection, true, true, index_reference); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } ( index = pr_IndexSpec {index_reference = $index.reference;} )? | index = pr_IndexSpec {index_reference = $index.reference;} ) )? - { $statement = new Done_Statement($cr.value, doneMatch, reference, true, true, index_reference); } //Done_Statement + { $statement = new Done_Statement($cr.value, doneMatch, valueRedirection, true, true, index_reference); } //Done_Statement ) ) | pr_AllKeyword pr_ComponentKeyword pr_Dot ( pr_KilledKeyword ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Killed_Statement(null, reference, false, false, null); } //pr_KilledStatement + { $statement = new Killed_Statement(null, valueRedirection, false, false, null); } //pr_KilledStatement | pr_DoneKeyword //pr_DoneStatement ( pr_LParen t = pr_TemplateInstance { doneMatch = $t.templateInstance; } pr_RParen )? ( pr_PortRedirectSymbol - ( vs = pr_ValueSpec { reference = $vs.reference; } + ( vs = pr_ValueSpec { valueRedirection = $vs.redirection; } )? )? - { $statement = new Done_Statement(null, doneMatch, reference, false, false, null); } //Done_Statement + { $statement = new Done_Statement(null, doneMatch, valueRedirection, false, false, null); } //Done_Statement ) | pr_AnyKeyword ( pr_TimerKeyword pr_Dot pr_TimeoutKeyword { $statement = new Timeout_Statement(null); }